import type { Appointment } from 'fhir/r4'; /** * HAS THE PRACTICE AGREED TO THIS APPOINTMENT YET? * * A booking made under review mode comes back `pending`, and one made under request-only comes back * `proposed`. Neither is a visit the practice has accepted; both are a time the patient asked for and * is holding while somebody looks. * * MEASURED 2026-09-15, booking as a patient at a practice in review mode. The receipt said "Until then * it shows as pending on your appointments." It did not: the appointments row printed the day, date, * time and location with no status at all, and the home card read "Next appointment", so the only place * the state existed was inside the detail panel nobody has a reason to open. * * WHY THAT IS WORSE THAN AN OMISSION. The whole point of review mode is that the practice can move or * refuse the time. A patient who reads "Next appointment" has been told it was agreed, and turns up. * The absence of a marker is carrying the message that the appointment is confirmed, which is the * convention against letting a screen speak by showing nothing. * * ONE PREDICATE, so a row, a card and a panel cannot disagree about the same appointment. */ const AWAITING: ReadonlySet> = new Set([ // Review mode: the slot is held and staff have to approve it. 'pending', // Request-only: the patient has asked, and nothing is held until staff turn it into a booking. 'proposed', ]); export const isAwaitingPractice = (appointment: Appointment | undefined): boolean => Boolean(appointment?.status && AWAITING.has(appointment.status)); /** * The short marker a row or a card carries, in the patient's words rather than the resource's. * * "Pending" alone is the status field read aloud, and it does not say pending on WHAT. What a patient * needs to know is that somebody else still has to say yes. */ export const AWAITING_PRACTICE_LABEL = 'Waiting for the practice to confirm'; /** * The sentence the detail panel leads with, which has room to say what happens next. * * It replaces a band that printed the raw status word in the same green the confirmed state uses - so * the one screen that did carry the state was colouring it as though the practice had agreed. */ export const AWAITING_PRACTICE_SENTENCE = 'Waiting for the practice to confirm. Your time is held until they do, and they will let you know.';