From 26e9ea96eace723e692d3b5119b4953aea4d68a3 Mon Sep 17 00:00:00 2001 From: riefive Date: Fri, 24 Oct 2025 17:04:46 +0700 Subject: [PATCH] fix: debug encounter --- app/components/app/encounter/entry-form.vue | 41 ++++++++++----------- app/components/content/encounter/entry.vue | 19 ++++++++-- app/components/content/sep/entry.vue | 13 ++++++- app/handlers/patient.handler.ts | 29 +++++++++++++++ app/services/patient.service.ts | 16 ++++++++ 5 files changed, 91 insertions(+), 27 deletions(-) diff --git a/app/components/app/encounter/entry-form.vue b/app/components/app/encounter/entry-form.vue index 68edf83a..5ea847ec 100644 --- a/app/components/app/encounter/entry-form.vue +++ b/app/components/app/encounter/entry-form.vue @@ -56,11 +56,11 @@ const patientName = computed(() => { return props.selectedPatientObject?.person?.name || '' }) -const patientNik = computed(() => { +const patientNationalIdentity = computed(() => { return props.selectedPatientObject?.person?.residentIdentityNumber || '' }) -const patientRm = computed(() => { +const patientMedicalRecordNumber = computed(() => { return props.selectedPatientObject?.number || '' }) @@ -109,10 +109,11 @@ function onSippFileChange(e: Event) { } function onAddSep(formContext: any) { + console.log('formContext', formContext) const formValues = { - patient_name: formContext?.patient_name, - national_identity: formContext?.nik, - medical_record_number: formContext?.rm, + patient_name: formContext?.patient_name || patientName.value, + national_identity: formContext?.national_identity || patientNationalIdentity.value, + medical_record_number: formContext?.medical_record_number || patientMedicalRecordNumber.value, doctor_id: formContext?.doctor_id, register_date: formContext?.register_date, payment_type: formContext?.payment_type, @@ -120,7 +121,6 @@ function onAddSep(formContext: any) { sep_type: formContext?.sep_type, sep_number: formContext?.sep_number } - emit('click', 'add-sep', formValues) } @@ -161,8 +161,7 @@ function onAddSep(formContext: any) { @@ -175,17 +174,16 @@ function onAddSep(formContext: any) { - - - + + + @@ -194,17 +192,16 @@ function onAddSep(formContext: any) { - - - + + + diff --git a/app/components/content/encounter/entry.vue b/app/components/content/encounter/entry.vue index 796ea58b..c00ffd28 100644 --- a/app/components/content/encounter/entry.vue +++ b/app/components/content/encounter/entry.vue @@ -3,8 +3,8 @@ import AppViewPatient from '~/components/app/patient/view-patient.vue' // Types -import type { PaginationMeta } from '~/components/pub/my-ui/pagination/pagination.type' import type { DataTableLoader } from '~/components/pub/my-ui/data-table/type' +import type { PatientEntity } from '~/models/patient' // Handlers import { @@ -14,6 +14,7 @@ import { paginationMeta, getPatientsList, getPatientCurrent, + getPatientByIdentifierSearch, } from '~/handlers/patient.handler' const props = defineProps<{ @@ -78,6 +79,8 @@ function onClick(e: 'search' | 'add' | 'add-sep', formValues?: any) { } else if (e === 'add') { navigateTo('/client/patient/add') } else if (e === 'add-sep') { + selectedPatientObject.value = {} as PatientEntity + console.log('formValues', formValues) toNavigateSep({ resource: 'encounter', is_service: 'false', ...formValues }) } } @@ -94,7 +97,7 @@ provide('table_data_loader', isLoading) {{ props.formType }} Kunjungan - + diff --git a/app/components/content/sep/entry.vue b/app/components/content/sep/entry.vue index b387b936..8bd8c22f 100644 --- a/app/components/content/sep/entry.vue +++ b/app/components/content/sep/entry.vue @@ -46,7 +46,8 @@ import { selectedPatientObject, paginationMeta, getPatientsList, - getPatientCurrent + getPatientCurrent, + getPatientByIdentifierSearch, } from '~/handlers/patient.handler' const route = useRoute() @@ -386,7 +387,15 @@ onMounted(async () => { v-model:selected="selectedPatient" :patients="patients" :pagination-meta="paginationMeta" - @fetch="(value) => getPatientsList({ ...value, 'page-size': 10, includes: 'person' })" + @fetch="(value) => { + if (value.search && value.search.length >= 3) { + // Use identifier search for specific searches (NIK, RM, etc.) + getPatientByIdentifierSearch(value.search) + } else { + // Use regular search for general searches + getPatientsList({ ...value, 'page-size': 10, includes: 'person' }) + } + }" @save="handleSavePatient" /> ) || {} + result.type = urlPath.includes('by-resident-identity') ? 'resident-identity' : 'identity' + return result + } catch (error) { + console.error('Error fetching patient by identifier:', error) + throw new Error('Failed to get patient by identifier') + } +} + export async function postPatient(record: any) { try { const resp = await xfetch(mainUrl, 'POST', record)