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.

Module: Recovery Housing Management
Prefix: rh_
Table Count: 51
Last Updated: 2026-01-10

Overview

The RH module provides comprehensive recovery housing management including resident tracking, program phases, daily operations, drug screening, discharge planning, alumni engagement, and outcome measurement.

Table Categories

1. Residences & Beds (3 tables)

TableColumnsDescription
rh_residences24Recovery residence properties
rh_beds16Individual bed inventory
rh_census_snapshots14Daily census records
Residence Structure:
rh_residences (property)
    └── pf_sites (linked location)
    └── rh_beds (bed inventory)
            └── capacity, gender, status
Bed Status:
  • available - Ready for admission
  • occupied - Currently assigned
  • reserved - Hold for incoming resident
  • maintenance - Out of service
  • blocked - Administratively blocked

2. Resident Management (6 tables)

TableColumnsDescription
rh_resident_profiles36Resident demographic data
rh_resident_agreements18Signed agreements
rh_episodes28Stay episodes (admissions)
rh_episode_phases14Phase progression tracking
rh_episode_programs10Program enrollments
rh_episode_payment_status16Payment tracking
Episode Flow:
Admission → rh_episodes (status: 'active')

rh_episode_phases (phase progression)

Discharge → rh_episodes (status: 'discharged')
Resident Status:
  • active - Currently in residence
  • discharged - Completed/left program
  • transferred - Moved to another facility
  • awol - Absent without leave
  • administrative - Admin discharge

3. Programs & Phases (5 tables)

TableColumnsDescription
rh_programs20Program definitions
rh_program_phases18Phase definitions
rh_phase_milestones14Milestone requirements
rh_phase_privileges12Privilege levels
rh_milestone_completions12Milestone tracking
Typical Phase Structure:
Phase 1: Orientation (Days 1-14)
    - Milestones: House rules quiz, mentor assignment
    - Privileges: Limited passes
    
Phase 2: Foundation (Days 15-60)
    - Milestones: Employment, sponsor
    - Privileges: Extended curfew
    
Phase 3: Independence (Days 61-90)
    - Milestones: Savings goal, treatment compliance
    - Privileges: Overnight passes

4. Daily Operations (5 tables)

TableColumnsDescription
rh_attendance_records14Daily attendance
rh_curfew_checks12Curfew verification
rh_chore_assignments14House chore tracking
rh_passes18Leave pass management
rh_transport_requests16Transportation requests
Pass Types:
  • day_pass - Same-day return
  • overnight_pass - Overnight leave
  • work_pass - Employment-related
  • medical_pass - Medical appointment
  • emergency_pass - Emergency leave

5. Drug Screening (2 tables)

TableColumnsDescription
rh_uds_tests22Drug screen records
rh_uds_random_schedule12Random testing schedule
UDS Result Types:
  • negative - Clean test
  • positive - Detected substances
  • dilute - Invalid sample
  • refused - Test refused
  • missed - No-show for test

6. Medication Management (1 table)

TableColumnsDescription
rh_med_storage_audits16Medication locker audits

7. Significant Events (4 tables)

TableColumnsDescription
rh_significant_events26Incident records
rh_significant_event_types12Event type catalog
rh_significant_event_actions14Follow-up actions
rh_significant_event_investigations18Investigation tracking
Event Categories:
  • behavioral - Rule violations
  • medical - Health incidents
  • safety - Safety concerns
  • positive - Achievements/milestones
  • administrative - Admin events

8. Staff Scheduling (3 tables)

TableColumnsDescription
rh_schedule_templates14Schedule patterns
rh_schedule_instances16Actual schedules
rh_shift_notes12Shift handoff notes

9. Staff Management (2 tables)

TableColumnsDescription
rh_staff_assignments12Staff-to-residence assignments
rh_staff_trainings14Training records

10. Discharge Planning (3 tables)

TableColumnsDescription
rh_discharge_plans22Discharge planning
rh_discharge_checklists14Checklist tracking
rh_discharge_documents12Required documents
Discharge Types:
  • successful_completion - Completed program
  • step_down - Moved to lower level of care
  • step_up - Moved to higher level of care
  • voluntary - Left voluntarily
  • administrative - Admin discharge
  • medical - Medical discharge
  • awol - Left without notice

11. Alumni Engagement (4 tables)

TableColumnsDescription
rh_alumni20Alumni records
rh_alumni_engagement14Engagement activities
rh_follow_up_schedules12Follow-up scheduling
rh_follow_up_contacts16Contact records
Follow-Up Schedule:
  • 30-day post-discharge
  • 60-day post-discharge
  • 90-day post-discharge
  • 6-month post-discharge
  • 12-month post-discharge

12. Outcomes Measurement (5 tables)

TableColumnsDescription
rh_outcome_indicators16Outcome definitions
rh_outcome_measurements14Measurement records
rh_outcome_assessments18Assessment instances
rh_outcome_checkpoints12Checkpoint tracking
rh_participation_metrics14Participation data
Key Outcome Indicators:
  • Sobriety maintenance
  • Employment status
  • Housing stability
  • Treatment engagement
  • Legal compliance
  • Family reunification

13. Referrals (2 tables)

TableColumnsDescription
rh_referrals24Referral records
rh_eligibility_checklists14Eligibility screening

14. Compliance (4 tables)

TableColumnsDescription
rh_compliance_requirements16Requirement definitions
rh_compliance_checklists14Compliance tracking
rh_audit_schedules12Audit scheduling
rh_audit_findings16Audit results

15. Reporting (1 table)

TableColumnsDescription
rh_report_definitions18Custom report configs

16. Module Settings (1 table)

TableColumnsDescription
rh_module_settings30RH configuration
Key Settings:
SettingTypeDefault
default_program_length_daysinteger90
uds_frequency_daysinteger7
curfew_timetime’22:00’
pass_approval_requiredbooleantrue
alumni_follow_up_intervalsinteger[][30,60,90,180,365]

Common Query Patterns

Get Active Residents

const { data } = await supabase
  .from('rh_episodes')
  .select(`
    *,
    resident:rh_resident_profiles(*),
    bed:rh_beds(
      bed_number,
      residence:rh_residences(name)
    ),
    current_phase:rh_episode_phases(
      phase:rh_program_phases(name, level)
    )
  `)
  .eq('status', 'active')
  .eq('organization_id', orgId);

Get Census by Residence

const { data } = await supabase
  .from('rh_census_snapshots')
  .select(`
    *,
    residence:rh_residences(name, capacity)
  `)
  .eq('snapshot_date', today)
  .eq('organization_id', orgId);

Get UDS History

const { data } = await supabase
  .from('rh_uds_tests')
  .select('*')
  .eq('episode_id', episodeId)
  .order('test_date', { ascending: false });

Get Phase Progression

const { data } = await supabase
  .from('rh_episode_phases')
  .select(`
    *,
    phase:rh_program_phases(
      name,
      milestones:rh_phase_milestones(*)
    ),
    completions:rh_milestone_completions(*)
  `)
  .eq('episode_id', episodeId)
  .order('started_at', { ascending: true });

RLS Policies

RH uses role-based RLS:
  • Staff access to assigned residences
  • Manager access to all residences in org
  • Resident self-service for limited data
Helper Functions:
  • rh_user_has_residence_access() - Residence assignment check
  • rh_user_can_view_resident() - Resident data access
  • rh_user_can_modify_episode() - Episode modification

PHI Considerations

Sensitive Fields:
TableFieldsProtection
rh_resident_profilesssn, dob, medicalEncrypted + RLS
rh_uds_testsresults, substancesRLS restricted
rh_significant_eventsdetailsAudit logged

See Also