Package ca.cdr.api.consent
Class ConsentParameterizedPolicyRequest
java.lang.Object
ca.cdr.api.consent.ConsentParameterizedPolicyRequest
A consent policy request for parameterized policies that accept query parameters.
Contains:
- The policy name which should be mapped to a new instance of an
IConsentService - The
UserSessionDetailsJsonof the user making the request (may be null during bootstrap validation). - A map of parameters with AND/OR structure that can be used to configure the consent service.
- An optional Consent resource for consent-resource-based policies.
Parameterized policies support query parameters that configure their behavior. Parameters are parsed into an AND/OR structure where:
- Comma-separated values within a single parameter create OR conditions
- Repeated parameter occurrences (separated by &) create AND groups
Example: RedactFhirPathsWhen?_type=Patient,Observation&fhirpath=Patient.name&fhirpath=Patient.address
For fixed policies that do not accept parameters, use ConsentFixedPolicyRequest instead.
-
Constructor Summary
ConstructorsConstructorDescriptionConsentParameterizedPolicyRequest(String thePolicyNameWithQueryParams, UserSessionDetailsJson theUserSessionDetails) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddParameter(String theKey, String theValue) Add a parameter value.voidaddParameterOrList(String theKey, List<String> theOrList) Add a pre-split OR list as a new AND group for the key.Get all parameters with their AND/OR structure.Get the Consent resource associated with this request.getParameter(String theKey) Get the AND/OR structure for a parameter.booleanhasParameter(String theKey) Check if a parameter exists.setConsentResource(IBaseResource theConsentResource) Set the Consent resource for consent-resource-based policies.
-
Constructor Details
-
ConsentParameterizedPolicyRequest
public ConsentParameterizedPolicyRequest(String thePolicyNameWithQueryParams, UserSessionDetailsJson theUserSessionDetails)
-
-
Method Details
-
getPolicyName
-
getUserSessionDetailsJson
-
addParameter
Add a parameter value. The value is split on commas to create an OR list, and each call creates a new AND group for the key. This supports multi-valued query parameters likefhirpath=X,Y&fhirpath=Zwhere X,Y is an OR list and Z is a separate AND group.- Parameters:
theKey- the parameter keytheValue- the parameter value (comma-separated values become OR conditions)
-
addParameterOrList
Add a pre-split OR list as a new AND group for the key. This is used when parameters have already been parsed and split.- Parameters:
theKey- the parameter keytheOrList- the pre-split OR values
-
hasParameter
Check if a parameter exists.- Parameters:
theKey- the parameter key- Returns:
- true if the parameter exists
-
getParameter
Get the AND/OR structure for a parameter. The outer list represents AND groups (each occurrence of the parameter). The inner list represents OR values (comma-separated within one occurrence).- Parameters:
theKey- the parameter key- Returns:
- list of AND groups, each containing OR values, or empty list if not found
-
getAllParameters
Get all parameters with their AND/OR structure.- Returns:
- unmodifiable map of parameter keys to lists of AND groups
-
getConsentResource
Get the Consent resource associated with this request. This is only set for consent-resource-based policies.- Returns:
- the Consent resource, or null for builtin policies
-
setConsentResource
public ConsentParameterizedPolicyRequest setConsentResource(@Nullable IBaseResource theConsentResource) Set the Consent resource for consent-resource-based policies.- Parameters:
theConsentResource- the Consent resource- Returns:
- this request for method chaining
-