@kenyaemr/esm-service-queues-app 7.0.2-pre.65

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 (289) hide show
  1. package/.turbo/turbo-build.log +40 -0
  2. package/README.md +20 -0
  3. package/dist/130.js +2 -0
  4. package/dist/130.js.LICENSE.txt +3 -0
  5. package/dist/130.js.map +1 -0
  6. package/dist/152.js +1 -0
  7. package/dist/152.js.map +1 -0
  8. package/dist/169.js +1 -0
  9. package/dist/169.js.map +1 -0
  10. package/dist/185.js +1 -0
  11. package/dist/185.js.map +1 -0
  12. package/dist/233.js +1 -0
  13. package/dist/233.js.map +1 -0
  14. package/dist/237.js +1 -0
  15. package/dist/237.js.map +1 -0
  16. package/dist/255.js +2 -0
  17. package/dist/255.js.LICENSE.txt +9 -0
  18. package/dist/255.js.map +1 -0
  19. package/dist/271.js +1 -0
  20. package/dist/276.js +1 -0
  21. package/dist/276.js.map +1 -0
  22. package/dist/303.js +1 -0
  23. package/dist/303.js.map +1 -0
  24. package/dist/319.js +1 -0
  25. package/dist/401.js +1 -0
  26. package/dist/401.js.map +1 -0
  27. package/dist/430.js +2 -0
  28. package/dist/430.js.LICENSE.txt +50 -0
  29. package/dist/430.js.map +1 -0
  30. package/dist/460.js +1 -0
  31. package/dist/501.js +1 -0
  32. package/dist/501.js.map +1 -0
  33. package/dist/574.js +1 -0
  34. package/dist/591.js +2 -0
  35. package/dist/591.js.LICENSE.txt +32 -0
  36. package/dist/591.js.map +1 -0
  37. package/dist/644.js +1 -0
  38. package/dist/647.js +1 -0
  39. package/dist/647.js.map +1 -0
  40. package/dist/650.js +1 -0
  41. package/dist/650.js.map +1 -0
  42. package/dist/669.js +1 -0
  43. package/dist/669.js.map +1 -0
  44. package/dist/696.js +1 -0
  45. package/dist/696.js.map +1 -0
  46. package/dist/703.js +1 -0
  47. package/dist/703.js.map +1 -0
  48. package/dist/729.js +1 -0
  49. package/dist/729.js.map +1 -0
  50. package/dist/738.js +1 -0
  51. package/dist/738.js.map +1 -0
  52. package/dist/757.js +1 -0
  53. package/dist/764.js +1 -0
  54. package/dist/764.js.map +1 -0
  55. package/dist/784.js +2 -0
  56. package/dist/784.js.LICENSE.txt +9 -0
  57. package/dist/784.js.map +1 -0
  58. package/dist/788.js +1 -0
  59. package/dist/806.js +1 -0
  60. package/dist/806.js.map +1 -0
  61. package/dist/807.js +1 -0
  62. package/dist/833.js +1 -0
  63. package/dist/877.js +1 -0
  64. package/dist/877.js.map +1 -0
  65. package/dist/917.js +1 -0
  66. package/dist/917.js.map +1 -0
  67. package/dist/940.js +1 -0
  68. package/dist/940.js.map +1 -0
  69. package/dist/981.js +1 -0
  70. package/dist/981.js.map +1 -0
  71. package/dist/kenyaemr-esm-service-queues-app.js +1 -0
  72. package/dist/kenyaemr-esm-service-queues-app.js.buildmanifest.json +965 -0
  73. package/dist/kenyaemr-esm-service-queues-app.js.map +1 -0
  74. package/dist/main.js +2 -0
  75. package/dist/main.js.LICENSE.txt +60 -0
  76. package/dist/main.js.map +1 -0
  77. package/dist/routes.json +1 -0
  78. package/jest.config.js +3 -0
  79. package/package.json +54 -0
  80. package/src/active-visits/active-visits-row-actions.component.tsx +25 -0
  81. package/src/active-visits/active-visits-row-actions.scss +4 -0
  82. package/src/active-visits/active-visits-table.resource.ts +273 -0
  83. package/src/active-visits/change-status-dialog.component.tsx +272 -0
  84. package/src/active-visits/change-status-dialog.scss +47 -0
  85. package/src/active-visits/change-status-dialog.test.tsx +154 -0
  86. package/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx +228 -0
  87. package/src/add-patient-toqueue/add-patient-toqueue-dialog.scss +32 -0
  88. package/src/add-provider-queue-room/add-provider-queue-room.component.tsx +238 -0
  89. package/src/add-provider-queue-room/add-provider-queue-room.resource.ts +76 -0
  90. package/src/add-provider-queue-room/add-provider-queue-room.scss +17 -0
  91. package/src/add-provider-queue-room/add-provider-queue-room.test.tsx +105 -0
  92. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.component.tsx +76 -0
  93. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.resource.ts +7 -0
  94. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.scss +8 -0
  95. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.test.tsx +43 -0
  96. package/src/clear-queue-entries-dialog/clear-queue-entries.component.tsx +43 -0
  97. package/src/config-schema.ts +465 -0
  98. package/src/constants.ts +10 -0
  99. package/src/createDashboardLink.component.tsx +39 -0
  100. package/src/current-visit/current-visit-summary.component.tsx +38 -0
  101. package/src/current-visit/current-visit-summary.test.tsx +43 -0
  102. package/src/current-visit/current-visit.resource.ts +84 -0
  103. package/src/current-visit/current-visit.scss +34 -0
  104. package/src/current-visit/hooks/useVitalsConceptMetadata.tsx +101 -0
  105. package/src/current-visit/visit-details/biometrics-config-schema.ts +14 -0
  106. package/src/current-visit/visit-details/current-visit-details.component.tsx +96 -0
  107. package/src/current-visit/visit-details/triage-note.component.tsx +53 -0
  108. package/src/current-visit/visit-details/triage-note.scss +89 -0
  109. package/src/current-visit/visit-details/vitals-config-schema.ts +17 -0
  110. package/src/current-visit/visit-details/vitals.component.tsx +165 -0
  111. package/src/dashboard.meta.ts +5 -0
  112. package/src/declarations.d.ts +4 -0
  113. package/src/helpers/functions.ts +28 -0
  114. package/src/helpers/helpers.ts +177 -0
  115. package/src/helpers/time-helpers.ts +15 -0
  116. package/src/home.component.tsx +16 -0
  117. package/src/home.test.tsx +48 -0
  118. package/src/hooks/useConcept.ts +13 -0
  119. package/src/hooks/useQueue.ts +10 -0
  120. package/src/hooks/useQueueEntries.ts +187 -0
  121. package/src/hooks/useQueues.ts +22 -0
  122. package/src/hooks/useSystemSetting.ts +18 -0
  123. package/src/index.ts +172 -0
  124. package/src/past-visit/past-visit-details/encounter-list.component.tsx +54 -0
  125. package/src/past-visit/past-visit-details/medications-list.component.tsx +98 -0
  126. package/src/past-visit/past-visit-details/notes-list.component.tsx +41 -0
  127. package/src/past-visit/past-visit-details/past-visit-summary.component.tsx +181 -0
  128. package/src/past-visit/past-visit-details/past-visit-summary.scss +58 -0
  129. package/src/past-visit/past-visit.component.tsx +37 -0
  130. package/src/past-visit/past-visit.resource.ts +83 -0
  131. package/src/past-visit/past-visit.scss +126 -0
  132. package/src/past-visit/past-visit.test.tsx +41 -0
  133. package/src/patient-info/appointment-details.component.tsx +98 -0
  134. package/src/patient-info/appointment-details.scss +34 -0
  135. package/src/patient-info/appointment-details.test.tsx +36 -0
  136. package/src/patient-info/appointments.resource.ts +43 -0
  137. package/src/patient-info/hooks/usePatientAttributes.tsx +42 -0
  138. package/src/patient-info/patient-info.component.tsx +82 -0
  139. package/src/patient-info/patient-info.scss +60 -0
  140. package/src/patient-info/patient-info.test.tsx +43 -0
  141. package/src/patient-queue-header/patient-queue-header.component.tsx +99 -0
  142. package/src/patient-queue-header/patient-queue-header.scss +90 -0
  143. package/src/patient-queue-header/patient-queue-illustration.component.tsx +22 -0
  144. package/src/patient-queue-metrics/clinic-metrics.component.tsx +98 -0
  145. package/src/patient-queue-metrics/clinic-metrics.resource.ts +58 -0
  146. package/src/patient-queue-metrics/clinic-metrics.scss +11 -0
  147. package/src/patient-queue-metrics/clinic-metrics.test.tsx +76 -0
  148. package/src/patient-queue-metrics/metrics-card.component.tsx +68 -0
  149. package/src/patient-queue-metrics/metrics-card.scss +80 -0
  150. package/src/patient-queue-metrics/metrics-header.component.tsx +61 -0
  151. package/src/patient-queue-metrics/metrics-header.scss +26 -0
  152. package/src/patient-queue-metrics/queue-metrics.resource.ts +42 -0
  153. package/src/patient-search/advanced-search.component.tsx +191 -0
  154. package/src/patient-search/advanced-search.scss +154 -0
  155. package/src/patient-search/advanced-search.test.tsx +29 -0
  156. package/src/patient-search/basic-search.component.tsx +112 -0
  157. package/src/patient-search/basic-search.scss +139 -0
  158. package/src/patient-search/basic-search.test.tsx +23 -0
  159. package/src/patient-search/empty-data-illustration.component.tsx +41 -0
  160. package/src/patient-search/hooks/useActivePatientEnrollment.tsx +29 -0
  161. package/src/patient-search/hooks/useDefaultLocation.ts +14 -0
  162. package/src/patient-search/hooks/usePatients.tsx +25 -0
  163. package/src/patient-search/hooks/useQueueLocations.tsx +23 -0
  164. package/src/patient-search/hooks/useRecommendedVisitTypes.tsx +35 -0
  165. package/src/patient-search/hooks/useScheduledVisits.ts +52 -0
  166. package/src/patient-search/patient-scheduled-visits.component.tsx +324 -0
  167. package/src/patient-search/patient-scheduled-visits.scss +131 -0
  168. package/src/patient-search/patient-scheduled-visits.test.tsx +44 -0
  169. package/src/patient-search/patient-search.scss +43 -0
  170. package/src/patient-search/patient-search.workspace.tsx +135 -0
  171. package/src/patient-search/search-illustration.component.tsx +27 -0
  172. package/src/patient-search/search-results.component.tsx +75 -0
  173. package/src/patient-search/search-results.scss +80 -0
  174. package/src/patient-search/search-results.test.tsx +77 -0
  175. package/src/patient-search/search.resource.ts +10 -0
  176. package/src/patient-search/visit-form/existing-visit-form.component.tsx +112 -0
  177. package/src/patient-search/visit-form/queue.resource.ts +64 -0
  178. package/src/patient-search/visit-form/visit-form.component.tsx +344 -0
  179. package/src/patient-search/visit-form/visit-form.scss +73 -0
  180. package/src/patient-search/visit-form/visit-type-selector.component.tsx +155 -0
  181. package/src/patient-search/visit-form/visit-type-selector.scss +100 -0
  182. package/src/patient-search/visit-form/visit-type-selector.test.tsx +83 -0
  183. package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.component.tsx +178 -0
  184. package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.scss +19 -0
  185. package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.test.tsx +63 -0
  186. package/src/queue-entry-table-components/edit-entry.scss +14 -0
  187. package/src/queue-entry-table-components/queue-duration.component.tsx +41 -0
  188. package/src/queue-entry-table-components/queue-priority.component.tsx +38 -0
  189. package/src/queue-entry-table-components/queue-priority.scss +12 -0
  190. package/src/queue-entry-table-components/queue-status.component.tsx +39 -0
  191. package/src/queue-entry-table-components/transition-entry.component.tsx +55 -0
  192. package/src/queue-entry-table-components/transition-entry.scss +22 -0
  193. package/src/queue-patient-linelists/queue-linelist-base-table.component.tsx +241 -0
  194. package/src/queue-patient-linelists/queue-linelist-base-table.scss +110 -0
  195. package/src/queue-patient-linelists/queue-linelist-base-table.test.tsx +93 -0
  196. package/src/queue-patient-linelists/queue-linelist-filter.scss +63 -0
  197. package/src/queue-patient-linelists/queue-linelist-filter.test.tsx +94 -0
  198. package/src/queue-patient-linelists/queue-linelist-filter.workspace.tsx +185 -0
  199. package/src/queue-patient-linelists/queue-linelist.resource.ts +84 -0
  200. package/src/queue-patient-linelists/queue-services-table.component.tsx +63 -0
  201. package/src/queue-patient-linelists/scheduled-appointments-table.component.tsx +305 -0
  202. package/src/queue-patient-linelists/scheduled-appointments-table.test.tsx +41 -0
  203. package/src/queue-rooms/queue-room-form.scss +56 -0
  204. package/src/queue-rooms/queue-room-form.test.tsx +80 -0
  205. package/src/queue-rooms/queue-room-form.workspace.tsx +169 -0
  206. package/src/queue-rooms/queue-room.resource.ts +20 -0
  207. package/src/queue-screen/queue-screen.component.tsx +47 -0
  208. package/src/queue-screen/queue-screen.scss +39 -0
  209. package/src/queue-screen/queue-screen.test.tsx +51 -0
  210. package/src/queue-screen/useActiveTickets.tsx +13 -0
  211. package/src/queue-services/queue-service-form.scss +61 -0
  212. package/src/queue-services/queue-service-form.test.tsx +60 -0
  213. package/src/queue-services/queue-service-form.workspace.tsx +179 -0
  214. package/src/queue-services/queue-service.resource.ts +33 -0
  215. package/src/queue-table/cells/columns.resource.ts +135 -0
  216. package/src/queue-table/cells/queue-table-action-cell.component.tsx +88 -0
  217. package/src/queue-table/cells/queue-table-action-cell.scss +7 -0
  218. package/src/queue-table/cells/queue-table-coming-from-cell.component.tsx +13 -0
  219. package/src/queue-table/cells/queue-table-extension-cell.component.tsx +16 -0
  220. package/src/queue-table/cells/queue-table-name-cell.component.tsx +20 -0
  221. package/src/queue-table/cells/queue-table-patient-age-cell.component.tsx +18 -0
  222. package/src/queue-table/cells/queue-table-patient-identifier-cell.component.tsx +25 -0
  223. package/src/queue-table/cells/queue-table-priority-cell.component.tsx +23 -0
  224. package/src/queue-table/cells/queue-table-queue-name-cell.component.tsx +14 -0
  225. package/src/queue-table/cells/queue-table-status-cell.component.tsx +18 -0
  226. package/src/queue-table/cells/queue-table-visit-attribute-queue-number-cell.component.tsx +37 -0
  227. package/src/queue-table/cells/queue-table-visit-start-time-cell.component.tsx +20 -0
  228. package/src/queue-table/cells/queue-table-wait-time-cell.component.tsx +17 -0
  229. package/src/queue-table/default-queue-table.component.tsx +174 -0
  230. package/src/queue-table/default-queue-table.test.tsx +131 -0
  231. package/src/queue-table/queue-entry-actions/edit-queue-entry-modal.component.tsx +52 -0
  232. package/src/queue-table/queue-entry-actions/end-queue-entry-modal.component.tsx +39 -0
  233. package/src/queue-table/queue-entry-actions/queue-entry-actions-modal.component.tsx +362 -0
  234. package/src/queue-table/queue-entry-actions/queue-entry-actions-modal.test.tsx +152 -0
  235. package/src/queue-table/queue-entry-actions/queue-entry-actions.resource.ts +83 -0
  236. package/src/queue-table/queue-entry-actions/queue-entry-actons-modal.scss +36 -0
  237. package/src/queue-table/queue-entry-actions/queue-entry-confirm-action-modal.component.tsx +97 -0
  238. package/src/queue-table/queue-entry-actions/queue-entry-confirm-action-modal.test.tsx +106 -0
  239. package/src/queue-table/queue-entry-actions/queue-entry-undo-actions-modal.test.tsx +76 -0
  240. package/src/queue-table/queue-entry-actions/transition-queue-entry-modal.component.tsx +51 -0
  241. package/src/queue-table/queue-entry-actions/undo-transition-queue-entry-modal.component.tsx +58 -0
  242. package/src/queue-table/queue-entry-actions/void-queue-entry-modal.component.tsx +34 -0
  243. package/src/queue-table/queue-table-by-status-menu.component.tsx +42 -0
  244. package/src/queue-table/queue-table-by-status-menu.scss +11 -0
  245. package/src/queue-table/queue-table-by-status-skeleton.component.tsx +32 -0
  246. package/src/queue-table/queue-table-by-status.component.tsx +96 -0
  247. package/src/queue-table/queue-table-expanded-row.component.tsx +29 -0
  248. package/src/queue-table/queue-table-metrics-card.component.tsx +50 -0
  249. package/src/queue-table/queue-table-metrics-card.scss +48 -0
  250. package/src/queue-table/queue-table-metrics.component.tsx +30 -0
  251. package/src/queue-table/queue-table-metrics.scss +11 -0
  252. package/src/queue-table/queue-table.component.tsx +179 -0
  253. package/src/queue-table/queue-table.scss +192 -0
  254. package/src/queue-table/queue-table.test.tsx +210 -0
  255. package/src/remove-queue-entry-dialog/remove-queue-entry.component.tsx +87 -0
  256. package/src/remove-queue-entry-dialog/remove-queue-entry.resource.ts +93 -0
  257. package/src/remove-queue-entry-dialog/remove-queue-entry.scss +7 -0
  258. package/src/remove-queue-entry-dialog/remove-queue-entry.test.tsx +45 -0
  259. package/src/root.component.tsx +28 -0
  260. package/src/root.scss +15 -0
  261. package/src/root.test.tsx +24 -0
  262. package/src/routes.json +133 -0
  263. package/src/side-menu/nav-group/createNavGroup.tsx +17 -0
  264. package/src/side-menu/nav-group/nav-group.component.tsx +24 -0
  265. package/src/side-menu/nav-group/nav-group.test.tsx +32 -0
  266. package/src/side-menu/nav-group/nav-group.ts +10 -0
  267. package/src/side-menu/side-menu.component.tsx +6 -0
  268. package/src/side-menu/side-menu.test.tsx +17 -0
  269. package/src/transition-queue-entry/transition-queue-entry-dialog.component.tsx +134 -0
  270. package/src/transition-queue-entry/transition-queue-entry-dialog.scss +12 -0
  271. package/src/transition-queue-entry/transition-queue-entry-dialog.test.tsx +102 -0
  272. package/src/transition-queue-entry/transition-queue-entry.resource.ts +16 -0
  273. package/src/types/index.ts +494 -0
  274. package/src/views/queue-table-by-status-view.component.tsx +25 -0
  275. package/src/views/queue-tables-for-all-statuses.component.tsx +150 -0
  276. package/src/visits-missing-inqueue/visits-missing-inqueue.component.tsx +277 -0
  277. package/src/visits-missing-inqueue/visits-missing-inqueue.resource.ts +93 -0
  278. package/src/visits-missing-inqueue/visits-missing-inqueue.scss +108 -0
  279. package/translations/am.json +295 -0
  280. package/translations/ar.json +295 -0
  281. package/translations/en.json +305 -0
  282. package/translations/es.json +295 -0
  283. package/translations/fr.json +295 -0
  284. package/translations/he.json +295 -0
  285. package/translations/km.json +295 -0
  286. package/translations/zh.json +295 -0
  287. package/translations/zh_CN.json +295 -0
  288. package/tsconfig.json +5 -0
  289. package/webpack.config.js +1 -0
@@ -0,0 +1,56 @@
1
+ @use '@carbon/styles/scss/spacing';
2
+ @use '@carbon/styles/scss/type';
3
+ @import '~@openmrs/esm-styleguide/src/vars';
4
+
5
+ $overlay-header-height: 5.5rem;
6
+
7
+ .heading {
8
+ @include type.type-style('heading-compact-01');
9
+ margin: spacing.$spacing-05 0 spacing.$spacing-05;
10
+ }
11
+
12
+ .warningContainer {
13
+ background-color: $carbon--red-50;
14
+ padding: spacing.$spacing-04;
15
+ margin: spacing.$spacing-03 0 spacing.$spacing-03;
16
+ display: flex;
17
+ justify-content: space-between;
18
+ .warning {
19
+ @include type.type-style('heading-compact-01');
20
+ color: $ui-05;
21
+ }
22
+ }
23
+
24
+ .form {
25
+ display: flex;
26
+ flex-direction: column;
27
+ justify-content: space-between;
28
+ height: var(--desktop-workspace-window-height);
29
+ }
30
+
31
+ .grid {
32
+ margin: 0 spacing.$spacing-05;
33
+ padding: 0rem;
34
+ }
35
+
36
+ .input {
37
+ margin-top: spacing.$spacing-04;
38
+ }
39
+
40
+ .button {
41
+ height: spacing.$spacing-10;
42
+ display: flex;
43
+ align-content: flex-start;
44
+ align-items: baseline;
45
+ min-width: 50%;
46
+ }
47
+
48
+ .tablet {
49
+ padding: spacing.$spacing-06 spacing.$spacing-05;
50
+ background-color: $ui-02;
51
+ }
52
+
53
+ .desktop {
54
+ padding: 0rem;
55
+ margin-top: spacing.$spacing-05;
56
+ }
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { render, screen } from '@testing-library/react';
4
+ import QueueRoomForm from './queue-room-form.workspace';
5
+
6
+ jest.mock('@openmrs/esm-framework', () => ({
7
+ ...jest.requireActual('@openmrs/esm-framework'),
8
+ useLayoutType: jest.fn(() => 'tablet'),
9
+ useQueueLocations: jest.fn(() => ({
10
+ queueLocations: { uuid: 'e7786d9a-ab62-11ec-b909-0242ac120002', display: 'Location Test' },
11
+ })),
12
+ showSnackbar: jest.fn(),
13
+ }));
14
+
15
+ const workspaceProps = {
16
+ closeWorkspace: jest.fn(),
17
+ promptBeforeClosing: jest.fn(),
18
+ closeWorkspaceWithSavedChanges: jest.fn(),
19
+ };
20
+
21
+ jest.mock('./queue-room.resource', () => ({
22
+ saveQueueRoom: jest.fn(() => Promise.resolve({ status: 201 })),
23
+ }));
24
+
25
+ describe('QueueRoomForm', () => {
26
+ it('renders the form with queue room elements', () => {
27
+ render(<QueueRoomForm {...workspaceProps} />);
28
+
29
+ expect(screen.getByLabelText('Queue room name')).toBeInTheDocument();
30
+ expect(screen.getByLabelText('Select a service')).toBeInTheDocument();
31
+ expect(screen.getByLabelText('Select a queue location')).toBeInTheDocument();
32
+ expect(screen.getByText('Cancel')).toBeInTheDocument();
33
+ expect(screen.getByText('Save')).toBeInTheDocument();
34
+ });
35
+
36
+ it('displays error notification if queue room name is missing on submission', async () => {
37
+ const user = userEvent.setup();
38
+
39
+ render(<QueueRoomForm {...workspaceProps} />);
40
+
41
+ await user.click(screen.getByText('Save'));
42
+
43
+ expect(screen.getByText('Missing queue room name')).toBeInTheDocument();
44
+ });
45
+
46
+ it('displays error notification if queue room service is missing on submission', async () => {
47
+ const user = userEvent.setup();
48
+
49
+ render(<QueueRoomForm {...workspaceProps} />);
50
+
51
+ const queueRoomNameInput = screen.getByLabelText('Queue room name');
52
+
53
+ await user.type(queueRoomNameInput, 'Room 123');
54
+ await user.click(screen.getByText('Save'));
55
+
56
+ expect(screen.getByText('Missing queue room service')).toBeInTheDocument();
57
+ });
58
+
59
+ it('calls closePanel when Cancel button is clicked', async () => {
60
+ const user = userEvent.setup();
61
+
62
+ const closeWorkspace = jest.fn();
63
+ render(<QueueRoomForm {...{ ...workspaceProps, closeWorkspace }} />);
64
+
65
+ await user.click(screen.getByText('Cancel'));
66
+
67
+ expect(closeWorkspace).toHaveBeenCalledTimes(1);
68
+ });
69
+
70
+ it('updates queue room name state when a value is entered', async () => {
71
+ const user = userEvent.setup();
72
+
73
+ render(<QueueRoomForm {...workspaceProps} />);
74
+
75
+ const queueRoomNameInput = screen.getByLabelText('Queue room name');
76
+ await user.type(queueRoomNameInput, 'Room 123');
77
+
78
+ expect(queueRoomNameInput).toHaveValue('Room 123');
79
+ });
80
+ });
@@ -0,0 +1,169 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import {
4
+ Column,
5
+ Form,
6
+ Layer,
7
+ Stack,
8
+ TextInput,
9
+ Select,
10
+ SelectItem,
11
+ ButtonSet,
12
+ Button,
13
+ InlineNotification,
14
+ } from '@carbon/react';
15
+ import { type DefaultWorkspaceProps, restBaseUrl, showSnackbar, useLayoutType } from '@openmrs/esm-framework';
16
+ import { mutate } from 'swr';
17
+ import { useQueueLocations } from '../patient-search/hooks/useQueueLocations';
18
+ import { saveQueueRoom } from './queue-room.resource';
19
+ import styles from './queue-room-form.scss';
20
+ import { useQueues } from '../hooks/useQueues';
21
+
22
+ const QueueRoomForm: React.FC<DefaultWorkspaceProps> = ({ closeWorkspace }) => {
23
+ const { t } = useTranslation();
24
+ const isTablet = useLayoutType() === 'tablet';
25
+ const [queueRoomName, setQueueRoomName] = useState('');
26
+ const [queueRoomService, setQueueRoomService] = useState('');
27
+ const [isMissingRoomName, setMissingRoomName] = useState(false);
28
+ const [isMissingQueueRoomService, setMissingQueueRoomService] = useState(false);
29
+ const [selectedQueueLocation, setSelectedQueueLocation] = useState('');
30
+ const { queues } = useQueues(selectedQueueLocation);
31
+ const { queueLocations } = useQueueLocations();
32
+
33
+ const createQueueRoom = useCallback(
34
+ (event) => {
35
+ event.preventDefault();
36
+
37
+ if (!queueRoomName) {
38
+ setMissingRoomName(true);
39
+ return;
40
+ }
41
+ if (!queueRoomService) {
42
+ setMissingQueueRoomService(true);
43
+ return;
44
+ }
45
+
46
+ setMissingRoomName(false);
47
+ setMissingQueueRoomService(false);
48
+
49
+ saveQueueRoom(queueRoomName, queueRoomName, queueRoomService).then(
50
+ ({ status }) => {
51
+ if (status === 201) {
52
+ showSnackbar({
53
+ title: t('addQueueRoom', 'Add queue room'),
54
+ kind: 'success',
55
+ subtitle: t('queueRoomAddedSuccessfully', 'Queue room added successfully'),
56
+ });
57
+ closeWorkspace();
58
+ mutate(`${restBaseUrl}/queueroom`);
59
+ }
60
+ },
61
+ (error) => {
62
+ showSnackbar({
63
+ title: t('errorAddingQueueRoom', 'Error adding queue room'),
64
+ kind: 'error',
65
+ isLowContrast: false,
66
+ subtitle: error?.message,
67
+ });
68
+ },
69
+ );
70
+ },
71
+ [queueRoomName, queueRoomService, t, closeWorkspace],
72
+ );
73
+
74
+ return (
75
+ <Form onSubmit={createQueueRoom} className={styles.form}>
76
+ <Stack gap={4} className={styles.grid}>
77
+ <Column>
78
+ <Layer className={styles.input}>
79
+ <TextInput
80
+ id="queueRoomName"
81
+ invalidText="Required"
82
+ labelText={t('queueRoomName', 'Queue room name')}
83
+ onChange={(event) => setQueueRoomName(event.target.value)}
84
+ value={queueRoomName}
85
+ />
86
+ {isMissingRoomName && (
87
+ <section>
88
+ <InlineNotification
89
+ style={{ margin: '0', minWidth: '100%' }}
90
+ kind="error"
91
+ lowContrast={true}
92
+ title={t('missingQueueRoomName', 'Missing queue room name')}
93
+ subtitle={t('addQueueRoomName', 'Please add a queue room name')}
94
+ />
95
+ </section>
96
+ )}
97
+ </Layer>
98
+ </Column>
99
+
100
+ <Column>
101
+ <Layer className={styles.input}>
102
+ <section className={styles.section}>
103
+ <Select
104
+ labelText={t('selectQueueLocation', 'Select a queue location')}
105
+ id="location"
106
+ invalidText="Required"
107
+ value={selectedQueueLocation}
108
+ onChange={(event) => {
109
+ setSelectedQueueLocation(event.target.value);
110
+ }}>
111
+ {!selectedQueueLocation ? (
112
+ <SelectItem text={t('selectQueueLocation', 'Select a queue location')} value="" />
113
+ ) : null}
114
+ {queueLocations?.length > 0 &&
115
+ queueLocations.map((location) => (
116
+ <SelectItem key={location.id} text={location.name} value={location.id}>
117
+ {location.name}
118
+ </SelectItem>
119
+ ))}
120
+ </Select>
121
+ </section>
122
+ </Layer>
123
+ </Column>
124
+
125
+ <Column>
126
+ <Layer className={styles.input}>
127
+ <section className={styles.section}>
128
+ <Select
129
+ labelText={t('selectService', 'Select a service')}
130
+ id="service"
131
+ invalidText="Required"
132
+ value={queueRoomService}
133
+ onChange={(event) => setQueueRoomService(event.target.value)}>
134
+ {!queueRoomService ? <SelectItem text={t('selectService', 'Select a service')} value="" /> : null}
135
+ {queues?.length > 0 &&
136
+ queues.map((service) => (
137
+ <SelectItem key={service.uuid} text={service.display} value={service.uuid}>
138
+ {service.display}
139
+ </SelectItem>
140
+ ))}
141
+ </Select>
142
+ </section>
143
+ {isMissingQueueRoomService && (
144
+ <section>
145
+ <InlineNotification
146
+ style={{ margin: '0', minWidth: '100%' }}
147
+ kind="error"
148
+ lowContrast={true}
149
+ title={t('missingQueueRoomService', 'Missing queue room service')}
150
+ subtitle={t('addQueueRoomService', 'Please add a queue room service')}
151
+ />
152
+ </section>
153
+ )}
154
+ </Layer>
155
+ </Column>
156
+ </Stack>
157
+ <ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
158
+ <Button className={styles.button} kind="secondary" onClick={() => closeWorkspace()}>
159
+ {t('cancel', 'Cancel')}
160
+ </Button>
161
+ <Button className={styles.button} kind="primary" type="submit">
162
+ {t('save', 'Save')}
163
+ </Button>
164
+ </ButtonSet>
165
+ </Form>
166
+ );
167
+ };
168
+
169
+ export default QueueRoomForm;
@@ -0,0 +1,20 @@
1
+ import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
2
+
3
+ export function saveQueueRoom(name: string, description: string, queueUuid: string) {
4
+ const abortController = new AbortController();
5
+
6
+ return openmrsFetch(`${restBaseUrl}/queue-room`, {
7
+ method: 'POST',
8
+ headers: {
9
+ 'Content-Type': 'application/json',
10
+ },
11
+ signal: abortController.signal,
12
+ body: {
13
+ name: name,
14
+ description: description,
15
+ queue: {
16
+ uuid: queueUuid,
17
+ },
18
+ },
19
+ });
20
+ }
@@ -0,0 +1,47 @@
1
+ import React from 'react';
2
+ import { DataTableSkeleton } from '@carbon/react';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { useActiveTickets } from './useActiveTickets';
5
+ import PatientQueueHeader from '../patient-queue-header/patient-queue-header.component';
6
+ import styles from './queue-screen.scss';
7
+
8
+ interface QueueScreenProps {}
9
+
10
+ const QueueScreen: React.FC<QueueScreenProps> = () => {
11
+ const { t } = useTranslation();
12
+ const { activeTickets, isLoading, error } = useActiveTickets();
13
+
14
+ if (isLoading) {
15
+ return <DataTableSkeleton row={5} className={styles.queueScreen} role="progressbar" />;
16
+ }
17
+
18
+ if (error) {
19
+ return <div>Error</div>;
20
+ }
21
+
22
+ const rowData = activeTickets.map((ticket, index) => ({
23
+ id: `${index}}`,
24
+ room: ticket.room,
25
+ ticketNumber: ticket.ticketNumber,
26
+ status: ticket.status,
27
+ }));
28
+
29
+ return (
30
+ <div>
31
+ <PatientQueueHeader title={t('queueScreen', 'Queue screen')} />
32
+ <div className={styles.gridFlow}>
33
+ {rowData.map((row) => (
34
+ <div className={styles.card} key={row.id}>
35
+ <p className={styles.subHeader}>{t('ticketNumber', 'Ticket number')}</p>
36
+ <p className={row.status === 'calling' ? styles.headerBlinking : styles.header}>{row.ticketNumber}</p>
37
+ <p className={styles.subHeader}>
38
+ {t('room', 'Room')} &nbsp; : &nbsp; {row.room}
39
+ </p>
40
+ </div>
41
+ ))}
42
+ </div>
43
+ </div>
44
+ );
45
+ };
46
+
47
+ export default QueueScreen;
@@ -0,0 +1,39 @@
1
+ .gridFlow {
2
+ display: flex;
3
+ flex-direction: row;
4
+ padding: 2rem;
5
+ flex-wrap: wrap;
6
+ }
7
+
8
+ .card {
9
+ border-radius: 0.9rem;
10
+ border: 1px solid #343332;
11
+ margin: 1.5rem;
12
+ padding: 1.3rem;
13
+ width: 30%;
14
+ text-align: center;
15
+ justify-content: center;
16
+ }
17
+
18
+ .header {
19
+ font-size: 2rem;
20
+ font-weight: bold;
21
+ color: black;
22
+ }
23
+
24
+ .headerBlinking {
25
+ font-size: 2rem;
26
+ font-weight: bold;
27
+ color: red;
28
+ animation: blinker 1s linear infinite;
29
+ }
30
+
31
+ @keyframes blinker {
32
+ 50% {
33
+ opacity: 0;
34
+ }
35
+ }
36
+
37
+ .subheader {
38
+ font-size: medium;
39
+ }
@@ -0,0 +1,51 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import { useActiveTickets } from './useActiveTickets';
4
+ import QueueScreen from './queue-screen.component';
5
+
6
+ jest.mock('./useActiveTickets');
7
+ jest.mock('../helpers/helpers', () => ({
8
+ useSelectedQueueLocationName: jest.fn().mockReturnValue('Room A'),
9
+ useSelectedQueueLocationUuid: jest.fn().mockReturnValue(''),
10
+ }));
11
+
12
+ describe('QueueScreen component', () => {
13
+ test('renders loading skeleton when data is loading', () => {
14
+ const mockedUseActiveTickets = useActiveTickets as jest.MockedFunction<typeof useActiveTickets>;
15
+ mockedUseActiveTickets.mockReturnValue({ isLoading: true, activeTickets: [], error: undefined, mutate: jest.fn() });
16
+ render(<QueueScreen />);
17
+ expect(screen.getByRole('progressbar')).toBeInTheDocument();
18
+ });
19
+
20
+ test('renders error message when there is an error fetching data', () => {
21
+ const mockedUseActiveTickets = useActiveTickets as jest.MockedFunction<typeof useActiveTickets>;
22
+ mockedUseActiveTickets.mockReturnValue({
23
+ error: new Error('Error'),
24
+ isLoading: false,
25
+ activeTickets: [],
26
+ mutate: jest.fn(),
27
+ });
28
+ render(<QueueScreen />);
29
+ expect(screen.getByText('Error')).toBeInTheDocument();
30
+ });
31
+
32
+ test('renders table with active tickets when data is loaded', () => {
33
+ const mockedUseActiveTickets = useActiveTickets as jest.MockedFunction<typeof useActiveTickets>;
34
+ mockedUseActiveTickets.mockReturnValue({
35
+ activeTickets: [
36
+ {
37
+ room: 'Room A',
38
+ ticketNumber: '123',
39
+ status: 'Pending',
40
+ },
41
+ ],
42
+ isLoading: false,
43
+ error: undefined,
44
+ mutate: jest.fn(),
45
+ });
46
+ render(<QueueScreen />);
47
+ expect(screen.getByText('Room : Room A')).toBeInTheDocument();
48
+ expect(screen.getByText('Ticket number')).toBeInTheDocument();
49
+ expect(screen.getByText('123')).toBeInTheDocument();
50
+ });
51
+ });
@@ -0,0 +1,13 @@
1
+ import { openmrsFetch, restBaseUrl } from '@openmrs/esm-framework';
2
+ import useSWR from 'swr';
3
+
4
+ export const useActiveTickets = () => {
5
+ const { data, isLoading, error, mutate } = useSWR<{ data: Record<string, { status: string; ticketNumber: string }> }>(
6
+ `${restBaseUrl}/queueutil/active-tickets`,
7
+ openmrsFetch,
8
+ { refreshInterval: 3000 },
9
+ );
10
+ const activeTickets =
11
+ Array.from(Object.entries(data?.data ?? {}).map(([key, value]) => ({ room: key, ...value }))) ?? [];
12
+ return { activeTickets, isLoading, error, mutate };
13
+ };
@@ -0,0 +1,61 @@
1
+ @use '@carbon/styles/scss/spacing';
2
+ @use '@carbon/styles/scss/type';
3
+ @import '~@openmrs/esm-styleguide/src/vars';
4
+
5
+ .heading {
6
+ @include type.type-style('heading-compact-01');
7
+ margin: spacing.$spacing-05 0 spacing.$spacing-05;
8
+ }
9
+
10
+ .warningContainer {
11
+ background-color: $carbon--red-50;
12
+ padding: spacing.$spacing-04;
13
+ margin: spacing.$spacing-03 0 spacing.$spacing-03;
14
+ display: flex;
15
+ justify-content: space-between;
16
+ .warning {
17
+ @include type.type-style('heading-compact-01');
18
+ color: $ui-05;
19
+ }
20
+ }
21
+
22
+ .form {
23
+ display: flex;
24
+ flex-direction: column;
25
+ justify-content: space-between;
26
+ height: var(--desktop-workspace-window-height);
27
+ }
28
+
29
+ .grid {
30
+ margin: 0 spacing.$spacing-05;
31
+ padding: 0rem;
32
+ }
33
+
34
+ .input {
35
+ margin-top: spacing.$spacing-04;
36
+ }
37
+
38
+ .button {
39
+ height: spacing.$spacing-10;
40
+ display: flex;
41
+ align-content: flex-start;
42
+ align-items: baseline;
43
+ min-width: 50%;
44
+ }
45
+
46
+ .buttonSet {
47
+ padding: 0rem;
48
+ margin-top: spacing.$spacing-05;
49
+ }
50
+
51
+ /* Tablet */
52
+ :global(.omrs-breakpoint-lt-desktop) {
53
+ .form {
54
+ height: var(--tablet-workspace-window-height);
55
+ }
56
+
57
+ .buttonSet {
58
+ padding: spacing.$spacing-06 spacing.$spacing-05;
59
+ background-color: $ui-02;
60
+ }
61
+ }
@@ -0,0 +1,60 @@
1
+ import React from 'react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { render, screen } from '@testing-library/react';
4
+ import QueueServiceForm from './queue-service-form.workspace';
5
+
6
+ jest.mock('@openmrs/esm-framework', () => ({
7
+ useLayoutType: () => 'desktop',
8
+ showSnackbar: jest.fn(),
9
+ }));
10
+
11
+ jest.mock('./queue-service.resource', () => ({
12
+ useServiceConcepts: () => ({
13
+ queueConcepts: [
14
+ { uuid: '6f017eb0-b035-4acd-b284-da45f5067502', display: 'Concept 1' },
15
+ { uuid: '5f017eb0-b035-4acd-b284-da45f5067502', display: 'Concept 2' },
16
+ ],
17
+ }),
18
+ saveQueue: jest.fn(() => Promise.resolve({ status: 201 })),
19
+ }));
20
+
21
+ jest.mock('../patient-search/hooks/useQueueLocations', () => ({
22
+ useQueueLocations: () => ({
23
+ queueLocations: [
24
+ { id: '34567eb0-b035-4acd-b284-da45f5067502', name: 'Location 1' },
25
+ { id: '12wi7eb0-b035-4acd-b284-da45f5067502', name: 'Location 2' },
26
+ ],
27
+ }),
28
+ }));
29
+
30
+ describe('QueueServiceForm', () => {
31
+ it('should display required error messages when form is submitted with missing fields', async () => {
32
+ const user = userEvent.setup();
33
+
34
+ render(<QueueServiceForm toggleSearchType={() => {}} closePanel={() => {}} />);
35
+
36
+ const submitButton = screen.getByText('Save');
37
+
38
+ await user.click(submitButton);
39
+
40
+ expect(screen.getByText('Missing queue name')).toBeInTheDocument();
41
+ });
42
+
43
+ it('should submit the form when all fields are filled', async () => {
44
+ const user = userEvent.setup();
45
+
46
+ render(<QueueServiceForm toggleSearchType={() => {}} closePanel={() => {}} />);
47
+
48
+ const queueNameInput = screen.getByLabelText('Queue name');
49
+ const serviceSelect = screen.getByLabelText('Select a service type');
50
+ const locationSelect = screen.getByLabelText('Select a location');
51
+
52
+ await user.type(queueNameInput, 'Test Queue');
53
+ await user.selectOptions(serviceSelect, '6f017eb0-b035-4acd-b284-da45f5067502');
54
+ await user.selectOptions(locationSelect, '34567eb0-b035-4acd-b284-da45f5067502');
55
+
56
+ expect(queueNameInput).toHaveValue('Test Queue');
57
+ expect(serviceSelect).toHaveValue('6f017eb0-b035-4acd-b284-da45f5067502');
58
+ expect(locationSelect).toHaveValue('34567eb0-b035-4acd-b284-da45f5067502');
59
+ });
60
+ });