Skip to content

Commit 6058d4d

Browse files
authored
Merge pull request #1833 from IBM/issue-1831
Signed-off-by: Lee Surprenant <[email protected]>
2 parents 23a68d3 + bc23fb2 commit 6058d4d

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

fhir-search/src/main/java/com/ibm/fhir/search/util/SearchUtil.java

+12-3
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,13 @@ public static SearchParameter getSearchParameter(String resourceType, String cod
444444
// If we found it within the built-in search parameters, apply our filtering rules.
445445
if (result != null) {
446446

447+
// Check if this search parameter applies to the base Resource type
447448
ResourceType rt = result.getBase().get(0).as(ResourceType.class);
449+
if (SearchConstants.RESOURCE_RESOURCE.equals(rt.getValue())) {
450+
resourceType = rt.getValue();
451+
}
448452
Collection<SearchParameter> filteredResult =
449-
filterSearchParameters(getFilterRules(), rt.getValue(), Collections.singleton(result));
453+
filterSearchParameters(getFilterRules(), resourceType, Collections.singleton(result));
450454

451455
// If our filtered result is non-empty, then just return the first (and only) item.
452456
result = (filteredResult.isEmpty() ? null : filteredResult.iterator().next());
@@ -509,9 +513,14 @@ public static SearchParameter getSearchParameter(String resourceType, Canonical
509513

510514
// If we found it within the built-in search parameters, apply our filtering rules.
511515
if (result != null) {
512-
ResourceType rt = result.getBase().get(0);
516+
517+
// Check if this search parameter applies to the base Resource type
518+
ResourceType rt = result.getBase().get(0).as(ResourceType.class);
519+
if (SearchConstants.RESOURCE_RESOURCE.equals(rt.getValue())) {
520+
resourceType = rt.getValue();
521+
}
513522
Collection<SearchParameter> filteredResult =
514-
filterSearchParameters(getFilterRules(), rt.getValue(), Collections.singleton(result));
523+
filterSearchParameters(getFilterRules(), resourceType, Collections.singleton(result));
515524

516525
// If our filtered result is non-empty, then just return the first (and only) item.
517526
result = (filteredResult.isEmpty() ? null : filteredResult.iterator().next());

fhir-search/src/test/java/com/ibm/fhir/search/parameters/MultiTenantSearchParameterTest.java

+6
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,12 @@ public void testGetSearchParameter11() throws Exception {
274274
assertNotNull(result);
275275
}
276276

277+
@Test
278+
public void testGetSearchParameter12() throws Exception {
279+
SearchParameter result = SearchUtil.getSearchParameter("FamilyMemberHistory", "code");
280+
assertNotNull(result);
281+
}
282+
277283
@Test
278284
void testDynamicSearchParameters1() throws Exception {
279285
// Test behavior of dynamic updates to search parameters.
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
{
22
"__comment": "FHIR Server configuration",
33
"fhirServer": {
4+
"resources": {
5+
"open": true,
6+
"FamilyMemberHistory": {
7+
"searchParameters": {
8+
"code": "http://hl7.org/fhir/SearchParameter/clinical-code"
9+
}
10+
}
11+
}
412
}
513
}

0 commit comments

Comments
 (0)