Skip to content

Commit 1bad7e3

Browse files
committed
Revert "FM2-646: Practitioner: support limiting search to users or providers"
This reverts commit a304967.
1 parent a304967 commit 1bad7e3

File tree

9 files changed

+139
-246
lines changed

9 files changed

+139
-246
lines changed

api/src/main/java/org/openmrs/module/fhir2/FhirConstants.java

-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ private FhirConstants() {
109109

110110
public static final String OPENMRS_FHIR_EXT_ENCOUNTER_TAG = OPENMRS_FHIR_EXT_PREFIX + "/encounter-tag";
111111

112-
public static final String OPENMRS_FHIR_EXT_PRACTITIONER_TAG = OPENMRS_FHIR_EXT_PREFIX + "/practitioner-tag";
113-
114112
public static final String OPENMRS_FHIR_EXT_OBSERVATION_REFERENCE_RANGE = OPENMRS_FHIR_EXT_PREFIX
115113
+ "/obs/reference-range";
116114

api/src/main/java/org/openmrs/module/fhir2/api/impl/FhirPractitionerServiceImpl.java

+6-30
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,7 @@
1111

1212
import javax.annotation.Nonnull;
1313

14-
import java.util.Collections;
15-
1614
import ca.uhn.fhir.rest.api.server.IBundleProvider;
17-
import ca.uhn.fhir.rest.param.InternalCodingDt;
18-
import ca.uhn.fhir.rest.param.TokenAndListParam;
1915
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
2016
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
2117
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
@@ -25,7 +21,6 @@
2521
import org.hl7.fhir.r4.model.Practitioner;
2622
import org.openmrs.Provider;
2723
import org.openmrs.User;
28-
import org.openmrs.module.fhir2.FhirConstants;
2924
import org.openmrs.module.fhir2.api.FhirGlobalPropertyService;
3025
import org.openmrs.module.fhir2.api.FhirPractitionerService;
3126
import org.openmrs.module.fhir2.api.FhirUserService;
@@ -97,36 +92,17 @@ public Practitioner create(@Nonnull Practitioner newResource) {
9792
@Override
9893
@Transactional(readOnly = true)
9994
public IBundleProvider searchForPractitioners(PractitionerSearchParams practitionerSearchParams) {
95+
IBundleProvider providerBundle = searchQuery.getQueryResults(practitionerSearchParams.toSearchParameterMap(), dao,
96+
translator, searchQueryInclude);
97+
SearchParameterMap theParams = new SearchParameterMap();
98+
IBundleProvider userBundle = userService.searchForUsers(theParams);
10099

101-
IBundleProvider providerBundle = null;
102-
IBundleProvider userBundle = null;
103-
104-
if (shouldSearchExplicitlyFor(practitionerSearchParams.getTag(), "provider")) {
105-
providerBundle = searchQuery.getQueryResults(practitionerSearchParams.toSearchParameterMap(), dao, translator,
106-
searchQueryInclude);
107-
}
108-
109-
if (shouldSearchExplicitlyFor(practitionerSearchParams.getTag(), "user")) {
110-
SearchParameterMap theParams = new SearchParameterMap();
111-
userBundle = userService.searchForUsers(theParams);
112-
}
113-
114-
if (providerBundle != null && userBundle != null) {
100+
if (!providerBundle.isEmpty() && !userBundle.isEmpty()) {
115101
return new TwoSearchQueryBundleProvider(providerBundle, userBundle, globalPropertyService);
116-
} else if (providerBundle == null && userBundle != null) {
102+
} else if (providerBundle.isEmpty() && !userBundle.isEmpty()) {
117103
return userBundle;
118104
}
119105

120106
return providerBundle;
121107
}
122-
123-
protected boolean shouldSearchExplicitlyFor(TokenAndListParam tokenAndListParam, @Nonnull String valueToCheck) {
124-
if (tokenAndListParam == null || tokenAndListParam.size() == 0 || valueToCheck.isEmpty()) {
125-
return true;
126-
}
127-
128-
return tokenAndListParam.getValuesAsQueryTokens().stream().anyMatch(
129-
tokenOrListParam -> tokenOrListParam.doesCodingListMatch(Collections
130-
.singletonList(new InternalCodingDt(FhirConstants.OPENMRS_FHIR_EXT_PRACTITIONER_TAG, valueToCheck))));
131-
}
132108
}

api/src/main/java/org/openmrs/module/fhir2/api/search/param/PractitionerSearchParams.java

+2-7
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@ public class PractitionerSearchParams extends BaseResourceSearchParams {
4242

4343
private StringAndListParam country;
4444

45-
private TokenAndListParam tag;
46-
4745
@Builder
4846
public PractitionerSearchParams(TokenAndListParam identifier, StringAndListParam name, StringAndListParam given,
4947
StringAndListParam family, StringAndListParam city, StringAndListParam state, StringAndListParam postalCode,
50-
StringAndListParam country, TokenAndListParam id, TokenAndListParam tag, DateRangeParam lastUpdated,
51-
HashSet<Include> revIncludes) {
48+
StringAndListParam country, TokenAndListParam id, DateRangeParam lastUpdated, HashSet<Include> revIncludes) {
5249

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

@@ -60,7 +57,6 @@ public PractitionerSearchParams(TokenAndListParam identifier, StringAndListParam
6057
this.state = state;
6158
this.postalCode = postalCode;
6259
this.country = country;
63-
this.tag = tag;
6460
}
6561

6662
@Override
@@ -72,7 +68,6 @@ public SearchParameterMap toSearchParameterMap() {
7268
.addParameter(FhirConstants.CITY_SEARCH_HANDLER, getCity())
7369
.addParameter(FhirConstants.STATE_SEARCH_HANDLER, getState())
7470
.addParameter(FhirConstants.POSTALCODE_SEARCH_HANDLER, getPostalCode())
75-
.addParameter(FhirConstants.COUNTRY_SEARCH_HANDLER, getCountry())
76-
.addParameter(FhirConstants.TAG_SEARCH_HANDLER, getTag());
71+
.addParameter(FhirConstants.COUNTRY_SEARCH_HANDLER, getCountry());
7772
}
7873
}

api/src/main/java/org/openmrs/module/fhir2/providers/r3/PractitionerFhirResourceProvider.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ public IBundleProvider searchForPractitioners(@OptionalParam(name = Practitioner
113113
@OptionalParam(name = Practitioner.SP_ADDRESS_POSTALCODE) StringAndListParam postalCode,
114114
@OptionalParam(name = Practitioner.SP_ADDRESS_COUNTRY) StringAndListParam country,
115115
@OptionalParam(name = Practitioner.SP_RES_ID) TokenAndListParam id,
116-
@OptionalParam(name = "_tag") TokenAndListParam tag,
117116
@OptionalParam(name = "_lastUpdated") DateRangeParam lastUpdated,
118117
@IncludeParam(reverse = true, allow = { "Encounter:" + Encounter.SP_PARTICIPANT,
119118
"MedicationRequest:" + MedicationRequest.SP_REQUESTER,
@@ -125,7 +124,7 @@ public IBundleProvider searchForPractitioners(@OptionalParam(name = Practitioner
125124

126125
return new SearchQueryBundleProviderR3Wrapper(
127126
practitionerService.searchForPractitioners(new PractitionerSearchParams(identifier, name, given, family,
128-
city, state, postalCode, country, id, tag, lastUpdated, revIncludes)));
127+
city, state, postalCode, country, id, lastUpdated, revIncludes)));
129128
}
130129

131130
}

api/src/main/java/org/openmrs/module/fhir2/providers/r4/PractitionerFhirResourceProvider.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@ public IBundleProvider searchForPractitioners(@OptionalParam(name = Practitioner
122122
@OptionalParam(name = Practitioner.SP_ADDRESS_POSTALCODE) StringAndListParam postalCode,
123123
@OptionalParam(name = Practitioner.SP_ADDRESS_COUNTRY) StringAndListParam country,
124124
@OptionalParam(name = Practitioner.SP_RES_ID) TokenAndListParam id,
125-
@OptionalParam(name = "_tag") TokenAndListParam tag,
126125
@OptionalParam(name = "_lastUpdated") DateRangeParam lastUpdated,
127126
@IncludeParam(reverse = true, allow = { "Encounter:" + Encounter.SP_PARTICIPANT,
128127
"MedicationRequest:" + MedicationRequest.SP_REQUESTER, "ServiceRequest:" + ServiceRequest.SP_REQUESTER,
@@ -132,6 +131,6 @@ public IBundleProvider searchForPractitioners(@OptionalParam(name = Practitioner
132131
}
133132

134133
return practitionerService.searchForPractitioners(new PractitionerSearchParams(identifier, name, given, family, city,
135-
state, postalCode, country, id, tag, lastUpdated, revIncludes));
134+
state, postalCode, country, id, lastUpdated, revIncludes));
136135
}
137136
}

0 commit comments

Comments
 (0)