Status: ✅ Implemented
Spec Reference: CL-20-medical-record-export-document-generation.md
Last Updated: 2026-02-23
Cross-Core Integration Matrix
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)
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