@digihmis/esm-home-app 1.0.0 → 1.0.1

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.
Files changed (80) hide show
  1. package/package.json +1 -1
  2. package/src/config-schema.ts +63 -315
  3. package/src/dashboards/administration-dashboard/administration-dashboard.component.tsx +3 -65
  4. package/src/dashboards/appointments-dashboard/appointments-dashboard.component.tsx +6 -0
  5. package/src/dashboards/billing-dashboard/billing-dashboard.component.tsx +2 -65
  6. package/src/dashboards/laboratory-dashboard/laboratory-dashboard.component.tsx +6 -0
  7. package/src/dashboards/outpatient-dashboard/outpatient-dashboard.component.tsx +2 -65
  8. package/src/dashboards/procedures-dashboard/procedures-dashboard.component.tsx +6 -0
  9. package/src/dashboards/radiology-dashboard/radiology-dashboard.component.tsx +6 -0
  10. package/src/dashboards/triage-dashboard/triage-dashboard.component.tsx +2 -66
  11. package/src/generic-dashboard/module-dashboard.component.tsx +100 -0
  12. package/src/index.ts +4 -0
  13. package/src/root.component.tsx +16 -0
  14. package/src/routes.json +49 -23
  15. package/dist/117.js +0 -1
  16. package/dist/117.js.map +0 -1
  17. package/dist/132.js +0 -1
  18. package/dist/132.js.map +0 -1
  19. package/dist/137.js +0 -1
  20. package/dist/137.js.map +0 -1
  21. package/dist/150.js +0 -1
  22. package/dist/150.js.map +0 -1
  23. package/dist/152.js +0 -1
  24. package/dist/152.js.map +0 -1
  25. package/dist/209.js +0 -1
  26. package/dist/209.js.map +0 -1
  27. package/dist/248.js +0 -1
  28. package/dist/248.js.map +0 -1
  29. package/dist/252.js +0 -12
  30. package/dist/252.js.map +0 -1
  31. package/dist/317.js +0 -1
  32. package/dist/317.js.map +0 -1
  33. package/dist/349.js +0 -1
  34. package/dist/349.js.map +0 -1
  35. package/dist/371.js +0 -1
  36. package/dist/371.js.map +0 -1
  37. package/dist/378.js +0 -1
  38. package/dist/378.js.map +0 -1
  39. package/dist/442.js +0 -1
  40. package/dist/442.js.map +0 -1
  41. package/dist/45.js +0 -1
  42. package/dist/45.js.map +0 -1
  43. package/dist/466.js +0 -1
  44. package/dist/466.js.map +0 -1
  45. package/dist/49.js +0 -1
  46. package/dist/49.js.map +0 -1
  47. package/dist/508.js +0 -1
  48. package/dist/508.js.map +0 -1
  49. package/dist/567.js +0 -1
  50. package/dist/567.js.map +0 -1
  51. package/dist/60.js +0 -1
  52. package/dist/60.js.map +0 -1
  53. package/dist/61.js +0 -1
  54. package/dist/61.js.map +0 -1
  55. package/dist/689.js +0 -1
  56. package/dist/689.js.map +0 -1
  57. package/dist/712.js +0 -1
  58. package/dist/712.js.map +0 -1
  59. package/dist/720.js +0 -1
  60. package/dist/720.js.map +0 -1
  61. package/dist/742.js +0 -1
  62. package/dist/742.js.map +0 -1
  63. package/dist/771.js +0 -1
  64. package/dist/771.js.map +0 -1
  65. package/dist/806.js +0 -1
  66. package/dist/806.js.map +0 -1
  67. package/dist/912.js +0 -1
  68. package/dist/912.js.map +0 -1
  69. package/dist/913.js +0 -1
  70. package/dist/913.js.map +0 -1
  71. package/dist/940.js +0 -1
  72. package/dist/940.js.map +0 -1
  73. package/dist/987.js +0 -15
  74. package/dist/987.js.map +0 -1
  75. package/dist/digihmis-esm-home-app.js +0 -6
  76. package/dist/digihmis-esm-home-app.js.buildmanifest.json +0 -896
  77. package/dist/digihmis-esm-home-app.js.map +0 -1
  78. package/dist/main.js +0 -6
  79. package/dist/main.js.map +0 -1
  80. package/dist/routes.json +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digihmis/esm-home-app",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Homepage microfrontend for the OpenMRS SPA",
5
5
  "browser": "dist/digihmis-esm-home-app.js",
6
6
  "main": "src/index.ts",
@@ -1,5 +1,24 @@
1
1
  import { ConfigSchema, Type, validators } from '@openmrs/esm-framework';
2
2
 
3
+ /**
4
+ * Every home icon shares one shape -- a `src` (svg path, overridable per deployment) and `alt`
5
+ * text. `iconSchema` stamps that shape from a single default path, so each icon is one line.
6
+ */
7
+ const iconSchema = (defaultSrc: string) => ({
8
+ src: {
9
+ _type: Type.String,
10
+ _default: defaultSrc,
11
+ _description:
12
+ 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
13
+ _validators: [validators.isUrl],
14
+ },
15
+ alt: {
16
+ _type: Type.String,
17
+ _default: 'Logo',
18
+ _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
19
+ },
20
+ });
21
+
3
22
  export const configSchema: ConfigSchema = {
4
23
  excludeLinks: {
5
24
  _type: Type.Array,
@@ -10,301 +29,28 @@ export const configSchema: ConfigSchema = {
10
29
  _default: [],
11
30
  _description: 'Array of links to hide in the esm home app',
12
31
  },
13
- administrationIcon: {
14
- src: {
15
- _type: Type.String,
16
- _default: '/openmrs/spa/administration.svg',
17
- _description:
18
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
19
- _validators: [validators.isUrl],
20
- },
21
- alt: {
22
- _type: Type.String,
23
- _default: 'Logo',
24
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
25
- },
26
- },
27
- appointmentsIcon: {
28
- src: {
29
- _type: Type.String,
30
- _default: '/openmrs/spa/appointments.svg',
31
- _description:
32
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
33
- _validators: [validators.isUrl],
34
- },
35
- alt: {
36
- _type: Type.String,
37
- _default: 'Logo',
38
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
39
- },
40
- },
41
- billingIcon: {
42
- src: {
43
- _type: Type.String,
44
- _default: '/openmrs/spa/billing.svg',
45
- _description:
46
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
47
- _validators: [validators.isUrl],
48
- },
49
- alt: {
50
- _type: Type.String,
51
- _default: 'Logo',
52
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
53
- },
54
- },
32
+ administrationIcon: iconSchema('/openmrs/spa/administration.svg'),
33
+ appointmentsIcon: iconSchema('/openmrs/spa/appointments.svg'),
34
+ billingIcon: iconSchema('/openmrs/spa/billing.svg'),
55
35
 
56
- dentalIcon: {
57
- src: {
58
- _type: Type.String,
59
- _default: '/openmrs/spa/denal.svg',
60
- _description:
61
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
62
- _validators: [validators.isUrl],
63
- },
64
- alt: {
65
- _type: Type.String,
66
- _default: 'Logo',
67
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
68
- },
69
- },
70
- homeIcon: {
71
- src: {
72
- _type: Type.String,
73
- _default: '/openmrs/spa/home.svg',
74
- _description:
75
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
76
- _validators: [validators.isUrl],
77
- },
78
- alt: {
79
- _type: Type.String,
80
- _default: 'Logo',
81
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
82
- },
83
- },
84
- inpatientIcon: {
85
- src: {
86
- _type: Type.String,
87
- _default: '/openmrs/spa/Inpatient.svg',
88
- _description:
89
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
90
- _validators: [validators.isUrl],
91
- },
92
- alt: {
93
- _type: Type.String,
94
- _default: 'Logo',
95
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
96
- },
97
- },
98
- inventoryIcon: {
99
- src: {
100
- _type: Type.String,
101
- _default: '/openmrs/spa/inventory.svg',
102
- _description:
103
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
104
- _validators: [validators.isUrl],
105
- },
106
- alt: {
107
- _type: Type.String,
108
- _default: 'Logo',
109
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
110
- },
111
- },
112
- laboratoryIcon: {
113
- src: {
114
- _type: Type.String,
115
- _default: '/openmrs/spa/labs.svg',
116
- _description:
117
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
118
- _validators: [validators.isUrl],
119
- },
120
- alt: {
121
- _type: Type.String,
122
- _default: 'Logo',
123
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
124
- },
125
- },
126
- mchIcon: {
127
- src: {
128
- _type: Type.String,
129
- _default: '/openmrs/spa/mch.svg',
130
- _description:
131
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
132
- _validators: [validators.isUrl],
133
- },
134
- alt: {
135
- _type: Type.String,
136
- _default: 'Logo',
137
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
138
- },
139
- },
140
- outpatientIcon: {
141
- src: {
142
- _type: Type.String,
143
- _default: '/openmrs/spa/outpatient.svg',
144
- _description:
145
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
146
- _validators: [validators.isUrl],
147
- },
148
- alt: {
149
- _type: Type.String,
150
- _default: 'Logo',
151
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
152
- },
153
- },
154
- pharmacyIcon: {
155
- src: {
156
- _type: Type.String,
157
- _default: '/openmrs/spa/pharmacy.svg',
158
- _description:
159
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
160
- _validators: [validators.isUrl],
161
- },
162
- alt: {
163
- _type: Type.String,
164
- _default: 'Logo',
165
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
166
- },
167
- },
168
- proceduresIcon: {
169
- src: {
170
- _type: Type.String,
171
- _default: '/openmrs/spa/procedure.svg',
172
- _description:
173
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
174
- _validators: [validators.isUrl],
175
- },
176
- alt: {
177
- _type: Type.String,
178
- _default: 'Logo',
179
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
180
- },
181
- },
182
- radiologyIcon: {
183
- src: {
184
- _type: Type.String,
185
- _default: '/openmrs/spa/radiology.svg',
186
- _description:
187
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
188
- _validators: [validators.isUrl],
189
- },
190
- alt: {
191
- _type: Type.String,
192
- _default: 'Logo',
193
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
194
- },
195
- },
196
- referralIcon: {
197
- src: {
198
- _type: Type.String,
199
- _default: '/openmrs/spa/referral.svg',
200
- _description:
201
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
202
- _validators: [validators.isUrl],
203
- },
204
- alt: {
205
- _type: Type.String,
206
- _default: 'Logo',
207
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
208
- },
209
- },
210
- registrationIcon: {
211
- src: {
212
- _type: Type.String,
213
- _default: '/openmrs/spa/registration.svg',
214
- _description:
215
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
216
- _validators: [validators.isUrl],
217
- },
218
- alt: {
219
- _type: Type.String,
220
- _default: 'Logo',
221
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
222
- },
223
- },
224
- specialClinicIcon: {
225
- src: {
226
- _type: Type.String,
227
- _default: '/openmrs/spa/special_clinic.svg',
228
- _description:
229
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
230
- _validators: [validators.isUrl],
231
- },
232
- alt: {
233
- _type: Type.String,
234
- _default: 'Logo',
235
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
236
- },
237
- },
238
- staffManagementIcon: {
239
- src: {
240
- _type: Type.String,
241
- _default: '/openmrs/spa/staff_management.svg',
242
- _description:
243
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
244
- _validators: [validators.isUrl],
245
- },
246
- alt: {
247
- _type: Type.String,
248
- _default: 'Logo',
249
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
250
- },
251
- },
252
- triageIcon: {
253
- src: {
254
- _type: Type.String,
255
- _default: '/openmrs/spa/triage_1.svg',
256
- _description:
257
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
258
- _validators: [validators.isUrl],
259
- },
260
- alt: {
261
- _type: Type.String,
262
- _default: 'Logo',
263
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
264
- },
265
- },
266
- reportsIcon: {
267
- src: {
268
- _type: Type.String,
269
- _default: '/openmrs/spa/reports.svg',
270
- _description:
271
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
272
- _validators: [validators.isUrl],
273
- },
274
- alt: {
275
- _type: Type.String,
276
- _default: 'Logo',
277
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
278
- },
279
- },
280
- facilityDashboardIcon: {
281
- src: {
282
- _type: Type.String,
283
- _default: '/openmrs/spa/facility_analysis.svg',
284
- _description:
285
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
286
- _validators: [validators.isUrl],
287
- },
288
- alt: {
289
- _type: Type.String,
290
- _default: 'Logo',
291
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
292
- },
293
- },
294
- legacyUIIcon: {
295
- src: {
296
- _type: Type.String,
297
- _default: '/openmrs/spa/logo.svg',
298
- _description:
299
- 'The path or URL to the logo image. If set to an empty string, the default OpenMRS SVG sprite will be used.',
300
- _validators: [validators.isUrl],
301
- },
302
- alt: {
303
- _type: Type.String,
304
- _default: 'Logo',
305
- _description: 'The alternative text for the logo image, displayed when the image cannot be loaded or on hover.',
306
- },
307
- },
36
+ dentalIcon: iconSchema('/openmrs/spa/denal.svg'),
37
+ homeIcon: iconSchema('/openmrs/spa/home.svg'),
38
+ inpatientIcon: iconSchema('/openmrs/spa/Inpatient.svg'),
39
+ inventoryIcon: iconSchema('/openmrs/spa/inventory.svg'),
40
+ laboratoryIcon: iconSchema('/openmrs/spa/labs.svg'),
41
+ mchIcon: iconSchema('/openmrs/spa/mch.svg'),
42
+ outpatientIcon: iconSchema('/openmrs/spa/outpatient.svg'),
43
+ pharmacyIcon: iconSchema('/openmrs/spa/pharmacy.svg'),
44
+ proceduresIcon: iconSchema('/openmrs/spa/procedure.svg'),
45
+ radiologyIcon: iconSchema('/openmrs/spa/radiology.svg'),
46
+ referralIcon: iconSchema('/openmrs/spa/referral.svg'),
47
+ registrationIcon: iconSchema('/openmrs/spa/registration.svg'),
48
+ specialClinicIcon: iconSchema('/openmrs/spa/special_clinic.svg'),
49
+ staffManagementIcon: iconSchema('/openmrs/spa/staff_management.svg'),
50
+ triageIcon: iconSchema('/openmrs/spa/triage_1.svg'),
51
+ reportsIcon: iconSchema('/openmrs/spa/reports.svg'),
52
+ facilityDashboardIcon: iconSchema('/openmrs/spa/facility_analysis.svg'),
53
+ legacyUIIcon: iconSchema('/openmrs/spa/logo.svg'),
308
54
  leftNavMode: {
309
55
  _type: Type.String,
310
56
  _description: 'Sets the left nav mode for the home app.',
@@ -328,29 +74,31 @@ export const configSchema: ConfigSchema = {
328
74
  },
329
75
  };
330
76
 
77
+ type IconConfig = { src: string; alt: string };
78
+
331
79
  export type ConfigObject = {
332
80
  excludeLinks: Array<string>;
333
- administrationIcon: { src: string; alt: string };
334
- appointmentsIcon: { src: string; alt: string };
335
- billingIcon: { src: string; alt: string };
336
- dentalIcon: { src: string; alt: string };
337
- homeIcon: { src: string; alt: string };
338
- inpatientIcon: { src: string; alt: string };
339
- inventoryIcon: { src: string; alt: string };
340
- laboratoryIcon: { src: string; alt: string };
341
- mchIcon: { src: string; alt: string };
342
- outpatientIcon: { src: string; alt: string };
343
- pharmacyIcon: { src: string; alt: string };
344
- proceduresIcon: { src: string; alt: string };
345
- radiologyIcon: { src: string; alt: string };
346
- referralIcon: { src: string; alt: string };
347
- registrationIcon: { src: string; alt: string };
348
- specialClinicIcon: { src: string; alt: string };
349
- staffManagementIcon: { src: string; alt: string };
350
- triageIcon: { src: string; alt: string };
351
- reportsIcon: { src: string; alt: string };
352
- facilityDashboardIcon: { src: string; alt: string };
353
- legacyUIIcon: { src: string; alt: string };
81
+ administrationIcon: IconConfig;
82
+ appointmentsIcon: IconConfig;
83
+ billingIcon: IconConfig;
84
+ dentalIcon: IconConfig;
85
+ homeIcon: IconConfig;
86
+ inpatientIcon: IconConfig;
87
+ inventoryIcon: IconConfig;
88
+ laboratoryIcon: IconConfig;
89
+ mchIcon: IconConfig;
90
+ outpatientIcon: IconConfig;
91
+ pharmacyIcon: IconConfig;
92
+ proceduresIcon: IconConfig;
93
+ radiologyIcon: IconConfig;
94
+ referralIcon: IconConfig;
95
+ registrationIcon: IconConfig;
96
+ specialClinicIcon: IconConfig;
97
+ staffManagementIcon: IconConfig;
98
+ triageIcon: IconConfig;
99
+ reportsIcon: IconConfig;
100
+ facilityDashboardIcon: IconConfig;
101
+ legacyUIIcon: IconConfig;
354
102
  leftNavMode: 'normal' | 'collapsed' | 'hidden';
355
103
  triageQueueUuid: string;
356
104
  outpatientQueueUuid: string;
@@ -1,68 +1,6 @@
1
- import React, { useEffect } from 'react';
2
- import {
3
- ExtensionSlot,
4
- WorkspaceContainer,
5
- useLayoutType,
6
- isDesktop,
7
- useConfig,
8
- useLeftNav,
9
- useExtensionStore,
10
- } from '@openmrs/esm-framework';
11
- import classNames from 'classnames';
12
- import styles from '../../generic-dashboard/generic-dashboard.scss';
13
- import { ConfigObject } from '../../config-schema';
14
- import { useParams, useNavigate, useLocation } from 'react-router-dom';
15
- import { DashboardConfig } from '../../type';
16
- import DashboardView from '../../generic-dashboard/generic-dashboard-view.component';
1
+ import React from 'react';
2
+ import ModuleDashboard from '../../generic-dashboard/module-dashboard.component';
17
3
 
18
4
  export default function AdministrationDashboard() {
19
- const extensionStore = useExtensionStore();
20
- const params = useParams();
21
- const navigate = useNavigate();
22
- const location = useLocation();
23
- const layout = useLayoutType();
24
- const { leftNavMode } = useConfig<ConfigObject>();
25
-
26
- useLeftNav({
27
- name: 'administration-dashboard-slot',
28
- basePath: `${window.spaBase}/home/administration`,
29
- mode: leftNavMode,
30
- });
31
-
32
- const ungroupedDashboards =
33
- extensionStore.slots['administration-dashboard-slot']?.assignedExtensions
34
- .map((e) => e.meta)
35
- .filter((e) => Object.keys(e).length) || [];
36
- const dashboards = ungroupedDashboards as Array<DashboardConfig>;
37
-
38
- const dashboardParam = params?.dashboard || params?.['*'];
39
- const activeDashboard = dashboards.find((dashboard) => dashboard.name === dashboardParam) || dashboards[0];
40
-
41
- useEffect(() => {
42
- const basePaths = ['/home/administration', '/home/administration/'];
43
- if (basePaths.includes(location.pathname)) {
44
- if (dashboards.length > 0 && dashboards[0]?.name) {
45
- navigate(`/home/administration/${dashboards[0].name}`, { replace: true });
46
- }
47
- }
48
- }, [location.pathname, dashboards, navigate]);
49
-
50
- return (
51
- <div className={styles.homePageWrapper}>
52
- <section
53
- className={classNames([
54
- isDesktop(layout) ? styles.dashboardContainer : styles.dashboardContainerTablet,
55
- leftNavMode === 'normal' ? styles.hasLeftNav : '',
56
- ])}>
57
- {isDesktop(layout) && <ExtensionSlot name="administration-sidebar-slot" />}
58
- {activeDashboard && (
59
- <DashboardView
60
- title={activeDashboard?.title || activeDashboard?.name}
61
- dashboardSlot={activeDashboard?.slot}
62
- />
63
- )}
64
- </section>
65
- <WorkspaceContainer overlay contextKey="home/administration" />
66
- </div>
67
- );
5
+ return <ModuleDashboard moduleName="administration" redirectToFirstDashboard />;
68
6
  }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import ModuleDashboard from '../../generic-dashboard/module-dashboard.component';
3
+
4
+ export default function AppointmentsDashboard() {
5
+ return <ModuleDashboard moduleName="appointments" />;
6
+ }
@@ -1,71 +1,8 @@
1
1
  import React from 'react';
2
- import {
3
- ExtensionSlot,
4
- WorkspaceContainer,
5
- useLayoutType,
6
- isDesktop,
7
- useConfig,
8
- useLeftNav,
9
- useExtensionStore,
10
- } from '@openmrs/esm-framework';
11
- import classNames from 'classnames';
12
- import styles from '../../generic-dashboard/generic-dashboard.scss';
13
- import { ConfigObject } from '../../config-schema';
14
- import { useParams, useLocation } from 'react-router-dom';
15
- import { DashboardConfig } from '../../type';
16
- import DashboardView from '../../generic-dashboard/generic-dashboard-view.component';
2
+ import ModuleDashboard from '../../generic-dashboard/module-dashboard.component';
17
3
 
18
4
  export default function BillingDashboard() {
19
- const extensionStore = useExtensionStore();
20
- const params = useParams();
21
- const location = useLocation();
22
- const layout = useLayoutType();
23
- const { leftNavMode } = useConfig<ConfigObject>();
24
-
25
- const isFileRoute = location.pathname.includes('/bill');
26
- const { patientUuid } = params;
27
-
28
- useLeftNav({
29
- name: 'billing-dashboard-slot',
30
- basePath: `${window.spaBase}/home/billing`,
31
- mode: leftNavMode,
32
- });
33
-
34
- const ungroupedDashboards =
35
- extensionStore.slots['billing-dashboard-slot']?.assignedExtensions
36
- .map((e) => e.meta)
37
- .filter((e) => Object.keys(e).length) || [];
38
-
39
- const dashboards = ungroupedDashboards as Array<DashboardConfig>;
40
-
41
- const matchedDashboard = dashboards.find((dashboard) => dashboard.name === params?.dashboard);
42
- const activeDashboard = matchedDashboard || dashboards[0];
43
-
44
5
  return (
45
- <div className={styles.homePageWrapper}>
46
- <section
47
- className={classNames([
48
- isDesktop(layout) ? styles.dashboardContainer : styles.dashboardContainerTablet,
49
- leftNavMode === 'normal' ? styles.hasLeftNav : '',
50
- ])}>
51
- {isDesktop(layout) && <ExtensionSlot name="billing-sidebar-slot" />}
52
-
53
- {isFileRoute && patientUuid ? (
54
- <DashboardView
55
- title={activeDashboard?.title || activeDashboard?.name}
56
- dashboardSlot="patient-bill-dashboard-slot"
57
- state={{ patientUuid }}
58
- />
59
- ) : (
60
- activeDashboard && (
61
- <DashboardView
62
- title={activeDashboard?.title || activeDashboard?.name}
63
- dashboardSlot={activeDashboard?.slot}
64
- />
65
- )
66
- )}
67
- </section>
68
- <WorkspaceContainer overlay contextKey="home/billing" />
69
- </div>
6
+ <ModuleDashboard moduleName="billing" patientRoute={{ pathSegment: '/bill', slot: 'patient-bill-dashboard-slot' }} />
70
7
  );
71
8
  }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import ModuleDashboard from '../../generic-dashboard/module-dashboard.component';
3
+
4
+ export default function LaboratoryDashboard() {
5
+ return <ModuleDashboard moduleName="laboratory" />;
6
+ }
@@ -1,71 +1,8 @@
1
1
  import React from 'react';
2
- import {
3
- ExtensionSlot,
4
- WorkspaceContainer,
5
- useLayoutType,
6
- isDesktop,
7
- useConfig,
8
- useLeftNav,
9
- useExtensionStore,
10
- } from '@openmrs/esm-framework';
11
- import classNames from 'classnames';
12
- import styles from '../../generic-dashboard/generic-dashboard.scss';
13
- import { ConfigObject } from '../../config-schema';
14
- import { useParams, useLocation } from 'react-router-dom';
15
- import { DashboardConfig } from '../../type';
16
- import DashboardView from '../../generic-dashboard/generic-dashboard-view.component';
2
+ import ModuleDashboard from '../../generic-dashboard/module-dashboard.component';
17
3
 
18
4
  export default function OutpatientDashboard() {
19
- const extensionStore = useExtensionStore();
20
- const params = useParams();
21
- const location = useLocation();
22
- const layout = useLayoutType();
23
- const { leftNavMode } = useConfig<ConfigObject>();
24
-
25
- const isFileRoute = location.pathname.includes('/file');
26
- const { patientUuid } = params;
27
-
28
- useLeftNav({
29
- name: 'outpatient-dashboard-slot',
30
- basePath: `${window.spaBase}/home/outpatient`,
31
- mode: leftNavMode,
32
- });
33
-
34
- const ungroupedDashboards =
35
- extensionStore.slots['outpatient-dashboard-slot']?.assignedExtensions
36
- .map((e) => e.meta)
37
- .filter((e) => Object.keys(e).length) || [];
38
-
39
- const dashboards = ungroupedDashboards as Array<DashboardConfig>;
40
-
41
- const matchedDashboard = dashboards.find((dashboard) => dashboard.name === params?.dashboard);
42
- const activeDashboard = matchedDashboard || dashboards[0];
43
-
44
5
  return (
45
- <div className={styles.homePageWrapper}>
46
- <section
47
- className={classNames([
48
- isDesktop(layout) ? styles.dashboardContainer : styles.dashboardContainerTablet,
49
- leftNavMode === 'normal' ? styles.hasLeftNav : '',
50
- ])}>
51
- {isDesktop(layout) && <ExtensionSlot name="outpatient-sidebar-slot" />}
52
-
53
- {isFileRoute && patientUuid ? (
54
- <DashboardView
55
- title={activeDashboard?.title || activeDashboard?.name}
56
- dashboardSlot="outpatient-file-dashboard-slot"
57
- state={{ patientUuid }}
58
- />
59
- ) : (
60
- activeDashboard && (
61
- <DashboardView
62
- title={activeDashboard?.title || activeDashboard?.name}
63
- dashboardSlot={activeDashboard?.slot}
64
- />
65
- )
66
- )}
67
- </section>
68
- <WorkspaceContainer overlay contextKey="home/outpatient" />
69
- </div>
6
+ <ModuleDashboard moduleName="outpatient" patientRoute={{ pathSegment: '/file', slot: 'outpatient-file-dashboard-slot' }} />
70
7
  );
71
8
  }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import ModuleDashboard from '../../generic-dashboard/module-dashboard.component';
3
+
4
+ export default function ProceduresDashboard() {
5
+ return <ModuleDashboard moduleName="procedures" />;
6
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import ModuleDashboard from '../../generic-dashboard/module-dashboard.component';
3
+
4
+ export default function RadiologyDashboard() {
5
+ return <ModuleDashboard moduleName="radiology" />;
6
+ }