use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldNotAddRelatedResourcesToResultListForEmptyRevInclude.
@Test
public void searchForPatients_shouldNotAddRelatedResourcesToResultListForEmptyRevInclude() {
HashSet<Include> revIncludes = new HashSet<>();
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.REVERSE_INCLUDE_SEARCH_HANDLER, revIncludes);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(PATIENT_UUID));
when(dao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(patient));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, patientTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(patientTranslator.toFhirResource(patient)).thenReturn(fhirPatient);
IBundleProvider results = patientService.searchForPatients(null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, revIncludes);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList.size(), greaterThanOrEqualTo(1));
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImplTest method searchForPatients_shouldReturnEmptyCollectionWhenPatientCityNotMatched.
@Test
public void searchForPatients_shouldReturnEmptyCollectionWhenPatientCityNotMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringParam(UNKNOWN_ADDRESS));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.NAME_SEARCH_HANDLER, "city", stringAndListParam);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, patientTranslator, globalPropertyService, searchQueryInclude));
IBundleProvider results = patientService.searchForPatients(null, null, null, null, null, null, null, null, stringAndListParam, null, null, null, null, null, null, null);
assertThat(results, notNullValue());
assertThat(get(results), empty());
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirPersonServiceImplTest method searchForPeople_shouldReturnEmptyCollectionWhenLastUpdatedNotMatched.
@Test
public void searchForPeople_shouldReturnEmptyCollectionWhenLastUpdatedNotMatched() {
DateRangeParam lastUpdated = new DateRangeParam().setUpperBound(WRONG_LAST_UPDATED_DATE).setLowerBound(WRONG_LAST_UPDATED_DATE);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated);
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(null, null, null, null, null, null, null, null, lastUpdated, null, null);
assertThat(results, notNullValue());
assertThat(get(results), empty());
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirPersonServiceImplTest method searchForPeople_shouldReturnEmptyCollectionWhenPersonCountryNotMatched.
@Test
public void searchForPeople_shouldReturnEmptyCollectionWhenPersonCountryNotMatched() {
StringAndListParam stringAndListParam = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(NOT_ADDRESS_FIELD)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, 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(null, null, null, null, null, null, stringAndListParam, null, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirPersonServiceImplTest method searchForPeople_shouldReturnEmptyCollectionWhenUUIDNotMatched.
@Test
public void searchForPeople_shouldReturnEmptyCollectionWhenUUIDNotMatched() {
TokenAndListParam uuid = new TokenAndListParam().addAnd(new TokenParam(WRONG_PERSON_UUID));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, uuid);
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(null, null, null, null, null, null, null, uuid, null, null, null);
assertThat(results, notNullValue());
assertThat(get(results), empty());
}
Aggregations