6a29fdfd50
- Migrate from Form component to vee-validate useForm - Update combobox component to support number values - Modify base model ID type for mock data - Improve type safety in treatment report schema - Add proper form submission handling
98 lines
2.6 KiB
TypeScript
98 lines
2.6 KiB
TypeScript
import { z } from 'zod'
|
|
|
|
const isoDateTime = z.string().min(1, 'Tanggal / waktu wajib diisi')
|
|
const positiveInt = z.number().int().nonnegative()
|
|
|
|
const OperatorTeamSchema = z.object({
|
|
dpjpId: z.coerce
|
|
.number({
|
|
invalid_type_error: 'Dokter Pemeriksa wajib diisi',
|
|
})
|
|
.int(),
|
|
operatorId: z.coerce
|
|
.number({
|
|
invalid_type_error: 'Operator wajib diisi',
|
|
})
|
|
.int(),
|
|
assistantOperatorId: z.coerce.number().int().optional().nullable(),
|
|
instrumentNurseId: z.coerce.number().int().optional().nullable(),
|
|
|
|
surgeryDate: isoDateTime,
|
|
actionDiagnosis: z.string().min(1),
|
|
|
|
postSurgeryNurseId: z.number().int().optional().nullable(),
|
|
})
|
|
|
|
const ProcedureSchema = z.object({
|
|
id: z.number().int().optional(),
|
|
name: z.string().min(1),
|
|
code: z.string().min(1),
|
|
})
|
|
|
|
const OperationExecutionSchema = z.object({
|
|
surgeryType: z.enum(['kecil', 'sedang', 'besar', 'khusus']),
|
|
billingCode: z.string().min(1),
|
|
operationSystem: z.enum(['khusus', 'cito', 'elektif']),
|
|
|
|
operationStartAt: isoDateTime,
|
|
operationEndAt: isoDateTime,
|
|
|
|
anesthesiaStartAt: isoDateTime,
|
|
anesthesiaEndAt: isoDateTime,
|
|
|
|
surgeryCleanType: z.enum(['bersih', 'bersih_terkontaminasi', 'terkontaminasi', 'kotor']).optional(),
|
|
surgeryNumber: z.enum(['1', '2', '3', '4+', 'tidak_diketahui']).optional(),
|
|
|
|
birthPlaceNote: z.string().optional(),
|
|
babyWeightGram: positiveInt.optional(),
|
|
birthCondition: z.string().optional(),
|
|
|
|
operationDescription: z.string().min(1),
|
|
|
|
bleedingAmountCc: positiveInt.optional(),
|
|
|
|
birthRemark: z.enum(['lahir_hidup', 'lahir_mati', 'abortus', 'tidak_diketahui']).optional(),
|
|
})
|
|
|
|
const BloodComponentSchema = z.object({
|
|
used: z.boolean().default(false),
|
|
volumeCc: positiveInt.optional(),
|
|
})
|
|
|
|
const BloodInputSchema = z.object({
|
|
prc: BloodComponentSchema,
|
|
ffp: BloodComponentSchema,
|
|
wb: BloodComponentSchema,
|
|
tc: BloodComponentSchema,
|
|
})
|
|
|
|
const ImplantSchema = z.object({
|
|
brand: z.string().optional(),
|
|
name: z.string().optional(),
|
|
stickerNumber: z.string().optional(),
|
|
companionName: z.string().optional(),
|
|
})
|
|
|
|
const SpecimenSchema = z.object({
|
|
destination: z.string().min(1),
|
|
})
|
|
|
|
const TissueNoteSchema = z.object({
|
|
note: z.string().min(1),
|
|
})
|
|
|
|
export const TreatmentReportSchema = z.object({
|
|
operatorTeam: OperatorTeamSchema,
|
|
procedures: z.array(ProcedureSchema).min(1),
|
|
|
|
operationExecution: OperationExecutionSchema,
|
|
|
|
bloodInput: BloodInputSchema.optional(),
|
|
implant: ImplantSchema.optional(),
|
|
specimen: SpecimenSchema.optional(),
|
|
|
|
tissueNotes: z.array(TissueNoteSchema).optional(),
|
|
})
|
|
|
|
export type TreatmentReportFormData = z.infer<typeof TreatmentReportSchema>
|