refactor: clean up role permission handling in encounter process pages
This commit is contained in:
@@ -95,7 +95,6 @@ function initMenus() {
|
||||
protocolChemotherapy: paginationMeta,
|
||||
medicineProtocolChemotherapy: paginationMeta,
|
||||
})
|
||||
console.log(menus.value)
|
||||
}
|
||||
|
||||
async function getData() {
|
||||
|
||||
@@ -33,7 +33,9 @@ const AssesmentFunctionListAsync = defineAsyncComponent(() => import('~/componen
|
||||
const EarlyMedicalAssesmentListAsync = defineAsyncComponent(() => import('~/components/content/soapi/entry.vue'))
|
||||
const EarlyMedicalRehabListAsync = defineAsyncComponent(() => import('~/components/content/soapi/entry.vue'))
|
||||
const ChemoProtocolListAsync = defineAsyncComponent(() => import('~/components/app/chemotherapy/list.protocol.vue'))
|
||||
const ChemoMedicineProtocolListAsync = defineAsyncComponent(() => import('~/components/app/chemotherapy/list.medicine.vue'))
|
||||
const ChemoMedicineProtocolListAsync = defineAsyncComponent(
|
||||
() => import('~/components/app/chemotherapy/list.medicine.vue'),
|
||||
)
|
||||
const DeviceOrderAsync = defineAsyncComponent(() => import('~/components/content/device-order/main.vue'))
|
||||
const PrescriptionAsync = defineAsyncComponent(() => import('~/components/content/prescription/main.vue'))
|
||||
const CpLabOrderAsync = defineAsyncComponent(() => import('~/components/content/cp-lab-order/main.vue'))
|
||||
@@ -92,13 +94,13 @@ const defaultKeys: Record<string, any> = {
|
||||
unit: 'chemo',
|
||||
afterId: 'chemotherapy-protocol',
|
||||
},
|
||||
educationAssessment: {
|
||||
educationAssessment: {
|
||||
id: 'education-assessment',
|
||||
title: 'Asesmen Kebutuhan Edukasi',
|
||||
classCode: ['ambulatory', 'emergency', 'inpatient'],
|
||||
unit: 'all',
|
||||
},
|
||||
consent: {
|
||||
consent: {
|
||||
id: 'consent',
|
||||
title: 'General Consent',
|
||||
classCode: ['ambulatory', 'emergency', 'inpatient'],
|
||||
@@ -277,13 +279,13 @@ export function injectComponents(id: string | number, data: EncounterListData, m
|
||||
paginationMeta: meta?.medicineProtocolChemotherapy,
|
||||
}
|
||||
}
|
||||
if (currentKeys?.educationAssessment) {
|
||||
if (currentKeys?.educationAssessment) {
|
||||
currentKeys.educationAssessment['component'] = null
|
||||
currentKeys.educationAssessment['props'] = { encounter_id: id }
|
||||
}
|
||||
if (currentKeys?.consent) {
|
||||
currentKeys.report['component'] = GeneralConsentListAsync
|
||||
currentKeys.report['props'] = { encounter_id: id }
|
||||
currentKeys.consent['component'] = GeneralConsentListAsync
|
||||
currentKeys.consent['props'] = { encounter_id: id }
|
||||
}
|
||||
if (currentKeys?.patientNote) {
|
||||
currentKeys.patientNote['component'] = null
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { PagePermission } from '~/models/role'
|
||||
import type { Permission } from '~/models/role'
|
||||
import { permissions } from '~/const/page-permission/emergency'
|
||||
import Error from '~/components/pub/my-ui/error/error.vue'
|
||||
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
||||
import EncounterProcess from '~/components/content/encounter/process-next.vue'
|
||||
|
||||
definePageMeta({
|
||||
@@ -11,35 +11,29 @@ definePageMeta({
|
||||
contentFrame: 'cf-full-width',
|
||||
})
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
useHead({
|
||||
title: () => `${route.meta.title}`, // backtick to avoid the ts-plugin(2322) warning
|
||||
})
|
||||
|
||||
const roleAccess: PagePermission = PAGE_PERMISSIONS['/emergency/encounter']
|
||||
|
||||
const { checkRole, hasCreateAccess } = useRBAC()
|
||||
// Preps role checking
|
||||
const roleAccess: Record<string, Permission[]> = permissions['/emergency/encounter'] || {}
|
||||
const { checkRole, hasReadAccess } = useRBAC()
|
||||
|
||||
// Check if user has access to this page
|
||||
const hasAccess = checkRole(roleAccess)
|
||||
if (!hasAccess) {
|
||||
throw createError({
|
||||
statusCode: 403,
|
||||
statusMessage: 'Access denied',
|
||||
})
|
||||
navigateTo('/403')
|
||||
}
|
||||
|
||||
// Define permission-based computed properties
|
||||
const canCreate = hasCreateAccess(roleAccess)
|
||||
const canRead = hasReadAccess(roleAccess)
|
||||
|
||||
// Page needs
|
||||
const route = useRoute()
|
||||
useHead({
|
||||
title: () => `${route.meta.title}`,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="canCreate">
|
||||
<div v-if="canRead">
|
||||
<EncounterProcess class-code="emergency" sub-class-code="emg" />
|
||||
</div>
|
||||
<Error
|
||||
v-else
|
||||
:status-code="403"
|
||||
/>
|
||||
</template>
|
||||
<Error v-else :status-code="403" />
|
||||
</template>
|
||||
@@ -1,7 +1,6 @@
|
||||
<script setup lang="ts">
|
||||
import type { Permission } from '~/models/role'
|
||||
import { permissions } from '~/const/page-permission/inpatient'
|
||||
import { PAGE_PERMISSIONS } from '~/lib/page-permission'
|
||||
import Error from '~/components/pub/my-ui/error/error.vue'
|
||||
import EncounterProcess from '~/components/content/encounter/process-next.vue'
|
||||
|
||||
@@ -13,7 +12,7 @@ definePageMeta({
|
||||
})
|
||||
|
||||
// Preps role checking
|
||||
const roleAccess: Record<string, Permission[]> = permissions['/outpatient/encounter'] || {}
|
||||
const roleAccess: Record<string, Permission[]> = permissions['/inpatient/encounter'] || {}
|
||||
const { checkRole, hasReadAccess } = useRBAC()
|
||||
|
||||
// Check if user has access to this page
|
||||
|
||||
Reference in New Issue
Block a user