import type { Appointment } from 'fhir/r4'; /** * IS OPENING THIS APPOINTMENT A PLACEMENT RATHER THAN AN EDIT? * * A request-only practice on the "preferred days & times" variant takes requests that name no * practitioner: the patient gives a reason and their general availability, and the PRACTICE decides * who they see and when. Everything that opens such a request is doing a different job from editing a * booking that already has a practitioner and a time. * * SHARED BECAUSE THREE SURFACES HAVE TO AGREE ABOUT IT. The booking form titles itself from this, and * the two dialogs that host it name themselves from it for a screen reader. Answering it in three * places is how a dialog comes to be announced as "Edit Appointment" while it reads "Place * Appointment" on screen - which is the same defect the visible copy already had, one layer down and * only audible to the people who cannot see the correction. */ export const isAppointmentPlacement = (appointment?: Appointment): boolean => { if (!appointment?.id) return false; return !appointment.participant?.some((participant) => participant.actor?.reference?.startsWith('Practitioner/') || participant.actor?.reference?.startsWith('PractitionerRole/'), ); };