use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirGroupMemberService_2_1Test method shouldSearchForGroupMembersByGroupUuid.
@Test
public void shouldSearchForGroupMembersByGroupUuid() {
GroupMember groupMember = mock(GroupMember.class);
CohortMembership cohortMembership = mock(CohortMembership.class);
List<CohortMembership> memberships = new ArrayList<>();
memberships.add(cohortMembership);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.GROUP_MEMBERS_SEARCH_HANDLER, GROUP_MEMBER_UUID);
when(dao.getSearchResults(any(), any())).thenReturn(memberships);
when(dao.getSearchResultUuids(any())).thenReturn(Collections.singletonList(GROUP_MEMBER_UUID));
when(translator.toFhirResource(cohortMembership)).thenReturn(groupMember);
when(searchQuery.getQueryResults(any(), any(), any(), any())).thenReturn(new SearchQueryBundleProvider<>(theParams, dao, translator, globalPropertyService, searchQueryInclude));
when(searchQueryInclude.getIncludedResources(any(), any())).thenReturn(Collections.emptySet());
IBundleProvider results = groupMemberService.getGroupMembers(GROUP_MEMBER_UUID);
List<IBaseResource> resultList = get(results);
assertThat(results, Matchers.notNullValue());
assertThat(resultList, not(empty()));
assertThat(resultList, hasSize(1));
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class SearchQueryBundleProviderTest method shouldReturnDifferentUuid.
@Test
public void shouldReturnDifferentUuid() {
assertThat(searchQueryBundleProvider.getUuid(), notNullValue());
assertThat(searchQueryBundleProvider.getUuid(), not(equalTo(new SearchQueryBundleProvider<>(new SearchParameterMap(), observationDao, translator, globalPropertyService, searchQueryInclude).getUuid())));
}
use of org.openmrs.module.fhir2.api.search.SearchQueryInclude in project openmrs-module-fhir2 by openmrs.
the class FhirImmunizationServiceImpl method searchImmunizations.
@Override
public IBundleProvider searchImmunizations(ReferenceAndListParam patientParam, SortSpec sort) {
SearchParameterMap theParams = new SearchParameterMap();
theParams.addParameter(PATIENT_REFERENCE_SEARCH_HANDLER, patientParam);
TokenAndListParam conceptParam = new TokenAndListParam();
TokenParam token = new TokenParam();
token.setValue(Integer.toString(helper.concept(IMMUNIZATION_GROUPING_CONCEPT).getId()));
conceptParam.addAnd(token);
theParams.addParameter(CODED_SEARCH_HANDLER, conceptParam);
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 FhirPatientServiceImpl method getPatientEverything.
@Override
@Transactional(readOnly = true)
public IBundleProvider getPatientEverything() {
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.EVERYTHING_SEARCH_HANDLER, "");
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 FhirEncounterServiceImpl method searchForEncounters.
@Override
@Transactional(readOnly = true)
public IBundleProvider searchForEncounters(DateRangeParam date, ReferenceAndListParam location, ReferenceAndListParam participant, ReferenceAndListParam subject, TokenAndListParam encounterType, TokenAndListParam id, DateRangeParam lastUpdated, SortSpec sort, HashSet<Include> includes, HashSet<Include> revIncludes) {
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.DATE_RANGE_SEARCH_HANDLER, date).addParameter(FhirConstants.LOCATION_REFERENCE_SEARCH_HANDLER, location).addParameter(FhirConstants.PARTICIPANT_REFERENCE_SEARCH_HANDLER, participant).addParameter(FhirConstants.PATIENT_REFERENCE_SEARCH_HANDLER, subject).addParameter(FhirConstants.ENCOUNTER_TYPE_REFERENCE_SEARCH_HANDLER, encounterType).addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.ID_PROPERTY, id).addParameter(FhirConstants.COMMON_SEARCH_HANDLER, FhirConstants.LAST_UPDATED_PROPERTY, lastUpdated).addParameter(FhirConstants.INCLUDE_SEARCH_HANDLER, includes).addParameter(FhirConstants.REVERSE_INCLUDE_SEARCH_HANDLER, revIncludes).setSortSpec(sort);
IBundleProvider visitBundle = visitService.searchForVisits(theParams);
IBundleProvider encounterBundle = searchQuery.getQueryResults(theParams, dao, translator, searchQueryInclude);
if (!encounterBundle.isEmpty() && !visitBundle.isEmpty()) {
return new TwoSearchQueryBundleProvider(visitBundle, encounterBundle, globalPropertyService);
} else if (encounterBundle.isEmpty() && !visitBundle.isEmpty()) {
return visitBundle;
}
return encounterBundle;
}
Aggregations