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-08
Status: ๐Ÿ“ Planned
Spec Reference: CL-08-clinical-decision-support.md
Last Updated: 2026-02-18

Table of Contents


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

CategoryValue
Tablescl_cds_rules, cl_cds_alerts
Rule typesdrug_interaction, drug_allergy, monitoring, documentation, quality_measure, custom
Trigger eventsmedication_add, prescription_submit, document_save, chart_open, assessment_due, quality_measure_eval
Condition/actionJSONB structure per spec Errata E-3 (CdsRuleCondition, CdsRuleAction)
RLS helperscl_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 DEFINERcreate_cl_cds_rule(), acknowledge_cl_cds_alert(), override_cl_cds_alert() โ€” SET search_path = public
Notification patternDirect insert into pf_notifications (client-side with org_id filter) or via createNotificationIfNew() from supabase/functions/_shared/ in edge functions

Integration Points (from Spec)

DependencyPatternPurpose
CL-01 (Patient Chart)DataAlerts scoped to chart; cl_cds_alerts.chart_id โ†’ cl_patient_charts.id
CL-05 (Medication Management)APIDrug interaction checking from medication list; CDS evaluates at medication add/reconciliation
CL-06 (E-Prescribing)APIPrescribing alerts during e-prescribing workflow (e.g. at prescription_submit)
CL-10 (Outcomes Tracking)API / DataQuality 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 / APIAlert delivery via notifications system (in-app; email/push per PF-10)
PF-70 (Code Libraries)APIICD-10-CM, CPT, HCPCS, LOINC for rule conditions and display (e.g. lab LOINC in monitoring rules)
Drug interaction data source: CL-05/CL-06/CL-08 do not specify the interaction database (First Databank, Medi-Span, RxNav/NLM, etc.). Per CL-PM-SPEC-REVIEW: define data source and update process in a PF-level or CL-08 integration contract. CL-05 integration doc currently references RxNav/NLM for MVP with interface abstracted for future FDB swap; CL-08 should use the same abstraction.

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; add created_by, updated_by per Errata E-1.
  • Custom fields: custom_fields JSONB NOT NULL DEFAULT '{}'.

cl_cds_alerts

  • Scope: organization_id, chart_id; optional rule_id linking to rule that fired.
  • Lifecycle: triggered_at โ†’ acknowledged_by/acknowledged_at; overridden + override_reason when user proceeds despite alert.
  • Audit: created_at, updated_at; add created_by, updated_by per 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

EventChannelDirectionPurpose
cds_alert_triggeredcl_eventsCL-08 โ†’ PF-10, PF-04Alert created; triggers in-app notification via direct pf_notifications insert and audit log
cds_rule_overriddencl_eventsCL-08 โ†’ PF-10, PF-04Alert overridden with reason; audit event for compliance review
(TBD)cl_eventsCL-10 โ†’ CL-08Quality measure gap data available for CDS rules (optional; may be pull/API). Blocked until CL-10 Phase 1 complete.
Registration: Both 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_rules and cl_cds_alerts; org isolation via cl_has_org_access(organization_id) (per Errata E-2). Do not use current_setting('app.current_org').
  • Rule CRUD: Restrict INSERT/UPDATE/DELETE on cl_cds_rules to users with org access and permitted role (e.g. admin, compliance) via SECURITY DEFINER helper cl_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).