Skip to main content

Type-Level Operations

Execute FHIR operations on all resources of a specific type.
resource_type
string
required
The FHIR resource type (e.g., Patient, Observation, Encounter)
operation
string
required
The operation name (e.g., $validate, $everything, $export)

Endpoint

GET /fhir/:resource_type/$:operation
POST /fhir/:resource_type/$:operation
Use GET for operations that only read data, or POST for operations that require input parameters.

Example Request

curl -X POST \
     -H "Content-Type: application/fhir+json" \
     -d '{"resourceType":"Parameters"}' \
     https://your-server.com/fhir/Patient/$validate

Common Type Operations

$validate

Validate a resource of this type:
POST /fhir/Patient/$validate
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "resource",
      "resource": {
        "resourceType": "Patient",
        "name": [{"family": "Doe"}]
      }
    }
  ]
}

$everything

Get all resources of this type and related resources:
GET /fhir/Patient/$everything
Or with parameters:
POST /fhir/Patient/$everything
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "_since",
      "valueDateTime": "2024-01-01T00:00:00Z"
    }
  ]
}

$export

Export all resources of this type:
POST /fhir/Patient/$export
Content-Type: application/fhir+json

{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "_outputFormat",
      "valueString": "application/fhir+ndjson"
    }
  ]
}

Request Format

Operations use a Parameters resource for input:
{
  "resourceType": "Parameters",
  "parameter": [
    {
      "name": "parameter-name",
      "valueString": "parameter-value"
    },
    {
      "name": "resource",
      "resource": {
        "resourceType": "Patient",
        ...
      }
    }
  ]
}

Response

Success (200 OK)

Returns operation results, typically as a Parameters resource or a Bundle:
{
  "resourceType": "Bundle",
  "type": "searchset",
  "entry": [
    {
      "resource": {
        "resourceType": "Patient",
        ...
      }
    }
  ]
}

Error (400 Bad Request)

Returns an OperationOutcome if the operation fails:
{
  "resourceType": "OperationOutcome",
  "issue": [
    {
      "severity": "error",
      "code": "invalid",
      "details": {
        "text": "Operation $unknown not supported for Patient"
      }
    }
  ]
}

Available Operations

The available type-level operations depend on server configuration and resource type. Check the capability statement (/fhir/metadata) to see which operations are supported for each resource type:
{
  "rest": [
    {
      "resource": [
        {
          "type": "Patient",
          "operation": [
            {
              "name": "$validate",
              "definition": "http://hl7.org/fhir/OperationDefinition/Resource-validate"
            },
            {
              "name": "$everything",
              "definition": "http://hl7.org/fhir/OperationDefinition/Patient-everything"
            }
          ]
        }
      ]
    }
  ]
}

Notes

  • Type operations apply to all resources of the specified type
  • Available operations vary by resource type
  • Operations may require specific permissions
  • Use POST when operations require input parameters
  • Operation names are case-sensitive and start with $