diff --git a/app/composables/useRBAC.ts b/app/composables/useRBAC.ts index 076cae68..2383e306 100644 --- a/app/composables/useRBAC.ts +++ b/app/composables/useRBAC.ts @@ -17,12 +17,12 @@ export function useRBAC() { const checkRole = (roleAccess: RoleAccess, _userRoles?: string[]): boolean => { const roles = authStore.userRole - return roles.some((role: string) => (role in roleAccess) || role === 'system') // system by-passes this check + return roles.some((role: string) => role === 'system' || (role in roleAccess)) // system by-passes this check } const checkPermission = (roleAccess: RoleAccess, permission: Permission, _userRoles?: string[]): boolean => { const roles = authStore.userRole - return roles.some((role: string) => roleAccess[role]?.includes(permission) || role === 'system') // system by-passes this check + return roles.some((role: string) => role === 'system' || roleAccess[role]?.includes(permission)) // system by-passes this check } const getUserPermissions = (roleAccess: RoleAccess, _userRoles?: string[]): Permission[] => { diff --git a/app/lib/clinical-const.ts b/app/const/key-val/clinical.ts similarity index 100% rename from app/lib/clinical-const.ts rename to app/const/key-val/clinical.ts diff --git a/app/lib/common-const.ts b/app/const/key-val/common.ts similarity index 100% rename from app/lib/common-const.ts rename to app/const/key-val/common.ts diff --git a/app/lib/encounter-const.ts b/app/const/key-val/encounter.ts similarity index 100% rename from app/lib/encounter-const.ts rename to app/const/key-val/encounter.ts diff --git a/app/lib/org-const.ts b/app/const/key-val/org.ts similarity index 100% rename from app/lib/org-const.ts rename to app/const/key-val/org.ts diff --git a/app/lib/person-const.ts b/app/const/key-val/person.ts similarity index 100% rename from app/lib/person-const.ts rename to app/const/key-val/person.ts diff --git a/app/const/page-permission/chemo.ts b/app/const/page-permission/chemo.ts new file mode 100644 index 00000000..8796999e --- /dev/null +++ b/app/const/page-permission/chemo.ts @@ -0,0 +1,32 @@ +import type { Permission } from "~/models/role"; + +// Should we define the keys first? +// export type Keys = 'key1' | 'key2' | 'key3' | etc + +export const permissions: Record> = { + '/chemo/verification': { + 'emp|reg': ['R'], + 'emp|doc': ['R'], + 'emp|nur': ['R'], + }, + '/chemo/verification/[id]': { + 'emp|reg': ['R'], + 'emp|doc': ['R'], + 'emp|nur': ['R'], + }, + '/chemo/verification/[id]/process': { + 'emp|doc': ['R', 'U'], + 'emp|nur': ['R', 'U'], + }, + '/chemo/action': { + 'emp|reg': ['R', 'U', 'D'], + }, + '/chemo/action/[id]': { + 'emp|reg': ['R', 'U', 'D'], + }, + '/chemo/action/[id]/process': { + 'emp|doc': ['R', 'U'], + 'emp|nur': ['R', 'U'], + 'emp|thr': ['R', 'U'], + }, +} diff --git a/app/const/page-permission/emergency.ts b/app/const/page-permission/emergency.ts new file mode 100644 index 00000000..cfbab478 --- /dev/null +++ b/app/const/page-permission/emergency.ts @@ -0,0 +1,67 @@ +import type { Permission } from "~/models/role"; + +// Should we define the keys first? +// export type Keys = 'key1' | 'key2' | 'key3' | etc + +export const permissions: Record> = { + '/emergency/triage': { + 'emp|doc': ['C', 'R', 'U', 'D'], + 'emp|nur': ['C', 'R', 'U', 'D'], + }, + '/emergency/triage/add': { + 'emp|doc': ['C', 'R', 'U', 'D'], + 'emp|nur': ['C', 'R', 'U', 'D'], + }, + '/emergency/triage/[id]': { + 'emp|doc': ['C', 'R', 'U', 'D'], + 'emp|nur': ['C', 'R', 'U', 'D'], + }, + '/emergency/triage/[id]/edit': { + 'emp|doc': ['C', 'R', 'U', 'D'], + 'emp|nur': ['C', 'R', 'U', 'D'], + }, + '/emergency/encounter': { + 'emp|reg': ['C', 'R', 'U', 'D'], + 'emp|doc': ['R'], + 'emp|nur': ['R'], + 'emp|thr': ['R'], + 'emp|miw': ['R'], + 'emp|nut': ['R'], + 'emp|pha': ['R'], + 'emp|lab': ['R'], + 'emp|rad': ['R'], + }, + '/emergency/encounter/add': { + 'emp|reg': ['C', 'R', 'U', 'D'], + }, + '/emergency/encounter/[id]': { + 'emp|reg': ['C', 'R', 'U', 'D'], + 'emp|doc': ['R'], + 'emp|nur': ['R'], + 'emp|thr': ['R'], + 'emp|miw': ['R'], + 'emp|nut': ['R'], + 'emp|pha': ['R'], + 'emp|lab': ['R'], + 'emp|rad': ['R'], + }, + '/emergency/encounter/[id]/edit': { + 'emp|reg': ['C', 'R', 'U', 'D'], + }, + '/emergency/encounter/[id]/process': { + 'emp|doc': ['R', 'U'], + 'emp|nur': ['R', 'U'], + 'emp|thr': ['R', 'U'], + 'emp|miw': ['R', 'U'], + 'emp|nut': ['R', 'U'], + 'emp|pha': ['R', 'U'], + 'emp|lab': ['R', 'U'], + 'emp|rad': ['R', 'U'], + }, + '/emergency/consulation': { + 'emp|doc': ['R'], + }, + '/emergency/consulation/[id]/process': { + 'emp|doc': ['R', 'U'], + }, +} diff --git a/app/const/page-permission/human-src.ts b/app/const/page-permission/human-src.ts new file mode 100644 index 00000000..1698f3e5 --- /dev/null +++ b/app/const/page-permission/human-src.ts @@ -0,0 +1,25 @@ +import type { Permission } from "~/models/role"; + +// Should we define the keys first? +// export type Keys = 'key1' | 'key2' | 'key3' | etc + +export const permissions: Record> = { + '/human-src/employee': { + 'div|hrd': ['C', 'R', 'U', 'D'], + }, + '/human-src/employee/add': { + 'div|hrd': ['C', 'R', 'U', 'D'], + }, + '/human-src/employee/[id]/edit': { + 'div|hrd': ['C', 'R', 'U', 'D'], + }, + '/human-src/intern': { + 'div|hrd': ['C', 'R', 'U', 'D'], + }, + '/human-src/intern/add': { + 'div|hrd': ['C', 'R', 'U', 'D'], + }, + '/human-src/intern/[id]/edit': { + 'div|hrd': ['C', 'R', 'U', 'D'], + }, +} diff --git a/app/const/page-permission/inpatient.ts b/app/const/page-permission/inpatient.ts new file mode 100644 index 00000000..b116c5fa --- /dev/null +++ b/app/const/page-permission/inpatient.ts @@ -0,0 +1,57 @@ +import type { Permission } from "~/models/role"; + +// Should we define the keys first? +// export type Keys = 'key1' | 'key2' | 'key3' | etc + +export const permissions: Record> = { + '/inpatient/request': { + 'emp|reg': ['C', 'R', 'U', 'D'], + }, + '/inpatient/request/[id]/detail': { + 'emp|reg': ['C', 'R', 'U', 'D'], + }, + '/inpatient/encounter': { + 'emp|reg': ['C', 'R', 'U', 'D'], + 'emp|doc': ['R'], + 'emp|nur': ['R'], + 'emp|thr': ['R'], + 'emp|miw': ['R'], + 'emp|nut': ['R'], + 'emp|pha': ['R'], + 'emp|lab': ['R'], + 'emp|rad': ['R'], + }, + '/inpatient/encounter/add': { + 'emp|reg': ['C', 'R', 'U', 'D'], + }, + '/inpatient/encounter/[id]': { + 'emp|reg': ['C', 'R', 'U', 'D'], + 'emp|doc': ['R'], + 'emp|nur': ['R'], + 'emp|thr': ['R'], + 'emp|miw': ['R'], + 'emp|nut': ['R'], + 'emp|pha': ['R'], + 'emp|lab': ['R'], + 'emp|rad': ['R'], + }, + '/inpatient/encounter/[id]/edit': { + 'emp|reg': ['C', 'R', 'U', 'D'], + }, + '/inpatient/encounter/[id]/process': { + 'emp|doc': ['R', 'U'], + 'emp|nur': ['R', 'U'], + 'emp|thr': ['R', 'U'], + 'emp|miw': ['R', 'U'], + 'emp|nut': ['R', 'U'], + 'emp|pha': ['R', 'U'], + 'emp|lab': ['R', 'U'], + 'emp|rad': ['R', 'U'], + }, + '/inpatient/consulation': { + 'emp|doc': ['R'], + }, + '/inpatient/consulation/[id]/process': { + 'emp|doc': ['R', 'U'], + }, +} diff --git a/app/const/page-permission/mcu-src.ts b/app/const/page-permission/mcu-src.ts new file mode 100644 index 00000000..85ad5f71 --- /dev/null +++ b/app/const/page-permission/mcu-src.ts @@ -0,0 +1,19 @@ +import type { Permission } from "~/models/role"; + +// Should we define the keys first? +// export type Keys = 'key1' | 'key2' | 'key3' | etc + +export const permissions: Record> = { + '/muc-src/checkup': { + 'emp|lab': ['C', 'R', 'U', 'D'], + }, + '/muc-src/checkup-category': { + 'emp|lab': ['C', 'R', 'U', 'D'], + }, + '/mcu-src/antibiotic-src': { + 'emp|lab': ['C', 'R', 'U', 'D'], + }, + '/mcu-src/antibiotic-src-category': { + 'emp|lab': ['C', 'R', 'U', 'D'], + } +} diff --git a/app/const/page-permission/org-src.ts b/app/const/page-permission/org-src.ts new file mode 100644 index 00000000..9bd9eb68 --- /dev/null +++ b/app/const/page-permission/org-src.ts @@ -0,0 +1,31 @@ +import type { Permission } from "~/models/role"; + +// Should we define the keys first? +// export type Keys = 'key1' | 'key2' | 'key3' | etc + +export const permissions: Record> = { + '/infra-src/bed': { + 'div|fin': ['C', 'R', 'U', 'D'], + }, + '/infra-src/chamber': { + 'div|fin': ['C', 'R', 'U', 'D'], + }, + '/infra-src/room': { + 'div|fin': ['C', 'R', 'U', 'D'], + }, + '/infra-src/warehouse': { + 'div|fin': ['C', 'R', 'U', 'D'], + }, + '/infra-src/building': { + 'div|fin': ['C', 'R', 'U', 'D'], + }, + '/infra-src/floor': { + 'div|fin': ['C', 'R', 'U', 'D'], + }, + '/infra-src/counter': { + 'div|fin': ['C', 'R', 'U', 'D'], + }, + '/infra-src/public-screen': { + 'div|fin': ['C', 'R', 'U', 'D'], + }, +} diff --git a/app/const/page-permission/outpatient.ts b/app/const/page-permission/outpatient.ts new file mode 100644 index 00000000..644f63c9 --- /dev/null +++ b/app/const/page-permission/outpatient.ts @@ -0,0 +1,57 @@ +import type { Permission } from "~/models/role"; + +// Should we define the keys first? +// export type Keys = 'key1' | 'key2' | 'key3' | etc + +export const permissions: Record> = { + '/outpatient/registration-queue': { + 'emp|reg': ['R', 'U', 'D'], + }, + '/outpatient/encounter-queue': { + 'emp|nur': ['R', 'U', 'D'], + }, + '/outpatient/encounter': { + 'emp|reg': ['C', 'R', 'U', 'D'], + 'emp|doc': ['R'], + 'emp|nur': ['R'], + 'emp|thr': ['R'], + 'emp|miw': ['R'], + 'emp|nut': ['R'], + 'emp|pha': ['R'], + 'emp|lab': ['R'], + 'emp|rad': ['R'], + }, + '/outpatient/encounter/add': { + 'emp|reg': ['C', 'R', 'U', 'D'], + }, + '/outpatient/encounter/[id]/detail': { + 'emp|reg': ['C', 'R', 'U', 'D'], + 'emp|doc': ['R'], + 'emp|nur': ['R'], + 'emp|thr': ['R'], + 'emp|miw': ['R'], + 'emp|nut': ['R'], + 'emp|pha': ['R'], + 'emp|lab': ['R'], + 'emp|rad': ['R'], + }, + '/outpatient/encounter/[id]/edit': { + 'emp|reg': ['C', 'R', 'U', 'D'], + }, + '/outpatient/encounter/[id]/process': { + 'emp|doc': ['R', 'U'], + 'emp|nur': ['R', 'U'], + 'emp|thr': ['R', 'U'], + 'emp|miw': ['R', 'U'], + 'emp|nut': ['R', 'U'], + 'emp|pha': ['R', 'U'], + 'emp|lab': ['R', 'U'], + 'emp|rad': ['R', 'U'], + }, + '/outpatient/consulation': { + 'emp|doc': ['R'], + }, + '/outpatient/consulation/[id]/process': { + 'emp|doc': ['R', 'U'], + }, +} diff --git a/app/const/page-permission/tools-equipment.ts b/app/const/page-permission/tools-equipment.ts new file mode 100644 index 00000000..dd112ae8 --- /dev/null +++ b/app/const/page-permission/tools-equipment.ts @@ -0,0 +1,27 @@ +import type { Permission } from "~/models/role"; + +// Should we define the keys first? +// export type Keys = 'key1' | 'key2' | 'key3' | etc + +export const permissions: Record> = { + '/tools-equipment-src/medicine': { + 'div|fin': ['C', 'R', 'U', 'D'], + 'emp|pha': ['R'], + }, + '/tools-equipment-src/medicine-method': { + 'div|fin': ['C', 'R', 'U', 'D'], + 'emp|pha': ['R'], + }, + '/tools-equipment-src/medicine-type': { + 'div|fin': ['C', 'R', 'U', 'D'], + 'emp|pha': ['R'], + }, + '/tools-equipment-src/medicine-form': { + 'div|fin': ['C', 'R', 'U', 'D'], + 'emp|pha': ['R'], + }, + '/tools-equipment-src/device-src': { + 'div|fin': ['C', 'R', 'U', 'D'], + 'emp|pha': ['R'], + }, +} diff --git a/app/lib/page-permission.ts b/app/lib/page-permission.ts index ab7b5550..807131a8 100644 --- a/app/lib/page-permission.ts +++ b/app/lib/page-permission.ts @@ -1,7 +1,7 @@ import type { RoleAccess } from '~/models/role' export const PAGE_PERMISSIONS = { - '/patient': { + '/client/patient': { 'emp|doc': ['R'], 'emp|nur': ['R'], 'emp|reg': ['C', 'R', 'U', 'D'], @@ -9,13 +9,11 @@ export const PAGE_PERMISSIONS = { 'emp|pay': ['R'], 'emp|mng': ['R'], }, - '/doctor': { - 'emp|doc': ['C', 'R', 'U', 'D'], - 'emp|nur': ['R'], - 'emp|reg': ['R'], - 'emp|pha': ['R'], - 'emp|pay': ['R'], - 'emp|mng': ['R'], + '/human-src/employee': { + 'div|hrd': ['C', 'R', 'U', 'D'], + }, + '/human-src/intern': { + 'div|hrd': ['C', 'R', 'U', 'D'], }, '/satusehat': { 'emp|doc': ['R'], diff --git a/app/models/unit-position.ts b/app/models/unit-position.ts index a583d948..3e1dc426 100644 --- a/app/models/unit-position.ts +++ b/app/models/unit-position.ts @@ -2,7 +2,7 @@ import { type Base, genBase } from './_base' import type { Employee } from './employee' export interface UnitPosition extends Base { - unit_code: string + unit_id: string code: string name: string headStatus?: boolean @@ -14,7 +14,7 @@ export interface UnitPosition extends Base { export function genUnitPosition(): UnitPosition { return { ...genBase(), - unit_code: '', + unit_id: '', code: '', name: '', headStatus: false, diff --git a/app/pages/(features)/children-action/spirometry/index.vue b/app/pages/(features)/children-action/spirometry/index.vue deleted file mode 100644 index 50485cec..00000000 --- a/app/pages/(features)/children-action/spirometry/index.vue +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/pages/(features)/children-action/thalasemia/index.vue b/app/pages/(features)/children-action/thalasemia/index.vue deleted file mode 100644 index 50485cec..00000000 --- a/app/pages/(features)/children-action/thalasemia/index.vue +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/pages/(features)/doctor/add.vue b/app/pages/(features)/doctor/add.vue deleted file mode 100644 index a76811de..00000000 --- a/app/pages/(features)/doctor/add.vue +++ /dev/null @@ -1,41 +0,0 @@ - - - diff --git a/app/pages/(features)/doctor/index.vue b/app/pages/(features)/doctor/index.vue deleted file mode 100644 index 078df778..00000000 --- a/app/pages/(features)/doctor/index.vue +++ /dev/null @@ -1,40 +0,0 @@ - - - diff --git a/app/pages/(features)/emergency/encounter/add.vue b/app/pages/(features)/emergency/encounter/add.vue index aa382643..587e00e7 100644 --- a/app/pages/(features)/emergency/encounter/add.vue +++ b/app/pages/(features)/emergency/encounter/add.vue @@ -1,44 +1,46 @@