use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method test_medicationreq_patient.
// private static FHIRContext context = new FHIRContext(true, false);
// private static final Logger LOGGER = LoggerFactory.getLogger(Hl7MedicationRequestFHIRConversionTest.class);
@Test
void test_medicationreq_patient() {
String hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I|6N^1234^A^GENHOS||||0100^ANDERSON,CARL|0148^ADDISON,JAMES||SUR|||||||0100^ANDERSON,CARL|S|V446911|A|||||||||||||||||||SF|K||||20180622230000\n" + "ORC|NW|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
List<Resource> patientList = ResourceUtils.getResourceList(e, ResourceType.Patient);
assertThat(patientList).hasSize(1);
Patient patient = ResourceUtils.getResourcePatient(patientList.get(0), ResourceUtils.context);
List<Resource> medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
MedicationRequest medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getSubject()).isNotNull();
assertThat(medicationRequest.getSubject().getReference()).isEqualTo(patient.getId());
// Test that RDE_O11 messages don't create ServiceRequests
List<Resource> serviceRequestList = ResourceUtils.getResourceList(e, ResourceType.ServiceRequest);
// Confirm that a serviceRequest was not created.
assertThat(serviceRequestList).isEmpty();
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method test_medicationCodeableConcept_authoredOn_and_intent_in_rde_with_just_rxe.
// Tests medication request fields MedicationCodeableConcept, Authored On, and Intent.
// Tests with supported message types RDE-O11, RDE-O25.
// With just the RXE segment.
@ParameterizedTest
@ValueSource(strings = { "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\r", "MSH|^~\\&||||||S1|RDE^O25||T|2.6|||||||||\r" })
void test_medicationCodeableConcept_authoredOn_and_intent_in_rde_with_just_rxe(String msh) {
// AuthoredOn comes from RXE.32
String hl7message = msh + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20190622160000\n" + // RXE.32 to MedicationRequest.AuthoredOn
"RXE|||3||mL|47||||1|PC||||||||||||||||||||DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|20180622230000||||||||\n";
// RXE.31
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);
// Verify Authored On date is correct (RXE.32)
Date authoredOnDate = medicationRequest.getAuthoredOn();
Calendar c = Calendar.getInstance();
c.clear();
// 2018 06 22 23 00 00 -- June is 05
c.set(2018, 5, 22, 23, 0);
ZoneId zone = ConverterConfiguration.getInstance().getZoneId();
TimeZone timeZone = TimeZone.getTimeZone(zone);
c.setTimeZone(timeZone);
Date authoredOnDateTest = c.getTime();
assertThat(authoredOnDate).isEqualTo(authoredOnDateTest);
// Verify intent is set correctly (Hardcoded for all MedicalRequests in template)
String intent = medicationRequest.getIntent().toString();
assertThat(intent).isEqualTo("ORDER");
// Verify medicationCodeableConcept is set correctly RXE.31
assertThat(medicationRequest.hasMedicationCodeableConcept()).isTrue();
CodeableConcept medCC = medicationRequest.getMedicationCodeableConcept();
assertThat(medCC.getText()).isEqualTo("3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN");
assertThat(medCC.getCoding().get(0).getSystem()).isEqualTo("urn:id:ADS");
assertThat(medCC.getCoding().get(0).getCode()).isEqualTo("DUONEB3INH");
assertThat(medCC.getCoding().get(0).getDisplay()).isEqualTo("3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN");
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method test_medicationCodeableConcept_authoredOn_and_intent_in_rde_with_rxO_with_rxe.
// Tests medication request fields MedicationCodeableConcept, Authored On, and Intent.
// Tests with supported message types RDE-O11, RDE-O25.
// With both RXO and RXE segments, only RXE will be used.
@ParameterizedTest
@ValueSource(strings = { "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\r", "MSH|^~\\&||||||S1|RDE^O25||T|2.6|||||||||\r" })
void test_medicationCodeableConcept_authoredOn_and_intent_in_rde_with_rxO_with_rxe(String msh) {
// AuthoredOn comes from ORC.9 (the backup value) No RXE.32
String hl7message = msh + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE^NDC||100||mg|||||G||10||5\n" + "RXE||DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS||||||||||||||||||||||||||||||||||||||\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);
// Verify Authored On date is correct.
Date authoredOnDate = medicationRequest.getAuthoredOn();
Calendar c = Calendar.getInstance();
c.clear();
// 2018 06 22 23 00 00 -- june is 05 //ORC.9
c.set(2018, 5, 22, 23, 0);
ZoneId zone = ConverterConfiguration.getInstance().getZoneId();
TimeZone timeZone = TimeZone.getTimeZone(zone);
c.setTimeZone(timeZone);
Date authoredOnDateTest = c.getTime();
assertThat(authoredOnDate).isEqualTo(authoredOnDateTest);
// Verify intent is set correctly
String intent = medicationRequest.getIntent().toString();
assertThat(intent).isEqualTo("ORDER");
// Very medicationCodeableConcept is set correctly RXE.2
assertThat(medicationRequest.hasMedicationCodeableConcept()).isTrue();
CodeableConcept medCC = medicationRequest.getMedicationCodeableConcept();
assertThat(medCC.getText()).isEqualTo("3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN");
assertThat(medCC.getCoding().get(0).getSystem()).isEqualTo("urn:id:ADS");
assertThat(medCC.getCoding().get(0).getCode()).isEqualTo("DUONEB3INH");
assertThat(medCC.getCoding().get(0).getDisplay()).isEqualTo("3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN");
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method testMedicationRequestCategoryRequesterAndDispenseRequest2.
@Test
void testMedicationRequestCategoryRequesterAndDispenseRequest2() {
String hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + // ORC.12 purposely present but ignored by RXE.13 priority
"ORC|NW|||||||||||3122^PROVIDER^ORDERING^^^DR|||||||||||||||||\n" + "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||||||" + // RXE.13 to practitioner take priority over ORC.12
"|2213^ORDERING^PROVIDER|||||||||||||||||||||||||||\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 RXE.13
String requesterRef = medicationRequest.getRequester().getReference();
Practitioner practBundle = ResourceUtils.getSpecificPractitionerFromBundleEntriesList(e, requesterRef);
Identifier practitionerIdentifier = practBundle.getIdentifierFirstRep();
HumanName practName = practBundle.getNameFirstRep();
CodeableConcept practitionerIdentifierType = practitionerIdentifier.getType();
// Check meta extension.display is null
Extension ext = practBundle.getMeta().getExtension().get(0);
assertThat(ext).isNotNull();
CodeableConcept cc = (CodeableConcept) ext.getValue();
assertThat(cc.hasCoding()).isTrue();
assertThat(cc.getCoding().get(0).getDisplay()).isNull();
DatatypeUtils.checkCommonCodeableConceptAssertions(practitionerIdentifierType, "DEA", "Drug Enforcement Administration registration number", "http://terminology.hl7.org/CodeSystem/v2-0203", null);
// RXE.13.1
assertThat(practitionerIdentifier.getValue()).isEqualTo("2213");
// RXE.13.9
assertThat(practitionerIdentifier.getSystem()).isNull();
// RXE.13.2
assertThat(practName.getFamily()).isEqualTo("ORDERING");
// RXE.13.3
assertThat(practName.getGivenAsSingleString()).isEqualTo("PROVIDER");
// RXE.13.6
assertThat(practName.getPrefix()).isEmpty();
// RXE.13.5
assertThat(practName.getSuffix()).isEmpty();
// RXE.13
assertThat(practName.getText()).isEqualTo("PROVIDER ORDERING");
}
use of org.hl7.fhir.r4.model.codesystems.V3Hl7PublishingDomain.MR in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7MedicationRequestFHIRConversionTest method test_medicationreq_status.
@Test
void test_medicationreq_status() {
// ORC.5 = A -> Expected medication status = (ACTIVE ORC.1 is present but ORC.5 takes precedence)
String hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX||A|E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\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);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.ACTIVE);
// ORC.5 = CM -> Expected medication status = COMPLETED (ORC.1 is present but ORC.5 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX||CM|E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.COMPLETED);
// ORC.5 = ER -> Expected medication status = ENTEREDINERROR (ORC.1 is present but ORC.5 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX||ER|E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.ENTEREDINERROR);
// ORC.1 = NW -> Expected medication status = ACTIVE (Missing ORC.5 so ORC.1 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.ACTIVE);
// ORC.1 = RP -> Expected medication status = UNKNOWN (Missing ORC.5 so ORC.1 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|RP|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.UNKNOWN);
// ORC.1 = DC -> Expected medication status = STOPPED (Missing ORC.5 so ORC.1 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|DC|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.STOPPED);
// Test that RDE_O11 messages don't create ServiceRequests
List<Resource> serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
// Confirm that a serviceRequest was not created.
assertThat(serviceRequestList).isEmpty();
// ORC.1 = CA -> Expected medication status = CANCELLED (Missing ORC.5 so ORC.1 takes precedence)
hl7message = "MSH|^~\\&|APP|FAC|WHIA|IBM|20180622230000||RDE^O11^RDE_O11|MSGID221xx0xcnvMed31|T|2.6\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||I|6N^1234^A^GENHOS||||0100^ANDERSON,CARL|0148^ADDISON,JAMES||SUR|||||||0100^ANDERSON,CARL|S|V446911|A|||||||||||||||||||SF|K||||20180622230000\n" + "ORC|CA|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||20180622230000\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE|100||mg|||||G||10||5\n" + "RXE|^^^20180622230000^^R|62756-017^Testosterone Cypionate^NDC|100||mg|||||10||5\n";
e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
medicationRequestList.clear();
medicationRequestList = ResourceUtils.getResourceList(e, ResourceType.MedicationRequest);
assertThat(medicationRequestList).hasSize(1);
medicationRequest = ResourceUtils.getResourceMedicationRequest(medicationRequestList.get(0), ResourceUtils.context);
assertThat(medicationRequest.getStatus()).isEqualTo(MedicationRequestStatus.CANCELLED);
// Test that RDE_O11 messages don't create ServiceRequests
serviceRequestList.clear();
serviceRequestList = e.stream().filter(v -> ResourceType.ServiceRequest == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
// Confirm that a serviceRequest was not created.
assertThat(serviceRequestList).isEmpty();
}
Aggregations