Operation $purge on Patient
This operation is used to delete all resources, as well as their history, related to a given Patient (as per patient compartment definition). Unlike standard FHIR delete interaction, it performs hard delete on data . This operation is officially introduced in FHIR R6, however in Kodjin it is available for all supported FHIR versions.
This operation is asynchronous and follows the async request pattern.
$purge operation uses hard delete and can't be rolled back.
This operation requires the following SMART on FHIR scopes: 
 - system/kodjin/$patient-purge 
 - user/kodjin/$patient-purge 
 - patient/kodjin/$patient-purge 
 You can read more about smart-on-FHIR scopes on SMART on FHIR Authorization page
Endpoints:
- GET,POST [fhir_base]/fhir/Patient/[id]/$purge
Purpose
Kickoff the patient purge request.
Request
Headers
| Name | Value | Required | Documentation | 
|---|---|---|---|
| Prefer | respond-async | true | Specifies that the response is asynchronous. Synchronous interaction isn't supported for this operation | 
Path parameters
| Name | Cardinality | Type | Documentation | 
|---|---|---|---|
| id | 1…1 | string | The id of the patient | 
Request parameters (in body)
None
Response
Headers
| Name | Required | Documentation | 
|---|---|---|
| Content-Location | true | The absolute URL of an endpoint for subsequent status requests (polling location) | 
Resonse parameters (in body)
None
Examples
Example - Patient $purge kickoff
- GET [fhir_base]/fhir/patient-purge/[job-id]
Purpose
Get the status of the purge operation.
Request
Headers
None
Path parameters
| Name | Cardinality | Type | Documentation | 
|---|---|---|---|
| job-id | 1…1 | string | The id of the purge job | 
Request parameters (in body)
None
Response
Headers
None
Resonse parameters (in body, as Parameters resource)
| Name | Cardinality | Type | Documentation | 
|---|---|---|---|
| patientId | 1…1 | String | The id of the patient for which the purge is performed | 
| updatedAt | 1…1 | DateTime | The updated at time for this job | 
| status | 1…1 | Code | The status of this job. One of: new, processing, completed, error | 
| totalResourcesCount | 0…1 | Integer | The total number of patient's resources to be purged | 
| purgedResourcesCount | 0…1 | Integer | The number of purged patient's resources as to the updatedAt time | 
Example - Patient $purge get the job status
Status: 200 OK      # The HTTP status
{                   # The body
    "resourceType": "Parameters",
    "parameter": [
                {
                    "name": "patientId",
                    "valueString": "c81f33f3-f275-4c61-89f1-e52736079a95"
                },
                {
                    "name": "updatedAt",
                    "valueDateTime": "2024-07-03T14:46:45.107453265Z"
                },
                {
                    "name": "status",
                    "valueCode": "completed"
                },
                {
                    "name": "totalResourcesCount",
                    "valueInteger": 500
                },
                {
                    "name": "purgedResourcesCount",
                    "valueInteger": 500
                }
        ]
}