Search in sources :

Example 91 with SearchQueryInclude

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));
}
Also used : GroupMember(org.openmrs.module.fhir2.model.GroupMember) ArrayList(java.util.ArrayList) IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) IBaseResource(org.hl7.fhir.instance.model.api.IBaseResource) CohortMembership(org.openmrs.CohortMembership) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 92 with SearchQueryInclude

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())));
}
Also used : SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Test(org.junit.Test)

Example 93 with SearchQueryInclude

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);
}
Also used : TokenParam(ca.uhn.fhir.rest.param.TokenParam) TokenAndListParam(ca.uhn.fhir.rest.param.TokenAndListParam) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap)

Example 94 with 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);
}
Also used : SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Transactional(org.springframework.transaction.annotation.Transactional)

Example 95 with 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;
}
Also used : IBundleProvider(ca.uhn.fhir.rest.api.server.IBundleProvider) TwoSearchQueryBundleProvider(org.openmrs.module.fhir2.api.search.TwoSearchQueryBundleProvider) SearchParameterMap(org.openmrs.module.fhir2.api.search.param.SearchParameterMap) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)190 IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)187 Test (org.junit.Test)184 IBaseResource (org.hl7.fhir.instance.model.api.IBaseResource)148 StringParam (ca.uhn.fhir.rest.param.StringParam)72 StringAndListParam (ca.uhn.fhir.rest.param.StringAndListParam)66 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)49 TokenParam (ca.uhn.fhir.rest.param.TokenParam)41 ArrayList (java.util.ArrayList)41 SimpleBundleProvider (ca.uhn.fhir.rest.server.SimpleBundleProvider)39 Include (ca.uhn.fhir.model.api.Include)29 HashSet (java.util.HashSet)29 SearchQueryInclude (org.openmrs.module.fhir2.api.search.SearchQueryInclude)29 StringOrListParam (ca.uhn.fhir.rest.param.StringOrListParam)28 DateRangeParam (ca.uhn.fhir.rest.param.DateRangeParam)27 ReferenceAndListParam (ca.uhn.fhir.rest.param.ReferenceAndListParam)22 ReferenceOrListParam (ca.uhn.fhir.rest.param.ReferenceOrListParam)22 ReferenceParam (ca.uhn.fhir.rest.param.ReferenceParam)22 TokenOrListParam (ca.uhn.fhir.rest.param.TokenOrListParam)19 Patient (org.openmrs.Patient)12