Feature ID: GR-14Documentation Index
Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt
Use this file to discover all available pages before exploring further.
Spec: GR-14 Regulatory Incident Reporting Automation
Version: 1.0
Status: ✅ Complete
Last Updated: 2026-03-07
Owner: GR (Governance & Risk)
Overview
GR-14 implements the regulatory reporting automation layer on top of GR-09 (Incident Reporting). It automatically classifies incidents against statutory reporting rules, tracks deadlines, generates report packages, and notifies compliance staff. Integration patterns used:- Event Consumer: Subscribes to
incident_created(channel:gr_events, ✅ Implemented) from GR-09 - Event Publisher: Publishes
regulatory_report_submittedconsumed by GR-03, GR-08, PF-10 - Platform Layer: PF-10 (Notifications), PF-11 (Documents), PF-12 (Reporting), PF-30 (Permissions)
Integration 1: GR-09 → GR-14 (Event Consumer)
Event: incident_created
Channel: gr_eventsPublisher: GR-09 (Incident Reporting)
Consumer: GR-14 (
gr-classify-incident-reporting-obligations edge function)Status: ✅ Implemented — trigger emits for ALL incidents Payload consumed by GR-14:
- Fetch
gr_incidentsrow forincident_idto getcategory,severity,incident_date,custom_fields - Evaluate all active
gr_regulatory_reporting_rulesfororganization_id(system-wide + org-specific) - For each matching rule: calculate
statutory_deadlineperdeadline_type(calendar or business hours) - Insert
gr_incident_regulatory_reportsrows (UNIQUE constraint prevents duplicates)
supabase/functions/gr-classify-incident-reporting-obligations/index.tsAuth:
verify_jwt: false (server-to-server via pg_net; validates via service role key in Authorization header, NOT verifyOrgAccess() which expects a user JWT)
Integration 2: GR-14 → GR-03, GR-08, PF-10 (Event Publisher)
Event: regulatory_report_submitted
Channel: gr_eventsPublisher: GR-14 (on
status → submitted transition)Subscribers: GR-03 (compliance evidence), GR-08 (accreditation evidence), PF-10 (notification)
Status: ✅ Implemented Payload (stub — finalize on implementation):
Integration 3: GR-14 → PF-10 (Platform Layer — Notifications)
Pattern: Platform Integration Layer (PF-10)Usage: Deadline D-N and overdue alerts sent to users with
incident_regulatory_reports.view permissionFunction:
createNotificationIfNew() from supabase/functions/_shared/notification-utils.tsCalled by:
gr-regulatory-deadline-alerts cron edge function
Notification types:
gr_regulatory_deadline_approaching: Sentdeadline_notification_days_beforedays beforestatutory_deadlinegr_regulatory_deadline_overdue: Sent daily whilenow() > statutory_deadline AND status IN ('draft', 'ready')
Integration 4: GR-14 → PF-11 (Platform Layer — Documents)
Pattern: Platform Integration Layer (PF-11)Usage: Regulatory report packages stored as PF documents
Called by:
gr-generate-regulatory-report edge functionOutput:
report_document_id UUID linked on gr_incident_regulatory_reports
Document metadata (stub):
Integration 5: GR-14 → PF-12 (Platform Layer — Reporting)
Pattern: Platform Integration Layer (PF-12)Usage: Regulatory reporting summary report for accreditation/audit purposes
Status: 📝 Planned — Phase 3
Security & Tenant Isolation
- All GR-14 tables RLS-filtered by
organization_id - SECURITY DEFINER helpers
gr_has_org_access()/gr_is_org_admin()used exclusively in RLS policies - PHI in
narrativecolumn: access gated byincident_regulatory_reports.viewpermission - Event payloads contain patient identifiers (
chart_id) as UUIDs; subscribing functions must enforce RLS and appropriate patient access controls gr-classify-incident-reporting-obligations: runs asservice_role(bypasses RLS by design); performs explicitorganization_idvalidation before inserting regulatory reports. Because service-role bypasses RLS, the function must independently verify the caller’s org membership and the incident’s organization context before any writes
Pending Contract Items
| Item | Blocked On | Notes |
|---|---|---|
regulatory_report_submitted event payload schema | GR-14 Phase 2 implementation | GR-03 and GR-08 teams to confirm compliance evidence record format |
PF-11 document metadata schema for gr_incident_regulatory_report source type | PF-11 implementation status | Confirm source_type string for document generation |
Contract Validation
Validated against CONTRACT_VALIDATION_CHECKLIST.md:- Event payload schema documented (GR-14 Phase 2)
- Publisher/subscriber declared for each event
- Auth and tenant isolation documented per event/function
- PHI restrictions documented (UUIDs only in event payloads)
- Platform layer usage documented (PF-10, PF-11, PF-12)
- Integration matrix updated in CROSS_CORE_INTEGRATIONS.md (see below)
References
- GR-14 Spec
- GR-09 Spec
- EVENT_CONTRACTS.md —
incident_createdevent - PLATFORM_INTEGRATION_LAYERS.md — PF-10, PF-11, PF-12
- CROSS_CORE_INTEGRATIONS.md