use of org.hl7.fhir.r4b.model.Observation in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ObservationFHIRConversionTest method testObservationSTResult.
@Test
void testObservationSTResult() throws IOException {
String hl7message = baseMessage + "OBX|1|ST|^Type of protein feed^L||Fourth Line: HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%||||||F||||Alex||";
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("Fourth Line: HYPERDYNAMIC LV SYSTOLIC FUNCTION, VISUAL EF 80%");
}
use of org.hl7.fhir.r4b.model.Observation in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ObservationFHIRConversionTest method testObservationCeResultKnownSystem.
@Test
void testObservationCeResultKnownSystem() throws IOException {
String hl7message = baseMessage + "OBX|1|CE|93000&CMP^LIN^CPT4|11|1305^No significant change was found^LN";
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.getValueCodeableConcept()).isNotNull();
assertThat(obs.getStatus()).isNotNull();
CodeableConcept cc = obs.getValueCodeableConcept();
assertThat(cc.getCoding()).isNotNull();
assertThat(cc.getCoding().get(0)).isNotNull();
assertThat(cc.getCoding().get(0).getSystem()).isEqualTo("http://loinc.org");
assertThat(cc.getCoding().get(0).getCode()).isEqualTo("1305");
assertThat(cc.getText()).isEqualTo("No significant change was found");
}
use of org.hl7.fhir.r4b.model.Observation in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ObservationFHIRConversionTest method testObservationSN_valueRatio_slash_result.
@Test
void testObservationSN_valueRatio_slash_result() throws IOException {
String hl7message = baseMessage + "OBX|1|SN|111^LabWithRatio||^2^/^3|";
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);
assertTrue(obs.hasValueRatio());
Ratio r = obs.getValueRatio();
assertEquals(2f, r.getNumerator().getValue().floatValue());
assertEquals(3f, r.getDenominator().getValue().floatValue());
}
use of org.hl7.fhir.r4b.model.Observation in project hl7v2-fhir-converter by LinuxForHealth.
the class Hl7ObservationFHIRConversionTest method testObservationStNullResult.
@Test
void testObservationStNullResult() throws IOException {
String hl7message = baseMessage + "OBX|1|ST|14151-5^HCO3 BldCo-sCnc^LN|TEST|||||||F|||20210311122016|||||20210311122153||||";
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()).isNull();
// Check the coding (OBX.3)
assertThat(obs.hasCode()).isTrue();
DatatypeUtils.checkCommonCodeableConceptAssertions(obs.getCode(), "14151-5", "HCO3 BldCo-sCnc", "http://loinc.org", "HCO3 BldCo-sCnc");
// Check the effective Date Time (OBX 14)
assertThat(obs.hasEffective()).isTrue();
assertThat(obs.hasEffectiveDateTimeType()).isTrue();
assertThat(obs.getEffectiveDateTimeType().asStringValue()).isEqualTo("2021-03-11T12:20:16+08:00");
}
use of org.hl7.fhir.r4b.model.Observation in project hl7v2-fhir-converter by LinuxForHealth.
the class FHIRConverterTest method verifyResult.
private void verifyResult(String json, BundleType expectedBundleType, boolean messageHeaderExpected) {
FHIRContext context = new FHIRContext();
IBaseResource bundleResource = context.getParser().parseResource(json);
assertThat(bundleResource).isNotNull();
Bundle b = (Bundle) bundleResource;
assertThat(b.getType()).isEqualTo(expectedBundleType);
assertThat(b.getId()).isNotNull();
assertThat(b.getMeta().getLastUpdated()).isNotNull();
List<BundleEntryComponent> e = b.getEntry();
List<Resource> patientResource = e.stream().filter(v -> ResourceType.Patient == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(patientResource).hasSize(1);
List<Resource> encounterResource = e.stream().filter(v -> ResourceType.Encounter == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(encounterResource).hasSize(1);
List<Resource> obsResource = e.stream().filter(v -> ResourceType.Observation == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
// No Observation resource because OBX.2 is type TX
assertThat(obsResource).isEmpty();
List<Resource> pracResource = e.stream().filter(v -> ResourceType.Practitioner == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(pracResource).hasSize(4);
List<Resource> allergyResources = e.stream().filter(v -> ResourceType.AllergyIntolerance == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(allergyResources).hasSize(2);
if (messageHeaderExpected) {
List<Resource> messageHeader = e.stream().filter(v -> ResourceType.MessageHeader == v.getResource().getResourceType()).map(BundleEntryComponent::getResource).collect(Collectors.toList());
assertThat(messageHeader).hasSize(1);
}
}
Aggregations