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:
@@ -7,6 +7,7 @@ const makeSchema = () => z.object({
|
||||
userId: z.literal(true).optional(),
|
||||
apiKey: z.literal(true).optional(),
|
||||
afterHoursEnabled: z.literal(true).optional(),
|
||||
openPhoneReply: z.literal(true).optional(),
|
||||
_all: z.literal(true).optional()
|
||||
}).strict();
|
||||
export const AiSettingsCountAggregateInputObjectSchema: z.ZodType<Prisma.AiSettingsCountAggregateInputType> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsCountAggregateInputType>;
|
||||
|
||||
@@ -6,7 +6,8 @@ const makeSchema = () => z.object({
|
||||
id: SortOrderSchema.optional(),
|
||||
userId: SortOrderSchema.optional(),
|
||||
apiKey: SortOrderSchema.optional(),
|
||||
afterHoursEnabled: SortOrderSchema.optional()
|
||||
afterHoursEnabled: SortOrderSchema.optional(),
|
||||
openPhoneReply: SortOrderSchema.optional()
|
||||
}).strict();
|
||||
export const AiSettingsCountOrderByAggregateInputObjectSchema: z.ZodType<Prisma.AiSettingsCountOrderByAggregateInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsCountOrderByAggregateInput>;
|
||||
export const AiSettingsCountOrderByAggregateInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -5,6 +5,7 @@ import { UserCreateNestedOneWithoutAiSettingsInputObjectSchema as UserCreateNest
|
||||
const makeSchema = () => z.object({
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean().optional(),
|
||||
openPhoneReply: z.boolean().optional(),
|
||||
user: z.lazy(() => UserCreateNestedOneWithoutAiSettingsInputObjectSchema)
|
||||
}).strict();
|
||||
export const AiSettingsCreateInputObjectSchema: z.ZodType<Prisma.AiSettingsCreateInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsCreateInput>;
|
||||
|
||||
@@ -6,7 +6,8 @@ const makeSchema = () => z.object({
|
||||
id: z.number().int().optional(),
|
||||
userId: z.number().int(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean().optional()
|
||||
afterHoursEnabled: z.boolean().optional(),
|
||||
openPhoneReply: z.boolean().optional()
|
||||
}).strict();
|
||||
export const AiSettingsCreateManyInputObjectSchema: z.ZodType<Prisma.AiSettingsCreateManyInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsCreateManyInput>;
|
||||
export const AiSettingsCreateManyInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -4,7 +4,8 @@ import type { Prisma } from '../../../generated/prisma';
|
||||
|
||||
const makeSchema = () => z.object({
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean().optional()
|
||||
afterHoursEnabled: z.boolean().optional(),
|
||||
openPhoneReply: z.boolean().optional()
|
||||
}).strict();
|
||||
export const AiSettingsCreateWithoutUserInputObjectSchema: z.ZodType<Prisma.AiSettingsCreateWithoutUserInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsCreateWithoutUserInput>;
|
||||
export const AiSettingsCreateWithoutUserInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -6,7 +6,8 @@ const makeSchema = () => z.object({
|
||||
id: z.literal(true).optional(),
|
||||
userId: z.literal(true).optional(),
|
||||
apiKey: z.literal(true).optional(),
|
||||
afterHoursEnabled: z.literal(true).optional()
|
||||
afterHoursEnabled: z.literal(true).optional(),
|
||||
openPhoneReply: z.literal(true).optional()
|
||||
}).strict();
|
||||
export const AiSettingsMaxAggregateInputObjectSchema: z.ZodType<Prisma.AiSettingsMaxAggregateInputType> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsMaxAggregateInputType>;
|
||||
export const AiSettingsMaxAggregateInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -6,7 +6,8 @@ const makeSchema = () => z.object({
|
||||
id: SortOrderSchema.optional(),
|
||||
userId: SortOrderSchema.optional(),
|
||||
apiKey: SortOrderSchema.optional(),
|
||||
afterHoursEnabled: SortOrderSchema.optional()
|
||||
afterHoursEnabled: SortOrderSchema.optional(),
|
||||
openPhoneReply: SortOrderSchema.optional()
|
||||
}).strict();
|
||||
export const AiSettingsMaxOrderByAggregateInputObjectSchema: z.ZodType<Prisma.AiSettingsMaxOrderByAggregateInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsMaxOrderByAggregateInput>;
|
||||
export const AiSettingsMaxOrderByAggregateInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -6,7 +6,8 @@ const makeSchema = () => z.object({
|
||||
id: z.literal(true).optional(),
|
||||
userId: z.literal(true).optional(),
|
||||
apiKey: z.literal(true).optional(),
|
||||
afterHoursEnabled: z.literal(true).optional()
|
||||
afterHoursEnabled: z.literal(true).optional(),
|
||||
openPhoneReply: z.literal(true).optional()
|
||||
}).strict();
|
||||
export const AiSettingsMinAggregateInputObjectSchema: z.ZodType<Prisma.AiSettingsMinAggregateInputType> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsMinAggregateInputType>;
|
||||
export const AiSettingsMinAggregateInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -6,7 +6,8 @@ const makeSchema = () => z.object({
|
||||
id: SortOrderSchema.optional(),
|
||||
userId: SortOrderSchema.optional(),
|
||||
apiKey: SortOrderSchema.optional(),
|
||||
afterHoursEnabled: SortOrderSchema.optional()
|
||||
afterHoursEnabled: SortOrderSchema.optional(),
|
||||
openPhoneReply: SortOrderSchema.optional()
|
||||
}).strict();
|
||||
export const AiSettingsMinOrderByAggregateInputObjectSchema: z.ZodType<Prisma.AiSettingsMinOrderByAggregateInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsMinOrderByAggregateInput>;
|
||||
export const AiSettingsMinOrderByAggregateInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -12,6 +12,7 @@ const makeSchema = () => z.object({
|
||||
userId: SortOrderSchema.optional(),
|
||||
apiKey: SortOrderSchema.optional(),
|
||||
afterHoursEnabled: SortOrderSchema.optional(),
|
||||
openPhoneReply: SortOrderSchema.optional(),
|
||||
_count: z.lazy(() => AiSettingsCountOrderByAggregateInputObjectSchema).optional(),
|
||||
_avg: z.lazy(() => AiSettingsAvgOrderByAggregateInputObjectSchema).optional(),
|
||||
_max: z.lazy(() => AiSettingsMaxOrderByAggregateInputObjectSchema).optional(),
|
||||
|
||||
@@ -8,6 +8,7 @@ const makeSchema = () => z.object({
|
||||
userId: SortOrderSchema.optional(),
|
||||
apiKey: SortOrderSchema.optional(),
|
||||
afterHoursEnabled: SortOrderSchema.optional(),
|
||||
openPhoneReply: SortOrderSchema.optional(),
|
||||
user: z.lazy(() => UserOrderByWithRelationInputObjectSchema).optional()
|
||||
}).strict();
|
||||
export const AiSettingsOrderByWithRelationInputObjectSchema: z.ZodType<Prisma.AiSettingsOrderByWithRelationInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsOrderByWithRelationInput>;
|
||||
|
||||
@@ -11,7 +11,8 @@ const aisettingsscalarwherewithaggregatesinputSchema = z.object({
|
||||
id: z.union([z.lazy(() => IntWithAggregatesFilterObjectSchema), z.number().int()]).optional(),
|
||||
userId: z.union([z.lazy(() => IntWithAggregatesFilterObjectSchema), z.number().int()]).optional(),
|
||||
apiKey: z.union([z.lazy(() => StringWithAggregatesFilterObjectSchema), z.string()]).optional(),
|
||||
afterHoursEnabled: z.union([z.lazy(() => BoolWithAggregatesFilterObjectSchema), z.boolean()]).optional()
|
||||
afterHoursEnabled: z.union([z.lazy(() => BoolWithAggregatesFilterObjectSchema), z.boolean()]).optional(),
|
||||
openPhoneReply: z.union([z.lazy(() => BoolWithAggregatesFilterObjectSchema), z.boolean()]).optional()
|
||||
}).strict();
|
||||
export const AiSettingsScalarWhereWithAggregatesInputObjectSchema: z.ZodType<Prisma.AiSettingsScalarWhereWithAggregatesInput> = aisettingsscalarwherewithaggregatesinputSchema as unknown as z.ZodType<Prisma.AiSettingsScalarWhereWithAggregatesInput>;
|
||||
export const AiSettingsScalarWhereWithAggregatesInputObjectZodSchema = aisettingsscalarwherewithaggregatesinputSchema;
|
||||
|
||||
@@ -7,6 +7,7 @@ const makeSchema = () => z.object({
|
||||
userId: z.boolean().optional(),
|
||||
apiKey: z.boolean().optional(),
|
||||
afterHoursEnabled: z.boolean().optional(),
|
||||
openPhoneReply: z.boolean().optional(),
|
||||
user: z.union([z.boolean(), z.lazy(() => UserArgsObjectSchema)]).optional()
|
||||
}).strict();
|
||||
export const AiSettingsSelectObjectSchema: z.ZodType<Prisma.AiSettingsSelect> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsSelect>;
|
||||
|
||||
@@ -6,7 +6,8 @@ const makeSchema = () => z.object({
|
||||
id: z.number().int().optional(),
|
||||
userId: z.number().int(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean().optional()
|
||||
afterHoursEnabled: z.boolean().optional(),
|
||||
openPhoneReply: z.boolean().optional()
|
||||
}).strict();
|
||||
export const AiSettingsUncheckedCreateInputObjectSchema: z.ZodType<Prisma.AiSettingsUncheckedCreateInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsUncheckedCreateInput>;
|
||||
export const AiSettingsUncheckedCreateInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -5,7 +5,8 @@ import type { Prisma } from '../../../generated/prisma';
|
||||
const makeSchema = () => z.object({
|
||||
id: z.number().int().optional(),
|
||||
apiKey: z.string(),
|
||||
afterHoursEnabled: z.boolean().optional()
|
||||
afterHoursEnabled: z.boolean().optional(),
|
||||
openPhoneReply: z.boolean().optional()
|
||||
}).strict();
|
||||
export const AiSettingsUncheckedCreateWithoutUserInputObjectSchema: z.ZodType<Prisma.AiSettingsUncheckedCreateWithoutUserInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsUncheckedCreateWithoutUserInput>;
|
||||
export const AiSettingsUncheckedCreateWithoutUserInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -8,7 +8,8 @@ const makeSchema = () => z.object({
|
||||
id: z.union([z.number().int(), z.lazy(() => IntFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
userId: z.union([z.number().int(), z.lazy(() => IntFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
apiKey: z.union([z.string(), z.lazy(() => StringFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional()
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
openPhoneReply: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional()
|
||||
}).strict();
|
||||
export const AiSettingsUncheckedUpdateInputObjectSchema: z.ZodType<Prisma.AiSettingsUncheckedUpdateInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsUncheckedUpdateInput>;
|
||||
export const AiSettingsUncheckedUpdateInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -8,7 +8,8 @@ const makeSchema = () => z.object({
|
||||
id: z.union([z.number().int(), z.lazy(() => IntFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
userId: z.union([z.number().int(), z.lazy(() => IntFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
apiKey: z.union([z.string(), z.lazy(() => StringFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional()
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
openPhoneReply: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional()
|
||||
}).strict();
|
||||
export const AiSettingsUncheckedUpdateManyInputObjectSchema: z.ZodType<Prisma.AiSettingsUncheckedUpdateManyInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsUncheckedUpdateManyInput>;
|
||||
export const AiSettingsUncheckedUpdateManyInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -7,7 +7,8 @@ import { BoolFieldUpdateOperationsInputObjectSchema as BoolFieldUpdateOperations
|
||||
const makeSchema = () => z.object({
|
||||
id: z.union([z.number().int(), z.lazy(() => IntFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
apiKey: z.union([z.string(), z.lazy(() => StringFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional()
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
openPhoneReply: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional()
|
||||
}).strict();
|
||||
export const AiSettingsUncheckedUpdateWithoutUserInputObjectSchema: z.ZodType<Prisma.AiSettingsUncheckedUpdateWithoutUserInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsUncheckedUpdateWithoutUserInput>;
|
||||
export const AiSettingsUncheckedUpdateWithoutUserInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -7,6 +7,7 @@ import { UserUpdateOneRequiredWithoutAiSettingsNestedInputObjectSchema as UserUp
|
||||
const makeSchema = () => z.object({
|
||||
apiKey: z.union([z.string(), z.lazy(() => StringFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
openPhoneReply: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
user: z.lazy(() => UserUpdateOneRequiredWithoutAiSettingsNestedInputObjectSchema).optional()
|
||||
}).strict();
|
||||
export const AiSettingsUpdateInputObjectSchema: z.ZodType<Prisma.AiSettingsUpdateInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsUpdateInput>;
|
||||
|
||||
@@ -5,7 +5,8 @@ import { BoolFieldUpdateOperationsInputObjectSchema as BoolFieldUpdateOperations
|
||||
|
||||
const makeSchema = () => z.object({
|
||||
apiKey: z.union([z.string(), z.lazy(() => StringFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional()
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
openPhoneReply: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional()
|
||||
}).strict();
|
||||
export const AiSettingsUpdateManyMutationInputObjectSchema: z.ZodType<Prisma.AiSettingsUpdateManyMutationInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsUpdateManyMutationInput>;
|
||||
export const AiSettingsUpdateManyMutationInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -5,7 +5,8 @@ import { BoolFieldUpdateOperationsInputObjectSchema as BoolFieldUpdateOperations
|
||||
|
||||
const makeSchema = () => z.object({
|
||||
apiKey: z.union([z.string(), z.lazy(() => StringFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional()
|
||||
afterHoursEnabled: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional(),
|
||||
openPhoneReply: z.union([z.boolean(), z.lazy(() => BoolFieldUpdateOperationsInputObjectSchema)]).optional()
|
||||
}).strict();
|
||||
export const AiSettingsUpdateWithoutUserInputObjectSchema: z.ZodType<Prisma.AiSettingsUpdateWithoutUserInput> = makeSchema() as unknown as z.ZodType<Prisma.AiSettingsUpdateWithoutUserInput>;
|
||||
export const AiSettingsUpdateWithoutUserInputObjectZodSchema = makeSchema();
|
||||
|
||||
@@ -14,6 +14,7 @@ const aisettingswhereinputSchema = z.object({
|
||||
userId: z.union([z.lazy(() => IntFilterObjectSchema), z.number().int()]).optional(),
|
||||
apiKey: z.union([z.lazy(() => StringFilterObjectSchema), z.string()]).optional(),
|
||||
afterHoursEnabled: z.union([z.lazy(() => BoolFilterObjectSchema), z.boolean()]).optional(),
|
||||
openPhoneReply: z.union([z.lazy(() => BoolFilterObjectSchema), z.boolean()]).optional(),
|
||||
user: z.union([z.lazy(() => UserScalarRelationFilterObjectSchema), z.lazy(() => UserWhereInputObjectSchema)]).optional()
|
||||
}).strict();
|
||||
export const AiSettingsWhereInputObjectSchema: z.ZodType<Prisma.AiSettingsWhereInput> = aisettingswhereinputSchema as unknown as z.ZodType<Prisma.AiSettingsWhereInput>;
|
||||
|
||||
Reference in New Issue
Block a user