|
1 | | -import { t } from "@lingui/macro"; |
2 | | - |
3 | | -import { MenuLayoutValue } from "@beda.software/emr/dist/components/BaseLayout/Sidebar/SidebarTop/context"; |
4 | | -import {OrganizationsIcon, PatientsIcon, PractitionersIcon, ServicesIcon} from '@beda.software/emr/icons'; |
5 | | -import {matchCurrentUserRole, Role} from '@beda.software/emr/utils' |
6 | | - |
7 | | -export const menuLayout: MenuLayoutValue = () => |
8 | | - matchCurrentUserRole({ |
9 | | - [Role.Admin]: () => [ |
10 | | - { label: t`Patients`, path: '/patients', icon: <PatientsIcon /> }, |
11 | | - ], |
12 | | - [Role.Practitioner]: () => [ |
13 | | - { label: t`Patients`, path: '/patients', icon: <PatientsIcon /> }, |
14 | | - ], |
15 | | - [Role.Patient]: (patient) => [ |
16 | | - { label: 'Me', path: `/patients/${patient.id}`, icon: <PatientsIcon /> }, |
17 | | - ], |
18 | | - [Role.Receptionist]: () => [], |
19 | | - }); |
| 1 | +import { t } from '@lingui/macro'; |
| 2 | + |
| 3 | +import { MenuLayoutValue } from '@beda.software/emr/dist/components/BaseLayout/Sidebar/SidebarTop/context'; |
| 4 | +import { OrganizationsIcon, PatientsIcon, PractitionersIcon, ServicesIcon } from '@beda.software/emr/icons'; |
| 5 | +import { matchCurrentUserRole, Role } from '@beda.software/emr/utils'; |
| 6 | +import config from '@beda.software/emr-config'; |
| 7 | + |
| 8 | +import { AuthProvider, authProvidersConfig } from 'src/services/auth.ts'; |
| 9 | + |
| 10 | +const EPIC_PATIENT_ID = 'e0lof40pd7mW6R7f0v.4POw3'; |
| 11 | +const ORION_HEALTH_PATIENT_ID = 'GE3DQMRZHE4UAU2ZKNPUC'; |
| 12 | + |
| 13 | +const digitalHealthMenuItems = [ |
| 14 | + { label: t`Services`, path: '/healthcare-services', icon: <ServicesIcon /> }, |
| 15 | + { label: t`Practitioners`, path: '/practitioners', icon: <PractitionersIcon /> }, |
| 16 | + { label: t`Organizations`, path: '/organizations', icon: <OrganizationsIcon /> }, |
| 17 | + { label: t`Locations`, path: '/locations', icon: <OrganizationsIcon /> }, |
| 18 | +]; |
| 19 | + |
| 20 | +function getPatientsPath() { |
| 21 | + if (config.baseURL === authProvidersConfig[AuthProvider.Epic].baseUrl) { |
| 22 | + return `/patients/${EPIC_PATIENT_ID}`; |
| 23 | + } |
| 24 | + |
| 25 | + if (config.baseURL === authProvidersConfig[AuthProvider.OrionHealth].baseUrl) { |
| 26 | + return `/patients/${ORION_HEALTH_PATIENT_ID}`; |
| 27 | + } |
| 28 | + |
| 29 | + return '/patients'; |
| 30 | +} |
| 31 | + |
| 32 | +function isDigitalHealth() { |
| 33 | + return config.baseURL === authProvidersConfig[AuthProvider.DigitalHealth].baseUrl; |
| 34 | +} |
| 35 | + |
| 36 | +export const menuLayout: MenuLayoutValue = () => { |
| 37 | + if (isDigitalHealth()) { |
| 38 | + return matchCurrentUserRole({ |
| 39 | + [Role.Admin]: () => digitalHealthMenuItems, |
| 40 | + [Role.Practitioner]: () => digitalHealthMenuItems, |
| 41 | + [Role.Patient]: () => [], |
| 42 | + [Role.Receptionist]: () => [], |
| 43 | + }); |
| 44 | + } |
20 | 45 |
|
| 46 | + const patientsPath = getPatientsPath(); |
21 | 47 |
|
22 | | -export const digitalHealthMenuLayout: MenuLayoutValue = () => |
23 | | - matchCurrentUserRole({ |
24 | | - [Role.Admin]: () => [ |
25 | | - { label: t`Services`, path: '/healthcare-services', icon: <ServicesIcon /> }, |
26 | | - { label: t`Practitioners`, path: '/practitioners', icon: <PractitionersIcon /> }, |
27 | | - { label: t`Organizations`, path: '/organizations', icon: <OrganizationsIcon /> }, |
28 | | - { label: t`Locations`, path: '/locations', icon: <OrganizationsIcon /> }, |
29 | | - ], |
30 | | - [Role.Practitioner]: () => [ |
31 | | - { label: t`Services`, path: '/healthcare-services', icon: <ServicesIcon /> }, |
32 | | - { label: t`Practitioners`, path: '/practitioners', icon: <PractitionersIcon /> }, |
33 | | - { label: t`Organizations`, path: '/organizations', icon: <OrganizationsIcon /> }, |
34 | | - { label: t`Locations`, path: '/locations', icon: <OrganizationsIcon /> }, |
35 | | - ], |
36 | | - [Role.Patient]: () => [], |
| 48 | + return matchCurrentUserRole({ |
| 49 | + [Role.Admin]: () => [{ label: t`Patients`, path: patientsPath, icon: <PatientsIcon /> }], |
| 50 | + [Role.Practitioner]: () => [{ label: t`Patients`, path: patientsPath, icon: <PatientsIcon /> }], |
| 51 | + [Role.Patient]: (patient) => [{ label: 'Me', path: `/patients/${patient.id}`, icon: <PatientsIcon /> }], |
37 | 52 | [Role.Receptionist]: () => [], |
38 | 53 | }); |
| 54 | +}; |
0 commit comments