use of org.hl7.fhir.dstu2.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");
}
use of org.hl7.fhir.dstu2.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);
}
use of org.hl7.fhir.dstu2.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);
}
use of org.hl7.fhir.dstu2.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);
}
use of org.hl7.fhir.dstu2.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);
}
Aggregations