Search in sources :

Example 66 with MR

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

the class Hl7ImmunizationFHIRConversionTest method testImmunizationAdministrationPlaceOrg1.

@Test
// Test priority of Immunization Performer sourcing is tested.
void testImmunizationAdministrationPlaceOrg1() throws IOException {
    String hl7VUXmessageRep = "MSH|^~\\&|||||20140701041038||VXU^V04^VXU_V04|MSG.Valid_01|P|2.6|||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + // PV1.3.4 to Organization referenced by Encounter.serviceProvider; but bypassed for Immunization.performer because RXA.27.4 has priority
    "PV1||O|^^^PlacePV1.3.4\r" + "ORC|||197027|||||||^Clerk^Myron|||||||RI2050\r" + // RXA.12 - RXA.26 not used
    "RXA|0|1|20130531||48^HIB PRP-T^CVX||||||^^^PlaceRXA11|||||||||||||||" + // RXA.27 to Immunization Performer
    "|^^^PlaceRXA274\r" + "OBX|1|CE|59784-9^Disease with presumed immunity^LN||\r";
    List<Bundle.BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7VUXmessageRep);
    // We expect two different organizations, one for Encounter.serviceProvider, one for Immunization.performer
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    assertThat(organizations).hasSize(2);
    Organization org1 = (Organization) organizations.get(0);
    Organization org2 = (Organization) organizations.get(1);
    // RXA.27.4
    String orgId1 = org1.getId();
    // RXA.27.4
    assertThat(orgId1).isEqualTo("Organization/placerxa274");
    // PV1.3.4
    String orgId2 = org2.getId();
    // PV1.3.4
    assertThat(orgId2).isEqualTo("Organization/placepv1.3.4");
    List<Resource> immunizations = ResourceUtils.getResourceList(e, ResourceType.Immunization);
    assertThat(immunizations).hasSize(1);
    Immunization imm = (Immunization) immunizations.get(0);
    // RXA.27.4
    assertThat(imm.getPerformer()).hasSize(1);
    // RXA.27
    assertThat(imm.getPerformerFirstRep().getActor().getReference()).isEqualTo(orgId1);
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    assertThat(encounters).hasSize(1);
    Encounter enc = (Encounter) encounters.get(0);
    // PV1.3.4
    assertThat(enc.getServiceProvider().getReference()).isEqualTo(orgId2);
    // Check for expected resources: Organizations (2), Immunization, Encounter, Patient
    assertThat(e).hasSize(5);
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Organization(org.hl7.fhir.r4.model.Organization) Resource(org.hl7.fhir.r4.model.Resource) Encounter(org.hl7.fhir.r4.model.Encounter) Test(org.junit.jupiter.api.Test)

Example 67 with MR

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

the class Hl7ImmunizationFHIRConversionTest method testImmunizationOBX3is309567.

@Test
void testImmunizationOBX3is309567() throws IOException {
    // When OBX.3 is 30956-7 and RXA.5 is not provided we get a vaccine code from OBX.5
    String hl7VUXmessageRep = "MSH|^~\\&|EHR|12345^SiteName|MIIS|99990|20140701041038||VXU^V04^VXU_V04|MSG.Valid_01|P|2.6|||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "ORC|||197027|||||||^Clerk^Myron|||||||RI2050\r" + "RXA|0|1|20130531\r" + "OBX|1|CWE|30956-7^vaccine type^LN|1|107^DTAP^CVX\r";
    Immunization immunization = ResourceUtils.getImmunization(ftv, hl7VUXmessageRep);
    // Status defaults to completed
    assertThat(immunization.getStatus().getDisplay()).isEqualTo("completed");
    assertThat(immunization.hasStatusReason()).isFalse();
    assertThat(immunization.hasReaction()).isFalse();
    assertThat(immunization.hasProgramEligibility()).isFalse();
    assertThat(immunization.hasFundingSource()).isFalse();
    // When OBX.3 is 30956-7 we get a vaccine code
    assertThat(immunization.hasVaccineCode()).isTrue();
    assertThat(immunization.getVaccineCode().getCodingFirstRep().getCode()).isEqualTo("107");
    assertThat(immunization.getVaccineCode().getCodingFirstRep().getDisplay()).isEqualTo("DTAP");
    assertThat(immunization.getVaccineCode().getCodingFirstRep().getSystem()).isEqualTo("http://hl7.org/fhir/sid/cvx");
    assertThat(immunization.getVaccineCode().getText()).isEqualTo("DTAP");
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Test(org.junit.jupiter.api.Test)

Example 68 with MR

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

the class Hl7ImmunizationFHIRConversionTest method testImmunizationReasonImmune2.

@Test
void testImmunizationReasonImmune2() throws IOException {
    // Status reason is IMMUNE when OBX.3 is 59784-9, RXA.18 not provided, and RXA.20 is not RE
    String hl7VUXmessageRep = "MSH|^~\\&|EHR|12345^SiteName|MIIS|99990|20140701041038||VXU^V04^VXU_V04|MSG.Valid_01|P|2.6|||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "ORC|||197027|||||||^Clerk^Myron|||||||RI2050\r" + // RXA.20 is not RE, so OBX.3==59784-9 is activated; yeilds status not-done
    "RXA|0|1|20130531||48^HIB PRP-T^CVX|||||||||||||||NA\r" + "OBX|1|CE|59784-9^Disease with presumed immunity^LN|1|V02^VFC eligible Medicaid/MedicaidManaged Care^HL70064\r";
    Immunization immunization = ResourceUtils.getImmunization(ftv, hl7VUXmessageRep);
    // RXA.20
    assertThat(immunization.getStatus().getDisplay()).isEqualTo("not-done");
    assertThat(immunization.hasStatusReason()).isTrue();
    assertThat(immunization.getStatusReason().getCoding()).hasSize(2);
    // From OBX.3==59784-9
    assertThat(immunization.getStatusReason().getCoding().get(0).getCode()).isEqualTo("IMMUNE");
    assertThat(immunization.getStatusReason().getCoding().get(0).getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v3-ActReason");
    assertThat(immunization.getStatusReason().getCoding().get(0).getDisplay()).isEqualTo("immunity");
    assertThat(immunization.getStatusReason().getCoding().get(1).getCode()).isEqualTo("59784-9");
    assertThat(immunization.getStatusReason().getCoding().get(1).getSystem()).isEqualTo("http://loinc.org");
    assertThat(immunization.getStatusReason().getCoding().get(1).getDisplay()).isEqualTo("Disease with presumed immunity");
    assertThat(immunization.getStatusReason().getText()).isEqualTo("Disease with presumed immunity");
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Test(org.junit.jupiter.api.Test)

Example 69 with MR

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

the class Hl7ImmunizationFHIRConversionTest method testImmunizationStatusReasonMEDPREC2.

@Test
void testImmunizationStatusReasonMEDPREC2() throws IOException {
    // Status reason is MEDPREC when OBX.3 is 30945-0, RXA.18 empty, and RXA.20 not RE
    String hl7VUXmessageRep = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|20130531||VXU^V04^VXU_V04|20130531RI881401010105|P|2.5.1|||NE|AL||||||RI543763\r" + "PID|1||12345^^^^MR||TestPatient^Jane^^^^^L||||||\r" + "ORC|||197027|||||||^Clerk^Myron|||||||RI2050\r" + // RXA.20 is not RE, so OBX.3==30945-0 is activated; yeilds status not-done and MEDPREC statusReason
    "RXA|0|1|20130531||48^HIB PRP-T^CVX|||||||||||||||NA\r" + "OBX|1|CE|30945-0^contraindication^LN|1|V02^VFC eligible Medicaid/MedicaidManaged Care^HL70064||||||F||||||\r";
    Immunization immunization = ResourceUtils.getImmunization(ftv, hl7VUXmessageRep);
    // RXA-20
    assertThat(immunization.getStatus().getDisplay()).isEqualTo("not-done");
    assertThat(immunization.hasStatusReason()).isTrue();
    assertThat(immunization.getStatusReason().getCoding()).hasSize(2);
    assertThat(immunization.getStatusReason().getCoding().get(0).getCode()).isEqualTo("MEDPREC");
    assertThat(immunization.getStatusReason().getCoding().get(0).getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v3-ActReason");
    assertThat(immunization.getStatusReason().getCoding().get(0).getDisplay()).isEqualTo("medical precaution");
    assertThat(immunization.getStatusReason().getCoding().get(1).getCode()).isEqualTo("30945-0");
    assertThat(immunization.getStatusReason().getCoding().get(1).getSystem()).isEqualTo("http://loinc.org");
    assertThat(immunization.getStatusReason().getCoding().get(1).getDisplay()).isEqualTo("contraindication");
    assertThat(immunization.getStatusReason().getText()).isEqualTo("contraindication");
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Test(org.junit.jupiter.api.Test)

Example 70 with MR

use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR 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)

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