fix: debug encounter
This commit is contained in:
@@ -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)
|
||||
}
|
||||
</script>
|
||||
@@ -161,8 +161,7 @@ function onAddSep(formContext: any) {
|
||||
<FormControl>
|
||||
<Input
|
||||
id="patient_name"
|
||||
v-bind="componentField"
|
||||
:model-value="patientName"
|
||||
v-model="patientName"
|
||||
disabled
|
||||
placeholder="Tambah data pasien terlebih dahulu"
|
||||
/>
|
||||
@@ -175,17 +174,16 @@ function onAddSep(formContext: any) {
|
||||
|
||||
<!-- NIK -->
|
||||
<Cell :cosSpan="3">
|
||||
<Label label-for="nik">NIK</Label>
|
||||
<Field id="nik" :errors="errors">
|
||||
<FormField v-slot="{ componentField }" name="nik">
|
||||
<Label label-for="national_identity">NIK</Label>
|
||||
<Field id="national_identity" :errors="errors">
|
||||
<FormField v-slot="{ componentField }" name="national_identity">
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
id="nik"
|
||||
v-bind="componentField"
|
||||
:model-value="patientNik"
|
||||
id="national_identity"
|
||||
v-model="patientNationalIdentity"
|
||||
disabled
|
||||
placeholder="Otomatis"
|
||||
placeholder="-"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
@@ -194,17 +192,16 @@ function onAddSep(formContext: any) {
|
||||
</Field>
|
||||
</Cell>
|
||||
<Cell>
|
||||
<Label label-for="rm">No. RM</Label>
|
||||
<Field id="rm" :errors="errors">
|
||||
<FormField v-slot="{ componentField }" name="rm">
|
||||
<Label label-for="medical_record_number">No. RM</Label>
|
||||
<Field id="medical_record_number" :errors="errors">
|
||||
<FormField v-slot="{ componentField }" name="medical_record_number">
|
||||
<FormItem>
|
||||
<FormControl>
|
||||
<Input
|
||||
id="rm"
|
||||
v-bind="componentField"
|
||||
:model-value="patientRm"
|
||||
id="medical_record_number"
|
||||
v-model="patientMedicalRecordNumber"
|
||||
disabled
|
||||
placeholder="RM99222"
|
||||
placeholder="-"
|
||||
/>
|
||||
</FormControl>
|
||||
<FormMessage />
|
||||
|
||||
@@ -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)
|
||||
<span class="font-semibold">{{ props.formType }}</span>
|
||||
Kunjungan
|
||||
</div>
|
||||
|
||||
|
||||
<AppEncounterEntryForm
|
||||
:division="division"
|
||||
:items="items"
|
||||
@@ -111,7 +114,17 @@ provide('table_data_loader', isLoading)
|
||||
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"
|
||||
/>
|
||||
</template>
|
||||
|
||||
@@ -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"
|
||||
/>
|
||||
<AppSepTableSearchLetter
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
removePatient as remove,
|
||||
getPatientDetail,
|
||||
getPatients,
|
||||
getPatientByIdentifier,
|
||||
} from '~/services/patient.service'
|
||||
|
||||
const isPatientsLoading = ref(false)
|
||||
@@ -85,6 +86,33 @@ async function getPatientCurrent(id: string) {
|
||||
}
|
||||
}
|
||||
|
||||
async function getPatientByIdentifierSearch(search: string) {
|
||||
try {
|
||||
isPatientsLoading.value = true
|
||||
patients.value = []
|
||||
paginationMeta.value = {} as PaginationMeta
|
||||
const result = await getPatientByIdentifier(search)
|
||||
if (result && result.success && result.body) {
|
||||
if (result.type === 'resident-identity' && result.body.data) {
|
||||
patients.value = [mapPatientToRow(result.body.data)]
|
||||
} else if (result.type === 'identity') {
|
||||
patients.value = [mapPatientToRow(result.body.data)]
|
||||
} else {
|
||||
const meta = result.body.meta
|
||||
patients.value = result.body.data.map(mapPatientToRow)
|
||||
paginationMeta.value = mapPaginationMetaToRow(meta)
|
||||
}
|
||||
} else {
|
||||
patients.value = [] // fallback to empty array
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to fetch patients by identifier:', err)
|
||||
patients.value = []
|
||||
} finally {
|
||||
isPatientsLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
isPatientsLoading,
|
||||
patients,
|
||||
@@ -93,6 +121,7 @@ export {
|
||||
paginationMeta,
|
||||
getPatientsList,
|
||||
getPatientCurrent,
|
||||
getPatientByIdentifierSearch,
|
||||
}
|
||||
|
||||
export const {
|
||||
|
||||
@@ -40,6 +40,22 @@ export async function getPatientDetail(id: number) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function getPatientByIdentifier(search: string) {
|
||||
try {
|
||||
const urlPath = search.length === 16 ? `by-resident-identity/search=${encodeURIComponent(search)}` : `/search/${search}`
|
||||
const url = `${mainUrl}/${urlPath}`
|
||||
const resp = await xfetch(url, 'GET')
|
||||
const result: any = {}
|
||||
result.success = resp.success
|
||||
result.body = (resp.body as Record<string, any>) || {}
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user