import type { Patient } from 'fhir/r4'; export type BookingPatientSeed = { patient: Patient; from: 'chart' | 'open-visit' }; /** * The patient a new booking starts on, and why. * * - A chart's Book Appointment names its patient explicitly, so that patient starts picked (deck * practitioner#s-appointments "Booking"). It wins over a visit open on someone else, because the * chart is what the practitioner pressed the button on. * - With no chart, the open visit's own patient, as before. * - With neither, nobody: a wrong guess is a booking on the wrong record. */ export const bookingPatientSeed = ( chartPatient: Patient | undefined, openVisitPatient: Patient | undefined, ): BookingPatientSeed | undefined => { if (chartPatient) return { patient: chartPatient, from: 'chart' }; if (openVisitPatient) return { patient: openVisitPatient, from: 'open-visit' }; return undefined; };