From b38487e41f5413a028186bd6e42c02727402cf35 Mon Sep 17 00:00:00 2001 From: riefive Date: Thu, 27 Nov 2025 11:46:06 +0700 Subject: [PATCH] feat: enhance encounter entry forms with mode handling and default date setup --- app/components/app/encounter/entry-form.vue | 68 +++++++++++-------- app/components/app/sep/entry-form.vue | 2 +- app/components/content/encounter/entry.vue | 7 +- app/handlers/encounter-entry.handler.ts | 16 ++--- .../emergency/encounter/[id]/edit.vue | 2 +- .../(features)/emergency/encounter/add.vue | 4 +- .../inpatient/encounter/[id]/edit.vue | 2 +- .../(features)/inpatient/encounter/add.vue | 2 +- .../outpatient/encounter/[id]/edit.vue | 2 +- .../(features)/outpatient/encounter/add.vue | 2 +- 10 files changed, 57 insertions(+), 50 deletions(-) diff --git a/app/components/app/encounter/entry-form.vue b/app/components/app/encounter/entry-form.vue index 22acbbb8..9cb4d177 100644 --- a/app/components/app/encounter/entry-form.vue +++ b/app/components/app/encounter/entry-form.vue @@ -27,6 +27,7 @@ const props = defineProps<{ isReadonly?: boolean isSepValid?: boolean isCheckingSep?: boolean + mode?: string doctor?: any[] subSpecialist?: any[] specialists?: TreeItem[] @@ -63,11 +64,10 @@ const patientId = ref('') const isLoading = props.isLoading !== undefined ? props.isLoading : false const isReadonly = props.isReadonly !== undefined ? props.isReadonly : false - +const mode = props.mode !== undefined ? props.mode : 'add' // SEP validation state from props const isSepValid = computed(() => props.isSepValid || false) const isCheckingSep = computed(() => props.isCheckingSep || false) - const doctorOpts = computed(() => { // Add default option const defaultOption = [{ label: 'Pilih', value: '' }] @@ -75,9 +75,17 @@ const doctorOpts = computed(() => { const doctors = props.doctor || [] return [...defaultOption, ...doctors] }) - const isJKNPayment = computed(() => paymentType.value === 'jkn') +if (mode === 'add') { + // Set default sepDate to current date in YYYY-MM-DD format + const today = new Date() + const year = today.getFullYear() + const month = String(today.getMonth() + 1).padStart(2, '0') + const day = String(today.getDate()).padStart(2, '0') + registerDate.value = `${year}-${month}-${day}` +} + async function onFetchChildren(parentId: string): Promise { console.log('onFetchChildren', parentId) } @@ -141,7 +149,7 @@ function onAddSep() { registerDate: registerDate.value, cardNumber: cardNumber.value, paymentType: paymentType.value, - sepType: sepType.value + sepType: sepType.value, } emit('event', 'add-sep', formValues) } @@ -165,7 +173,7 @@ function submitForm() { }) console.log('🔵 Form errors:', errors.value) console.log('🔵 Form meta:', meta.value) - + // Trigger form submit using native form submit // This will trigger validation and onSubmit handler if (formRef.value) { @@ -179,7 +187,7 @@ function submitForm() { preventDefault: () => {}, target: formRef.value || {}, } as SubmitEvent - + // Call onSubmit directly console.log('🔵 Calling onSubmit with mock event') onSubmit(mockEvent) @@ -285,6 +293,22 @@ defineExpose({ :colCount="3" :cellFlex="false" > + + + + + + + - - - - - - - - - + +