feat/role-check: updat flow for input encounter
This commit is contained in:
No files matched your search
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user