From 4439a88b370a545fc599c1150fc480c05ca5ea26 Mon Sep 17 00:00:00 2001 From: riefive Date: Tue, 11 Nov 2025 15:00:09 +0700 Subject: [PATCH 01/88] feat(encounter): provide cancel of encounter --- .../app/encounter/dropdown-action.vue | 103 ++++++++++++++++++ app/components/app/encounter/list.cfg.ts | 2 +- app/components/content/encounter/list.vue | 83 +++++++++++++- app/components/pub/my-ui/data/types.ts | 2 + app/services/encounter.service.ts | 5 + 5 files changed, 189 insertions(+), 6 deletions(-) create mode 100644 app/components/app/encounter/dropdown-action.vue diff --git a/app/components/app/encounter/dropdown-action.vue b/app/components/app/encounter/dropdown-action.vue new file mode 100644 index 00000000..85b909a5 --- /dev/null +++ b/app/components/app/encounter/dropdown-action.vue @@ -0,0 +1,103 @@ + + + diff --git a/app/components/app/encounter/list.cfg.ts b/app/components/app/encounter/list.cfg.ts index 9ebbc34f..cc0b951c 100644 --- a/app/components/app/encounter/list.cfg.ts +++ b/app/components/app/encounter/list.cfg.ts @@ -6,7 +6,7 @@ import { getAge } from '~/lib/date' type SmallDetailDto = Encounter -const action = defineAsyncComponent(() => import('~/components/pub/my-ui/data/dropdown-action-pdud.vue')) +const action = defineAsyncComponent(() => import('./dropdown-action.vue')) const statusBadge = defineAsyncComponent(() => import('./status-badge.vue')) export const config: Config = { diff --git a/app/components/content/encounter/list.vue b/app/components/content/encounter/list.vue index 655a553d..dc5328d4 100644 --- a/app/components/content/encounter/list.vue +++ b/app/components/content/encounter/list.vue @@ -14,7 +14,7 @@ import type { HeaderPrep, RefSearchNav } from '~/components/pub/my-ui/data/types import { ActionEvents } from '~/components/pub/my-ui/data/types' // Services -import { getList as getEncounterList, remove as removeEncounter } from '~/services/encounter.service' +import { getList as getEncounterList, remove as removeEncounter, cancel as cancelEncounter } from '~/services/encounter.service' // UI import { toast } from '~/components/pub/ui/toast' @@ -35,6 +35,7 @@ const recAction = ref('') const recItem = ref(null) const isFormEntryDialogOpen = ref(false) const isRecordConfirmationOpen = ref(false) +const isRecordCancelOpen = ref(false) const hreaderPrep: HeaderPrep = { title: 'Kunjungan', @@ -114,6 +115,43 @@ async function getPatientList() { } } +// Handle confirmation result +async function handleConfirmCancel(record: any, action: string) { + if (action === 'delete' && record?.id) { + try { + const result = await cancelEncounter(record.id) + if (result.success) { + toast({ + title: 'Berhasil', + description: 'Kunjungan berhasil dibatalkan', + variant: 'default', + }) + await getPatientList() // Refresh list + } else { + const errorMessage = result.body?.message || 'Gagal membatalkan kunjungan' + toast({ + title: 'Gagal', + description: errorMessage, + variant: 'destructive', + }) + } + } catch (error: any) { + console.error('Error cancellation encounter:', error) + toast({ + title: 'Gagal', + description: error?.message || 'Gagal membatalkan kunjungan', + variant: 'destructive', + }) + } finally { + // Reset state + recId.value = 0 + recAction.value = '' + recItem.value = null + isRecordCancelOpen.value = false + } + } +} + // Handle confirmation result async function handleConfirmDelete(record: any, action: string) { if (action === 'delete' && record?.id) { @@ -152,6 +190,14 @@ async function handleConfirmDelete(record: any, action: string) { } function handleCancelConfirmation() { + // Reset record state when cancelled + recId.value = 0 + recAction.value = '' + recItem.value = null + isRecordCancelOpen.value = false +} + +function handleRemoveConfirmation() { // Reset record state when cancelled recId.value = 0 recAction.value = '' @@ -166,16 +212,21 @@ watch( isRecordConfirmationOpen.value = true return } + + if (recAction.value === ActionEvents.showCancel) { + isRecordCancelOpen.value = true + return + } const basePath = getBasePath() if (props.type === 'encounter') { if (recAction.value === 'showDetail') { - navigateTo(`${basePath}/${recId.value}/detail`) + navigateTo(`${basePath}/${recId.value}/process`) } else if (recAction.value === 'showEdit') { navigateTo(`${basePath}/${recId.value}/edit`) - } else if (recAction.value === 'showProcess') { - navigateTo(`${basePath}/${recId.value}/process`) + } else if (recAction.value === 'showPrint') { + console.log('print') } else { // handle other actions } @@ -234,12 +285,34 @@ onMounted(() => { + + + +