Search in sources :

Example 11 with MedicationRequest

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

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestRouteRXO.

@Test
void dosageInstructionTestRouteRXO() {
    // Test dosageInstruction.Route (RXO.5)
    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^^^^^^dexamethasone (DECADRON) 4 MG TABS|||" + // RXO.5 to dosageInstruction.Route
    "|6064005^Topical route^http://snomed.info/sct|||||||||||||||||\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);
    CodeableConcept route = medicationRequest.getDosageInstructionFirstRep().getRoute();
    // dosageInstruction.route (RXO.5)
    // 5.1
    assertThat(route.getCodingFirstRep().getCode()).isEqualTo("6064005");
    // 5.2
    assertThat(route.getCodingFirstRep().getDisplay()).isEqualTo("Topical route");
    // 5.3
    assertThat(route.getCodingFirstRep().getSystem()).isEqualTo("http://snomed.info/sct");
    // 5.2
    assertThat(route.getText()).isEqualTo("Topical route");
    // 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) CodeableConcept(org.hl7.fhir.r4.model.CodeableConcept) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with MedicationRequest

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

the class Hl7MedicationRequestFHIRConversionTest method testMedicationRequestCategoryRequesterAndDispenseRequest.

@Test
void testMedicationRequestCategoryRequesterAndDispenseRequest() {
    String hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // ORC.29 to category
    "ORC|NW|||||||||||3122^PROVIDER^ORDERING^^^DR|||20190606193536||||||||||||||I\n" + // RXE.13 empty so ORC.12 takes priority
    "RXE|^Q24H&0600^^20210330144208^^ROU|DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|3||mL|47||||||||||||||||||||||||||||||||||\n";
    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);
    // requester comes from ORC.12 which is the back up value for RXE.13
    String requesterRef = medicationRequest.getRequester().getReference();
    Practitioner practBundle = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRef);
    Identifier practitionerIdentifier = practBundle.getIdentifierFirstRep();
    HumanName practName = practBundle.getNameFirstRep();
    // ORC.12.1
    assertThat(practitionerIdentifier.getValue()).isEqualTo("3122");
    // ORC.12.9
    assertThat(practitionerIdentifier.getSystem()).isNull();
    // ORC.12.2
    assertThat(practName.getFamily()).isEqualTo("PROVIDER");
    // ORC.12.3
    assertThat(practName.getGivenAsSingleString()).isEqualTo("ORDERING");
    // ORC.12.6
    assertThat(practName.getPrefixAsSingleString()).isEqualTo("DR");
    // ORC.12.5
    assertThat(practName.getSuffix()).isEmpty();
    // ORC.12
    assertThat(practName.getText()).isEqualTo("DR ORDERING PROVIDER");
    // category comes from  ORC.29
    assertThat(medicationRequest.getCategory()).hasSize(1);
    DatatypeUtils.checkCommonCodeableConceptAssertions(medicationRequest.getCategory().get(0), "inpatient", "Inpatient", "http://terminology.hl7.org/CodeSystem/medicationrequest-category", null);
    // DispenseRequest.start comes from ORC.15
    assertThat(medicationRequest.getDispenseRequest().hasValidityPeriod()).isTrue();
    assertThat(medicationRequest.getDispenseRequest().getValidityPeriod().getStartElement().toString()).containsPattern("2019-06-06");
}
Also used : Practitioner(org.hl7.fhir.r4.model.Practitioner) HumanName(org.hl7.fhir.r4.model.HumanName) MedicationRequest(org.hl7.fhir.r4.model.MedicationRequest) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Identifier(org.hl7.fhir.r4.model.Identifier) Resource(org.hl7.fhir.r4.model.Resource) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 13 with MedicationRequest

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

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestTextRXO.

@Test
void dosageInstructionTestTextRXO() {
    // Test dosageInstruction.text (RXO.6.2)
    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^^^^^^dexamethasone (DECADRON) 4 MG TABS||||" + // RXO.6.2 to dosageInstruction.text (Purposely leave RXO.6.1 empty) take priority over RXE.21
    "|^Take 1 tablet by mouth every 6 (six) hours.||||||||||||||||||\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);
    String txt = medicationRequest.getDosageInstructionFirstRep().getText();
    // dosageInstruction.text (RXO.6.2)
    assertThat(txt).isEqualTo("Take 1 tablet by mouth every 6 (six) hours.");
    // 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) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 14 with MedicationRequest

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

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestPatientInstructionRXO.

@Test
void dosageInstructionTestPatientInstructionRXO() {
    // Test dosageInstruction.patientInstruction (RXO.7)
    String hl7message = "MSH|^~\\\\&|||||20210101000000||OMP^O09|MSGID|T|2.6\n" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|OP||||||||||||||||||||||\n" + // Split and concatenate RXO for easier understanding
    "RXO|00054418425^Dexamethasone 4 MG Oral Tablet^NDC|||||" + // RXO.7 to dosageInstruction.patientInstruction
    "|^Take 1 tablet by mouth every 6 (six) hours.|||||||||||||||||\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);
    String patInstruct = medicationRequest.getDosageInstructionFirstRep().getPatientInstruction();
    // dosageInstruction.patientInstruction (RXO.7.2)
    assertThat(patInstruct).isEqualTo("Take 1 tablet by mouth every 6 (six) hours.");
    // 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) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with MedicationRequest

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

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestRateRatioRXE.

@Test
void dosageInstructionTestRateRatioRXE() {
    // Test dosageInstruction.RateRatio from RXE.22,23,24
    String hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|||||E|||||||||||||||||||||||I\n" + "RXE||DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|||||||||||||||||||" + // RXE.24.3 empty to cause default in dosageInstruction.doseAndRate.rateRatio.numerator.system
    "|PC|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 rateRatio = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getRateRatio();
    // dosageInstruction.doseAndRate.rateRatio.numerator(RXE.23)
    // RXE.23
    assertThat(rateRatio.getNumerator().getValue()).hasToString("7.0");
    // RXE.24
    assertThat(rateRatio.getNumerator().getUnit()).isEqualTo("PC");
    // Defaulted
    assertThat(rateRatio.getNumerator().getSystem()).isEqualTo("http://unitsofmeasure.org");
    // dosageInstruction.doseAndRate.rateRatio.denominator
    assertThat(rateRatio.getDenominator().getValue()).hasToString("1.0");
    // RXE.22
    assertThat(rateRatio.getDenominator().getUnit()).isEqualTo("PC");
    assertThat(rateRatio.getDenominator().getSystem()).isEqualTo("http://unitsofmeasure.org");
    // 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) Ratio(org.hl7.fhir.r4.model.Ratio) 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