use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonSearchQueryTest method shouldReturnCollectionOfPeopleForMatchOnCity.
@Test
public void shouldReturnCollectionOfPeopleForMatchOnCity() {
StringAndListParam city = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(CITY)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, city);
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().getCity(), equalTo(CITY));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonSearchQueryTest method shouldReturnEmptyCollectionForNoMatchOnPersonName.
@Test
public void shouldReturnEmptyCollectionForNoMatchOnPersonName() {
StringAndListParam personName = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_FOUND_NAME)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, FhirConstants.NAME_PROPERTY, personName);
IBundleProvider people = search(theParams);
assertThat(people, notNullValue());
assertThat(people.size(), equalTo(0));
List<Person> resultList = get(people);
assertThat(resultList, is(empty()));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonSearchQueryTest method shouldReturnCollectionOfPeopleSortedByState.
@Test
public void shouldReturnCollectionOfPeopleSortedByState() throws Exception {
executeDataSet(ADDRESS_SEARCH_FILE);
SortSpec sort = new SortSpec();
sort.setParamName(SP_ADDRESS_STATE);
sort.setOrder(SortOrderEnum.ASC);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, new StringAndListParam().addAnd(new StringParam("M"))).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().getState(), lessThanOrEqualTo(people.get(i).getAddressFirstRep().getState()));
}
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().getState(), greaterThanOrEqualTo(people.get(i).getAddressFirstRep().getState()));
}
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class PersonSearchQueryTest method shouldReturnCollectionOfPeopleForMatchOnPostalCode.
@Test
public void shouldReturnCollectionOfPeopleForMatchOnPostalCode() {
StringAndListParam postalCode = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(POSTAL_CODE)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.POSTAL_CODE_PROPERTY, postalCode);
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().getPostalCode(), equalTo(POSTAL_CODE));
}
use of org.hl7.fhir.r4.model.Person in project openmrs-module-fhir2 by openmrs.
the class BaseReferenceHandlingTranslatorTest method shouldReturnReferenceWithDisplayForProviderWithPerson.
@Test
public void shouldReturnReferenceWithDisplayForProviderWithPerson() {
PersonName name = new PersonName();
name.setGivenName(GIVEN_NAME);
name.setFamilyName(FAMILY_NAME);
Person person = new Person();
person.setUuid(PERSON_UUID);
person.addName(name);
provider.setPerson(person);
Reference reference = referenceHandlingTranslator.createPractitionerReference(provider);
assertThat(reference, notNullValue());
assertThat(reference.getDisplay(), equalTo(PROVIDER_DISPLAY));
}
Aggregations