Deleting data
The FHIR delete operation performs a "logical" delete. This means that data is not physically removed from the database.
For example, Patient resource with ID 123 is created (via an HTTP POST /Patient) and subsequently deleted (via an HTTP DELETE Patient/123). This causes a second version of the Patient/123 resource to be created with version Patient/123/_history/2 that is marked as deleted.
This patient no longer appears in search results and attempts to read the resource (using an HTTP GET Patient/123) fails with an "HTTP 410 Gone" response.
The original content of the resource is not destroyed, however. It can still be found using two FHIR operations:
- Using a FHIR version-specific read: GET Patient/123/_history/1
- Using a FHIR instance-history: GET Patient/123/_history
Note that HTTP 410 Gone responses include a Location header containing the fully qualified resource ID as well as the version ID.
Example: DELETE 410 Gone response with a Location Header
Figure 11-1 Status Code: 410 Gone Response
![Status Code: 410 Gone Status Code: 410 Gone](img/statuscode-410gone.png)
Example: DELETE 410 Gone response with latest non-deleted version
In this example, we can see that the deleted version of the resource is version 2. This means that the last non-deleted version is version 1, and this could be accessed using a version-specific read to the following URL:
- Deletes and referential integrity
The FHIR delete operation performs a "logical" delete. This means that data is not physically removed from the database. - Transactional delete
Use the FHIR Transaction operation to delete multiple resources at the same time. - Referential integrity
By default, Oracle HDR-FHIR server blocks the deletion of a resource if any other resources have indexed references to the resource being deleted. - Cascading deletes
By enabling the cascading delete, a user can perform the delete on parent resource, then all the corresponding child resources will be deleted as well. - The $expunge operation
In some cases, you may need to completely delete data from the HDR-FHIR repository after performing the DELTE operation. In those cases, the $expunge operation will be used and is a powerful operation that can physically delete old versions of resources, deleted resources, or even all data in the database.
Parent topic: FHIR Operations