use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirPatientServiceImpl method getPatientEverything.
@Override
@Transactional(readOnly = true)
public IBundleProvider getPatientEverything(TokenParam patientId) {
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.EVERYTHING_SEARCH_HANDLER, "").addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, new TokenAndListParam().addAnd(patientId));
populateEverythingOperationParams(theParams);
return searchQuery.getQueryResults(theParams, dao, translator, searchQueryInclude);
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirPractitionerServiceImpl method searchForPractitioners.
@Override
public IBundleProvider searchForPractitioners(TokenAndListParam identifier, StringAndListParam name, StringAndListParam given, StringAndListParam family, StringAndListParam city, StringAndListParam state, StringAndListParam postalCode, StringAndListParam country, TokenAndListParam id, DateRangeParam lastUpdated, HashSet<Include> revIncludes) {
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.IDENTIFIER_SEARCH_HANDLER, identifier).addParameter(FhirConstants.NAME_SEARCH_HANDLER, FhirConstants.NAME_PROPERTY, name).addParameter(FhirConstants.NAME_SEARCH_HANDLER, FhirConstants.GIVEN_PROPERTY, given).addParameter(FhirConstants.NAME_SEARCH_HANDLER, FhirConstants.FAMILY_PROPERTY, family).addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.CITY_PROPERTY, city).addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.STATE_PROPERTY, state).addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.POSTAL_CODE_PROPERTY, postalCode).addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, country).addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, id).addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated).addParameter(FhirConstants.REVERSE_INCLUDE_SEARCH_HANDLER, revIncludes);
IBundleProvider providerBundle = searchQuery.getQueryResults(theParams, dao, translator, searchQueryInclude);
IBundleProvider userBundle = userService.searchForUsers(theParams);
if (!providerBundle.isEmpty() && !userBundle.isEmpty()) {
return new TwoSearchQueryBundleProvider(providerBundle, userBundle, globalPropertyService);
} else if (providerBundle.isEmpty() && !userBundle.isEmpty()) {
return userBundle;
}
return providerBundle;
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirEncounterServiceImpl method getEncounterEverything.
@Override
@Transactional(readOnly = true)
public IBundleProvider getEncounterEverything(TokenParam encounterId) {
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.EVERYTHING_SEARCH_HANDLER, "").addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, new TokenAndListParam().addAnd(encounterId));
populateReverseIncludeForEverythingOperationParams(theParams);
populateIncludeForEverythingOperationParams(theParams);
IBundleProvider visitBundle = visitService.searchForVisits(theParams);
IBundleProvider encounterBundle = searchQuery.getQueryResults(theParams, dao, translator, searchQueryInclude);
if (!encounterBundle.isEmpty() && !visitBundle.isEmpty()) {
return new TwoSearchQueryBundleProvider(encounterBundle, visitBundle, globalPropertyService);
} else if (encounterBundle.isEmpty() && !visitBundle.isEmpty()) {
return visitBundle;
}
return encounterBundle;
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirPractitionerServiceImplTest method shouldSearchForPractitionersByNameWhoIsUserAndProvider.
@Test
public void shouldSearchForPractitionersByNameWhoIsUserAndProvider() {
StringAndListParam name = new StringAndListParam().addAnd(new StringOrListParam().add(new StringParam(USER_NAME)));
SearchParameterMap theParams = new SearchParameterMap().addParameter(NAME_SEARCH_HANDLER, NAME_PROPERTY, name);
when(practitionerDao.getSearchResults(any(), any())).thenReturn(Collections.singletonList(provider));
when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(UUID));
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
when(practitionerTranslator.toFhirResource(provider)).thenReturn(practitioner);
when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider(practitioner2));
IBundleProvider results = practitionerService.searchForPractitioners(null, name, 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(2)));
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirPractitionerServiceImplTest method shouldReturnEmptyCollectionByWrongAddressCountry.
@Test
public void shouldReturnEmptyCollectionByWrongAddressCountry() {
StringAndListParam country = new StringAndListParam().addAnd(new StringParam(WRONG_COUNTRY));
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.ADDRESS_SEARCH_HANDLER, FhirConstants.COUNTRY_PROPERTY, country);
when(practitionerDao.getSearchResultUuids(any())).thenReturn(Collections.emptyList());
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, practitionerDao, practitionerTranslator, globalPropertyService, searchQueryInclude));
when(userService.searchForUsers(any())).thenReturn(new SimpleBundleProvider());
IBundleProvider results = practitionerService.searchForPractitioners(null, null, null, null, null, null, null, country, null, null, null);
List<IBaseResource> resultList = get(results);
assertThat(results, notNullValue());
assertThat(resultList, empty());
}
Aggregations