Functional contract
Visits and whiteboard
A visit is the on-floor encounter for one patient after arrival. An appointment is only the booking. Every visit comes from checking in an appointment; a walk-in is booked first as an appointment with no patient, then checked in once a patient is chosen.
Domain
| Model | What it is |
|---|---|
Visit | Encounter after arrival. Linked appointment, optional attending staff, optional current room. Code VI-000123 per Organization |
VisitStaff | Staff on the visit (may differ from the booking) |
VisitService | Catalog item (+ optional appointment type) on the visit; each is a sales-order line source |
Charges belong to the Visit. A ready_to_bill card shows Checkout (checkout.manage), which opens or reuses the visit’s home sales order. See Appointment to invoice.
Statuses and place
checked_in → in_room ⇄ waiting → ready_to_bill → completed.
| Status | Place | Meaning |
|---|---|---|
checked_in | Waiting room | Arrived, not seen |
in_room | A room | In any room (exam, treatment, surgery), first time or again |
waiting | Waiting room | Seen, waiting for the next step |
ready_to_bill | Off floor | Care done, waiting for checkout |
completed | Off floor | Closed |
Place is derived (waiting room / a room / off floor), not a column. Illegal pairs are rejected. Room → waiting room sets waiting; waiting room → a room sets in_room. Timestamps: arrived_at, status_changed_at, place_changed_at. There is no “in treatment” status. Room occupancy over the limit warns but still saves.
The Schedule keeps appointment statuses (scheduled, canceled, no-show, checked-in); a checked-in appointment only displays its visit status.
Check-in and undo
| Action | Who | Behavior |
|---|---|---|
| Check-in | visits.manage (API: appointments.manage) | Requires a patient. Materializes a virtual occurrence, requires blocking deposits settled, creates the Visit (checked_in, waiting room, staff and type copied), opens the sales order, auto-charges the type’s catalog item. Idempotent. Redirects to the whiteboard |
| Walk-in | appointments.manage | Book an appointment with no patient (labeled “Walk-In”). No visit-only walk-in; POST /app/visits is removed |
| Undo check-in | visits.manage (API: appointments.manage) | Only while still checked_in in the waiting room. AppointmentUndoCheckIn → Visit#undo_check_in!: unlinks deposits, releases visit-sourced sales lines, destroys the visit (and its emptied order), appointment back to scheduled. Web: whiteboard PATCH /app/visits/:id/undo_check_in or the popover. API: status: "scheduled" |
| Cancel / no-show | appointments.manage | Terminal, no Visit. If checked in and still waiting, undoes the visit first |
Whiteboard
GET /app/whiteboard (visits.read). Query view: floor (default), pipeline, or list. Today’s arrivals plus still-open prior-day visits. /app/flowboard redirects here.
- Floor — Upcoming (today’s scheduled appointments, walk-ins labeled) + waiting room (Arrived and Waiting groups) + rooms. Ready-to-bill and completed hidden.
- Pipeline —
upcoming→checked_in→in_room→waiting→ready_to_bill→completed(hidden by default). Room is a chip. - Upcoming drag — dropping a scheduled appointment checks it in first; a room drop then places it.
- Timers — visit clock since arrival (warn 60, alert 120 min) and time in status (warn 15, alert 30 for Checked in and Waiting).
- Type color — cards use the appointment type color as the left accent.
- List — every visit at the Location, newest first, searchable by code, patient, or client.
Cards expose Open (Visit 360 in the drawer), Checkout when ready, and up to two service chips. Live over Action Cable (ClinicBoardChannel), same as Schedule.
Visit services
Check-in from a typed appointment creates the first service and auto-charges it. Staff add more (Vaccination + Dental + Grooming on one encounter). AppointmentType#clinical marks exam-style types; SOAP is never required for ready-to-bill or checkout.
Visit 360 workspace
GET /app/visits/:id and /app/visits/:id/cockpit (visits.read) share one shell: full page, or the app drawer (app_drawer / embed=1).
- Sticky header — identity, alerts, visit code, status, room, dual timers, service chips, lifecycle stepper.
- Tabs — Overview (services, live estimated total, SOAP summary), Charges, SOAP, Diagnostics, Treatments, Medications, History.
- SOAP — inline note with autosave, apply last visit / templates. Not a billing gate. See SOAP notes.
- Charges — visit sales-order editor (qty, provider, discounts) with unbilled service callouts.
No Patient 360 rail and no sticky checkout CTA: floor moves and Take payment stay on the Whiteboard / Checkout desk.
Home clinic radar
Home complements the Whiteboard; it does not replace it. Web only (not on the staff API; mobile Home stats are sample data).
- Location with
visits.read:ClinicDayRadarKPIs (open visits, ready to bill, long waits), a queue by status with cockpit links, recent completed visits, then SaaS billing widgets. - Location without
visits.read: placeholder stat cards plus SaaS billing widgets. Organization workspace: SaaS widgets only. - Secondary flows (cockpit, checkout / invoice / pay, deposit setup) open in the reusable drawer without leaving the page.
- Home clears the header breadcrumb trail.
RBAC
Location-scoped visits.read / visits.manage. Org admin, location admin, receptionist, and veterinarian may manage. Veterinarian cannot book, cancel, or no-show (appointments.manage) or manage desk checkout (checkout.manage).
Out of scope
Mobile Whiteboard and visit API, visit-only walk-ins, auto no-show, undo after the visit left the waiting room, confirmed status, reminders. Invoices and payments live in Billing.
Full contract: docs/functional/visits.md, home-clinic-radar.md.