Feature ID: CL-20Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Status: ✅ Implemented
Spec Reference: CL-20-medical-record-export-document-generation.md
Last Updated: 2026-02-23
Cross-Core Integration Matrix
| From Core | To Core | Integration Pattern | Status | Documentation link |
|---|---|---|---|---|
| CL (CL-20) | PF-64, PF-11, CL-01–07, CL-11, CL-13, CL-14 | Platform Layer / Data | ✅ Implemented | CL-20 spec |
Overview
CL-20 enables per-document PDF export and full chart export for clinical documentation, using the platform templated PDF infrastructure (PF-64) and audit logging. No new CL tables; usespf_audit_logs and existing CL entities.
Integration Points (from Spec)
| Dependency | Pattern | Purpose |
|---|---|---|
| PF-01 (Organizations & Sites) | Direct | Tenant context for export and audit |
| PF-02 (RBAC) | Direct | Permissions cl.charts.export, cl.records.export |
| PF-11 (Documents) | Platform | Optional storage in pf-documents bucket (future ROI) |
| PF-64 / Platform Templates | Platform Integration Layer | useGenerateTemplatedPdf, generate-templated-pdf edge function, letterhead |
| CL-01, CL-02, CL-03, CL-04, CL-07, CL-11, CL-13, CL-14 | Internal | Source data for per-document hooks and bulk chart export |
API / Data Contracts
Platform Integration Layer (Pattern 1)
- Consumes:
@/platform/templates—useGenerateTemplatedPdf,useOrgLetterheads - Edge function: Existing
generate-templated-pdf(no new edge function for MVP) - Audit: All exports write to
pf_audit_logswithaction(cl_export_document|cl_export_chart),entity_type,entity_id,patient_id,metadata(optional JSONB)
Placeholder: Event Contracts
- No domain events published by CL-20. (Future: ROI workflow could consume export completion; out of scope for MVP.)
Placeholder: API Contracts
- No new REST APIs. Export is triggered from UI via hooks that call platform PDF generation and audit helpers.
Security and Tenant Isolation
- Export hooks run in authenticated user context; RLS on CL tables unchanged.
- Permissions: Bulk “Export Chart” button requires
cl.records.export; per-document “Export PDF” on detail pages requirescl.charts.export. - Audit log entries MUST include
organization_idanduser_id. - 42 CFR Part 2: SUD content included only when consent verified (e.g.
cl_has_sud_consent(patient_id, user_id)); otherwise excluded from export payload.
Related Docs
- CL-20 Spec
- Platform Templates
- CL-11 Consent & Part 2
- CROSS_CORE_INTEGRATIONS.md — CL-20 row included; see matrix for medical-record-export-document-generation