# Exporting Bulk Fhir

Kick off and harvest a FHIR Bulk Data $export (system-, group-, or patient-level) and...

- Repository: https://github.com/maziyarpanahi/openmed (5755 stars)
- Category: Writing
- License: Apache-2.0
- Last updated: 2026-10-31
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add maziyarpanahi/openmed --skill exporting-bulk-fhir -g -a claude-code -y`
Codex: `npx skills add maziyarpanahi/openmed --skill exporting-bulk-fhir -g -a codex -y`
Cursor: `npx skills add maziyarpanahi/openmed --skill exporting-bulk-fhir -g -a cursor -y`
Gemini CLI: `npx skills add maziyarpanahi/openmed --skill exporting-bulk-fhir -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add maziyarpanahi/openmed`

## Description

Kick off and harvest a FHIR Bulk Data $export (system-, group-, or patient-level) and stream the resulting NDJSON into a batch OpenMed de-identification + NER pipeline at cohort scale. Covers the async kickoff (Prefer respond-async) -> poll Content-Location -> download NDJSON flow, the Bulk Data Access IG, _type/_since filters, and feeding DocumentReference/DiagnosticReport notes into openmed.deidentify in batch. Use when the user needs population-scale note extraction from an EHR or data warehouse to feed OpenMed, mentions bulk export, $export, NDJSON, Flat FHIR, or cohort de-identification. Pairs before the OpenMed de-id/NER pipeline.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Exporting Bulk FHIR

When you need *cohort-scale* clinical text, not one patient in a UI, you use
the FHIR **Bulk Data Access** (`$export`) operation: an async job that emits
**NDJSON** files of resources you then stream into OpenMed for batch
de-identification and NER. This skill sits **before** the OpenMed pipeline: it is
how the notes arrive.

## When to use

Reach for it when the source is an EHR or FHIR data warehouse and the volume is
a population/group (thousands of patients), the workload is headless (no
clinician UI), and the goal is to batch-feed `openmed.deidentify` /
`openmed.analyze_text`. Triggers: "bulk export", "$export", "NDJSON", "Flat
FHIR", "cohort de-identification", "export all notes". For a single in-chart
patient with a UI, use `scaffolding-smart-on-fhir` instead.

## Three export levels

- **System**, `GET [base]/$export`, everything the client is authorized for.
- **Group**, `GET [base]/Group/[id]/$export`, a defined cohort (most common).
- **Patient**, `GET [base]/Patient/$export`, all patients in scope.

Bulk export uses **SMART Backend Services** auth (a `system/*.read`-scoped
client-credentials token via a signed JWT assertion), not an interactive launch.

## Quick start: kickoff → poll → download

```bash
# 1) Kickoff (async). Ask for clinical-note-bearing resource types.
curl -s -X GET \
  'https://ehr.example/fhir/Group/cohort-42/$export?_type=DocumentReference,DiagnosticReport&_since=2024-01-01T00:00:00Z' \
  -H 'Authorization: Bearer <backend-services-token>' \
  -H 'Accept: application/fhir+json' \
  -H 'Prefer: respond-async' -D -
# -> 202 Accepted
#    Content-Location: https://ehr.example/fhir/bulkstatus/JOB123

The rest: https://github.com/maziyarpanahi/openmed/blob/HEAD/skills/exporting-bulk-fhir/SKILL.md
