Search in sources :

Example 1 with TwoSearchQueryBundleProvider

use of org.openmrs.module.fhir2.api.search.TwoSearchQueryBundleProvider 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)

Example 2 with TwoSearchQueryBundleProvider

use of org.openmrs.module.fhir2.api.search.TwoSearchQueryBundleProvider 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;
}
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)

Example 3 with TwoSearchQueryBundleProvider

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

Aggregations

IBundleProvider (ca.uhn.fhir.rest.api.server.IBundleProvider)3 TwoSearchQueryBundleProvider (org.openmrs.module.fhir2.api.search.TwoSearchQueryBundleProvider)3 SearchParameterMap (org.openmrs.module.fhir2.api.search.param.SearchParameterMap)3 Transactional (org.springframework.transaction.annotation.Transactional)2 TokenAndListParam (ca.uhn.fhir.rest.param.TokenAndListParam)1