Search in sources :

Example 6 with ObservationReferenceRangeComponent

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

the class Hl7ObservationFHIRConversionTest method testObservationSN_valueQuantity_equals_comparator_result.

/**
 * Testing Observation.yml valueQuantity_2 with a comparator that FHIR does not support
 *
 * Also tests referenceRange and interpretation fields
 *
 * @throws IOException
 */
@Test
void testObservationSN_valueQuantity_equals_comparator_result() throws IOException {
    String hl7message = baseMessage + "OBX|1|SN|24467-3^CD3+CD4+ (T4 helper) cells [#/volume] in Blood^LN||=^440|{Cells}/uL^cells per microliter^UCUM|649-1346 cells/mcL|L|||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 for unit
    assertEquals("{Cells}/uL", q.getCode());
    // unit units to OBX.6.1
    assertEquals("{Cells}/uL", q.getUnit());
    // system for unit
    assertEquals("http://unitsofmeasure.org", q.getSystem());
    assertEquals(440f, q.getValue().floatValue());
    // = is not put in comparator
    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("{Cells}/uL", high.getUnit());
    assertEquals(1346f, high.getValue().floatValue());
    Quantity low = range.getLow();
    // uses OBX.6.1 for units not text in string
    assertEquals("{Cells}/uL", low.getUnit());
    assertEquals(649f, low.getValue().floatValue());
    assertEquals("649-1346 cells/mcL", range.getText());
    // Check interpretation (OBX.8)
    assertTrue(obs.hasInterpretation());
    assertThat(obs.getInterpretation()).hasSize(1);
    DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getInterpretation().get(0), "L", "Low", "http://terminology.hl7.org/CodeSystem/v2-0078", null);
}
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)

Aggregations

Observation (org.hl7.fhir.r4.model.Observation)6 ObservationReferenceRangeComponent (org.hl7.fhir.r4.model.Observation.ObservationReferenceRangeComponent)6 Quantity (org.hl7.fhir.r4.model.Quantity)6 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)5 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)5 Resource (org.hl7.fhir.r4.model.Resource)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)5 Test (org.junit.jupiter.api.Test)4 Bundle (org.hl7.fhir.r4.model.Bundle)2 IObservation (ch.elexis.core.findings.IObservation)1 TransientCoding (ch.elexis.core.findings.util.model.TransientCoding)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Coding (org.hl7.fhir.r4.model.Coding)1 Device (org.hl7.fhir.r4.model.Device)1 Organization (org.hl7.fhir.r4.model.Organization)1 Practitioner (org.hl7.fhir.r4.model.Practitioner)1 StringType (org.hl7.fhir.r4.model.StringType)1 Test (org.junit.Test)1 ValueSource (org.junit.jupiter.params.provider.ValueSource)1