Feature ID: CL-08Documentation 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: ๐ Planned
Spec Reference: CL-08-clinical-decision-support.md
Last Updated: 2026-02-18
Table of Contents
- Overview
- Quick Reference
- Integration Points (from Spec)
- API / Data Contracts
- Event Contracts
- Security and RLS
- Related Docs
Overview
CL-08 provides clinical decision support (CDS): drug-drug and drug-allergy alerts, medication monitoring reminders (e.g. lithium, clozapine), documentation completeness and overdue alerts, and quality measure gap detection (HEDIS: FUH, FUM, IET, AMM). Alerts are configurable per organization (severity, hard stop vs soft), with override tracking for alert fatigue management. Delivery uses PF-10 (notifications).Quick Reference
| Category | Value |
|---|---|
| Tables | cl_cds_rules, cl_cds_alerts |
| Rule types | drug_interaction, drug_allergy, monitoring, documentation, quality_measure, custom |
| Trigger events | medication_add, prescription_submit, document_save, chart_open, assessment_due, quality_measure_eval |
| Condition/action | JSONB structure per spec Errata E-3 (CdsRuleCondition, CdsRuleAction) |
| RLS helpers | cl_has_org_access(organization_id); rule CRUD via cl_can_manage_cds_rules(organization_id, auth.uid()) โ delegates to pf_is_org_admin(user, org) at SQL level; finer-grained access (compliance role) via PF-30 permissions at app layer |
| SECURITY DEFINER | create_cl_cds_rule(), acknowledge_cl_cds_alert(), override_cl_cds_alert() โ SET search_path = public |
| Notification pattern | Direct insert into pf_notifications (client-side with org_id filter) or via createNotificationIfNew() from supabase/functions/_shared/ in edge functions |
Integration Points (from Spec)
| Dependency | Pattern | Purpose |
|---|---|---|
| CL-01 (Patient Chart) | Data | Alerts scoped to chart; cl_cds_alerts.chart_id โ cl_patient_charts.id |
| CL-05 (Medication Management) | API | Drug interaction checking from medication list; CDS evaluates at medication add/reconciliation |
| CL-06 (E-Prescribing) | API | Prescribing alerts during e-prescribing workflow (e.g. at prescription_submit) |
| CL-10 (Outcomes Tracking) | API / Data | Quality measure gap data; CL-08 rules consume or react to HEDIS gap data from CL-10 or platform measure logic. Exact contract (events/APIs) TBD here. |
| PF-10 (Notifications) | Event / API | Alert delivery via notifications system (in-app; email/push per PF-10) |
| PF-70 (Code Libraries) | API | ICD-10-CM, CPT, HCPCS, LOINC for rule conditions and display (e.g. lab LOINC in monitoring rules) |
API / Data Contracts
cl_cds_rules
- Scope:
organization_id; rule types and trigger_event per spec Data Model. - Condition/action: JSONB schemas per spec Errata E-3.
- Audit:
created_at,updated_at; addcreated_by,updated_byper Errata E-1. - Custom fields:
custom_fields JSONB NOT NULL DEFAULT '{}'.
cl_cds_alerts
- Scope:
organization_id,chart_id; optionalrule_idlinking to rule that fired. - Lifecycle: triggered_at โ acknowledged_by/acknowledged_at; overridden + override_reason when user proceeds despite alert.
- Audit:
created_at,updated_at; addcreated_by,updated_byper Errata E-1.
CDS invocation (inbound)
- Callers: CL-05 (medication list + allergies โ interaction check), CL-06 (prescription submit โ interaction/allergy check), documentation/chart flows (documentation_gap, quality_measure_eval).
- Response: List of alerts with severity and is_hard_stop; caller blocks or shows modal per config.
Outbound to PF-10
- Payload: Alert title, message, severity, chart_id, user context; optional deep link to chart/medication.
- When: On insert of
cl_cds_alerts(or via application logic that creates alert then notifies).
Event Contracts
| Event | Channel | Direction | Purpose |
|---|---|---|---|
cds_alert_triggered | cl_events | CL-08 โ PF-10, PF-04 | Alert created; triggers in-app notification via direct pf_notifications insert and audit log |
cds_rule_overridden | cl_events | CL-08 โ PF-10, PF-04 | Alert overridden with reason; audit event for compliance review |
| (TBD) | cl_events | CL-10 โ CL-08 | Quality measure gap data available for CDS rules (optional; may be pull/API). Blocked until CL-10 Phase 1 complete. |
cds_alert_triggered and cds_rule_overridden must be inserted into fw_workflow_events with category = 'operational' during Phase 1 migration.
Security and RLS
- RLS: Enabled on
cl_cds_rulesandcl_cds_alerts; org isolation viacl_has_org_access(organization_id)(per Errata E-2). Do not usecurrent_setting('app.current_org'). - Rule CRUD: Restrict INSERT/UPDATE/DELETE on
cl_cds_rulesto users with org access and permitted role (e.g. admin, compliance) via SECURITY DEFINER helpercl_can_manage_cds_rules(organization_id, auth.uid()). - Alerts: SELECT/UPDATE for clinicians in same org; UPDATE for acknowledgement/override only (clinician or prescriber roles). Compliance may manage rules; may have read-only access to alert history for audit.
- SECURITY DEFINER: All helpers use
SET search_path = public. UPDATE policies include WITH CHECK (ยง5.2.4).
Related Docs
- CL-08 Spec
- CL-05 Medication Management Integration โ drug interaction request/response
- CL-06 E-Prescribing Integration โ prescribing-time CDS
- CROSS_CORE_INTEGRATIONS โ matrix entry for CL-08