import { z } from "zod";

export const patientSchema = z.object({
  patientCode: z
    .string()
    .trim()
    .max(50)
    .optional()
    .transform((v) => (v ? v.toUpperCase() : undefined)),
  firstName: z.string().trim().min(1, "Ad zorunlu.").max(100),
  lastName: z.string().trim().min(1, "Soyad zorunlu.").max(100),
  phone: z
    .string()
    .trim()
    .max(30)
    .optional()
    .transform((v) => (v ? v : undefined)),
  dateOfBirth: z
    .string()
    .trim()
    .optional()
    .transform((v) => (v ? new Date(v).toISOString() : undefined)),
  notes: z
    .string()
    .trim()
    .max(2000)
    .optional()
    .transform((v) => (v ? v : undefined)),
});

export type PatientInput = z.infer<typeof patientSchema>;
