use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonSearchQueryTest method shouldReturnEmptyCollectionForNoMatchOnGender.
@Test
public void shouldReturnEmptyCollectionForNoMatchOnGender() {
TokenAndListParam gender = new TokenAndListParam().addAnd(new TokenOrListParam().add(WRONG_GENDER));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.GENDER_SEARCH_HANDLER, gender);
IBundleProvider people = search(theParams);
List<Person> resultList = get(people);
assertThat(people, notNullValue());
assertThat(resultList, is(empty()));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonSearchQueryTest method shouldReturnCollectionOfPeopleForMatchOnState.
@Test
public void shouldReturnCollectionOfPeopleForMatchOnState() {
StringAndListParam state = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(STATE)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, state);
IBundleProvider people = search(theParams);
assertThat(people, notNullValue());
assertThat(people.size(), greaterThanOrEqualTo(1));
List<Person> resultList = get(people);
assertThat(resultList, not(empty()));
assertThat(resultList.get(0).getAddressFirstRep().getState(), equalTo(STATE));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonSearchQueryTest method shouldReturnCollectionOfPeopleForMatchOnCountry.
@Test
public void shouldReturnCollectionOfPeopleForMatchOnCountry() {
StringAndListParam country = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(COUNTRY)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, country);
IBundleProvider people = search(theParams);
assertThat(people, notNullValue());
assertThat(people.size(), greaterThanOrEqualTo(1));
List<Person> resultList = get(people);
assertThat(resultList, not(empty()));
assertThat(resultList.get(0).getAddressFirstRep().getCountry(), equalTo(COUNTRY));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonSearchQueryTest method shouldReturnCollectionOfPeopleSortedByCountry.
@Test
public void shouldReturnCollectionOfPeopleSortedByCountry() throws Exception {
executeDataSet(ADDRESS_SEARCH_FILE);
SortSpec sort = new SortSpec();
sort.setParamName(SP_ADDRESS_COUNTRY);
sort.setOrder(SortOrderEnum.ASC);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, new StringAndListParam().addAnd(new StringParam("F"))).setSortSpec(sort);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThan(1));
List<Person> people = get(results);
assertThat(people, hasSize(greaterThan(1)));
for (int i = 1; i < people.size(); i++) {
assertThat(people.get(i - 1).getAddressFirstRep().getCountry(), lessThanOrEqualTo(people.get(i).getAddressFirstRep().getCountry()));
}
sort.setOrder(SortOrderEnum.DESC);
theParams.setSortSpec(sort);
results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThan(1));
people = get(results);
assertThat(people, hasSize(greaterThan(1)));
for (int i = 1; i < people.size(); i++) {
assertThat(people.get(i - 1).getAddressFirstRep().getCountry(), greaterThanOrEqualTo(people.get(i).getAddressFirstRep().getCountry()));
}
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonSearchQueryTest method shouldReturnCollectionOfPeopleSortedByBirthDate.
@Test
public void shouldReturnCollectionOfPeopleSortedByBirthDate() {
SortSpec sort = new SortSpec();
sort.setParamName(SP_BIRTHDATE);
sort.setOrder(SortOrderEnum.ASC);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, "birthdate", new DateRangeParam().setLowerBound("1900-01-01").setUpperBoundInclusive(new Date())).setSortSpec(sort);
IBundleProvider results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThan(1));
List<Person> people = get(results);
assertThat(people, hasSize(greaterThan(1)));
for (int i = 1; i < people.size(); i++) {
assertThat(people.get(i - 1).getBirthDate(), sameOrBefore(people.get(i).getBirthDate()));
}
sort.setOrder(SortOrderEnum.DESC);
theParams.setSortSpec(sort);
results = search(theParams);
assertThat(results, notNullValue());
assertThat(results.size(), greaterThan(1));
people = get(results);
assertThat(people, hasSize(greaterThan(1)));
for (int i = 1; i < people.size(); i++) {
assertThat(people.get(i - 1).getBirthDate(), sameOrAfter(people.get(i).getBirthDate()));
}
}
Aggregations