Files
DentalManagementMH06/packages/db/shared/schemas/objects/PaymentWhereInput.schema.ts
Gitead e26ebf7fd5 feat: fix DDMA eligibility — patient list, name extraction, PDF page, OTP session
- Filter patient list by userId so each user sees only their own patients
- Sort patients by updatedAt DESC so recently checked patients appear first
- Add updatedAt field to Patient model (DB migration via raw SQL + db:generate)
- Fix DDMA name extraction: read from detail page "Name:" label, not search
  results row text which included appended dates
- Fix PDF capture: use driver.get() instead of click() to avoid race condition
  that was saving the search results page instead of the patient detail page
- Strip trailing bare dates from extracted names (e.g. "Rodriguez 04/27/2026")
- Handle "Last, First" comma format and single-word last names in splitName
- Normalize insuranceId consistently in createOrUpdatePatientByInsuranceId
- Fix OTP persistent session: stop clearing LocalStorage/IndexedDB on startup
  (these hold the DDMA device trust token that skips OTP on subsequent logins)
- Increase post-navigation wait time for full page render before PDF generation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-01 21:40:04 -04:00

80 lines
5.2 KiB
TypeScript

import * as z from 'zod';
import type { Prisma } from '../../../generated/prisma';
import { IntFilterObjectSchema as IntFilterObjectSchema } from './IntFilter.schema';
import { IntNullableFilterObjectSchema as IntNullableFilterObjectSchema } from './IntNullableFilter.schema';
import { DecimalFilterObjectSchema as DecimalFilterObjectSchema } from './DecimalFilter.schema';
import { EnumPaymentStatusFilterObjectSchema as EnumPaymentStatusFilterObjectSchema } from './EnumPaymentStatusFilter.schema';
import { PaymentStatusSchema } from '../enums/PaymentStatus.schema';
import { StringNullableFilterObjectSchema as StringNullableFilterObjectSchema } from './StringNullableFilter.schema';
import { DateTimeFilterObjectSchema as DateTimeFilterObjectSchema } from './DateTimeFilter.schema';
import { ClaimNullableScalarRelationFilterObjectSchema as ClaimNullableScalarRelationFilterObjectSchema } from './ClaimNullableScalarRelationFilter.schema';
import { ClaimWhereInputObjectSchema as ClaimWhereInputObjectSchema } from './ClaimWhereInput.schema';
import { PatientScalarRelationFilterObjectSchema as PatientScalarRelationFilterObjectSchema } from './PatientScalarRelationFilter.schema';
import { PatientWhereInputObjectSchema as PatientWhereInputObjectSchema } from './PatientWhereInput.schema';
import { UserNullableScalarRelationFilterObjectSchema as UserNullableScalarRelationFilterObjectSchema } from './UserNullableScalarRelationFilter.schema';
import { UserWhereInputObjectSchema as UserWhereInputObjectSchema } from './UserWhereInput.schema';
import { ServiceLineTransactionListRelationFilterObjectSchema as ServiceLineTransactionListRelationFilterObjectSchema } from './ServiceLineTransactionListRelationFilter.schema';
import { ServiceLineListRelationFilterObjectSchema as ServiceLineListRelationFilterObjectSchema } from './ServiceLineListRelationFilter.schema'
import { DecimalJSLikeSchema, isValidDecimalInput } from '../../helpers/decimal-helpers';
import Decimal from "decimal.js";
const paymentwhereinputSchema = z.object({
AND: z.union([z.lazy(() => PaymentWhereInputObjectSchema), z.lazy(() => PaymentWhereInputObjectSchema).array()]).optional(),
OR: z.lazy(() => PaymentWhereInputObjectSchema).array().optional(),
NOT: z.union([z.lazy(() => PaymentWhereInputObjectSchema), z.lazy(() => PaymentWhereInputObjectSchema).array()]).optional(),
id: z.union([z.lazy(() => IntFilterObjectSchema), z.number().int()]).optional(),
claimId: z.union([z.lazy(() => IntNullableFilterObjectSchema), z.number().int()]).optional().nullable(),
patientId: z.union([z.lazy(() => IntFilterObjectSchema), z.number().int()]).optional(),
userId: z.union([z.lazy(() => IntFilterObjectSchema), z.number().int()]).optional(),
updatedById: z.union([z.lazy(() => IntNullableFilterObjectSchema), z.number().int()]).optional().nullable(),
totalBilled: z.union([z.lazy(() => DecimalFilterObjectSchema), z.union([
z.number(),
z.string(),
z.instanceof(Decimal),
z.instanceof(Decimal),
DecimalJSLikeSchema,
]).refine((v) => isValidDecimalInput(v), {
message: "Field 'totalBilled' must be a Decimal",
})]).optional(),
totalPaid: z.union([z.lazy(() => DecimalFilterObjectSchema), z.union([
z.number(),
z.string(),
z.instanceof(Decimal),
z.instanceof(Decimal),
DecimalJSLikeSchema,
]).refine((v) => isValidDecimalInput(v), {
message: "Field 'totalPaid' must be a Decimal",
})]).optional(),
totalAdjusted: z.union([z.lazy(() => DecimalFilterObjectSchema), z.union([
z.number(),
z.string(),
z.instanceof(Decimal),
z.instanceof(Decimal),
DecimalJSLikeSchema,
]).refine((v) => isValidDecimalInput(v), {
message: "Field 'totalAdjusted' must be a Decimal",
})]).optional(),
totalDue: z.union([z.lazy(() => DecimalFilterObjectSchema), z.union([
z.number(),
z.string(),
z.instanceof(Decimal),
z.instanceof(Decimal),
DecimalJSLikeSchema,
]).refine((v) => isValidDecimalInput(v), {
message: "Field 'totalDue' must be a Decimal",
})]).optional(),
status: z.union([z.lazy(() => EnumPaymentStatusFilterObjectSchema), PaymentStatusSchema]).optional(),
notes: z.union([z.lazy(() => StringNullableFilterObjectSchema), z.string()]).optional().nullable(),
icn: z.union([z.lazy(() => StringNullableFilterObjectSchema), z.string()]).optional().nullable(),
createdAt: z.union([z.lazy(() => DateTimeFilterObjectSchema), z.coerce.date()]).optional(),
updatedAt: z.union([z.lazy(() => DateTimeFilterObjectSchema), z.coerce.date()]).optional(),
claim: z.union([z.lazy(() => ClaimNullableScalarRelationFilterObjectSchema), z.lazy(() => ClaimWhereInputObjectSchema)]).optional(),
patient: z.union([z.lazy(() => PatientScalarRelationFilterObjectSchema), z.lazy(() => PatientWhereInputObjectSchema)]).optional(),
updatedBy: z.union([z.lazy(() => UserNullableScalarRelationFilterObjectSchema), z.lazy(() => UserWhereInputObjectSchema)]).optional(),
serviceLineTransactions: z.lazy(() => ServiceLineTransactionListRelationFilterObjectSchema).optional(),
serviceLines: z.lazy(() => ServiceLineListRelationFilterObjectSchema).optional()
}).strict();
export const PaymentWhereInputObjectSchema: z.ZodType<Prisma.PaymentWhereInput> = paymentwhereinputSchema as unknown as z.ZodType<Prisma.PaymentWhereInput>;
export const PaymentWhereInputObjectZodSchema = paymentwhereinputSchema;