From 910b6417505d71d59c7da5423b5dfe338d38c722 Mon Sep 17 00:00:00 2001 From: Khafid Prayoga Date: Mon, 8 Dec 2025 20:43:30 +0700 Subject: [PATCH] form cleanup feat(patient): add edit functionality to patient form - Modify genPatientEntity to accept existing patient data for updates - Add handleActionEdit handler for edit mode - Update form to handle both create and edit modes - Rename patient ref to patientDetail for clarity refactor(patient): update marital status codes and job options mapping - Change marital status enum values to standardized codes (S, M, D, W) - Simplify job options and marital status options mapping using mapToComboboxOptList - Add error handling in patient data loading ajust styling text based on combobox wip: edit patient redirect refactor(models): update type definitions and form field handling - Add field-name prop to SelectDob component for better form handling - Update Person and Patient interfaces to use null for optional fields - Add maritalStatus_code field to Person interface - Improve type safety by replacing undefined with null for optional fields fix casting radio str to boolean and parsing date error --- app/components/app/patient/entry-form.vue | 13 +-- .../fields/radio-communication-barrier.vue | 10 +- .../app/patient/fields/radio-disability.vue | 14 ++- .../app/patient/fields/radio-newborn.vue | 8 +- .../app/patient/fields/select-job.vue | 5 +- .../patient/fields/select-marital-status.vue | 15 ++- app/components/content/patient/detail.vue | 1 - app/components/content/patient/form.vue | 102 ++++++++++++------ app/components/content/patient/list.vue | 14 ++- app/components/pub/my-ui/form/select.vue | 2 +- app/models/patient.ts | 44 ++++---- app/models/person.ts | 39 +++---- app/schemas/patient.schema.ts | 102 ++++-------------- 13 files changed, 175 insertions(+), 194 deletions(-) diff --git a/app/components/app/patient/entry-form.vue b/app/components/app/patient/entry-form.vue index 341bdcd5..4f577091 100644 --- a/app/components/app/patient/entry-form.vue +++ b/app/components/app/patient/entry-form.vue @@ -34,7 +34,7 @@ interface PatientFormInput { drivingLicenseNumber?: string passportNumber?: string fullName?: string - isNewBorn?: 'YA' | 'TIDAK' + isNewBorn?: string gender?: string birthPlace?: string birthDate?: string @@ -45,8 +45,8 @@ interface PatientFormInput { ethnicity?: string language?: string religion?: string - communicationBarrier?: 'YA' | 'TIDAK' - disability?: 'YA' | 'TIDAK' + communicationBarrier?: string + disability?: string disabilityType?: string note?: string residentIdentityFile?: File @@ -61,7 +61,7 @@ interface Props { const props = defineProps() const formSchema = toTypedSchema(PatientSchema) -const { values, resetForm, setValues, validate } = useForm({ +const { values, resetForm, setValues, setFieldValue, validate } = useForm({ name: 'patientForm', validationSchema: formSchema, initialValues: (props.initialValues ?? {}) as any, @@ -135,6 +135,7 @@ defineExpose({ :is-disabled="isReadonly" /> @@ -47,7 +47,7 @@ const genderOptions = [ :id="fieldName" :errors="errors" class="pt-0.5" - > + > @@ -60,7 +60,7 @@ const dissabilityOptions = [ :class="cn('flex flex-row flex-wrap gap-4 sm:gap-6', radioGroupClass)" >
@@ -70,7 +70,7 @@ const dissabilityOptions = [ :value="option.value" :class=" cn( - 'peer border-1 relative h-4 w-4 rounded-full border-muted-foreground before:absolute before:inset-1 before:rounded-full before:bg-primary before:opacity-0 before:transition-opacity data-[state=checked]:border-primary data-[state=checked]:bg-white data-[state=checked]:before:opacity-100 sm:h-5 sm:w-5', + 'border-1 peer relative h-4 w-4 rounded-full border-muted-foreground before:absolute before:inset-1 before:rounded-full before:bg-primary before:opacity-0 before:transition-opacity data-[state=checked]:border-primary data-[state=checked]:bg-white data-[state=checked]:before:opacity-100 sm:h-5 sm:w-5', containerClass, ) " @@ -80,9 +80,7 @@ const dissabilityOptions = [ :class=" cn( 'select-none text-xs !font-normal leading-none transition-colors', - isDisabled - ? 'cursor-not-allowed opacity-70' - : 'cursor-pointer hover:text-primary', + isDisabled ? 'cursor-not-allowed opacity-70' : 'cursor-pointer hover:text-primary', labelClass, ) " diff --git a/app/components/app/patient/fields/radio-newborn.vue b/app/components/app/patient/fields/radio-newborn.vue index 4b66f8db..55fdb11e 100644 --- a/app/components/app/patient/fields/radio-newborn.vue +++ b/app/components/app/patient/fields/radio-newborn.vue @@ -29,8 +29,8 @@ const { } = props const newbornOptions = [ - { label: 'Ya', value: 'YA' }, - { label: 'Tidak', value: 'TIDAK' }, + { label: 'Ya', value: 'yes' }, + { label: 'Tidak', value: 'no' }, ] @@ -81,9 +81,7 @@ const newbornOptions = [ :class=" cn( 'select-none text-xs !font-normal leading-none transition-colors', - isDisabled - ? 'cursor-not-allowed opacity-70' - : 'cursor-pointer hover:text-primary', + isDisabled ? 'cursor-not-allowed opacity-70' : 'cursor-pointer hover:text-primary', labelClass, ) " diff --git a/app/components/app/patient/fields/select-job.vue b/app/components/app/patient/fields/select-job.vue index f9751a5e..18b0e857 100644 --- a/app/components/app/patient/fields/select-job.vue +++ b/app/components/app/patient/fields/select-job.vue @@ -30,7 +30,10 @@ const { } = props // Generate job options from constants, sama seperti pola genderCodes -const jobOptions = mapToComboboxOptList(occupationCodes) +const jobOptions = mapToComboboxOptList(occupationCodes).map(({ label, value }) => ({ + label, + value, +}))