> ## Documentation Index
> Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
> Use this file to discover all available pages before exploring further.

# C-CDA Documents

> Generate, preview, and manage Consolidated CDA documents for a patient chart; requires the CDA generation feature flag to be enabled.

The C-CDA Documents screen at `/cl/charts/:chartId/cda` lets authorized users generate, preview, and review HL7 Consolidated Clinical Document Architecture (C-CDA) records for a single patient chart.

## Overview

The page is wrapped in a `PermissionGate` for `cl.cda.view`; users without this permission see an "Access denied" alert. An additional feature flag `cl_module_settings.cda_generation_enabled` must be `true`; otherwise a settings-disabled alert is shown. When enabled, the page displays a two-column layout: a left panel for document generation (type selector, recipient name, purpose of disclosure) and document history; a right panel for previewing the selected document via `CdaDocumentPreview`. A `CdaConsentBanner` is shown when the Part 2 SUD consent check (`useConsentCheck`) returns a result. The most recent document in history is auto-selected on load.

## Who it's for

Requires permission: `cl.cda.view`

Generating a new document additionally requires: `cl.cda.generate` (the Generate button is wrapped in a `PermissionGate` for this permission).

## Before you start

* Must hold `cl.cda.view`.
* The `cda_generation_enabled` setting must be enabled in CL module settings (accessible via `cl.admin`).
* Navigate here from the Patient Chart page ("Generate C-CDA" button) or directly via `/cl/charts/:chartId/cda`.

## Steps

<Steps>
  <Step title="Open the C-CDA page">From the Patient Chart for the target patient, click the "Generate C-CDA" button (visible when you hold `cl.cda.view`). The page loads with the patient name in the breadcrumb.</Step>
  <Step title="Review the consent banner">If a SUD consent check result is present, the `CdaConsentBanner` is shown. Review any consent warnings before proceeding.</Step>
  <Step title="Select document type">Use `CdaDocumentTypeSelector` to choose the C-CDA document type (default: `ccd`).</Step>
  <Step title="Enter recipient and purpose">Fill in the Recipient name field (required) and the Purpose of disclosure field (defaults to `Treatment`).</Step>
  <Step title="Generate the document">Click "Generate document". On success with `validation_status: 'valid'`, a success toast is shown. If validation fails, a warning toast is shown — the document still appears in history.</Step>
  <Step title="Preview and review history">Select any document from the History panel on the left to display it in the Preview panel. The most recent document is auto-selected.</Step>
</Steps>

## Key concepts

<AccordionGroup>
  <Accordion title="Document types">
    The available document types are defined by `CdaDocumentTypeSelector`. The default is `ccd`. SME: confirm full type list and clinical use cases.
  </Accordion>

  <Accordion title="Validation status">
    After generation, each document has a `validation_status` field. A `valid` status shows a success toast; any other status shows a warning toast indicating the document failed validation. Both states produce a document record visible in history.
  </Accordion>

  <Accordion title="SUD consent check">
    `useConsentCheck` is called with the chart ID. The result controls the `CdaConsentBanner` display. SME: confirm whether missing consent blocks generation or only provides a warning.
  </Accordion>

  <Accordion title="Error and empty states">
    If settings or chart data are loading, skeleton placeholders are shown. If the feature flag is disabled, a static alert instructs the admin to enable "C-CDA generation" in CL module settings. If no documents exist and none is selected, the preview panel shows a prompt to select or generate one.
  </Accordion>
</AccordionGroup>

## Related

<Columns cols={2}>
  <Card title="Clinical" icon="stethoscope" href="/cl/overview">
    Overview of the Clinical core.
  </Card>

  <Card title="Governance & parity" icon="scale-balanced" href="/governance/index">
    Documentation coverage and governance.
  </Card>
</Columns>

<Note>
  This page documents shipped product behavior. It is not medical, legal, or
  billing advice. Verify against your organization's policies and applicable
  regulations before using it for clinical, compliance, or billing decisions.
  Protected health information (PHI) shown in the product is governed by your
  tenant's access controls and is never exposed in this documentation.
</Note>

<Accordion title="Documentation sources">
  * src/routes/cl.tsx
  * src/cores/cl/pages/CdaGenerationPage.tsx
  * src/cores/cl/hooks/useChartDetail.ts
</Accordion>
