> ## 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.

# Medical Record Export & Document Generation — User Guide

> Contact your organization administrator if you need access.

## Quick Reference

| I need to...                    | Pattern                                        | Location                                                          |
| ------------------------------- | ---------------------------------------------- | ----------------------------------------------------------------- |
| Export one chart document       | Per-record download action                     | [Exporting a Single Document](#exporting-a-single-document)       |
| Export a complete patient chart | Export dialog with section/date filters        | [Exporting a Full Patient Chart](#exporting-a-full-patient-chart) |
| Include SUD content legally     | Consent-gated SUD toggle + redisclosure notice | [SUD Records & 42 CFR Part 2](#sud-records--42-cfr-part-2)        |
| Verify export permissions       | Permission-gated actions                       | [Permissions](#permissions)                                       |

## Decision Trees

### Export path selection

1. Need one document only?
   * Yes → use row/header Download action in target section.
   * No → use **Export Chart** in chart header.
2. Need date-filtered bundle?
   * Yes → enable date range in chart export dialog.
3. Need SUD records?
   * Only include when consent and SUD indicators permit the toggle.

### SUD consent branch

1. Is patient SUD-indicated and consent active?
   * Yes → SUD toggle enabled; include redisclosure notice.
   * No → SUD content excluded from export.

## Pattern Library

* **Download icon pattern:** section-level row action for single-document PDF export.
* **Export Chart dialog pattern:** section selector + optional date filter + consent-gated SUD inclusion.
* **Progress pattern:** visible progress bar for full-chart export generation.
* **Audit pattern:** every export writes immutable export audit metadata.

## Common Mistakes

| Mistake                                              | Outcome                                | Resolution                                           |
| ---------------------------------------------------- | -------------------------------------- | ---------------------------------------------------- |
| Trying full-chart export without `cl.records.export` | Export button unavailable              | Request permission update from org admin             |
| Expecting SUD data without active consent            | SUD toggle disabled or content missing | Verify CL-11 consent status and chart SUD indicators |
| Exporting oversized chart without date filter        | Slow/timeout-prone export              | Use date range filter to reduce scope                |

## Pre-Flight Checklist

* [ ] Confirm user has required export permission(s).
* [ ] Confirm patient chart context is correct.
* [ ] If SUD content is needed, verify active consent and SUD flag conditions.
* [ ] Select only necessary sections and apply date filters where appropriate.
* [ ] Verify PHI handling workflow for downloaded PDFs.

***

## Overview

CL-20 enables clinicians and authorized staff to export clinical documents as PDF files. You can export individual documents (e.g., a single progress note) or an entire patient chart (multiple sections combined into one PDF).

***

## Permissions

| Action                      | Required Permission |
| --------------------------- | ------------------- |
| Export a single document    | `cl.charts.export`  |
| Export a full patient chart | `cl.records.export` |

Contact your organization administrator if you need access.

***

## Exporting a Single Document

### Where to Find Export Buttons

Each section of the patient chart has a **Download** (↓) icon button next to individual records:

| Section               | Location                                       |
| --------------------- | ---------------------------------------------- |
| Progress Notes        | Per-row action area in the Notes tab           |
| Treatment Plans       | Per-row action area in the Treatment Plans tab |
| Assessments           | Per-row action area in the Assessments tab     |
| Clinical Summary      | Section header in the Summary tab              |
| Safety Plans          | In the Safety Plan card (Risk tab)             |
| Consent Documents     | Per-row action area in the Consents tab        |
| Group Sessions (Peer) | Per-row action area in the Peer tab            |

### How to Export

1. Navigate to the patient chart.
2. Open the relevant tab (e.g., Notes, Treatment Plans).
3. Click the **Download** (↓) icon next to the record you want to export.
4. The PDF will be generated and opened in a new browser tab.
5. From the new tab, you can print or save the document.

***

## Exporting a Full Patient Chart

### Steps

1. Navigate to the patient chart.
2. Click the **Export Chart** button in the chart header (top-right area).
3. The **Export Patient Chart** dialog will open.
4. **Select Sections:** Check or uncheck the sections you want to include. All sections are selected by default.
5. **Date Range (optional):** Toggle "Filter by date range" and enter start/end dates to limit exported records.
6. **SUD Records:** If the patient has SUD-indicated records and active consent, you can toggle "Include SUD Records" to include 42 CFR Part 2 protected content.
7. Click **Export Chart**.
8. A progress bar will show generation status.
9. The combined PDF opens in a new browser tab.

### Section Availability

* **Crisis Episodes** is shown but disabled (grayed out). This section requires CL-13 (Crisis Intervention), which is not yet implemented.
* All other sections are available for export.

***

## SUD Records & 42 CFR Part 2

Substance Use Disorder (SUD) records are protected under federal regulation **42 CFR Part 2**. When exporting:

* The "Include SUD Records" toggle is only enabled when:
  * The patient has SUD-indicated flags on their chart
  * Active patient consent exists for SUD record disclosure
* If enabled, exported documents automatically include the **federal redisclosure notice**
* If consent is not active, SUD content is excluded from the export

**Important:** You are responsible for ensuring that exported documents containing SUD information are handled in accordance with 42 CFR Part 2 redisclosure restrictions.

***

## Audit Trail

Every PDF export (single document or full chart) is automatically logged in the system audit trail. The audit record includes:

* **Who** exported the document (user ID)
* **What** was exported (document type, record ID)
* **When** the export occurred
* **Which patient** the record belongs to
* **Export type** (`cl_export_document` for single exports, `cl_export_chart` for full chart exports)

Administrators can review export activity in the audit logs.

***

## Troubleshooting

| Issue                                | Solution                                                                          |
| ------------------------------------ | --------------------------------------------------------------------------------- |
| "Export Chart" button not visible    | Verify you have the `cl.records.export` permission                                |
| Download icon not visible on records | Verify you have the `cl.charts.export` permission                                 |
| SUD toggle is disabled               | Patient may not have SUD-indicated flags, or consent may be expired/revoked       |
| PDF generation fails                 | Check your internet connection; try again. If the issue persists, contact support |
| Export times out on large charts     | Try filtering by date range to reduce the number of records                       |

***

## Related Documentation

* Specification: specs/cl/specs/CL-20-medical-record-export-document-generation.md
* [CL-11: Consent Management & 42 CFR Part 2](https://github.com/Encore-OS/encoreos/blob/development/specs/cl/specs/CL-11-consent-management-42cfr-part2.md)
* [Regulatory Compliance Tracker (42 CFR Part 2)](/compliance/REGULATORY_COMPLIANCE_TRACKER)
