Skip to main content
Feature ID: CL-20
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; uses pf_audit_logs and existing CL entities.

Integration Points (from Spec)


API / Data Contracts

Platform Integration Layer (Pattern 1)

  • Consumes: @/platform/templatesuseGenerateTemplatedPdf, useOrgLetterheads
  • Edge function: Existing generate-templated-pdf (no new edge function for MVP)
  • Audit: All exports write to pf_audit_logs with action (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 requires cl.charts.export.
  • Audit log entries MUST include organization_id and user_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.