> ## 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.

# Participation & Attendance — Integration

> Version: 1.0.0 Last Updated: 2026-03-20 Spec: RH-04 Participation & Attendance Constitution Reference: Section 1.2 (Core Independence), Section 1.3 (Integratio…

**Version:** 1.0.0\
**Last Updated:** 2026-03-20\
**Spec:** [RH-04 Participation & Attendance](../../../specs/rh/specs/RH-04-participation-attendance.md)\
**Constitution Reference:** Section 1.2 (Core Independence), Section 1.3 (Integration Patterns)

***

## Overview

RH-04 manages resident participation tracking, attendance recording, and curfew compliance. It publishes events for attendance threshold breaches and integrates with RH-05 (Discharge Planning) and PF-10 (Notifications).

***

## Integration Points

### Platform Foundation (PF) Dependencies

**Required PF Features:**

* **PF-08 (Forms Integration)**: Excused absence request forms
* **PF-10 (Notifications)**: Attendance warnings, curfew violation alerts

**Integration Type:** Platform Integration Layer (Pattern 1)

### RBAC Dependencies (PF-02)

RH-04 requires these RH-specific roles in the platform RBAC system:

* **`rh_housing_tech`**: Record attendance, assign chores, schedule transport, record curfew checks
* **`rh_house_manager`**: Approve excused absences, view participation metrics, manage daily operations
* **`rh_program_manager`**: View all participation data, generate compliance reports, access program-level metrics

These roles must be defined in PF-02 (RBAC) and enforced via RLS policies using the `rh_has_role()` SECURITY DEFINER function.

### Consumer Core Dependencies (Downstream)

**Internal RH Features:**

* **RH-01 (Episodes)**: Episode records required for attendance tracking
* **RH-02 (Phases)**: Phase data required for curfew time validation
* **RH-03 (Significant Events)**: Curfew violations can trigger significant events
* **RH-05 (Discharge Planning)**: Attendance non-compliance flags linked to discharge planning

***

## Event Contracts

### Event: `rh_attendance_threshold_breached`

**Publisher:** RH (RH-04)\
**Subscribers:** RH-05 (Discharge Planning), PF-10 (Notifications)\
**Status:** 📝 Planned

**Purpose:** Trigger discharge planning, send attendance warnings

**Payload Schema:**

```typescript theme={null}
interface RhAttendanceThresholdBreachedPayload {
  event_type: 'rh_attendance_threshold_breached';
  episode_id: uuid;
  organization_id: uuid;
  attendance_percentage: number;
  threshold: number;
  breach_date: timestamp;
  timestamp: timestamptz;
}
```

***

## Platform Integration Layer Usage

**Consumes:**

* **PF-08 (Forms Integration)**: Excused absence request forms via `@/platform/forms`
* **PF-10 (Notifications)**: Attendance warnings, curfew violation alerts via `@/platform/notifications`

***

## Security Considerations

### Multi-Tenancy

* ✅ **RLS Enforcement**: All `rh_attendance_*` and `rh_participation_*` tables filtered by `organization_id` via RLS policies

### Role-Based Access Control

* ✅ **RH Housing Tech**: Record attendance, assign chores, schedule transport, record curfew checks
* ✅ **RH House Manager**: Approve excused absences, view participation metrics, manage daily operations
* ✅ **RH Program Manager**: View all participation data, generate compliance reports, access program-level metrics

### Data Protection

* ✅ **PII Handling**: Attendance and participation data may contain resident information; access controlled via RLS
* ✅ **Audit Trail**: All attendance and participation changes logged via PF-04

***

## Testing Requirements

* [ ] Event payload structure validation
* [ ] Event fires on trigger condition (attendance threshold breach)
* [ ] Correct `organization_id` included in all events
* [ ] Subscribers handle events correctly (RH-05, PF-10)
* [ ] RLS policies enforce org isolation on attendance and participation queries
* [ ] RBAC roles work correctly for different user types

***

## References

* [RH-04 Spec](../../../specs/rh/specs/RH-04-participation-attendance.md)
* [EVENT\_CONTRACTS.md](./EVENT_CONTRACTS.md)
* [CROSS\_CORE\_INTEGRATIONS.md](./CROSS_CORE_INTEGRATIONS.md)
