import type { Appointment } from 'fhir/r4'; /** The line across the top of a past visit's details: what actually happened to it. */ export const pastAppointmentBand = (status: Appointment['status'] | undefined): string => { switch (status) { case 'cancelled': return 'Appointment cancelled'; case 'noshow': return 'Missed appointment'; case 'fulfilled': case 'arrived': case 'checked-in': return 'Appointment completed'; default: return 'Past appointment'; } }; /** The patient's own words for why they booked, when they gave any. */ export const bookingReasonOf = (appointment: Appointment): string | undefined => appointment.reasonCode?.map((reason) => reason.text?.trim()).find((text): text is string => Boolean(text));