Search in sources :

Example 71 with BundleEntryComponent

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

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestDoseQuantityRXO.

@Test
void dosageInstructionTestDoseQuantityRXO() {
    // Test dosageInstruction.DoseQuantity where RXO.2 exists -> use RXO segment, no range
    String hl7message = "MSH|^~\\\\&|||||20210101000000||OMP^O09|MSGID|T|2.6\n" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|OP||||||||||||||||||||||\n" + // RXO.5 through RXO.35 not used.
    "RXO|00054418425^Dexamethasone 4 MG Oral Tablet^NDC|100||CC||||||||||||||||||||||||||\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    // Confirm that one medicationRequest was created.
    assertThat(medicationRequestList).hasSize(1);
    MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    Quantity doseQuantity = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getDoseQuantity();
    // dosageInstruction.doseAndRate.doseQuantity RXO.2
    // RXO.2
    assertThat(doseQuantity.getValue()).hasToString("100.0");
    // RXO.4.1
    assertThat(doseQuantity.getUnit()).isEqualTo("CC");
    // default
    assertThat(doseQuantity.getSystem()).isEqualTo("http://unitsofmeasure.org");
    // Verify no extraneous resources
    // Expect MedicationRequest, and Patient
    assertThat(e).hasSize(2);
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Quantity(org.hl7.fhir.r4.model.Quantity) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 72 with BundleEntryComponent

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

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestMaxDosePerPeriodRXO.

@Test
void dosageInstructionTestMaxDosePerPeriodRXO() {
    // Test dosageInstruction.maxDosePerPeriod from RXO.23
    String hl7message = "MSH|^~\\\\&|||||20210101000000||OMP^O09|MSGID|T|2.6\n" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|OP||||||||||||||||||||||\n" + "RXO|00054418425^Dexamethasone 4 MG Oral Tablet^NDC|||||" + // RXO.8 through RXO.22 optional
    "||||||||||||||||" + // RXO.23 to dosageInstruction.maxDosePerPeriod.numerator
    "|7^PC|\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    // Confirm that one medicationRequest was created.
    assertThat(medicationRequestList).hasSize(1);
    MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    Ratio maxDose = medicationRequest.getDosageInstructionFirstRep().getMaxDosePerPeriod();
    // dosageInstruction.maxDosePerPeriod.numerator(RXO.23)
    assertThat(maxDose.getNumerator().getValue()).hasToString("7.0");
    assertThat(maxDose.getNumerator().getUnit()).isEqualTo("PC");
    assertThat(maxDose.getNumerator().getSystem()).isEqualTo("http://unitsofmeasure.org");
    // dosageInstruction.maxDosePerPeriod.denominator
    assertThat(maxDose.getDenominator().getValue()).hasToString("1.0");
    assertThat(maxDose.getDenominator().getUnit()).isEqualTo("day");
    assertThat(maxDose.getDenominator().getSystem()).isEqualTo("http://unitsofmeasure.org");
    // Verify no extraneous resources
    // Expect MedicationRequest, Patient, and Encounter
    assertThat(e).hasSize(3);
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Ratio(org.hl7.fhir.r4.model.Ratio) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 73 with BundleEntryComponent

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

the class Hl7MedicationRequestFHIRConversionTest method dispenseRequestTestRXE.

@Test
void dispenseRequestTestRXE() {
    // Get DispenseRequest from RXE segment (RXE.10, RXE.11.1 and RXE.11.3)
    String hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW||||||||||||||||||||||||||||\n" + "RXE||DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|||||||" + // RXE.39 to dispenseRequest.InitialFill.Quantity
    "|1|PC^^measureofunits|0|||||||||||||||||||||||||||7|\n";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    // Confirm that one medicationRequest was created.
    assertThat(medicationRequestList).hasSize(1);
    MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    MedicationRequest.MedicationRequestDispenseRequestComponent disReq = medicationRequest.getDispenseRequest();
    // dispenseRequest.Quantity comes from RXE.10, RXE.11.1 and RXE.11.3
    assertThat(disReq.getQuantity().getValue()).hasToString("1.0");
    assertThat(disReq.getQuantity().getUnit()).isEqualTo("PC");
    assertThat(disReq.getQuantity().getSystem()).isEqualTo("urn:id:measureofunits");
    // dispenseRequest.NumberOfRepeatsAllowed RXE.12
    assertThat(disReq.getNumberOfRepeatsAllowed()).hasToString("0");
    // dispenseRequest.InitialFill.Quantity comes from RXE.39
    assertThat(disReq.getInitialFill().getQuantity().getValue()).hasToString("7.0");
    // Verify no extraneous resources
    // Expect MedicationRequest, Patient
    assertThat(e).hasSize(2);
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 74 with BundleEntryComponent

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

the class Hl7MedicationRequestFHIRConversionTest method testMedicationRequestReasonCode.

@Test
void testMedicationRequestReasonCode() {
    // Reason code from RXO.20, should ignore ORC.16
    String hl7message = "MSH|^~\\&||||||S1|PPR^PC1||T|2.6|||||||||\r" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\r" + "PRB|AD|20141015103243|15777000^Prediabetes (disorder)^SNM|654321^^OtherSoftware.ProblemOID|||||\r" + // ORC.16 purposely present to be ignored because RXO.20 is present
    "ORC|NW|||||||||||||||4338008^Wheezing^PRN\r" + "OBR|1|||555|||20170825010500||||||||||||||||||F\r" + // RXO.2 through RXO.35 otherwise purposely empty
    "RXO|65862-063-01^METOPROLOL TARTRATE^NDC|||||||||||||||||||134006\r";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getReasonCode()).hasSize(1);
    assertThat(medicationRequest.getReasonCodeFirstRep().getCoding()).hasSize(1);
    // RXO.20.1
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getCode()).isEqualTo("134006");
    // No RXO.20.2
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isNull();
    // No RXO.20.3
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getSystem()).isNull();
    // Reason code from RXE.27. Ignores ORC.16.
    hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // ORC.16 purposely present to be ignored because RXE.27 is present
    "ORC|NW|||||||||||||||4338008^Wheezing^PRN\n" + // RXE.6 through RXE.44 otherwise purposely empty
    "RXE|^Q24H&0600^^20210330144208^^ROU|DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|3||mL||||||||||||||||||||||Wheezing^Wheezing^PRN|||||||||||||\r";
    e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getReasonCode()).hasSize(1);
    assertThat(medicationRequest.getReasonCodeFirstRep().getCoding()).hasSize(1);
    // RXE.27
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getCode()).isEqualTo("Wheezing");
    // RXE.27
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isEqualTo("Wheezing");
    // RXE.27
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getSystem()).isEqualTo("urn:id:PRN");
    // Reason code from ORC.16 (when RXE.27 is not present)
    hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // ORC.16 to reason code
    "ORC|NW|||||||||||||||4338008^Wheezing^PRN\n" + // RXE.6 through RXE.44 purposely empty
    "RXE|^Q24H&0600^^20210330144208^^ROU|DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|3||mL|||||||||||||||||||||||||||||||||||\n";
    e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
    assertThat(medicationRequestList).hasSize(1);
    medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
    assertThat(medicationRequest.getReasonCode()).hasSize(1);
    assertThat(medicationRequest.getReasonCodeFirstRep().getCoding()).hasSize(1);
    // ORC.16.1
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getCode()).isEqualTo("4338008");
    // ORC.16.2
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getDisplay()).isEqualTo("Wheezing");
    // ORC.16.3 (unknown system)
    assertThat(medicationRequest.getReasonCodeFirstRep().getCodingFirstRep().getSystem()).isEqualTo("urn:id:PRN");
}
Also used : MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Resource(org.hl7.fhir.r4.model.Resource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 75 with BundleEntryComponent

use of org.hl7.fhir.r4.model.Bundle.BundleEntryComponent 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)

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