feat(encounter): add outpatient class and implement record deletion confirmation
This commit is contained in:
No files matched your search
@@ -38,7 +38,7 @@ import { useUserStore } from '~/stores/user'
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
id: number
|
id: number
|
||||||
classCode?: 'ambulatory' | 'emergency' | 'inpatient'
|
classCode?: 'ambulatory' | 'emergency' | 'inpatient' | 'outpatient'
|
||||||
subClassCode?: 'reg' | 'rehab' | 'chemo' | 'emg' | 'eon' | 'op' | 'icu' | 'hcu' | 'vk'
|
subClassCode?: 'reg' | 'rehab' | 'chemo' | 'emg' | 'eon' | 'op' | 'icu' | 'hcu' | 'vk'
|
||||||
formType: string
|
formType: string
|
||||||
}>()
|
}>()
|
||||||
@@ -64,6 +64,22 @@ const isSaveDisabled = computed(() => {
|
|||||||
return !selectedPatient.value || !selectedPatientObject.value || isSaving.value
|
return !selectedPatient.value || !selectedPatientObject.value || isSaving.value
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function getListPath(): string {
|
||||||
|
if (props.classCode === 'ambulatory' && props.subClassCode === 'rehab') {
|
||||||
|
return '/rehab/encounter'
|
||||||
|
}
|
||||||
|
if (props.classCode === 'emergency') {
|
||||||
|
return '/emergency/encounter'
|
||||||
|
}
|
||||||
|
if (props.classCode === 'outpatient') {
|
||||||
|
return '/outpatient/encounter'
|
||||||
|
}
|
||||||
|
if (props.classCode === 'inpatient') {
|
||||||
|
return '/inpatient/encounter'
|
||||||
|
}
|
||||||
|
return '/encounter' // fallback
|
||||||
|
}
|
||||||
|
|
||||||
function handleSavePatient() {
|
function handleSavePatient() {
|
||||||
selectedPatientObject.value = null
|
selectedPatientObject.value = null
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -150,8 +166,17 @@ async function handleSaveEncounter(formValues: any) {
|
|||||||
payload.subspecialist_id = subspecialist_id
|
payload.subspecialist_id = subspecialist_id
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formValues.paymentType === 'jkn') {
|
let paymentMethod = 'cash'
|
||||||
payload.paymentMethod_code = 'insurance'
|
if (formValues.paymentType === 'jkn' || formValues.paymentType === 'jkmm') {
|
||||||
|
paymentMethod = 'insurance'
|
||||||
|
} else if (formValues.paymentType === 'spm') {
|
||||||
|
paymentMethod = 'cash'
|
||||||
|
} else if (formValues.paymentType === 'pks') {
|
||||||
|
paymentMethod = 'membership'
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paymentMethod === 'insurance') {
|
||||||
|
payload.paymentMethod_code = paymentMethod
|
||||||
payload.insuranceCompany_id = null
|
payload.insuranceCompany_id = null
|
||||||
payload.member_number = formValues.cardNumber
|
payload.member_number = formValues.cardNumber
|
||||||
payload.ref_number = formValues.sepNumber
|
payload.ref_number = formValues.sepNumber
|
||||||
@@ -172,8 +197,8 @@ async function handleSaveEncounter(formValues: any) {
|
|||||||
description: 'Kunjungan berhasil dibuat',
|
description: 'Kunjungan berhasil dibuat',
|
||||||
variant: 'default',
|
variant: 'default',
|
||||||
})
|
})
|
||||||
// Optionally navigate or reset form
|
// Redirect to list page
|
||||||
// navigateTo(`/encounter/${result.body?.data?.id}`)
|
await navigateTo(getListPath())
|
||||||
} else {
|
} else {
|
||||||
const errorMessage = result.body?.message || 'Gagal membuat kunjungan'
|
const errorMessage = result.body?.message || 'Gagal membuat kunjungan'
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
@@ -5,14 +5,19 @@ import SummaryCard from '~/components/pub/my-ui/summary-card/summary-card.vue'
|
|||||||
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
|
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
|
||||||
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
|
||||||
import Filter from '~/components/pub/my-ui/nav-header/filter.vue'
|
import Filter from '~/components/pub/my-ui/nav-header/filter.vue'
|
||||||
|
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
|
||||||
|
|
||||||
// Types
|
// Types
|
||||||
import type { DataTableLoader } from '~/components/pub/my-ui/data-table/type'
|
import type { DataTableLoader } from '~/components/pub/my-ui/data-table/type'
|
||||||
import type { Summary } from '~/components/pub/my-ui/summary-card/type'
|
import type { Summary } from '~/components/pub/my-ui/summary-card/type'
|
||||||
import type { HeaderPrep, RefSearchNav } from '~/components/pub/my-ui/data/types'
|
import type { HeaderPrep, RefSearchNav } from '~/components/pub/my-ui/data/types'
|
||||||
|
import { ActionEvents } from '~/components/pub/my-ui/data/types'
|
||||||
|
|
||||||
// Services
|
// Services
|
||||||
import { getList as getEncounterList } from '~/services/encounter.service'
|
import { getList as getEncounterList, remove as removeEncounter } from '~/services/encounter.service'
|
||||||
|
|
||||||
|
// UI
|
||||||
|
import { toast } from '~/components/pub/ui/toast'
|
||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
classCode?: 'ambulatory' | 'emergency' | 'inpatient' | 'outpatient'
|
classCode?: 'ambulatory' | 'emergency' | 'inpatient' | 'outpatient'
|
||||||
@@ -29,6 +34,7 @@ const recId = ref<number>(0)
|
|||||||
const recAction = ref<string>('')
|
const recAction = ref<string>('')
|
||||||
const recItem = ref<any>(null)
|
const recItem = ref<any>(null)
|
||||||
const isFormEntryDialogOpen = ref(false)
|
const isFormEntryDialogOpen = ref(false)
|
||||||
|
const isRecordConfirmationOpen = ref(false)
|
||||||
|
|
||||||
const hreaderPrep: HeaderPrep = {
|
const hreaderPrep: HeaderPrep = {
|
||||||
title: 'Kunjungan',
|
title: 'Kunjungan',
|
||||||
@@ -71,7 +77,11 @@ const refSearchNav: RefSearchNav = {
|
|||||||
async function getPatientList() {
|
async function getPatientList() {
|
||||||
isLoading.isTableLoading = true
|
isLoading.isTableLoading = true
|
||||||
try {
|
try {
|
||||||
const result = await getEncounterList({ includes: 'patient,patient-person' })
|
const params: any = { includes: 'patient,patient-person' }
|
||||||
|
if (props.classCode) {
|
||||||
|
params['class-code'] = props.classCode
|
||||||
|
}
|
||||||
|
const result = await getEncounterList(params)
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
data.value = result.body?.data || []
|
data.value = result.body?.data || []
|
||||||
}
|
}
|
||||||
@@ -86,10 +96,59 @@ onMounted(() => {
|
|||||||
getPatientList()
|
getPatientList()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Handle confirmation result
|
||||||
|
async function handleConfirmDelete(record: any, action: string) {
|
||||||
|
if (action === 'delete' && record?.id) {
|
||||||
|
try {
|
||||||
|
const result = await removeEncounter(record.id)
|
||||||
|
if (result.success) {
|
||||||
|
toast({
|
||||||
|
title: 'Berhasil',
|
||||||
|
description: 'Kunjungan berhasil dihapus',
|
||||||
|
variant: 'default',
|
||||||
|
})
|
||||||
|
await getPatientList() // Refresh list
|
||||||
|
} else {
|
||||||
|
const errorMessage = result.body?.message || 'Gagal menghapus kunjungan'
|
||||||
|
toast({
|
||||||
|
title: 'Gagal',
|
||||||
|
description: errorMessage,
|
||||||
|
variant: 'destructive',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
console.error('Error deleting encounter:', error)
|
||||||
|
toast({
|
||||||
|
title: 'Gagal',
|
||||||
|
description: error?.message || 'Gagal menghapus kunjungan',
|
||||||
|
variant: 'destructive',
|
||||||
|
})
|
||||||
|
} finally {
|
||||||
|
// Reset state
|
||||||
|
recId.value = 0
|
||||||
|
recAction.value = ''
|
||||||
|
recItem.value = null
|
||||||
|
isRecordConfirmationOpen.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCancelConfirmation() {
|
||||||
|
// Reset record state when cancelled
|
||||||
|
recId.value = 0
|
||||||
|
recAction.value = ''
|
||||||
|
recItem.value = null
|
||||||
|
isRecordConfirmationOpen.value = false
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => recAction.value,
|
() => recAction.value,
|
||||||
() => {
|
() => {
|
||||||
console.log('recAction.value', recAction.value)
|
console.log('recAction.value', recAction.value)
|
||||||
|
if (recAction.value === ActionEvents.showConfirmDelete) {
|
||||||
|
isRecordConfirmationOpen.value = true
|
||||||
|
return
|
||||||
|
}
|
||||||
if (props.type === 'encounter') {
|
if (props.type === 'encounter') {
|
||||||
if (recAction.value === 'showDetail') {
|
if (recAction.value === 'showDetail') {
|
||||||
navigateTo(`/rehab/encounter/${recId.value}/detail`)
|
navigateTo(`/rehab/encounter/${recId.value}/detail`)
|
||||||
@@ -139,4 +198,30 @@ provide('table_data_loader', isLoading)
|
|||||||
>
|
>
|
||||||
<AppEncounterFilter />
|
<AppEncounterFilter />
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
|
||||||
|
<!-- Record Confirmation Modal -->
|
||||||
|
<RecordConfirmation
|
||||||
|
v-model:open="isRecordConfirmationOpen"
|
||||||
|
action="delete"
|
||||||
|
:record="recItem"
|
||||||
|
@confirm="handleConfirmDelete"
|
||||||
|
@cancel="handleCancelConfirmation"
|
||||||
|
>
|
||||||
|
<template #default="{ record }">
|
||||||
|
<div class="text-sm">
|
||||||
|
<p>
|
||||||
|
<strong>ID:</strong>
|
||||||
|
{{ record?.id }}
|
||||||
|
</p>
|
||||||
|
<p v-if="record?.patient?.person?.name">
|
||||||
|
<strong>Pasien:</strong>
|
||||||
|
{{ record.patient.person.name }}
|
||||||
|
</p>
|
||||||
|
<p v-if="record?.class_code">
|
||||||
|
<strong>Kelas:</strong>
|
||||||
|
{{ record.class_code }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</RecordConfirmation>
|
||||||
</template>
|
</template>
|
||||||
Reference in New Issue
Block a user