Skip to main content
Feature ID: PM-03 Status: 📝 Planned Spec Reference: PM-03-appointment-scheduling.md Version: 1.1 Last Updated: 2026-02-19 Last Verified: N/A (Planned — update to ISO date after Phase 1 deployment) Constitution Reference: §1.3 Integration Patterns, §2.1 Integration documentation

Quick Reference


Integration Points


Event Contracts

All PM-03 events are registered in fw_workflow_events (seeded by migration 20260219124331_...). Publish via publishEvent() from @/platform/events.

Published Events

Canonical Payload: appointment_scheduled

DOC-1 fix: All field names match EVENT_CONTRACTS.md canonical schema — use appointment_id and start_datetime/end_datetime, not entity_id or start_at/end_at.

Canonical Payload: encounter_completed


API / Data Contracts

PM-05: Provider Availability (READ)

Pattern: Direct Supabase query (PM-03 reads pm_provider_schedules owned by PM-05)
Prerequisite: pm_provider_schedules table must exist (PM-05 Phase 1 migration). If not present, double-booking check MUST be stubbed with a TODO: PM-05 comment — do not silently skip.

PF-10: Reminder Delivery (INVOKE)

Pattern: Platform Integration Layer — @/platform/notifications
Fallback: PF-10 failure MUST NOT block appointment CRUD. Wrap in try/catch; log error; set delivery_status = 'failed' in pm_appointment_reminders.

Decision Trees

Appointment Type Decision

Telehealth URL Decision (Phase 1 vs Phase 2)

Recurrence Rule Decision

Double-Booking Prevention


Pre-Flight Checklist

Use this checklist before beginning each PM-03 implementation phase.

Before Phase 1 (Database)

  • PM-05 Phase 1 migration confirmed deployed (pm_provider_schedules exists in DB)
  • pf_has_org_access function confirmed in DB (SELECT proname FROM pg_proc WHERE proname = 'pf_has_org_access')
  • pm_has_org_access function confirmed in DB
  • pm_set_updated_at trigger function confirmed in DB (from PM-01 — do NOT recreate, just reference)
  • fw_workflow_events rows confirmed for all six PM-03 events (migration 20260219124331 applied)
  • pf_module_permissions rows confirmed for pm.scheduling.view, pm.scheduling.override_double_booking
  • appointment_scheduled and encounter_completed present in KnownEventName type (src/platform/events/types.ts)
  • PM_PERMISSIONS.SCHEDULING_VIEW and PM_PERMISSIONS.SCHEDULING_OVERRIDE_DOUBLE_BOOKING present in constants.ts

Before Phase 2 (Hooks & API)

  • All Phase 1 tables confirmed in live DB (pm_appointments, pm_appointment_reminders, pm_waitlist, pm_encounters)
  • FORCE ROW LEVEL SECURITY confirmed on all four tables
  • RLS cross-tenant test passes (org1 cannot read org2 appointments)
  • @/platform/notifications integration pattern confirmed (or PF-10 contract stub documented)

Before Phase 3 (UI)

  • All hooks from Phase 2 returning correct data shapes
  • PF-15 picklist pm_appointment_types seeded with defaults
  • Calendar library selected and installed (recommend @fullcalendar/react or react-big-calendar)
  • Dialog size standards confirmed: Create/Edit = sm:max-w-lg, Waitlist = sm:max-w-md, Reminder/No-show = sm:max-w-sm

Before Phase 4 (Testing & Docs)

  • All RLS tests authored for pm_appointments, pm_appointment_reminders, pm_waitlist, pm_encounters
  • E2E test covers: schedule → confirm → check-in → complete flow
  • Performance tested: schedule view p95 < 1s, creation p95 < 1s, availability search p95 < 2s
  • pm.admin placeholder in /pm/settings route cleaned up (replaced with real permission key)

Common Mistakes



Fallback / Resilience