@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,168 @@
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 { showNotification, showToast, useLayoutType } from '@openmrs/esm-framework';
16
+ import styles from './queue-room.scss';
17
+ import { SearchTypes } from '../types';
18
+ import { mutate } from 'swr';
19
+ import { useQueueLocations } from '../patient-search/hooks/useQueueLocations';
20
+ import { useServices } from '../active-visits/active-visits-table.resource';
21
+ import { saveQueueRoom } from './queue-room.resource';
22
+
23
+ interface QueueRoomFormProps {
24
+ toggleSearchType: (searchMode: SearchTypes) => void;
25
+ closePanel: () => void;
26
+ }
27
+
28
+ const QueueRoomForm: React.FC<QueueRoomFormProps> = ({ toggleSearchType, closePanel }) => {
29
+ const { t } = useTranslation();
30
+ const isTablet = useLayoutType() === 'tablet';
31
+ const [queueRoomName, setQueueRoomName] = useState('');
32
+ const [queueRoomService, setQueueRoomService] = useState('');
33
+ const [isMissingRoomName, setMissingRoomName] = useState(false);
34
+ const [isMissingQueueRoomService, setMissingQueueRoomService] = useState(false);
35
+ const [selectedQueueLocation, setSelectedQueueLocation] = useState('');
36
+ const { services } = useServices(selectedQueueLocation);
37
+ const { queueLocations } = useQueueLocations();
38
+
39
+ const createQueueRoom = useCallback(
40
+ (event) => {
41
+ event.preventDefault();
42
+
43
+ if (!queueRoomName) {
44
+ setMissingRoomName(true);
45
+ return;
46
+ }
47
+ if (!queueRoomService) {
48
+ setMissingQueueRoomService(true);
49
+ return;
50
+ }
51
+
52
+ setMissingRoomName(false);
53
+ setMissingQueueRoomService(false);
54
+
55
+ saveQueueRoom(queueRoomName, queueRoomName, queueRoomService).then(
56
+ ({ status }) => {
57
+ if (status === 201) {
58
+ showToast({
59
+ title: t('addQueueRoom', 'Add queue room'),
60
+ kind: 'success',
61
+ description: t('queueRoomAddedSuccessfully', 'Queue room addeded successfully'),
62
+ });
63
+ closePanel();
64
+ mutate(`/ws/rest/v1/queueroom`);
65
+ }
66
+ },
67
+ (error) => {
68
+ showNotification({
69
+ title: t('errorAddingQueueRoom', 'Error adding queue room'),
70
+ kind: 'error',
71
+ critical: true,
72
+ description: error?.message,
73
+ });
74
+ },
75
+ );
76
+ },
77
+ [queueRoomName, queueRoomService, t, closePanel],
78
+ );
79
+
80
+ return (
81
+ <Form onSubmit={createQueueRoom} className={styles.form}>
82
+ <Stack gap={4} className={styles.grid}>
83
+ <Column>
84
+ <h3 className={styles.heading}>{t('addNewQueueRoom', 'Add new queue room')}</h3>
85
+ <Layer className={styles.input}>
86
+ <TextInput
87
+ id="queueRoomName"
88
+ invalidText="Required"
89
+ labelText={t('queueRoomName', 'Queue room name')}
90
+ onChange={(event) => setQueueRoomName(event.target.value)}
91
+ value={queueRoomName}
92
+ />
93
+ {isMissingRoomName && (
94
+ <section>
95
+ <InlineNotification
96
+ style={{ margin: '0', minWidth: '100%' }}
97
+ kind="error"
98
+ lowContrast={true}
99
+ title={t('missingQueueRoomName', 'Missing queue room name')}
100
+ subtitle={t('addQueueRoomName', 'Please add a queue room name')}
101
+ />
102
+ </section>
103
+ )}
104
+ </Layer>
105
+
106
+ <section className={styles.section}>
107
+ <Select
108
+ labelText={t('selectQueueLocation', 'Select a queue location')}
109
+ id="location"
110
+ invalidText="Required"
111
+ value={selectedQueueLocation}
112
+ onChange={(event) => {
113
+ setSelectedQueueLocation(event.target.value);
114
+ }}>
115
+ {!selectedQueueLocation ? (
116
+ <SelectItem text={t('selectQueueLocation', 'Select a queue location')} value="" />
117
+ ) : null}
118
+ {queueLocations?.length > 0 &&
119
+ queueLocations.map((location) => (
120
+ <SelectItem key={location.id} text={location.name} value={location.id}>
121
+ {location.name}
122
+ </SelectItem>
123
+ ))}
124
+ </Select>
125
+ </section>
126
+
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
+ {services?.length > 0 &&
136
+ services.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
+ </Column>
155
+ </Stack>
156
+ <ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
157
+ <Button className={styles.button} kind="secondary" onClick={() => closePanel()}>
158
+ {t('cancel', 'Cancel')}
159
+ </Button>
160
+ <Button className={styles.button} kind="primary" type="submit">
161
+ {t('save', 'Save')}
162
+ </Button>
163
+ </ButtonSet>
164
+ </Form>
165
+ );
166
+ };
167
+
168
+ export default QueueRoomForm;
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import { render, screen, fireEvent } from '@testing-library/react';
3
+ import QueueRoomForm from './queue-room-form.component';
4
+ import { mockServices } from '../../__mocks__/active-visits.mock';
5
+
6
+ jest.mock('@openmrs/esm-framework', () => ({
7
+ ...jest.requireActual('@openmrs/esm-framework'),
8
+ useLayoutType: jest.fn(() => 'tablet'),
9
+ useServices: jest.fn(() => ({ services: mockServices })),
10
+ useQueueLocations: jest.fn(() => ({
11
+ queueLocations: { uuid: 'e7786d9a-ab62-11ec-b909-0242ac120002', display: 'Location Test' },
12
+ })),
13
+ showToast: jest.fn(),
14
+ }));
15
+
16
+ jest.mock('./queue-room.resource', () => ({
17
+ saveQueueRoom: jest.fn(() => Promise.resolve({ status: 201 })),
18
+ }));
19
+
20
+ describe('QueueRoomForm', () => {
21
+ it('renders the form with queue room elements', () => {
22
+ render(<QueueRoomForm toggleSearchType={jest.fn()} closePanel={jest.fn()} />);
23
+
24
+ expect(screen.getByLabelText('Queue room name')).toBeInTheDocument();
25
+ expect(screen.getByLabelText('Select a service')).toBeInTheDocument();
26
+ expect(screen.getByLabelText('Select a queue location')).toBeInTheDocument();
27
+ expect(screen.getByText('Cancel')).toBeInTheDocument();
28
+ expect(screen.getByText('Save')).toBeInTheDocument();
29
+ });
30
+
31
+ it('displays error notification if queue room name is missing on submission', () => {
32
+ render(<QueueRoomForm toggleSearchType={jest.fn()} closePanel={jest.fn()} />);
33
+
34
+ fireEvent.click(screen.getByText('Save'));
35
+
36
+ expect(screen.getByText('Missing queue room name')).toBeInTheDocument();
37
+ });
38
+
39
+ it('displays error notification if queue room service is missing on submission', () => {
40
+ render(<QueueRoomForm toggleSearchType={jest.fn()} closePanel={jest.fn()} />);
41
+
42
+ fireEvent.change(screen.getByLabelText('Queue room name'), { target: { value: 'Room 123' } });
43
+ fireEvent.click(screen.getByText('Save'));
44
+
45
+ expect(screen.getByText('Missing queue room service')).toBeInTheDocument();
46
+ });
47
+
48
+ it('calls closePanel when Cancel button is clicked', () => {
49
+ const closePanelMock = jest.fn();
50
+ render(<QueueRoomForm toggleSearchType={jest.fn()} closePanel={closePanelMock} />);
51
+
52
+ fireEvent.click(screen.getByText('Cancel'));
53
+
54
+ expect(closePanelMock).toHaveBeenCalledTimes(1);
55
+ });
56
+
57
+ it('updates queue room name state when a value is entered', () => {
58
+ render(<QueueRoomForm toggleSearchType={jest.fn()} closePanel={jest.fn()} />);
59
+
60
+ const queueRoomNameInput = screen.getByLabelText('Queue room name');
61
+ fireEvent.change(queueRoomNameInput, { target: { value: 'Room 123' } });
62
+
63
+ expect(queueRoomNameInput).toHaveValue('Room 123');
64
+ });
65
+ });
@@ -0,0 +1,20 @@
1
+ import { openmrsFetch } from '@openmrs/esm-framework';
2
+
3
+ export function saveQueueRoom(name: string, description: string, queueUuid: string) {
4
+ const abortController = new AbortController();
5
+
6
+ return openmrsFetch(`/ws/rest/v1/queueroom`, {
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,58 @@
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('productive-heading-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: calc(100vh - 6rem);
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
+ .tablet {
47
+ padding: spacing.$spacing-06 spacing.$spacing-05;
48
+ background-color: $ui-02;
49
+ }
50
+
51
+ .desktop {
52
+ padding: 0rem;
53
+ margin-top: spacing.$spacing-05;
54
+ }
55
+
56
+ .section {
57
+ margin: spacing.$spacing-03;
58
+ }
@@ -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 />
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,47 @@
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
+
8
+ describe('QueueScreen component', () => {
9
+ test('renders loading skeleton when data is loading', () => {
10
+ const mockedUseActiveTickets = useActiveTickets as jest.MockedFunction<typeof useActiveTickets>;
11
+ mockedUseActiveTickets.mockReturnValue({ isLoading: true, activeTickets: [], error: undefined, mutate: jest.fn() });
12
+ render(<QueueScreen />);
13
+ expect(screen.getByRole('progressbar')).toBeInTheDocument();
14
+ });
15
+
16
+ test('renders error message when there is an error fetching data', () => {
17
+ const mockedUseActiveTickets = useActiveTickets as jest.MockedFunction<typeof useActiveTickets>;
18
+ mockedUseActiveTickets.mockReturnValue({
19
+ error: new Error('Error'),
20
+ isLoading: false,
21
+ activeTickets: [],
22
+ mutate: jest.fn(),
23
+ });
24
+ render(<QueueScreen />);
25
+ expect(screen.getByText('Error')).toBeInTheDocument();
26
+ });
27
+
28
+ test('renders table with active tickets when data is loaded', () => {
29
+ const mockedUseActiveTickets = useActiveTickets as jest.MockedFunction<typeof useActiveTickets>;
30
+ mockedUseActiveTickets.mockReturnValue({
31
+ activeTickets: [
32
+ {
33
+ room: 'Room A',
34
+ ticketNumber: '123',
35
+ status: 'Pending',
36
+ },
37
+ ],
38
+ isLoading: false,
39
+ error: undefined,
40
+ mutate: jest.fn(),
41
+ });
42
+ render(<QueueScreen />);
43
+ expect(screen.getByText('Room : Room A')).toBeInTheDocument();
44
+ expect(screen.getByText('Ticket number')).toBeInTheDocument();
45
+ expect(screen.getByText('123')).toBeInTheDocument();
46
+ });
47
+ });
@@ -0,0 +1,13 @@
1
+ import { openmrsFetch } 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
+ '/ws/rest/v1/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,183 @@
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 { showNotification, showToast, useLayoutType } from '@openmrs/esm-framework';
16
+ import styles from './queue-service.scss';
17
+ import { saveQueue, useServiceConcepts } from './queue-service.resource';
18
+ import { SearchTypes } from '../types';
19
+ import { mutate } from 'swr';
20
+ import { useQueueLocations } from '../patient-search/hooks/useQueueLocations';
21
+
22
+ interface QueueServiceFormProps {
23
+ toggleSearchType: (searchMode: SearchTypes) => void;
24
+ closePanel: () => void;
25
+ }
26
+
27
+ const QueueServiceForm: React.FC<QueueServiceFormProps> = ({ toggleSearchType, closePanel }) => {
28
+ const { t } = useTranslation();
29
+ const isTablet = useLayoutType() === 'tablet';
30
+ const { queueConcepts } = useServiceConcepts();
31
+ const [queueName, setQueueName] = useState('');
32
+ const [queueConcept, setQueueConcept] = useState('');
33
+ const [isMissingName, setMissingName] = useState(false);
34
+ const [isMissingQueue, setMissingQueue] = useState(false);
35
+ const [isMissingLocation, setMissingLocation] = useState(false);
36
+ const [userLocation, setUserLocation] = useState('');
37
+ const { queueLocations } = useQueueLocations();
38
+
39
+ const createQueue = useCallback(
40
+ (event) => {
41
+ event.preventDefault();
42
+
43
+ if (!queueName) {
44
+ setMissingName(true);
45
+ return;
46
+ }
47
+ if (!queueConcept) {
48
+ setMissingQueue(true);
49
+ return;
50
+ }
51
+ if (!userLocation) {
52
+ setMissingLocation(true);
53
+ return;
54
+ }
55
+
56
+ setMissingName(false);
57
+ setMissingQueue(false);
58
+ setMissingLocation(false);
59
+
60
+ saveQueue(queueName, queueConcept, queueName, userLocation).then(
61
+ ({ status }) => {
62
+ if (status === 201) {
63
+ showToast({
64
+ title: t('addQueue', 'Add queue'),
65
+ kind: 'success',
66
+ description: t('queueAddedSuccessfully', 'Queue addeded successfully'),
67
+ });
68
+ closePanel();
69
+ mutate(`/ws/rest/v1/queue?${userLocation}`);
70
+ mutate(`/ws/rest/v1/queue?location=${userLocation}`);
71
+ }
72
+ },
73
+ (error) => {
74
+ showNotification({
75
+ title: t('errorAddingQueue', 'Error adding queue'),
76
+ kind: 'error',
77
+ critical: true,
78
+ description: error?.message,
79
+ });
80
+ },
81
+ );
82
+ },
83
+ [queueName, queueConcept, userLocation, t, closePanel],
84
+ );
85
+
86
+ return (
87
+ <Form onSubmit={createQueue} className={styles.form}>
88
+ <Stack gap={4} className={styles.grid}>
89
+ <Column>
90
+ <h3 className={styles.heading}>{t('addNewQueue', 'Add new queue')}</h3>
91
+ <Layer className={styles.input}>
92
+ <TextInput
93
+ id="queueName"
94
+ invalidText="Required"
95
+ labelText={t('queueName', 'Queue name')}
96
+ onChange={(event) => setQueueName(event.target.value)}
97
+ value={queueName}
98
+ />
99
+ {isMissingName && (
100
+ <section>
101
+ <InlineNotification
102
+ style={{ margin: '0', minWidth: '100%' }}
103
+ kind="error"
104
+ lowContrast={true}
105
+ title={t('missingQueueName', 'Missing queue name')}
106
+ subtitle={t('addQueueName', 'Please add a queue name')}
107
+ />
108
+ </section>
109
+ )}
110
+ </Layer>
111
+
112
+ <Layer className={styles.input}>
113
+ <Select
114
+ labelText={t('selectServiceType', 'Select a service type')}
115
+ id="queueConcept"
116
+ invalidText="Required"
117
+ value={queueConcept}
118
+ onChange={(event) => setQueueConcept(event.target.value)}>
119
+ {!queueConcept && <SelectItem text={t('selectServiceType', 'Select a service type')} />}
120
+ {queueConcepts.length === 0 && <SelectItem text={t('noServicesAvailable', 'No services available')} />}
121
+ {queueConcepts?.length > 0 &&
122
+ queueConcepts.map((concept) => (
123
+ <SelectItem key={concept.uuid} text={concept.display} value={concept.uuid}>
124
+ {concept.display}
125
+ </SelectItem>
126
+ ))}
127
+ </Select>
128
+ {isMissingQueue && (
129
+ <section>
130
+ <InlineNotification
131
+ style={{ margin: '0', minWidth: '100%' }}
132
+ kind="error"
133
+ lowContrast={true}
134
+ title={t('missingService', 'Missing service')}
135
+ subtitle={t('selectServiceType', 'Select a service type')}
136
+ />
137
+ </section>
138
+ )}
139
+ </Layer>
140
+
141
+ <Layer className={styles.input}>
142
+ <Select
143
+ labelText={t('selectLocation', 'Select a location')}
144
+ id="location"
145
+ invalidText="Required"
146
+ value={userLocation}
147
+ onChange={(event) => setUserLocation(event.target.value)}>
148
+ {!userLocation && <SelectItem text={t('selectLocation', 'Select a location')} />}
149
+ {queueLocations.length === 0 && <SelectItem text={t('noLocationsAvailable', 'No locations available')} />}
150
+ {queueLocations?.length > 0 &&
151
+ queueLocations.map((location) => (
152
+ <SelectItem key={location.id} text={location.name} value={location.id}>
153
+ {location.name}
154
+ </SelectItem>
155
+ ))}
156
+ </Select>
157
+ {isMissingLocation && (
158
+ <section>
159
+ <InlineNotification
160
+ style={{ margin: '0', minWidth: '100%' }}
161
+ kind="error"
162
+ lowContrast={true}
163
+ title={t('missingLocation', 'Missing location')}
164
+ subtitle={t('selectLocation', 'Please select a location')}
165
+ />
166
+ </section>
167
+ )}
168
+ </Layer>
169
+ </Column>
170
+ </Stack>
171
+ <ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
172
+ <Button className={styles.button} kind="secondary" onClick={() => closePanel()}>
173
+ {t('cancel', 'Cancel')}
174
+ </Button>
175
+ <Button className={styles.button} kind="primary" type="submit">
176
+ {t('save', 'Save')}
177
+ </Button>
178
+ </ButtonSet>
179
+ </Form>
180
+ );
181
+ };
182
+
183
+ export default QueueServiceForm;