Search in sources :

Example 31 with Location

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"));
}
Also used : Encounter(org.hl7.fhir.r4.model.Encounter) Test(org.junit.Test)

Example 32 with Location

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));
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Encounter(org.hl7.fhir.r4.model.Encounter) Test(org.junit.Test)

Example 33 with Location

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));
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) ArrayList(java.util.ArrayList) Encounter(org.hl7.fhir.r4.model.Encounter) Test(org.junit.Test)

Example 34 with Location

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"));
}
Also used : Coding(org.hl7.fhir.r4.model.Coding) Location(org.openmrs.Location) Test(org.junit.Test)

Example 35 with Location

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());
}
Also used : Reference(org.hl7.fhir.r4.model.Reference) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)215 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)94 Location (org.hl7.fhir.r4.model.Location)93 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)71 Location (org.hl7.fhir.dstu3.model.Location)66 InputStream (java.io.InputStream)46 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)39 Matchers.containsString (org.hamcrest.Matchers.containsString)38 Test (org.junit.jupiter.api.Test)38 BaseModuleContextSensitiveTest (org.openmrs.test.BaseModuleContextSensitiveTest)37 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)35 ArrayList (java.util.ArrayList)29 Complex (org.hl7.fhir.r4.utils.formats.Turtle.Complex)29 BaseFhirProvenanceResourceTest (org.openmrs.module.fhir2.providers.BaseFhirProvenanceResourceTest)26 Reference (org.hl7.fhir.r4.model.Reference)25 Date (java.util.Date)24 Bundle (org.hl7.fhir.r4.model.Bundle)24 BundleEntryComponent (org.hl7.fhir.r4.model.Bundle.BundleEntryComponent)24 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)23 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)23