Search in sources :

Example 1 with Immunization

use of org.hl7.fhir.r4.model.Immunization 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 2 with Immunization

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

the class Hl7ImmunizationFHIRConversionTest method testImmunizationReasonImmune.

@Test
void testImmunizationReasonImmune() throws IOException {
    // Status reason is IMMUNE when OBX.3 is 59784-9, and RXA.18 and RXA.20 not provided
    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||48^HIB PRP-T^CVX\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);
    // Status defaults to completed
    assertThat(immunization.getStatus().getDisplay()).isEqualTo("completed");
    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 3 with Immunization

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

the class Hl7ImmunizationFHIRConversionTest method testImmunizationAdministrationPlaceOrg3.

@Test
// Third test of priority of Immunization Performer sourcing.
void testImmunizationAdministrationPlaceOrg3() 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 purposely missing
    "ORC|||197027|||||||^Clerk^Myron|||||||RI2050\r" + // RXA.11.4 present and takes priority because there is no RXA.27 nor PV1.3.4
    "RXA|0|1|20130531||48^HIB PRP-T^CVX||||||^^^PlaceRXA11|||||||||||||||" + "OBX|1|CE|59784-9^Disease with presumed immunity^LN||\r";
    // TENANT prepend is passed through the options.
    ConverterOptions customOptionsWithTenant = new Builder().withValidateResource().withPrettyPrint().withProperty("TENANT", "TenantId").build();
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7VUXmessageRep, customOptionsWithTenant);
    // We expect two different organizations, one for Encounter.serviceProvider, one for Immunization.performer
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    assertThat(organizations).hasSize(1);
    Organization org = (Organization) organizations.get(0);
    String orgId = org.getId();
    // RXA.11.4 + tenantid
    assertThat(orgId).isEqualTo("Organization/tenantid.placerxa11");
    List<Resource> immunizations = ResourceUtils.getResourceList(e, ResourceType.Immunization);
    assertThat(immunizations).hasSize(1);
    Immunization imm = (Immunization) immunizations.get(0);
    // RXA.11.4
    assertThat(imm.getPerformer()).hasSize(1);
    // RXA.11.4 + tenantid
    assertThat(imm.getPerformerFirstRep().getActor().getReference()).isEqualTo(orgId);
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    assertThat(encounters).isEmpty();
    // Check for expected resources: Organization, Immunization,  Patient
    assertThat(e).hasSize(3);
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) 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) Test(org.junit.jupiter.api.Test)

Example 4 with Immunization

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

the class Hl7ImmunizationFHIRConversionTest method testImmunizationUsePATOBJ.

@Test
void testImmunizationUsePATOBJ() throws IOException {
    // Test should only return RXA.10, ORC.12  is empty
    // If RXA.20 is RE but RXA.18 is blank then we use PATOBJ from v3ActReason
    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|RE||197027||PA|||||^Clerk^Myron|||||||RI2050\r" + "RXA|||20130531||48^HIB PRP-T^CVX|0.5|ML^^UCUM||||||||||||00^refusal|RE\r" + "OBX|1|CWE|30963-3^ VACCINE FUNDING SOURCE^LN|1|V02^VFC eligible Medicaid/MedicaidManaged Care^HL70064\r";
    Immunization immunization = ResourceUtils.getImmunization(ftv, hl7VUXmessageRep);
    assertThat(immunization.hasReasonCode()).isTrue();
    assertThat(immunization.getReasonCodeFirstRep().getCodingFirstRep().getCode()).isEqualTo("00");
    assertThat(immunization.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isEqualTo("refusal");
    assertThat(immunization.getReasonCodeFirstRep().getCodingFirstRep().getSystem()).isNull();
    assertThat(immunization.getReasonCodeFirstRep().getText()).isEqualTo("refusal");
    assertThat(immunization.getStatus().getDisplay()).isEqualTo("not-done");
    assertThat(immunization.hasStatusReason()).isTrue();
    // If RXA.20 is RE but RXA.18 is blank then we use PATOBJ from v3ActReason
    assertThat(immunization.getStatusReason().getCodingFirstRep().getCode()).isEqualTo("PATOBJ");
    assertThat(immunization.getStatusReason().getCodingFirstRep().getSystem()).isEqualTo("http://terminology.hl7.org/CodeSystem/v3-ActReason");
    assertThat(immunization.getStatusReason().getCodingFirstRep().getDisplay()).isEqualTo("Patient Refusal");
    // dose Quantity with a known system
    assertThat(immunization.hasDoseQuantity()).isTrue();
    assertThat(immunization.getDoseQuantity().getValue()).hasToString("0.5");
    assertThat(immunization.getDoseQuantity().getUnit()).isEqualTo("ML");
    assertThat(immunization.getDoseQuantity().getSystem()).isEqualTo("http://unitsofmeasure.org");
    // If OBX.3 is 30963-3 the OBX.5 is for funding source
    DatatypeUtils.checkCommonCodeableConceptAssertions(immunization.getFundingSource(), "V02", "VFC eligible Medicaid/MedicaidManaged Care", "https://phinvads.cdc.gov/vads/ViewCodeSystem.action?id=2.16.840.1.113883.12.64#", "VFC eligible Medicaid/MedicaidManaged Care");
    assertThat(immunization.hasProgramEligibility()).isFalse();
    assertThat(immunization.hasReaction()).isFalse();
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Test(org.junit.jupiter.api.Test)

Example 5 with Immunization

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

the class Hl7ImmunizationFHIRConversionTest method testImmunizationReturnOnlyRXA10.

@Test
void testImmunizationReturnOnlyRXA10() throws IOException {
    // Test should only return RXA.10, ORC.12  is empty
    // ORC.9 (Backup for RXA.22) has recorded date
    // RXA.18 is not empty which signals that the status is not-done. ORC.5 is here to show precedence
    // Since status is "not-done" we show the Status reason (RXA.18)
    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|RE||197027||CP||||20120901041038|^Clerk^Myron|||||||\r" + "RXA|||20130531||48^HIB PRP-T^CVX|0.5|ML^^^|||^Sticker^Nurse||||||||00^Patient refusal^NIP002|||\r" + "OBX|1|CWE|64994-7^vaccine fund pgm elig cat^LN|1|V02^VFC eligible Medicaid/MedicaidManaged Care^HL70064\r";
    Immunization immunization = ResourceUtils.getImmunization(ftv, hl7VUXmessageRep);
    assertThat(immunization.getPerformer()).hasSize(1);
    DatatypeUtils.checkCommonCodingAssertions(immunization.getPerformer().get(0).getFunction().getCodingFirstRep(), "AP", "Administering Provider", "http://terminology.hl7.org/CodeSystem/v2-0443", // RXA.10
    null);
    assertThat(immunization.getPerformer().get(0).getFunction().hasText()).isFalse();
    // RXA.18 is not empty which signals that the status is not-done. ORC.5 is here to show precedence
    assertThat(immunization.getStatus().getDisplay()).isEqualTo("not-done");
    // if status is "not-done" we show the Status reason
    assertThat(immunization.hasStatusReason()).isTrue();
    assertThat(immunization.getStatusReason().getCodingFirstRep().getCode()).isEqualTo("00");
    assertThat(immunization.getStatusReason().getCodingFirstRep().getSystem()).isEqualTo("urn:id:NIP002");
    assertThat(immunization.getStatusReason().getCodingFirstRep().getDisplay()).isEqualTo("Patient refusal");
    // ORC.9
    assertThat(immunization.hasRecorded()).isTrue();
    // ORC.9
    assertThat(immunization.getRecordedElement().toString()).contains("2012-09-01");
    // dose Quantity without a system
    assertThat(immunization.hasDoseQuantity()).isTrue();
    assertThat(immunization.getDoseQuantity().getValue()).hasToString("0.5");
    assertThat(immunization.getDoseQuantity().getUnit()).isEqualTo("ML");
    assertThat(immunization.getDoseQuantity().getSystem()).isNull();
    assertThat(immunization.getDoseQuantity().getCode()).isNull();
    DatatypeUtils.checkCommonCodeableConceptAssertions(immunization.getProgramEligibilityFirstRep(), "V02", "VFC eligible Medicaid/MedicaidManaged Care", "https://phinvads.cdc.gov/vads/ViewCodeSystem.action?id=2.16.840.1.113883.12.64#", "VFC eligible Medicaid/MedicaidManaged Care");
    assertThat(immunization.hasFundingSource()).isFalse();
    assertThat(immunization.hasReaction()).isFalse();
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Test(org.junit.jupiter.api.Test)

Aggregations

Immunization (org.hl7.fhir.r4.model.Immunization)47 Test (org.junit.Test)27 Test (org.junit.jupiter.api.Test)22 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)18 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)15 Resource (org.hl7.fhir.r4.model.Resource)13 OperationOutcome (org.hl7.fhir.r4.model.OperationOutcome)8 Bundle (org.hl7.fhir.r4.model.Bundle)7 Organization (org.hl7.fhir.r4.model.Organization)7 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)6 Date (java.util.Date)5 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)5 IdType (org.hl7.fhir.r4.model.IdType)5 Observation (org.hl7.fhir.r4.model.Observation)5 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)5 InputStream (java.io.InputStream)4 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)4 Complex (org.hl7.fhir.dstu3.utils.formats.Turtle.Complex)4 Obs (org.openmrs.Obs)4 FhirContext (ca.uhn.fhir.context.FhirContext)3