-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Feature - Permit Bulk Export on Compartment by FHIR Query #7310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: rel_8_6
Are you sure you want to change the base?
Changes from 20 commits
6bba3cb
f795113
4d57ea8
c80280d
384ff31
e070201
33d0df7
5575871
6ff269b
6c5d860
640c9ef
2f02a09
10fd885
af123a9
bd3ca50
5873e18
0d906c4
78324a9
9727733
f8b3d41
7fdc3a4
31d143c
17ed1ad
5f52b36
5390b9b
1f83598
b50a5aa
d558587
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| --- | ||
| type: add | ||
| issue: 7342 | ||
| title: "Enhanced the bulk export RuleBuilder code to support the identification of allowable Groups/Patients to export by a FHIR query matcher." |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| /*- | ||
| * #%L | ||
| * HAPI FHIR JPA Server | ||
| * %% | ||
| * Copyright (C) 2014 - 2025 Smile CDR, Inc. | ||
| * %% | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * #L% | ||
| */ | ||
| package ca.uhn.fhir.jpa.interceptor; | ||
|
|
||
| import ca.uhn.fhir.jpa.api.dao.DaoRegistry; | ||
| import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; | ||
| import ca.uhn.fhir.rest.api.Constants; | ||
| import ca.uhn.fhir.rest.api.server.SystemRequestDetails; | ||
| import ca.uhn.fhir.rest.param.TokenOrListParam; | ||
| import ca.uhn.fhir.rest.server.interceptor.auth.IAuthResourceResolver; | ||
| import org.hl7.fhir.instance.model.api.IBaseResource; | ||
| import org.hl7.fhir.instance.model.api.IIdType; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Small service class to inject DB access into an interceptor | ||
| * For example, used in bulk export security to allow querying for resource to match against permission argument filters | ||
| */ | ||
| @Service | ||
| public class AuthResourceResolver implements IAuthResourceResolver { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes me nervous. I get the design, but it's breaking the well-established pattern we have that auth interceptor doesn't resolve anything, it just looks at the data it's passed and makes a decision. Instead of creating a loading infrastructure, could we add a new parameter object to |
||
| private final DaoRegistry myDaoRegistry; | ||
|
|
||
| public AuthResourceResolver(DaoRegistry myDaoRegistry) { | ||
| this.myDaoRegistry = myDaoRegistry; | ||
| } | ||
|
|
||
| public IBaseResource resolveCompartmentById(IIdType theResourceId) { | ||
| return myDaoRegistry | ||
| .getResourceDao(theResourceId.getResourceType()) | ||
| .read(theResourceId, new SystemRequestDetails()); | ||
| } | ||
jdar8 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| public List<IBaseResource> resolveCompartmentByIds(List<String> theResourceIds, String theResourceType) { | ||
| TokenOrListParam t = new TokenOrListParam(null, theResourceIds.toArray(String[]::new)); | ||
|
|
||
| SearchParameterMap m = new SearchParameterMap(); | ||
| m.add(Constants.PARAM_ID, t); | ||
| return myDaoRegistry.getResourceDao(theResourceType).searchForResources(m, new SystemRequestDetails()); | ||
tadgh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /*- | ||
| * #%L | ||
| * HAPI FHIR - Server Framework | ||
| * %% | ||
| * Copyright (C) 2014 - 2025 Smile CDR, Inc. | ||
| * %% | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * #L% | ||
| */ | ||
| package ca.uhn.fhir.rest.server.interceptor.auth; | ||
|
|
||
| import org.hl7.fhir.instance.model.api.IBaseResource; | ||
| import org.hl7.fhir.instance.model.api.IIdType; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * Small service class to inject DB access into an interceptor | ||
| * For example, used in bulk export security to allow querying for resource to match against permission argument filters | ||
| */ | ||
| public interface IAuthResourceResolver { | ||
| IBaseResource resolveCompartmentById(IIdType theResourceId); | ||
tadgh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| /** | ||
| * Resolve a list of resources by ID. All resources should be the same type. | ||
| * @param theResourceIds the FHIR id of the resource(s) | ||
| * @param theResourceType the type of resource | ||
| * @return A list of resources resolved by ID | ||
| */ | ||
tadgh marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| List<IBaseResource> resolveCompartmentByIds(List<String> theResourceIds, String theResourceType); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,6 +127,22 @@ public interface IAuthRuleBuilderRule { | |
| */ | ||
| IAuthRuleBuilderRuleBulkExport bulkExport(); | ||
|
|
||
| /** | ||
| * This rule permits the user to initiate a FHIR bulk export | ||
| * by providing a filter matcher on Group compartment(s). | ||
| * | ||
| * @since 8.6.0 | ||
| */ | ||
| IAuthRuleBuilderRuleGroupMatcherBulkExport bulkExportGroupCompartmentMatcher(); | ||
|
||
|
|
||
| /** | ||
| * This rule permits the user to initiate a FHIR bulk export | ||
| * by providing a filter matcher on Patient compartment(s). | ||
| * | ||
| * @since 8.6.0 | ||
| */ | ||
| IAuthRuleBuilderRulePatientMatcherBulkExport bulkExportPatientCompartmentMatcher(); | ||
|
|
||
| /** | ||
| * This rule specifically allows a user to perform a FHIR update on the historical version of a resource | ||
| * | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /*- | ||
| * #%L | ||
| * HAPI FHIR - Server Framework | ||
| * %% | ||
| * Copyright (C) 2014 - 2025 Smile CDR, Inc. | ||
| * %% | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * #L% | ||
| */ | ||
| package ca.uhn.fhir.rest.server.interceptor.auth; | ||
|
|
||
| import jakarta.annotation.Nonnull; | ||
|
|
||
| /** | ||
| * @since 8.6.0 | ||
| */ | ||
| public interface IAuthRuleBuilderRuleGroupMatcherBulkExport { | ||
| /** | ||
| * Allow/deny <b>group-level</b> export rule applies to the Group with the given resource ID, e.g. <code>Group/123</code> | ||
| * | ||
| * @since 8.6.0 | ||
| */ | ||
| IAuthRuleBuilderRuleBulkExportWithTarget groupExportOnGroup(@Nonnull String theCompartmentFilterMatcher); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /*- | ||
| * #%L | ||
| * HAPI FHIR - Server Framework | ||
| * %% | ||
| * Copyright (C) 2014 - 2025 Smile CDR, Inc. | ||
| * %% | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * #L% | ||
| */ | ||
| package ca.uhn.fhir.rest.server.interceptor.auth; | ||
|
|
||
| import jakarta.annotation.Nonnull; | ||
|
|
||
| /** | ||
| * @since 8.6.0 | ||
| */ | ||
| public interface IAuthRuleBuilderRulePatientMatcherBulkExport { | ||
| /** | ||
| * Allow/deny <b>group-level</b> export rule applies to the Group with the given resource ID, e.g. <code>Group/123</code> | ||
jdar8 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * | ||
| * @since 8.6.0 | ||
| */ | ||
| IAuthRuleBuilderRuleBulkExportWithTarget patientExportOnPatient(@Nonnull String theCompartmentFilterMatcher); | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.