Search in sources :

Example 66 with BundleEntryComponent

use of org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent 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 67 with BundleEntryComponent

use of org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent 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 68 with BundleEntryComponent

use of org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent 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 69 with BundleEntryComponent

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

Example 70 with BundleEntryComponent

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

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