Search in sources :

Example 6 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testForDataBleedFromPatientToOrganization.

@Test
// Ensure that Patient data does not bleed into Organizations created for the Patient's insurance
void testForDataBleedFromPatientToOrganization() throws IOException {
    String hl7message = "MSH|^~\\&|TEST|TEST|||20220101120000||ADT^A01^ADT_A01|1234|P|2.6\n" + // PID.12 Used for district calculation
    "PID|1|103456|MR12345678^^^^MR||DOE^JANE^|||F|||19 Raymond St^Route3^Albany^NY^56321^USA^P|12||||||||||||||||||||||||||\n" + // PD1.4 Used for org creation to check for bleed of districts
    "PD1|||Mayo|123456^Walt^^^^Dr||||||||||||||||||\n" + // IN1 Broadly populated to create organization
    "IN1|1|GLOBAL|7776664|Blue Cross Blue Shield|456 Blue Cross Lane||||Blue|987123|IBM||||||NON||||||||||||20210322145350|Dr Disney|S|GOOD|200|12|B6543|H789456|||17|||1|M|123 IBM way|True|NONE|B|NO|J321456|M|20210322145605|London|YES\n" + // IN2 Broadly populated to create organizations
    "IN2|A23456|222001111|IBM 1345|EMPLOYEED|E|N23497234|R3294809|S234234|Army|U439823|SGT SCHULTZ|Army|Fort Wayne|USA|E1... E9|ACT|20300402145954|N|N|N|Yes|Grey Duck|Goose|T34941341232|D123123123|C435435345|2|SPR|2ANC|1234.00|O|A0|USA|EN|F|F|Y|N|COG|Stanley|DUTCH|N|M|20170322150208||Software Engineer|8|P|Mr Blue|1-555-333-4444|SURGERY|Jim Stanley|1-555-222-3333|FIRST|20170202150409|20210322150400|3|1-222-333-4444|GLOBAL|GROUP|B14456789|OTH|1-444-777-8888|1-444-555-3333|NONE|N|Y|N|GVH 123456|CDP 98765|2106-3|9\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // From PID
    assertThat(patients).hasSize(1);
    Patient patient = (Patient) patients.get(0);
    assertThat(patient.getAddressFirstRep().getDistrict()).hasToString("12");
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // From Payor created by IN1
    assertThat(organizations).hasSize(3);
    Organization org = (Organization) organizations.get(0);
    assertThat(org.getAddressFirstRep().hasDistrict()).isFalse();
    org = (Organization) organizations.get(1);
    assertThat(org.hasAddress()).isFalse();
    org = (Organization) organizations.get(2);
    assertThat(org.hasAddress()).isFalse();
    List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
    // From IN1 segment
    assertThat(coverages).hasSize(1);
    Coverage coverage = (Coverage) coverages.get(0);
    // Confirm Coverage Identifiers
    assertThat(coverage.getIdentifier()).hasSize(6);
    // Coverage Identifiers deep check in testBasicInsuranceCoverageFields
    // Because the relationship is NON, no subscriber is created
    assertThat(coverage.hasSubscriber()).isFalse();
    // Expect no RelatedPerson because IN1.17 is NON
    List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
    // No related person should be created because IN1.17 was an unknown code
    assertThat(relatedPersons).isEmpty();
    // Confirm there are no unaccounted for resources
    // Expected: Coverage, Organization (3), Patient, Practitioner
    assertThat(e).hasSize(6);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Organization(org.hl7.fhir.r4.model.Organization) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testInsuranceCoverageOfSelfAndTenant.

// Suppress warnings about too many assertions in a test.  Justification: creating a FHIR message is very costly; we need to check many asserts per creation for efficiency.
@java.lang.SuppressWarnings("squid:S5961")
@Test
// Tests multiple Organization Id's created with a TENANT prepend.
void testInsuranceCoverageOfSelfAndTenant() throws IOException {
    String hl7message = "MSH|^~\\&|||||20151008111200||DFT^P03^DFT_P03|MSGID000001|T|2.6|||||||||\n" + "EVN||20210407191342||||||\n" + // PID.19 purposely empty so IN2.2 used as SSN PatientIdentifier
    "PID|||MR1^^^XYZ^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + // FT1.7 is required transaction code (currently not used)
    "FT1||||20201231145045||CG|FAKE|||||||||||||||||||||||||||||||||||||\n" + // IN1.2.4, IN1.2.6 to second XV Coverage.identifier
    "IN1|1|Value1^^System3^Value4^^System6" + // IN1.5 to 15 NOT REFERENCED (Tested in testBasicInsuranceCoverageFields)
    "|IdValue1^^^IdSystem4^^^^|Large Blue Organization|||||||||||" + // IN1.18 through IN1.35 NOT REFERENCED
    "||SEL||||||||||||||||||" + // IN1.47 through IN1.53 NOT REFERENCED
    "|MEMBER36||||||||||Value46|||||||\n" + // Only used for MB Patient.Identifier because subscriber is SELF
    "IN2||SSN123456|||||||||||||||||||||||IdValue25.1^^^IdSystem25.4^IdType25.5^^20201231145045^20211231145045|||||||||||||||||||||||||||||||||||||||||||" + // IN2.72 is purposely empty (backup to IN1.17) so no RelatedPerson is created.
    "|Name69.1^^^^^IdSystem69.6^XX^^^IdValue69.10||\n";
    // TENANT prepend is passed through the options.
    ConverterOptions customOptionsWithTenant = new Builder().withValidateResource().withPrettyPrint().withProperty("TENANT", "TenantId").build();
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message, customOptionsWithTenant);
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // From PV1
    assertThat(encounters).hasSize(1);
    List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // From PID
    assertThat(patients).hasSize(1);
    Patient patient = (Patient) patients.get(0);
    String patientId = patient.getId();
    // Check Patient.identifiers
    // From PID.3, IN2.2 and IN1.36
    assertThat(patient.getIdentifier()).hasSize(3);
    Identifier patientIdentifier = patient.getIdentifier().get(0);
    // PID.3.1
    assertThat(patientIdentifier.getValue()).isEqualTo("MR1");
    // PID.3.4
    assertThat(patientIdentifier.getSystem()).isEqualTo("urn:id:XYZ");
    DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "MR", "Medical record number", "http://terminology.hl7.org/CodeSystem/v2-0203", // PID.3.5
    null);
    patientIdentifier = patient.getIdentifier().get(1);
    // IN1.36 backup to IN2.61, active because subscriber is SELF
    assertThat(patientIdentifier.getValue()).isEqualTo("MEMBER36");
    // No system for MB
    assertThat(patientIdentifier.hasSystem()).isFalse();
    DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "MB", "Member Number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    patientIdentifier = patient.getIdentifier().get(2);
    // IN2.2
    assertThat(patientIdentifier.getValue()).isEqualTo("SSN123456");
    // No system for SSN
    assertThat(patientIdentifier.hasSystem()).isFalse();
    DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "SS", "Social Security number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // From Payor created by IN1, PayorId Organization (IN2.25), and PolcyHolder Organization Name (IN2.69)
    assertThat(organizations).hasSize(3);
    Organization org = (Organization) organizations.get(0);
    String payorOrgId = org.getId();
    // IN1.17.1 w/TENANT prepend (Id's lowercased)
    assertThat(payorOrgId).isEqualTo("Organization/tenantid.idvalue1");
    // Check organization Identifier's
    // IN1.4
    assertThat(org.getName()).isEqualTo("Large Blue Organization");
    assertThat(org.getIdentifier()).hasSize(1);
    Identifier orgIdentifier = org.getIdentifierFirstRep();
    // IN1.3.1
    assertThat(orgIdentifier.getValue()).isEqualTo("IdValue1");
    // IN1.3.4
    assertThat(orgIdentifier.getSystem()).isEqualTo("urn:id:IdSystem4");
    // IN1.3.7 & IN1.3.7 empty
    assertThat(orgIdentifier.hasPeriod()).isFalse();
    // IN1.3.5 empty
    assertThat(orgIdentifier.hasType()).isFalse();
    // Check PayorId Organization from IN2.25
    org = (Organization) organizations.get(1);
    String payorOrgIdIn25 = org.getId();
    // IN1.25.1 w/TENANT prepend (Id's lowercased)
    assertThat(payorOrgIdIn25).isEqualTo("Organization/tenantid.idvalue25.1");
    // IN2.25.1
    assertThat(org.getName()).isEqualTo("IdValue25.1");
    assertThat(org.getIdentifier()).hasSize(1);
    orgIdentifier = org.getIdentifier().get(0);
    // IN2.25.1
    assertThat(orgIdentifier.getValue()).isEqualTo("IdValue25.1");
    // IN2.25.4
    assertThat(orgIdentifier.getSystem()).isEqualTo("urn:id:IdSystem25.4");
    // IN2.25.7
    assertThat(orgIdentifier.getPeriod().getStartElement().toString()).containsPattern("2020-12-31T14:50:45");
    // IN2.25.8
    assertThat(orgIdentifier.getPeriod().getEndElement().toString()).containsPattern("2021-12-31T14:50:45");
    // IN2.25.5
    DatatypeUtils.checkCommonCodeableConceptAssertions(orgIdentifier.getType(), "IdType25.5", null, null, null);
    // Check PolicyHolder Organization Name and ID Organization from IN2.69
    org = (Organization) organizations.get(2);
    String policyHolderOrgId = org.getId();
    // IN2.69.1 w/TENANT prepend (Id's lowercased)
    assertThat(policyHolderOrgId).isEqualTo("Organization/tenantid.idvalue69.10");
    // IN2.69.1
    assertThat(org.getName()).isEqualTo("Name69.1");
    assertThat(org.getIdentifier()).hasSize(1);
    orgIdentifier = org.getIdentifier().get(0);
    // IN2.69.10
    assertThat(orgIdentifier.getValue()).isEqualTo("IdValue69.10");
    // IN2.69.6
    assertThat(orgIdentifier.getSystem()).isEqualTo("urn:id:IdSystem69.6");
    // Becuase the code is known, the 0203 table lookup is successful and returns code, display, and system
    DatatypeUtils.checkCommonCodeableConceptAssertions(orgIdentifier.getType(), "XX", "Organization identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", // IN2.69.7 with lookup
    null);
    List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
    // From IN1 segment
    assertThat(coverages).hasSize(1);
    Coverage coverage = (Coverage) coverages.get(0);
    // Confirm Coverage Identifiers
    // XV, XV, XV, MB, SN
    assertThat(coverage.getIdentifier()).hasSize(5);
    // Coverage Identifiers deep check in testBasicInsuranceCoverageFields
    // Confirm Coverage Subscriber references to Patient
    assertThat(coverage.getSubscriber().getReference()).isEqualTo(patientId);
    // Confirm Coverage Beneficiary references to Patient, and Payors references correct Organizations
    assertThat(coverage.getBeneficiary().getReference()).isEqualTo(patientId);
    // One for each payorOrganization
    assertThat(coverage.getPayor()).hasSize(2);
    assertThat(coverage.getPayor().get(0).getReference()).isEqualTo(payorOrgId);
    assertThat(coverage.getPayor().get(1).getReference()).isEqualTo(payorOrgIdIn25);
    // Confirm policyHolder references correct organization
    assertThat(coverage.getPolicyHolder().getReference()).isEqualTo(policyHolderOrgId);
    // Expect no RelatedPerson because IN1.17 was self
    List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
    // No related person should be created because IN1.17 was SEL
    assertThat(relatedPersons).isEmpty();
    // Check coverage.relationship (from SubscriberRelationship mapping)
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getRelationship(), "self", "Self", "http://terminology.hl7.org/CodeSystem/subscriber-relationship", // IN1.17
    null);
    // Confirm there are no unaccounted for resources
    // Expected: Coverage, Organization (3x), Patient, Encounter
    assertThat(e).hasSize(6);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Organization(org.hl7.fhir.r4.model.Organization) ConverterOptions(io.github.linuxforhealth.hl7.ConverterOptions) Builder(io.github.linuxforhealth.hl7.ConverterOptions.Builder) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 8 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testInsuranceCoverageOfWorkersComp.

@Test
// Tests non-related subscriber, employer.
void testInsuranceCoverageOfWorkersComp() throws IOException {
    String hl7message = "MSH|^~\\&|TEST|TEST|||20220101120000||DFT^P03|1234|P|2.6\n" + // + "EVN||20210407191342||||||\n"
    "PID|||workers_comp^^^XYZ^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + // FT1.7 is required transaction code (currently not used)
    "FT1||||20201231145045||CG|FAKE|||||||||||||||||||||||||||||||||||||\n" + // IN1.2.4, IN1.2.6 to second XV Coverage.identifier
    "IN1|1|Value1^^System3^Value4^^System6" + // IN1.5 through 15 NOT REFERENCED (Tested in testBasicInsuranceCoverageFields)
    "|IdValue1^^^IdSystem4^^^^|Large Blue Organization|||||||||||" + // IN1.18 through IN1.35 NOT REFERENCED
    "||EMR||||||||||||||||||" + // IN1.37 through IN1.53 NOT REFERENCED
    "|MEMBER36|||||||||||||J321456||||\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // From PV1
    assertThat(encounters).hasSize(1);
    List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // From PID
    assertThat(patients).hasSize(1);
    Patient patient = (Patient) patients.get(0);
    String patientId = patient.getId();
    // No patient identifier should have value IN1.49 "J321456" because relationship is not SEL (self)
    // Finding exactly 1 expected identifier "workers_comp" proves not "J321456"
    assertThat(patient.getIdentifier()).hasSize(1);
    assertThat(patient.getIdentifierFirstRep().getValueElement()).hasToString("workers_comp");
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // From Payor created by IN1
    assertThat(organizations).hasSize(1);
    Organization org = (Organization) organizations.get(0);
    // Check organization Id's
    assertThat(org.getIdentifier()).hasSize(1);
    // Org identifiers checked deeply in other tests
    List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
    // From IN1 segment
    assertThat(coverages).hasSize(1);
    Coverage coverage = (Coverage) coverages.get(0);
    // Confirm Coverage Identifiers
    // XV, XV, MB, SN
    assertThat(coverage.getIdentifier()).hasSize(4);
    // Coverage Identifiers deep check in testBasicInsuranceCoverageFields
    // Because the relationship is EMR (Employer), no subscriber is created (subscriber can't be an Organization)
    assertThat(coverage.hasSubscriber()).isFalse();
    // Confirm Coverage Beneficiary references to Patient, and Payor references to Organization
    assertThat(coverage.getBeneficiary().getReference()).isEqualTo(patientId);
    assertThat(coverage.getPayorFirstRep().getReference()).isEqualTo(organizations.get(0).getId());
    // Expect no RelatedPerson because IN1.17 was EMR
    List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
    // No related person should be created because IN2.72 was 01 (self)
    assertThat(relatedPersons).isEmpty();
    // Check coverage.relationship (from SubscriberRelationship mapping)
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getRelationship(), "EMR", null, null, // IN1.17, because it is not mapped there is no system or display.
    null);
    // Confirm there are no unaccounted for resources
    // Expected: Coverage, Organization, Patient, Encounter
    assertThat(e).hasSize(4);
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Organization(org.hl7.fhir.r4.model.Organization) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 9 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testInsuranceCoverageFromIN2.

@Test
// Tests empty IN2.63 missing telecom.
void testInsuranceCoverageFromIN2() throws IOException {
    String hl7message = "MSH|^~\\&|||||20151008111200||ADT^A01^ADT_A01|MSGID000001|T|2.6|||||||||\n" + "EVN||20210407191342||||||\n" + "PID|||MR1^^^XYZ^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + // FT1.7 is required transaction code (currently not used)
    "FT1||||20201231145045||CG|FAKE|||||||||||||||||||||||||||||||||||||\n" + // IN1.2.4, IN1.2.6 to second XV Coverage.identifier
    "IN1|1|Value1^^System3^Value4^^System6" + // IN1.5 to 15 NOT REFERENCED (See test testBasicInsuranceCoverageFields)
    "|IdValue1^^^IdSystem4^^^^|Large Blue Organization|||||||||||" + // IN1.18 through IN1.35 NOT REFERENCED
    "|DoeFake^Judy^^^Rev.|||||||||||||||||||" + // IN1.37 through IN1.53 NOT REFERENCED
    "|MEMBER36|||||||||||||||||\n" + // IN2.63 purposely empty to ensure an empty telecom is not created.
    "IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" + // IN2.72 to Coverage.relationship and RelatedPerson.relationship.  (Backup for IN1.17) Codes from table 0344
    "04|\n";
    // 04 = Natural child
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    // From PV1
    assertThat(encounters).hasSize(1);
    List<Resource> patients = ResourceUtils.getResourceList(e, ResourceType.Patient);
    // From PID
    assertThat(patients).hasSize(1);
    Patient patient = (Patient) patients.get(0);
    String patientId = patient.getId();
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // From Payor created by IN1
    assertThat(organizations).hasSize(1);
    List<Resource> coverages = ResourceUtils.getResourceList(e, ResourceType.Coverage);
    // From IN1 segment
    assertThat(coverages).hasSize(1);
    Coverage coverage = (Coverage) coverages.get(0);
    // Confirm Coverage Identifiers
    // XV, XV, MB, SN
    assertThat(coverage.getIdentifier()).hasSize(4);
    // Coverage Identifiers deep check in testBasicInsuranceCoverageFields
    // Confirm Coverage Beneficiary references to Patient, and Payor references to Organization
    assertThat(coverage.getBeneficiary().getReference()).isEqualTo(patientId);
    assertThat(coverage.getPayorFirstRep().getReference()).isEqualTo(organizations.get(0).getId());
    // Expect one RelatedPerson
    List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
    // From IN2.72
    assertThat(relatedPersons).hasSize(1);
    RelatedPerson related = (RelatedPerson) relatedPersons.get(0);
    // Because IN2.63 is empty
    assertThat(related.hasTelecom()).isFalse();
    assertThat(related.getName()).hasSize(1);
    HumanName relatedName = related.getName().get(0);
    // Simplified name test.  Deeper tests in other tests.
    // from IN1.16 aggregate
    assertThat(relatedName.getText()).isEqualTo("Rev. Judy DoeFake");
    // Check coverage relationship
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getRelationship(), "child", "Child", "http://terminology.hl7.org/CodeSystem/subscriber-relationship", // IN2.72 (04 = Natural child)
    null);
    // Check relatedPerson relationship
    assertThat(related.getRelationship()).hasSize(1);
    DatatypeUtils.checkCommonCodeableConceptAssertions(related.getRelationship().get(0), "PRN", "parent", "http://terminology.hl7.org/CodeSystem/v3-RoleCode", // IN2.72 (04 = Natural child)
    null);
    // Confirm the Coverage (subscriber) references the RelatedPerson
    assertThat(coverage.getSubscriber().getReference()).isEqualTo(related.getId());
    // Confirm the RelatedPerson references the Patient
    assertThat(related.getPatient().getReference()).isEqualTo(patientId);
    // Confirm there are no unaccounted for resources
    // Expected: Coverage, Organization, Patient, Encounter, RelatedPerson
    assertThat(e).hasSize(5);
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Patient(org.hl7.fhir.r4.model.Patient) Coverage(org.hl7.fhir.r4.model.Coverage) RelatedPerson(org.hl7.fhir.r4.model.RelatedPerson) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 10 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7AddressFHIRConversionTest method patient_address_date_ranges_test.

@Test
void patient_address_date_ranges_test() {
    String patientAddress = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Moose^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|111 1st Street^Suite #1^Minneapolis^MN^11111^USA^H^^AdrC^^^20010101&20081231^^^^Y^Z^V^c/o Pluto19|PatC|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|||USA||||\n";
    String patientAddressExplicitEffectiveExpirationDates = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + "PID|1||12345678^^^^MR|ALTID|Moose^Mickey^J^III^^^|Mother^Micky|20060504|M|Alias^Alias|2106-3^White^ HL70005|111 1st Street^Suite #1^Minneapolis^MN^11111^USA^H^^AdrC^^^20010101&20081231^19920101^19981231^^Y^Z^V^c/o Pluto19|PatC|^PRN^^^PH^555^5555555|^PRN^^^PH^555^666666|english|married|bhuddist|1234567_account|111-22-3333|||2186-5^not Hispanic or Latino^CDCREC|Born in USA|||USA||||\n";
    // If address county, ignore patient county
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientAddress);
    assertThat(patient.hasAddress()).isTrue();
    List<Address> addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(1);
    Address address = addresses.get(0);
    // Test date range
    Period period = address.getPeriod();
    assertThat(period.hasStart()).isTrue();
    assertThat(period.hasEnd()).isTrue();
    Date startDate = period.getStart();
    Calendar startCalendar = Calendar.getInstance();
    startCalendar.setTime(startDate);
    assertThat(startCalendar.get(Calendar.YEAR)).isEqualTo(2001);
    // Zero based; January is 0
    assertThat(startCalendar.get(Calendar.MONTH)).isZero();
    assertThat(startCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(1);
    Date endDate = period.getEnd();
    Calendar endCalendar = Calendar.getInstance();
    endCalendar.setTime(endDate);
    assertThat(endCalendar.get(Calendar.YEAR)).isEqualTo(2008);
    // Zero based; December is 11
    assertThat(endCalendar.get(Calendar.MONTH)).isEqualTo(11);
    assertThat(endCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(31);
    // Test explicit date start (effective) and end (expiration)
    patient = PatientUtils.createPatientFromHl7Segment(ftv, patientAddressExplicitEffectiveExpirationDates);
    assertThat(patient.hasAddress()).isTrue();
    addresses = patient.getAddress();
    assertThat(addresses.size()).isEqualTo(1);
    address = addresses.get(0);
    period = address.getPeriod();
    assertThat(period.hasStart()).isTrue();
    assertThat(period.hasEnd()).isTrue();
    startDate = period.getStart();
    startCalendar = Calendar.getInstance();
    startCalendar.setTime(startDate);
    assertThat(startCalendar.get(Calendar.YEAR)).isEqualTo(1992);
    // Zero based; January is 0
    assertThat(startCalendar.get(Calendar.MONTH)).isZero();
    assertThat(startCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(1);
    endDate = period.getEnd();
    endCalendar = Calendar.getInstance();
    endCalendar.setTime(endDate);
    assertThat(endCalendar.get(Calendar.YEAR)).isEqualTo(1998);
    // Zero based; December is 11
    assertThat(endCalendar.get(Calendar.MONTH)).isEqualTo(11);
    assertThat(endCalendar.get(Calendar.DAY_OF_MONTH)).isEqualTo(31);
}
Also used : Address(org.hl7.fhir.r4.model.Address) Calendar(java.util.Calendar) Patient(org.hl7.fhir.r4.model.Patient) Period(org.hl7.fhir.r4.model.Period) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Aggregations

Test (org.junit.jupiter.api.Test)126 Resource (org.hl7.fhir.r4.model.Resource)86 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)83 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)58 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)40 Patient (org.hl7.fhir.r4.model.Patient)36 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)35 Identifier (org.hl7.fhir.r4.model.Identifier)30 Bundle (org.hl7.fhir.r4.model.Bundle)29 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)22 Immunization (org.hl7.fhir.r4.model.Immunization)19 Encounter (org.hl7.fhir.r4.model.Encounter)18 Coding (org.hl7.fhir.r4.model.Coding)16 Observation (org.hl7.fhir.r4.model.Observation)15 Organization (org.hl7.fhir.r4.model.Organization)15 ServiceRequest (org.hl7.fhir.r4.model.ServiceRequest)15 ValueSource (org.junit.jupiter.params.provider.ValueSource)14 ResourceModel (io.github.linuxforhealth.api.ResourceModel)13 Reference (org.hl7.fhir.r4.model.Reference)13 Extension (org.hl7.fhir.r4.model.Extension)11