Skip to content

Commit ee6ccab

Browse files
committed
adding documentation for bulk delete with excluded resource types and remove reference
1 parent 94cffe8 commit ee6ccab

File tree

1 file changed

+51
-2
lines changed

1 file changed

+51
-2
lines changed

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

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,54 @@ Note: This feature is available in Azure Health Data Services FHIR Server only,
144144
145145
As mentioned in the "Query parameters" section above, 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.
146146
147-
The following example will bulk delete all Patient resources that are not referenced by any other resources:
148-
`DELETE [base]/Patient/$bulk-delete?_not-referenced=*:*`
147+
The following example will bulk delete all Patient resources that are not referenced by any other resources:
148+
`DELETE [base]/Patient/$bulk-delete?_not-referenced=*:*`
149+
150+
151+
152+
153+
### `$bulk-delete` with excluded resource types
154+
<!--- check with Paola: confirm gen 2 only or both Note: This feature is available in Azure Health Data Services FHIR Server only, and is not available in Azure API for FHIR. --->
155+
156+
157+
158+
159+
<!--- Check with Paola: Can it be multiple, or just one resource type? --->
160+
161+
162+
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 resource type 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 type.
163+
164+
The following example will delete all resources in your FHIR server, except for the `Patient` resource type:
165+
`DELETE [base]/$bulk-delete?excludedResourceTypes=patient`
166+
167+
168+
### `$bulk-delete` and removing references
169+
170+
171+
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:
172+
173+
`"display": "Referenced resource deleted"`
174+
175+
Note: This feature only works with hard delete, so you must also set the `_hardDelete` query parameter to `true`.
176+
177+
This is useful for maintaining data integrity and ensuring that resources that are no longer needed are properly cleaned up.
178+
179+
The following example will bulk hard delete all Patient resources, and remove references to those patients from other resources.
180+
181+
`DELETE [base]/Patient/$bulk-delete?_remove-references=true&_hardDelete=true`
182+
183+
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.
184+
185+
For an Observation's subject reference:
186+
187+
Before delete:
188+
189+
`"subject": {
190+
"reference": "Patient/example-patient-id",
191+
}`
192+
193+
After delete:
194+
195+
`"subject": {
196+
"display": "Referenced resource deleted"
197+
}`

0 commit comments

Comments
 (0)