-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
21,331 additions
and
26 deletions.
There are no files selected for viewing
20,824 changes: 20,824 additions & 0 deletions
20,824
packages/esm-billing-app/src/hooks/payload.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
packages/esm-version-app/src/app-navigation/home-root.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ExtensionSlot, useExtensionStore } from '@openmrs/esm-framework'; | ||
import React, { useEffect } from 'react'; | ||
import { BrowserRouter, Route, Routes } from 'react-router-dom'; | ||
|
||
const HomeRoot = () => { | ||
const baseName = window.getOpenmrsSpaBase() + 'home'; | ||
|
||
return ( | ||
<BrowserRouter basename={baseName}> | ||
<Routes> | ||
<Route path="/" element={<ExtensionSlot name="home-dashboard-slot" />} /> | ||
<Route path="/providers/*" element={<ExtensionSlot name="providers-dashboard-slot" />} /> | ||
<Route path="/referrals/*" element={<ExtensionSlot name="referrals-slot" />} /> | ||
<Route path="/bed-admission/*" element={<ExtensionSlot name="bed-admission-dashboard-slot" />} /> | ||
{/* Patient services Routes */} | ||
<Route path="/appointments/*" element={<ExtensionSlot name="clinical-appointments-dashboard-slot" />} /> | ||
<Route path="/service-queues/*" element={<ExtensionSlot name="service-queues-dashboard-slot" />} /> | ||
{/* Diagnostics routes */} | ||
<Route path="/lab-manifest/*" element={<ExtensionSlot name="lab-manifest-slot" />} /> | ||
<Route path="/laboratory/*" element={<ExtensionSlot name="laboratory-dashboard-slot" />} /> | ||
<Route path="/procedure/*" element={<ExtensionSlot name="procedure-dashboard-slot" />} /> | ||
<Route path="/imaging-orders/*" element={<ExtensionSlot name="imaging-dashboard-slot" />} /> | ||
{/* lINKAGE services Routes */} | ||
<Route path="/pharmacy/*" element={<ExtensionSlot name="pharmacy-dashboard-slot" />} /> | ||
<Route path="/case-management/*" element={<ExtensionSlot name="case-management-dashboard-slot" />} /> | ||
<Route path="/peer-calendar/*" element={<ExtensionSlot name="peer-calendar-dashboard-slot" />} /> | ||
{/* Billing routes */} | ||
<Route path="/billing/*" element={<ExtensionSlot name="billing-dashboard-slot" />} /> | ||
</Routes> | ||
</BrowserRouter> | ||
); | ||
}; | ||
|
||
export default HomeRoot; |
27 changes: 27 additions & 0 deletions
27
packages/esm-version-app/src/app-navigation/nav-utils/create-dasboard-group.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import DashboardGroupExtension from './dashboard-group-extension.component'; | ||
import { CarbonIconType } from '@carbon/react/icons'; | ||
import { createDashboardGroup as cdg } from '@openmrs/esm-patient-common-lib'; | ||
type Conf = { | ||
title: string; | ||
slotName: string; | ||
isExpanded?: boolean; | ||
icon?: CarbonIconType; | ||
}; | ||
|
||
const createDashboardGroup = ({ slotName, title, isExpanded, icon }: Conf) => { | ||
const DashboardGroup = ({ basePath }: { basePath: string }) => { | ||
return ( | ||
<DashboardGroupExtension | ||
title={title} | ||
slotName={slotName} | ||
basePath={basePath} | ||
isExpanded={isExpanded} | ||
icon={icon} | ||
/> | ||
); | ||
}; | ||
return DashboardGroup; | ||
}; | ||
|
||
export default createDashboardGroup; |
21 changes: 21 additions & 0 deletions
21
packages/esm-version-app/src/app-navigation/nav-utils/create-left-panel-link.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
import { LinkExtension } from './link-extension.component'; | ||
import { type CarbonIconType } from '@carbon/react/icons'; | ||
|
||
type LinkConfig = { | ||
route: string; | ||
title: string; | ||
otherRoutes?: Array<string>; | ||
icon?: CarbonIconType; | ||
}; | ||
|
||
const createLeftPanelLink = (config: LinkConfig) => { | ||
return () => ( | ||
<BrowserRouter> | ||
<LinkExtension route={config.route} title={config.title} otherRoutes={config.otherRoutes} icon={config.icon} /> | ||
</BrowserRouter> | ||
); | ||
}; | ||
|
||
export default createLeftPanelLink; |
21 changes: 21 additions & 0 deletions
21
...ages/esm-version-app/src/app-navigation/nav-utils/create-patient-chart-dashboard-meta.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import React from 'react'; | ||
import PatientChartDasboardExtension, { DashboardExtensionProps } from './patient-chart-dashboard.component'; | ||
import { BrowserRouter } from 'react-router-dom'; | ||
|
||
const createPatientChartDashboardExtension = (props: Omit<DashboardExtensionProps, 'basePath'>) => { | ||
return ({ basePath }: { basePath: string }) => { | ||
return ( | ||
<BrowserRouter> | ||
<PatientChartDasboardExtension | ||
basePath={basePath} | ||
title={props.title} | ||
path={props.path} | ||
moduleName={props.moduleName} | ||
icon={props.icon} | ||
/> | ||
</BrowserRouter> | ||
); | ||
}; | ||
}; | ||
|
||
export default createPatientChartDashboardExtension; |
36 changes: 36 additions & 0 deletions
36
...ages/esm-version-app/src/app-navigation/nav-utils/dashboard-group-extension.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { Accordion, AccordionItem } from '@carbon/react'; | ||
import { CarbonIconType } from '@carbon/react/icons'; | ||
import { ExtensionSlot } from '@openmrs/esm-framework'; | ||
import { registerNavGroup } from '@openmrs/esm-patient-common-lib'; | ||
import React, { useEffect } from 'react'; | ||
import styles from './nav.scss'; | ||
type Props = { | ||
title: string; | ||
slotName?: string; | ||
basePath: string; | ||
isExpanded?: boolean; | ||
icon?: CarbonIconType; | ||
}; | ||
const DashboardGroupExtension: React.FC<Props> = ({ basePath, title, isExpanded, slotName, icon }) => { | ||
useEffect(() => { | ||
registerNavGroup(slotName); | ||
}, [slotName]); | ||
return ( | ||
<Accordion> | ||
<AccordionItem | ||
className={styles.item} | ||
open={isExpanded ?? true} | ||
title={ | ||
<span className={styles.itemTitle}> | ||
{icon && React.createElement(icon)} | ||
{title} | ||
</span> | ||
} | ||
style={{ border: 'none' }}> | ||
<ExtensionSlot name={slotName ?? title} state={{ basePath }} /> | ||
</AccordionItem> | ||
</Accordion> | ||
); | ||
}; | ||
|
||
export default DashboardGroupExtension; |
6 changes: 6 additions & 0 deletions
6
packages/esm-version-app/src/app-navigation/nav-utils/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export * from './link-extension.component'; | ||
export * from './utils'; | ||
export { default as createDashboardGroup } from './create-dasboard-group'; | ||
export { default as createLeftPanelLink } from './create-left-panel-link'; | ||
export { default as PatientChartDasboardExtension } from './patient-chart-dashboard.component'; | ||
export { default as createPatientChartDashboardExtension } from './create-patient-chart-dashboard-meta'; |
48 changes: 48 additions & 0 deletions
48
packages/esm-version-app/src/app-navigation/nav-utils/link-extension.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ConfigurableLink } from '@openmrs/esm-framework'; | ||
import React, { ReactNode, useCallback, useMemo } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import { parseParams } from './utils'; | ||
import { CarbonIconType } from '@carbon/react/icons'; | ||
import styles from './nav.scss'; | ||
export interface LinkConfig { | ||
route: string; | ||
title: string; | ||
otherRoutes?: Array<string>; | ||
icon?: CarbonIconType; | ||
} | ||
|
||
export const LinkExtension: React.FC<LinkConfig> = ({ route, title, otherRoutes = [], icon }) => { | ||
const spaBasePath = window.getOpenmrsSpaBase(); | ||
const location = useLocation(); | ||
const path = useMemo(() => location.pathname.replace(spaBasePath, ''), [spaBasePath, location]); | ||
// Parse params to see if the current route matches the location path | ||
const matcher = useCallback( | ||
(route: string) => { | ||
const staticMatch = `/${route}/`.replaceAll('//', '/') === `/${path}/`.replaceAll('//', '/'); // Exact match for static routes | ||
const paramMatch = !staticMatch && parseParams(route, path) !== null; // Check parameterized match if not exact | ||
|
||
return staticMatch || paramMatch; | ||
}, | ||
[path], | ||
); | ||
// Check if the route is active | ||
const isActive = matcher(route); | ||
const isOtherRoutesActive = useMemo(() => { | ||
return otherRoutes.some(matcher); | ||
}, [otherRoutes, matcher]); | ||
// Generate the `to` URL for the ConfigurableLink | ||
const to = useMemo(() => { | ||
return (spaBasePath + route).replaceAll('//', '/'); | ||
}, [spaBasePath, route]); | ||
|
||
return ( | ||
<ConfigurableLink | ||
to={to} | ||
className={`cds--side-nav__link ${isActive || isOtherRoutesActive ? 'active-left-nav-link' : ''} ${ | ||
styles.itemTitle | ||
}`}> | ||
{icon && React.createElement(icon)} | ||
{title} | ||
</ConfigurableLink> | ||
); | ||
}; |
9 changes: 9 additions & 0 deletions
9
packages/esm-version-app/src/app-navigation/nav-utils/nav.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
@use '@carbon/layout'; | ||
@use '@carbon/type'; | ||
|
||
.itemTitle { | ||
display: flex; | ||
flex-direction: row; | ||
gap: layout.$spacing-05; | ||
align-items: center; | ||
} |
41 changes: 41 additions & 0 deletions
41
packages/esm-version-app/src/app-navigation/nav-utils/patient-chart-dashboard.component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { CarbonIconType } from '@carbon/react/icons'; | ||
import { ConfigurableLink } from '@openmrs/esm-framework'; | ||
import classNames from 'classnames'; | ||
import last from 'lodash-es/last'; | ||
import React, { useMemo } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { useLocation } from 'react-router-dom'; | ||
import styles from './nav.scss'; | ||
|
||
export interface DashboardExtensionProps { | ||
path: string; | ||
title: string; | ||
basePath: string; | ||
moduleName?: string; | ||
icon?: CarbonIconType; | ||
} | ||
|
||
const PatientChartDasboardExtension = ({ | ||
path, | ||
title, | ||
basePath, | ||
moduleName = '@openmrs/esm-patient-chart-app', | ||
icon, | ||
}: DashboardExtensionProps) => { | ||
const { t } = useTranslation(moduleName); | ||
const location = useLocation(); | ||
const navLink = useMemo(() => decodeURIComponent(last(location.pathname.split('/'))), [location.pathname]); | ||
|
||
return ( | ||
<div key={path}> | ||
<ConfigurableLink | ||
className={classNames('cds--side-nav__link', { 'active-left-nav-link': path === navLink }, styles.itemTitle)} | ||
to={`${basePath}/${encodeURIComponent(path)}`}> | ||
{icon && React.createElement(icon)} | ||
{t(title)} | ||
</ConfigurableLink> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PatientChartDasboardExtension; |
Oops, something went wrong.