use of org.openmrs.module.fhir2.api.translators.PersonTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPersonServiceImplTest method searchForPeople_shouldReturnCollectionOfPersonWhenPersonGenderMatched.
@Test
public void searchForPeople_shouldReturnCollectionOfPersonWhenPersonGenderMatched() {
TokenAndListParam tokenAndListParam = new TokenAndListParam().addAnd(new TokenOrListParam().add(GENDER));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.GENDER_SEARCH_HANDLER, tokenAndListParam);
when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(person));
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PERSON_UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(personTranslator.toFhirResource(person)).thenReturn(fhirPerson);
IBundleProvider results = personService.searchForPeople(null, tokenAndListParam, null, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.openmrs.module.fhir2.api.translators.PersonTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPersonServiceImplTest method searchForPeople_shouldReturnCollectionOfPeopleWhenLastUpdatedMatched.
@Test
public void searchForPeople_shouldReturnCollectionOfPeopleWhenLastUpdatedMatched() {
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(LAST_UPDATED_DATE).setLowerBound(LAST_UPDATED_DATE);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(person));
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PERSON_UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(personTranslator.toFhirResource(person)).thenReturn(fhirPerson);
IBundleProvider results = personService.searchForPeople(null, null, null, null, null, null, null, null, lastUpdated, null, null);
assertThat(results, notNullValue());
assertThat(get(results), not(empty()));
assertThat(results.size(), greaterThanOrEqualTo(1));
}
use of org.openmrs.module.fhir2.api.translators.PersonTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPersonServiceImplTest method searchForPeople_shouldReturnEmptyCollectionWhenPersonNameNotMatched.
@Test
public void searchForPeople_shouldReturnEmptyCollectionWhenPersonNameNotMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_FOUND_NAME)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, stringAndListParam);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
IBundleProvider results = personService.searchForPeople(stringAndListParam, null, null, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
use of org.openmrs.module.fhir2.api.translators.PersonTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPersonServiceImplTest method searchForPeople_shouldReturnCollectionOfPersonWhenPersonBirthDateMatched.
@Test
public void searchForPeople_shouldReturnCollectionOfPersonWhenPersonBirthDateMatched() throws ParseException {
Date birthDate = dateFormatter.parse(PERSON_BIRTH_DATE);
person.setBirthdate(birthDate);
DateRangeParam dateRangeParam = new DateRangeParam().setLowerBound(PERSON_BIRTH_DATE).setUpperBound(PERSON_BIRTH_DATE);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, dateRangeParam);
when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(person));
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PERSON_UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(personTranslator.toFhirResource(person)).thenReturn(fhirPerson);
IBundleProvider results = personService.searchForPeople(null, null, dateRangeParam, null, null, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
use of org.openmrs.module.fhir2.api.translators.PersonTranslator in project openmrs-module-fhir2 by openmrs.
the class FhirPersonServiceImplTest method searchForPeople_shouldReturnCollectionOfPersonWhenPersonStateMatched.
@Test
public void searchForPeople_shouldReturnCollectionOfPersonWhenPersonStateMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(STATE)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, stringAndListParam);
when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(person));
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PERSON_UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, personTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(personTranslator.toFhirResource(person)).thenReturn(fhirPerson);
IBundleProvider results = personService.searchForPeople(null, null, null, null, stringAndListParam, null, null, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(greaterThanOrEqualTo(1)));
}
Aggregations