use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method toFhirResource_shouldConvertStatus.
@Test
public void toFhirResource_shouldConvertStatus() {
Obs observation = new Obs();
when(observationStatusTranslator.toFhirResource(observation)).thenReturn(Observation.ObservationStatus.UNKNOWN);
Observation result = observationTranslator.toFhirResource(observation);
assertThat(result.getStatus(), is(Observation.ObservationStatus.UNKNOWN));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method toOpenmrsType_shouldTranslateCodeToConcept.
@Test
public void toOpenmrsType_shouldTranslateCodeToConcept() {
Observation observation = new Observation();
CodeableConcept codeableConcept = new CodeableConcept();
codeableConcept.setId(CONCEPT_UUID);
observation.setCode(codeableConcept);
Concept concept = new Concept();
concept.setUuid(CONCEPT_UUID);
when(conceptTranslator.toOpenmrsType(codeableConcept)).thenReturn(concept);
Obs result = observationTranslator.toOpenmrsType(new Obs(), observation);
assertThat(result, notNullValue());
assertThat(result.getConcept(), notNullValue());
assertThat(result.getConcept().getUuid(), equalTo(CONCEPT_UUID));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method toFhirResource_shouldTranslateOpenMrsDateCreatedToDateIssued.
@Test
public void toFhirResource_shouldTranslateOpenMrsDateCreatedToDateIssued() {
Obs observation = new Obs();
observation.setDateCreated(new Date());
Observation result = observationTranslator.toFhirResource(observation);
assertThat(result, notNullValue());
assertThat(result.getIssued(), DateMatchers.sameDay(new Date()));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method toFhirResource_shouldConvertPatientToReference.
@Test
public void toFhirResource_shouldConvertPatientToReference() {
Obs observation = new Obs();
Patient patient = new Patient();
patient.setUuid(PATIENT_UUID);
observation.setPerson(patient);
Reference patientReference = new Reference();
patientReference.setType("Patient");
patientReference.setId(PATIENT_UUID);
when(patientReferenceTranslator.toFhirResource(patient)).thenReturn(patientReference);
Observation result = observationTranslator.toFhirResource(observation);
assertThat(result.getSubject(), notNullValue());
assertThat(result.getSubject().getType(), equalTo("Patient"));
assertThat(result.getSubject().getId(), equalTo(PATIENT_UUID));
}
use of org.hl7.fhir.r5.model.Observation in project openmrs-module-fhir2 by openmrs.
the class ObservationTranslatorImplTest method toOpenmrsType_shouldThrowExceptionIfObsNull.
@Test(expected = NullPointerException.class)
public void toOpenmrsType_shouldThrowExceptionIfObsNull() {
Observation observation = new Observation();
observationTranslator.toOpenmrsType(null, observation);
}
Aggregations