Skip to content

Commit 1fb3a1e

Browse files
authored
Merge pull request #307046 from v-rachitsh/v-rachitsh/releasenotesaug
Bulkdeletedocs
2 parents 0877b78 + 149d463 commit 1fb3a1e

3 files changed

Lines changed: 63 additions & 76 deletions

File tree

articles/healthcare-apis/fhir/fhir-bulk-delete.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,24 @@ ms.author: kesheth
1313

1414
[!INCLUDE [bulk-delete operation common content](../includes/fhir-bulk-delete-operation.md)]
1515

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.
22+
23+
24+
`DELETE [base] /Patient/$bulk-delete?_lastUpdated=lt{date}&_revinclude=*:* `
25+
26+
Next, you can delete all Practitioner resources that aren't referenced by any Patient resources.
27+
28+
`DELETE [base]/Practitioner/$bulk-delete?_not-referenced=Patient:*`
29+
1630
## Related content
1731

1832
[Supported FHIR features](fhir-features-supported.md)
1933

2034
[FHIR REST API capabilities for Azure Health Data Services FHIR service](rest-api-capabilities.md)
2135

22-
[!INCLUDE [FHIR trademark statement](../includes/healthcare-apis-fhir-trademark.md)]
36+
[!INCLUDE [FHIR trademark statement](../includes/healthcare-apis-fhir-trademark.md)]

articles/healthcare-apis/fhir/overview-of-search.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ GET {{FHIR_URL}}/Patient
2222

2323
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.
2424

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.
2626

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.
2828

2929
## Search parameters
3030

3131
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.
3232

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.
3434

3535

3636
| **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
137137
| `_contained` | No | No | |
138138
| `_containedType` | No | No | |
139139
| `_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. |
141141

142142
Note:
143143
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
252252
>[!div class="nextstepaction"]
253253
>[FHIR search examples](search-samples.md)
254254
255-
[!INCLUDE [FHIR trademark statement](../includes/healthcare-apis-fhir-trademark.md)]
255+
[!INCLUDE [FHIR trademark statement](../includes/healthcare-apis-fhir-trademark.md)]

articles/healthcare-apis/includes/fhir-bulk-delete-operation.md

Lines changed: 43 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,50 @@ Query parameters allow you to filter the raw resources you plan to delete. To su
5151
|------------------------|---|------------|
5252
|_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.|
5353
|_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+
5559
5660
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:
68+
69+
`DELETE [base]/Patient/$bulk-delete?_lastUpdated=lt2021-12-18&_revinclude=*:* `
70+
71+
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):
72+
73+
`DELETE [base]/DiagnosticReport/$bulk-delete?_lastUpdated=lt2021-12-12&_include=DiagnosticReport:based-on:ServiceRequest&_include:iterate=ServiceRequest:encounter`
74+
75+
#### `$bulk-delete` with `_not-referenced`
76+
>[!Note]
77+
> 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:
82+
83+
`DELETE [base]/Patient/$bulk-delete?_not-referenced=Encounter:subject`
84+
85+
The following example will bulk delete all Patient resources that are not referenced by Encounter resources in any field:
86+
87+
`DELETE [base]/Patient/$bulk-delete?_not-referenced=Encounter:*`
88+
89+
The following example will bulk delete all Patient resources that are not referenced by Encounter and DiagnosticReport resources:
90+
91+
`DELETE [base]/Patient/$bulk-delete?_not-referenced=Encounter:subject&_not-referenced=DiagnosticReport:subject`
92+
93+
The following example will bulk delete all Patient resources that are not referenced by any other resources:
94+
95+
`DELETE [base]/Patient/$bulk-delete?_not-referenced=*:* `
96+
97+
5798
5899
### `$bulk-delete-soft-deleted` operation
59100
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
123164
- 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.
124165
125166
> [!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:
135-
136-
`DELETE [base]/Patient/$bulk-delete?_lastUpdated=lt2021-12-18&_revinclude=*:*`
137-
138-
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):
139-
140-
`DELETE [base]/DiagnosticReport/$bulk-delete?_lastUpdated=lt2021-12-12&_include=DiagnosticReport:based-on:ServiceRequest&_include:iterate=ServiceRequest:encounter`
141-
142-
### `$bulk-delete` with `_not-referenced`
143-
>[!Note]
144-
> 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:
149-
`DELETE [base]/Patient/$bulk-delete?_not-referenced=*:*`
150-
151-
152-
153-
154-
### `$bulk-delete` with excluded resource types
155-
156-
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:
159-
`DELETE [base]/$bulk-delete?excludedResourceTypes=patient`
160-
161-
The following example will delete all resources in your FHIR server, except for the `Patient` and `Observation` resource types:
162-
`DELETE [base]/$bulk-delete?excludedResourceTypes=patient,observation`
163-
164-
### `$bulk-delete` and removing references
165-
166-
167-
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.
177-
178-
`DELETE [base]/Patient/$bulk-delete?_remove-references=true&_hardDelete=true`
179-
180-
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

Comments
 (0)