Search in sources :

Example 56 with Immunization

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

the class Hl7ImmunizationFHIRConversionTest method testImmunizationTestORC5BackupForRXA20.

@Test
void testImmunizationTestORC5BackupForRXA20() throws IOException {
    // ORC.5 backs up RXA.20 and 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|||197027||PA|||||^Clerk^Myron|||||||RI2050\r" + "RXA|0|1|20130531||48^HIB PRP-T^CVX|999|ML^^UCUM||||||||||||||A\r";
    Immunization immunization = ResourceUtils.getImmunization(ftv, hl7VUXmessageRep);
    // doseQuantity with 999 as the value which should return null;
    assertThat(immunization.hasDoseQuantity()).isFalse();
    // ORC.5 backs up RXA.20 and RXA.18
    assertThat(immunization.getStatus().getDisplay()).isEqualTo("completed");
    assertThat(immunization.hasStatusReason()).isFalse();
    assertThat(immunization.hasReaction()).isFalse();
    assertThat(immunization.hasProgramEligibility()).isFalse();
    assertThat(immunization.hasFundingSource()).isFalse();
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Test(org.junit.jupiter.api.Test)

Example 57 with Immunization

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

the class Hl7ImmunizationFHIRConversionTest method testMultipleImmunizationsNoInterference.

// TODO: 10/15/21 RXA.9 (also mapped to primarySource)
// The following checks for a situation where non-manufacturer RXA Immunizations interfered with the creation of manufacturer Immununization
// The test will ensure the problem doesn't come back.
@Test
void testMultipleImmunizationsNoInterference() throws IOException {
    String hl7VUXmessageRep = "MSH|^~\\&|||||20130531||VXU^V04^VXU_V04|20130531RI881401010105|P|2.5.1||||||||||\r" + "PID|1||12345^^^^MR||TestPatient^Jane^^^^^L||||||\r" + // First Immunization, also create manufacturer reference to Organization sanofi
    "ORC|RE||197027||ER||||||||||||RI2050\r" + // ORC.5 is here to prove RXA.20 is taking precedence
    "RXA|0|1|20130531|20130531|48^HIB PRP-T^CVX|0.5|ML^^ISO+||||||||33k2a|20131210|PMC^sanofi^MVX|||CP|A|\r" + // Second Immunization.  No manufacturer or Organization created. No RXA.11 nor RXA.27
    "ORC|RE||IZ-783278^NDA||||||||||||||\r" + "RXA|0|1|20170513|20170513|62^HPV quadrivalent^CVX|999||||||||||||00^Parental Refusal^NIP002||RE\r" + // Third Immunization, also create manufacturer reference to Organization merck
    "ORC|RE||IZ-783279^NDA||||||||||||||\r" + "RXA|0|1|20170513|20170513|136^MCV4-CRM^CVX^90734^MCV4-CRM^CPT|1|mL||||||||MRK1234|20211201|MSD^MERCK^MVX||||CP|A\r";
    List<Bundle.BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7VUXmessageRep);
    List<Resource> immunizations = ResourceUtils.getResourceList(e, ResourceType.Immunization);
    // Exactly 3
    assertThat(immunizations).hasSize(3);
    // This maps manufacturer to drug name from RXA records above
    Map<String, String> mapMfgNameToDrugName = new HashMap<>();
    mapMfgNameToDrugName.put("MERCK", "MCV4-CRM");
    mapMfgNameToDrugName.put("sanofi", "HIB PRP-T");
    // This maps Immunization drug name to manufacturer reference Id (the GUID)
    Map<String, String> mapDrugNameToMfgRefId = new HashMap<>();
    for (int immunizationIndex = 0; immunizationIndex < immunizations.size(); immunizationIndex++) {
        // condIndex is index for condition
        Immunization immunization = ResourceUtils.getResourceImmunization(immunizations.get(immunizationIndex), ResourceUtils.context);
        String mfgId = immunization.hasManufacturer() ? immunization.getManufacturer().getReference() : null;
        String codeText = immunization.getVaccineCode().getText();
        mapDrugNameToMfgRefId.put(codeText, mfgId);
    }
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // Exactly 2
    assertThat(organizations).hasSize(2);
    // For each organization, we look up the name, get the known drug, get the manufacturer Id and see it is the same.
    for (int orgIndex = 0; orgIndex < organizations.size(); orgIndex++) {
        // orgIndex is index for organization
        Organization org = ResourceUtils.getResourceOrganization(organizations.get(orgIndex), ResourceUtils.context);
        assertThat(mapDrugNameToMfgRefId.get(mapMfgNameToDrugName.get(org.getName()))).contains(org.getId());
    }
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Organization(org.hl7.fhir.r4.model.Organization) HashMap(java.util.HashMap) Resource(org.hl7.fhir.r4.model.Resource) Test(org.junit.jupiter.api.Test)

Example 58 with Immunization

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

the class Hl7ImmunizationFHIRConversionTest method testImmunizationAdministrationPlaceOrg2.

@Test
// There will only be one created organization, because any duplicates are de-duplicated.
void testImmunizationAdministrationPlaceOrg2() 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 place id
    "PV1||O|^^^PlacePV1.3.4\r" + "ORC|||197027|||||||^Clerk^Myron|||||||RI2050\r" + // RXA.12 - RXA.27 not used
    "RXA|0|1|20130531||48^HIB PRP-T^CVX||||||^^^PlaceRXA11||||||||||||||||" + "OBX|1|CE|59784-9^Disease with presumed immunity^LN||\r";
    List<Bundle.BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7VUXmessageRep);
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    // Proves that deduplication worked
    assertThat(organizations).hasSize(1);
    Organization org = (Organization) organizations.get(0);
    // PV1.3.4
    String orgId = org.getId();
    // PV1.3.4
    assertThat(orgId).isEqualTo("Organization/placepv1.3.4");
    List<Resource> immunizations = ResourceUtils.getResourceList(e, ResourceType.Immunization);
    assertThat(immunizations).hasSize(1);
    Immunization imm = (Immunization) immunizations.get(0);
    // PV1.3.4
    assertThat(imm.getPerformer()).hasSize(1);
    assertThat(imm.getPerformerFirstRep().getActor().getReference()).isEqualTo(orgId);
    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(orgId);
    // Check for expected resources: Organization, Immunization, Encounter, Patient
    assertThat(e).hasSize(4);
}
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 59 with Immunization

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

the class Hl7IdentifierFHIRConversionTest method immunizationIdentifierTest.

@Test
void immunizationIdentifierTest() {
    // RXA-5.1 and RXA-5.3, concatenate together with a dash
    String field1AndField3 = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|20130531||VXU^V04^VXU_V04|20130531RI881401010105|P|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "PID|1||432155^^^ANF^MR||Patient^Johnny^New^^^^L\r" + "ORC|RE||197027|||||||||M|||||RI2050\r" + "RXA|0|1|20130531|20130531|48^HIB PRP-T^CVX||||00^new immunization record^NIP001|||||||20131210||||CP|A\r";
    Immunization immunization = ResourceUtils.getImmunization(ftv, field1AndField3);
    // Expect a single identifier
    assertThat(immunization.hasIdentifier()).isTrue();
    assertThat(immunization.getIdentifier()).hasSize(1);
    // Identifier: extRef from RXA.5
    Identifier identifier = immunization.getIdentifier().get(0);
    String value = identifier.getValue();
    String system = identifier.getSystem();
    assertThat(value).isEqualTo("48-CVX");
    assertThat(system).isEqualTo("urn:id:extID");
    // RXA-5.1 and RXA-5.2, use RXA5.1
    String field1AndField2 = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|20130531||VXU^V04^VXU_V04|20130531RI881401010105|P|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "PID|1||432155^^^ANF^MR||Patient^Johnny^New^^^^L\r" + "ORC|RE||197027||||||||||||||RI2050\r" + "RXA|0|1|20130531|20130531|48^HIB PRP-T||||00^new immunization record^NIP001|||||||20131210||||CP|A\r";
    immunization = ResourceUtils.getImmunization(ftv, field1AndField2);
    // Expect a single identifier
    assertThat(immunization.hasIdentifier()).isTrue();
    assertThat(immunization.getIdentifier()).hasSize(1);
    // Identifier: extRef from RXA.5
    identifier = immunization.getIdentifier().get(0);
    value = identifier.getValue();
    system = identifier.getSystem();
    assertThat(value).isEqualTo("48");
    assertThat(system).isEqualTo("urn:id:extID");
    // RXA-5.2 only
    String justField2 = "MSH|^~\\&|MYEHR2.5|RI88140101|KIDSNET_IFL|RIHEALTH|20130531||VXU^V04^VXU_V04|20130531RI881401010105|P|2.6|||AL|NE|764|ASCII||||||^4086::132:2A57:3C28^IPv6\r" + "PID|1||432155^^^ANF^MR||Patient^Johnny^New^^^^L\r" + "ORC|RE||197027||||||||||||||RI2050\r" + "RXA|0|1|20130531|20130531|^HIB PRP-T||||00^new immunization record^NIP001|||||||20131210||||CP|A\r";
    immunization = ResourceUtils.getImmunization(ftv, justField2);
    // Expect a single identifier
    assertThat(immunization.hasIdentifier()).isTrue();
    assertThat(immunization.getIdentifier()).hasSize(1);
    // Identifier: extRef from RXA.5
    identifier = immunization.getIdentifier().get(0);
    value = identifier.getValue();
    system = identifier.getSystem();
    assertThat(value).isEqualTo("HIB PRP-T");
    assertThat(system).isEqualTo("urn:id:extID");
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) Identifier(org.hl7.fhir.r4.model.Identifier) Test(org.junit.jupiter.api.Test)

Example 60 with Immunization

use of org.hl7.fhir.r4.model.Immunization in project openmrs-module-fhir2 by openmrs.

the class FhirImmunizationServiceImplTest method saveImmunization_shouldCreateEncounterAndObsGroupWhenNewImmunization.

@Test
public void saveImmunization_shouldCreateEncounterAndObsGroupWhenNewImmunization() {
    // setup
    FhirContext ctx = FhirContext.forR4();
    IParser parser = ctx.newJsonParser();
    Immunization newImmunization = parser.parseResource(Immunization.class, "{\n" + "  \"resourceType\": \"Immunization\",\n" + "  \"status\": \"completed\",\n" + "  \"vaccineCode\": {\n" + "    \"coding\": [\n" + "      {\n" + "        \"code\": \"15f83cd6-64e9-4e06-a5f9-364d3b14a43d\",\n" + "        \"display\": \"Aspirin as a vaccine\"\n" + "      }\n" + "    ]\n" + "  },\n" + "  \"patient\": {\n" + "    \"reference\": \"Patient/a7e04421-525f-442f-8138-05b619d16def\",\n" + "    \"type\": \"Patient\"\n" + "  },\n" + "  \"encounter\": {\n" + "    \"reference\": \"Encounter/7d8c1980-6b78-11e0-93c3-18a905e044dc\",\n" + "    \"type\": \"Encounter\"\n" + "  },\n" + "  \"occurrenceDateTime\": \"2020-07-08T18:30:00.000Z\",\n" + "  \"manufacturer\": {\n" + "    \"display\": \"Acme\"\n" + "  },\n" + "  \"lotNumber\": \"FOO1234\",\n" + "  \"expirationDate\": \"2022-07-31T18:30:00.000Z\",\n" + "  \"performer\": [\n" + "    {\n" + "      \"actor\": {\n" + "        \"reference\": \"Practitioner/f9badd80-ab76-11e2-9e96-0800200c9a66\",\n" + "        \"type\": \"Practitioner\"\n" + "      }\n" + "    }\n" + "  ],\n" + "  \"protocolApplied\": [\n" + "    {\n" + "      \"doseNumberPositiveInt\": 2,\n" + "      \"series\": \"Dose 2\"\n" + "    }\n" + "  ]\n" + "}");
    // replay
    Immunization savedImmunization = service.create(newImmunization);
    Obs obs = obsService.getObsByUuid(savedImmunization.getId());
    // verify
    helper.validateImmunizationObsGroup(obs);
    assertObsCommons(obs, "a7e04421-525f-442f-8138-05b619d16def", "7d8c1980-6b78-11e0-93c3-18a905e044dc", "f9badd80-ab76-11e2-9e96-0800200c9a66");
    obs.getGroupMembers().forEach(o -> assertObsCommons(o, "a7e04421-525f-442f-8138-05b619d16def", "7d8c1980-6b78-11e0-93c3-18a905e044dc", "f9badd80-ab76-11e2-9e96-0800200c9a66"));
    Map<String, Obs> members = helper.getObsMembersMap(obs);
    assertThat(members.get(CIEL_984).getValueCoded().getUuid(), is("15f83cd6-64e9-4e06-a5f9-364d3b14a43d"));
    assertThat(members.get(CIEL_1410).getValueDatetime(), equalTo(new DateTimeType("2020-07-08T18:30:00.000Z").getValue()));
    assertThat(members.get(CIEL_1418).getValueNumeric(), equalTo(2.0));
    assertThat(members.get(CIEL_1419).getValueText(), is("Acme"));
    assertThat(members.get(CIEL_1420).getValueText(), is("FOO1234"));
    assertThat(members.get(CIEL_165907).getValueDatetime(), equalTo(new DateTimeType("2022-07-31T18:30:00.000Z").getValue()));
}
Also used : Obs(org.openmrs.Obs) FhirContext(ca.uhn.fhir.context.FhirContext) Immunization(org.hl7.fhir.r4.model.Immunization) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) IParser(ca.uhn.fhir.parser.IParser) BaseModuleContextSensitiveTest(org.openmrs.test.BaseModuleContextSensitiveTest) Test(org.junit.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