use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method initLocation.
@Before
public void initLocation() {
Address address = new Address();
address.setCity(CITY);
address.setCountry(COUNTRY);
address.setState(STATE);
address.setPostalCode(POSTAL_CODE);
location = new org.hl7.fhir.r4.model.Location();
location.setId(LOCATION_UUID);
location.setName(LOCATION_NAME);
location.setAddress(address);
location.getMeta().addTag(new Coding(FhirConstants.OPENMRS_FHIR_EXT_LOCATION_TAG, LOGIN_LOCATION_TAG_NAME, LOGIN_LOCATION_TAG_DESCRIPTION));
setProvenanceResources(location);
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method getLocationByUuid_shouldReturnMatchingLocation.
@Test
public void getLocationByUuid_shouldReturnMatchingLocation() {
when(locationService.get(LOCATION_UUID)).thenReturn(location);
IdType id = new IdType();
id.setValue(LOCATION_UUID);
org.hl7.fhir.dstu3.model.Location result = resourceProvider.getLocationById(id);
assertThat(result, notNullValue());
assertThat(result.getId(), notNullValue());
assertThat(result.getId(), equalTo(LOCATION_UUID));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfLocations.
@Test
public void searchLocations_shouldReturnMatchingBundleOfLocations() {
List<org.hl7.fhir.r4.model.Location> locations = new ArrayList<>();
locations.add(location);
when(locationService.searchForLocations(any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any(), any())).thenReturn(new MockIBundleProvider<>(locations, PREFERRED_PAGE_SIZE, COUNT));
StringAndListParam location = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_NAME)));
IBundleProvider results = resourceProvider.searchLocations(location, null, null, null, null, null, null, null, null, null, null, null);
List<Location> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method searchLocations_shouldReturnMatchingBundleOfLocationsByLastUpdated.
@Test
public void searchLocations_shouldReturnMatchingBundleOfLocationsByLastUpdated() {
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(LAST_UPDATED_DATE).setLowerBound(LAST_UPDATED_DATE);
when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), argThat(is(lastUpdated)), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchLocations(null, null, null, null, null, null, null, null, lastUpdated, null, null, null);
List<Location> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationFhirResourceProviderTest method searchLocations_shouldNotAddRelatedResourcesForEmptyReverseInclude.
@Test
public void searchLocations_shouldNotAddRelatedResourcesForEmptyReverseInclude() {
HashSet<Include> revIncludeSet = new HashSet<>();
when(locationService.searchForLocations(isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull(), isNull())).thenReturn(new MockIBundleProvider<>(Collections.singletonList(location), PREFERRED_PAGE_SIZE, COUNT));
IBundleProvider results = resourceProvider.searchLocations(null, null, null, null, null, null, null, null, null, null, revIncludeSet, null);
List<Location> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList.get(0).fhirType(), is(FhirConstants.LOCATION));
assertThat(resultList.size(), equalTo(1));
assertThat(resultList.get(0).getId(), equalTo(LOCATION_UUID));
}
Aggregations