41985ea89f
- Add date-fns-tz for timezone-aware date formatting - Refactor patient detail view to use accordion components - Improve date display formatting with locale support - Update navigation handling for edit and back actions - Extend ClickType enum to include 'edit' action
87 lines
1.6 KiB
Vue
87 lines
1.6 KiB
Vue
<script setup lang="ts">
|
|
import { withBase } from '~/models/_base'
|
|
import type { HeaderPrep } from '~/components/pub/my-ui/data/types'
|
|
import type { PatientEntity } from '~/models/patient'
|
|
import type { Person } from '~/models/person'
|
|
|
|
// Components
|
|
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
|
|
|
import { getPatientDetail } from '~/services/patient.service'
|
|
|
|
// #region Props & Emits
|
|
const props = defineProps<{
|
|
patientId: number
|
|
}>()
|
|
|
|
// #endregion
|
|
|
|
// #region State & Computed
|
|
const patient = ref(
|
|
withBase<PatientEntity>({
|
|
person: {} as Person,
|
|
personAddresses: [],
|
|
personContacts: [],
|
|
personRelatives: [],
|
|
}),
|
|
)
|
|
|
|
const headerPrep: HeaderPrep = {
|
|
title: 'Detail Pasien',
|
|
icon: 'i-lucide-user',
|
|
}
|
|
|
|
// #endregion
|
|
|
|
// #region Lifecycle Hooks
|
|
onMounted(async () => {
|
|
// await getPatientDetail()
|
|
const result = await getPatientDetail(props.patientId)
|
|
if (result.success) {
|
|
patient.value = result.body.data || {}
|
|
}
|
|
})
|
|
// #endregion
|
|
|
|
// #region Functions
|
|
// #endregion region
|
|
|
|
// #region Utilities & event handlers
|
|
async function onBack() {
|
|
await navigateTo({
|
|
name: 'client-patient',
|
|
})
|
|
}
|
|
async function onEdit() {
|
|
console.log(props.patientId)
|
|
await navigateTo({
|
|
name: 'client-patient-id-edit',
|
|
params: {
|
|
id: props.patientId,
|
|
},
|
|
})
|
|
}
|
|
// #endregion
|
|
|
|
// #region Watchers
|
|
// #endregion
|
|
</script>
|
|
|
|
<template>
|
|
<div
|
|
v-if="patient"
|
|
:key="patient.id"
|
|
>
|
|
<Header
|
|
:prep="headerPrep"
|
|
:ref-search-nav="headerPrep.refSearchNav"
|
|
/>
|
|
|
|
<AppPatientPreview
|
|
:patient="patient"
|
|
@back="onBack"
|
|
@edit="onEdit"
|
|
/>
|
|
</div>
|
|
</template>
|