Merge branch 'dev' of https://github.com/dikstub-rssa/simrs-fe into feat/assessment-adjustment-223
This commit is contained in:
@@ -7,8 +7,12 @@ 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'
|
||||
|
||||
// Constants
|
||||
import { paymentTypes, sepRefTypeCodes } from '~/lib/constants.vclaim'
|
||||
|
||||
// App libs
|
||||
import { getServicePosition } from '~/lib/roles' // previously getPositionAs
|
||||
|
||||
@@ -18,6 +22,10 @@ import {
|
||||
remove as removeEncounter,
|
||||
cancel as cancelEncounter,
|
||||
} from '~/services/encounter.service'
|
||||
import { getValueLabelList as getUnits } from '~/services/unit.service'
|
||||
|
||||
// Handlers
|
||||
import { uploadAttachmentCustom } from '~/handlers/supporting-document.handler'
|
||||
|
||||
// Apps
|
||||
import Content from '~/components/app/encounter/list.vue'
|
||||
@@ -53,9 +61,16 @@ const isLoading = reactive<DataTableLoader>({
|
||||
const recId = ref<number>(0)
|
||||
const recAction = ref<string>('')
|
||||
const recItem = ref<any>(null)
|
||||
const recSepId = ref<number>(0)
|
||||
const recSepMenu = ref<string>('')
|
||||
const recSepSubMenu = ref<string>('')
|
||||
const isFilterFormDialogOpen = ref(false)
|
||||
const isRecordConfirmationOpen = ref(false)
|
||||
const isRecordCancelOpen = ref(false)
|
||||
const uploadFile = ref<any>(null)
|
||||
const payments = ref<any>([])
|
||||
const units = ref<any>([])
|
||||
const sepsList = ref<any>([])
|
||||
|
||||
// Headers
|
||||
const hreaderPrep: CH.Config = {
|
||||
@@ -72,36 +87,14 @@ if (!props.canCreate) {
|
||||
delete hreaderPrep.addNav
|
||||
}
|
||||
|
||||
// Filters
|
||||
const filter = ref<{
|
||||
installation: {
|
||||
msg: {
|
||||
placeholder: string
|
||||
}
|
||||
items: {
|
||||
value: string
|
||||
label: string
|
||||
code: string
|
||||
}[]
|
||||
}
|
||||
schema: any
|
||||
initialValues?: Partial<any>
|
||||
errors?: any
|
||||
}>({
|
||||
installation: {
|
||||
msg: {
|
||||
placeholder: 'Pilih',
|
||||
},
|
||||
items: [],
|
||||
},
|
||||
schema: {},
|
||||
})
|
||||
|
||||
// Recrod reactivities
|
||||
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,15 +122,50 @@ watch(
|
||||
},
|
||||
)
|
||||
|
||||
onMounted(() => {
|
||||
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(async () => {
|
||||
getPatientList()
|
||||
units.value = await getUnits({}, true)
|
||||
payments.value = Object.keys(paymentTypes).map((item) => ({
|
||||
value: item.toString(),
|
||||
label: paymentTypes[item],
|
||||
})) as any
|
||||
sepsList.value = Object.keys(sepRefTypeCodes).map((item) => ({
|
||||
value: item.toString(),
|
||||
label: sepRefTypeCodes[item],
|
||||
})) as any
|
||||
})
|
||||
|
||||
/////// Functions
|
||||
async function getPatientList() {
|
||||
isLoading.isTableLoading = true
|
||||
const includesParams =
|
||||
'patient,patient-person,patient-person-addresses,unit,Appointment_Doctor,Appointment_Doctor-employee,Appointment_Doctor-employee-person,Responsible_Doctor,Responsible_Doctor-employee,Responsible_Doctor-employee-person'
|
||||
const includesParamsArrays = [
|
||||
'patient',
|
||||
'patient-person',
|
||||
'patient-person-addresses',
|
||||
'Appointment_Doctor',
|
||||
'Appointment_Doctor-employee',
|
||||
'Appointment_Doctor-employee-person',
|
||||
'Responsible_Doctor',
|
||||
'Responsible_Doctor-employee',
|
||||
'Responsible_Doctor-employee-person',
|
||||
'EncounterDocuments',
|
||||
'unit',
|
||||
'vclaimReference', // vclaimReference | vclaimSep
|
||||
]
|
||||
const includesParams = includesParamsArrays.join(',')
|
||||
data.value = []
|
||||
try {
|
||||
const params: any = { includes: includesParams, ...filterParams.value }
|
||||
@@ -159,15 +187,92 @@ async function getPatientList() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleUploadFile(id: number, menu: string) {
|
||||
uploadFile.value = null
|
||||
const fileInput: HTMLInputElement | undefined | null = document
|
||||
.getElementById('uploadFile')
|
||||
?.querySelector("input[type='file']")
|
||||
if (fileInput) {
|
||||
fileInput.value = ''
|
||||
fileInput.click()
|
||||
}
|
||||
}
|
||||
|
||||
async function handleUploadFileSubmit() {
|
||||
const files = uploadFile.value
|
||||
if (!uploadFile.value || files.length === 0) {
|
||||
recSepId.value = 0
|
||||
recSepMenu.value = ''
|
||||
recSepSubMenu.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',
|
||||
})
|
||||
}
|
||||
recSepId.value = 0
|
||||
recSepMenu.value = ''
|
||||
recSepSubMenu.value = ''
|
||||
}
|
||||
|
||||
function handleViewFile(id: number, menu: string, subMenu: string) {
|
||||
const currentData: any = data.value.find((item: any) => Number(item.id) === Number(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,
|
||||
// 'person-name': filters.personName,
|
||||
'patient-identifier': filters.personName,
|
||||
'start-date': filters.startDate,
|
||||
'end-date': filters.endDate,
|
||||
}
|
||||
getPatientList()
|
||||
}
|
||||
|
||||
function handleFilterReset() {
|
||||
isFilterFormDialogOpen.value = false
|
||||
filterParams.value = {}
|
||||
getPatientList()
|
||||
}
|
||||
|
||||
function handleFilterSearch(filters: any) {
|
||||
isFilterFormDialogOpen.value = false
|
||||
filterParams.value = { ...filterParams.value, ...filters }
|
||||
getPatientList()
|
||||
}
|
||||
|
||||
// Handle confirmation result
|
||||
async function handleConfirmCancel(record: any, action: string) {
|
||||
if (action === 'deactivate' && record?.id) {
|
||||
@@ -263,23 +368,34 @@ function handleRemoveConfirmation() {
|
||||
<CH.ContentHeader v-bind="hreaderPrep">
|
||||
<FilterNav
|
||||
:active-positon="activeServicePosition"
|
||||
:enable-export="false"
|
||||
@apply="handleFilterApply"
|
||||
@click="() => (isFilterFormDialogOpen = true)"
|
||||
@onExportPdf="() => {}"
|
||||
@onExportExcel="() => {}"
|
||||
@nExportCsv="() => {}"
|
||||
/>
|
||||
</CH.ContentHeader>
|
||||
|
||||
<Content :data="data" />
|
||||
<Content
|
||||
:data="data"
|
||||
:class-code="classCode"
|
||||
/>
|
||||
|
||||
<!-- Filter -->
|
||||
<Dialog
|
||||
v-model:open="isFilterFormDialogOpen"
|
||||
title="Filter"
|
||||
title="Filter Data"
|
||||
size="lg"
|
||||
prevent-outside
|
||||
>
|
||||
<FilterForm v-bind="filter" />
|
||||
<FilterForm
|
||||
:payments="payments"
|
||||
:units="units"
|
||||
:visits="sepsList"
|
||||
@search="handleFilterSearch"
|
||||
@reset="handleFilterReset"
|
||||
/>
|
||||
</Dialog>
|
||||
|
||||
<!-- Batal -->
|
||||
@@ -340,4 +456,15 @@ function handleRemoveConfirmation() {
|
||||
>
|
||||
Hak akses tidak memenuhi kriteria untuk proses ini.
|
||||
</Dialog>
|
||||
|
||||
<FileUpload
|
||||
class="hidden"
|
||||
field-name="uploadFile"
|
||||
label="Dokumen"
|
||||
placeholder="Pilih file"
|
||||
:accept="['pdf', 'jpg', 'png']"
|
||||
:max-size-mb="1"
|
||||
v-model="uploadFile"
|
||||
@file-selected="handleUploadFileSubmit"
|
||||
/>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user