**Full name**: projects.locations.datasets.fhirStores.applyConsents

Apply the Consent resources for the FHIR store and reindex the underlying resources in the FHIR store according to the aggregate consent. The aggregate consent of the patient in scope in this request replaces any previous call of this method. Any Consent resource change after this operation execution (including deletion) requires you to call `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores/applyConsents#google.cloud.healthcare.v1beta1.fhir.FhirStoreService.ApplyConsents` again to have effect.

This method returns an `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation` that can be used to track the progress of the consent resources that were processed by calling `operations.get`. Upon completion, the `ApplyConsentsResponse` additionally contains the number of resources that was reindexed.

Errors are logged to Cloud Logging (see [Viewing error logs in Cloud Logging](https://cloud.google.com/healthcare/docs/how-tos/logging)).

To enforce consent check for data access, `consentConfig.access_enforced` must be set to true for the `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores#FhirStore`.

FHIR Consent is not supported in DSTU2 or R5.

### HTTP request

`POST https://healthcare.googleapis.com/v1beta1/{name=projects/*/locations/*/datasets/*/fhirStores/*}:applyConsents`

The URL uses [gRPC Transcoding](https://google.aip.dev/127) syntax.

### Path parameters

| Parameters ||
|---|---|
| `name` | `string` Required. The name of the FHIR store to enforce, in the format `projects/{projectId}/locations/{locationId}/datasets/{datasetId}/fhirStores/{fhirStoreId}`. Authorization requires the following [IAM](https://cloud.google.com/iam/docs/) permission on the specified resource `name`: - `healthcare.fhirStores.applyConsents` |

### Request body

The request body contains data with the following structure:

| JSON representation |
|---|
| ``` { "validateOnly": boolean, // The following is a list of mutually exclusive fields. At most one of the // fields will be set in a response: "patientScope": { object(`https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores/applyConsents#PatientScope`) }, "timeRange": { object(`https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores/applyConsents#TimeRange`) } // End of mutually exclusive fields. } ``` |

| Fields ||
|---|---|
| `validateOnly` | `boolean` Optional. If true, the method only validates Consent resources to make sure they are supported. When the operation completes, `ApplyConsentsResponse` is returned where `consentApplySuccess` and `consentApplyFailure` indicate supported and unsupported (or invalid) Consent resources, respectively. Otherwise, the method propagates the aggregate consensual information to the patient's resources. Upon success, `affectedResources` in the `ApplyConsentsResponse` indicates the number of resources that may have consensual access changed. |
| The following is a list of mutually exclusive fields. At most one of the fields will be set in a response: ||
| `patientScope` | ``object(`https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores/applyConsents#PatientScope`)`` Optional. Scope down to a list of patients. |
| `timeRange` | ``object(`https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores/applyConsents#TimeRange`)`` Optional. Scope down to patients whose most recent consent changes are in the time range. Can only be used with a versioning store (i.e. when `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/v1beta1/projects.locations.datasets.fhirStores#FhirStore.FIELDS.disable_resource_versioning` is set to false). |
| End of mutually exclusive fields. ||

### Response body

If successful, the response body contains an instance of `https://docs.cloud.google.com/healthcare-api/docs/reference/rest/Shared.Types/ListOperationsResponse#Operation`.

### Authorization scopes

Requires one of the following OAuth scopes:

- `https://www.googleapis.com/auth/cloud-healthcare`
- `https://www.googleapis.com/auth/cloud-platform`

For more information, see the [Authentication Overview](https://docs.cloud.google.com/docs/authentication#authorization-gcp).

## PatientScope

Apply consents given by a list of patients.

| JSON representation |
|---|
| ``` { "patientIds": [ string ] } ``` |

| Fields ||
|---|---|
| `patientIds[]` | `string` Optional. The list of patient IDs whose Consent resources will be enforced. At most 10,000 patients can be specified. An empty list is equivalent to all patients (meaning the entire FHIR store). |

## TimeRange

Apply consents given by patients whose most recent consent changes are in the time range. Note that after identifying these patients, the server applies all Consent resources given by those patients, not just the Consent resources within the timestamp in the range.

| JSON representation |
|---|
| ``` { "start": string, "end": string } ``` |

| Fields ||
|---|---|
| `start` | `string` Optional. The earliest consent change time, in format YYYY-MM-DDThh:mm:ss.sss+zz:zz If not specified, the system uses the FHIR store creation time. |
| `end` | `string` Optional. The latest consent change time, in format YYYY-MM-DDThh:mm:ss.sss+zz:zz If not specified, the system uses the time when \[fhirStores.applyConsents\]\[\] was called. |