fix: append IST offset (+05:30) to bare datetime in appointment booking
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

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) <noreply@anthropic.com>
This commit is contained in:
2026-04-21 11:14:24 +05:30
parent 9cb4d1c122
commit 9890559ec1
2 changed files with 6 additions and 3 deletions

View File

@@ -142,7 +142,7 @@ export class ToolRegistry {
const sections: ListSection[] = [{ const sections: ListSection[] = [{
title: targetDate, title: targetDate,
rows: timeSlots.map(s => ({ 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, title: s.time,
description: s.clinic || undefined, description: s.clinic || undefined,
})), })),
@@ -202,7 +202,7 @@ export class ToolRegistry {
// Book — include patientId so appointment is linked to patient record // Book — include patientId so appointment is linked to patient record
const result = await this.platform.query<any>( const result = await this.platform.query<any>(
`mutation($data: AppointmentCreateInput!) { createAppointment(data: $data) { id } }`, `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; const id = result?.createAppointment?.id;
if (id) { if (id) {

View File

@@ -235,7 +235,10 @@ export class WidgetService {
`mutation($data: AppointmentCreateInput!) { createAppointment(data: $data) { id } }`, `mutation($data: AppointmentCreateInput!) { createAppointment(data: $data) { id } }`,
{ data: { { data: {
name: `${req.patientName.trim() || 'Patient'}${new Date(req.scheduledAt).toISOString().slice(0, 10)}`, 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, durationMin: 30,
appointmentType: 'CONSULTATION', appointmentType: 'CONSULTATION',
status: 'SCHEDULED', status: 'SCHEDULED',