feat/role-check: updat flow for input encounter

This commit is contained in:
2025-12-15 12:10:04 +07:00
parent 49ffad1dde
commit bd48cc5907
13 changed files with 1163 additions and 499 deletions

No files matched your search

+19 -2
View File
@@ -1,5 +1,9 @@
import { isValid } from "date-fns"
import { z } from 'zod'
import { PatientSchema } from "./patient.schema"
import { PersonAddressSchema } from "./person-address.schema"
import { PersonContactBaseSchema } from "./person-contact.schema"
import { PersonAddressRelativeSchema } from "./person-address-relative.schema"
const ERROR_MESSAGES = {
required: {
@@ -132,8 +136,21 @@ const IntegrationEncounterSchema = z
},
)
const IntegrationEncounterWPSchema = z
.object({
encounter: IntegrationEncounterSchema,
patient: z.object({
person: PatientSchema,
personAddresses: z.array(PersonAddressSchema),
personContacts: z.array(PersonContactBaseSchema),
personRelatives: z.array(PersonAddressRelativeSchema),
}),
})
type IntegrationEncounterFormData = z.infer<typeof IntegrationEncounterSchema>
type IntegrationEncounterWPFormData = z.infer<typeof IntegrationEncounterWPSchema>
export { IntegrationEncounterSchema }
export type { IntegrationEncounterFormData }
export { IntegrationEncounterSchema, IntegrationEncounterWPSchema }
export type { IntegrationEncounterFormData, IntegrationEncounterWPFormData }
+2 -1
View File
@@ -102,7 +102,8 @@ const PatientSchema = z
(data) => {
if (data.nationality === 'WNI') {
const nik = data.identityNumber?.trim()
return !!nik && nik.length === 16 && /^\d+$/.test(nik)
if (!nik) return true
return nik && nik.length === 16 && /^\d+$/.test(nik)
}
return true
},