Search in sources :

Example 91 with Patient

use of org.hl7.fhir.r4.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class FHIRExtensionsTest method testTextOnlyReligion.

@Test
void testTextOnlyReligion() {
    String patientWithDataForExtensions = "MSH|^~\\&|MIICEHRApplication|MIIC|MIIC|MIIC|201705130822||VXU^V04^VXU_V04|test1100|P|2.5.1|||AL|AL|||||Z22^CDCPHINVS|^^^^^MIIC^SR^^^MIIC|MIIC\n" + // Test text only religion
    "PID|1||12345678^^^^MR||Jane^TestPatientLastName||||||||||||Methodist|\n";
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientWithDataForExtensions);
    assertThat(patient.hasExtension()).isTrue();
    Extension ext = patient.getExtensionByUrl(UrlLookup.getExtensionUrl("religion"));
    assertThat(ext).isNotNull();
    CodeableConcept cc = (CodeableConcept) ext.getValue();
    assertThat(cc.hasCoding()).isTrue();
    assertThat(cc.hasText()).isFalse();
    Coding coding = cc.getCodingFirstRep();
    assertThat(coding).isNotNull();
    assertThat(coding.hasCode()).isFalse();
    String theSystem = V3ReligiousAffiliation._1029.getSystem();
    assertThat(coding.hasSystem()).isTrue();
    assertThat(coding.getSystem()).isEqualTo(theSystem);
    assertThat(coding.hasDisplay()).isTrue();
    assertThat(coding.getDisplay()).containsPattern("Invalid.*Methodist.*" + theSystem);
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Coding(org.hl7.fhir.r4.model.Coding) Patient(org.hl7.fhir.r4.model.Patient) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Example 92 with Patient

use of org.hl7.fhir.r4.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testInsuranceCoverageByRelatedFields.

// 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")
@ParameterizedTest
// The breadth of this test is sufficent for multiple message type coverage, so other tests are not parameterized.
@ValueSource(strings = { "DFT^P03^DFT_P03", "VXU^V04^VXU_V04", "ADT^A01^ADT_A01", "ADT^A03^ADT_A03", // ADT^A04 uses structure ADT_A01
"ADT^A04^ADT_A01", // ADT^A08 uses structure ADT_A01
"ADT^A08^ADT_A01", // ADT^A28 uses structure ADT_A05
"ADT^A28^ADT_A05", // ADT^A31 uses structure ADT_A05
"ADT^A31^ADT_A05" })
// Also test IN2.2 Social Security number
void testInsuranceCoverageByRelatedFields(String messageType) throws IOException {
    String hl7message = "MSH|^~\\&|||||20151008111200||" + messageType + "|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.23 through IN1.35 NOT REFERENCED
    "|DoeFake^Judy^^^Rev.|PAR|19780429|19 Rose St^^Faketown^CA^ZIP5||||||||||||||||" + // IN1.50 through IN1.53 NOT REFERENCED
    "|MEMBER36|||||||F|||Value46|||J494949^^^Large HMO^XX||||\n" + // IN2.9 through IN2.60 not used
    "IN2||777-88-9999||||MEDICARE06||MEDICAID08|| |||||||||| ||||||||||| |||||||||| |||||||||| ||||||||||" + // IN2.63.18 to Organization Contact telecom .rank
    "MEMBER61||^^^^^555^7677777^^^^^^20201231145045^20211231145045^^^^1|";
    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();
    // From PID.3, IN1.49, IN2.6, IN2.8
    assertThat(patient.getIdentifier()).hasSize(4);
    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.49.1
    assertThat(patientIdentifier.getValue()).isEqualTo("J494949");
    // IN1.49.4
    assertThat(patientIdentifier.getSystem()).isEqualTo("urn:id:Large_HMO");
    DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "XX", null, "http://terminology.hl7.org/CodeSystem/v2-0203", // IN1.49.5
    null);
    patientIdentifier = patient.getIdentifier().get(2);
    // IN2.8
    assertThat(patientIdentifier.getValue()).isEqualTo("MEDICAID08");
    // No system for IN2.8
    assertThat(patientIdentifier.hasSystem()).isFalse();
    DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "MA", "Patient Medicaid number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    patientIdentifier = patient.getIdentifier().get(3);
    // IN2.6
    assertThat(patientIdentifier.getValue()).isEqualTo("MEDICARE06");
    // No system for IN2.6
    assertThat(patientIdentifier.hasSystem()).isFalse();
    DatatypeUtils.checkCommonCodeableConceptAssertions(patientIdentifier.getType(), "MC", "Patient's Medicare number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    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 - Order matches order of identifier_X in Coverage.yml
    // XV, XV, XV, MB, MA, MC, SN
    assertThat(coverage.getIdentifier()).hasSize(7);
    // IN1.2.1
    assertThat(coverage.getIdentifier().get(0).getValue()).isEqualTo("Value1");
    // IN1.2.3
    assertThat(coverage.getIdentifier().get(0).getSystem()).isEqualTo("urn:id:System3");
    // No use, here
    assertThat(coverage.getIdentifier().get(0).getUse()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(0).getType(), "XV", "Health Plan Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN1.2.4
    assertThat(coverage.getIdentifier().get(1).getValue()).isEqualTo("Value4");
    // IN1.2.6
    assertThat(coverage.getIdentifier().get(1).getSystem()).isEqualTo("urn:id:System6");
    // No use, here
    assertThat(coverage.getIdentifier().get(1).getUse()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(1).getType(), "XV", "Health Plan Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN1.46
    assertThat(coverage.getIdentifier().get(2).getValue()).isEqualTo("Value46");
    // No system, here
    assertThat(coverage.getIdentifier().get(2).getSystem()).isNull();
    // Use is enumeration "old"
    assertThat(coverage.getIdentifier().get(2).getUseElement().getCode()).hasToString("old");
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(2).getType(), "XV", "Health Plan Identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN2.61 takes priority over IN1.36
    assertThat(coverage.getIdentifier().get(3).getValue()).isEqualTo("MEMBER61");
    // No system, here
    assertThat(coverage.getIdentifier().get(3).getSystem()).isNull();
    // No use, here
    assertThat(coverage.getIdentifier().get(3).getUse()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(3).getType(), "MB", "Member Number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN2.8
    assertThat(coverage.getIdentifier().get(4).getValue()).isEqualTo("MEDICAID08");
    // No system, here
    assertThat(coverage.getIdentifier().get(4).getSystem()).isNull();
    // No use, here
    assertThat(coverage.getIdentifier().get(4).getUse()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(4).getType(), "MA", "Patient Medicaid number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN2.6
    assertThat(coverage.getIdentifier().get(5).getValue()).isEqualTo("MEDICARE06");
    // No system, here
    assertThat(coverage.getIdentifier().get(5).getSystem()).isNull();
    // No use, here
    assertThat(coverage.getIdentifier().get(5).getUse()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(5).getType(), "MC", "Patient's Medicare number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN1.36
    assertThat(coverage.getIdentifier().get(6).getValue()).isEqualTo("MEMBER36");
    // No system, here
    assertThat(coverage.getIdentifier().get(6).getSystem()).isNull();
    // No use, here
    assertThat(coverage.getIdentifier().get(6).getUse()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getIdentifier().get(6).getType(), "SN", "Subscriber Number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // 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 IN1.16 through IN1.19; IN1.43; INI.49
    assertThat(relatedPersons).hasSize(1);
    RelatedPerson related = (RelatedPerson) relatedPersons.get(0);
    // Check RelatedPerson identifiers
    assertThat(related.getIdentifier()).hasSize(2);
    // IN1.49.1
    assertThat(related.getIdentifier().get(0).getValue()).isEqualTo("J494949");
    // IN1.49.4
    assertThat(related.getIdentifier().get(0).getSystem()).isEqualTo("urn:id:Large_HMO");
    // IN1.49.5
    DatatypeUtils.checkCommonCodeableConceptAssertions(// IN1.49.5
    related.getIdentifier().get(0).getType(), // IN1.49.5
    "XX", // Display value looked up from code 'XX'
    "Organization identifier", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // IN2.2
    assertThat(related.getIdentifier().get(1).getValue()).isEqualTo("777-88-9999");
    // No system to assign
    assertThat(related.getIdentifier().get(1).hasSystem()).isFalse();
    DatatypeUtils.checkCommonCodeableConceptAssertions(related.getIdentifier().get(1).getType(), "SS", "Social Security number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // Check RelatedPerson name. IN1.16 name is standard XPN, tested exhaustively in other tests.
    assertThat(related.getName()).hasSize(1);
    HumanName relatedName = related.getName().get(0);
    // IN1.16.1
    assertThat(relatedName.getFamily()).isEqualTo("DoeFake");
    // IN1.16.2
    assertThat(relatedName.getGiven().get(0).getValueAsString()).isEqualTo("Judy");
    // IN1.16.6
    assertThat(relatedName.getPrefixAsSingleString()).hasToString("Rev.");
    // from IN1.16 aggregate
    assertThat(relatedName.getText()).isEqualTo("Rev. Judy DoeFake");
    // Check RelatedPerson birth and gender
    // IN1.18
    assertThat(related.getBirthDateElement().toString()).containsPattern("1978-04-29");
    Enumerations.AdministrativeGender gen = related.getGender();
    // IN1.43
    assertThat(gen).isNotNull().isEqualTo(Enumerations.AdministrativeGender.FEMALE);
    // Check the RelatedPerson address. IN1.19 is a standard XAD address, which is tested exhaustively in other tests.
    assertThat(related.getAddress()).hasSize(1);
    assertThat(related.getAddress().get(0).getLine().get(0).getValueAsString()).isEqualTo(// IN1.19.1
    "19 Rose St");
    // IN1.19.3
    assertThat(related.getAddress().get(0).getCity()).isEqualTo("Faketown");
    // IN1.19.4
    assertThat(related.getAddress().get(0).getState()).isEqualTo("CA");
    // IN1.19.5
    assertThat(related.getAddress().get(0).getPostalCode()).isEqualTo("ZIP5");
    // Check RelatedPerson telecom.  IN2.63 is standard XTN, tested exhaustively in other tests.
    // telecom is type ContactPoint
    ContactPoint contactPoint = related.getTelecomFirstRep();
    // default type hardcoded.
    assertThat(contactPoint.getSystemElement().getCode()).hasToString("phone");
    // Hard-coded to home.  IN2.63.2 is not mapped (ignored).
    assertThat(contactPoint.getUseElement().getCode()).isEqualTo("home");
    // Hard-coded to home.  IN2.63.2 is not mapped (ignored).
    ;
    // IN2.63.6, IN2.63.7 via getFormattedTelecomNumberValue
    assertThat(contactPoint.getValue()).hasToString("(555) 767 7777");
    // IN2.63.13
    assertThat(contactPoint.getPeriod().getStartElement().toString()).containsPattern("2020-12-31T14:50:45");
    // IN2.63.14
    assertThat(contactPoint.getPeriod().getEndElement().toString()).containsPattern("2021-12-31T14:50:45");
    // IN2.63.18
    assertThat(contactPoint.getRank()).isEqualTo(1);
    // Check coverage relationship
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getRelationship(), "child", "Child", "http://terminology.hl7.org/CodeSystem/subscriber-relationship", // IN1.17
    null);
    // Check relatedPerson relationship
    assertThat(related.getRelationship()).hasSize(1);
    DatatypeUtils.checkCommonCodeableConceptAssertions(related.getRelationship().get(0), "PRN", "parent", "http://terminology.hl7.org/CodeSystem/v3-RoleCode", // IN1.17
    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 coverage.Order
    // IN1.1 backup for missing IN1.22
    assertThat(coverage.getOrder()).isEqualTo(1);
    // Confirm there are no unaccounted for resources
    // Expected: Coverage, Organization, Patient, Encounter, RelatedPerson
    assertThat(e).hasSize(5);
}
Also used : 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) HumanName(org.hl7.fhir.r4.model.HumanName) ContactPoint(org.hl7.fhir.r4.model.ContactPoint) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Enumerations(org.hl7.fhir.r4.model.Enumerations) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 93 with Patient

use of org.hl7.fhir.r4.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7FinancialInsuranceTest method testInsuranceCoverageUnknownRelationship.

@Test
// As part of the test, there is a valid code in IN2.72 that would create a related person, but it should be ignored.
void testInsuranceCoverageUnknownRelationship() 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.53 NOT REFERENCED
    "||05||||||||||||||||||||||||||||||||||||\n" + // IN2.1 through IN2.71 NOT REFERENCED
    "IN2||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||" + // A valid code in IN2.72 does not take priority over an invalid code in IN1.17.
    "04|\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();
    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
    assertThat(coverage.getIdentifier()).hasSize(2);
    // Coverage Identifiers deep check in testBasicInsuranceCoverageFields
    // Because the relationship is 05, an unknown code, no subscriber is created
    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 an unknown code
    List<Resource> relatedPersons = ResourceUtils.getResourceList(e, ResourceType.RelatedPerson);
    // No related person should be created because IN1.17 was an unknown code
    assertThat(relatedPersons).isEmpty();
    // Check coverage.relationship (from SubscriberRelationship mapping)
    DatatypeUtils.checkCommonCodeableConceptAssertions(coverage.getRelationship(), "05", null, null, // IN1.17, because it is unkown 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 94 with Patient

use of org.hl7.fhir.r4.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7PatientFHIRConversionTest method patient_multiple_birth_conversion_test.

@Test
void patient_multiple_birth_conversion_test() {
    /**
     * Simplified logic for multiple birth
     *
     * Y + number = number
     * N + number = N
     * Y + blank = Y
     * N + blank = N
     * blank + number = number
     * blank + blank = nothing.
     */
    String patientMsgEmptyMultiple = "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|Mouse^Mickey^J^III^^^||||||||||||||||||Born in USA|||USA||||\n";
    Patient patientObjEmptyMultiple = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgEmptyMultiple);
    assertThat(patientObjEmptyMultiple.hasMultipleBirth()).isFalse();
    assertThat(patientObjEmptyMultiple.hasMultipleBirthIntegerType()).isFalse();
    assertThat(patientObjEmptyMultiple.hasMultipleBirthBooleanType()).isFalse();
    String patientMsgMultipleN = "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|Mouse^Mickey^J^III^^^||||||||||||||||||Born in USA|N||USA||||\n";
    Patient patientObjMultipleN = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgMultipleN);
    assertThat(patientObjMultipleN.hasMultipleBirth()).isTrue();
    assertThat(patientObjMultipleN.hasMultipleBirthIntegerType()).isFalse();
    assertThat(patientObjMultipleN.hasMultipleBirthBooleanType()).isTrue();
    assertThat(patientObjMultipleN.getMultipleBirthBooleanType().booleanValue()).isFalse();
    String patientMsgMultipleNumberOnly = "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|Mouse^Mickey^J^III^^^||||||||||||||||||Born in USA||2|USA||||\n";
    // A number when the boolean is missing presumes the number has meaning.  An integer is created.
    Patient patientObjMultipleNumberOnly = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgMultipleNumberOnly);
    assertThat(patientObjMultipleNumberOnly.hasMultipleBirth()).isTrue();
    assertThat(patientObjMultipleNumberOnly.hasMultipleBirthIntegerType()).isTrue();
    assertThat(patientObjMultipleNumberOnly.hasMultipleBirthBooleanType()).isFalse();
    assertThat(patientObjMultipleNumberOnly.getMultipleBirthIntegerType().asStringValue()).isEqualTo("2");
    String patientMsgMultipleBooleanYOnly = "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|Mouse^Mickey^J^III^^^||||||||||||||||||Born in USA|Y||USA||||\n";
    Patient patientObjMultipleBooleanYOnly = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgMultipleBooleanYOnly);
    assertThat(patientObjMultipleBooleanYOnly.hasMultipleBirth()).isTrue();
    assertThat(patientObjMultipleBooleanYOnly.hasMultipleBirthIntegerType()).isFalse();
    assertThat(patientObjMultipleBooleanYOnly.hasMultipleBirthBooleanType()).isTrue();
    assertThat(patientObjMultipleBooleanYOnly.getMultipleBirthBooleanType().booleanValue()).isTrue();
    String patientMsgMultipleNumberAndBooleanY = "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|Mouse^Mickey^J^III^^^||||||||||||||||||Born in USA|Y|3|USA||||\n";
    Patient patientObjMultipleNumberAndBooleanY = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgMultipleNumberAndBooleanY);
    assertThat(patientObjMultipleNumberAndBooleanY.hasMultipleBirth()).isTrue();
    assertThat(patientObjMultipleNumberAndBooleanY.hasMultipleBirthIntegerType()).isTrue();
    assertThat(patientObjMultipleNumberAndBooleanY.hasMultipleBirthBooleanType()).isFalse();
    // DateUtil.formatToDate
    assertThat(patientObjMultipleNumberAndBooleanY.getMultipleBirthIntegerType().asStringValue()).isEqualTo("3");
    String patientMsgMultipleN16 = "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|Mouse^Mickey^J^III^^^||||||||||||||||||Born in USA|N|16|USA||||\n";
    Patient patientObjMultipleN16 = PatientUtils.createPatientFromHl7Segment(ftv, patientMsgMultipleN16);
    assertThat(patientObjMultipleN16.hasMultipleBirth()).isTrue();
    assertThat(patientObjMultipleN16.hasMultipleBirthIntegerType()).isFalse();
    assertThat(patientObjMultipleN16.hasMultipleBirthBooleanType()).isTrue();
    assertThat(patientObjMultipleN16.getMultipleBirthBooleanType().booleanValue()).isFalse();
}
Also used : Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 95 with Patient

use of org.hl7.fhir.r4.model.Patient in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7PatientFHIRConversionTest method patientNameTest.

@Test
void patientNameTest() {
    String patientHasMiddleName = "MSH|^~\\&|MyEMR|DE-000001| |CAIRLO|20160701123030-0700||VXU^V04^VXU_V04|CA0001|P|2.6|||ER|AL|||||Z22^CDCPHINVS|DE-000001\r" + // PID 5 fields (name) are extracted and tested
    "PID|1||PA123456^^^MYEMR^MR||JONES^GEORGE^Q^III^MR^^B||||||||||||||||||||\r";
    Patient patientObjUsualName = PatientUtils.createPatientFromHl7Segment(ftv, patientHasMiddleName);
    java.util.List<org.hl7.fhir.r4.model.HumanName> name = patientObjUsualName.getName();
    List<StringType> givenName = name.get(0).getGiven();
    List<StringType> suffixes = name.get(0).getSuffix();
    assertThat(suffixes).hasSize(1);
    List<StringType> prefixes = name.get(0).getPrefix();
    assertThat(prefixes).hasSize(1);
    String fullName = name.get(0).getText();
    assertThat(prefixes.get(0).toString()).hasToString("MR");
    assertThat(givenName.get(0).toString()).hasToString("GEORGE");
    assertThat(givenName.get(1).toString()).hasToString("Q");
    assertThat(suffixes.get(0).toString()).hasToString("III");
    assertThat(fullName).isEqualTo("MR GEORGE Q JONES III");
}
Also used : HumanName(org.hl7.fhir.r4.model.HumanName) StringType(org.hl7.fhir.r4.model.StringType) Patient(org.hl7.fhir.r4.model.Patient) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.Test)576 Test (org.junit.jupiter.api.Test)442 Patient (org.hl7.fhir.r4.model.Patient)437 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)255 HashMap (java.util.HashMap)251 Patient (org.hl7.fhir.dstu3.model.Patient)249 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)228 Bundle (org.hl7.fhir.r4.model.Bundle)203 Path (javax.ws.rs.Path)188 Date (java.util.Date)171 Produces (javax.ws.rs.Produces)163 ArrayList (java.util.ArrayList)156 JsonObject (javax.json.JsonObject)141 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)140 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)138 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)137 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)128 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)128 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)125 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)120