use of org.hl7.fhir.r5.model.Address 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.r5.model.Address 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.r5.model.Address in project openmrs-module-fhir2 by openmrs.
the class PatientSearchQueryTest method shouldReturnCollectionOfPatientsSortedByCity.
@Test
public void shouldReturnCollectionOfPatientsSortedByCity() {
SortSpec sort = new SortSpec();
sort.setParamName("address-city");
sort.setOrder(SortOrderEnum.ASC);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, new StringAndListParam().addAnd(new StringParam("City"))).setSortSpec(sort);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThan(1));
List<Patient> resultList = get(results);
assertThat(resultList, hasSize(greaterThan(1)));
for (int i = 1; i < resultList.size(); i++) {
assertThat(resultList.get(i - 1).getAddressFirstRep().getCity(), lessThanOrEqualTo(resultList.get(i).getAddressFirstRep().getCity()));
}
sort.setOrder(SortOrderEnum.DESC);
theParams.setSortSpec(sort);
results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThan(1));
resultList = get(results);
assertThat(resultList, hasSize(greaterThan(1)));
for (int i = 1; i < resultList.size(); i++) {
assertThat(resultList.get(i - 1).getAddressFirstRep().getCity(), greaterThanOrEqualTo(resultList.get(i).getAddressFirstRep().getCity()));
}
}
use of org.hl7.fhir.r5.model.Address in project openmrs-module-fhir2 by openmrs.
the class PatientSearchQueryTest method shouldReturnCollectionOfPatientsSortedByCountry.
@Test
public void shouldReturnCollectionOfPatientsSortedByCountry() {
SortSpec sort = new SortSpec();
sort.setParamName("address-country");
sort.setOrder(SortOrderEnum.ASC);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, new StringAndListParam().addAnd(new StringParam("Fake"))).setSortSpec(sort);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThan(1));
List<Patient> resultList = get(results);
assertThat(resultList, hasSize(greaterThan(1)));
for (int i = 1; i < resultList.size(); i++) {
assertThat(resultList.get(i - 1).getAddressFirstRep().getCountry(), lessThanOrEqualTo(resultList.get(i).getAddressFirstRep().getCountry()));
}
sort.setOrder(SortOrderEnum.DESC);
theParams.setSortSpec(sort);
results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThan(1));
resultList = get(results);
assertThat(resultList, hasSize(greaterThan(1)));
for (int i = 1; i < resultList.size(); i++) {
assertThat(resultList.get(i - 1).getAddressFirstRep().getCountry(), greaterThanOrEqualTo(resultList.get(i).getAddressFirstRep().getCountry()));
}
}
use of org.hl7.fhir.r5.model.Address in project openmrs-module-fhir2 by openmrs.
the class LocationAddressTranslatorImplTest method shouldTranslateLocationPostalCodeToAddressCode.
@Test
public void shouldTranslateLocationPostalCodeToAddressCode() {
omrsLocation.setPostalCode(POSTAL_CODE);
org.hl7.fhir.r4.model.Address address = translator.toFhirResource(omrsLocation);
assertThat(address, notNullValue());
assertThat(address.getPostalCode(), notNullValue());
assertThat(address.getPostalCode(), equalTo(POSTAL_CODE));
}
Aggregations