Skip to content

Commit

Permalink
issue #3242 - update $everything to use ResourcesConfigAdapter
Browse files Browse the repository at this point in the history
1. add the FHIRVersionParam to the OperationContext
2. use that with a ResourcesConfigAdapter to get the list of applicable
resource types in EverythingOperation.getDefaultIncludedResourceTypes

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
  • Loading branch information
lmsurpre committed Apr 21, 2022
1 parent a86cd75 commit 422e20b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* (C) Copyright IBM Corp. 2017, 2021
* (C) Copyright IBM Corp. 2017, 2022
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -84,6 +84,11 @@ public enum Type { SYSTEM, RESOURCE_TYPE, INSTANCE }
*/
public static final String PROPNAME_RESPONSE_PARAMETERS = "RESPONSE_PARAMETERS";

/**
* The FHIRVersionParam for this invocation
*/
public static final String PROPNAME_FHIR_VERSION = "FHIR_VERSION";

private final Type type;
private final String code;
private Map<String, Object> properties = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2603,6 +2603,7 @@ private void setOperationContextProperties(FHIROperationContext operationContext
operationContext.setProperty(FHIROperationContext.PROPNAME_REQUEST_BASE_URI, getRequestBaseUri(resourceTypeName));
operationContext.setProperty(FHIROperationContext.PROPNAME_REQUEST_PARAMETERS, requestParameters);
operationContext.setProperty(FHIROperationContext.PROPNAME_PERSISTENCE_IMPL, persistence);
operationContext.setProperty(FHIROperationContext.PROPNAME_FHIR_VERSION, fhirVersion);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.ibm.fhir.config.PropertyGroup;
import com.ibm.fhir.config.ResourcesConfigAdapter;
import com.ibm.fhir.core.FHIRConstants;
import com.ibm.fhir.core.FHIRVersionParam;
import com.ibm.fhir.core.HTTPHandlingPreference;
import com.ibm.fhir.exception.FHIROperationException;
import com.ibm.fhir.model.resource.Bundle;
Expand Down Expand Up @@ -210,7 +211,8 @@ protected Parameters doInvoke(FHIROperationContext operationContext, Class<? ext

List<String> defaultResourceTypes = new ArrayList<String>(0);
try {
defaultResourceTypes = getDefaultIncludedResourceTypes(resourceHelper);
FHIRVersionParam fhirVersion = (FHIRVersionParam) operationContext.getProperty(FHIROperationContext.PROPNAME_FHIR_VERSION);
defaultResourceTypes = getDefaultIncludedResourceTypes(resourceHelper, fhirVersion);
} catch (FHIRSearchException e) {
throw new Error("There has been an error retrieving the list of included resources of the $everything operation.", e);
}
Expand Down Expand Up @@ -390,12 +392,12 @@ protected List<String> getOverridenIncludedResourceTypes(Parameters parameters,
* @return the list of patient subresources that will be included in the $everything operation
* @throws FHIRSearchException
*/
private List<String> getDefaultIncludedResourceTypes(FHIRResourceHelpers resourceHelper) throws FHIRSearchException {
private List<String> getDefaultIncludedResourceTypes(FHIRResourceHelpers resourceHelper, FHIRVersionParam fhirVersion) throws FHIRSearchException {
List<String> resourceTypes = new ArrayList<>(compartmentHelper.getCompartmentResourceTypes(PATIENT));

try {
PropertyGroup resourcesGroup = FHIRConfigHelper.getPropertyGroup(FHIRConfiguration.PROPERTY_RESOURCES);
ResourcesConfigAdapter configAdapter = new ResourcesConfigAdapter(resourcesGroup);
ResourcesConfigAdapter configAdapter = new ResourcesConfigAdapter(resourcesGroup, fhirVersion);
Set<String> supportedResourceTypes = configAdapter.getSupportedResourceTypes(Interaction.SEARCH);

if (LOG.isLoggable(Level.FINE)) {
Expand All @@ -411,7 +413,7 @@ private List<String> getDefaultIncludedResourceTypes(FHIRResourceHelpers resourc
resourceTypes.retainAll(supportedResourceTypes);
} catch (Exception e) {
FHIRSearchException exceptionWithIssue = new FHIRSearchException("There has been an error retrieving the list "
+ "of supported resource types of the $everything operation.", e);
+ "of supported resource types for the $everything operation.", e);
LOG.throwing(this.getClass().getName(), "doInvoke", exceptionWithIssue);
throw exceptionWithIssue;
}
Expand Down

0 comments on commit 422e20b

Please sign in to comment.