From 642911fa6c5432774488482c7d80d55e54d2f29d Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Mon, 13 Apr 2026 14:38:11 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20appointment=20clinic=20relation=20?= =?UTF-8?q?=E2=80=94=20save=20clinicId,=20query=20clinic.clinicName=20for?= =?UTF-8?q?=20branch=20column?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/call-desk/appointment-form.tsx | 1 + src/pages/appointments.tsx | 12 ++++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) 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';