diff --git a/fhir-config/src/main/java/com/ibm/fhir/config/FHIRConfiguration.java b/fhir-config/src/main/java/com/ibm/fhir/config/FHIRConfiguration.java index d2aa3a35d7a..3032a623b9c 100644 --- a/fhir-config/src/main/java/com/ibm/fhir/config/FHIRConfiguration.java +++ b/fhir-config/src/main/java/com/ibm/fhir/config/FHIRConfiguration.java @@ -36,8 +36,13 @@ public class FHIRConfiguration { public static final String PROPERTY_CAPABILITY_STATEMENT_CACHE = "fhirServer/core/capabilityStatementCacheTimeout"; public static final String PROPERTY_EXTENDED_CODEABLE_CONCEPT_VALIDATION = "fhirServer/core/extendedCodeableConceptValidation"; - public static final String PROPERTY_SEARCH_PARAMETER_FILTER = "fhirServer/searchParameterFilter"; - + // Resources properties + public static final String PROPERTY_RESOURCES = "fhirServer/resources"; + public static final String PROPERTY_FIELD_RESOURCES_INCLUDE_OMITTED = "includeOmittedResourceTypes"; + public static final String PROPERTY_FIELD_RESOURCES_SEARCH_PARAMETERS = "searchParameters"; + public static final String PROPERTY_FIELD_RESOURCES_SEARCH_PARAMETER_URL = "url"; + public static final String PROPERTY_FIELD_RESOURCES_SEARCH_PARAMETER_REQUIRED = "required"; + // Auth and security properties public static final String PROPERTY_SECURITY_CORS = "fhirServer/security/cors"; public static final String PROPERTY_SECURITY_BASIC_ENABLED = "fhirServer/security/basic/enabled"; diff --git a/fhir-search/src/main/java/com/ibm/fhir/search/util/SearchUtil.java b/fhir-search/src/main/java/com/ibm/fhir/search/util/SearchUtil.java index e18af058c86..eaebfa09aa2 100644 --- a/fhir-search/src/main/java/com/ibm/fhir/search/util/SearchUtil.java +++ b/fhir-search/src/main/java/com/ibm/fhir/search/util/SearchUtil.java @@ -258,9 +258,9 @@ private static Collection filterSearchParameters(Map unfilteredSearchParameters) { List results = new ArrayList<>(); - // First, retrieve the filter rule (list of SP names to be included) for the specified resource type. + // First, retrieve the filter rule (list of SP urls to be included) for the specified resource type. // We know that the SearchParameters in the unfiltered list are all associated with this resource type, - // so we can use this same "name list" for each Search Parameter in the unfiltered list. + // so we can use this same "url list" for each Search Parameter in the unfiltered list. List includedSPs = filterRules.get(resourceType); if (includedSPs == null) { @@ -271,7 +271,7 @@ private static Collection filterSearchParameters(Map filterSearchParameters(Map filterSearchParameters(Map> getFilterRules() throws Exception { Map> result = new HashMap<>(); - - // Retrieve the "searchParameterFilter" config property group. - PropertyGroup spFilter = FHIRConfigHelper.getPropertyGroup(FHIRConfiguration.PROPERTY_SEARCH_PARAMETER_FILTER); - List ruleEntries = null; - if (spFilter != null) { - ruleEntries = spFilter.getProperties(); - } - - // If we have a non-empty set of filter rules, then walk through them and populate our map. - if (ruleEntries != null && !ruleEntries.isEmpty()) { - for (PropertyEntry ruleEntry : ruleEntries) { - String resourceType = ruleEntry.getName(); - - // Make sure the value is a List. - if (ruleEntry.getValue() instanceof List) { - for (Object listMember : (List) ruleEntry.getValue()) { - if (!(listMember instanceof String)) { + boolean includeOmittedRsrcTypes = true; + + // Retrieve the "resources" config property group. + PropertyGroup rsrcsGroup = FHIRConfigHelper.getPropertyGroup(FHIRConfiguration.PROPERTY_RESOURCES); + if (rsrcsGroup != null) { + List rsrcsEntries = rsrcsGroup.getProperties(); + if (rsrcsEntries != null && !rsrcsEntries.isEmpty()) { + for (PropertyEntry rsrcsEntry : rsrcsEntries) { + + // Check special property for including omitted resource types + if (FHIRConfiguration.PROPERTY_FIELD_RESOURCES_INCLUDE_OMITTED.equals(rsrcsEntry.getName())) { + if (rsrcsEntry.getValue() instanceof Boolean) { + includeOmittedRsrcTypes = (Boolean) rsrcsEntry.getValue(); + } + else { throw SearchExceptionUtil.buildNewIllegalStateException(); } } - - // Add the rule entry to our map, keyed by resource type. - List stringList = (List) ruleEntry.getValue(); - result.put(resourceType, stringList); - } else { - throw SearchExceptionUtil.buildNewIllegalStateException(); + else { + String resourceType = rsrcsEntry.getName(); + PropertyGroup resourceTypeGroup = (PropertyGroup) rsrcsEntry.getValue(); + if (resourceTypeGroup != null) { + List searchParameterUrls = new ArrayList<>(); + + // Get search parameters + PropertyGroup spGroup = resourceTypeGroup.getPropertyGroup(FHIRConfiguration.PROPERTY_FIELD_RESOURCES_SEARCH_PARAMETERS); + if (spGroup != null) { + List spEntries = spGroup.getProperties(); + if (spEntries != null && !spEntries.isEmpty()) { + for (PropertyEntry spEntry : spEntries) { + + PropertyGroup spValueGroup = (PropertyGroup) spEntry.getValue(); + if (spValueGroup != null) { + String url = spValueGroup.getStringProperty(FHIRConfiguration.PROPERTY_FIELD_RESOURCES_SEARCH_PARAMETER_URL); + if (url == null) { + throw SearchExceptionUtil.buildNewIllegalStateException(); + } + searchParameterUrls.add(url); + } + } + } + } + else { + searchParameterUrls.add(SearchConstants.WILDCARD); + } + result.put(resourceType, searchParameterUrls); + } + } } } - } else { - // The current tenant doesn't have any filter rules defined, so - // we'll just fabricate one that includes all search parameters: - //
{ "*": ["*"] }
- List list = new ArrayList<>(); - list.add(SearchConstants.WILDCARD); - result.put(SearchConstants.WILDCARD, list); } + + if (includeOmittedRsrcTypes) { + // All other resource types include all search parameters + result.put(SearchConstants.WILDCARD, Collections.singletonList(SearchConstants.WILDCARD)); + } + return result; } - + /** * Returns the SearchParameter map (keyed by resource type) for the specified * tenant-id, or null if there are no SearchParameters for the tenant. diff --git a/fhir-search/src/test/resources/config/default/fhir-server-config.json b/fhir-search/src/test/resources/config/default/fhir-server-config.json index 8598a573846..50141b10b27 100644 --- a/fhir-search/src/test/resources/config/default/fhir-server-config.json +++ b/fhir-search/src/test/resources/config/default/fhir-server-config.json @@ -1,9 +1,5 @@ { "__comment": "FHIR Server configuration", "fhirServer": { - "_comment": "Just hiding this property because 'include-all' should be the default", - "_searchParameterFilter": { - "*": "*" - } } } diff --git a/fhir-search/src/test/resources/config/tenant1/fhir-server-config.json b/fhir-search/src/test/resources/config/tenant1/fhir-server-config.json index 25378079045..1d2412af4f7 100644 --- a/fhir-search/src/test/resources/config/tenant1/fhir-server-config.json +++ b/fhir-search/src/test/resources/config/tenant1/fhir-server-config.json @@ -1,23 +1,41 @@ { "__comment": "FHIR Server configuration", "fhirServer": { - "searchParameterFilter": { - "Device": [ - "patient", - "organization" - ], - "Observation": [ - "code" - ], - "Patient": [ - "active", - "address", - "birthdate", - "name" - ], - "*": [ - "*" - ] + "resources": { + "includeOmittedResourceTypes": true, + "Device": { + "searchParameters": { + "patient": { + "url": "http://hl7.org/fhir/SearchParameter/Device-patient" + }, + "organization": { + "url": "http://hl7.org/fhir/SearchParameter/Device-organization" + } + } + }, + "Observation": { + "searchParameters": { + "code": { + "url": "http://hl7.org/fhir/SearchParameter/clinical-code" + } + } + }, + "Patient": { + "searchParameters": { + "active": { + "url": "http://hl7.org/fhir/SearchParameter/Patient-active" + }, + "address": { + "url": "http://hl7.org/fhir/SearchParameter/individual-address" + }, + "birthdate": { + "url": "http://hl7.org/fhir/SearchParameter/individual-birthdate" + }, + "name": { + "url": "http://hl7.org/fhir/SearchParameter/Patient-name" + } + } + } } } } diff --git a/fhir-search/src/test/resources/config/tenant2/fhir-server-config.json b/fhir-search/src/test/resources/config/tenant2/fhir-server-config.json index 308161e86c3..50141b10b27 100644 --- a/fhir-search/src/test/resources/config/tenant2/fhir-server-config.json +++ b/fhir-search/src/test/resources/config/tenant2/fhir-server-config.json @@ -1,9 +1,5 @@ { "__comment": "FHIR Server configuration", "fhirServer": { - "_comment": "include all search parameters for all resource types (default)", - "searchParameterFilter": { - "*": ["*"] - } } } diff --git a/fhir-search/src/test/resources/config/tenant4/fhir-server-config.json b/fhir-search/src/test/resources/config/tenant4/fhir-server-config.json index 25378079045..1d2412af4f7 100644 --- a/fhir-search/src/test/resources/config/tenant4/fhir-server-config.json +++ b/fhir-search/src/test/resources/config/tenant4/fhir-server-config.json @@ -1,23 +1,41 @@ { "__comment": "FHIR Server configuration", "fhirServer": { - "searchParameterFilter": { - "Device": [ - "patient", - "organization" - ], - "Observation": [ - "code" - ], - "Patient": [ - "active", - "address", - "birthdate", - "name" - ], - "*": [ - "*" - ] + "resources": { + "includeOmittedResourceTypes": true, + "Device": { + "searchParameters": { + "patient": { + "url": "http://hl7.org/fhir/SearchParameter/Device-patient" + }, + "organization": { + "url": "http://hl7.org/fhir/SearchParameter/Device-organization" + } + } + }, + "Observation": { + "searchParameters": { + "code": { + "url": "http://hl7.org/fhir/SearchParameter/clinical-code" + } + } + }, + "Patient": { + "searchParameters": { + "active": { + "url": "http://hl7.org/fhir/SearchParameter/Patient-active" + }, + "address": { + "url": "http://hl7.org/fhir/SearchParameter/individual-address" + }, + "birthdate": { + "url": "http://hl7.org/fhir/SearchParameter/individual-birthdate" + }, + "name": { + "url": "http://hl7.org/fhir/SearchParameter/Patient-name" + } + } + } } } } diff --git a/fhir-search/src/test/resources/config/tenant5/fhir-server-config.json b/fhir-search/src/test/resources/config/tenant5/fhir-server-config.json index 25378079045..1d2412af4f7 100644 --- a/fhir-search/src/test/resources/config/tenant5/fhir-server-config.json +++ b/fhir-search/src/test/resources/config/tenant5/fhir-server-config.json @@ -1,23 +1,41 @@ { "__comment": "FHIR Server configuration", "fhirServer": { - "searchParameterFilter": { - "Device": [ - "patient", - "organization" - ], - "Observation": [ - "code" - ], - "Patient": [ - "active", - "address", - "birthdate", - "name" - ], - "*": [ - "*" - ] + "resources": { + "includeOmittedResourceTypes": true, + "Device": { + "searchParameters": { + "patient": { + "url": "http://hl7.org/fhir/SearchParameter/Device-patient" + }, + "organization": { + "url": "http://hl7.org/fhir/SearchParameter/Device-organization" + } + } + }, + "Observation": { + "searchParameters": { + "code": { + "url": "http://hl7.org/fhir/SearchParameter/clinical-code" + } + } + }, + "Patient": { + "searchParameters": { + "active": { + "url": "http://hl7.org/fhir/SearchParameter/Patient-active" + }, + "address": { + "url": "http://hl7.org/fhir/SearchParameter/individual-address" + }, + "birthdate": { + "url": "http://hl7.org/fhir/SearchParameter/individual-birthdate" + }, + "name": { + "url": "http://hl7.org/fhir/SearchParameter/Patient-name" + } + } + } } } } diff --git a/fhir-search/src/test/resources/config/tenant6/fhir-server-config.json b/fhir-search/src/test/resources/config/tenant6/fhir-server-config.json index 8598a573846..50141b10b27 100644 --- a/fhir-search/src/test/resources/config/tenant6/fhir-server-config.json +++ b/fhir-search/src/test/resources/config/tenant6/fhir-server-config.json @@ -1,9 +1,5 @@ { "__comment": "FHIR Server configuration", "fhirServer": { - "_comment": "Just hiding this property because 'include-all' should be the default", - "_searchParameterFilter": { - "*": "*" - } } } diff --git a/fhir-search/src/test/resources/config/tenant7/fhir-server-config.json b/fhir-search/src/test/resources/config/tenant7/fhir-server-config.json index 8598a573846..ebc9242d612 100644 --- a/fhir-search/src/test/resources/config/tenant7/fhir-server-config.json +++ b/fhir-search/src/test/resources/config/tenant7/fhir-server-config.json @@ -1,9 +1,41 @@ { "__comment": "FHIR Server configuration", "fhirServer": { - "_comment": "Just hiding this property because 'include-all' should be the default", - "_searchParameterFilter": { - "*": "*" + "resources": { + "includeOmittedResourceTypes": true, + "ExplanationOfBenefit": { + "interactions": ["read", + "vread", + "history", + "search"], + "searchIncludes": ["ExplanationOfBenefit:patient", + "ExplanationOfBenefit:provider", + "ExplanationOfBenefit:care-team", + "ExplanationOfBenefit:coverage", + "ExplanationOfBenefit:insurer"], + "searchRevIncludes": [], + "searchParameters": { + "_id": { + "url": "http://hl7.org/fhir/SearchParameter/Resource-id" + }, + "patient": { + "url": "http://hl7.org/fhir/us/carin-bb/SearchParameter/explanationofbenefit-patient", + "required": true + }, + "_lastUpdated": { + "url": "http://hl7.org/fhir/SearchParameter/Resource-lastUpdated" + }, + "type": { + "url": "http://hl7.org/fhir/us/carin-bb/SearchParameter/explanationofbenefit-type" + }, + "identifier": { + "url": "http://hl7.org/fhir/us/carin-bb/SearchParameter/explanationofbenefit-identifier" + }, + "service-date": { + "url": "http://hl7.org/fhir/us/carin-bb/SearchParameter/explanationofbenefit-service-date" + } + } + } } } } diff --git a/fhir-server/liberty-config-tenants/config/tenant1/fhir-server-config.json b/fhir-server/liberty-config-tenants/config/tenant1/fhir-server-config.json index 17af53ec42c..a139769e50c 100644 --- a/fhir-server/liberty-config-tenants/config/tenant1/fhir-server-config.json +++ b/fhir-server/liberty-config-tenants/config/tenant1/fhir-server-config.json @@ -1,13 +1,34 @@ { "__comment": "FHIR Server configuration for mythical tenant id 'tenant1'", "fhirServer": { - "searchParameterFilter": { - "Observation": ["subject", - "patient", - "value-quantity", - "component-value-quantity"], - "Resource": ["_id"], - "*": ["*"] + "resources": { + "includeOmittedResourceTypes": true, + "Observation": { + "searchParameters": { + "_id": { + "url": "http://hl7.org/fhir/SearchParameter/Resource-id" + }, + "subject": { + "url": "http://hl7.org/fhir/SearchParameter/Observation-subject" + }, + "patient": { + "url": "http://hl7.org/fhir/SearchParameter/clinical-patient" + }, + "value-quantity": { + "url": "http://hl7.org/fhir/SearchParameter/Observation-value-quantity" + }, + "component-value-quantity": { + "url": "http://hl7.org/fhir/SearchParameter/Observation-component-value-quantity" + } + } + }, + "Resource": { + "searchParameters": { + "_id": { + "url": "http://hl7.org/fhir/SearchParameter/Resource-id" + } + } + } }, "persistence": { "datasources": {