fix(role): add role in encounter home

This commit is contained in:
riefive
2025-11-13 15:36:31 +07:00
parent 8bb57de4cc
commit 5af84a8dc2
6 changed files with 175 additions and 34 deletions
@@ -3,5 +3,5 @@ import EncounterHome from '~/components/content/encounter/home.vue'
</script>
<template>
<EncounterHome classes="chemotherapy" />
<EncounterHome class-code="ambulatory" sub-class-code="chemo" />
</template>
+153 -28
View File
@@ -3,6 +3,7 @@ import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { getDetail } from '~/services/encounter.service'
import { getPositionAs } from '~/lib/roles'
import type { TabItem } from '~/components/pub/my-ui/comp-tab/type'
import CompTab from '~/components/pub/my-ui/comp-tab/comp-tab.vue'
@@ -17,11 +18,15 @@ import Consultation from '~/components/content/consultation/list.vue'
import ProtocolList from '~/components/app/chemotherapy/list.protocol.vue'
import MedicineProtocolList from '~/components/app/chemotherapy/list.medicine.vue'
const authStore = useUserStore()
const route = useRoute()
const router = useRouter()
const activeRole = authStore.getActiveRole()
const activePosition = getPositionAs(activeRole)
const props = defineProps<{
classes?: string
classCode?: 'ambulatory' | 'emergency' | 'inpatient' | 'outpatient'
subClassCode?: 'reg' | 'rehab' | 'chemo' | 'emg' | 'eon' | 'op' | 'icu' | 'hcu' | 'vk'
}>()
// activeTab selalu sinkron dengan query param
@@ -93,82 +98,202 @@ const tabsRaws: TabItem[] = [
{
value: 'status',
label: 'Status Masuk/Keluar',
groups: ['ambulatory', 'rehabilitation', 'chemotherapy'],
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'chemo', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
component: Status,
props: { encounter: data },
},
{
value: 'early-medical-assessment',
label: 'Pengkajian Awal Medis',
groups: ['ambulatory', 'rehabilitation', 'chemotherapy'],
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'chemo', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
component: EarlyMedicalAssesmentList,
},
{
value: 'rehab-medical-assessment',
label: 'Pengkajian Awal Medis Rehabilitasi Medis',
groups: ['ambulatory', 'rehabilitation', 'chemotherapy'],
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'chemo', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
component: EarlyMedicalRehabList,
},
{
value: 'function-assessment',
label: 'Asesmen Fungsi',
groups: ['ambulatory', 'rehabilitation'],
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
component: AssesmentFunctionList,
},
{ value: 'therapy-protocol', groups: ['ambulatory', 'rehabilitation'], label: 'Protokol Terapi' },
{
value: 'therapy-protocol',
groups: ['medical'],
classCode: ['ambulatory'],
subClassCode: ['rehab'],
label: 'Protokol Terapi',
},
{
value: 'chemotherapy-protocol',
label: 'Protokol Kemoterapi',
groups: ['chemotherapy'],
groups: ['medical', 'verificator'],
classCode: ['ambulatory'],
subClassCode: ['chemo'],
component: ProtocolList,
props: { data: protocolRows, paginationMeta },
},
{
value: 'chemotherapy-medicine',
label: 'Protokol Obat Kemoterapi',
groups: ['chemotherapy'],
groups: ['medical', 'verificator'],
classCode: ['ambulatory'],
subClassCode: ['chemo'],
component: MedicineProtocolList,
props: { data: protocolRows, paginationMeta },
},
{ value: 'report', label: 'Laporan Tindakan', groups: ['chemotherapy'] },
{ value: 'patient-note', label: 'CPRJ', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{
value: 'report',
label: 'Laporan Tindakan',
groups: ['medical'],
classCode: ['ambulatory'],
subClassCode: ['chemo'],
},
{
value: 'patient-note',
label: 'CPRJ',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'education-assessment',
label: 'Asesmen Kebutuhan Edukasi',
groups: ['ambulatory', 'rehabilitation', 'chemotherapy'],
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'consent',
label: 'General Consent',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'patient-note',
label: 'CPRJ',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{ value: 'consent', label: 'General Consent', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{ value: 'patient-note', label: 'CPRJ', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{
value: 'prescription',
label: 'Order Obat',
groups: ['ambulatory', 'rehabilitation', 'chemotherapy'],
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
component: PrescriptionList,
},
{ value: 'device', label: 'Order Alkes', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{ value: 'mcu-radiology', label: 'Order Radiologi', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{ value: 'mcu-lab-pc', label: 'Order Lab PK', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{ value: 'mcu-lab-micro', label: 'Order Lab Mikro', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{ value: 'mcu-lab-pa', label: 'Order Lab PA', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{ value: 'medical-action', label: 'Order Ruang Tindakan', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{ value: 'mcu-result', label: 'Hasil Penunjang', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{
value: 'device',
label: 'Order Alkes',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'mcu-radiology',
label: 'Order Radiologi',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'mcu-lab-pc',
label: 'Order Lab PK',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'mcu-lab-micro',
label: 'Order Lab Mikro',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'mcu-lab-pa',
label: 'Order Lab PA',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'medical-action',
label: 'Order Ruang Tindakan',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'mcu-result',
label: 'Hasil Penunjang',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'consultation',
label: 'Konsultasi',
groups: ['ambulatory', 'rehabilitation', 'chemotherapy'],
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
component: Consultation,
props: { encounter: data },
},
{ value: 'resume', label: 'Resume', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{ value: 'control', label: 'Surat Kontrol', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{ value: 'screening', label: 'Skrinning MPP', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{ value: 'supporting-document', label: 'Upload Dokumen Pendukung', groups: ['ambulatory', 'rehabilitation'] },
{ value: 'price-list', label: 'Tarif Tindakan', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] },
{
value: 'resume',
label: 'Resume',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'control',
label: 'Surat Kontrol',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'screening',
label: 'Skrinning MPP',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
{
value: 'supporting-document',
label: 'Upload Dokumen Pendukung',
groups: ['medical'],
classCode: ['ambulatory'],
subClassCode: ['rehab'],
},
{
value: 'price-list',
label: 'Tarif Tindakan',
groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
},
]
const tabs = computed(() => {
return tabsRaws
.filter((tab: TabItem) => tab.groups ? tab.groups.some((group: string) => props.classes?.includes(group)) : true)
.filter((tab: TabItem) => (tab.groups ? tab.groups.some((group: string) => group?.includes(activePosition)) : true))
.map((tab: TabItem) => {
return { ...tab, props: { ...tab.props, encounter: data } }
})
@@ -3,5 +3,7 @@ export interface TabItem {
label: string
component?: any
groups?: string[]
classCode?: string[]
subClassCode?: string[]
props?: Record<string, any>
}
+14
View File
@@ -0,0 +1,14 @@
const standartRoles = ['emp|doc', 'emp|nur', 'emp|reg', 'emp|pha', 'emp|pay', 'emp|mng']
const verificatorRole = 'verificator'
export function getPositionAs(roleAccess: string): string {
if (roleAccess.includes('|')) {
if (standartRoles.includes(roleAccess)) {
return 'medical'
}
if (roleAccess.includes(verificatorRole)) {
return 'verificator'
}
}
return 'none'
}
@@ -20,7 +20,7 @@ const roleAccess: PagePermission = PAGE_PERMISSIONS['/doctor']
const { checkRole, hasCreateAccess } = useRBAC()
Check if user has access to this page
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
if (!hasAccess) {
throw createError({
@@ -31,10 +31,10 @@ const roleAccess: PagePermission = PAGE_PERMISSIONS['/doctor'] || {}
const { checkRole, hasReadAccess } = useRBAC()
// Check if user has access to this page
const hasAccess = checkRole(roleAccess)
if (!hasAccess) {
navigateTo('/403')
}
// const hasAccess = checkRole(roleAccess)
// if (!hasAccess) {
// navigateTo('/403')
// }
// Define permission-based computed properties
const canRead = true // hasReadAccess(roleAccess)