Skip to content

Commit

Permalink
Revert "FM2-646: Practitioner: support limiting search to users or pr…
Browse files Browse the repository at this point in the history
…oviders"

This reverts commit 6eaa03a.
  • Loading branch information
mogoodrich committed Oct 8, 2024
1 parent 6eaa03a commit d43f85a
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 204 deletions.
2 changes: 0 additions & 2 deletions api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ private FhirConstants() {

public static final String ENCOUNTER_TYPE_REFERENCE_SEARCH_HANDLER = "type.reference.search.handler";

public static final String PROVIDER_ROLE_SEARCH_HANDLER = "providerRole.search.handler";

public static final String ID_PROPERTY = "_id.property";

public static final String LAST_UPDATED_PROPERTY = "_lastUpdated.property";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,8 @@
*/
package org.openmrs.module.fhir2.api.dao.impl;

import static org.hibernate.criterion.Restrictions.eq;

import java.util.Optional;

import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.param.TokenAndListParam;
import org.hibernate.Criteria;
import org.hibernate.criterion.Criterion;
import org.openmrs.Auditable;
import org.openmrs.OpenmrsObject;
import org.openmrs.module.fhir2.FhirConstants;
Expand All @@ -44,8 +37,6 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams
case FhirConstants.ADDRESS_SEARCH_HANDLER:
handleAddresses(criteria, entry);
break;
case FhirConstants.PROVIDER_ROLE_SEARCH_HANDLER:
handlerProviderRoles(criteria, (StringOrListParam) entry.getValue());
case FhirConstants.COMMON_SEARCH_HANDLER:
handleCommonSearchParameters(entry.getValue()).ifPresent(criteria::add);
break;
Expand All @@ -55,17 +46,6 @@ protected void setupSearchParams(Criteria criteria, SearchParameterMap theParams

protected abstract void handleIdentifier(Criteria criteria, TokenAndListParam identifier);

protected void handlerProviderRoles(Criteria criteria, StringOrListParam providerRole) {
handleOrListParam(providerRole, param -> handleProviderRole(criteria, param)).ifPresent(criteria::add);
}

protected Optional<Criterion> handleProviderRole(Criteria criteria, StringParam providerRole) {
if (lacksAlias(criteria, "pr")) {
criteria.createAlias("providerRole", "pr");
}
return Optional.of(eq("pr.uuid", providerRole));
}

@Override
protected String getSqlAlias() {
return "p_";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public IBundleProvider searchForPractitioners(PractitionerSearchParams practitio
IBundleProvider providerBundle = null;
IBundleProvider userBundle = null;

// TODO only search for providers if we have a provider roles tag
if (shouldSearchExplicitlyFor(practitionerSearchParams.getTag(), "provider")) {
providerBundle = searchQuery.getQueryResults(practitionerSearchParams.toSearchParameterMap(), dao, translator,
searchQueryInclude);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.TokenAndListParam;
import lombok.Builder;
import lombok.Data;
Expand Down Expand Up @@ -43,15 +42,13 @@ public class PractitionerSearchParams extends BaseResourceSearchParams {

private StringAndListParam country;

private StringOrListParam providerRole;

private TokenAndListParam tag;

@Builder
public PractitionerSearchParams(TokenAndListParam identifier, StringAndListParam name, StringAndListParam given,
StringAndListParam family, StringAndListParam city, StringAndListParam state, StringAndListParam postalCode,
StringAndListParam country, TokenAndListParam id, StringOrListParam providerRole, TokenAndListParam tag,
DateRangeParam lastUpdated, HashSet<Include> revIncludes) {
StringAndListParam country, TokenAndListParam id, TokenAndListParam tag, DateRangeParam lastUpdated,
HashSet<Include> revIncludes) {

super(id, lastUpdated, null, null, revIncludes);

Expand All @@ -63,7 +60,6 @@ public PractitionerSearchParams(TokenAndListParam identifier, StringAndListParam
this.state = state;
this.postalCode = postalCode;
this.country = country;
this.providerRole = providerRole;
this.tag = tag;
}

Expand All @@ -77,7 +73,6 @@ public SearchParameterMap toSearchParameterMap() {
.addParameter(FhirConstants.STATE_SEARCH_HANDLER, getState())
.addParameter(FhirConstants.POSTALCODE_SEARCH_HANDLER, getPostalCode())
.addParameter(FhirConstants.COUNTRY_SEARCH_HANDLER, getCountry())
.addParameter(FhirConstants.PROVIDER_ROLE_SEARCH_HANDLER, getProviderRole())
.addParameter(FhirConstants.TAG_SEARCH_HANDLER, getTag());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import ca.uhn.fhir.rest.api.server.IBundleProvider;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.TokenAndListParam;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
Expand Down Expand Up @@ -114,7 +113,6 @@ public IBundleProvider searchForPractitioners(@OptionalParam(name = Practitioner
@OptionalParam(name = Practitioner.SP_ADDRESS_POSTALCODE) StringAndListParam postalCode,
@OptionalParam(name = Practitioner.SP_ADDRESS_COUNTRY) StringAndListParam country,
@OptionalParam(name = Practitioner.SP_RES_ID) TokenAndListParam id,
@OptionalParam(name = "providerRole") StringOrListParam providerRole,
@OptionalParam(name = "_tag") TokenAndListParam tag,
@OptionalParam(name = "_lastUpdated") DateRangeParam lastUpdated,
@IncludeParam(reverse = true, allow = { "Encounter:" + Encounter.SP_PARTICIPANT,
Expand All @@ -127,7 +125,7 @@ public IBundleProvider searchForPractitioners(@OptionalParam(name = Practitioner

return new SearchQueryBundleProviderR3Wrapper(
practitionerService.searchForPractitioners(new PractitionerSearchParams(identifier, name, given, family,
city, state, postalCode, country, id, providerRole, tag, lastUpdated, revIncludes)));
city, state, postalCode, country, id, tag, lastUpdated, revIncludes)));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.DateRangeParam;
import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringOrListParam;
import ca.uhn.fhir.rest.param.TokenAndListParam;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
Expand Down Expand Up @@ -123,7 +122,6 @@ public IBundleProvider searchForPractitioners(@OptionalParam(name = Practitioner
@OptionalParam(name = Practitioner.SP_ADDRESS_POSTALCODE) StringAndListParam postalCode,
@OptionalParam(name = Practitioner.SP_ADDRESS_COUNTRY) StringAndListParam country,
@OptionalParam(name = Practitioner.SP_RES_ID) TokenAndListParam id,
@OptionalParam(name = "providerRole") StringOrListParam providerRole,
@OptionalParam(name = "_tag") TokenAndListParam tag,
@OptionalParam(name = "_lastUpdated") DateRangeParam lastUpdated,
@IncludeParam(reverse = true, allow = { "Encounter:" + Encounter.SP_PARTICIPANT,
Expand All @@ -134,6 +132,6 @@ public IBundleProvider searchForPractitioners(@OptionalParam(name = Practitioner
}

return practitionerService.searchForPractitioners(new PractitionerSearchParams(identifier, name, given, family, city,
state, postalCode, country, id, providerRole, tag, lastUpdated, revIncludes));
state, postalCode, country, id, tag, lastUpdated, revIncludes));
}
}
Loading

0 comments on commit d43f85a

Please sign in to comment.