# C-CDA documents

Canonical URL: https://docs.chartvoyant.com/c-cda/
Endpoint: `GET https://chartvoyant.com/api/v1/patients/{id}/ccda`

Generate a patient's current Continuity of Care Document as XML, on demand, through SMART on FHIR or with an API key. Export is in beta: the document is human-readable today, and coded entries are still to come. Importing C-CDA files is part of moving a practice onto ChartVoyant and has no public API.

## At a glance

| Status | Export: beta. The endpoints answer in production, but the document is not yet fully conformant. Import: onboarding migration only, with no public API. |
| --- | --- |
| Document | A Continuity of Care Document generated from the current chart at request time. Carries the C-CDA R2.1 CCD document template (`2.16.840.1.113883.10.20.22.1.2`, `2015-08-01`) and document code LOINC `34133-9`. |
| Contents | Patient demographics, then Problems (LOINC `11450-4`), Medications (`10160-0`), Allergies (`48765-2`), and Results (`30954-2`), each as a human-readable narrative table. |
| Not yet included | Coded section entries and section-level templates. Systems that import only structured C-CDA entries will not find data in it yet. Validate it against your own requirements before relying on it, and use the [FHIR R4 API](https://docs.chartvoyant.com/fhir-r4/) for structured data. |
| Format | `application/xml`. |
| Authentication | A SMART token with a complete-chart grant, or a ChartVoyant API key (read-only is enough). |
| Delivery | Returned to the caller. ChartVoyant does not transmit the document to another system on your behalf through this API. |

## Endpoints

| Route | Auth | What it returns |
| --- | --- | --- |
| `GET {FHIR base}/DocumentReference/$docref?patient={id}` | SMART token, complete-chart grant | A `searchset` Bundle with a DocumentReference for the current CCD (LOINC 34133-9). Passing `start`, `end`, or `type` returns existing documents instead. See [FHIR R4 API](https://docs.chartvoyant.com/fhir-r4/). |
| `GET {FHIR base}/Patient/{id}/$ccd` | SMART token, complete-chart grant | The CCD itself, as an XML attachment. |
| `GET https://chartvoyant.com/api/v1/patients/{id}/ccda` | API key | The CCD as XML. Sandbox keys use the same URL and reach only the synthetic sandbox office. |

A generated CCD spans the whole chart, so a grant limited to documents or to some resource classes cannot be used to generate one.

## Example

    cURLResponse (abridged XML)
    Copy

```
curl "https://chartvoyant.com/api/v1/patients/PATIENT_ID/ccda" \
  -H "Authorization: Bearer $CHARTVOYANT_API_KEY"
```

```
<ClinicalDocument xmlns="urn:hl7-org:v3">
  <templateId root="2.16.840.1.113883.10.20.22.1.2" extension="2015-08-01"/>
  <code code="34133-9" codeSystem="2.16.840.1.113883.6.1"/>
  <!-- recordTarget: synthetic demographics -->
  <component><structuredBody>
    <section><code code="11450-4"/><title>Problems</title><text></text></section>
    <section><code code="10160-0"/><title>Medications</title> … </section>
    <section><code code="48765-2"/><title>Allergies</title> … </section>
    <section><code code="30954-2"/><title>Results</title> … </section>
  </structuredBody></component>
</ClinicalDocument>
```

## Importing C-CDA

When a practice moves to ChartVoyant, its data migration can read C-CDA R2.1 CCD files exported by the prior system: demographics plus problems, medications, allergies, results, vital signs, immunizations, procedures, encounters, payers, and notes. The practice reviews a preview before anything is committed to a chart.

This runs inside ChartVoyant during onboarding. It is not a public API, and API keys cannot reach migration routes. To plan a migration, contact [info@chartvoyant.com](mailto:info@chartvoyant.com?subject=Data%20migration%20question).

## How to get access

- **Start in the sandbox** Request a sandbox key with a short form. It is issued on the spot, shown once, lasts 14 days, and reaches synthetic patients only, under the [ChartVoyant Sandbox Terms](https://chartvoyant.com/sandbox-terms/).

- **Go to production with a practice** A production key needs a sponsoring practice that confirms the request, a signed [API Use Agreement](https://docs.chartvoyant.com/api-use-agreement/), and a BAA between you and the practice. See [Onboarding Process](https://docs.chartvoyant.com/onboarding/).

- **Or connect via SMART on FHIR** Register an app as described on [SMART App Launch](https://docs.chartvoyant.com/smart-app-launch/#access). There is no fee.
