You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/healthcare-apis/fhir/fhir-bulk-delete.md
+15-1Lines changed: 15 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,10 +13,24 @@ ms.author: kesheth
13
13
14
14
[!INCLUDE [bulk-delete operation common content](../includes/fhir-bulk-delete-operation.md)]
15
15
16
+
## End to end example: Utilizing `$bulk-delete` for data retention use cases
17
+
The various features of `$bulk-delete` can be used together to satisfy different use cases. Following is an example of utilizing $bulk-delete for data retention.
18
+
19
+
Let’s say that you would like to delete Patient data that's older than three years old, along with all data that references to that Patient. However, as multiple Patients can map to a single Practitioner, you’d like to make sure that Practitioners aren't deleted until all their Patients are deleted. This use case can be achieved in a series of calls.
20
+
21
+
First, you can delete all Patient resources older than three years old, along with all data that references to that Patient.
Copy file name to clipboardExpand all lines: articles/healthcare-apis/fhir/overview-of-search.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,15 +22,15 @@ GET {{FHIR_URL}}/Patient
22
22
23
23
You can also search using `POST`. To search using `POST`, the search parameters are delivered in the body of the request. This makes it easier to send queries with longer, more complex series of parameters.
24
24
25
-
With either `POST` or `GET`, if the search request is successful, you receive a FHIR `searchset` bundle containing the resource instances returned from the search. If the search fails, you’ll find the error details in an`OperationOutcome` response.
25
+
With either `POST` or `GET`, if the search request is successful, you receive a FHIR `searchset` bundle containing the resource instances returned from the search. If the search fails, the error details are in the`OperationOutcome` response.
26
26
27
-
In the following sections, we cover the various aspects of querying resources in FHIR. Once you’ve reviewed these topics, refer to the [FHIR search samples page](search-samples.md), which features examples of different FHIR search methods.
27
+
In the following sections, we cover the various aspects of querying resources in FHIR. Once you review these topics, refer to the [FHIR search samples page](search-samples.md), which features examples of different FHIR search methods.
28
28
29
29
## Search parameters
30
30
31
31
When you do a search in FHIR, you're searching the database for resources that match certain criteria. The FHIR API specifies a rich set of search parameters for fine-tuning search criteria. Each resource in FHIR carries information as a set of elements, and search parameters work to query the information in these elements. In a FHIR search API call, if a positive match is found between the request's search parameters and corresponding element values stored in a resource instance, then the FHIR server returns a bundle containing the resource instances whose elements satisfied the search criteria.
32
32
33
-
For each search parameter, the FHIR specification defines the [data type](https://www.hl7.org/fhir/search.html#ptypes) that can be used. Support in the FHIR service for the various data types is outlined below.
33
+
For each search parameter, the FHIR specification defines the [data type](https://www.hl7.org/fhir/search.html#ptypes) that can be used. Support in the FHIR service for the various data types is outlined in the following.
34
34
35
35
36
36
|**Search parameter type**|**FHIR service in Azure Health Data Services**|**Azure API for FHIR**|**Comment**|
@@ -137,7 +137,7 @@ FHIR specifies a set of search result parameters to help manage the information
137
137
|`_contained`| No | No ||
138
138
|`_containedType`| No | No ||
139
139
|`_score`| No | No ||
140
-
|`_not-referenced`| Yes | No |`_not-referenced=*:*` to search for resources that are not referenced by any other resources. For example, `/Patient?_not-referenced=*:*` is used to search for Patient resources that are not referenced by any other resources. |
140
+
|`_not-referenced`| Yes | No |`_not-referenced=*:*` to search for resources that are not referenced by other resources. For example, `/Patient?_not-referenced=*:*` is used to search for Patient resources that are not referenced by any other resources. `/Patient?_not-referenced=Encounter:subject` is used to search for Patient resources that are not referenced by Encounter resources that list them as a subject. A list can also be used for multiple referenced fields, for example, `/Patient/$bulk-delete?_not-referenced=Encounter:subject&_not-referenced=DiagnosticReport:subject` is used to search for Patient resources that are not referenced by Encounter and DiagnosticReport resources. |
141
141
142
142
Note:
143
143
1. By default, `_sort` arranges records in ascending order. You can also use the prefix `-` to sort in descending order. The FHIR service only allows you to sort on a single field at a time.
@@ -252,4 +252,4 @@ Now that you've learned about the basics of FHIR search, see the search samples
Copy file name to clipboardExpand all lines: articles/healthcare-apis/includes/fhir-bulk-delete-operation.md
+43-70Lines changed: 43 additions & 70 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,9 +51,50 @@ Query parameters allow you to filter the raw resources you plan to delete. To su
51
51
|------------------------|---|------------|
52
52
|_hardDelete|False|Allows you to hard delete a resource. If you don't pass this parameter or set hardDelete to false, the historic versions of the resource are still available.|
53
53
|_purgeHistory|False|Allows you to delete history versions associated with resource. It doesn't delete the current version of the resource and soft deleted resources. Note: When _purgeHistory used with the _hardDelete parameter set to true, it permanently deletes all versions associated with the resource.|
54
-
|FHIR service supported search parameters||Allows you to specify search criteria and resources matching the search criteria are deleted. For example: `address:contains=Meadow subject:Patient.birthdate=1987-02-20`|
54
+
|excludedResourceTypes|empty|Allows you to exclude specified resource types (comma-separated) from being deleted in a bulk delete request. For example, `DELETE [base]/$bulk-delete?excludedResourceTypes=patient,observation` deletes all resources in your FHIR server, except for the Patient and Observation resource types. |
55
+
|_remove-references|False|Allows you to remove references to resources that are being deleted. This parameter must be used with _hardDelete=true. After you use this parameter to remove references, the reference that was removed is now replaced with the following value: `“display”: “Referenced resource deleted”`. For example, `DELETE [base]/Patient/$bulk-delete?_remove-references=true&_hardDelete=true` bulk hard deleted all Patient resources, and remove references to those patients from other resources. So, if a Patient resource was referenced by an Observation resource, the reference to that Patient, which was previously `"subject": { "reference": "Patient/example-patient-id", }`, is removed from the Observation resource after using bulk delete and removing references, and will be replaced with `"subject": { "display": "Referenced resource deleted" }`. |
56
+
|_not-referenced|empty| Allows you to use the [`_not-referenced`](/azure/healthcare-apis/fhir/overview-of-search#search-result-parameters)search parameter to search for resources that aren't referenced by other resources. See below section for more examples of using FHIR service supported search parameters.|
57
+
|FHIR service supported search parameters||Allows you to specify search criteria and resources matching the search criteria are deleted. For example: `address:contains=Meadow subject:Patient.birthdate=1987-02-20`. The section below provides more examples of using FHIR service supported search parameters, including how to use `_include` and `_revinclude` to use bulk delete with references, and _not-referenced to look for resources not referenced by other resources. |
58
+
55
59
56
60
All the query parameters are optional.
61
+
### Examples of using `$bulk-delete` with FHIR service supported search parameters
62
+
The $bulk-delete operation supports using FHIR service supported search parameters as a query parameter. Please note that singular deletes do not support extra parameters. When using bulk delete with FHIR search parameters, consider using the same query in a FHIR search first, so that you can verify the data that you want to delete.
63
+
64
+
#### `$bulk-delete` with `_include` and `_revinclude`
65
+
`$bulk-delete` can be used with `_include` and `_revinclude` to use bulk delete with references. More information about `_include` and `_revinclude` as search result parameters can be found here. Some examples of using `$bulk-delete` with `_include` and `_revinclude`:
66
+
67
+
The following example using `_revinclude` will bulk delete all Patient resources that were last updated before December 18, 2021, and all resources that reference to those patients:
The following example using `_include` will bulk delete all DiagnosticReport resources that were last updated before 12/18/2021, as well as all ServiceRequest resources that are referenced by those DiagnosticReport resources (via DiagnosticReport.basedOn relationship), and all Encounter resources that are referenced by those ServiceRequest resources (via ServiceRequest.encounters relationship):
> The `_not-referenced` feature is available in Azure Health Data Services FHIR Server only, and isn't available in Azure API for FHIR.
78
+
79
+
Utilizing $bulk-delete with the [_not-referenced parameter](/azure/healthcare-apis/fhir/overview-of-search#search-result-parameters) allows you to search for and delete resources that are not referenced by other resources.
80
+
81
+
The following example will bulk delete all Patient resources that are not referenced by Encounter resources that list them as a subject:
To delete soft deleted resources within a FHIR service -$bulk-delete-soft-deleted operation can be used. This operation can be executed at the system level or for individual resource types.
@@ -123,72 +164,4 @@ Here's a list of error messages that might occur if the bulk delete operation fa
123
164
- Do API interactions see any latency when a bulk delete operation job is executed concurrently?<br/><br/>When you run a bulk delete operation, you might see increased latency on concurrent calls to the service. To avoid a latency increase, we recommend that you cancel the bulk delete job, and then rerun it during a period of lower traffic.
124
165
125
166
> [!NOTE]
126
-
> If you cancel and then restart a bulk delete job, the deletion process resumes from where it was stopped.
127
-
128
-
## Preview capabilities for the bulk delete operation
129
-
### `$bulk-delete` with `_include` and `_revinclude`
130
-
Note: The `$bulk-delete` operation now supports using `_include` and `_revinclude` in the search criteria for conditional and bulk delete. This new feature doesn't affect current behavior of singular deletes, which doesn't support extra parameters. Additionally, when using bulk delete with FHIR search parameters, consider using the same query in a FHIR search first, so that you can verify the data that you want to delete.
131
-
132
-
Some examples of using `$bulk-delete` with `_include` and `_revinclude`:
133
-
134
-
The following example using `_revinclude` will bulk delete all Patient resources that were last updated before December 18, 2021, and all resources that reference to those patients:
The following example using `_include` will bulk delete all DiagnosticReport resources that were last updated before 12/18/2021, as well as all ServiceRequest resources that are referenced by those DiagnosticReport resources (via DiagnosticReport.basedOn relationship), and all Encounter resources that are referenced by those ServiceRequest resources (via ServiceRequest.encounters relationship):
> The `_not-referenced` feature is available in Azure Health Data Services FHIR Server only, and isn't available in Azure API for FHIR.
145
-
146
-
As mentioned in the "Query parameters" section, the `$bulk-delete` operation uses FHIR service supported search parameters. This includes the new `_not-referenced` parameter, which allows you to search for and delete resources that are not referenced by any other resources.
147
-
148
-
The following example will bulk delete all Patient resources that are not referenced by any other resources:
The `$bulk-delete` operation supports configuring excluded resource types. When you perform a bulk delete operation, these resource types are excluded from deletion. This means that if you include this parameter and specify a comma separated list of resource types in your bulk delete request, those resource types will not be deleted, and the operation will complete successfully deleting everything else in the request, without deleting the specified excluded resource types.
157
-
158
-
The following example will delete all resources in your FHIR server, except for the `Patient` resource type:
The `$bulk-delete` operation supports removing references to resources that are being deleted. This means that if you delete a resource that is referenced by another resource, the reference will be removed from the referencing resource. The reference that has been removed with be replaced with the following value:
168
-
169
-
`"display": "Referenced resource deleted"`
170
-
171
-
>[!Note]
172
-
> This feature only works with hard delete, so you must also set the `_hardDelete` query parameter to `true`.
173
-
174
-
This is useful for maintaining data integrity and ensuring that resources that are no longer needed are properly cleaned up.
175
-
176
-
The following example will bulk hard delete all Patient resources, and remove references to those patients from other resources.
In the example above, if a Patient resource is referenced by a DiagnosticReport resource and an Observation resource, the reference to that Patient will be removed from the DiagnosticReport and Observation resources.
181
-
182
-
For an Observation's subject reference:
183
-
184
-
Before delete:
185
-
186
-
`"subject": {
187
-
"reference": "Patient/example-patient-id",
188
-
}`
189
-
190
-
After delete:
191
-
192
-
`"subject": {
193
-
"display": "Referenced resource deleted"
194
-
}`
167
+
> If you cancel and then restart a bulk delete job, the deletion process resumes from where it was stopped.
0 commit comments