From 9890559ec14ff1141527976626fad8809b857c0f Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Tue, 21 Apr 2026 11:14:24 +0530 Subject: [PATCH] fix: append IST offset (+05:30) to bare datetime in appointment booking Widget and WhatsApp flows send scheduledAt without timezone offset, causing platform to interpret as UTC (10:00 shows as 3:30 PM IST). Server now appends +05:30 if no timezone indicator present. Also fixed in WhatsApp slot ID generation and widget source. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/messaging/flow/tool-registry.ts | 4 ++-- src/widget/widget.service.ts | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/messaging/flow/tool-registry.ts b/src/messaging/flow/tool-registry.ts index 2d687a3..4bd8300 100644 --- a/src/messaging/flow/tool-registry.ts +++ b/src/messaging/flow/tool-registry.ts @@ -142,7 +142,7 @@ export class ToolRegistry { const sections: ListSection[] = [{ title: targetDate, rows: timeSlots.map(s => ({ - id: `slot:${doctorId}:${targetDate}T${s.time}:00`, + id: `slot:${doctorId}:${targetDate}T${s.time}:00+05:30`, title: s.time, description: s.clinic || undefined, })), @@ -202,7 +202,7 @@ export class ToolRegistry { // Book — include patientId so appointment is linked to patient record const result = await this.platform.query( `mutation($data: AppointmentCreateInput!) { createAppointment(data: $data) { id } }`, - { data: { name: `WhatsApp Booking — ${patientName} (${department})`, scheduledAt, status: 'SCHEDULED', doctorName, department, reasonForVisit: reason ?? 'General Consultation', ...(patientId ? { patientId } : {}) } }, + { data: { name: `WhatsApp Booking — ${patientName} (${department})`, scheduledAt: scheduledAt.includes('+') || scheduledAt.includes('Z') ? scheduledAt : `${scheduledAt}+05:30`, status: 'SCHEDULED', doctorName, department, reasonForVisit: reason ?? 'General Consultation', ...(patientId ? { patientId } : {}) } }, ); const id = result?.createAppointment?.id; if (id) { diff --git a/src/widget/widget.service.ts b/src/widget/widget.service.ts index 5f48fac..bdf2846 100644 --- a/src/widget/widget.service.ts +++ b/src/widget/widget.service.ts @@ -235,7 +235,10 @@ export class WidgetService { `mutation($data: AppointmentCreateInput!) { createAppointment(data: $data) { id } }`, { data: { name: `${req.patientName.trim() || 'Patient'} — ${new Date(req.scheduledAt).toISOString().slice(0, 10)}`, - scheduledAt: req.scheduledAt, + // Ensure IST offset — widget may send bare datetime without timezone + scheduledAt: req.scheduledAt.includes('+') || req.scheduledAt.includes('Z') + ? req.scheduledAt + : `${req.scheduledAt}+05:30`, durationMin: 30, appointmentType: 'CONSULTATION', status: 'SCHEDULED',