Search in sources :

Example 31 with ENCOUNTER

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER 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 32 with ENCOUNTER

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER 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 33 with ENCOUNTER

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestMaxDosePerPeriodRXO.

@Test
void dosageInstructionTestMaxDosePerPeriodRXO() {
    // Test dosageInstruction.maxDosePerPeriod from RXO.23
    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|||||" + // RXO.8 through RXO.22 optional
    "||||||||||||||||" + // RXO.23 to dosageInstruction.maxDosePerPeriod.numerator
    "|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 maxDose = medicationRequest.getDosageInstructionFirstRep().getMaxDosePerPeriod();
    // dosageInstruction.maxDosePerPeriod.numerator(RXO.23)
    assertThat(maxDose.getNumerator().getValue()).hasToString("7.0");
    assertThat(maxDose.getNumerator().getUnit()).isEqualTo("PC");
    assertThat(maxDose.getNumerator().getSystem()).isEqualTo("http://unitsofmeasure.org");
    // dosageInstruction.maxDosePerPeriod.denominator
    assertThat(maxDose.getDenominator().getValue()).hasToString("1.0");
    assertThat(maxDose.getDenominator().getUnit()).isEqualTo("day");
    assertThat(maxDose.getDenominator().getSystem()).isEqualTo("http://unitsofmeasure.org");
    // 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) Ratio(org.hl7.fhir.r4.model.Ratio) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 34 with ENCOUNTER

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ImmunizationFHIRConversionTest method testImmunizationAdministrationPlaceOrg1.

@Test
// Test priority of Immunization Performer sourcing is tested.
void testImmunizationAdministrationPlaceOrg1() throws IOException {
    String hl7VUXmessageRep = "MSH|^~\\&|||||20140701041038||VXU^V04^VXU_V04|MSG.Valid_01|P|2.6|||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\r" + // PV1.3.4 to Organization referenced by Encounter.serviceProvider; but bypassed for Immunization.performer because RXA.27.4 has priority
    "PV1||O|^^^PlacePV1.3.4\r" + "ORC|||197027|||||||^Clerk^Myron|||||||RI2050\r" + // RXA.12 - RXA.26 not used
    "RXA|0|1|20130531||48^HIB PRP-T^CVX||||||^^^PlaceRXA11|||||||||||||||" + // RXA.27 to Immunization Performer
    "|^^^PlaceRXA274\r" + "OBX|1|CE|59784-9^Disease with presumed immunity^LN||\r";
    List<Bundle.BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7VUXmessageRep);
    // We expect two different organizations, one for Encounter.serviceProvider, one for Immunization.performer
    List<Resource> organizations = ResourceUtils.getResourceList(e, ResourceType.Organization);
    assertThat(organizations).hasSize(2);
    Organization org1 = (Organization) organizations.get(0);
    Organization org2 = (Organization) organizations.get(1);
    // RXA.27.4
    String orgId1 = org1.getId();
    // RXA.27.4
    assertThat(orgId1).isEqualTo("Organization/placerxa274");
    // PV1.3.4
    String orgId2 = org2.getId();
    // PV1.3.4
    assertThat(orgId2).isEqualTo("Organization/placepv1.3.4");
    List<Resource> immunizations = ResourceUtils.getResourceList(e, ResourceType.Immunization);
    assertThat(immunizations).hasSize(1);
    Immunization imm = (Immunization) immunizations.get(0);
    // RXA.27.4
    assertThat(imm.getPerformer()).hasSize(1);
    // RXA.27
    assertThat(imm.getPerformerFirstRep().getActor().getReference()).isEqualTo(orgId1);
    List<Resource> encounters = ResourceUtils.getResourceList(e, ResourceType.Encounter);
    assertThat(encounters).hasSize(1);
    Encounter enc = (Encounter) encounters.get(0);
    // PV1.3.4
    assertThat(enc.getServiceProvider().getReference()).isEqualTo(orgId2);
    // Check for expected resources: Organizations (2), Immunization, Encounter, Patient
    assertThat(e).hasSize(5);
}
Also used : Immunization(org.hl7.fhir.r4.model.Immunization) BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) Organization(org.hl7.fhir.r4.model.Organization) Resource(org.hl7.fhir.r4.model.Resource) Encounter(org.hl7.fhir.r4.model.Encounter) Test(org.junit.jupiter.api.Test)

Example 35 with ENCOUNTER

use of org.hl7.fhir.r4.model.codesystems.ResourceTypes.ENCOUNTER in project cqf-ruler by DBCG.

the class ProcessMessageProviderIT method testProcessMessage.

@Test
public void testProcessMessage() throws IOException {
    String packagePrefix = "org/opencds/cqf/ruler/casereporting/r4/";
    Bundle bundle = (Bundle) loadResource(packagePrefix + "example-eicr.json");
    Bundle returnBundle = getClient().operation().onServer().named("$process-message-bundle").withParameter(Parameters.class, "content", bundle).returnResourceType(Bundle.class).execute();
    assertNotNull(returnBundle);
    assertNotNull(getClient().read().resource(Patient.class).withId("patient-12742542").execute());
    assertNotNull(getClient().read().resource(Encounter.class).withId("encounter-97953898").execute());
    assertNotNull(getClient().read().resource(MeasureReport.class).withId("diabetes-mp").execute());
}
Also used : Bundle(org.hl7.fhir.r4.model.Bundle) Patient(org.hl7.fhir.r4.model.Patient) Encounter(org.hl7.fhir.r4.model.Encounter) MeasureReport(org.hl7.fhir.r4.model.MeasureReport) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) RestIntegrationTest(org.opencds.cqf.ruler.test.RestIntegrationTest)

Aggregations

Test (org.junit.Test)238 Encounter (org.hl7.fhir.r4.model.Encounter)166 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)100 Test (org.junit.jupiter.api.Test)93 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)87 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)79 Reference (org.hl7.fhir.r4.model.Reference)71 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)66 ArrayList (java.util.ArrayList)64 Resource (org.hl7.fhir.r4.model.Resource)61 Bundle (org.hl7.fhir.r4.model.Bundle)60 Date (java.util.Date)57 Encounter (org.hl7.fhir.dstu3.model.Encounter)55 Coding (org.hl7.fhir.r4.model.Coding)51 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)49 Reference (org.hl7.fhir.dstu3.model.Reference)48 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)43 CodeableConcept (org.hl7.fhir.r4.model.CodeableConcept)41 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)38 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)37