Files
simrsx-fe/app/components/content/patient/detail.vue
T
Khafid Prayoga 910b641750 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
2025-12-09 20:49:25 +07:00

86 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() {
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>