The IBM FHIR Server supports hard delete using the custom FHIR Operation Framework. The operation is called $erase; you can always read the design document.
The operation supports:
- Hard Delete All Versions of a Resource – removes all versions including the latest, and no longer available using Search
- Version Specific Hard Delete – the latest version may not be hard deleted, you must execute a soft DELETE, then a hard delete. Otherwise, all versions may be deleted.
By default, the $erase operation is not enabled, and must be set to true, and the roles allowed to execute the operation, can be tweaked to FHIROperationAdmin or FHIRUsers.
Property | Type | Description |
fhirServer/operations/erase/enabled | boolean | Enables the $erase operation |
fhirServer/operations/erase/allowedRoles | list | The list of allowed roles, allowed entries are: FHIRUsers every authenticated user, FHIROperationAdmin which is authenticated FHIRAdmin users |
The fhir-server-config.json should be amended with a snippet like the following:
"operations": {
"erase": {
"enabled": true,
"allowedRoles": [
"FHIROperationAdmin",
"FHIRUsers"
]
}
}
As the $erase operation uses stored procedures for Db2 and functions for Postgres, the data schema must be updated to the 4.8.3 level. It’s also worth noting that Derby is also supported as it uses the same DAO as the Db2 and Postgres to run.
A tip, you should search for the references to the Patient’s ResourceId, and delete the referenced resources in a Transaction Bundle. Net – Search, Assemble Bundle, Execute Batch.
Let me show you how to run with it, and operate the $erase operation with a container (Docker: ibmcom/ibm-fhir-server).
Recipe
- Download the fhir-server-config.json
2. Start the Docker container, and capture the container id. It’s going to take a few moments to start up as it lays down the test database.
docker run -d -p 9443:9443 -e BOOTSTRAP_DB=true -v $(pwd)/fhir-server-config.json:/config/config/default/fhir-server-config.json ibmcom/ibm-fhir-server
cde61943964464b528eb77d132fd2a4952e0eaf43588da1c9b6bb2fa584f0608
3. Check the logs until you see:
docker logs cde61943964464b528eb77d132fd2a4952e0eaf43588da1c9b6bb2fa584f0608
...
[6/16/21, 15:31:34:533 UTC] 0000002a FeatureManage A CWWKF0011I: The defaultServer server is ready to run a smarter planet. The defaultServer server started in 17.665 seconds.
4. Download the Postman Collection for Version Specific Erase and All Versions Erase.
5. Import the Postman Collections and Run

You’ve seen how to use the $erase operation, and a bit more details on configuring and using it.
Postman Collections