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

# Provider Schedule & Availability — Integration

> Feature ID: PM-05 Status: ✅ Complete (shipped 2026-02-20) Spec: PM-05-provider-schedule-availability.md Last Updated: 2026-05-04

**Feature ID:** PM-05\
**Status:** ✅ Complete (shipped 2026-02-20)\
**Spec:** [PM-05-provider-schedule-availability.md](../../../specs/pm/specs/PM-05-provider-schedule-availability.md)\
**Last Updated:** 2026-05-04

***

## Overview

PM-05 provides provider availability templates (recurring weekly), time-off and coverage, caseload tracking, panel status, and schedule conflict detection. It is consumed by PM-03 (appointment scheduling) and PM-04 (group scheduling); boundary with HR-04 (workforce scheduling) is documented only—no shared tables.

***

## Integration Points (from Spec)

| Dependency                     | Pattern    | Purpose                                                                                                            |
| ------------------------------ | ---------- | ------------------------------------------------------------------------------------------------------------------ |
| PM-03 (Appointment scheduling) | Data / API | Appointment scheduling uses provider availability from PM-05                                                       |
| PM-04 (Group scheduling)       | Data / API | Group scheduling uses facilitator availability from PM-05                                                          |
| HR-04 (Workforce scheduling)   | Boundary   | PM-05 does not implement HR employee shifts; HR-04 may consume PM availability for display later; no shared tables |

***

## API / Data Contracts

* **Provider schedules:** `pm_provider_schedules` (organization\_id, provider\_id, location\_id, day\_of\_week, start\_time, end\_time, block\_type, effective\_date, end\_date). Used by PM-03/PM-04 to resolve available slots.
* **Time-off:** `pm_provider_time_off` (organization\_id, provider\_id, start\_date, end\_date, time\_off\_type, coverage\_provider\_id, status). Availability resolution excludes time-off windows.
* **Caseloads:** `pm_provider_caseloads` (organization\_id, provider\_id, active\_patient\_count, max\_caseload, panel\_status). Schedulers use for panel open/closed/limited and over-assignment prevention.

***

## Event Contracts

* **Outbound:**
  * `pm_time_off_requested` — Published when a provider submits a time-off request. Payload: `{ organization_id, provider_id, time_off_id, start_date, end_date, time_off_type }`.
  * `pm_time_off_approved` — Published when time-off is approved. Payload: `{ organization_id, provider_id, time_off_id, approved_by, coverage_provider_id }`.
  * `pm_time_off_denied` — Published when time-off is denied. Payload: `{ organization_id, provider_id, time_off_id, denied_by }`.
* **Inbound:** (To be defined if PM-03/PM-04 or HR-04 need events—e.g. availability\_changed.)
* **Registration:** Events defined in `KnownEventName` (`src/platform/events/types.ts`) and registered in `fw_workflow_events` seed.

***

## Security and RLS

* RLS on `pm_provider_schedules`, `pm_provider_time_off`, `pm_provider_caseloads` with FORCE ROW LEVEL SECURITY. Uses `pm_has_org_access(organization_id, auth.uid())` SECURITY DEFINER helper. UPDATE policies include WITH CHECK (constitution §5.2.4).
* Permission keys (9 granular): `pm.schedule.view/create/edit/delete`, `pm.time_off.view/create/edit/approve`, `pm.caseload.view`.

***

## Related Docs

* [CROSS\_CORE\_INTEGRATIONS.md](./CROSS_CORE_INTEGRATIONS.md)
* [EVENT\_CONTRACTS.md](./EVENT_CONTRACTS.md)
* [API\_CONTRACTS.md](./API_CONTRACTS.md)
