import { Clock4, HousePlus, Stethoscope } from "lucide-react"; import { Appointment } from "fhir/r4"; import { useAuthServiceContext } from "../../../services"; import { formatDateForDisplay, formatTimeForDisplay, getDaysDifference, } from "../../../lib/utils"; import { appointmentSubjectLine } from '../../../utils/appointmentSubject'; import { cancellationExplanation } from '../../../utils/appointmentCancellation'; // Shared appointment display helpers (mirrors the ones inside PatientAppointments, kept local so the workspace // doesn't depend on that patient-portal component). Exported so the list reuses them. export const getAppointmentPractitionerName = ( participants: Appointment["participant"], ): string => { if (!participants) return "Unknown Practitioner"; const practitioner = participants.find( (participant) => participant.actor?.reference?.includes("Practitioner") || participant.type?.[0]?.text === "primary performer", ); return practitioner?.actor?.display || "Unknown Practitioner"; }; export const getAppointmentSpecialty = (appointment: Appointment): string => appointment.specialty?.[0]?.text || appointment.serviceCategory?.[0]?.text || "Practitioner"; // WHAT THE VISIT IS FOR, from the one shared helper - see utils/appointmentSubject. The fallback here // used to name a check-up nobody had booked, on any appointment that carried no type at all. export const getAppointmentVisitType = (appointment: Appointment): string => appointmentSubjectLine(appointment); // Read-only appointment detail for the receptionist workspace modal. Renders IN PLACE (no Sheet / nested Dialog), // so it never nests an overlay inside the workspace Dialog. Cancel / reschedule stay on the Overview's appointment // dialog (the receptionist's real appointment-management surface); this is the glance-and-go read view. export default function WorkspaceAppointmentDetail({ appointment, }: { appointment: Appointment; }) { const { wpOrganization } = useAuthServiceContext(); const start = appointment.start as string; const isBooked = appointment.status === "booked"; const isCancelled = appointment.status === "cancelled"; return (
{isBooked ? "Booking confirmed" : appointment.status || "—"}
{/* The same explanation its row gives: declined or cancelled, with the recorded reason. */} {isCancelled &&

{cancellationExplanation(appointment)}

}

{formatDateForDisplay(start)}

{start && !isCancelled && ( {getDaysDifference(start)} )}

{formatTimeForDisplay(start)}

Practitioner
{getAppointmentPractitionerName(appointment.participant)} ·{" "} {getAppointmentSpecialty(appointment)}
Visit type
{getAppointmentVisitType(appointment)}
Location
{wpOrganization.current?.name || "—"}
Booked on
{formatDateForDisplay((appointment.created as string) || start)}
Practitioner instruction

{(appointment.description as string) || "No instructions provided."}

); }