use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method toFhirResource_shouldConvertConceptToCodeableConcept.
@Test
public void toFhirResource_shouldConvertConceptToCodeableConcept() {
Obs observation = new Obs();
Concept concept = new Concept();
concept.setUuid(CONCEPT_UUID);
observation.setConcept(concept);
CodeableConcept codeableConcept = new CodeableConcept();
codeableConcept.setId(CONCEPT_UUID);
when(conceptTranslator.toFhirResource(concept)).thenReturn(codeableConcept);
Observation result = observationTranslator.toFhirResource(observation);
assertThat(result.getCode(), notNullValue());
assertThat(result.getCode().getId(), equalTo(CONCEPT_UUID));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method toFhirResource_shouldAddReferenceRange.
@Test
public void toFhirResource_shouldAddReferenceRange() {
ConceptNumeric conceptNumeric = new ConceptNumeric();
conceptNumeric.setLowNormal(LOW_NORMAL_VALUE);
conceptNumeric.setHiNormal(HIGH_NORMAL_VALUE);
Obs observation = new Obs();
observation.setConcept(conceptNumeric);
observation.setValueNumeric((HIGH_NORMAL_VALUE + LOW_NORMAL_VALUE) / 2);
Observation.ObservationReferenceRangeComponent referenceRangeComponent = new Observation.ObservationReferenceRangeComponent();
referenceRangeComponent.setLow(new Quantity().setValue(LOW_NORMAL_VALUE));
referenceRangeComponent.setHigh(new Quantity().setValue(HIGH_NORMAL_VALUE));
List<Observation.ObservationReferenceRangeComponent> referenceRangeComponentList = new ArrayList<>();
referenceRangeComponentList.add(referenceRangeComponent);
when(referenceRangeTranslator.toFhirResource(conceptNumeric)).thenReturn(referenceRangeComponentList);
Observation result = observationTranslator.toFhirResource(observation);
assertThat(result.getReferenceRange(), notNullValue());
assertThat(result.getReferenceRange(), hasItem(hasProperty("low", hasProperty("value", equalTo(BigDecimal.valueOf(LOW_NORMAL_VALUE))))));
assertThat(result.getReferenceRange(), hasItem(hasProperty("high", hasProperty("value", equalTo(BigDecimal.valueOf(HIGH_NORMAL_VALUE))))));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method toOpenmrsType_shouldReturnNullObsOrderWhenFhirBasedOnIsNull.
@Test
public void toOpenmrsType_shouldReturnNullObsOrderWhenFhirBasedOnIsNull() {
Observation observation = new Observation();
Obs obs = new Obs();
Obs result = observationTranslator.toOpenmrsType(obs, observation);
assertThat(result.getOrder(), nullValue());
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method toOpenmrsType_shouldTranslateBasedOnToObsOrder.
@Test
public void toOpenmrsType_shouldTranslateBasedOnToObsOrder() {
Observation observation = new Observation();
Reference orderReference = new Reference();
orderReference.setType("Order");
orderReference.setId(ORDER_UUID);
observation.setBasedOn(Collections.singletonList(orderReference));
Obs obs = new Obs();
Order order = new Order();
order.setUuid(ORDER_UUID);
when(basedOnReferenceTranslator.toOpenmrsType(orderReference)).thenReturn(order);
Obs result = observationTranslator.toOpenmrsType(obs, observation);
assertThat(result, notNullValue());
assertThat(result.getOrder(), notNullValue());
assertThat(result.getOrder(), equalTo(order));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method toFhirResource_shouldConvertUuidToId.
@Test
public void toFhirResource_shouldConvertUuidToId() {
Obs observation = new Obs();
observation.setUuid(OBS_UUID);
Observation result = observationTranslator.toFhirResource(observation);
assertThat(result.getId(), equalTo(OBS_UUID));
}
Aggregations