Overview
This document defines the integration contract between the RH (Recovery Housing) core and the FW (Forms & Workflow) core. RH uses FW for resident intake forms, phase progression approvals, safety event investigation workflows, pass request approvals, compliance automations, and drug testing documentation. Related Specifications:- RH-01: Census & Beds (resident admission/discharge)
- RH-02: Programs & Phases (phase progression, intake/exit forms)
- RH-03: Safety Events & Compliance (incidents, UDS testing, pass requests)
- RH-04: Participation & Attendance (attendance threshold monitoring)
- RH-06: Compliance & Staff Operations (regulatory deadlines)
- FW-01/FW-05: Forms (intake assessments, incident reports, UDS documentation, multi-page)
- FW-03: Automation Engine (compliance reminders, escalation triggers)
- FW-15: Form Field Lookups (residents, programs, phases, houses/beds)
- FW-16: Event-Based Workflow Triggers
- FW-33: Signature Capture (consent forms, pass agreements)
- FW-34: Approval Workflows (phase progression, pass requests, incident closure)
- FW-45: Decision Tables (safety event severity routing)
Integration Pattern
Primary Pattern: Pattern 1 — Platform Integration Layer Secondary Pattern: Pattern 2 — Event-Based Integration RH accesses FW capabilities through:@/platform/forms— intake assessments, incident reports, phase assessments, exit surveys@/platform/approvals— phase progression and pass request approval chains@/platform/events— publishing RH events for FW automation triggers@/platform/data-lookup— resident, program, phase, and staff lookups in forms@/platform/signatures— consent forms and pass agreement signatures
rh_programs.intake_form_id→fw_forms.idrh_programs.assessment_form_id→fw_forms.idrh_programs.exit_survey_form_id→fw_forms.id
Event Contracts (RH → FW)
Events published by RH that trigger FW automations and workflows.RH-01: Resident Lifecycle Events
Event: rh_resident_admitted
Event: rh_resident_admitted
Channel: domain_events
Publisher: RH (RH-01 Census & Beds)
Subscribers: FW-03 (intake workflow), FA (billing trigger), PF-10 (notification)
Status: ✅ Implemented (registered in KnownEventName)
Purpose
Triggers intake workflow when a new resident is admitted to a recovery housing program.Payload Schema
Consumer Actions
Event: rh_resident_discharged
Event: rh_resident_discharged
Channel: domain_events
Publisher: RH (RH-01 Census & Beds)
Subscribers: FW-03 (discharge workflow), FA (final billing), PF-10 (notification)
Status: ✅ Implemented (registered in KnownEventName)
Purpose
Triggers discharge workflow when a resident leaves the program.Payload Schema
Consumer Actions
RH-02: Phase Progression Events
Event: rh_phase_advanced
Event: rh_phase_advanced
Channel: domain_events
Publisher: RH (RH-02 Programs & Phases)
Subscribers: FW-03 (new phase automation), PF-10 (notification)
Status: ✅ Implemented (registered in KnownEventName)
Purpose
Triggers new-phase automation when a resident advances to the next phase of their program.Payload Schema
Consumer Actions
Event: rh_phase_progression_requested
Event: rh_phase_progression_requested
Channel: domain_events
Publisher: RH (RH-02 Programs & Phases)
Subscribers: FW-34 (phase progression approval chain)
Status: 📝 Planned (not yet in KnownEventName)
Purpose
Triggers phase progression approval workflow when manual approval is required for phase advancement.Payload Schema
RH-03: Safety Event & Compliance Events
Event: rh_safety_event_created
Event: rh_safety_event_created
Channel: domain_events
Publisher: RH (RH-03 Safety Events)
Subscribers: FW-03 (investigation workflow), GR (governance notification), PF-10 (alert)
Status: 📝 Planned (not yet in KnownEventName)
Purpose
Triggers investigation workflow and escalation based on safety event severity.Payload Schema
Consumer Actions
Event: rh_uds_test_positive
Event: rh_uds_test_positive
Channel: domain_events
Publisher: RH (RH-03 UDS Testing)
Subscribers: FW-03 (relapse plan workflow)
Status: 📝 Planned (not yet in KnownEventName)
Purpose
Triggers relapse plan workflow when a resident tests positive on a urine drug screen.Payload Schema
Consumer Actions
Event: rh_pass_requested
Event: rh_pass_requested
Channel: domain_events
Publisher: RH (RH-03 Pass System)
Subscribers: FW-34 (pass approval chain)
Status: 📝 Planned (not yet in KnownEventName)
Purpose
Triggers pass approval workflow when a resident requests a pass (temporary leave from the facility).Payload Schema
RH-04: Attendance Events
Event: rh_attendance_threshold_breached
Event: rh_attendance_threshold_breached
Channel: domain_events
Publisher: RH (RH-04 Participation & Attendance)
Subscribers: FW-03 (alert automation), PF-10 (notification)
Status: 📝 Planned (referenced in EVENT_CONTRACTS.md)
Purpose
Triggers alert workflow when a resident’s attendance drops below the required threshold.Payload Schema
RH-06: Compliance Events
Event: rh_compliance_deadline_approaching
Event: rh_compliance_deadline_approaching
Channel: domain_events
Publisher: RH (RH-06 Compliance & Staff Operations)
Subscribers: FW-03 (reminder automation)
Status: 📝 Planned (not yet in KnownEventName)
Purpose
Triggers reminder automation when a regulatory compliance deadline approaches (e.g., fire inspection, license renewal, staff training).Payload Schema
Consumer Actions
Approval Chain Configurations
Phase Progression Approval
Chain ID:rh-phase-progression-approval
Entity Type: rh_phase_progressions
Based On: RH-02
Pass Request Approval
Chain ID:rh-pass-request-approval
Entity Type: rh_passes
Based On: RH-03
Decision Table for Routing:
Safety Event Investigation Closure
Chain ID:rh-safety-event-closure-approval
Entity Type: rh_safety_events
Based On: RH-03
Discharge Approval
Chain ID:rh-discharge-approval
Entity Type: rh_discharges
Based On: RH-01
Decision Tables
Safety Event Severity Routing
Table ID:rh-safety-event-severity-routing
Hit Policy: FIRST
Pass Approval Routing
Table ID:rh-pass-approval-routing
Hit Policy: FIRST
Form Templates
Existing Templates
Planned Form Templates
Workflow Templates
Planned Workflow Templates (From Recommended Templates)
Form Field Lookups
RH exposes these data sources for FW form field lookups (FW-15):Database References (RH → FW)
RH programs have direct FK references to FW forms:- Intake: Filled during resident admission (RH-01)
- Assessment: Filled during phase transition evaluation (RH-02)
- Exit Survey: Filled during discharge (RH-01)
Platform Layer Usage
Hooks RH Components Import
Testing Requirements
Unit Tests
- RH event payloads match documented schemas
- Safety event severity decision table returns correct response workflow
- Pass approval routing decision table handles all phase × risk combinations
- No PII/PHI in event payloads (resident names, DOBs, substance details)
Integration Tests
-
rh_resident_admittedevent triggers intake workflow in FW -
rh_phase_progression_requestedevent routes to phase approval chain -
rh_safety_event_createdevent routes through severity decision table -
rh_pass_requestedevent routes through pass approval chain - Phase assessment form linked to program via
rh_programs.assessment_form_id - Form field lookups return correct residents, programs, houses
E2E Tests
- Complete intake flow: admission → intake form → orientation → assessment → bed assignment
- Phase progression flow: assessment → score → approval → phase update → privilege change
- Incident flow: report → severity routing → investigation → corrective action → closure approval
- Pass flow: request → risk assessment → approval chain → departure → return check-in
- Discharge flow: request → approval → exit survey → room inspection → billing close
RLS Tests
- RH events filtered by
organization_id - Approval requests scoped to submitter’s organization
- Form submissions isolated per tenant
- Resident lookups filtered by organization
Implementation Status
Related Documentation
- FW Cross-Core Integration Guide — Shared patterns
- RH-04 Attendance Integration — Attendance threshold events
- RH-06 Compliance Integration — Compliance events
- Event Contracts — RH event registry
- Cross-Core Integration Matrix — Platform-wide matrix
- Recommended Workflow Templates — RH templates (3)