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

No files matched your search

@@ -3,5 +3,5 @@ import EncounterHome from '~/components/content/encounter/home.vue'
</script> </script>
<template> <template>
<EncounterHome classes="chemotherapy" /> <EncounterHome class-code="ambulatory" sub-class-code="chemo" />
</template> </template>
+153 -28
View File
@@ -3,6 +3,7 @@ import { computed } from 'vue'
import { useRoute, useRouter } from 'vue-router' import { useRoute, useRouter } from 'vue-router'
import { getDetail } from '~/services/encounter.service' import { getDetail } from '~/services/encounter.service'
import { getPositionAs } from '~/lib/roles'
import type { TabItem } from '~/components/pub/my-ui/comp-tab/type' import type { TabItem } from '~/components/pub/my-ui/comp-tab/type'
import CompTab from '~/components/pub/my-ui/comp-tab/comp-tab.vue' 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 ProtocolList from '~/components/app/chemotherapy/list.protocol.vue'
import MedicineProtocolList from '~/components/app/chemotherapy/list.medicine.vue' import MedicineProtocolList from '~/components/app/chemotherapy/list.medicine.vue'
const authStore = useUserStore()
const route = useRoute() const route = useRoute()
const router = useRouter() const router = useRouter()
const activeRole = authStore.getActiveRole()
const activePosition = getPositionAs(activeRole)
const props = defineProps<{ 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 // activeTab selalu sinkron dengan query param
@@ -93,82 +98,202 @@ const tabsRaws: TabItem[] = [
{ {
value: 'status', value: 'status',
label: 'Status Masuk/Keluar', 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, component: Status,
props: { encounter: data }, props: { encounter: data },
}, },
{ {
value: 'early-medical-assessment', value: 'early-medical-assessment',
label: 'Pengkajian Awal Medis', 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, component: EarlyMedicalAssesmentList,
}, },
{ {
value: 'rehab-medical-assessment', value: 'rehab-medical-assessment',
label: 'Pengkajian Awal Medis Rehabilitasi Medis', 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, component: EarlyMedicalRehabList,
}, },
{ {
value: 'function-assessment', value: 'function-assessment',
label: 'Asesmen Fungsi', label: 'Asesmen Fungsi',
groups: ['ambulatory', 'rehabilitation'], groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
component: AssesmentFunctionList, 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', value: 'chemotherapy-protocol',
label: 'Protokol Kemoterapi', label: 'Protokol Kemoterapi',
groups: ['chemotherapy'], groups: ['medical', 'verificator'],
classCode: ['ambulatory'],
subClassCode: ['chemo'],
component: ProtocolList, component: ProtocolList,
props: { data: protocolRows, paginationMeta }, props: { data: protocolRows, paginationMeta },
}, },
{ {
value: 'chemotherapy-medicine', value: 'chemotherapy-medicine',
label: 'Protokol Obat Kemoterapi', label: 'Protokol Obat Kemoterapi',
groups: ['chemotherapy'], groups: ['medical', 'verificator'],
classCode: ['ambulatory'],
subClassCode: ['chemo'],
component: MedicineProtocolList, component: MedicineProtocolList,
props: { data: protocolRows, paginationMeta }, 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', value: 'education-assessment',
label: 'Asesmen Kebutuhan Edukasi', 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', value: 'prescription',
label: 'Order Obat', label: 'Order Obat',
groups: ['ambulatory', 'rehabilitation', 'chemotherapy'], groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
component: PrescriptionList, component: PrescriptionList,
}, },
{ value: 'device', label: 'Order Alkes', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, {
{ value: 'mcu-radiology', label: 'Order Radiologi', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, value: 'device',
{ value: 'mcu-lab-pc', label: 'Order Lab PK', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, label: 'Order Alkes',
{ value: 'mcu-lab-micro', label: 'Order Lab Mikro', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, groups: ['medical'],
{ value: 'mcu-lab-pa', label: 'Order Lab PA', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, classCode: ['ambulatory', 'emergency', 'inpatient'],
{ value: 'medical-action', label: 'Order Ruang Tindakan', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
{ value: 'mcu-result', label: 'Hasil Penunjang', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, },
{
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', value: 'consultation',
label: 'Konsultasi', label: 'Konsultasi',
groups: ['ambulatory', 'rehabilitation', 'chemotherapy'], groups: ['medical'],
classCode: ['ambulatory', 'emergency', 'inpatient'],
subClassCode: ['reg', 'rehab', 'emg', 'eon', 'op', 'icu', 'hcu', 'vk'],
component: Consultation, component: Consultation,
props: { encounter: data }, props: { encounter: data },
}, },
{ value: 'resume', label: 'Resume', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, {
{ value: 'control', label: 'Surat Kontrol', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, value: 'resume',
{ value: 'screening', label: 'Skrinning MPP', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, label: 'Resume',
{ value: 'supporting-document', label: 'Upload Dokumen Pendukung', groups: ['ambulatory', 'rehabilitation'] }, groups: ['medical'],
{ value: 'price-list', label: 'Tarif Tindakan', groups: ['ambulatory', 'rehabilitation', 'chemotherapy'] }, 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(() => { const tabs = computed(() => {
return tabsRaws 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) => { .map((tab: TabItem) => {
return { ...tab, props: { ...tab.props, encounter: data } } return { ...tab, props: { ...tab.props, encounter: data } }
}) })
@@ -3,5 +3,7 @@ export interface TabItem {
label: string label: string
component?: any component?: any
groups?: string[] groups?: string[]
classCode?: string[]
subClassCode?: string[]
props?: Record<string, any> 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() const { checkRole, hasCreateAccess } = useRBAC()
Check if user has access to this page // Check if user has access to this page
const hasAccess = checkRole(roleAccess) const hasAccess = checkRole(roleAccess)
if (!hasAccess) { if (!hasAccess) {
throw createError({ throw createError({
@@ -31,10 +31,10 @@ const roleAccess: PagePermission = PAGE_PERMISSIONS['/doctor'] || {}
const { checkRole, hasReadAccess } = useRBAC() const { checkRole, hasReadAccess } = useRBAC()
// Check if user has access to this page // Check if user has access to this page
const hasAccess = checkRole(roleAccess) // const hasAccess = checkRole(roleAccess)
if (!hasAccess) { // if (!hasAccess) {
navigateTo('/403') // navigateTo('/403')
} // }
// Define permission-based computed properties // Define permission-based computed properties
const canRead = true // hasReadAccess(roleAccess) const canRead = true // hasReadAccess(roleAccess)