Fix: refactor rehab medik - Resume UI

This commit is contained in:
hasyim_kai
2025-11-07 08:55:23 +07:00
parent fc308809b8
commit 53bd8e7f6e
32 changed files with 2142 additions and 185 deletions
+97 -1
View File
@@ -3,6 +3,14 @@ import type { ExposedForm } from '~/types/form';
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su.vue'
import { ResumeSchema } from '~/schemas/resume.schema';
import Confirmation from '~/components/pub/my-ui/confirmation/confirmation.vue'
import { CalendarDate, DateFormatter, getLocalTimeZone } from '@internationalized/date';
import type { DateRange } from 'radix-vue';
import { getPatients } from '~/services/patient.service';
import ActionHistoryDialog from '~/components/app/resume/history-list/action-history-dialog.vue';
import ConsultationHistoryDialog from '~/components/app/resume/history-list/consultation-history-dialog.vue';
import SupportingHistoryDialog from '~/components/app/resume/history-list/supporting-history-dialog.vue';
import FarmacyHistoryDialog from '~/components/app/resume/history-list/farmacy-history-dialog.vue';
import NationalProgramHistoryDialog from '~/components/app/resume/history-list/national-program-history-dialog.vue';
// #region Props & Emits
const props = defineProps<{
@@ -11,14 +19,60 @@ const props = defineProps<{
// form related state
const personPatientForm = ref<ExposedForm<any> | null>(null)
const actionHistoryData = usePaginatedList({
fetchFn: (params) => getPatients({ ...params, includes: ['person', 'person-Addresses'] }),
entityName: 'patient',
})
const consultationHistoryData = usePaginatedList({
fetchFn: (params) => getPatients({ ...params, includes: ['person', 'person-Addresses'] }),
entityName: 'patient',
})
const supportingHistoryData = usePaginatedList({
fetchFn: (params) => getPatients({ ...params, includes: ['person', 'person-Addresses'] }),
entityName: 'patient',
})
const farmacyHistoryData = usePaginatedList({
fetchFn: (params) => getPatients({ ...params, includes: ['person', 'person-Addresses'] }),
entityName: 'patient',
})
const nationalProgramServiceHistoryData = usePaginatedList({
fetchFn: (params) => getPatients({ ...params, includes: ['person', 'person-Addresses'] }),
entityName: 'patient',
})
// #endregion
// #region State & Computed
const router = useRouter()
const isConfirmationOpen = ref(false)
const isActionHistoryOpen = ref<boolean>(false)
const isConsultationHistoryOpen = ref<boolean>(false)
const isSupportingHistoryOpen = ref<boolean>(false)
const isFarmacyHistoryOpen = ref<boolean>(false)
const isNationalProgramServiceHistoryOpen = ref<boolean>(false)
provide(`isActionHistoryOpen`, isActionHistoryOpen)
provide(`isConsultationHistoryOpen`, isConsultationHistoryOpen)
provide(`isSupportingHistoryOpen`, isSupportingHistoryOpen)
provide(`isFarmacyHistoryOpen`, isFarmacyHistoryOpen)
provide(`isNationalProgramServiceHistoryOpen`, isNationalProgramServiceHistoryOpen)
const defaultDate = {
start: new CalendarDate(2022, 1, 20),
end: new CalendarDate(2022, 1, 20).add({ days: 20 }),
}
const actionHistoryDateValue = ref(defaultDate) as Ref<DateRange>
const consultationHistoryDateValue = ref(defaultDate) as Ref<DateRange>
const supportingHistoryDateValue = ref(defaultDate) as Ref<DateRange>
const farmacyHistoryDateValue = ref(defaultDate) as Ref<DateRange>
const nationalProgramServiceSearch = ref<string>('')
const nationalProgramServiceSelectedStatus = ref<string>('all')
// #endregion
// #region Lifecycle Hooks
onMounted(() => {
})
// #endregion
// #region Functions
@@ -86,7 +140,7 @@ async function handleActionClick(eventType: string) {
<AppResumeAdd
ref="personPatientForm"
:schema="ResumeSchema"
:resume-arrangement-type="personPatientForm?.values.arrangement" />
:resume-arrangement-type="personPatientForm?.values.arrangement"/>
<div class="my-2 flex justify-end py-2">
<Action :enable-draft="false"
@@ -101,4 +155,46 @@ async function handleActionClick(eventType: string) {
@confirm="handleConfirmAdd"
@cancel="handleCancelAdd"
/>
<ActionHistoryDialog
v-model:is-modal-open="isActionHistoryOpen"
v-model:date-value="actionHistoryDateValue"
:data="actionHistoryData.data.value"
:pagination-meta="actionHistoryData.paginationMeta"
@page-change="actionHistoryData.handlePageChange"
/>
<p v-if="isConsultationHistoryOpen === true">aaaaaaaaaaaaaaa</p>
<ConsultationHistoryDialog
v-model:is-modal-open="isConsultationHistoryOpen"
v-model:date-value="consultationHistoryDateValue"
:data="consultationHistoryData.data.value"
:pagination-meta="consultationHistoryData.paginationMeta"
@page-change="consultationHistoryData.handlePageChange"
/>
<SupportingHistoryDialog
v-model:is-modal-open="isSupportingHistoryOpen"
v-model:date-value="supportingHistoryDateValue"
:data="supportingHistoryData.data.value"
:pagination-meta="supportingHistoryData.paginationMeta"
@page-change="supportingHistoryData.handlePageChange"
/>
<FarmacyHistoryDialog
v-model:is-modal-open="isFarmacyHistoryOpen"
v-model:date-value="farmacyHistoryDateValue"
:data="farmacyHistoryData.data.value"
:pagination-meta="farmacyHistoryData.paginationMeta"
@page-change="farmacyHistoryData.handlePageChange"
/>
<NationalProgramHistoryDialog
v-model:is-modal-open="isNationalProgramServiceHistoryOpen"
v-model:search-value="nationalProgramServiceSearch"
v-model:status-value="nationalProgramServiceSelectedStatus"
:data="nationalProgramServiceHistoryData.data.value"
:pagination-meta="nationalProgramServiceHistoryData.paginationMeta"
@page-change="nationalProgramServiceHistoryData.handlePageChange"
/>
</template>
+88 -54
View File
@@ -10,9 +10,12 @@ import { ActionEvents } from '~/components/pub/my-ui/data/types'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import SummaryCard from '~/components/pub/my-ui/summary-card/summary-card.vue'
import { usePaginatedList } from '~/composables/usePaginatedList'
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su.vue'
import { getPatients, removePatient } from '~/services/patient.service'
import DetailRow from '~/components/pub/my-ui/form/view/detail-row.vue'
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import Confirmation from '~/components/pub/my-ui/confirmation/confirmation.vue'
// #endregion
@@ -35,6 +38,7 @@ const refSearchNav: RefSearchNav = {
}
const formType = ref<`a` | `b`>(`a`)
const isVerifyDialogOpen = ref(false)
const isRecordConfirmationOpen = ref(false)
const summaryLoading = ref(false)
@@ -69,23 +73,61 @@ async function getPatientSummary() {
summaryLoading.value = false
}
}
function handleFormScreening(key: string) {
switch (key) {
case 'form-a':
navigateTo("/screening-mpp/add/a")
break;
case 'preview-form-a':
navigateTo('https://google.com', { external: true, open: { target: '_blank' } });
break;
case 'form-b':
navigateTo("/screening-mpp/add/b")
break;
case 'preview-form-b':
navigateTo('https://google.com', { external: true, open: { target: '_blank' } });
break;
default:
break;
async function handleActionClick(eventType: string) {
if (eventType === 'submit') {
// const patient: Patient = await composeFormData()
// let createdPatientId = 0
// const response = await handleActionSave(
// patient,
// () => {},
// () => {},
// toast,
// )
// const data = (response?.body?.data ?? null) as PatientBase | null
// if (!data) return
// createdPatientId = data.id
// If has callback provided redirect to callback with patientData
// if (props.callbackUrl) {
// await navigateTo(props.callbackUrl + '?patient-id=' + patient.id)
// return
// }
// Navigate to patient list or show success message
// await navigateTo('/outpatient/encounter')
// return
}
if (eventType === 'back') {
isVerifyDialogOpen.value = false
}
}
async function handleConfirmDelete() {
try {
const result = await removePatient(recId.value)
if (result.success) {
console.log('Patient deleted successfully')
// Refresh the list
await fetchData()
} else {
console.error('Failed to delete patient:', result)
// Handle error - show error message to user
}
} catch (error) {
console.error('Error deleting patient:', error)
// Handle error - show error message to user
}
}
function handleCancelConfirmation() {
// Reset record state when cancelled
recId.value = 0
recAction.value = ''
recItem.value = null
}
// #endregion
@@ -99,26 +141,15 @@ provide('table_data_loader', isLoading)
// #region Watchers
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
navigateTo({
name: 'outpatient-encounter-id',
params: { id: recId.value },
})
case ActionEvents.showVerify:
isVerifyDialogOpen.value = true
break
case ActionEvents.showEdit:
// TODO: Handle edit action
// isFormEntryDialogOpen.value = true
navigateTo({
name: 'outpatient-encounter-id-edit',
params: { id: recId.value },
})
break
case ActionEvents.showConfirmDelete:
// Trigger confirmation modal open
case ActionEvents.showValidate:
isRecordConfirmationOpen.value = true
break
case ActionEvents.showPrint:
navigateTo('https://google.com', {external: true,open: { target: "_blank" },});
break
}
})
// #endregion
@@ -126,26 +157,29 @@ watch([recId, recAction], () => {
<template>
<Header :prep="{ ...headerPrep }" />
<AppResumeList />
<!-- Disable dulu, ayahab kalo diminta beneran -->
<!-- <div class="my-4 flex flex-1 flex-col gap-4 md:gap-8">
<div class="grid gap-4 md:grid-cols-2 md:gap-8 lg:grid-cols-4">
<template v-if="summaryLoading">
<SummaryCard
v-for="n in 4"
:key="n"
is-skeleton
/>
</template>
<template v-else>
<SummaryCard
v-for="card in summaryData"
:key="card.title"
:stat="card"
/>
</template>
</div>
</div>
-->
<!-- <AppTherapyProtocolList
:data="data"
:pagination-meta="paginationMeta"
@page-change="handlePageChange"/> -->
<AppResumeList
:data="data"
:pagination-meta="paginationMeta"
@page-change="handlePageChange"/>
<Dialog v-model:open="isVerifyDialogOpen" title="Verifikasi">
<AppResumeVerifyDialog />
<div class="flex justify-end">
<Action :enable-draft="false" @click="handleActionClick" />
</div>
</Dialog>
<Confirmation
v-model:open="isRecordConfirmationOpen"
title="Validasi Data"
message="Apakah Anda yakin ingin menvalidasi data ini?"
confirm-text="Validasi"
@confirm="handleConfirmDelete"
@cancel="handleCancelConfirmation"
/>
</template>