Skip to main content

Patient $ccda-export

The $ccda-export operation generates a Consolidated Clinical Document Architecture (C-CDA) document for a patient. C-CDA is the industry-standard XML format for exchanging clinical summaries between healthcare systems, making this operation essential for interoperability and regulatory compliance.

This operation produces a complete or time-windowed patient history in a format that can be consumed by EHRs, health information exchanges (HIEs), and patient portals-enabling seamless care coordination across organizational boundaries.

Internally, $ccda-export builds an IPS-style patient summary ($summary), then converts that FHIR Composition bundle to C-CDA XML via @medplum/ccda.

Use Cases

  • Health Information Exchange: Share patient records with other healthcare organizations via HIEs
  • Care Transitions: Generate discharge summaries or transfer documents when patients move between care settings
  • Patient Portal Downloads: Allow patients to download their medical records in a standard format
  • ONC Certification Compliance: Meet certification requirements for patient data export capabilities
  • Referral Documentation: Provide comprehensive clinical summaries when referring patients to specialists

Try it in the Medplum App

You can exercise this operation from the patient Export tab without calling the API directly. Open https://app.medplum.com/Patient/<PATIENT_ID>/export and use the export format controls to choose C-CDA (CCD) or C-CDA Referral, optionally set author and date filters, then download the resulting XML.

Invocation

GET [base]/Patient/[id]/$ccda-export
POST [base]/Patient/[id]/$ccda-export
curl 'https://api.medplum.com/fhir/R4/Patient/<PATIENT_ID>/$ccda-export' \
-H 'Authorization: Bearer <ACCESS_TOKEN>'

Input Parameters

$ccda-export accepts the same clinical filtering and authorship parameters as $summary, plus a C-CDA-specific type parameter that selects the document-level template.

ParameterCardinalityTypeDescription
type0..1codeC-CDA document type. Use referral to generate a Referral Note. When omitted (or any other value), Medplum generates a Continuity of Care Document (CCD) / Summarization of Episode Note.
author0..1ReferenceReference to Practitioner, PractitionerRole, or Organization to list as the composition author. Defaults to the current user.
authoredOn0..1instantThe date/time the summary was authored. Defaults to current time.
start0..1dateStart date for filtering resources by care date. If omitted, all records prior to end are in scope.
end0..1dateEnd date for filtering resources by care date. If omitted, all records after start are in scope.
_since0..1instantOnly include resources modified since this date
identifier0..1stringIdentifier for the composition (accepted; reserved for IPS alignment)
profile0..1canonicalProfile to validate against (accepted; reserved for IPS alignment)

Document types (type)

type valueDocumentLOINCNotes
(omitted)Continuity of Care Document (CCD)34133-9 Summarization of Episode NoteDefault export used by the Medplum App C-CDA option
referralReferral Note57133-1 Referral NoteUsed by the Medplum App C-CDA Referral option. Sets Referral Note document template IDs and uses Reason for Referral / ServiceRequest content when present

Example: Referral Note

curl -X POST 'https://api.medplum.com/fhir/R4/Patient/<PATIENT_ID>/$ccda-export' \
-H 'Authorization: Bearer <ACCESS_TOKEN>' \
-H 'Content-Type: application/fhir+json' \
-d '{
"resourceType": "Parameters",
"parameter": [
{ "name": "type", "valueCode": "referral" },
{ "name": "start", "valueDate": "2024-01-01" },
{ "name": "end", "valueDate": "2024-12-31" },
{
"name": "author",
"valueReference": { "reference": "Practitioner/example" }
}
]
}'

You can also pass parameters as query string values on GET, for example:

curl 'https://api.medplum.com/fhir/R4/Patient/<PATIENT_ID>/$ccda-export?type=referral' \
-H 'Authorization: Bearer <ACCESS_TOKEN>'

Output

Returns C-CDA XML (application/cda+xml) as a raw Binary response.

Behavior

  1. Data collection: Uses $summary (which gathers patient data via $everything) to build an IPS Composition bundle
  2. Document template: Applies CCD or Referral Note document-level template IDs and LOINC document type codes based on type
  3. XML serialization: Converts the FHIR bundle to C-CDA with @medplum/ccda, then returns the XML