mirror of
https://github.com/faiztyanirh/clqms-shadcn-v1.git
synced 2026-04-27 03:16:33 +07:00
fix after meeting 10/04/2026
1.fix datetime patient 2.fix duplicate email client validation 3.fix email2 duplicate
This commit is contained in:
parent
80d59f3120
commit
0c65d607d2
@ -25,7 +25,25 @@ export function usePatientForm(formState, patientSchema) {
|
|||||||
return status === "success" && data === false ? false : true;
|
return status === "success" && data === false ? false : true;
|
||||||
},
|
},
|
||||||
{ message: "Patient ID already used" }
|
{ message: "Patient ID already used" }
|
||||||
)
|
),
|
||||||
|
EmailAddress1: patientSchema.shape.EmailAddress1.refine(
|
||||||
|
async (value) => {
|
||||||
|
if (!value) return false;
|
||||||
|
const res = await fetch(`${API.BASE_URL}${API.CHECK}?EmailAddress1=${value}`);
|
||||||
|
const { status, data } = await res.json();
|
||||||
|
return status === "success" && data === false ? false : true;
|
||||||
|
},
|
||||||
|
{ message: "Email address already used" }
|
||||||
|
),
|
||||||
|
EmailAddress2: patientSchema.shape.EmailAddress2.refine(
|
||||||
|
async (value) => {
|
||||||
|
if (!value) return false;
|
||||||
|
const res = await fetch(`${API.BASE_URL}${API.CHECK}?EmailAddress1=${value}`);
|
||||||
|
const { status, data } = await res.json();
|
||||||
|
return status === "success" && data === false ? false : true;
|
||||||
|
},
|
||||||
|
{ message: "Email address already used" }
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
const partial = asyncSchema.pick({ [field]: true });
|
const partial = asyncSchema.pick({ [field]: true });
|
||||||
|
|||||||
@ -114,10 +114,10 @@
|
|||||||
tempMap,
|
tempMap,
|
||||||
});
|
});
|
||||||
console.log(payload)
|
console.log(payload)
|
||||||
// const result = await formState.save(masterDetail.mode, payload);
|
const result = await formState.save(masterDetail.mode, payload);
|
||||||
|
|
||||||
// toast('Test Map Created!');
|
toast('Test Map Created!');
|
||||||
// masterDetail?.exitForm(true);
|
masterDetail?.exitForm(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
const primaryAction = $derived({
|
const primaryAction = $derived({
|
||||||
|
|||||||
@ -14,7 +14,10 @@ export const patientSchema = z.object({
|
|||||||
EmailAddress2: z.string().trim().optional().refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val),"Invalid email format"),
|
EmailAddress2: z.string().trim().optional().refine((val) => !val || /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val),"Invalid email format"),
|
||||||
Phone: z.string().max(14, "Max 14 chars").regex(/^$|^[0-9]+$/, "Can only contain numbers"),
|
Phone: z.string().max(14, "Max 14 chars").regex(/^$|^[0-9]+$/, "Can only contain numbers"),
|
||||||
MobilePhone: z.string().max(14, "Max 14 chars").regex(/^$|^[0-9]+$/, "Can only contain numbers"),
|
MobilePhone: z.string().max(14, "Max 14 chars").regex(/^$|^[0-9]+$/, "Can only contain numbers"),
|
||||||
TimeOfDeath: z.string().optional(),
|
TimeOfDeath: z.string().optional().refine(
|
||||||
|
(date) => new Date(date) <= new Date(),
|
||||||
|
"Cannot exceed today's date"
|
||||||
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const patientInitialForm = {
|
export const patientInitialForm = {
|
||||||
@ -69,6 +72,7 @@ export const patientDefaultErrors = {
|
|||||||
PatIdt_Identifier: null,
|
PatIdt_Identifier: null,
|
||||||
Phone: null,
|
Phone: null,
|
||||||
MobilePhone: null,
|
MobilePhone: null,
|
||||||
|
TimeOfDeath: null,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const patientFormFields = [
|
export const patientFormFields = [
|
||||||
@ -259,7 +263,7 @@ export const patientFormFields = [
|
|||||||
{
|
{
|
||||||
type: "row",
|
type: "row",
|
||||||
columns: [
|
columns: [
|
||||||
{ key: "EmailAddress2", label: "Email Address 2", required: false, type: "email", validateOn: ["input"] },
|
{ key: "EmailAddress2", label: "Email Address 2", required: false, type: "email", validateOn: ["input", "blur"] },
|
||||||
{ key: "MobilePhone", label: "Mobile Phone", required: false, type: "text", validateOn: ["input"] },
|
{ key: "MobilePhone", label: "Mobile Phone", required: false, type: "text", validateOn: ["input"] },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -277,7 +281,7 @@ export const patientFormFields = [
|
|||||||
optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/death_indicator`,
|
optionsEndpoint: `${API.BASE_URL}${API.VALUESET}/death_indicator`,
|
||||||
defaultValue: 'N'
|
defaultValue: 'N'
|
||||||
},
|
},
|
||||||
{ key: "TimeOfDeath", label: "Time of Death", required: false, type: "datetime" }
|
{ key: "TimeOfDeath", label: "Time of Death", required: false, type: "datetime", validateOn: ["input"] }
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{ key: "LinkTo", label: "Link To", required: false, type: "linkto" }
|
{ key: "LinkTo", label: "Link To", required: false, type: "linkto" }
|
||||||
|
|||||||
@ -114,7 +114,7 @@
|
|||||||
}}
|
}}
|
||||||
onblur={() => {
|
onblur={() => {
|
||||||
if (validateOn?.includes("blur")) {
|
if (validateOn?.includes("blur")) {
|
||||||
formState.validateField(key, formState.form[key], false);
|
validateFieldAsync(key, mode, originalData?.[key]);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@ -147,12 +147,13 @@
|
|||||||
<ReusableCalendarTimepicker
|
<ReusableCalendarTimepicker
|
||||||
bind:value={formState.form[key]}
|
bind:value={formState.form[key]}
|
||||||
disabled={key === "TimeOfDeath" && isDeathDateDisabled}
|
disabled={key === "TimeOfDeath" && isDeathDateDisabled}
|
||||||
onValueChange={(val) => {
|
parentFunction={(val) => {
|
||||||
formState.form[key] = val;
|
formState.form[key] = val;
|
||||||
if (validateOn?.includes("input")) {
|
if (validateOn?.includes("input")) {
|
||||||
formState.validateField(key, formState.form[key], false);
|
formState.validateField(key, val, false);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
/>
|
/>
|
||||||
{:else if type === "textarea"}
|
{:else if type === "textarea"}
|
||||||
<textarea
|
<textarea
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user