Files
DentalManagement09/packages/db/usedSchemas/browser.ts
T
GiteadandClaude Opus 5.5 de33325b03 feat: secondary insurance; SCO primary + MassHealth secondary rule; United SCO service history
- Patient: new secondaryInsuranceProvider / secondaryInsuranceId (form section,
  Patient Details, merge fill)
- MassHealth check on an SCO patient (Tufts SCO / United SCO primary), matched by
  MassHealth ID on file as secondary or by the single SCO patient with the same DOB
  (name must share a word when the portal returns one): MassHealth saved as secondary,
  primary plan/ID/status unchanged, MassHealth history not imported, PDF still saved
  to Eligibility documents. Prevents the name+DOB fallback from overwriting the SCO ID
- United SCO check: a MassHealth patient moved to United SCO keeps the old
  MassHealth ID as secondary; reads Dental Hub Service History and saves it
- Service history saves drop duplicate identical lines
- Chatbot: bare 100… member ID + DOB with no patient/insurance defaults to MassHealth

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-06 00:22:22 -05:00

283 lines
9.0 KiB
TypeScript

import * as z from "zod";
// ─── Enums ────────────────────────────────────────────────────────────────────
export const PatientStatusSchema = z.enum(["ACTIVE", "INACTIVE", "UNKNOWN", "PLAN_NOT_ACCEPTED", "ACTIVE_PLAN_NOT_ACCEPTED"]);
export type PatientStatus = z.infer<typeof PatientStatusSchema>;
export const ClaimStatusSchema = z.enum([
"PENDING",
"APPROVED",
"CANCELLED",
"REVIEW",
"VOID",
]);
export type ClaimStatus = z.infer<typeof ClaimStatusSchema>;
export const PaymentMethodSchema = z.enum([
"EFT",
"CHECK",
"CASH",
"CARD",
"OTHER",
]);
export type PaymentMethod = z.infer<typeof PaymentMethodSchema>;
export const PaymentStatusSchema = z.enum([
"PENDING",
"PARTIALLY_PAID",
"PAID",
"OVERPAID",
"DENIED",
"VOID",
]);
export type PaymentStatus = z.infer<typeof PaymentStatusSchema>;
export const NotificationTypesSchema = z.enum([
"BACKUP",
"CLAIM",
"PAYMENT",
"ETC",
]);
export type NotificationTypes = z.infer<typeof NotificationTypesSchema>;
export const ProcedureSourceSchema = z.enum(["COMBO", "MANUAL"]);
export type ProcedureSource = z.infer<typeof ProcedureSourceSchema>;
export const PdfTitleKeySchema = z.enum([
"INSURANCE_CLAIM",
"INSURANCE_CLAIM_PREAUTH",
"ELIGIBILITY_STATUS",
"CLAIM_STATUS",
"OTHER",
]);
export type PdfTitleKey = z.infer<typeof PdfTitleKeySchema>;
export const CommunicationChannelSchema = z.enum(["sms", "voice"]);
export type CommunicationChannel = z.infer<typeof CommunicationChannelSchema>;
export const CommunicationDirectionSchema = z.enum(["outbound", "inbound"]);
export type CommunicationDirection = z.infer<
typeof CommunicationDirectionSchema
>;
export const CommunicationStatusSchema = z.enum([
"queued",
"sent",
"delivered",
"failed",
"completed",
"busy",
"no_answer",
]);
export type CommunicationStatus = z.infer<typeof CommunicationStatusSchema>;
// ─── Object Schemas ───────────────────────────────────────────────────────────
export const UserUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
username: z.string(),
password: z.string(),
});
export const PatientUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
firstName: z.string(),
lastName: z.string(),
dateOfBirth: z.string(),
gender: z.string().optional().nullable(),
phone: z.string().optional().nullable(),
email: z.string().optional().nullable(),
address: z.string().optional().nullable(),
city: z.string().optional().nullable(),
state: z.string().optional().nullable(),
zipCode: z.string().optional().nullable(),
insuranceProvider: z.string().optional().nullable(),
insuranceId: z.string().optional().nullable(),
groupNumber: z.string().optional().nullable(),
policyHolder: z.string().optional().nullable(),
policyHolderPatientId: z.number().int().optional().nullable(),
policyHolderRelationship: z.string().optional().nullable(),
secondaryInsuranceProvider: z.string().optional().nullable(),
secondaryInsuranceId: z.string().optional().nullable(),
allergies: z.string().optional().nullable(),
medicalConditions: z.string().optional().nullable(),
preferredLanguage: z.string().optional().nullable(),
status: PatientStatusSchema.optional(),
userId: z.number().int().optional(),
createdAt: z.coerce.date().optional(),
});
export const StaffUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
firstName: z.string(),
lastName: z.string(),
role: z.string(),
phone: z.string().optional(),
email: z.string().optional(),
userId: z.number().int().optional(),
});
export const AppointmentUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
patientId: z.number().int(),
userId: z.number().int().optional(),
staffId: z.number().int().optional(),
npiProviderId: z.number().int().optional().nullable(),
title: z.string().optional(),
date: z.coerce.date(),
startTime: z.string(),
endTime: z.string(),
type: z.string(),
status: z
.enum(["scheduled", "confirmed", "completed", "cancelled", "no-show"])
.optional(),
notes: z.string().optional(),
});
export const AppointmentProcedureUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
appointmentId: z.number().int(),
patientId: z.number().int(),
procedureCode: z.string(),
procedureLabel: z.string().optional().nullable(),
fee: z.number().optional().nullable(),
category: z.string().optional().nullable(),
toothNumber: z.string().optional().nullable(),
toothSurface: z.string().optional().nullable(),
oralCavityArea: z.string().optional().nullable(),
source: ProcedureSourceSchema.optional(),
comboKey: z.string().optional().nullable(),
createdAt: z.coerce.date().optional(),
});
export const NpiProviderUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
userId: z.number().int(),
npiNumber: z.string(),
providerName: z.string(),
createdAt: z.coerce.date().optional(),
});
export const ClaimUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
patientId: z.number().int(),
appointmentId: z.number().int().optional(),
status: ClaimStatusSchema.optional(),
submittedAt: z.string().optional(),
paidAt: z.string().optional(),
amount: z.number().optional(),
insuranceId: z.string().optional(),
});
export const InsuranceCredentialUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
userId: z.number().int(),
siteKey: z.string(),
username: z.string(),
password: z.string(),
});
export const PdfFileUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
filename: z.string(),
pdfData: z.instanceof(Uint8Array),
uploadedAt: z.coerce.date().optional(),
groupId: z.number().int(),
});
export const PdfGroupUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
title: z.string(),
titleKey: PdfTitleKeySchema.optional(),
createdAt: z.coerce.date().optional(),
patientId: z.number().int(),
});
export const PaymentUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
patientId: z.number().int(),
appointmentId: z.number().int().optional(),
amount: z.number(),
method: PaymentMethodSchema.optional(),
status: PaymentStatusSchema.optional(),
paymentDate: z.string().optional(),
updatedById: z.number().int().optional(),
});
export const ServiceLineTransactionCreateInputObjectSchema = z.object({
transactionId: z.string().optional().nullable(),
paidAmount: z.number(),
adjustedAmount: z.number().optional(),
method: PaymentMethodSchema,
receivedDate: z.coerce.date(),
payerName: z.string().optional().nullable(),
notes: z.string().optional().nullable(),
createdAt: z.coerce.date().optional(),
});
export const NotificationUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
userId: z.number().int(),
type: NotificationTypesSchema,
message: z.string(),
createdAt: z.coerce.date().optional(),
read: z.boolean().optional(),
});
export const DatabaseBackupUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
userId: z.number().int(),
createdAt: z.coerce.date().optional(),
});
export const BackupDestinationUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
userId: z.number().int(),
path: z.string(),
isActive: z.boolean().optional(),
createdAt: z.coerce.date().optional(),
});
export const CloudFolderUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
userId: z.number().int(),
name: z.string(),
parentId: z.number().int().optional().nullable(),
createdAt: z.coerce.date().optional(),
});
export const CloudFileUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
userId: z.number().int(),
name: z.string(),
mimeType: z.string().optional().nullable(),
fileSize: z.bigint(),
folderId: z.number().int().optional().nullable(),
isComplete: z.boolean().optional(),
totalChunks: z.number().int().optional().nullable(),
createdAt: z.coerce.date().optional(),
});
export const CommunicationUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
patientId: z.number().int(),
userId: z.number().int().optional().nullable(),
channel: CommunicationChannelSchema,
direction: CommunicationDirectionSchema,
status: CommunicationStatusSchema,
body: z.string().optional().nullable(),
callDuration: z.number().int().optional().nullable(),
twilioSid: z.string().optional().nullable(),
createdAt: z.coerce.date().optional(),
});
export const ShoppingVendorUncheckedCreateInputObjectSchema = z.object({
id: z.number().int().optional(),
userId: z.number().int(),
vendorName: z.string(),
websiteUrl: z.string(),
loginUsername: z.string(),
loginPassword: z.string(),
});