Functional contract
Appointments and schedule
Location appointment book at /app/schedule. An appointment is booking intent only: one patient (or none yet for a walk-in), one Location, start/end, optional appointment type, staff, and rooms/equipment. The on-floor encounter is a Visit.
Records
| Model | What it is | Scope |
|---|---|---|
Appointment | Booked slot or series override (RECURRENCE-ID). Status: scheduled, canceled, no-show, checked-in | Location |
AppointmentSeries | Recurring master (RFC 5545 DTSTART + RRULE + duration + EXDATEs) | Location |
AppointmentType | Kind of visit (name, duration, color) linked to a catalog item for billing | Organization |
LocationAppointmentTypeOverride | Sparse Location override for enabled only | Location |
LocationGroupAppointmentTypeOverride | Sparse Location group override for enabled, optionally locking it for the group's Locations | Location group |
AppointmentStaff / AppointmentLocationResource | Optional staff and rooms/equipment | Appointment or series |
Required: location_id, starts_at, ends_at (after start). Optional patient_id (blank = walk-in) and appointment_type_id. Times are stored in UTC and shown in the Location time zone. Occurrences are expanded for the visible range, not pre-created as rows. Booking pickers omit disabled or deceased patients. Overlaps are allowed; staff/resource conflicts, closed hours, and staff off-hours ask for confirmation and still save, then show a warning icon.
Statuses and check-in
Calendar-only statuses: scheduled, canceled, no-show, checked-in. Virtual series slots count as scheduled. Canceled and no-show are terminal and never create a visit.
- Check in sets
checked-inand creates the Visit (idempotent). A walk-in needs a patient first. This is the only way a Visit is created. - Undo check-in (
AppointmentUndoCheckIn) returns the appointment toscheduledand removes the Visit, only while it is stillchecked_inin the waiting room. It releases visit-sourced sales lines and unlinks deposits. - Cancel / no-show on a checked-in appointment undoes the check-in first (same waiting-room rule), then sets the terminal status.
- Check-in, undo, no-show, and restore apply to one occurrence only (virtual slots are materialized first). Cancel honors the series scope.
- The calendar never takes clinical statuses; a checked-in appointment just displays its visit status.
Appointment types
Organization master list at /app/appointment_types (appointmenttypes.read / appointmenttypes.manage). Each type has duration, color, linked catalog item, optional deposit, and a clinical flag (default true; service-forward types like grooming or boarding set false).
- Seeded on provision: Wellness exam 60m, Sick visit 30m, Vaccination 15m, Surgery 60m, Follow up 30m — each linked to a zero-priced Service catalog item. A type can retarget any non-subscription item, including Procedure/Package bundles; price stays on the catalog item.
- Locations inherit enabled through the shared inherit-or-override model:
lock_enabledisnone,locations(“Only location groups can override”), oreverywhere(replaces the old “Lock local overrides” switch, which becameeverywhere). Location overrides byappointmenttypes.override; group overrides (Elite) by Location group admins orappointmenttypes.manage, optionally locking it for the group's Locations. A disabled type is off everywhere. The show page has the same summary line, default view, Manage inheritance drawer, override drawer, and All sites tab as taxes (Editing overrides). - Pickers (web popover, mobile form,
GET /api/v1/scheduleappointment_types) list only types enabled at the booking Location (AppointmentTypes::EffectiveType). - Choosing a type sets the end time from its duration and colors the calendar block (untyped blocks stay brand-toned).
- Deposit: fixed amount (≤ catalog price) or percent. Booking prefills the amount, then staff collect (opens the deposit form) or skip. Blocks show Deposit pending / Deposit paid; a blocking deposit must be paid or waived before check-in. See Billing.
- Delete is blocked while any appointment, series, or visit references the type. The catalog item is not destroyed with it.
Walk-ins
A walk-in is an appointment with no patient yet. Pick Walk-In (no patient yet) in the popover Patient select (header Add → Appointment opens the same popover); mobile offers the same blank option. Calendar blocks, the day list, and the whiteboard Upcoming column label it “Walk-In”.
- Single appointments only: Repeat is hidden and a series still requires a patient.
- Check-in is rejected until staff edit the booking and choose a patient.
- There is no visit-only walk-in.
POST /app/visitsis gone; visits come only from check-in.
Recurrence and delete
Repeat presets: Daily, Weekly, Monthly (same weekday-in-month), Yearly, Every weekday, Custom (interval, weekdays, end never / on date / after N). Editing or canceling an occurrence asks for scope: This only (EXDATE + override), All in series, or This and following (end old rule with UNTIL, start a new series). Checked-in, canceled, and no-show overrides are never changed by a scoped cancel.
Delete is for booking mistakes: only scheduled rows without a Visit, by appointments.manage, audited. Appointments with a live deposit can’t be deleted — cancel or mark no-show so the deposit is invoiced as a fee, kept as credit, refunded, or voided.
Workspace
Views: Staff / Resource (swimlanes) · Day / Week / Month / Year. Query view (default month), date, and slot (15/30/60) on Staff, Resource, Day. Organization scope shows a pick-a-Location placeholder.
| Route | Who | Behavior |
|---|---|---|
GET /app/schedule | appointments.read | Calendar for the workspace Location |
POST /app/appointments | appointments.manage | Create a single appointment or a series |
PATCH /app/appointments/:id, /series_occurrence | appointments.manage | Update; series takes scope this / all / following. Optional status_action |
DELETE /app/appointments/:id, /series_occurrence | appointments.manage | Delete scheduled rows with no Visit |
PATCH /app/appointments/:id/check_in, /check_in_series_occurrence | visits.manage | Check in; redirects to the whiteboard |
PATCH /app/appointments/:id/cancel, /mark_no_show (+ series) | appointments.manage | Terminal status, with deposit retention choice when linked |
Popover status choices (status_action): Check in and Undo check-in (visits.manage), Mark scheduled, Cancel, No-show (appointments.manage). Popover fields: Location, date, times, type, deposit, patient (or Walk-In), staff, repeat. Rooms/equipment are set only through the staff API.
Schedule and Whiteboard refresh live over Action Cable (ClinicBoardChannel). The mobile Schedule reloads over HTTP (pull to refresh) and does not subscribe yet.
Staff API
The mobile Schedule uses the same rules through AppointmentWriter, at the request’s current Location (X-Location-Id or default), behind the schedule plan feature.
| Route | Who | Behavior |
|---|---|---|
GET /api/v1/schedule | appointments.read | Occurrences with conflicts, patients, staffs, resources, enabled appointment_types, can_manage; Year returns day counts |
POST /api/v1/appointments | appointments.manage | Single (patient optional = walk-in) or series (recurrence), with staff_ids and location_resource_ids |
PATCH /api/v1/appointments/:id | appointments.manage | status: "checked_in" checks in; "scheduled" on a checked-in row undoes check-in |
PATCH /api/v1/appointments/series_occurrence | appointments.manage | Same with series_edit_scope; status changes are this-only |
DELETE /api/v1/appointments/:id, /series_occurrence | appointments.manage | Delete; 422 appointment_has_visit when a Visit blocks it |
RBAC
| Role | May |
|---|---|
| Org / location admin, receptionist | Read and manage |
| Veterinarian | Read (cannot book, cancel, or mark no-show) |
Location-scoped appointments.read / appointments.manage. Check-in and undo check-in use visits.manage on the web (API: appointments.manage). Types use appointmenttypes.read / .manage / .override.
Out of scope
Reason, buffers, .ics export, room picking in the web popover, rejecting conflicts or off-hours bookings, auto no-show job. Reminders run from notification settings (AppointmentReminderJob).
Full contract: docs/functional/appointments.md.