Search in sources :

Example 16 with MedicationRequest

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

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestDoseRangeRXO.

@Test
void dosageInstructionTestDoseRangeRXO() {
    // Test dosageInstruction.DoseRange using RXO segment WITH a range (RXO.2 exists and RXO.3 exists)
    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^^^^^^dexamethasone (DECADRON) 4 MG TABS|100|150|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);
    Range doseRange = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getDoseRange();
    // doseRange.low(RXO.2)
    assertThat(doseRange.getLow().getValue()).hasToString("100.0");
    // RXO.4
    assertThat(doseRange.getLow().getUnit()).isEqualTo("CC");
    // Defaulted
    assertThat(doseRange.getLow().getSystem()).isEqualTo("http://unitsofmeasure.org");
    // doseRange.high(RXO.3)
    assertThat(doseRange.getHigh().getValue()).hasToString("150.0");
    // RXO.4
    assertThat(doseRange.getHigh().getUnit()).isEqualTo("CC");
    // Defaulted
    assertThat(doseRange.getHigh().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) Range(org.hl7.fhir.r4.model.Range) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 17 with MedicationRequest

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

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

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

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

Aggregations

MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)128 Test (org.junit.Test)128 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)78 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)58 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)48 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)44 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)44 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)44 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)36 Test (org.junit.jupiter.api.Test)35 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)33 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)33 Resource (org.hl7.fhir.r4.model.Resource)31 MedicationRequest (org.hl7.fhir.dstu3.model.MedicationRequest)26 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)23 TokenParam (ca.uhn.fhir.rest.param.TokenParam)23 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)23 ArrayList (java.util.ArrayList)19 Include (ca.uhn.fhir.model.api.Include)15 HashSet (java.util.HashSet)15