@digihmis/esm-billing-app 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,98 +1,6 @@
1
- import React, { useMemo } from 'react';
2
- import { ConfigurableLink, MaybeIcon } from '@openmrs/esm-framework';
3
- import { useTranslation } from 'react-i18next';
4
- import { BrowserRouter, useLocation, useParams } from 'react-router-dom';
5
- import { type CarbonIconType } from '@carbon/react/icons';
6
- import last from 'lodash-es/last';
7
- import styles from './left-panel.scss';
8
-
9
- export interface DashboardLinkConfig {
10
- name: string;
11
- title: string;
12
- icon?: string | CarbonIconType;
13
- showOnlyOnRoute?: string;
14
- }
15
-
16
- const DashboardLink = ({ dashboardLinkConfig }: { dashboardLinkConfig: DashboardLinkConfig }) => {
17
- const { t } = useTranslation();
18
- const { name, title, icon, showOnlyOnRoute } = dashboardLinkConfig;
19
- const location = useLocation();
20
- const params = useParams();
21
- const spaBasePath = window.getOpenmrsSpaBase() + 'home';
22
-
23
- const patientUuid = useMemo(() => {
24
- if (params.patientUuid) {
25
- return params.patientUuid;
26
- }
27
- const pathParts = location.pathname.split('/');
28
- const billingIndex = pathParts.indexOf('billing');
29
- if (billingIndex !== -1 && pathParts.length > billingIndex + 1) {
30
- const nextPart = pathParts[billingIndex + 1];
31
- // Check if it's a UUID pattern (basic check)
32
- if (nextPart && nextPart.length > 20 && nextPart.includes('-')) {
33
- return nextPart;
34
- }
35
- // Check if path is /billing/patient/UUID/file
36
- if (nextPart === 'patient' && pathParts.length > billingIndex + 2) {
37
- const uuidPart = pathParts[billingIndex + 2];
38
- if (uuidPart && uuidPart.length > 20 && uuidPart.includes('-')) {
39
- return uuidPart;
40
- }
41
- }
42
- }
43
- return null;
44
- }, [params.patientUuid, location.pathname]);
45
-
46
- const shouldShow = useMemo(() => {
47
- if (!showOnlyOnRoute) {
48
- return true;
49
- }
50
- return location.pathname.includes(showOnlyOnRoute);
51
- }, [showOnlyOnRoute, location.pathname]);
52
-
53
- const linkPath = useMemo(() => {
54
- let path = name;
55
- if (name.includes(':patientUuid') && patientUuid) {
56
- path = name.replace(':patientUuid', patientUuid);
57
- }
58
- return path;
59
- }, [name, patientUuid]);
60
-
61
- const isActive = useMemo(() => {
62
- if (name.includes(':patientUuid')) {
63
- return location.pathname.includes('/bill');
64
- }
65
- const urlSegment = decodeURIComponent(last(location.pathname.split('/')));
66
- const nameSegment = name.split('/').at(-1);
67
- return nameSegment === urlSegment;
68
- }, [location.pathname, name]);
69
-
70
- if (!shouldShow) {
71
- return null;
72
- }
73
-
74
- const IconComp = typeof icon !== 'string' ? (icon as CarbonIconType) : null;
75
-
76
- return (
77
- <ConfigurableLink
78
- to={`${spaBasePath}/${linkPath}`}
79
- className={`cds--side-nav__link ${isActive && 'active-left-nav-link'}`}>
80
- {typeof icon === 'string' ? (
81
- <MaybeIcon icon={icon} className={styles.icon} size={16} />
82
- ) : (
83
- IconComp && <IconComp className={styles.icon} />
84
- )}
85
- {t(title)}
86
- </ConfigurableLink>
87
- );
88
- };
89
-
90
- export const createDashboardLink = (dashboardLinkConfig: DashboardLinkConfig) => () => {
91
- return (
92
- <BrowserRouter>
93
- <DashboardLink dashboardLinkConfig={dashboardLinkConfig} />
94
- </BrowserRouter>
95
- );
96
- };
97
-
98
- export default DashboardLink;
1
+ // Moved to the shared library so every app uses one implementation.
2
+ export {
3
+ DashboardLink as default,
4
+ createDashboardLink,
5
+ type DashboardLinkConfig,
6
+ } from '@digihmis/esm-commons-lib';
package/src/routes.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "$schema": "https://json.openmrs.org/routes.schema.json",
3
3
  "backendDependencies": {
4
4
  "fhir2": ">=1.2",
5
- "webservices.rest": "^2.24.0"
5
+ "webservices.rest": ">=2.24.0"
6
6
  },
7
7
  "extensions": [
8
8
  {
@@ -10,13 +10,15 @@
10
10
  "slot": "extra-visit-attribute-slot",
11
11
  "component": "billingCheckInForm",
12
12
  "order": 0
13
- },{
13
+ },
14
+ {
14
15
  "name": "payment-type-tag",
15
16
  "slot": "patient-banner-tags-slot",
16
17
  "component": "paymentTypeTag",
17
18
  "online": true,
18
19
  "offline": true
19
- },{
20
+ },
21
+ {
20
22
  "name": "billing-db-link",
21
23
  "slot": "billing-dashboard-slot",
22
24
  "component": "billingQueueleftPanelLink",
@@ -28,7 +30,8 @@
28
30
  "order": 1,
29
31
  "online": true,
30
32
  "offline": true
31
- }, {
33
+ },
34
+ {
32
35
  "name": "care-panel-link",
33
36
  "slot": "billing-dashboard-slot",
34
37
  "component": "carePanelLink",
@@ -41,18 +44,19 @@
41
44
  "order": 2,
42
45
  "online": true,
43
46
  "offline": true
44
- },{
47
+ },
48
+ {
45
49
  "name": "billing-dashboard",
46
- "slot": "billing-homepage-dashboard-slot",
50
+ "slot": "billing-homepage-dashboard-slot",
47
51
  "component": "billingDashboard",
48
52
  "online": true,
49
53
  "offline": true
50
54
  }
51
55
  ],
52
56
  "modals": [
53
- {
57
+ {
54
58
  "name": "billing-timesheet-modal",
55
59
  "component": "billingTimesheetModal"
56
60
  }
57
61
  ]
58
- }
62
+ }