Recipe: IBM FHIR Server – Using Hard Delete with the $erase Operation

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:

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.

fhirServer/operations/erase/enabledbooleanEnables the $erase operation
fhirServer/operations/erase/allowedRoleslistThe 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": [

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


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

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

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.