Search in sources :

Example 86 with PATIENT

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

the class Hl7ORUMessageTest method test_oru_with_specimen.

// 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
void test_oru_with_specimen() throws IOException {
    String hl7message = "MSH|^~\\\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|ORU^R01|MSGID000005|T|2.6\r" + "PID||45483|45483||SMITH^SUZIE^||20160813|M|||123 MAIN STREET^^SCHENECTADY^NY^12345||(123)456-7890|||||^^^T||||||||||||\r" + "OBR|1||986^IA PHIMS Stage^2.16.840.1.114222.4.3.3.5.1.2^ISO|1051-2^New Born Screening^LN|||20151009173644|||||||||||||002|||||F|||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^||||3065^Mahoney^Paul^J|\r" + "OBX|1|ST|TS-F-01-002^Endocrine Disorders^L||obs report||||||F\r" + "SPM|1|SpecimenID||BLD|||||||P||||||201410060535|201410060821||Y||||||1\r";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    // Verify that the right resources are created
    List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
    assertThat(patientResource).hasSize(1);
    List<Resource> diagnosticReport = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
    assertThat(diagnosticReport).hasSize(1);
    List<Resource> servReqResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    assertThat(servReqResource).hasSize(1);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(1);
    List<Resource> practitionerResource = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
    assertThat(practitionerResource).hasSize(1);
    List<Resource> specimenResource = ResourceUtils.getResourceList(e, ResourceType.Specimen);
    assertThat(specimenResource).hasSize(1);
    // Expecting only the above resources, no extras!
    assertThat(e).hasSize(6);
    // /////////////////////////////////////////
    // Now confirm content of the diagnosticReport because we don't have separate tests for DiagnosticReport
    // /////////////////////////////////////////
    DiagnosticReport diag = ResourceUtils.getResourceDiagnosticReport(diagnosticReport.get(0), context);
    // Verify status from OBR.25
    assertThat(diag.getStatus().toCode()).isEqualTo("final");
    // Verify category from OBR.24
    assertThat(diag.getCategory()).isEmpty();
    // Verify code from OBR.4
    assertThat(diag.hasCode()).isTrue();
    List<Coding> codings = diag.getCode().getCoding();
    assertThat(codings).hasSize(1);
    Coding coding = codings.get(0);
    assertThat(coding.hasDisplay()).isTrue();
    assertThat(coding.getDisplay()).hasToString("New Born Screening");
    assertThat(coding.hasCode()).isTrue();
    assertThat(coding.getCode()).hasToString("1051-2");
    assertThat(coding.hasSystem()).isTrue();
    assertThat(coding.getSystem()).hasToString("http://loinc.org");
    // Verify encounter reference
    assertThat(diag.getEncounter().isEmpty()).isTrue();
    // Verify subject reference
    assertThat(diag.getSubject().isEmpty()).isFalse();
    // Verify effectiveDateTime from OBR.7 and OBR.8
    // This also verifies the type, confirming effectiveDateTime was set rather than effectivePeriod
    assertThat(diag.getEffectiveDateTimeType().asStringValue()).isEqualTo("2015-10-09T17:36:44+08:00");
    // Verify issued from OBR.22
    assertThat(diag.getIssued()).isNull();
    // Verify resultsInterpreter from OBR.32
    assertThat(diag.getResultsInterpreter()).hasSize(1);
    // Verify basedOn is ref to the ServiceRequest created for ORC or OBR
    assertThat(diag.getBasedOn()).hasSize(1);
    assertThat(diag.getBasedOn().get(0).getReference().substring(0, 15)).isEqualTo("ServiceRequest/");
    // Verify specimen reference
    List<Reference> spmRef = diag.getSpecimen();
    assertThat(spmRef).hasSize(1);
    assertThat(spmRef.get(0).isEmpty()).isFalse();
    // Verify result reference
    List<Reference> obsRef = diag.getResult();
    assertThat(obsRef).hasSize(1);
    assertThat(obsRef.get(0).isEmpty()).isFalse();
    // Verify presentedForm from OBX of type ST - No attachments expected because OBX of type not TX creates an Observation.
    List<Attachment> attachments = diag.getPresentedForm();
    Assertions.assertEquals(0, attachments.size(), "Unexpected number of attachments");
    // //////////////////////////////////
    for (Resource res : obsResource) {
        // Verify encounter reference
        Observation obs = (Observation) res;
        assertThat(obs.getEncounter().isEmpty()).isTrue();
        // Verify subject reference to Patient exists
        assertThat(obs.getSubject().isEmpty()).isFalse();
        assertThat(obs.getSubject().getReference().substring(0, 8)).isEqualTo("Patient/");
    }
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) Attachment(org.hl7.fhir.r4.model.Attachment) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.r4.model.Coding) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test)

Example 87 with PATIENT

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

the class Hl7ORUMessageTest method test_oru_with_multiple_reports.

// 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
void test_oru_with_multiple_reports() throws IOException {
    String hl7message = "MSH|^~\\\\&|SendTest1|Sendfac1|Receiveapp1|Receivefac1|200603081747|security|ORU^R01|MSGID000005|T|2.6\r" + "PID||45483|45483||SMITH^SUZIE^||20160813|M|||123 MAIN STREET^^SCHENECTADY^NY^12345||(123)456-7890|||||^^^T||||||||||||\r" + "OBR|1||986^IA PHIMS Stage^2.16.840.1.114222.4.3.3.5.1.2^ISO|112^Final Echocardiogram Report|||20151009173644|||||||||||||002|||||F|||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^||||3068^JOHN^Paul^J|\r" + "OBX|1|ST|TS-F-01-007^Endocrine Disorders 7^L||obs report||||||F\r" + "OBX|2|ST|TS-F-01-008^Endocrine Disorders 8^L||ECHOCARDIOGRAPHIC REPORT||||||F\r" + "OBR|1||98^IA PHIMS Stage^2.16.840.1.114222.4.3.3.5.1.2^ISO|113^Echocardiogram Report|||20151009173644|||||||||||||002|||||F|||2740^Tsadok^Janetary~2913^Merrit^Darren^F~3065^Mahoney^Paul^J~4723^Loh^Robert^L~9052^Winter^Oscar^||||3065^Mahoney^Paul^J|\r" + "OBX|1|CWE|625-4^Bacteria identified in Stool by Culture^LN^^^^2.33^^result1|1|27268008^Salmonella^SCT^^^^20090731^^Salmonella species|||A^A^HL70078^^^^2.5|||P|||20120301|||^^^^^^^^Bacterial Culture||201203140957||||||\r" + "OBX|2|ST|TS-F-01-002^Endocrine Disorders^L||ECHOCARDIOGRAPHIC REPORT Group 2||||||F\r";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    // Verify that the right resources are being created
    List<Resource> patientResource = ResourceUtils.getResourceList(e, ResourceType.Patient);
    assertThat(patientResource).hasSize(1);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(4);
    List<Resource> practitionerResource = ResourceUtils.getResourceList(e, ResourceType.Practitioner);
    assertThat(practitionerResource).hasSize(2);
    List<Resource> diagnosticReport = ResourceUtils.getResourceList(e, ResourceType.DiagnosticReport);
    assertThat(diagnosticReport).hasSize(2);
    List<Resource> servReqResource = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    assertThat(servReqResource).hasSize(2);
    // Expecting only the above resources, no extras!
    assertThat(e).hasSize(11);
    // /////////////////////////////////////////
    // Now confirm content of the FIRST diagnosticReport because we don't have separate tests for DiagnosticReport
    // /////////////////////////////////////////
    DiagnosticReport diag = ResourceUtils.getResourceDiagnosticReport(diagnosticReport.get(0), context);
    // Verify status from OBR.25
    assertThat(diag.getStatus().toCode()).isEqualTo("final");
    // Verify category from OBR.24
    assertThat(diag.getCategory()).isEmpty();
    // Verify code from OBR.4
    assertThat(diag.hasCode()).isTrue();
    List<Coding> codings = diag.getCode().getCoding();
    assertThat(codings).hasSize(1);
    Coding coding = codings.get(0);
    assertThat(coding.hasDisplay()).isTrue();
    assertThat(coding.getDisplay()).hasToString("Final Echocardiogram Report");
    assertThat(coding.hasCode()).isTrue();
    assertThat(coding.getCode()).hasToString("112");
    assertThat(coding.hasSystem()).isFalse();
    // Verify encounter reference
    assertThat(diag.getEncounter().isEmpty()).isTrue();
    // Verify subject reference
    assertThat(diag.getSubject().isEmpty()).isFalse();
    // Verify effectiveDateTime from OBR.7 and OBR.8
    // This also verifies the type, confirming effectiveDateTime was set rather than effectivePeriod
    assertThat(diag.getEffectiveDateTimeType().asStringValue()).isEqualTo("2015-10-09T17:36:44+08:00");
    // Verify issued from OBR.22
    assertThat(diag.getIssued()).isNull();
    // Verify resultsInterpreter from OBR.32
    assertThat(diag.getResultsInterpreter()).hasSize(1);
    // Verify basedOn is ref to the ServiceRequest created for ORC or OBR
    assertThat(diag.getBasedOn()).hasSize(1);
    assertThat(diag.getBasedOn().get(0).getReference().substring(0, 15)).isEqualTo("ServiceRequest/");
    // Verify specimen reference
    assertThat(diag.getSpecimen()).isEmpty();
    // Verify result reference
    List<Reference> obsRef = diag.getResult();
    assertThat(obsRef).hasSize(2);
    assertThat(obsRef.get(0).isEmpty()).isFalse();
    // Verify presentedForm from OBX of type TX - In this case no attachments created because the OBX is not of type TX.
    List<Attachment> attachments = diag.getPresentedForm();
    Assertions.assertEquals(0, attachments.size(), "Unexpected number of attachments");
    // /////////////////////////////////////////
    // Now confirm content of the SECOND diagnosticReport because we don't have separate tests for DiagnosticReport
    // /////////////////////////////////////////
    DiagnosticReport diag2 = ResourceUtils.getResourceDiagnosticReport(diagnosticReport.get(0), context);
    // Verify status from OBR.25
    assertThat(diag2.getStatus().toCode()).isEqualTo("final");
    // Verify category from OBR.24
    assertThat(diag2.getCategory()).isEmpty();
    // Verify code from OBR.4
    assertThat(diag2.hasCode()).isTrue();
    List<Coding> codings2 = diag2.getCode().getCoding();
    assertThat(codings2).hasSize(1);
    Coding coding2 = codings.get(0);
    assertThat(coding2.hasDisplay()).isTrue();
    assertThat(coding2.getDisplay()).hasToString("Final Echocardiogram Report");
    assertThat(coding2.hasCode()).isTrue();
    assertThat(coding2.getCode()).hasToString("112");
    assertThat(coding2.hasSystem()).isFalse();
    // Verify encounter reference
    assertThat(diag2.getEncounter().isEmpty()).isTrue();
    // Verify subject reference
    assertThat(diag2.getSubject().isEmpty()).isFalse();
    // Verify effectiveDateTime from OBR.7 and OBR.8
    // This also verifies the type, confirming effectiveDateTime was set rather than effectivePeriod
    assertThat(diag2.getEffectiveDateTimeType().asStringValue()).isEqualTo("2015-10-09T17:36:44+08:00");
    // Verify issued from OBR.22
    assertThat(diag2.getIssued()).isNull();
    // Verify resultsInterpreter from OBR.32
    assertThat(diag2.getResultsInterpreter()).hasSize(1);
    // Verify basedOn is ref to the ServiceRequest created for ORC or OBR
    assertThat(diag.getBasedOn()).hasSize(1);
    assertThat(diag.getBasedOn().get(0).getReference().substring(0, 15)).isEqualTo("ServiceRequest/");
    // Verify specimen reference
    assertThat(diag2.getSpecimen()).isEmpty();
    // Verify result reference
    List<Reference> obsRef2 = diag2.getResult();
    assertThat(obsRef2).hasSize(2);
    assertThat(obsRef2.get(0).isEmpty()).isFalse();
    // Verify presentedForm from OBX of type TX - In this case no attachments created because the OBX is not type TX.
    List<Attachment> attachments2 = diag2.getPresentedForm();
    Assertions.assertEquals(0, attachments2.size(), "Unexpected number of attachments");
    // //////////////////////////////////
    for (Resource res : obsResource) {
        // Verify encounter reference is not set
        Observation obs = (Observation) res;
        assertThat(obs.getEncounter().isEmpty()).isTrue();
        // Verify subject reference to Patient exists
        Base subject = ResourceUtils.getValue(obs, "subject");
        assertThat(ResourceUtils.getValueAsString(subject, "reference").substring(0, 8)).isEqualTo("Patient/");
    }
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) DiagnosticReport(org.hl7.fhir.r4.model.DiagnosticReport) Attachment(org.hl7.fhir.r4.model.Attachment) Base(org.hl7.fhir.r4.model.Base) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Coding(org.hl7.fhir.r4.model.Coding) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test)

Example 88 with PATIENT

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

the class Hl7VXUMessageTest method test_VXU_with_minimum_patient_group_plus_multiple_order_groups.

// 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
void test_VXU_with_minimum_patient_group_plus_multiple_order_groups() throws IOException {
    String hl7message = "MSH|^~\\&|EHR|12345^SiteName|MIIS|99990|20140701041038||VXU^V04^VXU_V04|MSG.Valid_01|P|2.6|||\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "PV1|1|R||||||||||||||||||V01^20120901041038\r" + "ORC|RE||4242546^NameSpaceID||||||||||||||\r" + "RXA|0|1|20140701041038|20140701041038|48^HPV, quadrivalent^CVX|0.5|ml^MilliLiter [SI Volume Units]^UCUM||||14509|||||||||CP||\r" + "OBX|1|CWE|31044-1^Immunization reaction^LN|1|VXC12^fever of >40.5C within 48 hrs.^CDCPHINVS||||||F|||20120901041038\r" + "OBX|2|CWE|31044-1^Immunization reaction^LN|1|VXC14^Rash within 14 days of dose^CDCPHINVS||||||F|||20140701041038\r" + "ORC|RE||4242546^NameSpaceID||||||||||||||\r" + "RXA|0|1|20140701041038|20140701041038|48^HPV, quadrivalent^CVX|0.5|ml^MilliLiter [SI Volume Units]^UCUM||||14509|||||||||CP||\r" + "RXR|C28161^Intramuscular^NCIT||||\r" + "OBX|1|CWE|31044-1^Immunization reaction^LN|1|39579001^Anaphylaxis (disorder)^SCT||||||F|||20120901041038\r" + "OBX|2|TS|29768-9^DATE VACCINE INFORMATION STATEMENT PUBLISHED^LN|1|20010711||||||F|||20120720101321\r";
    List<Bundle.BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    // Validate that the correct resources are created
    List<Resource> patient = ResourceUtils.getResourceList(e, ResourceType.Patient);
    assertThat(patient).hasSize(1);
    List<Resource> enc = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    assertThat(enc).hasSize(1);
    List<Resource> immu = ResourceUtils.getResourceList(e, ResourceType.Immunization);
    assertThat(immu).hasSize(2);
    List<Resource> obs = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obs).hasSize(3);
    // verify that the correct Observations are associated with the correct Immunizations.
    // The first two reaction details come from the first immunization resource.
    // Too confirm both observations match we compare the IDs of the reaction detail and the actual observation resource id
    // The first two sets of assertions are from the first RXA segment
    Immunization resource = ResourceUtils.getResourceImmunization(immu.get(0), ResourceUtils.context);
    List<Resource> observations = ResourceUtils.getResourceList(e, ResourceType.Observation);
    String reactionDetail = resource.getReactionFirstRep().getDetail().getReference();
    Observation obsResource = ResourceUtils.getResourceObservation(observations.get(0), ResourceUtils.context);
    assertThat(obsResource.getId()).isEqualTo(reactionDetail);
    assertThat(obsResource.getCode().getCodingFirstRep().getDisplay()).isEqualTo("fever of >40.5C within 48 hrs.");
    assertThat(obsResource.getCode().getCodingFirstRep().getCode()).isEqualTo("VXC12");
    assertThat(obsResource.getCode().getCodingFirstRep().getSystem()).isEqualTo("urn:id:CDCPHINVS");
    assertThat(obsResource.getCode().getText()).isEqualTo("fever of >40.5C within 48 hrs.");
    assertThat(obsResource.getIdentifierFirstRep().getValue()).isEqualTo("4242546-VXC12-CDCPHINVS");
    // Expecting only the above resources, no extras!
    assertThat(obsResource.getIdentifierFirstRep().getSystem()).isEqualTo("urn:id:extID");
    reactionDetail = resource.getReaction().get(1).getDetail().getReference();
    obsResource = ResourceUtils.getResourceObservation(observations.get(1), ResourceUtils.context);
    assertThat(obsResource.getId()).isEqualTo(reactionDetail);
    assertThat(obsResource.getCode().getCodingFirstRep().getDisplay()).isEqualTo("Rash within 14 days of dose");
    assertThat(obsResource.getCode().getCodingFirstRep().getCode()).isEqualTo("VXC14");
    assertThat(obsResource.getCode().getCodingFirstRep().getSystem()).isEqualTo("urn:id:CDCPHINVS");
    assertThat(obsResource.getCode().getText()).isEqualTo("Rash within 14 days of dose");
    assertThat(obsResource.getIdentifierFirstRep().getValue()).isEqualTo("4242546-VXC14-CDCPHINVS");
    assertThat(obsResource.getIdentifierFirstRep().getSystem()).isEqualTo("urn:id:extID");
    assertThat(e).hasSize(7);
    // The second set of assertions are from the second RXA segment
    resource = ResourceUtils.getResourceImmunization(immu.get(1), ResourceUtils.context);
    reactionDetail = resource.getReaction().get(0).getDetail().getReference();
    obsResource = ResourceUtils.getResourceObservation(observations.get(2), ResourceUtils.context);
    assertThat(obsResource.getId()).isEqualTo(reactionDetail);
    assertThat(obsResource.getCode().getCodingFirstRep().getDisplay()).isEqualTo("Anaphylaxis (disorder)");
    assertThat(obsResource.getCode().getCodingFirstRep().getCode()).isEqualTo("39579001");
    assertThat(obsResource.getCode().getCodingFirstRep().getSystem()).isEqualTo("http://snomed.info/sct");
    assertThat(obsResource.getCode().getText()).isEqualTo("Anaphylaxis (disorder)");
    assertThat(obsResource.getIdentifierFirstRep().getValue()).isEqualTo("4242546-39579001-SCT");
    assertThat(obsResource.getIdentifierFirstRep().getSystem()).isEqualTo("urn:id:extID");
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test)

Example 89 with PATIENT

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

the class CodeableConceptTest method testSimilarCWEToCodeableConcepts.

@ParameterizedTest
@MethodSource("parmsTestSimilarCWEInputs")
void testSimilarCWEToCodeableConcepts(String cwe, String code, String display, String system, String text) {
    // See inputs and test explanation above
    String patientWithCodeableConcept = "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 race
    "PID|1||12345678^^^^MR||TestPatientLastName^Jane^|||||" + cwe + "\n";
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientWithCodeableConcept);
    assertThat(patient.hasExtension()).isTrue();
    List<Extension> extensions = patient.getExtensionsByUrl(UrlLookup.getExtensionUrl("race"));
    assertThat(extensions).isNotNull();
    assertThat(extensions.size()).isEqualTo(1);
    assertThat(extensions.get(0).hasValue()).isTrue();
    CodeableConcept ccW = (CodeableConcept) extensions.get(0).getValue();
    DatatypeUtils.checkCommonCodeableConceptAssertions(ccW, code, display, system, text);
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) Patient(org.hl7.fhir.r4.model.Patient) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 90 with PATIENT

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

the class CodeableConceptTest method testCodeableConceptDoubleRaceWithVersionAndAlternate.

@Test
void testCodeableConceptDoubleRaceWithVersionAndAlternate() {
    // This has both a known and an unknown system.
    // "valueCodeableConcept": {
    // "coding": [ {
    // "system": <known-to-FHIR>,  << FIRST CODING
    // "display": <original-display-value>
    // "code": <code-from-input>
    // "version": <version>
    // },
    // {
    // "system": <unknown, so made up "urn:id:L">,  << SECOND (ALTERNATE CODING)
    // "display": <original-alternate display-value>
    // "code": <altenate-code>
    // "version": <alternate-version>
    // } ],
    // "text": <original-display-value>
    // },
    String patientWithDoubleRaceWithVersionAndAlternate = "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 double race in the SAME CWE (not a second CWE) and versions.  Use made up Cauc to ensure test doesn't mix up whites.
    "PID|1||12345678^^^^MR||TestPatientLastName^Jane|||||2106-3^White^CDCREC^CA^Caucasian^L^1.1^4|\n";
    Patient patient = PatientUtils.createPatientFromHl7Segment(ftv, patientWithDoubleRaceWithVersionAndAlternate);
    assertThat(patient.hasExtension()).isTrue();
    List<Extension> extensions = patient.getExtensionsByUrl(UrlLookup.getExtensionUrl("race"));
    assertThat(extensions).isNotNull();
    assertThat(extensions.size()).isEqualTo(1);
    assertThat(extensions.get(0).hasValue()).isTrue();
    CodeableConcept ccW = (CodeableConcept) extensions.get(0).getValue();
    assertThat(ccW.hasCoding()).isTrue();
    assertThat(ccW.hasText()).isTrue();
    assertThat(ccW.getText()).hasToString("White");
    List<Coding> codings = ccW.getCoding();
    assertThat(codings.size()).isEqualTo(2);
    DatatypeUtils.checkCommonCodingAssertions(codings.get(0), "2106-3", "White", V3_RACE_SYSTEM, "1.1");
    DatatypeUtils.checkCommonCodingAssertions(codings.get(1), "CA", "Caucasian", "urn:id:L", "4");
}
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) 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