Purge Deleted FHIR Resources

Use the DDFS $purgeDeleted operation to permanently remove deleted FHIR resources for a supported resource type.

The $purgeDeleted operation permanently purges deleted resources of the requested type that were deleted before a specified cutoff time. The operation returns a FHIR OperationOutcome describing the purge result.

Use $purgeDeleted only for resources that are already in a deleted state. To delete a current resource instance, use the standard FHIR delete interaction first.

Endpoint

POST /api/fhir/{r4|r6-ballot4}/{Resource}/$purgeDeleted
Accept: application/fhir+json
Content-Type: application/fhir+json
Authorization: Bearer <access-token>

Parameters

Parameter In Required Type Description
before body true dateTime FHIR Parameters.parameter.valueDateTime cutoff. Deleted resources before this instant are eligible for purge.
limit body false integer FHIR Parameters.parameter.valueInteger. The accepted range is 1 through 50.

Authorization

The operation requires both a matching resource delete grant and the DDFS hard-delete scope.

  • Resource delete grant: system/{Resource}.d
  • Hard-delete scope: https://docs.oracle.com/iaas/device-data-fhir/scopes/hard-delete

Client application grants and token requests use the fixed ddfs-prefixed form for both FHIR resource scopes and the custom hard-delete scope. For example, a Patient purge client requests ddfssystem/Patient.d and ddfshttps://docs.oracle.com/iaas/device-data-fhir/scopes/hard-delete. The issued token contains the corresponding canonical scopes, system/Patient.d and https://docs.oracle.com/iaas/device-data-fhir/scopes/hard-delete. For scope syntax, see Authentication and Scopes. For OAuth client setup, see Configure the Client Application.

Examples

Purge up to 25 deleted resources that were deleted before the cutoff:

POST /api/fhir/r4/Patient/$purgeDeleted
Accept: application/fhir+json
Content-Type: application/fhir+json
Authorization: Bearer <access-token>

{
  "resourceType": "Parameters",
  "parameter": [
    { "name": "before", "valueDateTime": "2026-01-01T00:00:00Z" },
    { "name": "limit", "valueInteger": 25 }
  ]
}

Use the same FHIR Parameters body with an R6 resource endpoint, for example POST /api/fhir/r6-ballot4/Observation/$purgeDeleted.

Behavior

  • The operation applies to one resource type at a time.
  • The operation permanently removes deleted resources that match the cutoff and authorization requirements.
  • When limit is supplied, DDFS limits the number of resources purged by that request.
  • A successful request returns HTTP 200 with an OperationOutcome.
  • If the request is invalid or unauthorized, DDFS returns an error response, typically with an OperationOutcome when a FHIR-formatted error body is returned.

Supported Resources

DDFS supports $purgeDeleted for the following FHIR resource types.

FHIR Version Resources
R4 Condition, Device, DiagnosticReport, Encounter, Endpoint, Group, Location, Observation, Organization, Patient, Practitioner, PractitionerRole, Provenance, RelatedPerson, ServiceRequest, and Specimen.
R6 Device, DeviceAssociation, Encounter, Location, Observation, Patient, Practitioner, PractitionerRole, Provenance, Subscription, and SubscriptionTopic.

FHIR Contract Details

The $purgeDeleted and $hardDelete operations permanently remove data. Confirm the applicable OperationDefinition, resource support, and authorization requirements before using either operation.

Operation definitions and scope

Version Operation Definition Invocation scope Resources Affects state Status Description
R4 $hardDelete ddfs-r4-hardDelete.json instance-level Condition, Device, DiagnosticReport, Encounter, Endpoint, Group, Location, Observation, Organization, Patient, Practitioner, PractitionerRole, Provenance, RelatedPerson, ServiceRequest, Specimen Yes active Permanently removes one deleted resource instance. This instance-level operation returns an OperationOutcome and requires both matching system/{Resource}.d delete authority and the exact custom scope https://docs.oracle.com/iaas/device-data-fhir/scopes/hard-delete.
R4 $purgeDeleted ddfs-r4-purgeDeleted.json type-level Condition, Device, DiagnosticReport, Encounter, Endpoint, Group, Location, Observation, Organization, Patient, Practitioner, PractitionerRole, Provenance, RelatedPerson, ServiceRequest, Specimen Yes active Permanently purges deleted resources of the requested type that were deleted before the required before dateTime, optionally limited to 1 through 50 resources. Inputs are supplied in the POST FHIR Parameters body. This type-level operation returns an OperationOutcome and requires both matching system/{Resource}.d delete authority and the exact custom scope https://docs.oracle.com/iaas/device-data-fhir/scopes/hard-delete.
R6 $hardDelete ddfs-r6-hardDelete.json instance-level Device, DeviceAssociation, Encounter, Location, Observation, Patient, Practitioner, PractitionerRole, Provenance, Subscription, SubscriptionTopic Yes active Permanently removes one deleted resource instance. This instance-level operation returns an OperationOutcome and requires both matching system/{Resource}.d delete authority and the exact custom scope https://docs.oracle.com/iaas/device-data-fhir/scopes/hard-delete.
R6 $purgeDeleted ddfs-r6-purgeDeleted.json type-level Device, DeviceAssociation, Encounter, Location, Observation, Patient, Practitioner, PractitionerRole, Provenance, Subscription, SubscriptionTopic Yes active Permanently purges deleted resources of the requested type that were deleted before the required before dateTime, optionally limited to 1 through 50 resources. Inputs are supplied in the POST FHIR Parameters body. This type-level operation returns an OperationOutcome and requires both matching system/{Resource}.d delete authority and the exact custom scope https://docs.oracle.com/iaas/device-data-fhir/scopes/hard-delete.

Parameters

Version Operation Parameter Use Min Max Type Description
R4 $hardDelete return out 1 1 OperationOutcome OperationOutcome describing the hard-delete result.
R4 $purgeDeleted before in 1 1 dateTime Required FHIR dateTime cutoff supplied as Parameters.parameter.valueDateTime; deleted resources before this instant are purged.
R4 $purgeDeleted limit in 0 1 integer Optional maximum supplied as Parameters.parameter.valueInteger. The route accepts values from 1 through 50.
R4 $purgeDeleted return out 1 1 OperationOutcome OperationOutcome describing the purge result.
R6 $hardDelete return out 1 1 OperationOutcome OperationOutcome describing the hard-delete result.
R6 $purgeDeleted before in 1 1 dateTime Required FHIR dateTime cutoff supplied as Parameters.parameter.valueDateTime; deleted resources before this instant are purged.
R6 $purgeDeleted limit in 0 1 integer Optional maximum supplied as Parameters.parameter.valueInteger. The route accepts values from 1 through 50.
R6 $purgeDeleted return out 1 1 OperationOutcome OperationOutcome describing the purge result.