This file is an engineering snapshot (schema, route map, integration points) intended for developers working insrc/cores/rh/. Published end-user / admin documentation lives in the Mintlifydocs/rh/surface (slug/rh/overview).
Overview
The Recovery Housing module manages the full episode-based resident lifecycle for sober-living, recovery-housing, psychiatric-residential, and inpatient settings. It supports intake → admitted → on_hold → discharged transitions, 120-day phase progression, daily operations, compliance & audit, discharge planning, and outcomes / alumni tracking. Therh_episodes status field drives the core state machine (rh_update_episode_status):
Spec status
See
specs/rh/summaries/DEFERRED-PHASES-SUMMARY.md for the complete deferred / planned backlog and specs/rh/reports/rh-deep-review-20260418.md for the latest deep review.
End-user / admin documentation
Published Mintlify surface (docs/rh/, slug /rh/overview):
- User guides: Census & Operations · Programs & Phases · Safety & Compliance · Daily Operations · Discharge Planning · Compliance & Staff Operations · Outcomes & Alumni
- Admin guides: property setup · room configuration · program management · RH settings · compliance setup · audit setup · outcome indicators setup · report definitions setup
- Wizards: admission (as-built RH-UX-00); program creation, significant event reporting, discharge planning, compliance setup, outcomes assessment, grievance filing (planned reference)
- Planned (spec-only): RH-08, RH-09, RH-10, RH-11, RH-04 EN-4
Withindocs/rh/, this engineering snapshot plusdatabase-tables.mdandreferences.mdare engineering / regulatory references; the remaining*-user-guide.md/*-admin-guide.mdpages are the user-facing guides.
Routes
src/routes/rh.tsx defines 53 routes. Top-level groups (URL prefix /rh):
⚠️ Only/rh/settingsis wrapped in<RequirePermission>today. The remaining ~52 routes rely on RLS + nav gating only. A route-level permission sweep is filed as a HIGH-MEDIUM backlog item inDEFERRED-PHASES-SUMMARY.md.
Data model (key entities only)
Engineering DB cheat sheet:Census, residences, beds:docs/rh/database-tables.md. ERD:docs/database/erd/RH_ERD.md.
rh_residences— properties / facilities (withfacility_type:recovery_housingPOS 55,psychiatric_residentialPOS 56,inpatient_unitPOS 51)rh_beds— bed inventory (with optionalunit_labelfor inpatient grouping)rh_census_snapshots— census timeseries
rh_resident_profiles— long-lived demographic recordrh_episodes— one row per admission;bed_id, status, admission/discharge datesrh_episode_payment_status— FA balance cache (populated byfa-episode-balanceedge function)rh_eligibility_checklists,rh_resident_agreements— gating + agreements
rh_programs,rh_program_phases,rh_phase_milestones,rh_phase_privilegesrh_episode_programs,rh_episode_phases,rh_milestone_completions
rh_significant_event_types,rh_significant_events,rh_significant_event_investigations,rh_significant_event_actionsrh_uds_random_schedule,rh_uds_tests⚠️ 42 CFR Part 2 protectedrh_passesrh_med_storage_audits
rh_schedule_templates,rh_schedule_instances,rh_attendance_recordsrh_chore_assignments,rh_transport_requests,rh_curfew_checksrh_participation_metrics
rh_discharge_plans,rh_discharge_checklists,rh_discharge_documentsrh_referralsrh_follow_up_schedules,rh_follow_up_contacts
rh_compliance_requirements,rh_compliance_checklistsrh_staff_assignments,rh_staff_trainings,rh_shift_notesrh_audit_schedules,rh_audit_findings
rh_outcome_indicators,rh_outcome_checkpoints,rh_outcome_assessments,rh_outcome_measurementsrh_alumni,rh_alumni_engagementrh_report_definitions
rh_module_settings— one row per organisation (defaults, follow-up cadence, notification toggles, sender address)
rh_update_episode_status(p_episode_id, p_new_status, p_user_id)— drives the episode state machinerh_assign_bed_to_episode(p_episode_id, p_bed_id, p_user_id)— validates + assigns + emits eventrh_get_residence_census(p_residence_id, p_as_of)— live censusrh_trigger_invoice_creation(p_agreement_id)— agreement → FA invoice request
rh_resident_admitted,rh_resident_discharged,rh_phase_advanced→ persisted tofw_domain_events. Consumers in FA / PM / HR are not yet wired (see deep-review actions tracker).
Status enum reference
Integration points
- Platform Foundation (PF): multi-tenant org/site, auth/RBAC (
RH_PERMISSIONS.*), navigation, notifications (PF-10), document storage (PF-11; bucketpf-documents), forms (PF-08), CSV import (PF), templates (PF), wizards (PF-41 — RH wizard registration pending), jurisdiction profiles (PF-96). - FW (Forms & Workflow): intake, discharge, safety, custom assessments. Domain events persisted to
fw_domain_events. - HR (Human Resources): staff lookup via the Platform Workforce Layer (
@/platform/workforce) — no direct FK tohr_employees. - FA (Finance & Accounting): episode billing balance via the
fa-episode-balanceedge function (useFaEpisodeBalance); planned event consumer forrh_resident_admitted. - CL (Clinical): future — current-residence API for patient chart housing context (not yet implemented).
Reference
docs/rh/database-tables.md— engineering DB cheat sheetdocs/rh/references.md— regulatory & standards referencesdocs/database/erd/RH_ERD.md— entity-relationship diagramdocs/compliance/RH_RECOVERY_HOUSING_COMPLIANCE_TRACKING.md— live compliance trackersrc/cores/rh/AGENTS.md— AI agent instructions forsrc/cores/rh/specs/rh/— module specs, enhancement specs, UX wizard specs, deep reviews- Published end-user / admin docs: the Mintlify
docs/rh/surface (slug/rh/overview)
Last updated: 2026-04-18 (RH Audit & Optimization — Phase 0)