Search in sources :

Example 1 with Medication

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

the class Hl7AllergyFHIRConversionTest method test_allergy_no_severity_no_coding_system.

@Test
void test_allergy_no_severity_no_coding_system() {
    String hl7message = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|0010||PID1234^5^M11^A^MR^HOSP~1234568965^^^USA^SS||DOE^JOHN^A^||19800202|F||W|111 TEST_STREET_NAME^^TEST_CITY^NY^111-1111^USA||(905)111-1111|||S|ZZ|12^^^124|34-13-312||||TEST_BIRTH_PLACE\r" + "AL1|1|DA|00000741^OXYCODONE||HYPOTENSION\r";
    AllergyIntolerance allergy = ResourceUtils.getAllergyResource(ftv, hl7message);
    assertThat(allergy.hasCriticality()).isFalse();
    assertThat(allergy.getCategory().get(0).getCode()).isEqualTo("medication");
    assertThat(allergy.getCode().getText()).isEqualTo("OXYCODONE");
    List<Coding> codings = allergy.getCode().getCoding();
    Assertions.assertEquals(1, codings.size());
    Coding coding = codings.get(0);
    Assertions.assertEquals("00000741", coding.getCode());
    Assertions.assertEquals("OXYCODONE", coding.getDisplay());
    assertThat(allergy.getReaction().get(0).getManifestation()).extracting(m -> m.getText()).containsExactly("HYPOTENSION");
}
Also used : Test(org.junit.jupiter.api.Test) List(java.util.List) Date(java.util.Date) Coding(org.hl7.fhir.r4.model.Coding) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions(org.junit.jupiter.api.Assertions) ResourceUtils(io.github.linuxforhealth.hl7.segments.util.ResourceUtils) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) HL7ToFHIRConverter(io.github.linuxforhealth.hl7.HL7ToFHIRConverter) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Coding(org.hl7.fhir.r4.model.Coding) Test(org.junit.jupiter.api.Test)

Example 2 with Medication

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

the class Hl7AllergyFHIRConversionTest method test_allergy_single.

@Test
void test_allergy_single() {
    String hl7message = "MSH|^~\\&|SE050|050|PACS|050|20120912011230||ADT^A01|102|T|2.6|||AL|NE\r" + "PID|0010||PID1234^5^M11^A^MR^HOSP~1234568965^^^USA^SS||DOE^JOHN^A^||19800202|F||W|111 TEST_STREET_NAME^^TEST_CITY^NY^111-1111^USA||(905)111-1111|||S|ZZ|12^^^124|34-13-312||||TEST_BIRTH_PLACE\r" + "AL1|1|DA|^PENICILLIN|MI|PRODUCES HIVES~RASH|MI\r" + "AL1|2|AA|^CAT DANDER|SV";
    AllergyIntolerance allergy = ResourceUtils.getAllergyResource(ftv, hl7message);
    assertThat(allergy.getCriticality().toCode()).isEqualTo("low");
    assertThat(allergy.getCategory().get(0).getCode()).isEqualTo("medication");
    assertThat(allergy.getCode().getText()).isEqualTo("PENICILLIN");
    assertThat(allergy.getReaction().get(0).getManifestation()).extracting(m -> m.getText()).containsExactlyInAnyOrder("PRODUCES HIVES", "RASH");
}
Also used : Test(org.junit.jupiter.api.Test) List(java.util.List) Date(java.util.Date) Coding(org.hl7.fhir.r4.model.Coding) DateTimeType(org.hl7.fhir.r4.model.DateTimeType) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions(org.junit.jupiter.api.Assertions) ResourceUtils(io.github.linuxforhealth.hl7.segments.util.ResourceUtils) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) HL7ToFHIRConverter(io.github.linuxforhealth.hl7.HL7ToFHIRConverter) AllergyIntolerance(org.hl7.fhir.r4.model.AllergyIntolerance) Test(org.junit.jupiter.api.Test)

Example 3 with Medication

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

the class Hl7MedicationRequestFHIRConversionTest method test_medicationCodeableConcept_and_intent_in_OMP_and_ORM.

// Tests medication request fields MedicationCodeableConcept and Intent.
// Tests with supported message types ORM-O01, OMP-O09.
// With just the RXO segment -- these message types don't support RXE.
@ParameterizedTest
@ValueSource(strings = { "MSH|^~\\&||||||S1|OMP^O09||T|2.6|||||||||\r", // --UNCOMMENT BELOW WHEN CONVERTER SUPPORTS THIS MESSAGE TYPE--
"MSH|^~\\&||||||S1|ORM^O01||T|2.6|||||||||\r" })
void test_medicationCodeableConcept_and_intent_in_OMP_and_ORM(String msh) {
    String hl7message = msh + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||\n" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE^NDC||100||mg|||||G||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);
    // Verify authored on is not present
    assertThat(medicationRequest.getAuthoredOn()).isNull();
    // Verify intent is set correctly (Hardcoded for all MedicalRequests in template)
    String intent = medicationRequest.getIntent().toString();
    assertThat(intent).isEqualTo("ORDER");
    // Very medicationCodeableConcept is set correctly (RXO.1)
    assertThat(medicationRequest.hasMedicationCodeableConcept()).isTrue();
    CodeableConcept medCC = medicationRequest.getMedicationCodeableConcept();
    assertThat(medCC.getText()).isEqualTo("Test15 SODIUM 100 MG CAPSULE");
    assertThat(medCC.getCoding().get(0).getSystem()).isEqualTo("http://hl7.org/fhir/sid/ndc");
    assertThat(medCC.getCoding().get(0).getCode()).isEqualTo("RX800006");
    assertThat(medCC.getCoding().get(0).getDisplay()).isEqualTo("Test15 SODIUM 100 MG CAPSULE");
}
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) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with Medication

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

the class Hl7MedicationRequestFHIRConversionTest method test_medicationCodeableConcept_and_intent_in_PPR.

// Tests medication request fields MedicationCodeableConcept and Intent.
// Tests with supported message types PPR-PC1, PPR-PC2, PPR-PC3
// With just the RXO segment -- these message types don't support RXE.
@ParameterizedTest
@ValueSource(strings = { "MSH|^~\\&||||||S1|PPR^PC1||T|2.6|||||||||\r" // --UNCOMMENT BELOW WHEN CONVERTER SUPPORTS THIS MESSAGE TYPE--
// "MSH|^~\\&||||||S1|PPR^PC2||T|2.6|||||||||\r",
// "MSH|^~\\&||||||S1|PPR^PC3||T|2.6|||||||||\r",
})
void test_medicationCodeableConcept_and_intent_in_PPR(String msh) {
    String hl7message = msh + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "PRB|AD|20140610234741|^oxygenase|Problem_000054321_20190606193536||20140610234741\n" + "ORC|NW|F800006^OE|P800006^RX|||E|10^BID^D4^^^R||\n" + "OBR|1|||555|||20170825010500||||||||||||||||||F\r" + "RXO|RX800006^Test15 SODIUM 100 MG CAPSULE^NDC||100||mg|||||G||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);
    // Verify authored on is not present
    assertThat(medicationRequest.getAuthoredOn()).isNull();
    // Verify intent is set correctly
    String intent = medicationRequest.getIntent().toString();
    assertThat(intent).isEqualTo("ORDER");
    // Very medicationCodeableConcept is set correctly
    assertThat(medicationRequest.hasMedicationCodeableConcept()).isTrue();
    CodeableConcept medCC = medicationRequest.getMedicationCodeableConcept();
    assertThat(medCC.getText()).isEqualTo("Test15 SODIUM 100 MG CAPSULE");
    assertThat(medCC.getCoding().get(0).getSystem()).isEqualTo("http://hl7.org/fhir/sid/ndc");
    assertThat(medCC.getCoding().get(0).getCode()).isEqualTo("RX800006");
    assertThat(medCC.getCoding().get(0).getDisplay()).isEqualTo("Test15 SODIUM 100 MG CAPSULE");
}
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) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with Medication

use of org.hl7.fhir.r4.model.Medication in project cqf-ruler by DBCG.

the class ActivityDefinitionApplyProvider method resolveMedicationRequest.

private MedicationRequest resolveMedicationRequest(ActivityDefinition activityDefinition, String patientId) throws ActivityDefinitionApplyException {
    // intent, medication, and subject are required
    MedicationRequest medicationRequest = new MedicationRequest();
    medicationRequest.setIntent(MedicationRequest.MedicationRequestIntent.ORDER);
    medicationRequest.setSubject(new Reference(patientId));
    if (activityDefinition.hasProduct()) {
        medicationRequest.setMedication(activityDefinition.getProduct());
    } else {
        throw new ActivityDefinitionApplyException("Missing required product property");
    }
    if (activityDefinition.hasDosage()) {
        medicationRequest.setDosageInstruction(activityDefinition.getDosage());
    }
    if (activityDefinition.hasBodySite()) {
        throw new ActivityDefinitionApplyException("BodySite does not map to " + activityDefinition.getKind());
    }
    if (activityDefinition.hasCode()) {
        throw new ActivityDefinitionApplyException("Code does not map to " + activityDefinition.getKind());
    }
    if (activityDefinition.hasQuantity()) {
        throw new ActivityDefinitionApplyException("Quantity does not map to " + activityDefinition.getKind());
    }
    return medicationRequest;
}
Also used : MedicationRequest(org.hl7.fhir.dstu3.model.MedicationRequest) Reference(org.hl7.fhir.dstu3.model.Reference)

Aggregations

Test (org.junit.Test)112 Medication (org.hl7.fhir.r4.model.Medication)62 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)43 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)34 Medication (org.hl7.fhir.dstu3.model.Medication)33 BaseFhirIntegrationTest (org.openmrs.module.fhir2.BaseFhirIntegrationTest)30 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)24 TokenParam (ca.uhn.fhir.rest.param.TokenParam)24 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)20 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)20 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)19 MedicationRequest (org.hl7.fhir.r4.model.MedicationRequest)18 InputStream (java.io.InputStream)17 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)16 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)14 Coding (org.hl7.fhir.r4.model.Coding)14 Date (java.util.Date)13 ArrayList (java.util.ArrayList)12 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)12 Complex (org.hl7.fhir.dstu2016may.formats.RdfGenerator.Complex)11