diff --git a/src/components/call-desk/appointment-form.tsx b/src/components/call-desk/appointment-form.tsx index 8495b9d..1a9c887 100644 --- a/src/components/call-desk/appointment-form.tsx +++ b/src/components/call-desk/appointment-form.tsx @@ -297,6 +297,7 @@ export const AppointmentForm = ({ doctorId: doctor, reasonForVisit: chiefComplaint || null, ...(resolvedPatientId ? { patientId: resolvedPatientId } : {}), + ...(clinic ? { clinicId: clinic } : {}), }, }, ); diff --git a/src/pages/appointments.tsx b/src/pages/appointments.tsx index 9ee193a..e357fc5 100644 --- a/src/pages/appointments.tsx +++ b/src/pages/appointments.tsx @@ -27,8 +27,11 @@ type AppointmentRecord = { fullName: { firstName: string; lastName: string } | null; phones: { primaryPhoneNumber: string } | null; } | null; + clinic: { + clinicName: string; + } | null; doctor: { - clinic: { clinicName: string } | null; + id: string; } | null; }; @@ -58,7 +61,8 @@ const QUERY = `{ appointments(first: 100, orderBy: [{ scheduledAt: DescNullsLast id scheduledAt durationMin appointmentType status doctorName department reasonForVisit patient { id fullName { firstName lastName } phones { primaryPhoneNumber } } - doctor { id clinic { clinicName } } + clinic { clinicName } + doctor { id } } } } }`; const formatDate = (iso: string): string => formatDateOnly(iso); @@ -103,7 +107,7 @@ export const AppointmentsPage = () => { const phone = a.patient?.phones?.primaryPhoneNumber ?? ''; const doctor = (a.doctorName ?? '').toLowerCase(); const dept = (a.department ?? '').toLowerCase(); - const branch = (a.doctor?.clinic?.clinicName ?? '').toLowerCase(); + const branch = (a.clinic?.clinicName ?? '').toLowerCase(); return patientName.includes(q) || phone.includes(q) || doctor.includes(q) || dept.includes(q) || branch.includes(q); }); } @@ -177,7 +181,7 @@ export const AppointmentsPage = () => { ? `${appt.patient.fullName?.firstName ?? ''} ${appt.patient.fullName?.lastName ?? ''}`.trim() || 'Unknown' : 'Unknown'; const phone = appt.patient?.phones?.primaryPhoneNumber ?? ''; - const branch = appt.doctor?.clinic?.clinicName ?? '—'; + const branch = appt.clinic?.clinicName ?? '—'; const statusLabel = STATUS_LABELS[appt.status ?? ''] ?? appt.status ?? '—'; const statusColor = STATUS_COLORS[appt.status ?? ''] ?? 'gray';