diff --git a/app/components/app/encounter/entry-form.vue.backup b/app/components/app/encounter/entry-form-prev-00.vue similarity index 99% rename from app/components/app/encounter/entry-form.vue.backup rename to app/components/app/encounter/entry-form-prev-00.vue index f92b7736..a0c1ec28 100644 --- a/app/components/app/encounter/entry-form.vue.backup +++ b/app/components/app/encounter/entry-form-prev-00.vue @@ -43,7 +43,7 @@ const emit = defineEmits<{ }>() // Validation schema -const { handleSubmit, errors, defineField, meta } = useForm({ +const { handleSubmit, errors, defineField, meta } = useForm({ validationSchema: toTypedSchema(IntegrationEncounterSchema), }) @@ -141,7 +141,7 @@ function onAddSep() { registerDate: registerDate.value, cardNumber: cardNumber.value, paymentType: paymentType.value, - sepType: sepType.value + sepType: sepType.value, } emit('event', 'add-sep', formValues) } @@ -454,7 +454,7 @@ defineExpose({ name="i-lucide-loader-2" class="h-4 w-4 animate-spin" /> - { const recX = rec as Encounter - return recX.registeredAt ? (recX.registeredAt as string).substring(0, 10) : '-' + const currentDate = recX.registeredAt ? (recX.registeredAt as string) : (recX as any).createdAt + return currentDate ? currentDate.substring(0, 10) : '-' }, patientNumber: (rec: unknown): unknown => { const recX = rec as any @@ -194,10 +195,9 @@ export const ambulatoryConfig: Config = { }, components: { - sep(rec, idx) { + sep(rec) { const res: RecComponent = { rec: rec as object, - idx, component: vclaimSepInfo, } return res diff --git a/app/components/app/encounter/vclaim-sep-info.vue b/app/components/app/encounter/vclaim-sep-info.vue index a72e1352..06af4f85 100644 --- a/app/components/app/encounter/vclaim-sep-info.vue +++ b/app/components/app/encounter/vclaim-sep-info.vue @@ -1,33 +1,75 @@ diff --git a/app/components/content/encounter/list.vue b/app/components/content/encounter/list.vue index ebb49042..5cff930a 100644 --- a/app/components/content/encounter/list.vue +++ b/app/components/content/encounter/list.vue @@ -7,6 +7,7 @@ import { ActionEvents } from '~/components/pub/my-ui/data/types' import Dialog from '~/components/pub/my-ui/modal/dialog.vue' import * as CH from '~/components/pub/my-ui/content-header' import RecordConfirmation from '~/components/pub/my-ui/confirmation/record-confirmation.vue' +import FileUpload from '~/components/pub/my-ui/form/file-field.vue' import { useSidebar } from '~/components/pub/ui/sidebar/utils' // App libs @@ -19,6 +20,9 @@ import { cancel as cancelEncounter, } from '~/services/encounter.service' +// Handlers +import { uploadAttachmentCustom } from '~/handlers/supporting-document.handler' + // Apps import Content from '~/components/app/encounter/list.vue' import FilterNav from '~/components/app/encounter/filter-nav.vue' @@ -53,9 +57,13 @@ const isLoading = reactive({ const recId = ref(0) const recAction = ref('') const recItem = ref(null) +const recSepId = ref(0) +const recSepMenu = ref('') +const recSepSubMenu = ref('') const isFilterFormDialogOpen = ref(false) const isRecordConfirmationOpen = ref(false) const isRecordCancelOpen = ref(false) +const uploadFile = ref(null) // Headers const hreaderPrep: CH.Config = { @@ -102,6 +110,9 @@ provide('activeServicePosition', activeServicePosition) provide('rec_id', recId) provide('rec_action', recAction) provide('rec_item', recItem) +provide('rec_sep_id', recSepId) +provide('rec_sep_menu', recSepMenu) +provide('rec_sep_sub_menu', recSepSubMenu) provide('table_data_loader', isLoading) watch(getActiveRole, (role?: string) => { @@ -129,6 +140,19 @@ watch( }, ) +watch([recSepId, recSepMenu, recSepSubMenu], (value) => { + const id = value[0] + const menu = value[1] + const subMenu = value[2] + if (!id) return + if (subMenu === 'view') { + handleViewFile(id, menu, subMenu) + } + if (subMenu === 'edit') { + handleUploadFile(id, menu) + } +}) + onMounted(() => { getPatientList() }) @@ -172,6 +196,55 @@ async function getPatientList() { } } +function handleUploadFile(id: number, menu: string) { + uploadFile.value = null + document.getElementById('uploadFile')?.click() +} + +async function handleUploadFileSubmit() { + if (!uploadFile.value) return + const result = await uploadAttachmentCustom({ + file: uploadFile.value, + refId: recSepId.value, + entityTypeCode: 'encounter', + type: recSepMenu.value === 'sep' ? 'vclaim-sep' : 'vclaim-sipp', + }) + if (result.success) { + toast({ + title: 'Berhasil', + description: 'File berhasil diunggah', + variant: 'default', + }) + await getPatientList() + } else { + toast({ + title: 'Gagal', + description: 'File gagal diunggah', + variant: 'destructive', + }) + } +} + +function handleViewFile(id: number, menu: string, subMenu: string) { + const currentData: any = data.value.find((item: any) => item.id === id) + if (!currentData) return + let fileReviewSep: any = null + let fileReviewSipp: any = null + for (const doc of currentData.encounterDocuments) { + if (doc.type_code === 'vclaim-sep') { + fileReviewSep = { id: doc.id, fileName: doc.fileName, filePath: doc.filePath, type: doc.type_code } + } else if (doc.type_code === 'vclaim-sipp') { + fileReviewSipp = { id: doc.id, fileName: doc.fileName, filePath: doc.filePath, type: doc.type_code } + } + } + if (fileReviewSep && menu === 'sep' && subMenu === 'view') { + window.open(fileReviewSep.filePath, '_blank') + } + if (fileReviewSipp && menu === 'sipp' && subMenu === 'view') { + window.open(fileReviewSipp.filePath, '_blank') + } +} + function handleFilterApply(filters: { personName: string; startDate: string; endDate: string }) { filterParams.value = { 'person-name': filters.personName, @@ -356,4 +429,16 @@ function handleRemoveConfirmation() { > Hak akses tidak memenuhi kriteria untuk proses ini. + +