fix: resolve conflict

This commit is contained in:
riefive
2025-11-21 10:33:45 +07:00
139 changed files with 7690 additions and 498 deletions
+228 -11
View File
@@ -1,24 +1,177 @@
<script setup lang="ts">
import Nav from '~/components/pub/my-ui/nav-footer/ba-su.vue'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
// Composables
import { useQueryCRUDMode } from '~/composables/useQueryCRUD'
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
import { toast } from '~/components/pub/ui/toast'
// Pub components
import Nav from '~/components/pub/my-ui/nav-footer/ba-de-su.vue'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
import * as DE from '~/components/pub/my-ui/doc-entry'
// Refs / src
import { type Device } from '~/models/device'
import { getList as getDeviceList } from '~/services/device.service'
// Device order things
import { getDetail, remove, submit } from '~/services/device-order.service'
import EntryForm from '~/components/app/device-order/entry-form.vue'
// Items
import {
getList as getItemList,
create as createItem,
update as updateItem,
} from '~/services/device-order-item.service'
import {
recId,
recAction,
recItem,
handleActionRemove,
} from '~/handlers/device-order-item.handler'
import { genDeviceOrderItem, type DeviceOrderItem } from '~/models/device-order-item'
import ItemListEntry from '~/components/app/device-order-item/list-entry.vue'
import type { HeaderPrep } from '~/components/pub/my-ui/data/types'
const { backToList } = useQueryCRUDMode()
import ItemEntry from '~/components/app/device-order-item/entry-form.vue'
// Header
const headerPrep: HeaderPrep = {
title: 'Tambah Order Alkes',
icon: 'i-lucide-box',
}
function navClick(type: 'cancel' | 'submit') {
if (type === 'cancel') {
backToList()
}
// Device order things
const { getQueryParam } = useQueryParam()
const rawId = getQueryParam('id')
const id = typeof rawId === 'string' ? parseInt(rawId) : 0
const dataRes = await getDetail(id, { includes: 'doctor,doctor-employee,doctor-employee-person' })
const data = ref(dataRes.body?.data || null)
const devices = ref<Device[]>([])
const isSubmitConfirmationOpen = ref(false)
const isDeleteConfirmationOpen = ref(false)
// Items
const {
data: items,
isLoading,
fetchData: getDeviceOrderItems,
} = usePaginatedList({
fetchFn: async (params: any) => {
const result = await getItemList({
'device-order-id': id,
includes: 'device',
search: params.search,
sort: 'createdAt:asc',
'page-number': params['page-number'] || 0,
'page-size': params['page-size'] || 10,
})
return { success: result.success || false, body: result.body || {} }
},
entityName: 'division',
})
const selectedItem = ref<DeviceOrderItem>(genDeviceOrderItem())
const isItemDetailDialogOpen = ref(false)
const isItemEntryDialogOpen = ref(false)
const isItemDelConfirmDialogOpen = ref(false)
selectedItem.value.deviceOrder_id = id
// Last navs
const { backToList } = useQueryCRUDMode()
// Reactivities
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
watch([recId, recAction], () => {
let item: DeviceOrderItem | null
switch (recAction.value) {
case ActionEvents.showDetail:
item = pickItem()
if (item) {
isItemDetailDialogOpen.value = true
}
break
case ActionEvents.showEdit:
item = pickItem()
if (item) {
isItemEntryDialogOpen.value = true
getDevices('', item.device_code)
}
break
case ActionEvents.showConfirmDelete:
isItemDelConfirmDialogOpen.value = true
break
}
})
onMounted(async () => {
await getDeviceOrderItems()
})
// Functions
function navClick(type: 'back' | 'delete' | 'draft' | 'submit') {
if (type === 'back') {
backToList()
} else if (type === 'delete') {
isDeleteConfirmationOpen.value = true
} else if (type === 'submit') {
isSubmitConfirmationOpen.value = true
}
}
async function removeOrder() {
const res = await remove(id)
if (res.success) {
backToList()
}
}
async function submitOrder() {
const res = await submit(id)
if (res.success) {
backToList()
}
}
function addItem() {
isItemEntryDialogOpen.value = true
}
async function getDevices(value: string, code?: string) {
const res = await getDeviceList({ 'search': value, 'code': code })
if (res.success) {
devices.value = res.body.data
} else {
devices.value = []
}
}
function pickItem(): DeviceOrderItem | null {
const item = items.value.find(item => item.id === recId.value)
selectedItem.value = item
return item
}
async function saveItem() {
let res: any;
if(!selectedItem.value.id) {
res = await createItem(selectedItem.value)
} else {
res = await updateItem(selectedItem.value.id, selectedItem.value)
}
if (res.success) {
toast({ title: 'Berhasil', description: 'Resep telah di ajukan', variant: 'default' })
getDeviceOrderItems()
isItemEntryDialogOpen.value = false
selectedItem.value = genDeviceOrderItem()
}
}
</script>
<template>
@@ -28,10 +181,74 @@ const headerPrep: HeaderPrep = {
class="mb-4 xl:mb-5"
/>
<ItemListEntry />
<EntryForm :data="data" @add="addItem" />
<ItemListEntry :data="items" @add="addItem" />
<Separator class="my-5" />
<div class="w-full flex justify-center">
<Nav @click="navClick" />
</div>
<!-- Confirm delete -->
<RecordConfirmation
v-model:open="isDeleteConfirmationOpen"
action="delete"
:record="data"
@confirm="removeOrder()"
/>
<!-- Confirm submit -->
<RecordConfirmation
v-model:open="isSubmitConfirmationOpen"
customTitle="Ajukan Order"
customMessage="Akan dilakukan pengajuan order alat kesehatan"
customConfirmText="Ajukan"
:record="data"
@confirm="submitOrder"
@cancel=""
/>
<!-- Item entry -->
<Dialog
v-model:open="isItemEntryDialogOpen"
title="Item Order"
size="lg"
prevent-outside
>
<ItemEntry
:data="selectedItem"
:devices="devices"
@close="isItemEntryDialogOpen = false"
@save="saveItem"
@update:searchText="getDevices"
/>
</Dialog>
<RecordConfirmation
v-model:open="isItemDelConfirmDialogOpen"
action="delete"
size="md"
:record="recItem"
@confirm="() => handleActionRemove(recId, getDeviceOrderItems, toast)"
@cancel=""
>
<DE.Block mode="preview" label-size="small">
<DE.Cell>
<DE.Label>Nama</DE.Label>
<DE.Colon />
<DE.Field>
{{ recItem.device.name }}
</DE.Field>
</DE.Cell>
<DE.Cell>
<DE.Label>Dosis</DE.Label>
<DE.Colon />
<DE.Field>
{{ recItem.quantity }}
</DE.Field>
</DE.Cell>
</DE.Block>
</RecordConfirmation>
</template>
+108 -70
View File
@@ -1,69 +1,39 @@
<script setup lang="ts">
// Helpers
import { usePaginatedList } from '~/composables/usePaginatedList'
// Components
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
import List from '~/components/app/device-order/list.vue'
// Helpers
import { usePaginatedList } from '~/composables/usePaginatedList'
import { toast } from '~/components/pub/ui/toast'
// import { useQueryMode } from '~/composables/useQueryMode'
import { useQueryCRUDMode } from '~/composables/useQueryCRUD'
// Types
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
import { type DeviceOrderFormData, DeviceOrderSchema } from '~/schemas/device-order.schema'
import type { DeviceOrder } from "~/models/device-order";
// Handlers
// Device order things
import {
recId,
recAction,
recItem,
isReadonly,
isProcessing,
isFormEntryDialogOpen,
isRecordConfirmationOpen,
onResetState,
handleActionSave,
handleActionEdit,
handleActionRemove,
handleCancelForm,
} from '~/handlers/device-order.handler'
import { getList, submit } from '~/services/device-order.service'
import type { ToastFn } from '~/handlers/_handler'
import { type DeviceOrder } from "~/models/device-order";
import ConfirmationInfo from '~/components/app/device-order/confirmation-info.vue'
// Services
import { getList } from '~/services/device-order.service'
// Props
const props = defineProps<{
encounter_id: number
}>()
const route = useRoute()
const title = ref('')
// const { mode, openForm, backToList } = useQueryMode()
const { mode, goToEntry, backToList } = useQueryCRUDMode()
const { recordId } = useQueryCRUDRecordId()
const {
data,
isLoading,
paginationMeta,
searchInput,
handlePageChange,
handleSearch,
fetchData: getMyList,
} = usePaginatedList({
fetchFn: async (params: any) => {
const result = await getList({
search: params.search,
sort: 'createdAt:asc',
'page-number': params['page-number'] || 0,
'page-size': params['page-size'] || 10,
includes: 'parent,childrens',
})
return { success: result.success || false, body: result.body || {} }
},
entityName: 'device-order',
})
const encounter_id = props.encounter_id
// Header
const voidFn = () => {}
const headerPrep: HeaderPrep = {
title: 'Order Alkes',
icon: 'i-lucide-box',
@@ -85,21 +55,88 @@ const headerPrep: HeaderPrep = {
recItem.value = null
recId.value = 0
isReadonly.value = false
// await handleActionSave(recItem, getMyList, () => {}, () => {})
goToEntry()
const saveResp = await handleActionSave({ encounter_id }, voidFn, voidFn, voidFn)
if (saveResp.success) {
setQueryParams({
'mode': 'entry',
'id': saveResp.body?.data?.id.toString()
})
}
},
},
}
// List
const {
data,
isLoading,
paginationMeta,
searchInput,
handlePageChange,
handleSearch,
fetchData: getMyList,
} = usePaginatedList({
fetchFn: async (params: any) => {
const result = await getList({
'encounter-id': encounter_id,
search: params.search,
includes: 'doctor,doctor-employee,doctor-employee-person,items,items-device',
page: params.page,
'page-number': params['page-number'] || 0,
'page-size': params['page-size'] || 10,
})
return { success: result.success || false, body: result.body || {} }
},
entityName: 'device-order',
})
// Selected item
const selectedItem = ref<DeviceOrder | null>()
const isSubmitConfirmationOpen = ref(false)
const isDeleteConfirmationOpen = ref(false)
const { setQueryParams } = useQueryParam()
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
// Watch for row actions when recId or recAction changes
onMounted(async () => {
await getMyList()
watch([recId, recAction], () => {
let item: DeviceOrder | null
switch (recAction.value) {
case ActionEvents.showDetail:
setQueryParams({
'mode': 'entry',
'id': recId.value.toString()
})
break
case ActionEvents.showConfirmSubmit:
selectedItem.value = pickItem()
isSubmitConfirmationOpen.value = true
break
case ActionEvents.showConfirmDelete:
selectedItem.value = pickItem()
isDeleteConfirmationOpen.value = true
break
}
recAction.value = '';
})
async function handleActionSubmit(id: number, refresh: () => void, toast: ToastFn) {
const result = await submit(id)
if (result.success) {
toast({ title: 'Berhasil', description: 'Resep telah di ajukan', variant: 'default' })
setTimeout(refresh, 300)
} else {
toast({ title: 'Gagal', description: 'Gagal menjalankan perintah', variant: 'destructive' })
}
}
function pickItem(): DeviceOrder | null {
const item = data.value.find(item => item.id === recId.value)
selectedItem.value = item
return item
}
</script>
<template>
@@ -108,38 +145,39 @@ onMounted(async () => {
:prep="headerPrep"
:ref-search-nav="headerPrep.refSearchNav"
@search="handleSearch"
class="mb-4 xl:mb-5"
/>
<List
v-if="!isLoading.dataListLoading"
:data="data"
:pagination-meta="paginationMeta"
@page-change="handlePageChange"
/>
<!--
@cancel="cancel"
@edit="edit"
@submit="submit"
-->
<!-- Record Confirmation Modal -->
<!-- Submit Record Confirmation Modal -->
<RecordConfirmation
v-model:open="isRecordConfirmationOpen"
v-model:open="isSubmitConfirmationOpen"
customTitle="Ajukan Order"
customMessage="Akan dilakukan pengajuan order alat kesehatan"
customConfirmText="Ajukan"
:record="recItem"
@confirm="() => handleActionSubmit(recId, getMyList, toast)"
>
<ConfirmationInfo :data="selectedItem" />
</RecordConfirmation>
<!-- Del Record Confirmation Modal -->
<RecordConfirmation
v-model:open="isDeleteConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getMyList, toast)"
@cancel=""
>
<template #default="{ record }">
<div class="text-sm">
<p>
<strong>ID:</strong>
{{ record?.id }}
</p>
<p v-if="record?.name">
<strong>Nama:</strong>
{{ record.name }}
</p>
<p v-if="record?.code">
<strong>Kode:</strong>
{{ record.code }}
</p>
</div>
</template>
<ConfirmationInfo :data="selectedItem" />
</RecordConfirmation>
</template>
+7 -3
View File
@@ -3,10 +3,14 @@
import List from './list.vue'
import Entry from './entry.vue'
const { mode } = useQueryMode()
defineProps<{
encounter_id: number
}>()
const { mode } = useQueryCRUDMode()
</script>
<template>
<List v-if="mode === 'list'" />
<Entry v-else />
<List v-if="mode === 'list'" :encounter_id="encounter_id" />
<Entry v-else :encounter_id="encounter_id" />
</template>
@@ -0,0 +1,128 @@
<script setup lang="ts">
import { useRouter } from 'vue-router'
import type { ExposedForm } from '~/types/form'
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su.vue'
import { handleActionSave,} from '~/handlers/supporting-document.handler'
import { toast } from '~/components/pub/ui/toast'
import Confirmation from '~/components/pub/my-ui/confirmation/confirmation.vue'
import { DocumentUploadSchema } from '~/schemas/document-upload.schema'
import { toFormData } from '~/lib/utils'
import { uploadAttachment } from '~/services/supporting-document.service'
// #region Props & Emits
const props = defineProps<{
callbackUrl?: string
}>()
// form related state
const route = useRoute()
const encounterId = typeof route.params.id == 'string' ? parseInt(route.params.id) : 0
const inputForm = ref<ExposedForm<any> | null>(null)
const { user } = useUserStore()
// #endregion
// #region State & Computed
const router = useRouter()
const isConfirmationOpen = ref(false)
const initialValues = {
officer: user.user_name,
}
// #endregion
// #region Lifecycle Hooks
// #endregion
// #region Functions
function goBack() {
router.go(-1)
}
async function handleConfirmAdd() {
const inputData = await composeFormData()
const inputFormData: FormData = toFormData(inputData)
const response = await handleActionSave(inputFormData, () => { }, () => { }, toast, )
const data = (response?.body?.data ?? null)
if (!data) return
// // If has callback provided redirect to callback with patientData
if (props.callbackUrl) {
navigateTo(props.callbackUrl + '?control-letter-id=' + inputData.id)
}
goBack()
}
async function composeFormData(): Promise<any> {
inputForm.value?.setValues({
...inputForm.value?.values,
ref_id: encounterId,
upload_employee_id: user.employee_id
})
const [inputFormState,] = await Promise.all([
inputForm.value?.validate(),
])
const results = [inputFormState]
const allValid = results.every((r) => r?.valid)
// exit, if form errors happend during validation
if (!allValid) {
toast({ title: 'Form validation failed', variant: 'destructive',})
return Promise.reject('Form validation failed')
}
const formData = inputFormState?.values
return new Promise((resolve) => resolve(formData))
}
// #endregion region
// #region Utilities & event handlers
async function handleActionClick(eventType: string) {
if (eventType === 'submit') {
isConfirmationOpen.value = true
}
if (eventType === 'back') {
if (props.callbackUrl) {
await navigateTo(props.callbackUrl)
return
}
goBack()
}
}
function handleCancelAdd() {
isConfirmationOpen.value = false
}
// #endregion
// #region Watchers
// #endregion
</script>
<template>
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg font-semibold xl:text-xl">
<h1>Upload Dokumen</h1>
</div>
<AppDocumentUploadEntryForm
ref="inputForm"
:schema="DocumentUploadSchema"
:initial-values="initialValues"
/>
<div class="mb-2 flex justify-end py-2">
<Action :enable-draft="false" @click="handleActionClick" />
</div>
<Confirmation v-model:open="isConfirmationOpen"
title="Simpan Data"
message="Apakah Anda yakin ingin menyimpan data ini?"
confirm-text="Simpan"
@confirm="handleConfirmAdd"
@cancel="handleCancelAdd" />
</template>
<style scoped>
/* component style */
</style>
@@ -0,0 +1,134 @@
<script setup lang="ts">
import { useRouter } from 'vue-router'
import type { ExposedForm } from '~/types/form'
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su.vue'
import { handleActionSave,} from '~/handlers/supporting-document.handler'
import { toast } from '~/components/pub/ui/toast'
import Confirmation from '~/components/pub/my-ui/confirmation/confirmation.vue'
import { DocumentUploadSchema } from '~/schemas/document-upload.schema'
import { getDetail } from '~/services/supporting-document.service'
// #region Props & Emits
const props = defineProps<{
callbackUrl?: string
}>()
// form related state
const route = useRoute()
const encounterId = typeof route.params.id == 'string' ? parseInt(route.params.id) : 0
const docId = typeof route.params.document_id == 'string' ? parseInt(route.params.document_id) : 0
const inputForm = ref<ExposedForm<any> | null>(null)
// #endregion
// #region State & Computed
const router = useRouter()
const isConfirmationOpen = ref(false)
const { user } = useUserStore()
const initialValues = {
officer: user.user_name,
}
// #endregion
// #region Lifecycle Hooks
onMounted(async () => {
const result = await getDetail(docId)
if (result.success) {
inputForm.value?.setValues(result.body.data)
}
})
// #endregion
// #region Functions
function goBack() {
router.go(-1)
}
async function handleConfirmAdd() {
const inputData = await composeFormData()
let createdDataId = 0
// const response = await handleActionSave(
// inputData,
// () => { },
// () => { },
// toast,
// )
// const data = (response?.body?.data ?? null)
// if (!data) return
// createdDataId = data.id
// // // If has callback provided redirect to callback with patientData
// if (props.callbackUrl) {
// navigateTo(props.callbackUrl + '?control-letter-id=' + inputData.id)
// }
// goBack()
}
async function composeFormData(): Promise<any> {
const [inputFormState,] = await Promise.all([
inputForm.value?.validate(),
])
const results = [inputFormState]
const allValid = results.every((r) => r?.valid)
// exit, if form errors happend during validation
if (!allValid) return Promise.reject('Form validation failed')
const formData = inputFormState?.values
formData.encounter_id = encounterId
return new Promise((resolve) => resolve(formData))
}
// #endregion region
// #region Utilities & event handlers
async function handleActionClick(eventType: string) {
if (eventType === 'submit') {
isConfirmationOpen.value = true
}
if (eventType === 'back') {
if (props.callbackUrl) {
await navigateTo(props.callbackUrl)
return
}
goBack()
}
}
function handleCancelAdd() {
isConfirmationOpen.value = false
}
// #endregion
// #region Watchers
// #endregion
</script>
<template>
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg font-semibold xl:text-xl">
<h1>Upload Dokumen</h1>
</div>
<AppDocumentUploadEntryForm
ref="inputForm"
:schema="DocumentUploadSchema"
:initial-values="initialValues"
/>
<div class="my-2 flex justify-end py-2">
<Action :enable-draft="false" @click="handleActionClick" />
</div>
<Confirmation v-model:open="isConfirmationOpen"
title="Simpan Data"
message="Apakah Anda yakin ingin menyimpan data ini?"
confirm-text="Simpan"
@confirm="handleConfirmAdd"
@cancel="handleCancelAdd" />
</template>
<style scoped>
/* component style */
</style>
@@ -0,0 +1,183 @@
<script setup lang="ts">
// #region Imports
import { ActionEvents } from '~/components/pub/my-ui/data/types'
import type { HeaderPrep, RefSearchNav, } from '~/components/pub/my-ui/data/types'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import { getList, remove } from '~/services/supporting-document.service'
import { toast } from '~/components/pub/ui/toast'
import type { Encounter } from '~/models/encounter'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
import DocPreviewDialog from '~/components/pub/my-ui/modal/doc-preview-dialog.vue'
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import type { PagePermission } from '~/models/role'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
import { unauthorizedToast } from '~/lib/utils'
// #endregion
// #region Permission
const roleAccess: PagePermission = PAGE_PERMISSIONS['/rehab/encounter']
const { getPagePermissions } = useRBAC()
const pagePermission = getPagePermissions(roleAccess)
const {user,userRole} = useUserStore()
const {getUserPermissions} = useRBAC()
// #endregion
// #region State
const props = defineProps<{
encounter?: Encounter
refresh: () => void
}>()
const route = useRoute()
const encounterId = typeof route.params.id == 'string' ? parseInt(route.params.id) : 0
const { data, paginationMeta, handlePageChange, handleSearch, searchInput, fetchData } = usePaginatedList({
fetchFn: (params) => getList({
'encounter-id': encounterId,
// includes: "employee",
...params,
}),
entityName: 'encounter-document',
})
const isDocPreviewDialogOpen = ref(false)
const isRecordConfirmationOpen = ref(false)
const recId = ref<number>(0)
const recAction = ref<string>('')
const recItem = ref<any>(null)
const timestamp = ref<number>(0)
const headerPrep: HeaderPrep = {
title: "Upload Dokumen",
icon: 'i-lucide-newspaper',
}
if (pagePermission.canCreate) {
headerPrep.addNav = {
label: "Upload Dokumen",
onClick: () => navigateTo({
name: 'rehab-encounter-id-document-upload-add',
params: { id: encounterId },
}),
}
}
const refSearchNav: RefSearchNav = {
onClick: () => {
// open filter modal
},
onInput: (val: string) => {
searchInput.value = val
},
onClear: () => {
searchInput.value = ''
},
}
// #endregion
// #region Lifecycle Hooks
onMounted(() => {
})
// #endregion
// #region Functions
async function handleConfirmDelete(record: any, action: string) {
if (action === 'delete' && record?.id) {
try {
const result = await remove(record.id)
if (result.success) {
toast({ title: 'Berhasil', description: 'Data berhasil dihapus', variant: 'default' })
fetchData()
} else {
toast({ title: 'Gagal', description: `Data gagal dihapus`, variant: 'destructive' })
}
} catch (error) {
toast({ title: 'Gagal', description: `Something went wrong`, variant: 'destructive' })
}
}
}
function handleCancelConfirmation() {
// Reset record state when cancelled
recId.value = 0
recAction.value = ''
recItem.value = null
}
// #endregion
// #region Provide
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
provide('timestamp', timestamp)
// #endregion
// #region Watchers
watch([recId, recAction, timestamp], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
isDocPreviewDialogOpen.value = true
break
case ActionEvents.showEdit:
if(pagePermission.canUpdate){
navigateTo({
name: 'rehab-encounter-id-document-upload-document_id-edit',
params: { id: encounterId, "document_id": recId.value },
})
} else {
unauthorizedToast()
}
break
case ActionEvents.showConfirmDelete:
if(pagePermission.canDelete){
isRecordConfirmationOpen.value = true
} else {
unauthorizedToast()
}
navigateTo(recItem.value.filePath, { external: true, open: { target: '_blank' } })
break
case ActionEvents.showEdit:
navigateTo({
name: 'rehab-encounter-id-document-upload-document_id-edit',
params: { id: encounterId, "document_id": recId.value },
})
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
break
}
})
// #endregion
</script>
<template>
<Header :prep="{ ...headerPrep }"
v-model:search="searchInput"
:ref-search-nav="refSearchNav"
@search="handleSearch"
/>
<AppDocumentUploadList :data="data" :pagination-meta="paginationMeta" @page-change="handlePageChange"/>
<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?.name">
<strong>Nama:</strong>
{{ record?.name }}
</p>
</div>
</template>
</RecordConfirmation>
<Dialog v-model:open="isDocPreviewDialogOpen" title="Preview Dokumen" size="2xl">
<DocPreviewDialog :link="recItem?.filePath" />
</Dialog>
</template>
+25 -11
View File
@@ -9,15 +9,21 @@ import { getDetail } from '~/services/encounter.service'
import type { TabItem } from '~/components/pub/my-ui/comp-tab/type'
import CompTab from '~/components/pub/my-ui/comp-tab/comp-tab.vue'
import { genEncounter } from '~/models/encounter'
// PLASE ORDER BY TAB POSITION
import Status from '~/components/content/encounter/status.vue'
import AssesmentFunctionList from '~/components/content/soapi/entry.vue'
import EarlyMedicalAssesmentList from '~/components/content/soapi/entry.vue'
import EarlyMedicalRehabList from '~/components/content/soapi/entry.vue'
import DeviceOrder from '~/components/content/device-order/main.vue'
import Prescription from '~/components/content/prescription/main.vue'
import CpLabOrder from '~/components/content/cp-lab-order/main.vue'
import Radiology from '~/components/content/radiology-order/main.vue'
import Consultation from '~/components/content/consultation/list.vue'
import DocUploadList from '~/components/content/document-upload/list.vue'
import GeneralConsentList from '~/components/content/general-consent/entry.vue'
import ResumeList from '~/components/content/resume/list.vue'
import ControlLetterList from '~/components/content/control-letter/list.vue'
const route = useRoute()
@@ -32,12 +38,18 @@ const activeTab = computed({
})
const id = typeof route.params.id == 'string' ? parseInt(route.params.id) : 0
const dataRes = await getDetail(id, {
includes:
'patient,patient-person,patient-person-addresses,unit,Appointment_Doctor,Appointment_Doctor-employee,Appointment_Doctor-employee-person',
const data = ref(genEncounter())
async function fetchDetail() {
const res = await getDetail(id, {
includes: 'patient,patient-person,patient-person-addresses,unit,Appointment_Doctor,Appointment_Doctor-employee,Appointment_Doctor-employee-person,EncounterDocuments',
})
if(res.body?.data) data.value = res.body?.data
}
onMounted(() => {
fetchDetail()
})
const dataResBody = dataRes.body ?? null
const data = dataResBody?.data ?? null
const tabs: TabItem[] = [
{ value: 'status', label: 'Status Masuk/Keluar', component: Status, props: { encounter: data } },
@@ -61,21 +73,23 @@ const tabs: TabItem[] = [
},
{ value: 'therapy-protocol', label: 'Protokol Terapi' },
{ value: 'education-assessment', label: 'Asesmen Kebutuhan Edukasi' },
{ value: 'consent', label: 'General Consent' },
{ value: 'consent', label: 'General Consent', component: GeneralConsentList, props: { encounter: data } },
{ value: 'patient-note', label: 'CPRJ' },
{ value: 'prescription', label: 'Order Obat', component: Prescription, props: { encounter_id: data.id } },
{ value: 'device', label: 'Order Alkes' },
{ value: 'mcu-radiology', label: 'Order Radiologi', component: Radiology, props: { encounter_id: data.id } },
{ value: 'mcu-lab-cp', label: 'Order Lab PK', component: CpLabOrder, props: { encounter_id: data.id } },
{ value: 'prescription', label: 'Order Obat', component: Prescription, props: { encounter_id: data.value.id } },
{ value: 'device-order', label: 'Order Alkes', component: DeviceOrder, props: { encounter_id: data.value.id } },
{ value: 'mcu-radiology', label: 'Order Radiologi', component: Radiology, props: { encounter_id: data.value.id } },
{ value: 'mcu-lab-cp', label: 'Order Lab PK', component: CpLabOrder, props: { encounter_id: data.value.id } },
{ value: 'mcu-lab-micro', label: 'Order Lab Mikro' },
{ value: 'mcu-lab-pa', label: 'Order Lab PA' },
{ value: 'medical-action', label: 'Order Ruang Tindakan' },
{ value: 'mcu-result', label: 'Hasil Penunjang' },
{ value: 'consultation', label: 'Konsultasi', component: Consultation, props: { encounter: data } },
{ value: 'resume', label: 'Resume', component: ResumeList, props: { encounter: data } },
{ value: 'control', label: 'Surat Kontrol' },
{ value: 'resume', label: 'Resume' },
{ value: 'control', label: 'Surat Kontrol', component: ControlLetterList, props: { encounter: data } },
{ value: 'screening', label: 'Skrinning MPP' },
{ value: 'supporting-document', label: 'Upload Dokumen Pendukung' },
{ value: 'supporting-document', label: 'Upload Dokumen Pendukung', component: DocUploadList, props: { encounter: data }, },
]
</script>
+3 -2
View File
@@ -110,6 +110,7 @@ watch([recId, recAction], () => {
getCurrentMaterialDetail(recId.value)
title.value = 'Edit Perlengkapan'
isReadonly.value = false
isFormEntryDialogOpen.value = true
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
@@ -158,7 +159,7 @@ onMounted(async () => {
@submit="
(values: MaterialFormData, resetForm: any) => {
if (recId > 0) {
handleActionEdit(recId, values, getEquipmentList, resetForm, toast)
handleActionEdit(recItem.code, values, getEquipmentList, resetForm, toast)
return
}
handleActionSave(values, getEquipmentList, resetForm, toast)
@@ -173,7 +174,7 @@ onMounted(async () => {
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getEquipmentList, toast)"
@confirm="() => handleActionRemove(recItem.code, getEquipmentList, toast)"
@cancel=""
>
<template #default="{ record }">
@@ -0,0 +1,36 @@
<script setup lang="ts">
import { computed } from 'vue'
import { useRoute } from 'vue-router'
import { useQueryMode } from '@/composables/useQueryMode'
import List from './list.vue'
import Form from './form.vue'
// Models
import type { Encounter } from '~/models/encounter'
// Props
interface Props {
encounter: Encounter
}
const props = defineProps<Props>()
const route = useRoute()
const { mode, goToEntry, backToList } = useQueryCRUDMode('mode')
</script>
<template>
<div>
<List
v-if="mode === 'list'"
:encounter="props.encounter"
@add="goToEntry"
@edit="goToEntry"
/>
<Form
v-else
@back="backToList"
/>
</div>
</template>
@@ -0,0 +1,185 @@
<script setup lang="ts">
import { z } from 'zod'
import Entry from '~/components/app/general-consent/entry.vue'
import Action from '~/components/pub/my-ui/nav-footer/ba-dr-su-pr.vue'
import ActionDialog from '~/components/pub/my-ui/nav-footer/ba-su.vue'
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import { GeneralConsentSchema } from '~/schemas/general-consent.schema'
import { toast } from '~/components/pub/ui/toast'
import { handleActionSave, handleActionEdit } from '~/handlers/general-consent.handler'
import { create } from '~/services/generate-file.service'
// Services
import { getDetail } from '~/services/general-consent.service'
const { backToList } = useQueryCRUDMode('mode')
const { recordId } = useQueryCRUDRecordId('record-id')
const route = useRoute()
const isOpenProcedure = ref(false)
const isOpenDiagnose = ref(false)
const isOpenFungsional = ref(false)
const procedures = ref([])
const diagnoses = ref([])
const fungsional = ref([])
const selectedProcedure = ref<any>(null)
const selectedDiagnose = ref<any>(null)
const selectedFungsional = ref<any>(null)
const schema = GeneralConsentSchema
const payload = ref({
encounter_id: 0,
value: '',
})
const model = ref({
relatives: [],
responsibleName: '',
responsiblePhone: '',
informant: '',
witness1: '',
witness2: '',
})
const fileUrl = ref('')
const isLoading = reactive<DataTableLoader>({
isTableLoading: false,
})
async function getDiagnoses() {
isLoading.isTableLoading = true
const resp = await xfetch('/api/v1/diagnose-src')
if (resp.success) {
diagnoses.value = (resp.body as Record<string, any>).data
}
isLoading.isTableLoading = false
}
async function getProcedures() {
isLoading.isTableLoading = true
const resp = await xfetch('/api/v1/procedure-src')
if (resp.success) {
procedures.value = (resp.body as Record<string, any>).data
}
isLoading.isTableLoading = false
}
onMounted(() => {
const mode = route.query.mode
const recordId = route.query['record-id']
if (mode === 'entry' && recordId) {
loadEntryForEdit(+recordId)
}
})
// TODO: mapping data detail when edit
const loadEntryForEdit = async (id: number) => {
const result = await getDetail(id)
if (result?.success) {
const data = result.body?.data || {}
const value = JSON.parse(data.value || '{}')
model.value.witness1 = value?.witness1 || ''
model.value.witness2 = value?.witness2 || ''
model.value.informant = value?.informant || ''
model.value.responsibleName = value?.responsible || ''
model.value.responsiblePhone = value?.responsiblePhone || ''
model.value.relatives = value?.relatives || []
console.log('model', model.value)
}
}
function handleClick(type: string) {
if (type === 'prosedur') {
isOpenProcedure.value = true
} else if (type === 'diagnosa') {
isOpenDiagnose.value = true
} else if (type === 'fungsional') {
isOpenDiagnose.value = true
}
}
const entryGeneralConsent = ref()
async function actionHandler(type: string) {
if (type === 'back') {
backToList()
return
}
if (type === 'print') {
const data = await getDetail(recordId.value)
const detail = data.body?.data
fileUrl.value = detail?.fileUrl
isOpenDiagnose.value = true
return
}
const result = await entryGeneralConsent.value?.validate()
if (result?.valid) {
if (result.data.relatives.length > 0) {
result.data.relatives = result.data.relatives.map((item: any) => {
return item.name
})
}
console.log('data', result)
const resp = await handleActionSave(
{
...payload.value,
value: JSON.stringify(result.data),
encounter_id: +route.params.id,
},
() => {},
() => {},
toast,
)
const data = resp.body?.data
if (data) {
const resp2 = await create({
entityType_code: 'encounter',
ref_id: data?.id,
type_code: 'general-consent',
})
console.log('resp2', resp2.body?.data)
backToList()
}
} else {
console.log('Ada error di form', result)
}
}
const icdPreview = ref({
procedures: [],
diagnoses: [],
})
function actionDialogHandler(type: string) {
if (type === 'submit') {
// icdPreview.value.procedures = selectedProcedure.value || []
// icdPreview.value.diagnoses = selectedDiagnose.value || []
// icdPreview.value.fungsional = selectedFungsional.value || []
}
isOpenProcedure.value = false
isOpenDiagnose.value = false
}
provide('table_data_loader', isLoading)
provide('icdPreview', icdPreview)
</script>
<template>
<Entry
ref="entryGeneralConsent"
v-model="model"
:schema="schema"
@click="handleClick"
/>
<div class="my-2 flex justify-end py-2">
<Action @click="actionHandler" />
</div>
<Dialog
v-model:open="isOpenDiagnose"
title="Preview General Content"
size="xl"
prevent-outside
>
<embed
style="width: 100%; height: 90vh"
:src="fileUrl"
/>
</Dialog>
</template>
@@ -0,0 +1,179 @@
<script setup lang="ts">
// Components
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
import List from '~/components/app/general-consent/list.vue'
import Entry from '~/components/app/general-consent/entry.vue'
// Helpers
import { usePaginatedList } from '~/composables/usePaginatedList'
import { toast } from '~/components/pub/ui/toast'
// Types
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
import { GeneralConsentSchema, type GeneralConsentFormData } from '~/schemas/general-consent.schema'
// Handlers
import {
recId,
recAction,
recItem,
isReadonly,
isProcessing,
isFormEntryDialogOpen,
isRecordConfirmationOpen,
onResetState,
handleActionSave,
handleActionEdit,
handleActionRemove,
handleCancelForm,
} from '~/handlers/general-consent.handler'
// Services
import { getList, getDetail } from '~/services/general-consent.service'
// Models
import type { Encounter } from '~/models/encounter'
// Props
interface Props {
encounter: Encounter
}
const props = defineProps<Props>()
const emits = defineEmits(['add', 'edit'])
const router = useRouter()
const route = useRoute()
const { goToEntry, backToList } = useQueryCRUDMode('mode')
let units = ref<{ value: string; label: string }[]>([])
const encounterId = ref<number>(props?.encounter?.id || 0)
const title = ref('')
const {
data,
isLoading,
paginationMeta,
searchInput,
handlePageChange,
handleSearch,
fetchData: getMyList,
} = usePaginatedList({
fetchFn: async ({ page, search }) => {
const result = await getList({ 'encounter-id': props.encounter.id, includes: '', search, page })
if (result.success) {
data.value = result.body.data
}
return { success: result.success || false, body: result.body || {} }
},
entityName: 'general-consent',
})
const headerPrep: HeaderPrep = {
title: 'General Consent',
icon: 'i-lucide-box',
refSearchNav: {
placeholder: 'Cari (min. 3 karakter)...',
minLength: 3,
debounceMs: 500,
showValidationFeedback: true,
onInput: (value: string) => {
searchInput.value = value
},
onClick: () => {},
onClear: () => {},
},
addNav: {
label: 'Tambah',
icon: 'i-lucide-plus',
onClick: () => {
goToEntry()
},
},
}
const goEdit = (id: string) => {
router.replace({
path: route.path,
query: {
...route.query,
mode: 'entry',
'record-id': id,
},
})
}
const today = new Date()
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
const getMyDetail = async (id: number | string) => {
const result = await getDetail(id)
if (result.success) {
const currentValue = result.body?.data || {}
recItem.value = currentValue
isFormEntryDialogOpen.value = true
}
}
// Watch for row actions when recId or recAction changes
watch(recId, () => {
console.log('recId', recId.value)
if (recAction.value === ActionEvents.showEdit) {
goEdit(recId.value)
return
} else {
isRecordConfirmationOpen.value = true
}
})
onMounted(async () => {
await getMyList()
})
</script>
<template>
<Header
v-model="searchInput"
:prep="headerPrep"
:ref-search-nav="headerPrep.refSearchNav"
@search="handleSearch"
class="mb-4 xl:mb-5"
/>
<List
:data="data"
:pagination-meta="paginationMeta"
@page-change="handlePageChange"
/>
<!-- Record Confirmation Modal -->
<RecordConfirmation
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getMyList, toast)"
@cancel=""
>
<template #default="{ record }">
<div class="text-sm">
<p>
<strong>ID:</strong>
{{ record?.id }}
</p>
<p v-if="record?.name">
<strong>Nama:</strong>
{{ record.name }}
</p>
<p v-if="record?.code">
<strong>Kode:</strong>
{{ record.code }}
</p>
</div>
</template>
</RecordConfirmation>
</template>
@@ -0,0 +1,193 @@
<script setup lang="ts">
// Components
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
import AppMedicineFormList from '~/components/app/medicine-form/list.vue'
import AppMedicineFormEntryForm from '~/components/app/medicine-form/entry-form.vue'
// Helpers
import { usePaginatedList } from '~/composables/usePaginatedList'
import { toast } from '~/components/pub/ui/toast'
// Types
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
import { BaseSchema, type BaseFormData } from '~/schemas/base.schema'
// Handlers
import {
recId,
recAction,
recItem,
isReadonly,
isProcessing,
isFormEntryDialogOpen,
isRecordConfirmationOpen,
onResetState,
handleActionSave,
handleActionEdit,
handleActionRemove,
handleCancelForm,
} from '~/handlers/medicine-form.handler'
// Services
import { getList, getDetail } from '~/services/medicine-form.service'
const title = ref('')
const {
data,
isLoading,
paginationMeta,
searchInput,
handlePageChange,
handleSearch,
fetchData: getMedicineFormList,
} = usePaginatedList({
fetchFn: async (params: any) => {
const result = await getList({
search: params.search,
sort: 'createdAt:asc',
'page-number': params['page-number'] || 0,
'page-size': params['page-size'] || 10,
})
return { success: result.success || false, body: result.body || {} }
},
entityName: 'medicine-form',
})
const headerPrep: HeaderPrep = {
title: 'Sediaan Obat',
icon: 'i-lucide-medicine-bottle',
refSearchNav: {
placeholder: 'Cari (min. 3 karakter)...',
minLength: 3,
debounceMs: 500,
showValidationFeedback: true,
onInput: (value: string) => {
searchInput.value = value
},
onClick: () => {},
onClear: () => {},
},
addNav: {
label: 'Tambah',
icon: 'i-lucide-plus',
onClick: () => {
recItem.value = null
recId.value = 0
isFormEntryDialogOpen.value = true
isReadonly.value = false
},
},
}
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
const getCurrentMedicineFormDetail = async (id: number | string) => {
const result = await getDetail(id)
if (result.success) {
const currentValue = result.body?.data || {}
recItem.value = currentValue
isFormEntryDialogOpen.value = true
}
}
// Watch for row actions when recId or recAction changes
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
getCurrentMedicineFormDetail(recId.value)
title.value = 'Detail Sediaan Obat'
isReadonly.value = true
break
case ActionEvents.showEdit:
getCurrentMedicineFormDetail(recId.value)
title.value = 'Edit Sediaan Obat'
isFormEntryDialogOpen.value = true
isReadonly.value = false
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
break
}
})
onMounted(async () => {
await getMedicineFormList()
})
</script>
<template>
<Header
v-model="searchInput"
:prep="headerPrep"
:ref-search-nav="headerPrep.refSearchNav"
@search="handleSearch"
/>
<AppMedicineFormList
:data="data"
:pagination-meta="paginationMeta"
@page-change="handlePageChange"
/>
<Dialog
v-model:open="isFormEntryDialogOpen"
:title="!!recItem ? title : 'Tambah Sediaan Obat'"
size="lg"
prevent-outside
@update:open="
(value: any) => {
onResetState()
isFormEntryDialogOpen = value
}
"
>
<AppMedicineFormEntryForm
:schema="BaseSchema"
:values="recItem"
:is-loading="isProcessing"
:is-readonly="isReadonly"
@submit="
(values: BaseFormData | Record<string, any>, resetForm: () => void) => {
if (recId > 0) {
handleActionEdit(recItem.code, values, getMedicineFormList, resetForm, toast)
return
}
handleActionSave(values, getMedicineFormList, resetForm, toast)
}
"
@cancel="handleCancelForm"
/>
</Dialog>
<!-- Record Confirmation Modal -->
<RecordConfirmation
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recItem.code, getMedicineFormList, toast)"
@cancel=""
>
<template #default="{ record }">
<div class="text-sm">
<p>
<strong>ID:</strong>
{{ record?.id }}
</p>
<p v-if="record?.name">
<strong>Nama:</strong>
{{ record.name }}
</p>
<p v-if="record?.code">
<strong>Kode:</strong>
{{ record.code }}
</p>
</div>
</template>
</RecordConfirmation>
</template>
@@ -108,6 +108,7 @@ watch([recId, recAction], () => {
getCurrentMedicineGroupDetail(recId.value)
title.value = 'Edit Kelompok Obat'
isReadonly.value = false
isFormEntryDialogOpen.value = true
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
@@ -154,7 +155,7 @@ onMounted(async () => {
@submit="
(values: BaseFormData | Record<string, any>, resetForm: () => void) => {
if (recId > 0) {
handleActionEdit(recId, values, getMedicineGroupList, resetForm, toast)
handleActionEdit(recItem.code, values, getMedicineGroupList, resetForm, toast)
return
}
handleActionSave(values, getMedicineGroupList, resetForm, toast)
@@ -169,7 +170,7 @@ onMounted(async () => {
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getMedicineGroupList, toast)"
@confirm="() => handleActionRemove(recItem.code, getMedicineGroupList, toast)"
@cancel=""
>
<template #default="{ record }">
@@ -108,6 +108,7 @@ watch([recId, recAction], () => {
getCurrentMedicineMethodDetail(recId.value)
title.value = 'Edit Metode Obat'
isReadonly.value = false
isFormEntryDialogOpen.value = true
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
@@ -154,7 +155,7 @@ onMounted(async () => {
@submit="
(values: BaseFormData | Record<string, any>, resetForm: () => void) => {
if (recId > 0) {
handleActionEdit(recId, values, getMedicineMethodList, resetForm, toast)
handleActionEdit(recItem.code, values, getMedicineMethodList, resetForm, toast)
return
}
handleActionSave(values, getMedicineMethodList, resetForm, toast)
@@ -169,7 +170,7 @@ onMounted(async () => {
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getMedicineMethodList, toast)"
@confirm="() => handleActionRemove(recItem.code, getMedicineMethodList, toast)"
@cancel=""
>
<template #default="{ record }">
+8 -3
View File
@@ -37,10 +37,12 @@ import {
import { getList, getDetail } from '~/services/medicine.service'
import { getValueLabelList as getMedicineGroupList } from '~/services/medicine-group.service'
import { getValueLabelList as getMedicineMethodList } from '~/services/medicine-method.service'
import { getValueLabelList as getMedicineFormList } from '~/services/medicine-form.service'
import { getValueLabelList as getUomList } from '~/services/uom.service'
const medicineGroups = ref<{ value: string; label: string }[]>([])
const medicineMethods = ref<{ value: string; label: string }[]>([])
const medicineForms = ref<{ value: string; label: string }[]>([])
const uoms = ref<{ value: string; label: string }[]>([])
const title = ref('')
@@ -59,7 +61,7 @@ const {
sort: 'createdAt:asc',
'page-number': params['page-number'] || 0,
'page-size': params['page-size'] || 10,
includes: 'medicineGroup,medicineMethod,uom',
includes: 'medicineGroup,medicineMethod,medicineForm,uom',
})
return { success: result.success || false, body: result.body || {} }
},
@@ -116,6 +118,7 @@ watch([recId, recAction], () => {
case ActionEvents.showEdit:
getCurrentMedicineDetail(recId.value)
title.value = 'Edit Obat'
isFormEntryDialogOpen.value = true
isReadonly.value = false
break
case ActionEvents.showConfirmDelete:
@@ -127,6 +130,7 @@ watch([recId, recAction], () => {
onMounted(async () => {
medicineGroups.value = await getMedicineGroupList({ sort: 'createdAt:asc', 'page-size': 100 })
medicineMethods.value = await getMedicineMethodList({ sort: 'createdAt:asc', 'page-size': 100 })
medicineForms.value = await getMedicineFormList({ sort: 'createdAt:asc', 'page-size': 100 })
uoms.value = await getUomList({ sort: 'createdAt:asc', 'page-size': 100 })
await getMedicineList()
})
@@ -163,13 +167,14 @@ onMounted(async () => {
:values="recItem"
:medicineGroups="medicineGroups"
:medicineMethods="medicineMethods"
:medicineForms="medicineForms"
:uoms="uoms"
:is-loading="isProcessing"
:is-readonly="isReadonly"
@submit="
(values: MedicineFormData | Record<string, any>, resetForm: () => void) => {
if (recId > 0) {
handleActionEdit(recId, values, getMedicineList, resetForm, toast)
handleActionEdit(recItem.code, values, getMedicineList, resetForm, toast)
return
}
handleActionSave(values, getMedicineList, resetForm, toast)
@@ -184,7 +189,7 @@ onMounted(async () => {
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getMedicineList, toast)"
@confirm="() => handleActionRemove(recItem.code, getMedicineList, toast)"
@cancel=""
>
<template #default="{ record }">
+287 -53
View File
@@ -1,86 +1,215 @@
<script setup lang="ts">
import { type HeaderPrep, ActionEvents } from '~/components/pub/my-ui/data/types'
import Nav from '~/components/pub/my-ui/nav-footer/ba-de-su.vue'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import Dialog from '~/components/pub/my-ui/modal/dialog.vue'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
import * as DE from '~/components/pub/my-ui/doc-entry'
import { toast } from '~/components/pub/ui/toast'
import { useQueryCRUDMode } from '~/composables/useQueryCRUD'
import type { HeaderPrep } from '~/components/pub/my-ui/data/types'
// Medicine
import { type Medicine } from '~/models/medicine'
import { getList as getMedicineList } from '~/services/medicine.service'
// Prescription
import { getDetail } from '~/services/prescription.service'
import Detail from '~/components/app/prescription/detail.vue'
import { getList as getPrescriptionItemList } from '~/services/prescription-item.service'
import ItemListEntry from '~/components/app/prescription-item/list-entry.vue'
import { type PrescriptionItem } from '~/models/prescription-item'
import MixItemEntry from '~/components/app/prescription-item/mix-entry.vue'
import { create } from '~/services/prescription-item.service';
import NonMixItemEntry from '~/components/app/prescription-item/non-mix-entry.vue'
// import Detail from '~/components/app/prescription/detail.vue'
import Entry from '~/components/app/prescription/entry.vue'
import { remove, submit } from '~/services/prescription.service'
// Prescription items
import {
getList as getItemList,
create as createItem,
update as updateItem,
} from '~/services/prescription-item.service'
import {
recId,
recAction,
recItem,
isRecordConfirmationOpen,
handleActionRemove,
} from '~/handlers/prescription-item.handler'
// props
import { type PrescriptionItem, genPrescriptionItem } from '~/models/prescription-item'
import { type MedicinemixItem } from '~/models/medicinemix-item';
import ItemListEntry from '~/components/app/prescription-item/list-entry.vue'
import NonMixItemEntry from '~/components/app/prescription-item/non-mix-entry.vue'
import MixItemEntry from '~/components/app/prescription-item/mix-entry.vue'
// Props
const props = defineProps<{
encounter_id: number
}>()
// declaration & flows
// const route = useRoute()
const { getQueryParam } = useQueryParam()
const id = getQueryParam('id')
const dataRes = await getDetail(
typeof id === 'string' ? parseInt(id) : 0,
{ includes: 'encounter,doctor,doctor-employee,doctor-employee-person' }
)
const data = dataRes.body?.data || null
const items = ref(data?.items || [])
// Prescriptions
const isSubmitConfirmationOpen = ref(false)
const isDeleteConfirmationOpen = ref(false)
// Prescription Items
const isItemDetailDialogOpen = ref(false)
// Prescription
const { getQueryParam } = useQueryParam()
const rawId = getQueryParam('id')
const id = typeof rawId === 'string' ? parseInt(rawId) : 0
const dataRes = await getDetail(id, { includes: 'encounter,doctor,doctor-employee,doctor-employee-person' })
const data = ref(dataRes.body?.data || null)
// Prescription Items
const getItemsOpt = { 'prescription-id': id, includes: 'medicine,medicine-medicineForm,medicineMix' }
const {
data: prescriptionItems,
fetchData: getMyList,
} = usePaginatedList<PrescriptionItem> ({
fetchFn: async ({ page, search }) => {
const result = await getPrescriptionItemList({ 'prescription-id': id, search, page })
if (result.success) {
data.value = result.body.data
}
data: items,
isLoading,
fetchData: getPrescriptionItems,
} = usePaginatedList({
fetchFn: async (params: any) => {
const result = await getItemList({
...getItemsOpt,
search: params.search,
sort: 'createdAt:asc',
'page-number': params['page-number'] || 0,
'page-size': params['page-size'] || 10,
})
return { success: result.success || false, body: result.body || {} }
},
entityName: 'prescription-item',
entityName: 'division',
})
// const items = ref<PrescriptionItem[]>([])
const mixItem = ref<PrescriptionItem>(genPrescriptionItem())
const medicinemixItems = ref<MedicinemixItem[]>([])
const nonMixItem = ref<PrescriptionItem>(genPrescriptionItem())
mixItem.value.prescription_id = id
nonMixItem.value.prescription_id = id
const { backToList } = useQueryCRUDMode()
const headerPrep: HeaderPrep = {
title: 'Tambah Order Obat / Resep',
title: 'Pembuatan Order Obat / Resep',
icon: 'i-lucide-box',
}
const mixDialogOpen = ref(false)
const nonMixDialogOpen = ref(false)
const mixDialogOpenStatus = ref(false)
const nonMixDialogOpenStatus = ref(false)
const medicines = ref<Medicine[]>([])
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
watch([recId, recAction], () => {
let item: PrescriptionItem | null
switch (recAction.value) {
case ActionEvents.showDetail:
item = pickItem()
if (item) {
isItemDetailDialogOpen.value = true
}
break
case ActionEvents.showEdit:
item = pickItem()
if (item) {
if(item.isMix) {
mixDialogOpenStatus.value = true
} else {
nonMixDialogOpenStatus.value = true
}
getMedicines('', item.medicine_code)
}
break
case ActionEvents.showConfirmDelete:
isRecordConfirmationOpen.value = true
break
}
})
onMounted(async () => {
await getPrescriptionItems()
})
function navClick(type: 'back' | 'delete' | 'draft' | 'submit') {
if (type === 'back') {
backToList()
} else if (type === 'delete') {
isDeleteConfirmationOpen.value = true
} else if (type === 'submit') {
isSubmitConfirmationOpen.value = true
}
}
async function removePrescription() {
const res = await remove(id)
if (res.success) {
backToList()
}
// handleActionRemove(recId.value, getItems, toast)
}
async function submitPrescription() {
const res = await submit(id)
if (res.success) {
backToList()
}
// handleActionRemove(recId.value, getItems, toast)
}
function addItem(mode: 'mix' | 'non-mix') {
if (mode === 'mix') {
mixDialogOpen.value = true
mixDialogOpenStatus.value = true
} else if (mode === 'non-mix') {
nonMixDialogOpen.value = true
nonMixDialogOpenStatus.value = true
}
}
function saveMix() {
create({data})
async function saveMix() {
const res = await createItem(mixItem.value)
if (res.success) {
toast({ title: 'Berhasil', description: 'Resep telah di ajukan', variant: 'default' })
getPrescriptionItems()
mixDialogOpenStatus.value = false
}
}
function saveNonMix(data: PrescriptionItem) {
create({data})
async function saveNonMix() {
let res: any;
if(!nonMixItem.value.id) {
res = await createItem(nonMixItem.value)
} else {
res = await updateItem(nonMixItem.value.id, nonMixItem.value)
}
if (res.success) {
toast({ title: 'Berhasil', description: 'Resep telah di ajukan', variant: 'default' })
getPrescriptionItems()
nonMixDialogOpenStatus.value = false
}
}
async function getMedicines(value: string, code?: string) {
const res = await getMedicineList({ 'search': value, 'includes': 'medicineForm', 'code': code })
if (res.success) {
medicines.value = res.body.data
} else {
medicines.value = []
}
}
function pickItem(): PrescriptionItem | null {
const item = items.value.find(item => item.id === recId.value)
if (!item) {
return null
}
if(item.isMix) {
mixItem.value = item
} else {
nonMixItem.value = item
}
return item
}
</script>
@@ -91,42 +220,147 @@ function saveNonMix(data: PrescriptionItem) {
class="mb-4 xl:mb-5"
/>
<Detail :data="data" />
<Entry :data="data" />
<!-- <div class="mb-8">
<Button>
<Icon name="i-lucide-check" />
Simpan
</Button>
</div> -->
<ItemListEntry
:data="prescriptionItems"
:data="items"
@add="addItem"/>
<Separator class="my-5" />
<div class="w-full flex justify-center">
<Nav @click="navClick" />
</div>
<!-- Confirm delete -->
<RecordConfirmation
v-model:open="isDeleteConfirmationOpen"
action="delete"
:record="recItem"
@confirm="removePrescription()"
/>
<!-- Confirm submit -->
<RecordConfirmation
v-model:open="isSubmitConfirmationOpen"
action="delete"
customTitle="Ajukan Resep"
customMessage="Proses akan mengajukan resep ini untuk diproses lebih lanjut. Lanjutkan?"
customConfirmText="Ajukan"
:record="recItem"
@confirm="submitPrescription"
@cancel=""
/>
<!-- Mix form -->
<Dialog
v-model:open="mixDialogOpen"
:title="recItem?.id ? 'Edit Racikan' : 'Tambah Racikan'"
size="xl"
v-model:open="mixDialogOpenStatus"
title="Pembuatan Racikan"
size="lg"
prevent-outside
>
<MixItemEntry
:data="data"
:items="items"
@close="mixDialogOpen = false"
:data="mixItem"
:items="medicinemixItems"
:medicines="medicines"
@close="mixDialogOpenStatus = false"
@save="saveMix"
@update:searchText="getMedicines"
/>
</Dialog>
<!-- Non mix form -->
<Dialog
v-model:open="nonMixDialogOpen"
:title="recItem?.id ? 'Edit Non Racikan' : 'Tambah Non Racikan'"
size="xl"
v-model:open="nonMixDialogOpenStatus"
title="Pembuatan Non Racikan"
size="lg"
prevent-outside
>
<NonMixItemEntry
:data="data"
:items="items"
@close="mixDialogOpen = false"
:data="nonMixItem"
:medicines="medicines"
@close="mixDialogOpenStatus = false"
@save="saveNonMix"
@update:searchText="getMedicines"
/>
</Dialog>
<!-- Detail item -->
<Dialog
v-model:open="isItemDetailDialogOpen"
title="Detail Obat"
size="lg"
prevent-outside
>
<DE.Block mode="preview" label-size="small">
<DE.Cell>
<DE.Label>Nama</DE.Label>
<DE.Colon />
<DE.Field>
{{ recItem.medicine.name }}
</DE.Field>
</DE.Cell>
<DE.Cell>
<DE.Label>Dosis</DE.Label>
<DE.Colon />
<DE.Field>
{{ recItem.dose }}
</DE.Field>
</DE.Cell>
<DE.Cell>
<DE.Label>Sediaan</DE.Label>
<DE.Colon />
<DE.Field>
{{ recItem.medicine.medicineForm.name }}
</DE.Field>
</DE.Cell>
<DE.Cell>
<DE.Label>Jumlah</DE.Label>
<DE.Colon />
<DE.Field>
{{ recItem.quantity }}
</DE.Field>
</DE.Cell>
<DE.Cell>
<DE.Label>Cara Pakai</DE.Label>
<DE.Colon />
<DE.Field>
{{ recItem.Usage }}
</DE.Field>
</DE.Cell>
</DE.Block>
</Dialog>
<!-- Confirm delete items -->
<RecordConfirmation
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getPrescriptionItems, toast)"
@cancel=""
>
<template #default="{ record }">
<div class="text-sm">
<p>
<strong>ID:</strong>
{{ record?.id }}
</p>
<p v-if="record?.name">
<strong>Nama:</strong>
{{ record.name }}
</p>
<p v-if="record?.code">
<strong>Kode:</strong>
{{ record.code }}
</p>
</div>
</template>
</RecordConfirmation>
</template>
+106 -64
View File
@@ -1,8 +1,10 @@
<script setup lang="ts">
// Composables
import { usePaginatedList } from '~/composables/usePaginatedList'
// Pubs component
import { toast } from '~/components/pub/ui/toast'
import { ActionEvents, type HeaderPrep } from '~/components/pub/my-ui/data/types'
import { type HeaderPrep } from '~/components/pub/my-ui/data/types'
import Header from '~/components/pub/my-ui/nav-header/prep.vue'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
@@ -12,7 +14,6 @@ import {
recAction,
recItem,
isReadonly,
isFormEntryDialogOpen,
isRecordConfirmationOpen,
handleActionRemove,
handleActionSave,
@@ -20,17 +21,17 @@ import {
// Services
import { getList, getDetail } from '~/services/prescription.service'
import List from '~/components/app/prescription/list.vue'
import FlatList from '~/components/app/prescription/flat-list.vue'
import Grouped from '~/components/app/prescription/grouped-list.vue'
import type { Prescription } from '~/models/prescription'
const props = defineProps<{
encounter_id: number
}>()
import { submit } from '~/services/prescription.service'
import type { ToastFn } from '~/handlers/_handler'
const route = useRoute()
const { setQueryParams } = useQueryParam()
const title = ref('')
const isSubmitConfirmationOpen = ref(false)
const plainEid = route.params.id
const encounter_id = (plainEid && typeof plainEid == 'string') ? parseInt(plainEid) : 0
@@ -42,21 +43,40 @@ const {
searchInput,
fetchData: getMyList,
} = usePaginatedList<Prescription>({
fetchFn: async ({ page, search }) => {
fetchFn: async (params: any) => {
const result = await getList({
search,
page,
'encounter-id': encounter_id,
includes: 'doctor,doctor-employee,doctor-employee-person',
includes: 'doctor,doctor-employee,doctor-employee-person,items,items-medicine,items-medicine-medicineForm',
search: params.search,
page: params.page,
'page-number': params['page-number'] || 0,
'page-size': params['page-size'] || 10,
})
return { success: result.success || false, body: result.body || {} }
},
entityName: 'prescription'
})
function updateProvidedVal(val: boolean) {
flatMode.value = val
}
const flatMode = ref(false)
const flatModeLabel = ref('Mode Flat: Tidak')
provide('flatMode', { flatMode, updateProvidedVal })
watch(flatMode, (newVal) => {
flatModeLabel.value = newVal ? 'Mode Flat: Ya' : 'Mode Flat: Tidak'
})
const vFn = () => {} // Void function
const headerPrep: HeaderPrep = {
title: 'Order Obat',
icon: 'i-lucide-box',
components: [
{
component: defineAsyncComponent(() => import('~/components/pub/my-ui/toggle/provided-toggle.vue')),
props: { variant: 'outline', label: flatModeLabel, providedKey: 'flatMode' }
},
],
refSearchNav: {
placeholder: 'Cari (min. 3 karakter)...',
minLength: 3,
@@ -71,11 +91,17 @@ const headerPrep: HeaderPrep = {
addNav: {
label: 'Tambah',
icon: 'i-lucide-plus',
onClick: () => {
onClick: async () => {
recItem.value = null
recId.value = 0
isFormEntryDialogOpen.value = true
isReadonly.value = false
const saveResp = await handleActionSave({ encounter_id }, vFn, vFn, vFn)
if (saveResp.success) {
setQueryParams({
'mode': 'entry',
'id': saveResp.body?.data?.id.toString()
})
}
},
},
}
@@ -85,53 +111,13 @@ provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
const getMyDetail = async (id: number | string) => {
const result = await getDetail(id)
if (result.success) {
const currentValue = result.body?.data || {}
recItem.value = currentValue
isFormEntryDialogOpen.value = true
}
}
// Watch for row actions when recId or recAction changes
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showDetail:
getMyDetail(recId.value)
title.value = 'Detail Konsultasi'
isReadonly.value = true
break
case ActionEvents.showEdit:
getMyDetail(recId.value)
title.value = 'Edit Konsultasi'
isReadonly.value = false
break
case ActionEvents.showConfirmDelete:
break
}
})
watch([isFormEntryDialogOpen], async () => {
if (isFormEntryDialogOpen.value) {
isFormEntryDialogOpen.value = false;
const saveResp = await handleActionSave({ encounter_id }, getMyList, () =>{}, toast)
if (saveResp.success) {
setQueryParams({
'mode': 'entry',
'id': saveResp.body?.data?.id.toString()
})
}
}
})
function cancel(data: Prescription) {
function confirmCancel(data: Prescription) {
recId.value = data.id
recItem.value = data
isRecordConfirmationOpen.value = true
}
function edit(data: Prescription) {
function goToEdit(data: Prescription) {
setQueryParams({
'mode': 'entry',
'id': data.id.toString()
@@ -139,21 +125,45 @@ function edit(data: Prescription) {
recItem.value = data
}
function submit(data: Prescription) {
function confirmSubmit(data: Prescription) {
recId.value = data.id
recItem.value = data
isSubmitConfirmationOpen.value = true
}
async function handleActionSubmit(id: number, refresh: () => void, toast: ToastFn) {
const result = await submit(id)
if (result.success) {
toast({ title: 'Berhasil', description: 'Resep telah di ajukan', variant: 'default' })
setTimeout(refresh, 300)
} else {
toast({ title: 'Gagal', description: 'Gagal menjalankan perintah', variant: 'destructive' })
}
}
</script>
<template>
<Header :prep="{ ...headerPrep }" />
<List
v-if="!isLoading.dataListLoading"
:data="data"
:pagination-meta="paginationMeta"
@cancel="cancel"
@edit="edit"
@submit="submit"
/>
<template v-if="!flatMode">
<Grouped
v-if="!isLoading.dataListLoading"
:data="data"
:pagination-meta="paginationMeta"
@cancel="confirmCancel"
@edit="goToEdit"
@submit="confirmSubmit"
/>
</template>
<template v-else>
<FlatList
v-if="!isLoading.dataListLoading"
:data="data"
:pagination-meta="paginationMeta"
@cancel="confirmCancel"
@edit="goToEdit"
@submit="confirmSubmit"
/>
</template>
<RecordConfirmation
v-model:open="isRecordConfirmationOpen"
@@ -162,5 +172,37 @@ function submit(data: Prescription) {
@confirm="() => handleActionRemove(recId, getMyList, toast)"
@cancel=""
>
<div class="flex mb-2">
<div class="w-20">Tanggal</div>
<div class="w-4">:</div>
<div class="">{{ recItem.createdAt.substring(0, 10) }}</div>
</div>
<div class="flex">
<div class="w-20">DPJP</div>
<div class="w-4">:</div>
<div class="">{{ recItem.doctor?.employee?.person?.name }}</div>
</div>
</RecordConfirmation>
<RecordConfirmation
v-model:open="isSubmitConfirmationOpen"
action="delete"
customTitle="Ajukan Resep"
customMessage="Proses akan mengajukan resep ini untuk diproses lebih lanjut. Lanjutkan?"
customConfirmText="Ajukan"
:record="recItem"
@confirm="() => handleActionSubmit(recId, getMyList, toast)"
@cancel=""
>
<div class="flex mb-2">
<div class="w-20">Tanggal</div>
<div class="w-4">:</div>
<div class="">{{ recItem.createdAt.substring(0, 10) }}</div>
</div>
<div class="flex">
<div class="w-20">DPJP</div>
<div class="w-4">:</div>
<div class="">{{ recItem.doctor?.employee?.person?.name }}</div>
</div>
</RecordConfirmation>
</template>
+200
View File
@@ -0,0 +1,200 @@
<script setup lang="ts">
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<{
callbackUrl?: string
}>()
// 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
function goBack() {
router.go(-1)
}
async function handleConfirmAdd() {
// handleActionClick('submit')
console.log(`tersubmit wak`)
}
function handleCancelAdd() {
isConfirmationOpen.value = false
}
// #endregion region
// #region Utilities & event handlers
async function handleActionClick(eventType: string) {
if (eventType === 'submit') {
isConfirmationOpen.value = true
// 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') {
if (props.callbackUrl) {
await navigateTo(props.callbackUrl)
return
}
goBack()
// handleCancelForm()
}
}
// #endregion
// #region Watchers
// #endregion
</script>
<template>
<div class="mb-5 border-b border-b-slate-300 pb-3 text-lg font-semibold xl:text-xl">Tambah Resume</div>
<AppResumeAdd
ref="personPatientForm"
:schema="ResumeSchema"
:resume-arrangement-type="personPatientForm?.values.arrangement"/>
<div class="my-2 flex justify-end py-2">
<Action :enable-draft="false"
@click="handleActionClick"/>
</div>
<Confirmation
v-model:open="isConfirmationOpen"
title="Simpan Data"
message="Apakah Anda yakin ingin menyimpan data ini?"
confirm-text="Simpan"
@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>
+215
View File
@@ -0,0 +1,215 @@
<script setup lang="ts">
import type { HeaderPrep, RefSearchNav } from '~/components/pub/my-ui/data/types'
import type { Summary } from '~/components/pub/my-ui/summary-card/type'
// #region Imports
import { Calendar, Hospital, UserCheck, UsersRound } from 'lucide-vue-next'
import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue'
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'
import type { ExposedForm } from '~/types/form'
import { VerificationSchema } from '~/schemas/verification.schema'
import DocPreviewDialog from '~/components/pub/my-ui/modal/doc-preview-dialog.vue'
import type { PagePermission } from '~/models/role'
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
import { unauthorizedToast } from '~/lib/utils'
// #endregion
// #region Permission
const roleAccess: PagePermission = PAGE_PERMISSIONS['/rehab/encounter']
const { getPagePermissions } = useRBAC()
const pagePermission = getPagePermissions(roleAccess)
// #region State
const { data, isLoading, paginationMeta, searchInput, handlePageChange, handleSearch, fetchData } = usePaginatedList({
fetchFn: (params) => getPatients({ ...params, includes: ['person', 'person-Addresses'] }),
entityName: 'patient',
})
const refSearchNav: RefSearchNav = {
onClick: () => {
// open filter modal
},
onInput: (val: string) => {
searchInput.value = val
},
onClear: () => {
searchInput.value = ''
},
}
const verificationInputForm = ref<ExposedForm<any> | null>(null)
const isVerifyDialogOpen = ref(false)
const isDocPreviewDialogOpen = ref(false)
const isRecordConfirmationOpen = ref(false)
const summaryLoading = ref(false)
const recId = ref<number>(0)
const recAction = ref<string>('')
const recItem = ref<any>(null)
const isCaptchaValid = ref(false)
provide('isCaptchaValid', isCaptchaValid)
const headerPrep: HeaderPrep = {
title: "Resume",
icon: 'i-lucide-newspaper',
}
if (pagePermission.canCreate) {
headerPrep.addNav = {
label: "Resume",
onClick: () => navigateTo('/resume/add'),
}
}
// #endregion
// #region Lifecycle Hooks
onMounted(() => {
getPatientSummary()
})
// #endregion
// #region Functions
async function getPatientSummary() {
try {
summaryLoading.value = true
await new Promise((resolve) => setTimeout(resolve, 500))
} catch (error) {
console.error('Error fetching patient summary:', error)
} finally {
summaryLoading.value = false
}
}
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
// #region Provide
provide('rec_id', recId)
provide('rec_action', recAction)
provide('rec_item', recItem)
provide('table_data_loader', isLoading)
// #endregion
// #region Watchers
watch([recId, recAction], () => {
switch (recAction.value) {
case ActionEvents.showVerify:
if(pagePermission.canUpdate) {
isVerifyDialogOpen.value = true
} else {
unauthorizedToast()
}
break
case ActionEvents.showValidate:
if(pagePermission.canUpdate) {
isRecordConfirmationOpen.value = true
} else {
unauthorizedToast()
}
break
case ActionEvents.showPrint:
isDocPreviewDialogOpen.value = true
break
}
})
// #endregion
</script>
<template>
<Header :prep="{ ...headerPrep }" />
<!-- <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
ref="verificationInputForm"
:schema="VerificationSchema" />
<div class="flex justify-end">
<Action v-show="isCaptchaValid" :enable-draft="false" @click="handleActionClick" />
</div>
</Dialog>
<Dialog v-model:open="isDocPreviewDialogOpen" title="Preview Dokumen" size="2xl">
<DocPreviewDialog :link="`https://www.antennahouse.com/hubfs/xsl-fo-sample/pdf/basic-link-1.pdf`" />
</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>
+2 -2
View File
@@ -163,7 +163,7 @@ onMounted(async () => {
@submit="
(values: DeviceFormData, resetForm: any) => {
if (recId > 0) {
handleActionEdit(recId, values, getToolsList, resetForm, toast)
handleActionEdit(recItem.code, values, getToolsList, resetForm, toast)
return
}
handleActionSave(values, getToolsList, resetForm, toast)
@@ -178,7 +178,7 @@ onMounted(async () => {
v-model:open="isRecordConfirmationOpen"
action="delete"
:record="recItem"
@confirm="() => handleActionRemove(recId, getToolsList, toast)"
@confirm="() => handleActionRemove(recItem.code, getToolsList, toast)"
@cancel=""
>
<template #default="{ record }">