Scenario: Manage the ServiceRequest Lifecycle

Create, search, read, version-read, update, and delete FHIR R4 ServiceRequest resources, with separately authorized permanent-deletion operations.

Authorization

Use an OAuth 2.0 access token issued by OCI Identity Domains with the DDFS resource scopes required for each ServiceRequest interaction. The permanent-deletion operations require their separately documented authorization. Configure the client and obtain tokens by following Create an Integrated Application and DDFS Authentication Reference.

Advertised interactions

The R4 CapabilityStatement advertises create, read, version-read, update, delete, and type-search interactions for ServiceRequest:


POST   /api/fhir/r4/ServiceRequest
GET    /api/fhir/r4/ServiceRequest/{rid}
GET    /api/fhir/r4/ServiceRequest/{rid}/_history/{vid}
PUT    /api/fhir/r4/ServiceRequest/{rid}
DELETE /api/fhir/r4/ServiceRequest/{rid}
GET    /api/fhir/r4/ServiceRequest
      

Create and update a ServiceRequest

The following abbreviated base-FHIR R4 payload is an illustration. Supply the content required by the profiles and ordering workflow selected for your application.

(application/fhir+json)
POST {base}/api/fhir/r4/ServiceRequest
Content-Type: application/fhir+json

{
  "resourceType": "ServiceRequest",
  "status": "active",
  "intent": "order",
  "subject": {
    "reference": "Patient/{patient_id}"
  },
  "code": {
    "text": "Complete blood count"
  }
}
      

For the update request and payload requirements, see PUT /api/fhir/r4/ServiceRequest/{rid}.

Search ServiceRequest

The R4 ServiceRequest search surface advertises authored, category, code, patient, and status, in addition to _id, _lastUpdated, _profile, _tag, _count, and _total.

Search by one clinical parameter:


GET {base}/api/fhir/r4/ServiceRequest?status=active
GET {base}/api/fhir/r4/ServiceRequest?category={system}|{code}
GET {base}/api/fhir/r4/ServiceRequest?code={system}|{code}
      

Search by a direct patient reference or with the :identifier modifier:


GET {base}/api/fhir/r4/ServiceRequest?patient=Patient/{patient_id}
GET {base}/api/fhir/r4/ServiceRequest?patient:identifier={system}|{value}
      

Search date ranges

The authored and _lastUpdated parameters accept their advertised date comparators. A range can use a maximum of two repeated occurrences of the same date parameter. Do not combine date values with a comma.


GET {base}/api/fhir/r4/ServiceRequest?authored=ge2026-01-01&authored=le2026-01-31
GET {base}/api/fhir/r4/ServiceRequest?_lastUpdated=ge2026-01-01T00:00:00Z&_lastUpdated=le2026-01-31T23:59:59Z
      

Use the advertised _count parameter when requesting a page size.

Purge previously deleted resources by type

The advertised $purgeDeleted operation is type-level:


POST {base}/api/fhir/r4/ServiceRequest/$purgeDeleted
Content-Type: application/fhir+json
      

Its FHIR Parameters input requires one before value of type dateTime. It optionally accepts one integer limit from 1 through 50.

(application/fhir+json)
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "before",
      "valueDateTime": "2026-01-01T00:00:00Z"
    },
    {
      "name": "limit",
      "valueInteger": 25
    }
  ]
}
      

The operation definition requires one OperationOutcome output.

Hard-delete one deleted resource

The advertised $hardDelete operation is instance-level and targets one deleted ServiceRequest:


POST {base}/api/fhir/r4/ServiceRequest/{rid}/$hardDelete
      

The operation definition requires one OperationOutcome output.

Warning

Permanent deletion cannot be undone. Follow Data deletion and purge operations before invoking either permanent-deletion operation.

References