Search in sources :

Example 56 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ObservationFHIRConversionTest method testObservationSTMultiplePartsResult.

@Test
void testObservationSTMultiplePartsResult() throws IOException {
    String hl7message = baseMessage + "OBX|1|ST|^Type of protein feed^L||HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%~Fifth line, as part of a repeated field||||||F||";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(1);
    Observation obs = (Observation) obsResource.get(0);
    assertThat(obs.getValueStringType()).isNotNull();
    StringType q = obs.getValueStringType();
    assertThat(q.asStringValue()).isEqualTo("HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%. Fifth line, as part of a repeated field.");
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) StringType(org.hl7.fhir.r4.model.StringType) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 57 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7ObservationFHIRConversionTest method testObservationSN_valueQuantity_missing_comparator_result.

@Test
void testObservationSN_valueQuantity_missing_comparator_result() throws IOException {
    String hl7message = baseMessage + "OBX|1|SN|1554-5^GLUCOSE||^182|mg/dl|70_105||||F";
    List<BundleEntryComponent> e = ResourceUtils.createFHIRBundleFromHL7MessageReturnEntryList(ftv, hl7message);
    List<Resource> obsResource = ResourceUtils.getResourceList(e, ResourceType.Observation);
    assertThat(obsResource).hasSize(1);
    Observation obs = (Observation) obsResource.get(0);
    // Check valueQuantity
    assertNotNull(obs.getValueQuantity());
    Quantity q = obs.getValueQuantity();
    // code only set if system exists
    assertNull(q.getCode());
    assertEquals("mg/dl", q.getUnit());
    assertNull(q.getSystem());
    assertEquals(182, q.getValue().floatValue());
    // no comparator passed in
    assertNull(q.getComparator());
    // Check referenceRange
    assertTrue(obs.hasReferenceRange());
    assertThat(obs.getReferenceRange()).hasSize(1);
    ObservationReferenceRangeComponent range = obs.getReferenceRangeFirstRep();
    assertNotNull(range);
    assertTrue(range.hasHigh());
    assertTrue(range.hasLow());
    Quantity high = range.getHigh();
    // uses OBX.6.1 for units not text in string
    assertEquals("mg/dl", high.getUnit());
    assertEquals(105f, high.getValue().floatValue());
    Quantity low = range.getLow();
    // uses OBX.6.1 for units not text in string
    assertEquals("mg/dl", low.getUnit());
    assertEquals(70f, low.getValue().floatValue());
    assertEquals("70_105", range.getText());
}
Also used : BundleEntryComponent(org.hl7.fhir.r4.model.Bundle.BundleEntryComponent) ObservationReferenceRangeComponent(org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) Resource(org.hl7.fhir.r4.model.Resource) Observation(org.hl7.fhir.r4.model.Observation) Quantity(org.hl7.fhir.r4.model.Quantity) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 58 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestRateQuantityRXO.

@Test
void dosageInstructionTestRateQuantityRXO() {
    // Test dosageInstruction.rateQuantity where RXO.21 exists and RXO.17 does not exist -> use RXO segment, no range
    String hl7message = "MSH|^~\\\\&|||||20210101000000||OMP^O09|MSGID|T|2.6\n" + "PID|||1234||DOE^JANE^|||F||||||||||||||||||||||\n" + "PV1||||||||||||||||||||||||||||||||||||||||||||\n" + "ORC|OP||||||||||||||||||||||\n" + // RXO.22.3 purposely empty to check that default system is used
    "RXO|00054418425^Dexamethasone 4 MG Oral Tablet^NDC||||||||||||||||||||6|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);
    Quantity rateQuantity = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getRateQuantity();
    // dosageInstruction.doseAndRate.rateQuantity RXO.21
    // RXO.21
    assertThat(rateQuantity.getValue()).hasToString("6.0");
    // RXO.22.1
    assertThat(rateQuantity.getUnit()).isEqualTo("PC");
    // default
    assertThat(rateQuantity.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) Quantity(org.hl7.fhir.r4.model.Quantity) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 59 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestRateQuantityRXE.

@Test
void dosageInstructionTestRateQuantityRXE() {
    // Test dosageInstruction.rateQuantity where RXE.23 exists and RXE.22 does not exist -> use RXE segment, no range
    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 purposely empty to check that default system is used
    "||7|PC^^http://unitsofmeasure.org||||||||||||||||\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);
    Quantity rateQuantity = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getRateQuantity();
    // dosageInstruction.doseAndRate.rateQuantity RXE.23
    // RXO.23
    assertThat(rateQuantity.getValue()).hasToString("7.0");
    // RXO.24.1
    assertThat(rateQuantity.getUnit()).isEqualTo("PC");
    // RXO.24.3
    assertThat(rateQuantity.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) Quantity(org.hl7.fhir.r4.model.Quantity) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 60 with BundleEntryComponent

use of org.hl7.fhir.dstu2.model.Bundle.BundleEntryComponent in project hl7v2-fhir-converter by LinuxForHealth.

the class Hl7MedicationRequestFHIRConversionTest method dosageInstructionTestDoseQuantityRXE.

@Test
void dosageInstructionTestDoseQuantityRXE() {
    // Test dosageInstruction.DoseQuantity RXE.3 using RXE segment, no range
    String hl7message = "MSH|^~\\&||||||S1|RDE^O11||T|2.6|||||||||\n" + "PID|||1234^^^^MR||DOE^JANE^|||F||||||||||||||||||||||\n" + "ORC|NW|||||E|||||||||||||||||||||||I\n" + // RXE.6 through RXE.44 not used.
    "RXE||DUONEB3INH^3 ML PLAS CONT : IPRATROPIUM-ALBUTEROL 0.5-2.5 (3) MG/3ML IN SOLN^ADS|3||mL|||||||||||||||||||||||||||||\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);
    Quantity doseQuantity = medicationRequest.getDosageInstructionFirstRep().getDoseAndRateFirstRep().getDoseQuantity();
    // dosageInstruction.doseAndRate.doseQuantity RXE.3
    // RXE.3
    assertThat(doseQuantity.getValue()).hasToString("3.0");
    // RXE.5.1
    assertThat(doseQuantity.getUnit()).isEqualTo("mL");
    // default
    assertThat(doseQuantity.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) Quantity(org.hl7.fhir.r4.model.Quantity) 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