Search in sources :

Example 76 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ObservationFHIRConversionTest method testObservationCeResultUnknownSystem.

// NOTE that even though we are testing for it CE is not part of HL7 V2.6
@Test
void testObservationCeResultUnknownSystem() throws IOException {
    String hl7message = baseMessage + "OBX|1|CE|93000&CMP^LIN^CPT4|11|1305^No significant change was found^MEIECG";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(1);
    Observation obs = (Observation) obsResource.get(0);
    assertThat(obs.getValueCodeableConcept()).isNotNull();
    assertThat(obs.getStatus()).isNotNull();
    CodeableConcept cc = obs.getValueCodeableConcept();
    assertThat(cc.getCoding()).isNotNull();
    assertThat(cc.getCoding().get(0)).isNotNull();
    assertThat(cc.getCoding().get(0).getSystem()).isNull();
    assertThat(cc.getCoding().get(0).getCode()).isEqualTo("1305");
    assertThat(cc.getText()).isEqualTo("No significant change was found");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 77 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ObservationFHIRConversionTest method testObservationSTResult.

@Test
void testObservationSTResult() throws IOException {
    String hl7message = baseMessage + "OBX|1|ST|^Type of protein feed^L||Fourth Line: HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%||||||F||||Alex||";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(1);
    Observation obs = (Observation) obsResource.get(0);
    assertThat(obs.getValueStringType()).isNotNull();
    StringType q = obs.getValueStringType();
    assertThat(q.asStringValue()).isEqualTo("Fourth Line: HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) StringType(org.hl7.fhir.r4.model.StringType) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 78 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ObservationFHIRConversionTest method testObservationCeResultKnownSystem.

@Test
void testObservationCeResultKnownSystem() throws IOException {
    String hl7message = baseMessage + "OBX|1|CE|93000&CMP^LIN^CPT4|11|1305^No significant change was found^LN";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(1);
    Observation obs = (Observation) obsResource.get(0);
    assertThat(obs.getValueCodeableConcept()).isNotNull();
    assertThat(obs.getStatus()).isNotNull();
    CodeableConcept cc = obs.getValueCodeableConcept();
    assertThat(cc.getCoding()).isNotNull();
    assertThat(cc.getCoding().get(0)).isNotNull();
    assertThat(cc.getCoding().get(0).getSystem()).isEqualTo("http://loinc.org");
    assertThat(cc.getCoding().get(0).getCode()).isEqualTo("1305");
    assertThat(cc.getText()).isEqualTo("No significant change was found");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 79 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7OrderRequestFHIRConversionTest method testMDMT02ServiceRequest.

// This test assures the MDM_T02 is properly enabled.
// It focuses on _differences_ in MDM not tested above, then does general confirmation of other fields
@Test
void testMDMT02ServiceRequest() {
    String hl7message = "MSH|^~\\&|Epic|PQA|WHIA|IBM|20170920141233||MDM^T02^MDM_T02|M1005|D|2.6\r" + "EVN|T02|20170920141233|||\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "PV1|1|I|||||||||||||||||||||||||||||||||||||\r" + // ORC.15 is occurenceDateTime
    "ORC|NW|P1005|F1005|P1005|SC|D|1||20170920141233|||1212^docProvider^docOrdering|||20170920141233|\r" + // OBR.31 used for reason code
    "OBR|1|P1005|F1005|71260^CT Chest without contrast^ICD10|||||||||||||||||||||||||||exam reason ID^PREAURICULAR EDEMA text||||\r";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> serviceRequestList = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
    assertThat(serviceRequestList).hasSize(1);
    ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequestList.get(0), context);
    // Expect 3 identifiers (VN, PLAC, FILL)
    assertThat(serviceRequest.hasIdentifier()).isTrue();
    assertThat(serviceRequest.getIdentifier()).hasSize(3);
    // ORC.12 should create an ServiceRequest.requester reference
    assertThat(serviceRequest.hasRequester()).isTrue();
    assertThat(serviceRequest.getRequester().hasDisplay()).isTrue();
    assertThat(serviceRequest.getRequester().getDisplay()).isEqualTo("docOrdering docProvider");
    assertThat(serviceRequest.getRequester().hasReference()).isTrue();
    String requesterRef = serviceRequest.getRequester().getReference();
    Practitioner pract = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRef);
    // Confirm that the matching practitioner by ID has the correct content (simple validation)
    // Should be ORC.12.1
    assertThat(pract.getIdentifierFirstRep().getValue()).isEqualTo("1212");
    // OBR.31 is the reason code
    assertThat(serviceRequest.hasReasonCode()).isTrue();
    assertThat(serviceRequest.getReasonCode()).hasSize(1);
    DatatypeUtils.checkCommonCodeableConceptAssertions(serviceRequest.getReasonCodeFirstRep(), "exam reason ID", "PREAURICULAR EDEMA text", null, "PREAURICULAR EDEMA text");
    // OBR.4 is the  code
    assertThat(serviceRequest.hasCode()).isTrue();
    DatatypeUtils.checkCommonCodeableConceptAssertions(serviceRequest.getCode(), "71260", "CT Chest without contrast", "http://hl7.org/fhir/sid/icd-10-cm", "CT Chest without contrast");
    // General over valdation of presence of fields:
    // ORC.5
    assertThat(serviceRequest.hasStatus()).isTrue();
    assertThat(serviceRequest.hasIntent()).isTrue();
    assertThat(serviceRequest.hasSubject()).isTrue();
    // ORC.9
    assertThat(serviceRequest.hasAuthoredOn()).isTrue();
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) Test(org.junit.jupiter.api.Test)

Example 80 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7OrderRequestFHIRConversionTest method testBroadORCPlusOBRFields2.

@Test
void testBroadORCPlusOBRFields2() {
    String hl7message = "MSH|^~\\&|||||20180924152907|34001|ORU^R01^ORU_R01|213|T|2.6|||||||||||\n" + // PID.18 is empty, MSH.7 will be used as identifier visit number
    "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // PV1.19  is empty, MSH.7 will be used as identifier visit number
    "PV1|1|E|||||||||||||||||||||||||||||||||||||||||||\n" + // ORC.5 with purposely bad code to see that 'unknown' is result
    "ORC|RE|248648498^|248648498^||ZZ||||20120628071200||||||||||||||||||||||\n" + "OBR|1|248648498^|248648498^|83036E^HEMOGLOBIN A1C^PACSEAP^^^^^^HEMOGLOBIN A1C|||||||L||||||||||||||F||^^^20120606120606|||||||||||||||||||||||\n";
    String json = ftv.convert(hl7message, PatientUtils.OPTIONS);
    assertThat(json).isNotBlank();
    IBaseResource bundleResource = context.getParser().parseResource(json);
    assertThat(bundleResource).isNotNull();
    Bundle bundle = (Bundle) bundleResource;
    List<BundleEntryComponent> e = bundle.getEntry();
    List<Resource> serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
    // Important that we have exactly one service request (no duplication).  OBR creates it as a reference.
    assertThat(serviceRequestList).hasSize(1);
    ServiceRequest serviceRequest = ResourceUtils.getResourceServiceRequest(serviceRequestList.get(0), context);
    assertThat(serviceRequest.hasStatus()).isTrue();
    assertThat(serviceRequest.hasIdentifier()).isTrue();
    assertThat(serviceRequest.getIdentifier()).hasSize(3);
    // Identifier 1: visit number should be set by in this test by tertiary MSH.7
    // See notes about identifier testing in previous tests
    Identifier identifier = serviceRequest.getIdentifier().get(0);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    // MSH.7 as a string, not as a date
    assertThat(value).isEqualTo("20180924152907");
    assertThat(system).isNull();
    CodeableConcept type = identifier.getType();
    DatatypeUtils.checkCommonCodeableConceptAssertions(type, "VN", "Visit number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
    // OBR.27[0].4 should create an ServiceRequest.occurrenceDateTime date
    assertThat(serviceRequest.hasOccurrenceDateTimeType()).isTrue();
    assertThat(serviceRequest.getOccurrenceDateTimeType().toString()).containsPattern("2012-06-06T12:06:06");
    // // ORC.5 creates the serviceRequest.status() purposely an unknown code
    assertThat(serviceRequest.hasStatus()).isTrue();
    assertThat(serviceRequest.getStatusElement().getCode()).isEqualTo("unknown");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Bundle(org.hl7.fhir.r4.model.Bundle) Resource(org.hl7.fhir.r4.model.Resource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) ServiceRequest(org.hl7.fhir.r4.model.ServiceRequest) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test)

Aggregations

BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)265 Resource (org.hl7.fhir.r4.model.Resource)167 Test (org.junit.jupiter.api.Test)126 Bundle (org.hl7.fhir.r4.model.Bundle)116 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)96 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)88 ArrayList (java.util.ArrayList)67 Date (java.util.Date)52 Reference (org.hl7.fhir.r4.model.Reference)52 BundleEntryComponent (org.hl7.fhir.dstu3.model.Bundle.BundleEntryComponent)51 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)42 Patient (org.hl7.fhir.r4.model.Patient)37 IOException (java.io.IOException)36 Observation (org.hl7.fhir.r4.model.Observation)36 Test (org.junit.Test)35 BundleEntryComponent (org.hl7.fhir.r5.model.Bundle.BundleEntryComponent)34 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)33 Condition (org.hl7.fhir.r4.model.Condition)32 HashMap (java.util.HashMap)31 Encounter (org.hl7.fhir.r4.model.Encounter)31