use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationSearchQueryTest method searchForLocations_shouldReturnCorrectLocationByParentPostalCode.
@Test
public void searchForLocations_shouldReturnCorrectLocationByParentPostalCode() {
ReferenceAndListParam parentLocation = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(LOCATION_PARENT_POSTAL_CODE).setChain("address-postalcode")));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.LOCATION_REFERENCE_SEARCH_HANDLER, parentLocation);
IBundleProvider locations = search(theParams);
List<Location> resultList = get(locations);
assertThat(locations, notNullValue());
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(LOCATION_UUID));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationSearchQueryTest method searchForLocations_shouldSortLocationsByPostalCodeAsRequested.
@Test
public void searchForLocations_shouldSortLocationsByPostalCodeAsRequested() {
SortSpec sort = new SortSpec();
sort.setParamName("address-postalCode");
sort.setOrder(SortOrderEnum.ASC);
List<Location> resultsList = getLocationListWithoutNulls(sort);
// check if the sorting is indeed correct by ascending order
for (int i = 1; i < resultsList.size(); i++) {
assertThat(resultsList.get(i - 1).getAddress().getPostalCode(), lessThanOrEqualTo(resultsList.get(i).getAddress().getPostalCode()));
}
sort.setOrder(SortOrderEnum.DESC);
resultsList = new ArrayList<>(getLocationListWithoutNulls(sort));
// check if the sorting is indeed correct by descending order
for (int i = 1; i < resultsList.size(); i++) {
assertThat(resultsList.get(i - 1).getAddress().getPostalCode(), greaterThanOrEqualTo(resultsList.get(i).getAddress().getPostalCode()));
}
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationSearchQueryTest method searchForLocations_shouldReturnCorrectLocationByParentCountry.
@Test
public void searchForLocations_shouldReturnCorrectLocationByParentCountry() {
ReferenceAndListParam parentLocation = new ReferenceAndListParam().addAnd(new ReferenceOrListParam().add(new ReferenceParam().setValue(LOCATION_PARENT_COUNTRY).setChain("address-country")));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.LOCATION_REFERENCE_SEARCH_HANDLER, parentLocation);
IBundleProvider locations = search(theParams);
List<Location> resultList = get(locations);
assertThat(locations, notNullValue());
assertThat(resultList, hasSize(equalTo(1)));
assertThat(resultList.get(0).getIdElement().getIdPart(), equalTo(LOCATION_UUID));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class LocationSearchQueryTest method searchForLocations_shouldReturnCorrectLocationByCountry.
@Test
public void searchForLocations_shouldReturnCorrectLocationByCountry() {
StringAndListParam country = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(LOCATION_COUNTRY)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COUNTRY_SEARCH_HANDLER, country);
IBundleProvider locations = search(theParams);
assertThat(locations, notNullValue());
assertThat(locations.size(), equalTo(2));
List<Location> resultList = get(locations);
assertThat(resultList, hasSize(equalTo(2)));
assertThat(resultList.get(0).getAddress().getCountry(), equalTo(LOCATION_COUNTRY));
}
use of org.hl7.fhir.r4.model.Location in project openmrs-module-fhir2 by openmrs.
the class VisitSearchQueryTest method searchForVisits_shouldSearchForVisitsByLocationUUID.
@Test
public void searchForVisits_shouldSearchForVisitsByLocationUUID() {
ReferenceAndListParam locationReference = new ReferenceAndListParam();
ReferenceParam location = new ReferenceParam();
location.setValue(LOCATION_UUID);
locationReference.addValue(new ReferenceOrListParam().add(location));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.LOCATION_REFERENCE_SEARCH_HANDLER, locationReference);
IBundleProvider results = search(theParams);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
assertThat(((Encounter) resultList.iterator().next()).getLocationFirstRep().getLocation().getReferenceElement().getIdPart(), equalTo(LOCATION_UUID));
}
Aggregations