feat: enhance new-patient AI chat flow with full scheduling and eligibility
- Add 3-message intro (self-intro → empathetic ack → new/existing question) via single TwiML response to guarantee delivery order - Detect reschedule intent from first message; look up existing appointment date - New patient flow: ask insurance type → MassHealth consent → member ID + DOB → Selenium eligibility check - Post-eligibility: active → ask appointment date/time with office-hours validation; inactive → ask other insurance or collect contact info - Date/time collection mirrors reschedule flow: check office day open, ask time, validate against office hours - Auto-create appointment in schedule for known patients on confirmation; use first available staff member - Add openPhoneReply toggle (Settings → AI Chat) to respond to any number at any time - Add 5-minute inactivity timeout: reset conversation to initial stage and clear pending state - Normalize MassHealth DOB to zero-padded MM/DD/YYYY before Selenium submission - Expand isExistingPatient classifier to recognize "old patient", "old", "previous", "prior" - Existing patient confirmation message now acknowledges patient type before asking about insurance Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ export const AiSettingsAggregateResultSchema = z.object({ _count: z.object({
|
||||
userId: z.number(),
|
||||
apiKey: z.number(),
|
||||
afterHoursEnabled: z.number(),
|
||||
openPhoneReply: z.number(),
|
||||
user: z.number()
|
||||
}).optional(),
|
||||
_sum: z.object({
|
||||
|
||||
@@ -4,5 +4,6 @@ export const AiSettingsCreateResultSchema = z.object({
|
||||
userId: z.number().int(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean(),
|
||||
openPhoneReply: z.boolean(),
|
||||
user: z.unknown()
|
||||
});
|
||||
@@ -4,5 +4,6 @@ export const AiSettingsDeleteResultSchema = z.nullable(z.object({
|
||||
userId: z.number().int(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean(),
|
||||
openPhoneReply: z.boolean(),
|
||||
user: z.unknown()
|
||||
}));
|
||||
@@ -4,5 +4,6 @@ export const AiSettingsFindFirstResultSchema = z.nullable(z.object({
|
||||
userId: z.number().int(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean(),
|
||||
openPhoneReply: z.boolean(),
|
||||
user: z.unknown()
|
||||
}));
|
||||
@@ -5,6 +5,7 @@ export const AiSettingsFindManyResultSchema = z.object({
|
||||
userId: z.number().int(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean(),
|
||||
openPhoneReply: z.boolean(),
|
||||
user: z.unknown()
|
||||
})),
|
||||
pagination: z.object({
|
||||
|
||||
@@ -4,5 +4,6 @@ export const AiSettingsFindUniqueResultSchema = z.nullable(z.object({
|
||||
userId: z.number().int(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean(),
|
||||
openPhoneReply: z.boolean(),
|
||||
user: z.unknown()
|
||||
}));
|
||||
@@ -4,11 +4,13 @@ export const AiSettingsGroupByResultSchema = z.array(z.object({
|
||||
userId: z.number().int(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean(),
|
||||
openPhoneReply: z.boolean(),
|
||||
_count: z.object({
|
||||
id: z.number(),
|
||||
userId: z.number(),
|
||||
apiKey: z.number(),
|
||||
afterHoursEnabled: z.number(),
|
||||
openPhoneReply: z.number(),
|
||||
user: z.number()
|
||||
}).optional(),
|
||||
_sum: z.object({
|
||||
|
||||
@@ -4,5 +4,6 @@ export const AiSettingsUpdateResultSchema = z.nullable(z.object({
|
||||
userId: z.number().int(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean(),
|
||||
openPhoneReply: z.boolean(),
|
||||
user: z.unknown()
|
||||
}));
|
||||
@@ -4,5 +4,6 @@ export const AiSettingsUpsertResultSchema = z.object({
|
||||
userId: z.number().int(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean(),
|
||||
openPhoneReply: z.boolean(),
|
||||
user: z.unknown()
|
||||
});
|
||||
Reference in New Issue
Block a user