Skip to main content

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.

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

From CoreTo CoreIntegration PatternStatusDocumentation link
CL (CL-20)PF-64, PF-11, CL-01–07, CL-11, CL-13, CL-14Platform Layer / Data✅ ImplementedCL-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; uses pf_audit_logs and existing CL entities.

Integration Points (from Spec)

DependencyPatternPurpose
PF-01 (Organizations & Sites)DirectTenant context for export and audit
PF-02 (RBAC)DirectPermissions cl.charts.export, cl.records.export
PF-11 (Documents)PlatformOptional storage in pf-documents bucket (future ROI)
PF-64 / Platform TemplatesPlatform Integration LayeruseGenerateTemplatedPdf, generate-templated-pdf edge function, letterhead
CL-01, CL-02, CL-03, CL-04, CL-07, CL-11, CL-13, CL-14InternalSource data for per-document hooks and bulk chart export

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.