Status: 🏗️ Scaffolded (event contracts are placeholders)
Spec Reference: CL-21-medication-assisted-treatment-moud-tracking.md
Last Updated: 2026-02-23
Overview
CL-21 defines MAT/MOUD enrollment, medication events (ordered, prescribed, administered, dispensed, held, missed), and monitoring events (UDS, hepatic panel, etc.) for opioid treatment and behavioral health programs. It integrates with CL-05 (medications), CL-06 (e-prescribing), CL-10 (outcomes/CBE #3400), CL-11 (consent/42 CFR Part 2), PM-07 (charge triggers), PF-10 (alerts), and PF-70 (terminology).Quick Reference
Pattern Library
- Consent-gated MAT access: Always resolve consent via
consent_idon enrollment or chart-level SUD consent; enforce in RLS with SECURITY DEFINER helpers (no direct query to RLS-protected tables). - Charge context: Pass enrollment/medication/monitoring context to PM-07 for encounter-to-charge mapping.
- Alerts: Publish overdue monitoring / missed-dose events via PF-10 when event contracts are defined.
Common Mistakes
Pre-Flight Checklist
- CL-11 consent enforcement in place for all MAT tables.
- Permission keys seeded (PF-30); UI gated by
cl.moud.*. - UPDATE policies include WITH CHECK on
organization_id. - No direct queries to RLS-protected tables inside policies.
Decision Tree (major choices)
Integration Points (from Spec)
Consent (CL-11)
consent_idoncl_moud_enrollmentsis optional only for non-SUD MAT cases. For SUD MAT, a linked 42 CFR Part 2 consent must be used.- When
consent_idis null, the system falls back to chart-level SUD consent flags (CL-11) via RLS policies before any read/write access to MAT enrollment or related events. - When
consent_idis present, it ties to a specific consent record for that MAT episode. - All access to
cl_moud_enrollmentsand related events (cl_moud_medication_events,cl_moud_monitoring_events) must pass the CL-11 consent check—either the linkedconsent_idor the chart-level SUD consent flag—enforced in RLS via SECURITY DEFINER helpers. See CL-11 Consent Integration.
Integration Type Mapping (for CROSS_CORE_INTEGRATIONS matrix)
API Contracts
- PM-07 charge triggers: Inputs for MAT encounters and services (enrollment/medication/monitoring context) for charge capture. Document in API_CONTRACTS.md or CL-PM Encounter-to-Billing when implemented.
- Enrollments:
cl_moud_enrollments— enrollment, phase, status; consumed by CL-10 and reporting. - Medication events:
cl_moud_medication_events— dosing and adherence; feeds CL-10 numerator/denominator logic. - Monitoring events:
cl_moud_monitoring_events— UDS/lab due and completion; drives PF-10 alerts.
Event Contracts
- PF-10 (Platform): Overdue monitoring and adherence-risk alerts published via Platform Notifications (Platform Integration Layer).
- Event contracts are defined in EVENT_CONTRACTS.md as:
cl_moud_monitoring_overduecl_moud_adherence_risk
- See EVENT_CONTRACTS.md for payload definitions.
Security and RLS
- PHI/SUD: strict RLS and CL-11 consent enforcement before access.
- RLS on
cl_moud_enrollments,cl_moud_medication_events,cl_moud_monitoring_eventsvia SECURITY DEFINER helpers; no direct queries to RLS-protected tables in policies (constitution §5.7). - UPDATE policies must include WITH CHECK on
organization_id(constitution §5.2.4). - Permission keys:
cl.moud.view,cl.moud.enroll,cl.moud.medication-event.create,cl.moud.monitoring.manage,cl.moud.report.view(seed in migration per PF-30).