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);
}
Aggregations