@openmrs/esm-service-queues-app 5.0.1-pre.2087

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 (254) hide show
  1. package/.turbo/turbo-build.log +40 -0
  2. package/LICENSE.md +401 -0
  3. package/README.md +23 -0
  4. package/__mocks__/active-visits.mock.ts +97 -0
  5. package/__mocks__/appointments-data.mock.ts +283 -0
  6. package/__mocks__/search.mock.ts +35 -0
  7. package/__mocks__/visits.mock.ts +42 -0
  8. package/dist/121.js +1 -0
  9. package/dist/121.js.map +1 -0
  10. package/dist/130.js +2 -0
  11. package/dist/130.js.LICENSE.txt +5 -0
  12. package/dist/130.js.map +1 -0
  13. package/dist/176.js +1 -0
  14. package/dist/176.js.map +1 -0
  15. package/dist/227.js +1 -0
  16. package/dist/227.js.map +1 -0
  17. package/dist/242.js +1 -0
  18. package/dist/242.js.map +1 -0
  19. package/dist/252.js +1 -0
  20. package/dist/252.js.map +1 -0
  21. package/dist/286.js +1 -0
  22. package/dist/286.js.map +1 -0
  23. package/dist/308.js +1 -0
  24. package/dist/308.js.map +1 -0
  25. package/dist/319.js +1 -0
  26. package/dist/328.js +1 -0
  27. package/dist/328.js.map +1 -0
  28. package/dist/330.js +1 -0
  29. package/dist/330.js.map +1 -0
  30. package/dist/364.js +1 -0
  31. package/dist/364.js.map +1 -0
  32. package/dist/425.js +1 -0
  33. package/dist/425.js.map +1 -0
  34. package/dist/457.js +1 -0
  35. package/dist/457.js.map +1 -0
  36. package/dist/469.js +1 -0
  37. package/dist/469.js.map +1 -0
  38. package/dist/521.js +1 -0
  39. package/dist/521.js.map +1 -0
  40. package/dist/53.js +1 -0
  41. package/dist/53.js.map +1 -0
  42. package/dist/574.js +1 -0
  43. package/dist/591.js +2 -0
  44. package/dist/591.js.LICENSE.txt +32 -0
  45. package/dist/591.js.map +1 -0
  46. package/dist/610.js +1 -0
  47. package/dist/610.js.map +1 -0
  48. package/dist/611.js +1 -0
  49. package/dist/611.js.map +1 -0
  50. package/dist/616.js +1 -0
  51. package/dist/616.js.map +1 -0
  52. package/dist/644.js +1 -0
  53. package/dist/644.js.map +1 -0
  54. package/dist/670.js +2 -0
  55. package/dist/670.js.LICENSE.txt +57 -0
  56. package/dist/670.js.map +1 -0
  57. package/dist/733.js +1 -0
  58. package/dist/733.js.map +1 -0
  59. package/dist/757.js +1 -0
  60. package/dist/764.js +1 -0
  61. package/dist/764.js.map +1 -0
  62. package/dist/766.js +1 -0
  63. package/dist/766.js.map +1 -0
  64. package/dist/784.js +2 -0
  65. package/dist/784.js.LICENSE.txt +9 -0
  66. package/dist/784.js.map +1 -0
  67. package/dist/788.js +1 -0
  68. package/dist/807.js +1 -0
  69. package/dist/833.js +1 -0
  70. package/dist/86.js +1 -0
  71. package/dist/86.js.map +1 -0
  72. package/dist/981.js +1 -0
  73. package/dist/981.js.map +1 -0
  74. package/dist/main.js +1 -0
  75. package/dist/main.js.map +1 -0
  76. package/dist/openmrs-esm-service-queues-app.js +1 -0
  77. package/dist/openmrs-esm-service-queues-app.js.buildmanifest.json +930 -0
  78. package/dist/openmrs-esm-service-queues-app.js.map +1 -0
  79. package/dist/routes.json +1 -0
  80. package/jest.config.js +3 -0
  81. package/package.json +53 -0
  82. package/src/active-visits/active-visits-tab.component.tsx +71 -0
  83. package/src/active-visits/active-visits-tab.test.tsx +19 -0
  84. package/src/active-visits/active-visits-table.component.tsx +543 -0
  85. package/src/active-visits/active-visits-table.resource.ts +443 -0
  86. package/src/active-visits/active-visits-table.scss +271 -0
  87. package/src/active-visits/active-visits-table.test.tsx +131 -0
  88. package/src/active-visits/change-status-dialog.component.tsx +233 -0
  89. package/src/active-visits/change-status-dialog.scss +32 -0
  90. package/src/active-visits/change-status-dialog.test.tsx +107 -0
  91. package/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx +218 -0
  92. package/src/add-patient-toqueue/add-patient-toqueue-dialog.scss +32 -0
  93. package/src/add-provider-queue-room/add-provider-queue-room.component.tsx +236 -0
  94. package/src/add-provider-queue-room/add-provider-queue-room.resource.tsx +76 -0
  95. package/src/add-provider-queue-room/add-provider-queue-room.scss +17 -0
  96. package/src/add-provider-queue-room/add-provider-queue-room.test.tsx +98 -0
  97. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.component.tsx +74 -0
  98. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.resource.tsx +46 -0
  99. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.scss +15 -0
  100. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.test.tsx +42 -0
  101. package/src/clear-queue-entries-dialog/clear-queue-entries.component.tsx +36 -0
  102. package/src/config-schema.ts +177 -0
  103. package/src/constants.ts +7 -0
  104. package/src/createDashboardLink.tsx +35 -0
  105. package/src/current-visit/current-visit-summary.component.tsx +38 -0
  106. package/src/current-visit/current-visit-summary.test.tsx +47 -0
  107. package/src/current-visit/current-visit.resource.ts +84 -0
  108. package/src/current-visit/current-visit.scss +34 -0
  109. package/src/current-visit/hooks/useVitalsConceptMetadata.tsx +101 -0
  110. package/src/current-visit/visit-details/biometrics-config-schema.ts +14 -0
  111. package/src/current-visit/visit-details/current-visit-details.component.tsx +96 -0
  112. package/src/current-visit/visit-details/triage-note.component.tsx +53 -0
  113. package/src/current-visit/visit-details/triage-note.scss +89 -0
  114. package/src/current-visit/visit-details/vitals-config-schema.ts +17 -0
  115. package/src/current-visit/visit-details/vitals.component.tsx +164 -0
  116. package/src/dashboard.meta.ts +5 -0
  117. package/src/declarations.d.ts +2 -0
  118. package/src/helpers/functions.ts +67 -0
  119. package/src/helpers/helpers.ts +170 -0
  120. package/src/helpers/time-helpers.ts +15 -0
  121. package/src/home.component.tsx +29 -0
  122. package/src/home.test.tsx +58 -0
  123. package/src/index.ts +100 -0
  124. package/src/overlay.component.tsx +46 -0
  125. package/src/overlay.scss +96 -0
  126. package/src/overlay.test.tsx +49 -0
  127. package/src/past-visit/past-visit-details/encounter-list.component.tsx +51 -0
  128. package/src/past-visit/past-visit-details/medications-list.component.tsx +95 -0
  129. package/src/past-visit/past-visit-details/notes-list.component.tsx +40 -0
  130. package/src/past-visit/past-visit-details/past-visit-summary.component.tsx +172 -0
  131. package/src/past-visit/past-visit-details/past-visit-summary.scss +58 -0
  132. package/src/past-visit/past-visit.component.tsx +37 -0
  133. package/src/past-visit/past-visit.resource.ts +83 -0
  134. package/src/past-visit/past-visit.scss +126 -0
  135. package/src/past-visit/past-visit.test.tsx +41 -0
  136. package/src/patient-info/appointment-details.component.tsx +98 -0
  137. package/src/patient-info/appointment-details.scss +34 -0
  138. package/src/patient-info/appointment-details.test.tsx +36 -0
  139. package/src/patient-info/appointments.resource.tsx +43 -0
  140. package/src/patient-info/contact-details.component.tsx +71 -0
  141. package/src/patient-info/contact-details.scss +31 -0
  142. package/src/patient-info/contact-details.test.tsx +94 -0
  143. package/src/patient-info/hooks/usePatientAttributes.tsx +42 -0
  144. package/src/patient-info/patient-info.component.tsx +78 -0
  145. package/src/patient-info/patient-info.scss +60 -0
  146. package/src/patient-info/patient-info.test.tsx +45 -0
  147. package/src/patient-queue-header/patient-queue-header.component.tsx +64 -0
  148. package/src/patient-queue-header/patient-queue-header.scss +88 -0
  149. package/src/patient-queue-header/patient-queue-illustration.component.tsx +22 -0
  150. package/src/patient-queue-metrics/clinic-metrics.component.tsx +93 -0
  151. package/src/patient-queue-metrics/clinic-metrics.resource.tsx +51 -0
  152. package/src/patient-queue-metrics/clinic-metrics.scss +11 -0
  153. package/src/patient-queue-metrics/clinic-metrics.test.tsx +87 -0
  154. package/src/patient-queue-metrics/metrics-card.component.tsx +64 -0
  155. package/src/patient-queue-metrics/metrics-card.scss +80 -0
  156. package/src/patient-queue-metrics/metrics-header.component.tsx +74 -0
  157. package/src/patient-queue-metrics/metrics-header.scss +22 -0
  158. package/src/patient-queue-metrics/queue-metrics.resource.ts +54 -0
  159. package/src/patient-search/advanced-search.component.tsx +190 -0
  160. package/src/patient-search/advanced-search.scss +154 -0
  161. package/src/patient-search/advanced-search.test.tsx +29 -0
  162. package/src/patient-search/basic-search.component.tsx +112 -0
  163. package/src/patient-search/basic-search.scss +139 -0
  164. package/src/patient-search/basic-search.test.tsx +23 -0
  165. package/src/patient-search/empty-data-illustration.component.tsx +41 -0
  166. package/src/patient-search/hooks/useActivePatientEnrollment.tsx +29 -0
  167. package/src/patient-search/hooks/useDefaultLocation.tsx +14 -0
  168. package/src/patient-search/hooks/usePatients.tsx +25 -0
  169. package/src/patient-search/hooks/useQueueLocations.tsx +20 -0
  170. package/src/patient-search/hooks/useRecommendedVisitTypes.tsx +36 -0
  171. package/src/patient-search/hooks/useScheduledVisits.tsx +50 -0
  172. package/src/patient-search/patient-scheduled-visits.component.tsx +350 -0
  173. package/src/patient-search/patient-scheduled-visits.scss +131 -0
  174. package/src/patient-search/patient-scheduled-visits.test.tsx +55 -0
  175. package/src/patient-search/patient-search.component.tsx +64 -0
  176. package/src/patient-search/search-illustration.component.tsx +27 -0
  177. package/src/patient-search/search-results.component.tsx +75 -0
  178. package/src/patient-search/search-results.scss +80 -0
  179. package/src/patient-search/search-results.test.tsx +77 -0
  180. package/src/patient-search/search.resource.ts +10 -0
  181. package/src/patient-search/visit-form/base-visit-type.component.tsx +82 -0
  182. package/src/patient-search/visit-form/base-visit-type.scss +100 -0
  183. package/src/patient-search/visit-form/base-visit-type.test.tsx +41 -0
  184. package/src/patient-search/visit-form/queue.resource.ts +73 -0
  185. package/src/patient-search/visit-form/recommended-visit-type.component.tsx +38 -0
  186. package/src/patient-search/visit-form/visit-form.component.tsx +366 -0
  187. package/src/patient-search/visit-form/visit-form.scss +96 -0
  188. package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.component.tsx +160 -0
  189. package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.scss +21 -0
  190. package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.test.tsx +67 -0
  191. package/src/queue-entry-table-components/actions-menu.component.tsx +51 -0
  192. package/src/queue-entry-table-components/actions-menu.scss +3 -0
  193. package/src/queue-entry-table-components/edit-entry.component.tsx +28 -0
  194. package/src/queue-entry-table-components/edit-entry.scss +14 -0
  195. package/src/queue-entry-table-components/open-chart.component.tsx +33 -0
  196. package/src/queue-entry-table-components/open-chart.resource.tsx +14 -0
  197. package/src/queue-entry-table-components/open-chart.scss +14 -0
  198. package/src/queue-entry-table-components/status-icon.component.tsx +17 -0
  199. package/src/queue-entry-table-components/transition-entry.component.tsx +53 -0
  200. package/src/queue-entry-table-components/transition-entry.scss +22 -0
  201. package/src/queue-patient-linelists/queue-linelist-base-table.component.tsx +230 -0
  202. package/src/queue-patient-linelists/queue-linelist-base-table.scss +110 -0
  203. package/src/queue-patient-linelists/queue-linelist-base-table.test.tsx +118 -0
  204. package/src/queue-patient-linelists/queue-linelist-filter.component.tsx +172 -0
  205. package/src/queue-patient-linelists/queue-linelist-filter.scss +63 -0
  206. package/src/queue-patient-linelists/queue-linelist-filter.test.tsx +76 -0
  207. package/src/queue-patient-linelists/queue-linelist.component.tsx +29 -0
  208. package/src/queue-patient-linelists/queue-linelist.resource.tsx +84 -0
  209. package/src/queue-patient-linelists/queue-linelist.test.tsx +22 -0
  210. package/src/queue-patient-linelists/queue-services-table.component.tsx +63 -0
  211. package/src/queue-patient-linelists/scheduled-appointments-table.component.tsx +300 -0
  212. package/src/queue-patient-linelists/scheduled-appointments-table.test.tsx +42 -0
  213. package/src/queue-rooms/queue-room-form.component.tsx +168 -0
  214. package/src/queue-rooms/queue-room-form.test.tsx +65 -0
  215. package/src/queue-rooms/queue-room.resource.tsx +20 -0
  216. package/src/queue-rooms/queue-room.scss +58 -0
  217. package/src/queue-screen/queue-screen.component.tsx +47 -0
  218. package/src/queue-screen/queue-screen.scss +39 -0
  219. package/src/queue-screen/queue-screen.test.tsx +47 -0
  220. package/src/queue-screen/useActiveTickets.tsx +13 -0
  221. package/src/queue-services/queue-service-form.component.tsx +183 -0
  222. package/src/queue-services/queue-service-form.test.tsx +56 -0
  223. package/src/queue-services/queue-service.resource.tsx +38 -0
  224. package/src/queue-services/queue-service.scss +54 -0
  225. package/src/remove-queue-entry-dialog/remove-queue-entry.component.tsx +95 -0
  226. package/src/remove-queue-entry-dialog/remove-queue-entry.resource.tsx +93 -0
  227. package/src/remove-queue-entry-dialog/remove-queue-entry.scss +8 -0
  228. package/src/remove-queue-entry-dialog/remove-queue-entry.test.tsx +44 -0
  229. package/src/root.component.tsx +28 -0
  230. package/src/root.scss +15 -0
  231. package/src/root.test.tsx +28 -0
  232. package/src/routes.json +91 -0
  233. package/src/side-menu/nav-group/createNavGroup.tsx +17 -0
  234. package/src/side-menu/nav-group/nav-group.component.tsx +24 -0
  235. package/src/side-menu/nav-group/nav-group.test.tsx +32 -0
  236. package/src/side-menu/nav-group/nav-group.ts +10 -0
  237. package/src/side-menu/side-menu.component.tsx +6 -0
  238. package/src/side-menu/side-menu.test.tsx +17 -0
  239. package/src/transition-queue-entry/transition-queue-entry-dialog.component.tsx +174 -0
  240. package/src/transition-queue-entry/transition-queue-entry-dialog.scss +12 -0
  241. package/src/transition-queue-entry/transition-queue-entry-dialog.test.tsx +95 -0
  242. package/src/transition-queue-entry/transition-queue-entry.resource.ts +16 -0
  243. package/src/types/index.ts +434 -0
  244. package/src/visits-missing-inqueue/visits-missing-inqueue.component.tsx +298 -0
  245. package/src/visits-missing-inqueue/visits-missing-inqueue.resource.ts +93 -0
  246. package/src/visits-missing-inqueue/visits-missing-inqueue.scss +108 -0
  247. package/translations/am.json +258 -0
  248. package/translations/en.json +258 -0
  249. package/translations/es.json +258 -0
  250. package/translations/fr.json +258 -0
  251. package/translations/he.json +262 -0
  252. package/translations/km.json +258 -0
  253. package/tsconfig.json +5 -0
  254. package/webpack.config.js +1 -0
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Calendar, Location } from '@carbon/react/icons';
4
+ import { Dropdown } from '@carbon/react';
5
+ import { formatDate, useSession } from '@openmrs/esm-framework';
6
+ import PatientQueueIllustration from './patient-queue-illustration.component';
7
+ import { useQueueLocations } from '../patient-search/hooks/useQueueLocations';
8
+ import {
9
+ updateSelectedQueueLocationUuid,
10
+ updateSelectedQueueLocationName,
11
+ updateSelectedServiceName,
12
+ useSelectedQueueLocationName,
13
+ } from '../helpers/helpers';
14
+ import styles from './patient-queue-header.scss';
15
+
16
+ const PatientQueueHeader: React.FC<{ title?: string }> = ({ title }) => {
17
+ const { t } = useTranslation();
18
+ const userSession = useSession();
19
+ const userLocation = userSession?.sessionLocation?.display;
20
+ const { queueLocations } = useQueueLocations();
21
+ const currentQueueLocationName = useSelectedQueueLocationName();
22
+
23
+ const handleQueueLocationChange = ({ selectedItem }) => {
24
+ updateSelectedQueueLocationUuid(selectedItem.id);
25
+ updateSelectedQueueLocationName(selectedItem.name);
26
+ updateSelectedServiceName('All');
27
+ };
28
+
29
+ return (
30
+ <>
31
+ <div className={styles.header} data-testid="patient-queue-header">
32
+ <div className={styles['left-justified-items']}>
33
+ <PatientQueueIllustration />
34
+ <div className={styles['page-labels']}>
35
+ <p>{t('serviceQueues', 'Service queues')}</p>
36
+ <p className={styles['page-name']}>{title ?? t('home', 'Home')}</p>
37
+ </div>
38
+ </div>
39
+ <div className={styles['right-justified-items']}>
40
+ <div className={styles['date-and-location']}>
41
+ <Location size={16} />
42
+ <span className={styles.value}>{userLocation}</span>
43
+ <span className={styles.middot}>&middot;</span>
44
+ <Calendar size={16} />
45
+ <span className={styles.value}>{formatDate(new Date(), { mode: 'standard' })}</span>
46
+ </div>
47
+ <div className={styles.dropdown}>
48
+ <label className={styles.view}>{t('view', 'View')}:</label>
49
+ <Dropdown
50
+ id="typeOfCare"
51
+ label={currentQueueLocationName ?? queueLocations?.[0]?.name}
52
+ items={[{ display: `${t('all', 'All')}` }, ...queueLocations]}
53
+ itemToString={(item) => (item ? item.name : '')}
54
+ type="inline"
55
+ onChange={handleQueueLocationChange}
56
+ />
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </>
61
+ );
62
+ };
63
+
64
+ export default PatientQueueHeader;
@@ -0,0 +1,88 @@
1
+ @use '@carbon/styles/scss/type';
2
+ @use '@carbon/styles/scss/spacing';
3
+ @import '~@openmrs/esm-styleguide/src/vars';
4
+
5
+ .header {
6
+ @include type.type-style('body-compact-02');
7
+ color: $text-02;
8
+ height: spacing.$spacing-12;
9
+ background-color: $ui-02;
10
+ border: 1px solid $ui-03;
11
+ border-left: 0px;
12
+ display: flex;
13
+ justify-content: space-between;
14
+ }
15
+
16
+ .left-justified-items {
17
+ display: flex;
18
+ flex-direction: row;
19
+ align-items: center;
20
+ }
21
+
22
+ .right-justified-items {
23
+ @include type.type-style('body-compact-02');
24
+ color: $text-02;
25
+ padding-top: 1rem;
26
+ }
27
+
28
+ .page-name {
29
+ @include type.type-style('heading-04');
30
+ }
31
+
32
+ .page-labels {
33
+ p:first-of-type {
34
+ margin-bottom: 0.25rem;
35
+ }
36
+ }
37
+
38
+ .date-and-location {
39
+ display: flex;
40
+ justify-content: flex-end;
41
+ align-items: center;
42
+ margin-right: 1rem;
43
+ }
44
+
45
+ .value {
46
+ margin-left: 0.25rem;
47
+ }
48
+
49
+ .middot {
50
+ margin: 0 0.5rem;
51
+ }
52
+
53
+ .view {
54
+ @include type.type-style('label-01');
55
+ }
56
+
57
+ .dropdown {
58
+ display: flex;
59
+ align-items: center;
60
+ justify-content: flex-end;
61
+ margin-top: 0.25rem;
62
+
63
+ :global(.cds--dropdown__wrapper--inline) {
64
+ align-items: center;
65
+ display: flex;
66
+ }
67
+
68
+ :global(.cds--list-box__menu) {
69
+ left: -10.15rem;
70
+ }
71
+ }
72
+
73
+ // Overriding styles for RTL support
74
+ html[dir='rtl'] {
75
+ .date-and-location {
76
+ margin-right: unset;
77
+ margin-left: spacing.$spacing-05;
78
+ & > svg:first-child {
79
+ order: -1;
80
+ }
81
+ & > svg:nth-child(4) {
82
+ order: 1;
83
+ }
84
+ & > span:nth-child(2) {
85
+ order: -2;
86
+ }
87
+ }
88
+ }
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+
3
+ const PatientQueueIllustration: React.FC = () => {
4
+ return (
5
+ <svg width="92" height="94" viewBox="0 0 92 94" xmlns="http://www.w3.org/2000/svg">
6
+ <title>Patient queue illustration</title>
7
+ <g fill="none" fillRule="evenodd">
8
+ <path fill="#FFF" d="M0 0h92v94H0z" />
9
+ <path
10
+ d="M40 32c.84-.602 1.12-1.797 1-3 .12-5.005-3.96-9-9-9s-9.12 3.995-9 9c-.12 3.572 2.1 6.706 5 8-6.76 1.741-12 7.91-12 15v15h28V32h-4zM76 67V52c0-7.09-5.24-13.278-12-15 2.9-1.294 5.12-4.428 5-8 .12-5.005-3.96-9-9-9s-9.12 3.995-9 9c-.12 1.203.14 2.398 1 3h-4v35h28z"
11
+ fill="#CEE6E5"
12
+ />
13
+ <path
14
+ d="M32 75V60.312c0-7.402 5.24-13.59 12.3-15.216-3.2-1.39-5.42-4.523-5.42-8.166 0-4.935 4.08-8.93 9.12-8.93 5.04 0 9.12 3.995 9.12 8.93 0 3.642-2.22 6.776-5.42 8.166C58.76 46.741 64 52.91 64 60.313V75"
15
+ fill="#7BBCB9"
16
+ />
17
+ </g>
18
+ </svg>
19
+ );
20
+ };
21
+
22
+ export default PatientQueueIllustration;
@@ -0,0 +1,93 @@
1
+ import React, { useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Dropdown } from '@carbon/react';
4
+ import MetricsCard from './metrics-card.component';
5
+ import MetricsHeader from './metrics-header.component';
6
+ import {
7
+ updateSelectedServiceName,
8
+ updateSelectedServiceUuid,
9
+ useSelectedServiceName,
10
+ useSelectedServiceUuid,
11
+ useSelectedQueueLocationUuid,
12
+ } from '../helpers/helpers';
13
+ import { useActiveVisits, useAverageWaitTime } from './clinic-metrics.resource';
14
+ import { useServiceMetricsCount, useServices } from './queue-metrics.resource';
15
+ import { useVisitQueueEntries } from '../active-visits/active-visits-table.resource';
16
+ import styles from './clinic-metrics.scss';
17
+ import { useQueueLocations } from '../patient-search/hooks/useQueueLocations';
18
+
19
+ export interface Service {
20
+ uuid: string;
21
+ display: string;
22
+ }
23
+
24
+ function ClinicMetrics() {
25
+ const { t } = useTranslation();
26
+
27
+ const currentQueueLocation = useSelectedQueueLocationUuid();
28
+ const { queueLocations } = useQueueLocations();
29
+ const { allServices } = useServices(currentQueueLocation ?? queueLocations?.[0]?.id);
30
+ const currentServiceUuid = useSelectedServiceUuid();
31
+ const currentServiceName = useSelectedServiceName();
32
+ const { serviceCount } = useServiceMetricsCount(currentServiceName, currentQueueLocation ?? queueLocations?.[0]?.id);
33
+ const [initialSelectedItem, setInitialSelectItem] = useState(() => {
34
+ if (currentServiceName && currentServiceUuid) {
35
+ return false;
36
+ } else if (currentServiceName === t('all', 'All')) {
37
+ return true;
38
+ } else {
39
+ return true;
40
+ }
41
+ });
42
+ const { visitQueueEntriesCount } = useVisitQueueEntries(currentServiceName, currentQueueLocation);
43
+ const { activeVisitsCount, isLoading: loading } = useActiveVisits();
44
+ const { waitTime } = useAverageWaitTime(currentServiceUuid, '');
45
+
46
+ const handleServiceChange = ({ selectedItem }) => {
47
+ updateSelectedServiceUuid(selectedItem.uuid);
48
+ updateSelectedServiceName(selectedItem.display);
49
+ if (selectedItem.uuid == undefined) {
50
+ setInitialSelectItem(true);
51
+ } else {
52
+ setInitialSelectItem(false);
53
+ }
54
+ };
55
+
56
+ return (
57
+ <>
58
+ <MetricsHeader />
59
+ <div className={styles.cardContainer} data-testid="clinic-metrics">
60
+ <MetricsCard
61
+ label={t('patients', 'Patients')}
62
+ value={loading ? '--' : activeVisitsCount}
63
+ headerLabel={t('checkedInPatients', 'Checked in patients')}
64
+ service="scheduled"
65
+ />
66
+ <MetricsCard
67
+ label={t('patients', 'Patients')}
68
+ value={initialSelectedItem ? visitQueueEntriesCount : serviceCount}
69
+ headerLabel={`${t('waitingFor', 'Waiting for')}:`}
70
+ service={currentServiceName}
71
+ serviceUuid={currentServiceUuid}
72
+ locationUuid={currentQueueLocation}>
73
+ <Dropdown
74
+ id="inline"
75
+ type="inline"
76
+ label={currentServiceName ?? `${t('all', 'All')}`}
77
+ items={[{ display: `${t('all', 'All')}` }, ...allServices]}
78
+ itemToString={(item) => (item ? item.display : '')}
79
+ onChange={handleServiceChange}
80
+ />
81
+ </MetricsCard>
82
+ <MetricsCard
83
+ label={t('minutes', 'Minutes')}
84
+ value={waitTime ? waitTime.averageWaitTime : '--'}
85
+ headerLabel={t('averageWaitTime', 'Average wait time today')}
86
+ service="waitTime"
87
+ />
88
+ </div>
89
+ </>
90
+ );
91
+ }
92
+
93
+ export default ClinicMetrics;
@@ -0,0 +1,51 @@
1
+ import { useSession, Visit, openmrsFetch } from '@openmrs/esm-framework';
2
+ import dayjs from 'dayjs';
3
+ import useSWR from 'swr';
4
+ import { WaitTime } from '../types';
5
+
6
+ export function useActiveVisits() {
7
+ const currentUserSession = useSession();
8
+ const startDate = dayjs().format('YYYY-MM-DD');
9
+ const sessionLocation = currentUserSession?.sessionLocation?.uuid;
10
+
11
+ const customRepresentation =
12
+ 'custom:(uuid,patient:(uuid,identifiers:(identifier,uuid),person:(age,display,gender,uuid)),' +
13
+ 'visitType:(uuid,name,display),location:(uuid,name,display),startDatetime,' +
14
+ 'stopDatetime)&fromStartDate=' +
15
+ startDate +
16
+ '&location=' +
17
+ sessionLocation;
18
+ const url = `/ws/rest/v1/visit?includeInactive=false&v=${customRepresentation}`;
19
+ const { data, error, isLoading, isValidating } = useSWR<{ data: { results: Array<Visit> } }, Error>(
20
+ sessionLocation ? url : null,
21
+ openmrsFetch,
22
+ );
23
+
24
+ const activeVisitsCount = data?.data?.results.length
25
+ ? data.data.results.filter((visit) => dayjs(visit.startDatetime).isToday())?.length
26
+ : 0;
27
+
28
+ return {
29
+ activeVisitsCount: activeVisitsCount,
30
+ isLoading,
31
+ isError: error,
32
+ isValidating,
33
+ };
34
+ }
35
+
36
+ export function useAverageWaitTime(serviceUuid: string, statusUuid: string) {
37
+ const apiUrl = `/ws/rest/v1/queue-metrics?queue=${serviceUuid}&status=${statusUuid}`;
38
+
39
+ const { data, error, isLoading, isValidating, mutate } = useSWR<{ data: WaitTime }, Error>(
40
+ serviceUuid && statusUuid ? apiUrl : null,
41
+ openmrsFetch,
42
+ );
43
+
44
+ return {
45
+ waitTime: data ? data?.data : null,
46
+ isLoading,
47
+ isError: error,
48
+ isValidating,
49
+ mutate,
50
+ };
51
+ }
@@ -0,0 +1,11 @@
1
+ @use '@carbon/styles/scss/spacing';
2
+ @import '~@openmrs/esm-styleguide/src/vars';
3
+
4
+ .cardContainer {
5
+ background-color: $ui-02;
6
+ display: flex;
7
+ justify-content: space-between;
8
+ padding: 0 spacing.$spacing-05 spacing.$spacing-07 spacing.$spacing-03;
9
+ flex-flow: row wrap;
10
+ margin-top: -(spacing.$spacing-03);
11
+ }
@@ -0,0 +1,87 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { openmrsFetch, useConfig } from '@openmrs/esm-framework';
4
+ import ClinicMetrics from './clinic-metrics.component';
5
+ import { mockMetrics, mockServiceTypes } from '../../../../__mocks__/metrics.mock';
6
+ import { mockLocations } from '../../../../__mocks__/locations.mock';
7
+ import { mockSession } from '../../../../__mocks__/session.mock';
8
+
9
+ const mockedOpenmrsFetch = openmrsFetch as jest.Mock;
10
+ const mockedUseConfig = useConfig as jest.Mock;
11
+
12
+ jest.mock('./queue-metrics.resource.ts', () => {
13
+ const originalModule = jest.requireActual('./queue-metrics.resource.ts');
14
+
15
+ return {
16
+ ...originalModule,
17
+ useServices: jest.fn().mockImplementation(() => ({ allServices: mockServiceTypes.data })),
18
+ useServiceMetricsCount: jest.fn().mockReturnValue(5),
19
+ };
20
+ });
21
+
22
+ jest.mock('./clinic-metrics.resource.tsx', () => {
23
+ const originalModule = jest.requireActual('./clinic-metrics.resource.tsx');
24
+
25
+ return {
26
+ ...originalModule,
27
+ useAverageWaitTime: jest.fn().mockImplementation(() => ({ waitTime: mockMetrics.waitTime })),
28
+ useActiveVisits: jest.fn().mockImplementation(() => ({ activeVisitsCount: mockMetrics.activeVisitsCount })),
29
+ };
30
+ });
31
+
32
+ jest.mock('@openmrs/esm-framework', () => {
33
+ const originalModule = jest.requireActual('@openmrs/esm-framework');
34
+
35
+ return {
36
+ ...originalModule,
37
+ useLocations: jest.fn().mockImplementation(() => mockLocations.data),
38
+ useSession: jest.fn().mockImplementation(() => mockSession.data),
39
+ };
40
+ });
41
+
42
+ jest.mock('../helpers/helpers.ts', () => {
43
+ const originalModule = jest.requireActual('../helpers/helpers.ts');
44
+
45
+ return {
46
+ ...originalModule,
47
+ useSelectedServiceName: jest.fn().mockReturnValue('All'),
48
+ };
49
+ });
50
+
51
+ jest.mock('../active-visits/active-visits-table.resource.ts', () => {
52
+ const originalModule = jest.requireActual('../active-visits/active-visits-table.resource.ts');
53
+
54
+ return {
55
+ ...originalModule,
56
+ useVisitQueueEntries: jest.fn().mockReturnValue(5),
57
+ };
58
+ });
59
+
60
+ describe('Clinic metrics', () => {
61
+ it('renders a dashboard outlining metrics from the outpatient clinic', async () => {
62
+ mockedUseConfig.mockReturnValue({
63
+ concepts: {
64
+ visitQueueNumberAttributeUuid: 'c61ce16f-272a-41e7-9924-4c555d0932c5',
65
+ },
66
+ });
67
+
68
+ mockedOpenmrsFetch.mockReturnValue({ data: mockMetrics });
69
+
70
+ renderClinicMetrics();
71
+
72
+ await screen.findByText(/Checked in patients/i);
73
+ expect(screen.getByText(/100/i)).toBeInTheDocument();
74
+ expect(screen.getAllByText(/patient list/i));
75
+ expect(screen.getByText(/Average wait time today/i)).toBeInTheDocument();
76
+ expect(screen.getByText(/minutes/i)).toBeInTheDocument();
77
+ expect(screen.getByRole('button', { name: /Queue screen/i })).toBeInTheDocument();
78
+ expect(screen.getByText(/69/i)).toBeInTheDocument();
79
+
80
+ // Select a different service to show metrics for
81
+ expect(screen.getByRole('button', { name: /open menu/i }));
82
+ });
83
+ });
84
+
85
+ function renderClinicMetrics() {
86
+ render(<ClinicMetrics />);
87
+ }
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Layer, Tile } from '@carbon/react';
4
+ import { ArrowRight } from '@carbon/react/icons';
5
+ import { ConfigurableLink } from '@openmrs/esm-framework';
6
+ import styles from './metrics-card.scss';
7
+
8
+ interface MetricsCardProps {
9
+ label: string;
10
+ value: number | string;
11
+ headerLabel: string;
12
+ children?: React.ReactNode;
13
+ service?: string;
14
+ serviceUuid?: string;
15
+ locationUuid?: string;
16
+ }
17
+
18
+ const MetricsCard: React.FC<MetricsCardProps> = ({
19
+ label,
20
+ value,
21
+ headerLabel,
22
+ children,
23
+ service,
24
+ serviceUuid,
25
+ locationUuid,
26
+ }) => {
27
+ const { t } = useTranslation();
28
+
29
+ return (
30
+ <Layer className={`${children && styles.cardWithChildren} ${styles.container}`}>
31
+ <Tile className={styles.tileContainer}>
32
+ <div className={styles.tileHeader}>
33
+ <div className={styles.headerLabelContainer}>
34
+ <label className={styles.headerLabel}>{headerLabel}</label>
35
+ {children}
36
+ </div>
37
+ {service == 'scheduled' ? (
38
+ <div className={styles.link}>
39
+ <ConfigurableLink className={styles.link} to={`\${openmrsSpaBase}/home`}>
40
+ {t('patientList', 'Patient list')}
41
+ </ConfigurableLink>
42
+ <ArrowRight size={16} />
43
+ </div>
44
+ ) : service == 'waitTime' ? null : (
45
+ <div className={styles.link}>
46
+ <ConfigurableLink
47
+ className={styles.link}
48
+ to={`\${openmrsSpaBase}/queue-list/${service}/${serviceUuid}/${locationUuid}/`}>
49
+ {t('patientList', 'Patient list')}
50
+ </ConfigurableLink>
51
+ <ArrowRight size={16} />
52
+ </div>
53
+ )}
54
+ </div>
55
+ <div>
56
+ <label className={styles.totalsLabel}>{label}</label>
57
+ <p className={styles.totalsValue}>{value}</p>
58
+ </div>
59
+ </Tile>
60
+ </Layer>
61
+ );
62
+ };
63
+
64
+ export default MetricsCard;
@@ -0,0 +1,80 @@
1
+ @use '@carbon/styles/scss/spacing';
2
+ @use '@carbon/styles/scss/type';
3
+ @import '~@openmrs/esm-styleguide/src/vars';
4
+
5
+ .container {
6
+ flex-grow: 1;
7
+ }
8
+
9
+ /* Tablet viewport */
10
+ :global(.omrs-breakpoint-lt-desktop) {
11
+ // The card containing the dropdown element should be the first to overflow on tablet
12
+ .cardWithChildren {
13
+ order: 3;
14
+ }
15
+ }
16
+
17
+ .tileContainer {
18
+ border: 0.0625rem solid $ui-03;
19
+ height: 7.875rem;
20
+ padding: spacing.$spacing-05;
21
+ margin: spacing.$spacing-03 spacing.$spacing-03;
22
+ }
23
+
24
+ .tileHeader {
25
+ display: flex;
26
+ justify-content: space-between;
27
+ align-items: baseline;
28
+ margin-bottom: spacing.$spacing-03;
29
+ }
30
+
31
+ .headerLabel {
32
+ @include type.type-style('heading-compact-01');
33
+ color: $text-02;
34
+ }
35
+
36
+ .totalsLabel {
37
+ @include type.type-style('label-01');
38
+ color: $text-02;
39
+ }
40
+
41
+ .totalsValue {
42
+ @include type.type-style('heading-04');
43
+ color: $ui-05;
44
+ }
45
+
46
+ .headerLabelContainer {
47
+ display: flex;
48
+ height: spacing.$spacing-07;
49
+
50
+ :global(.cds--dropdown__wrapper--inline) {
51
+ gap: 0;
52
+ margin-top: -0.75rem;
53
+ }
54
+
55
+ :global(.cds--list-box__menu-icon) {
56
+ height: 1rem;
57
+ }
58
+ }
59
+
60
+ .link {
61
+ text-decoration: none;
62
+ display: flex;
63
+ align-items: center;
64
+ color: $interactive-01;
65
+
66
+ svg {
67
+ margin-left: spacing.$spacing-03;
68
+ }
69
+ }
70
+
71
+ // Overriding styles for RTL support
72
+ html[dir='rtl'] {
73
+ .link {
74
+ svg {
75
+ margin-right: spacing.$spacing-03;
76
+ margin-left: unset;
77
+ transform: scale(-1, 1);
78
+ }
79
+ }
80
+ }
@@ -0,0 +1,74 @@
1
+ import React, { useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { MessageQueue, ArrowRight } from '@carbon/react/icons';
4
+ import { Button } from '@carbon/react';
5
+ import styles from './metrics-header.scss';
6
+ import { navigate, UserHasAccess } from '@openmrs/esm-framework';
7
+ import { spaBasePath } from '../constants';
8
+ import { SearchTypes } from '../types';
9
+ import PatientSearch from '../patient-search/patient-search.component';
10
+
11
+ const MetricsHeader = () => {
12
+ const { t } = useTranslation();
13
+ const metricsTitle = t('clinicMetrics', 'Clinic metrics');
14
+ const queueScreenText = t('queueScreen', 'Queue screen');
15
+ const [showOverlay, setShowOverlay] = useState(false);
16
+ const [view, setView] = useState('');
17
+ const [viewState, setViewState] = useState<{ selectedPatientUuid: string }>(null);
18
+ const [overlayHeader, setOverlayTitle] = useState('');
19
+
20
+ const navigateToQueueScreen = () => {
21
+ navigate({ to: `${spaBasePath}/service-queues/screen` });
22
+ };
23
+
24
+ return (
25
+ <div className={styles.metricsContainer}>
26
+ <span className={styles.metricsTitle}>{metricsTitle}</span>
27
+ <div className={styles.actionBtn}>
28
+ <UserHasAccess privilege="Emr: View Legacy Interface">
29
+ <Button
30
+ kind="tertiary"
31
+ renderIcon={(props) => <ArrowRight size={16} {...props} />}
32
+ onClick={(selectedPatientUuid) => {
33
+ setShowOverlay(true);
34
+ setView(SearchTypes.QUEUE_SERVICE_FORM);
35
+ setViewState({ selectedPatientUuid });
36
+ setOverlayTitle(t('addNewQueueService', 'Add new queue service'));
37
+ }}
38
+ iconDescription={t('addNewQueueService', 'Add new queue service')}>
39
+ {t('addNewService', 'Add new service')}
40
+ </Button>
41
+ <Button
42
+ kind="tertiary"
43
+ renderIcon={(props) => <ArrowRight size={16} {...props} />}
44
+ onClick={(selectedPatientUuid) => {
45
+ setShowOverlay(true);
46
+ setView(SearchTypes.QUEUE_ROOM_FORM);
47
+ setViewState({ selectedPatientUuid });
48
+ setOverlayTitle(t('addNewQueueServiceRoom', 'Add new queue service room'));
49
+ }}
50
+ iconDescription={t('addNewQueueServiceRoom', 'Add new queue service room')}>
51
+ {t('addNewServiceRoom', 'Add new service room')}
52
+ </Button>
53
+ </UserHasAccess>
54
+ <Button
55
+ onClick={navigateToQueueScreen}
56
+ kind="tertiary"
57
+ renderIcon={(props) => <MessageQueue size={32} {...props} />}
58
+ iconDescription={queueScreenText}>
59
+ {queueScreenText}
60
+ </Button>
61
+ </div>
62
+ {showOverlay && (
63
+ <PatientSearch
64
+ view={view}
65
+ closePanel={() => setShowOverlay(false)}
66
+ viewState={viewState}
67
+ headerTitle={overlayHeader}
68
+ />
69
+ )}
70
+ </div>
71
+ );
72
+ };
73
+
74
+ export default MetricsHeader;
@@ -0,0 +1,22 @@
1
+ @use '@carbon/styles/scss/spacing';
2
+ @use '@carbon/styles/scss/type';
3
+ @import '~@openmrs/esm-styleguide/src/vars';
4
+
5
+ .metricsContainer {
6
+ display: flex;
7
+ justify-content: space-between;
8
+ background-color: $ui-02;
9
+ height: spacing.$spacing-10;
10
+ align-items: center;
11
+ padding: 0 spacing.$spacing-05;
12
+ }
13
+
14
+ .metricsTitle {
15
+ @include type.type-style('heading-03');
16
+ color: $ui-05;
17
+ }
18
+
19
+ .actionBtn {
20
+ display: flex;
21
+ column-gap: 0.5rem;
22
+ }