Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove x12 delimiter from segment group and segment data models #113

Merged
merged 1 commit into from
Jan 14, 2022
Merged

Remove x12 delimiter from segment group and segment data models #113

merged 1 commit into from
Jan 14, 2022

Conversation

dixonwhitmire
Copy link
Member

@dixonwhitmire dixonwhitmire commented Jan 14, 2022

This PR removes the "delimiters" field from the X12SegmentGroup and X12Segment models. "delimiters" are removed as there aren't part of the data payload, but rather metadata which drives x12 output and transformation.

(venv) mbp x12 % lfhx12 -m -p -x  demo-file/demo.270
[
    {
        "header": {
            "st_segment": {
                "segment_name": "ST",
                "transaction_set_identifier_code": "270",
                "transaction_set_control_number": "1234",
                "implementation_convention_reference": "005010X279A1"
            },
            "bht_segment": {
                "segment_name": "BHT",
                "hierarchical_structure_code": "0022",
                "transaction_set_purpose_code": "13",
                "submitter_transactional_identifier": "10001234",
                "transaction_set_creation_date": "2006-05-01",
                "transaction_set_creation_time": "1319"
            }
        },
        "loop_2000a": [
            {
                "hl_segment": {
                    "segment_name": "HL",
                    "hierarchical_id_number": "1",
                    "hierarchical_level_code": "20",
                    "hierarchical_child_code": "1"
                },
                "loop_2100a": {
                    "nm1_segment": {
                        "segment_name": "NM1",
                        "entity_identifier_code": "PR",
                        "entity_type_qualifier": "2",
                        "name_last_or_organization_name": "ABC COMPANY",
                        "identification_code_qualifier": "PI",
                        "identification_code": "842610001"
                    }
                },
                "loop_2000b": [
                    {
                        "hl_segment": {
                            "segment_name": "HL",
                            "hierarchical_id_number": "2",
                            "hierarchical_parent_id_number": "1",
                            "hierarchical_level_code": "21",
                            "hierarchical_child_code": "1"
                        },
                        "loop_2100b": {
                            "nm1_segment": {
                                "segment_name": "NM1",
                                "entity_identifier_code": "1P",
                                "entity_type_qualifier": "2",
                                "name_last_or_organization_name": "BONE AND JOINT CLINIC",
                                "identification_code_qualifier": "SV",
                                "identification_code": "2000035"
                            },
                            "ref_segment": []
                        },
                        "loop_2000c": [
                            {
                                "hl_segment": {
                                    "segment_name": "HL",
                                    "hierarchical_id_number": "3",
                                    "hierarchical_parent_id_number": "2",
                                    "hierarchical_level_code": "22",
                                    "hierarchical_child_code": "0"
                                },
                                "trn_segment": [
                                    {
                                        "segment_name": "TRN",
                                        "trace_type_code": "1",
                                        "reference_identification_1": "93175-012547",
                                        "originating_company_identifier": "9877281234"
                                    }
                                ],
                                "loop_2100c": {
                                    "nm1_segment": {
                                        "segment_name": "NM1",
                                        "entity_identifier_code": "IL",
                                        "entity_type_qualifier": "1",
                                        "name_last_or_organization_name": "SMITH",
                                        "name_first": "ROBERT",
                                        "identification_code_qualifier": "MI",
                                        "identification_code": "11122333301"
                                    },
                                    "ref_segment": [],
                                    "dmg_segment": {
                                        "segment_name": "DMG",
                                        "date_time_period_format_qualifier": "D8",
                                        "date_time_period": "1943-05-19"
                                    },
                                    "dtp_segment": {
                                        "segment_name": "DTP",
                                        "date_time_qualifier": "291",
                                        "date_time_period_format_qualifier": "D8",
                                        "date_time_period": "2006-05-01"
                                    },
                                    "loop_2110c": {
                                        "eq_segment": {
                                            "segment_name": "EQ",
                                            "service_type_code": [
                                                "30"
                                            ]
                                        },
                                        "amt_segment": []
                                    }
                                }
                            }
                        ]
                    }
                ]
            }
        ],
        "footer": {
            "se_segment": {
                "segment_name": "SE",
                "transaction_segment_count": 13,
                "transaction_set_control_number": "1234"
            }
        }
    }
]

The X12SegmentGroup.x12() method now supports a custom_delimiters parameter which allows a client to pass customer delimiters if needed

    with X12ModelReader(x12_with_custom_delimiters) as r:
        model_result = [m for m in r.models()]
        assert len(model_result) == 1
        assert (
            model_result[0].x12(custom_delimiters=x12_delimiters)
            == expected_transaction
        )

Signed-off-by: Dixon Whitmire dixonwh@gmail.com
closes #35

Signed-off-by: Dixon Whitmire <dixonwh@gmail.com>
@dixonwhitmire dixonwhitmire changed the title Removed x12 delimiter from segment group and segment data models Remove x12 delimiter from segment group and segment data models Jan 14, 2022
@dixonwhitmire dixonwhitmire merged commit 00e07e3 into LinuxForHealth:main Jan 14, 2022
@dixonwhitmire dixonwhitmire deleted the delimiter-exclusion branch January 14, 2022 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Upgrade to Pydantic 1.9 to Support Delimiter Exclusion Via Model Config
1 participant