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.

PropertyTypeDescription
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
Properties

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

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

{
"info": {
"_postman_id": "60b5dfcc-28f6-4288-bff4-73e006dc2ebf",
"name": "IBM FHIR Server - Operation: $erase - All Versions",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "0. Check the Metadata Endpoint",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/metadata",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"metadata"
]
}
},
"response": []
},
{
"name": "1. Confirm Authenticated Access using $healthcheck",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/$healthcheck",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"$healthcheck"
]
}
},
"response": []
},
{
"name": "2. Create Patient - version 1",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201 - '\" + RESOURCE_ID + \"'\", function () {",
" pm.response.to.have.status(201);",
"});",
"",
"var locationHeader = postman.getResponseHeader(\"Location\");",
"var location = locationHeader.split('/_history/')[0];",
"var RESOURCE_ID = location.substring(location.lastIndexOf(\"/\")+1);",
"pm.collectionVariables.set(\"RESOURCE_ID\", RESOURCE_ID);",
"console.log(RESOURCE_ID);",
"pm.collectionVariables.set(\"BODY\", pm.response.text());"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "default",
"type": "text"
},
{
"key": "Prefer",
"value": "return=representation",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"resourceType\": \"Patient\",\n \"managingOrganization\": {\n \"reference\": \"Organization/1\",\n \"display\": \"Demo Org\"\n },\n \"contact\": [\n {\n \"relationship\": [\n {\n \"coding\": [\n {\n \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0131\",\n \"code\": \"E\"\n }\n ]\n }\n ],\n \"organization\": {\n \"reference\": \"Organization/1\",\n \"display\": \"Demo Org\"\n }\n }\n ],\n \"text\": {\n \"status\": \"generated\",\n \"div\": \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">\\n \\n <table>\\n \\n <tbody>\\n \\n <tr>\\n \\n <td>Name</td>\\n \\n <td>Peter James \\n <b>Chalmers</b> (&quot;Jim&quot;)\\n </td>\\n \\n </tr>\\n \\n <tr>\\n \\n <td>Address</td>\\n \\n <td>534 Erewhon, Pleasantville, Vic, 3999</td>\\n \\n </tr>\\n \\n <tr>\\n \\n <td>Contacts</td>\\n \\n <td>Home: unknown. Work: (03) 5555 6473</td>\\n \\n </tr>\\n \\n <tr>\\n \\n <td>Id</td>\\n \\n <td>MRN: 12345 (Acme Healthcare)</td>\\n \\n </tr>\\n \\n </tbody>\\n \\n </table> \\n \\n </div>\"\n },\n \"identifier\": [\n {\n \"use\": \"usual\",\n \"type\": {\n \"coding\": [\n {\n \"system\": \"http://hl7.org/fhir/v2/0203\",\n \"code\": \"MR\"\n }\n ]\n },\n \"system\": \"urn:oid:1.2.36.146.595.217.0.1\",\n \"value\": \"12345\",\n \"period\": {\n \"start\": \"2001-05-06\"\n },\n \"assigner\": {\n \"display\": \"Acme Healthcare\"\n }\n }\n ],\n \"active\": true,\n \"name\": [\n {\n \"use\": \"official\",\n \"family\": \"Chalmers\",\n \"given\": [\n \"Peter\",\n \"James\"\n ]\n },\n {\n \"use\": \"usual\",\n \"given\": [\n \"Jim\"\n ]\n }\n ],\n \"telecom\": [\n {\n \"use\": \"home\"\n },\n {\n \"system\": \"phone\",\n \"value\": \"(03) 5555 6473\",\n \"use\": \"work\"\n }\n ],\n \"gender\": \"male\",\n \"birthDate\": \"1974-12-25\",\n \"_birthDate\": {\n \"extension\": [\n {\n \"url\": \"http://hl7.org/fhir/StructureDefinition/patient-birthTime\",\n \"valueDateTime\": \"1974-12-25T14:35:45-05:00\"\n }\n ]\n },\n \"deceasedBoolean\": false,\n \"address\": [\n {\n \"use\": \"home\",\n \"type\": \"both\",\n \"line\": [\n \"534 Erewhon St\"\n ],\n \"city\": \"PleasantVille\",\n \"district\": \"Rainbow\",\n \"state\": \"Vic\",\n \"postalCode\": \"3999\",\n \"period\": {\n \"start\": \"1974-12-25\"\n }\n }\n ],\n \"extension\": [ \n {\n \"url\": \"http://com.ibm.fhir.sample/favorite-mlb\",\n \"valueString\": \"RedSox\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient"
]
}
},
"response": []
},
{
"name": "2. Update Patient - version 2",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "default",
"type": "text"
},
{
"key": "Prefer",
"value": "return=representation",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{{BODY}}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{RESOURCE_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{RESOURCE_ID}}"
]
}
},
"response": []
},
{
"name": "3. Search for Patient",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var total = pm.response.json()[\"total\"];",
"",
"pm.test(\"Checking the Bundle Has GTE 1 Entry\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.total).to.gte(1);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient?_id={{RESOURCE_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient"
],
"query": [
{
"key": "_id",
"value": "{{RESOURCE_ID}}"
}
]
}
},
"response": []
},
{
"name": "4. Search for Patient - active",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var total = pm.response.json()[\"total\"];",
"",
"pm.test(\"Checking the Bundle Has GTE 1 Entry\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.total).to.gte(1);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient?_id={{RESOURCE_ID}}&active=true",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient"
],
"query": [
{
"key": "_id",
"value": "{{RESOURCE_ID}}"
},
{
"key": "active",
"value": "true"
}
]
}
},
"response": []
},
{
"name": "5. Get Patient",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Checking the IDs match\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.id).to.eq(pm.variables.get(\"RESOURCE_ID\"));",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{RESOURCE_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{RESOURCE_ID}}"
]
}
},
"response": []
},
{
"name": "6. Execute Operation - $erase Patient",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Checking total is 2\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.parameter[2].valueInteger).to.eql(2);",
" pm.collectionVariables.set(\"HISTORY_ID\", jsonData.parameter[1].valueString);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\n \"resourceType\": \"Parameters\",\n \"parameter\": [\n {\n \"name\": \"patient\",\n \"valueString\": \"patient-id-is-this-id\"\n },\n {\n \"name\": \"reason\",\n \"valueString\": \"My Reason for removing this resource\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{RESOURCE_ID}}/$erase",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{RESOURCE_ID}}",
"$erase"
]
}
},
"response": []
},
{
"name": "7. Search for Patient - Should not exist",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var total = pm.response.json()[\"total\"];",
"",
"pm.test(\"Checking the Bundle Has EQ 0\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.total).to.eql(0);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient?_id={{RESOURCE_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient"
],
"query": [
{
"key": "_id",
"value": "{{RESOURCE_ID}}"
}
]
}
},
"response": []
},
{
"name": "8. Search for Patient - Should not exist",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var total = pm.response.json()[\"total\"];",
"",
"pm.test(\"Checking the Bundle Has EQ 0\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.total).to.eql(0);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient?_id={{RESOURCE_ID}}&active=true",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient"
],
"query": [
{
"key": "_id",
"value": "{{RESOURCE_ID}}"
},
{
"key": "active",
"value": "true"
}
]
}
},
"response": []
},
{
"name": "9. Get Patient Copy - Should not exist",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 404\", function () {",
" pm.response.to.have.status(404);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\n \"resourceType\": \"Parameters\",\n \"parameter\": [\n {\n \"name\": \"patient\",\n \"valueString\": \"patient-id-is-this-id\"\n },\n {\n \"name\": \"reason\",\n \"valueString\": \"My Reason for removing this resource\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{RESOURCE_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{RESOURCE_ID}}"
]
}
},
"response": []
}
],
"auth": {
"type": "basic",
"basic": [
{
"key": "password",
"value": "change-password",
"type": "string"
},
{
"key": "username",
"value": "fhiruser",
"type": "string"
}
]
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "FHIR_TENANT_ID",
"value": "default"
},
{
"key": "SERVER_URL",
"value": "localhost:9443"
},
{
"key": "LOC",
"value": "",
"disabled": true
},
{
"key": "RESOURCE_ID",
"value": ""
},
{
"key": "BODY",
"value": ""
},
{
"key": "HISTORY_ID",
"value": ""
}
]
}
{
"info": {
"_postman_id": "362b999e-1816-4fb8-a835-589963e85aea",
"name": "IBM FHIR Server - Operation: $erase - Specific Version",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "0. Check the Metadata Endpoint",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/metadata",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"metadata"
]
}
},
"response": []
},
{
"name": "1. Confirm Authenticated Access using $healthcheck",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text"
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/$healthcheck",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"$healthcheck"
]
}
},
"response": []
},
{
"name": "2. Create Patient - version 1",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 201\", function () {",
" pm.response.to.have.status(201);",
"});",
"",
"var locationHeader = postman.getResponseHeader(\"Location\");",
"var location = locationHeader.split('/_history/')[0];",
"var RESOURCE_ID = location.substring(location.lastIndexOf(\"/\")+1);",
"pm.collectionVariables.set(\"RESOURCE_ID\", RESOURCE_ID);",
"",
"pm.collectionVariables.set(\"BODY\", pm.response.text());"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "default",
"type": "text"
},
{
"key": "Prefer",
"value": "return=representation",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{\n \"resourceType\": \"Patient\",\n \"managingOrganization\": {\n \"reference\": \"Organization/1\",\n \"display\": \"Demo Org\"\n },\n \"contact\": [\n {\n \"relationship\": [\n {\n \"coding\": [\n {\n \"system\": \"http://terminology.hl7.org/CodeSystem/v2-0131\",\n \"code\": \"E\"\n }\n ]\n }\n ],\n \"organization\": {\n \"reference\": \"Organization/1\",\n \"display\": \"Demo Org\"\n }\n }\n ],\n \"text\": {\n \"status\": \"generated\",\n \"div\": \"<div xmlns=\\\"http://www.w3.org/1999/xhtml\\\">\\n \\n <table>\\n \\n <tbody>\\n \\n <tr>\\n \\n <td>Name</td>\\n \\n <td>Peter James \\n <b>Chalmers</b> (&quot;Jim&quot;)\\n </td>\\n \\n </tr>\\n \\n <tr>\\n \\n <td>Address</td>\\n \\n <td>534 Erewhon, Pleasantville, Vic, 3999</td>\\n \\n </tr>\\n \\n <tr>\\n \\n <td>Contacts</td>\\n \\n <td>Home: unknown. Work: (03) 5555 6473</td>\\n \\n </tr>\\n \\n <tr>\\n \\n <td>Id</td>\\n \\n <td>MRN: 12345 (Acme Healthcare)</td>\\n \\n </tr>\\n \\n </tbody>\\n \\n </table> \\n \\n </div>\"\n },\n \"identifier\": [\n {\n \"use\": \"usual\",\n \"type\": {\n \"coding\": [\n {\n \"system\": \"http://hl7.org/fhir/v2/0203\",\n \"code\": \"MR\"\n }\n ]\n },\n \"system\": \"urn:oid:1.2.36.146.595.217.0.1\",\n \"value\": \"12345\",\n \"period\": {\n \"start\": \"2001-05-06\"\n },\n \"assigner\": {\n \"display\": \"Acme Healthcare\"\n }\n }\n ],\n \"active\": true,\n \"name\": [\n {\n \"use\": \"official\",\n \"family\": \"Chalmers\",\n \"given\": [\n \"Peter\",\n \"James\"\n ]\n },\n {\n \"use\": \"usual\",\n \"given\": [\n \"Jim\"\n ]\n }\n ],\n \"telecom\": [\n {\n \"use\": \"home\"\n },\n {\n \"system\": \"phone\",\n \"value\": \"(03) 5555 6473\",\n \"use\": \"work\"\n }\n ],\n \"gender\": \"male\",\n \"birthDate\": \"1974-12-25\",\n \"_birthDate\": {\n \"extension\": [\n {\n \"url\": \"http://hl7.org/fhir/StructureDefinition/patient-birthTime\",\n \"valueDateTime\": \"1974-12-25T14:35:45-05:00\"\n }\n ]\n },\n \"deceasedBoolean\": false,\n \"address\": [\n {\n \"use\": \"home\",\n \"type\": \"both\",\n \"line\": [\n \"534 Erewhon St\"\n ],\n \"city\": \"PleasantVille\",\n \"district\": \"Rainbow\",\n \"state\": \"Vic\",\n \"postalCode\": \"3999\",\n \"period\": {\n \"start\": \"1974-12-25\"\n }\n }\n ],\n \"extension\": [ \n {\n \"url\": \"http://com.ibm.fhir.sample/favorite-mlb\",\n \"valueString\": \"RedSox\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient"
]
}
},
"response": []
},
{
"name": "2. Update Patient - version 2",
"event": [
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "default",
"type": "text"
},
{
"key": "Prefer",
"value": "return=representation",
"type": "text"
}
],
"body": {
"mode": "raw",
"raw": "{{BODY}}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{RESOURCE_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{RESOURCE_ID}}"
]
}
},
"response": []
},
{
"name": "3. Search for Patient",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var total = pm.response.json()[\"total\"];",
"",
"pm.test(\"Checking the Bundle Has GTE 1 Entry\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.total).to.gte(1);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient?_id={{RESOURCE_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient"
],
"query": [
{
"key": "_id",
"value": "{{RESOURCE_ID}}"
}
]
}
},
"response": []
},
{
"name": "4. Search for Patient - active",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var total = pm.response.json()[\"total\"];",
"",
"pm.test(\"Checking the Bundle Has GTE 1 Entry\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.total).to.gte(1);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient?_id={{RESOURCE_ID}}&active=true",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient"
],
"query": [
{
"key": "_id",
"value": "{{RESOURCE_ID}}"
},
{
"key": "active",
"value": "true"
}
]
}
},
"response": []
},
{
"name": "5. Get Patient",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Checking the IDs match\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.id).to.eq(pm.variables.get(\"RESOURCE_ID\"));",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{RESOURCE_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{RESOURCE_ID}}"
]
}
},
"response": []
},
{
"name": "6. Execute Operation - $erase Patient - Latest Version",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 400\", function () {",
" pm.response.to.have.status(400);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\n \"resourceType\": \"Parameters\",\n \"parameter\": [\n {\n \"name\": \"patient\",\n \"valueString\": \"patient-id-is-this-id\"\n },\n {\n \"name\": \"reason\",\n \"valueString\": \"My Reason for removing this resource\"\n },\n {\n \"name\": \"version\",\n \"valueInteger\": 2\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{RESOURCE_ID}}/$erase",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{RESOURCE_ID}}",
"$erase"
]
}
},
"response": []
},
{
"name": "7. Execute Operation - $erase Patient - Too High",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 400\", function () {",
" pm.response.to.have.status(400);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\n \"resourceType\": \"Parameters\",\n \"parameter\": [\n {\n \"name\": \"patient\",\n \"valueString\": \"patient-id-is-this-id\"\n },\n {\n \"name\": \"reason\",\n \"valueString\": \"My Reason for removing this resource\"\n },\n {\n \"name\": \"version\",\n \"valueInteger\": 300\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{RESOURCE_ID}}/$erase",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{RESOURCE_ID}}",
"$erase"
]
}
},
"response": []
},
{
"name": "8. Execute Operation - $erase Patient - Version 1",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"pm.test(\"Checking total is 1\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.parameter[2].valueInteger).to.eql(1);",
" pm.collectionVariables.set(\"HISTORY_ID\", jsonData.parameter[1].valueString);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "POST",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\n \"resourceType\": \"Parameters\",\n \"parameter\": [\n {\n \"name\": \"patient\",\n \"valueString\": \"patient-id-is-this-id\"\n },\n {\n \"name\": \"reason\",\n \"valueString\": \"My Reason for removing this resource\"\n },\n {\n \"name\": \"version\",\n \"valueInteger\": 1\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{RESOURCE_ID}}/$erase",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{RESOURCE_ID}}",
"$erase"
]
}
},
"response": []
},
{
"name": "9. Search for Patient - Should exist",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"var total = pm.response.json()[\"total\"];",
"",
"pm.test(\"Checking the Bundle Has EQ 1\", function () {",
" var jsonData = pm.response.json();",
" pm.expect(jsonData.total).to.eql(1);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient?_id={{RESOURCE_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient"
],
"query": [
{
"key": "_id",
"value": "{{RESOURCE_ID}}"
}
]
}
},
"response": []
},
{
"name": "10. Search for Patient - Should exist",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient?_id={{RESOURCE_ID}}&active=true",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient"
],
"query": [
{
"key": "_id",
"value": "{{RESOURCE_ID}}"
},
{
"key": "active",
"value": "true"
}
]
}
},
"response": []
},
{
"name": "11. Get Patient - Should exist",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 200\", function () {",
" pm.response.to.have.status(200);",
"});"
],
"type": "text/javascript"
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{RESOURCE_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{RESOURCE_ID}}"
]
}
},
"response": []
},
{
"name": "12. Get Patient History - Should not exist",
"event": [
{
"listen": "prerequest",
"script": {
"exec": [
""
],
"type": "text/javascript"
}
},
{
"listen": "test",
"script": {
"exec": [
"pm.test(\"Status code is 404\", function () {",
" pm.response.to.have.status(404);",
"});"
],
"type": "text/javascript"
}
}
],
"protocolProfileBehavior": {
"disableBodyPruning": true
},
"request": {
"method": "GET",
"header": [
{
"key": "X-FHIR-TENANT-ID",
"value": "{{FHIR_TENANT_ID}}",
"type": "text",
"disabled": true
},
{
"key": "Content-Type",
"value": "application/fhir+json",
"type": "text"
},
{
"key": "X-FHIR-BULKDATA-PROVIDER",
"value": "{{BULKDATA_PROVIDER}}",
"type": "text",
"disabled": true
},
{
"key": "X-FHIR-BULKDATA-PROVIDER-OUTCOME",
"value": "{{BULKDATA_PROVIDER_OUTCOME}}",
"type": "text",
"disabled": true
}
],
"body": {
"mode": "raw",
"raw": "{\n \"resourceType\": \"Parameters\",\n \"parameter\": [\n {\n \"name\": \"patient\",\n \"valueString\": \"patient-id-is-this-id\"\n },\n {\n \"name\": \"reason\",\n \"valueString\": \"My Reason for removing this resource\"\n }\n ]\n}",
"options": {
"raw": {
"language": "json"
}
}
},
"url": {
"raw": "https://{{SERVER_URL}}/fhir-server/api/v4/Patient/{{HISTORY_ID}}",
"protocol": "https",
"host": [
"{{SERVER_URL}}"
],
"path": [
"fhir-server",
"api",
"v4",
"Patient",
"{{HISTORY_ID}}"
]
}
},
"response": []
}
],
"auth": {
"type": "basic",
"basic": [
{
"key": "password",
"value": "change-password",
"type": "string"
},
{
"key": "username",
"value": "fhiruser",
"type": "string"
}
]
},
"event": [
{
"listen": "prerequest",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
},
{
"listen": "test",
"script": {
"type": "text/javascript",
"exec": [
""
]
}
}
],
"variable": [
{
"key": "FHIR_TENANT_ID",
"value": "default"
},
{
"key": "SERVER_URL",
"value": "localhost:9443"
},
{
"key": "LOC",
"value": "",
"disabled": true
},
{
"key": "RESOURCE_ID",
"value": ""
},
{
"key": "BODY",
"value": ""
},
{
"key": "HISTORY_ID",
"value": ""
}
]
}