use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class EncounterTranslatorImplTest method toFhirResource_shouldTranslateLocationToEncounterDefaultClass.
@Test
public void toFhirResource_shouldTranslateLocationToEncounterDefaultClass() {
omrsEncounter.setLocation(location);
Encounter result = encounterTranslator.toFhirResource(omrsEncounter);
assertThat(result, notNullValue());
assertThat(result.getClass_(), notNullValue());
assertThat(result.getClass_().getSystem(), is(FhirConstants.ENCOUNTER_CLASS_VALUE_SET_URI));
assertThat(result.getClass_().getCode(), is("AMB"));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class EncounterTranslatorImplTest method toFhirResource_shouldTranslateLocationToEncounterLocationWithCorrectReference.
@Test
public void toFhirResource_shouldTranslateLocationToEncounterLocationWithCorrectReference() {
omrsEncounter.setLocation(location);
Encounter.EncounterLocationComponent locationComponent = new Encounter.EncounterLocationComponent();
Reference locationRef = new Reference();
locationRef.setReference(LOCATION_URI);
locationRef.setDisplay(TEST_LOCATION_NAME);
locationComponent.setLocation(locationRef);
when(encounterLocationTranslator.toFhirResource(location)).thenReturn(locationComponent);
Encounter result = encounterTranslator.toFhirResource(omrsEncounter);
assertThat(result, notNullValue());
assertThat(result.getLocation(), notNullValue());
assertThat(result.getLocation().size(), is(1));
assertThat(result.getLocation().get(0).getLocation().getDisplay(), equalTo(TEST_LOCATION_NAME));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class EncounterTranslatorImplTest method toOpenMrsType_shouldTranslateToLocationWithCorrectUuid.
@Test
public void toOpenMrsType_shouldTranslateToLocationWithCorrectUuid() {
List<Encounter.EncounterLocationComponent> locationComponents = new ArrayList<>();
Encounter.EncounterLocationComponent locationComponent = new Encounter.EncounterLocationComponent();
Reference locationRef = new Reference();
locationRef.setReference(LOCATION_URI);
locationRef.setDisplay(TEST_LOCATION_NAME);
locationComponent.setLocation(locationRef);
locationComponents.add(locationComponent);
fhirEncounter.setLocation(locationComponents);
when(patientReferenceTranslator.toOpenmrsType(patientRef)).thenReturn(patient);
when(encounterLocationTranslator.toOpenmrsType(locationComponent)).thenReturn(location);
org.openmrs.Encounter result = encounterTranslator.toOpenmrsType(fhirEncounter);
assertThat(result, notNullValue());
assertThat(result.getLocation(), notNullValue());
assertThat(result.getLocation().getUuid(), equalTo(LOCATION_UUID));
assertThat(result.getLocation().getName(), equalTo(TEST_LOCATION_NAME));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class BaseEncounterTranslatorTest method shouldMapLocationToClass.
@Test
public void shouldMapLocationToClass() {
Location location = new Location();
location.setUuid(LOCATION_UUID);
when(encounterClassMap.getFhirClass(LOCATION_UUID)).thenReturn("AMB");
Coding result = baseEncounterTranslator.mapLocationToClass(location);
assertThat(result, notNullValue());
assertThat(result, notNullValue());
assertThat(result.getSystem(), is(FhirConstants.ENCOUNTER_CLASS_VALUE_SET_URI));
assertThat(result.getCode(), is("AMB"));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class BaseReferenceHandlingTranslatorTest method shouldReturnNullDisplayWhenLocationNameIsNull.
@Test
public void shouldReturnNullDisplayWhenLocationNameIsNull() {
location.setName(null);
Reference reference = referenceHandlingTranslator.createLocationReference(location);
assertThat(reference, notNullValue());
assertThat(reference.getDisplay(), nullValue());
}
Aggregations