Skip to content

Commit

Permalink
Customer Testing (#112)
Browse files Browse the repository at this point in the history
* updating transaction set header models to support multiple implementation versions

Signed-off-by: Dixon Whitmire <[email protected]>

* Addressed issue with Loop2130.NM1.08

Signed-off-by: Dixon Whitmire <[email protected]>

* adding missing optional fields to v5010 HI segment

Signed-off-by: Dixon Whitmire <[email protected]>

* addressing issues with Loop 2320 SBR Claim Filing Indicator

Signed-off-by: Dixon Whitmire <[email protected]>

* added missing reference codes to Loop 2330B

Signed-off-by: Dixon Whitmire <[email protected]>

* black formatting

Signed-off-by: Dixon Whitmire <[email protected]>
  • Loading branch information
dixonwhitmire authored Jan 13, 2022
1 parent 17ace15 commit 3fa2480
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 13 deletions.
12 changes: 11 additions & 1 deletion src/linuxforhealth/x12/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@
BASE_TRANSACTION_PREFIX = "linuxforhealth.x12.v"


class X12ParseException(Exception):
"""Raised when an X12 unit of work such as a transaction or segment encounters a parsing error"""

pass


def match(segment_name: str, conditions: Dict = None) -> Callable:
"""
The match decorator matches a X12 segment to a decorated function.
Expand Down Expand Up @@ -248,7 +254,11 @@ def _parse_segment(self, segment_name: str, segment_fields: List[str]) -> Dict:
# drive the mapping with segment_fields as it includes all fields within the transactional context
# field_names includes ALL available fields within the specification
for index, value in enumerate(segment_fields):
field_name: str = field_names[index]
try:
field_name: str = field_names[index]
except IndexError as ie:
msg = f"Error parsing {segment_name} segment field {index}"
raise X12ParseException(msg)

multivalue_separator: str = multivalue_fields.get(field_name)
if multivalue_separator:
Expand Down
4 changes: 4 additions & 0 deletions src/linuxforhealth/x12/v5010/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,10 @@ class HiSegment(X12Segment):
health_care_code_6: Optional[List] = Field(is_component=True)
health_care_code_7: Optional[List] = Field(is_component=True)
health_care_code_8: Optional[List] = Field(is_component=True)
health_care_code_9: Optional[List] = Field(is_component=True)
health_care_code_10: Optional[List] = Field(is_component=True)
health_care_code_11: Optional[List] = Field(is_component=True)
health_care_code_12: Optional[List] = Field(is_component=True)


class HlSegment(X12Segment):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class HeaderStSegment(StSegment):
"""

transaction_set_identifier_code: Literal["270"]
implementation_convention_reference: Literal["005010X279A1"]
implementation_convention_reference: Literal["005010X279", "005010X279A1"]


class HeaderBhtSegment(BhtSegment):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class HeaderStSegment(StSegment):
"""

transaction_set_identifier_code: Literal["271"]
implementation_convention_reference: Literal["005010X279A1"]
implementation_convention_reference: Literal["005010X279", "005010X279A1"]


class HeaderBhtSegment(BhtSegment):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HeaderStSegment(StSegment):
"""

transaction_set_identifier_code: Literal["834"]
implementation_convention_reference: Literal["005010X220A1"]
implementation_convention_reference: Literal["005010X220", "005010X220A1"]


class HeaderRefSegment(RefSegment):
Expand Down
45 changes: 41 additions & 4 deletions src/linuxforhealth/x12/v5010/x12_837_005010X222A2/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ class HeaderStSegment(StSegment):
"""

transaction_set_identifier_code: Literal["837"]
implementation_convention_reference: Literal["005010X222A2"]
implementation_convention_reference: Literal[
"005010X222", "005010X222A1", "005010X222A2"
]


class HeaderBhtSegment(BhtSegment):
Expand Down Expand Up @@ -208,6 +210,7 @@ class ClaimFilingIndicatorCode(str, Enum):
payer_responsibility_code: PayerResponsibilityCode
individual_relationship_code: Optional[Literal["18"]]
insurance_type_code: Optional[InsuranceTypeCode]
claim_filing_indicator_code: ClaimFilingIndicatorCode


class Loop2000CHlSegment(HlSegment):
Expand Down Expand Up @@ -864,7 +867,7 @@ class Loop2310BNm1Segment(Nm1Segment):
"""

entity_identifier_code: Literal["82"]
identification_code_qualifier: Literal["XX"]
identification_code_qualifier: Optional[Literal["XX"]]


class Loop2310BPrvSegment(PrvSegment):
Expand Down Expand Up @@ -1042,9 +1045,39 @@ class InsuranceTypeCode(str, Enum):
MEDICARE_SECONDARY_DISABLED_BENEFICIARY = "43"
MEDICARE_SECONDARY_LIABILITY_PRIMARY = "47"

class ClaimFilingIndicatorCode(str, Enum):
"""
Code values for SBR09
"""

OTHER_NON_FEDERAL_PROGRAMS = "11"
PPO = "12"
POS = "13"
EPO = "14"
INDEMNITY_INSURANCE = "14"
HMO_MEDICARE_RISK = "16"
DENTAL_MAINTENANCE_ORGANIZATION = "17"
AUTOMOBILE_MEDICAL = "AM"
BLUE_CROSS_BLUE_SHIELD = "BL"
CHAMPUS = "CH"
COMMERCIAL_INSURANCE_CO = "CI"
DISABILITY = "DS"
FEDERAL_EMPLOYEE_PROGRAM = "FI"
HEALTH_MAINTENANCE_ORGANIZATION = "HM"
LIBABILITY_MEDICAL = "LM"
MEDICARE_PART_A = "MA"
MEDICARE_PART_B = "MB"
MEDICAID = "MC"
OTHER_FEDERAL_PROGRAM = "OF"
TITLE_V = "TV"
VETERANS_AFFAIR_PLAN = "VA"
WORKERS_COMPENSATION_HEALTH_CLAIM = "WC"
MUTUALLY_DEFINED = "ZZ"

payer_responsibility_code: PayerResponsibilityCode
individual_relationship_code: Optional[IndividualRelationshipCode]
claim_filing_indicator_code: InsuranceTypeCode
insurance_type_code: Optional[InsuranceTypeCode]
claim_filing_indicator_code: ClaimFilingIndicatorCode


class Loop2330aNm1Segment(Nm1Segment):
Expand Down Expand Up @@ -1110,10 +1143,14 @@ class ReferenceIdentificationQualifier(str, Enum):
Code values for REF01
"""

PAYOR_IDENTIFICATION = "PI"
PAYOR_IDENTIFICATION_NUMBER = "2U"
EMPLOYER_IDENTIFICATION_NUMBER = "EI"
CLAIM_OFFICE_NUMBER = "FY"
NAIC_CODE = "NF"
PRIOR_AUTHORIZATION_NUMBER = "G1"
REFERRAL_NUMBER = "9F"
SIGNAL_CODE = "T4"
ORIGINAL_REFERENCE_NUMBER = "F8"

reference_identification_qualifier: ReferenceIdentificationQualifier

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class HeaderStSegment(StSegment):
"""

transaction_set_identifier_code: Literal["837"]
implementation_convention_reference: Literal["005010X223A3"]
implementation_convention_reference: Literal[
"005010X223", "005010X223A1", "005010X223A2", "005010X223A3"
]


class HeaderBhtSegment(BhtSegment):
Expand Down
17 changes: 13 additions & 4 deletions src/tests/test_5010_segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,12 +354,21 @@ def test_hd_segment():

def test_hi_segment():
segment_data = {
"health_care_code_1": ["BK", "8901"],
"health_care_code_2": ["BF", "87200"],
"health_care_code_3": ["BF", "5559"],
"health_care_code_1": ["ABK", "M2578"],
"health_care_code_2": ["ABF", "M4802"],
"health_care_code_3": ["ABF", "M5023"],
"health_care_code_4": ["ABF", "M5136"],
"health_care_code_5": ["ABF", "M4126"],
"health_care_code_6": ["ABF", "M4316"],
"health_care_code_7": ["ABF", "M5416"],
"health_care_code_8": ["ABF", "M5030"],
"health_care_code_9": ["ABF", "M5412"],
}
hi_segment: HiSegment = HiSegment(**segment_data)
assert hi_segment.x12() == "HI*BK:8901*BF:87200*BF:5559~"
assert (
hi_segment.x12()
== "HI*ABK:M2578*ABF:M4802*ABF:M5023*ABF:M5136*ABF:M4126*ABF:M4316*ABF:M5416*ABF:M5030*ABF:M5412~"
)


def test_hl_segment():
Expand Down

0 comments on commit 3fa2480

Please sign in to comment.