Secondary Use FHIR Server Implementation Guide
0.1.0 - ci-build

Publish Box goes here

Bulk Export

Bulk Export

Export Shape

The runtime implements a compact Bulk Data-style flow:

  1. GET /fhir/$export
  2. 202 Accepted
  3. Content-Location: {base}/bulk-status/{jobId}
  4. GET /fhir/bulk-status/{jobId}
  5. download output[].url NDJSON files
  6. optionally DELETE /fhir/bulk-status/{jobId} after the caller no longer needs the job

The status response is not a FHIR resource. It follows the Bulk Data status body shape:

{
  "transactionTime": "2026-06-10T12:00:00Z",
  "request": "http://127.0.0.1:8080/fhir/$export",
  "requiresAccessToken": false,
  "output": [
    {
      "type": "Patient",
      "count": 53,
      "url": "http://127.0.0.1:8080/fhir/bulk-files/abc/Patient.ndjson",
      "storageLocation": "bulk://abc/Patient.ndjson"
    }
  ],
  "error": []
}

Each NDJSON file contains one FHIR JSON resource per line.

The export accepts _outputFormat=application/fhir+ndjson or _outputFormat=ndjson. Unsupported values return a FHIR OperationOutcome with HTTP 400.

Mock Server Export

The mock server exports the generated source dataset as-is:

curl -i http://127.0.0.1:8090/fhir/'$export'

This is useful when the caller wants to inspect the full synthetic source record set, including direct patient identifiers and source references.

Adapter Export

The adapter export resolves a cohort, fetches resources from the mock server, applies privacy transforms, and then writes Bulk output:

curl -i 'http://127.0.0.1:8080/fhir/$export?mode=minimized&condition-code=34000006'

Supported adapter parameters:

Parameter Meaning
mode pseudonymized or minimized, default pseudonymized
_type comma-separated output resource types
_outputFormat optional application/fhir+ndjson or ndjson
notification-url optional callback URL that receives a completion notification
condition-code condition code cohort filter
medication-code medication cohort filter over MedicationStatement and MedicationRequest
procedure-code procedure code cohort filter
observation-code observation code cohort filter
gender Patient.gender filter
birthdate, birthdate-ge, birthdate-le Patient.birthDate exact/range filters
date, date-ge, date-le clinical date exact/range filters

The adapter also accepts camelCase aliases for code filters: conditionCode, medicationCode, procedureCode, and observationCode.

Completion Notification

When notification-url is present, the adapter posts a compact JSON notification after the export is ready:

{
  "jobId": "abc",
  "status": "completed",
  "statusUrl": "http://127.0.0.1:8080/fhir/bulk-status/abc",
  "output": [
    {
      "type": "Patient",
      "count": 53,
      "downloadUrl": "http://127.0.0.1:8080/fhir/bulk-files/abc/Patient.ndjson",
      "storageLocation": "bulk://abc/Patient.ndjson"
    }
  ]
}

This is the prototype contract for "data is available at location X". Failed callback delivery is currently best-effort and does not fail the export.

Default Output Types

When _type is omitted, the adapter exports:

  • Patient
  • Condition
  • AllergyIntolerance
  • MedicationRequest
  • MedicationStatement
  • Observation
  • Procedure
  • Provenance

Encounter is supported by the privacy transformer and date search helper, but it is not part of the current default generated fixture/export set.

Count Preview

_summary=count on the adapter export returns a FHIR Parameters resource instead of starting a job:

curl 'http://127.0.0.1:8080/fhir/$export?_summary=count&condition-code=34000006&_type=Patient,Condition'

The response contains:

  • cohort-patients: number of patients after cohort resolution
  • repeated resource-count parts with type and count

This count response is a local prototype extension. It is not a standard Bulk Data response.