Secondary Use FHIR Server Implementation Guide
0.1.0 - ci-build

Secondary Use FHIR Server Implementation Guide - Local Development build (v0.1.0) built by the FHIR (HL7® FHIR® Standard) Build Tools. See the Directory of published versions

Getting Started

Getting Started

Start the mock source server, adapter, and optional UI as described in the repository usage guide. The default bases are:

  • mock: http://127.0.0.1:8090/fhir
  • adapter: http://127.0.0.1:8080/fhir

1. Explore Without Creating a Group

curl -fsS \
  'http://127.0.0.1:8080/fhir/Patient?_has:Condition:subject:code=34000006&gender=female&_summary=count'

The searchset Bundle total is the patient count and no entries are returned. Count selected resource types with the same Patient criteria as standard reference chains:

curl -fsS \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  --data-urlencode 'subject:Patient._has:Condition:subject:code=34000006' \
  --data-urlencode 'subject:Patient.gender=female' \
  --data '_summary=count' \
  'http://127.0.0.1:8080/fhir/Condition/_search'

This response also contains only Bundle.total. Patient ids and clinical resource instances are not returned during exploration.

2. Create a Bulk Cohort Group

Create cohort.json:

{
  "resourceType": "Group",
  "meta": { "profile": ["http://hl7.org/fhir/uv/bulkdata/StructureDefinition/bulk-cohort-group"] },
  "modifierExtension": [
    { "url": "http://hl7.org/fhir/uv/bulkdata/StructureDefinition/member-filter", "valueExpression": { "language": "application/x-fhir-query", "expression": "Condition?code=34000006" } },
    { "url": "http://hl7.org/fhir/uv/bulkdata/StructureDefinition/member-filter", "valueExpression": { "language": "application/x-fhir-query", "expression": "Patient?gender=female&birthdate=ge1980-01-01" } }
  ],
  "type": "person",
  "actual": false,
  "name": "IBD cohort"
}

Submit it:

curl -fsS \
  -H 'Accept: application/fhir+json' \
  -H 'Content-Type: application/fhir+json' \
  -H 'Prefer: respond-async, return=representation' \
  --data-binary @cohort.json \
  'http://127.0.0.1:8080/fhir/Group'

The response is 202 Accepted with Content-Location. Poll it to receive a batch-response Bundle containing the actual-member Group. Save the Group id; quantity contains the patient count.

3. Start Group Export

curl -i \
  -H 'Accept: application/fhir+json' \
  -H 'Prefer: respond-async' \
  'http://127.0.0.1:8080/fhir/Group/{group-id}/$export?_type=Patient,Condition,Observation'

The response is 202 Accepted and includes Content-Location.

4. Poll and Download

curl -fsS '{content-location}'
curl -fsS '{output-url}'

The first URL returns the Bulk Data manifest; each output[].url returns FHIR NDJSON.

5. Request Minimized Output

Pseudonymization is automatic. For the smaller analytical representation, add _elements:

curl -i \
  -H 'Accept: application/fhir+json' \
  -H 'Prefer: respond-async' \
  'http://127.0.0.1:8080/fhir/Group/{group-id}/$export?_type=Patient,Condition&_elements=Patient.gender,Patient.birthDate,Condition.subject,Condition.code'

Partial resources carry the standard SUBSETTED tag.