@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,230 @@
1
+ import React, { useMemo, useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import {
4
+ Button,
5
+ DataTable,
6
+ DataTableHeader,
7
+ Layer,
8
+ Table,
9
+ TableBody,
10
+ TableCell,
11
+ TableContainer,
12
+ TableHead,
13
+ TableHeader,
14
+ TableRow,
15
+ TableToolbar,
16
+ TableToolbarContent,
17
+ TableToolbarSearch,
18
+ Tag,
19
+ Tile,
20
+ DataTableSkeleton,
21
+ Pagination,
22
+ } from '@carbon/react';
23
+ import { Filter, OverflowMenuVertical } from '@carbon/react/icons';
24
+ import { ConfigurableLink, ExtensionSlot, formatDatetime, parseDate, usePagination } from '@openmrs/esm-framework';
25
+ import styles from './queue-linelist-base-table.scss';
26
+ import { FilterTypes } from '../types';
27
+ import QueueLinelist from './queue-linelist.component';
28
+ import { getGender } from '../helpers/functions';
29
+
30
+ type FilterProps = {
31
+ rowIds: Array<string>;
32
+ headers: Array<DataTableHeader>;
33
+ cellsById: any;
34
+ inputValue: string;
35
+ getCellId: (row, key) => string;
36
+ };
37
+
38
+ interface QueuePatientTableProps {
39
+ title: string;
40
+ patientData: Array<any>;
41
+ headers: Array<any>;
42
+ serviceType: string;
43
+ isLoading: boolean;
44
+ toggleFilter?: (filterMode: FilterTypes) => void;
45
+ }
46
+
47
+ const QueuePatientBaseTable: React.FC<QueuePatientTableProps> = ({
48
+ title,
49
+ patientData,
50
+ headers,
51
+ serviceType,
52
+ isLoading,
53
+ }) => {
54
+ const { t } = useTranslation();
55
+ const [showOverlay, setShowOverlay] = useState(false);
56
+ const { results, currentPage, goTo } = usePagination(patientData ?? [], 100);
57
+
58
+ const handleFilter = ({ rowIds, headers, cellsById, inputValue, getCellId }: FilterProps): Array<string> => {
59
+ return rowIds.filter((rowId) =>
60
+ headers.some(({ key }) => {
61
+ const cellId = getCellId(rowId, key);
62
+ const filterableValue = cellsById[cellId].value;
63
+ const filterTerm = inputValue.toLowerCase();
64
+
65
+ if (typeof filterableValue === 'boolean') {
66
+ return false;
67
+ }
68
+ if (filterableValue.hasOwnProperty('content')) {
69
+ if (Array.isArray(filterableValue.content.props.children)) {
70
+ return ('' + filterableValue.content.props.children[1].props.children).toLowerCase().includes(filterTerm);
71
+ }
72
+ if (typeof filterableValue.content.props.children === 'object') {
73
+ return ('' + filterableValue.content.props.children.props.children.props.children)
74
+ .toLowerCase()
75
+ .includes(filterTerm);
76
+ }
77
+ return ('' + filterableValue.content.props.children).toLowerCase().includes(filterTerm);
78
+ }
79
+ return ('' + filterableValue).toLowerCase().includes(filterTerm);
80
+ }),
81
+ );
82
+ };
83
+
84
+ const pageSizes = useMemo(() => {
85
+ const numberOfPages = Math.ceil(patientData?.length / 100);
86
+ return [...Array(numberOfPages).keys()].map((x) => {
87
+ return (x + 1) * 100;
88
+ });
89
+ }, [patientData]);
90
+
91
+ const tableRows = useMemo(
92
+ () =>
93
+ results?.map((entry) => {
94
+ return {
95
+ id: entry.id,
96
+ name: {
97
+ content: (
98
+ <ConfigurableLink to={`\${openmrsSpaBase}/patient/${entry.patientUuid}/chart`}>
99
+ {entry.name}
100
+ </ConfigurableLink>
101
+ ),
102
+ },
103
+ returnDate: formatDatetime(parseDate(entry.returnDate), { mode: 'wide' }),
104
+ gender: getGender(entry.gender, t),
105
+ age: entry.age,
106
+ visitType: entry.visitType,
107
+ phoneNumber: entry.phoneNumber,
108
+ };
109
+ }),
110
+ [results, t],
111
+ );
112
+
113
+ if (isLoading) {
114
+ return <DataTableSkeleton role="progressbar" />;
115
+ }
116
+
117
+ return (
118
+ <div className={styles.container}>
119
+ <ExtensionSlot name="breadcrumbs-slot" />
120
+
121
+ <div className={styles.headerContainer}>
122
+ <div>
123
+ <p className={styles.title}>
124
+ {title} {serviceType}
125
+ </p>
126
+ <p className={styles.subTitle}>
127
+ {patientData?.length} · Last Updated: {formatDatetime(new Date(), { mode: 'standard' })}
128
+ </p>
129
+ </div>
130
+
131
+ <Button kind="ghost" size="sm" renderIcon={(props) => <OverflowMenuVertical size={16} {...props} />}>
132
+ {t('actions', 'Actions')}
133
+ </Button>
134
+ </div>
135
+
136
+ <Layer>
137
+ <Tile className={styles.filterTile}>
138
+ <Tag size="md" title="Clear Filter" type="blue">
139
+ {t('today', 'Today')}
140
+ </Tag>
141
+
142
+ <div className={styles.actionsBtn}>
143
+ <Button
144
+ kind="ghost"
145
+ renderIcon={(props) => <Filter size={16} {...props} />}
146
+ iconDescription={t('filter', 'Filter (1)')}
147
+ onClick={() => setShowOverlay(true)}
148
+ size="sm">
149
+ {t('filter', 'Filter (1)')}
150
+ </Button>
151
+ </div>
152
+ </Tile>
153
+ </Layer>
154
+
155
+ <DataTable
156
+ data-floating-menu-container
157
+ filterRows={handleFilter}
158
+ headers={headers}
159
+ overflowMenuOnHover={false}
160
+ rows={tableRows}
161
+ size="md"
162
+ useZebraStyles>
163
+ {({ rows, headers, getHeaderProps, getTableProps, getRowProps, onInputChange }) => (
164
+ <TableContainer className={styles.tableContainer}>
165
+ <TableToolbar style={{ position: 'static', height: '3rem', overflow: 'visible', backgroundColor: 'color' }}>
166
+ <TableToolbarContent className={styles.toolbarContent}>
167
+ <TableToolbarSearch
168
+ className={styles.search}
169
+ expanded
170
+ onChange={onInputChange}
171
+ placeholder={t('searchThisList', 'Search this list')}
172
+ size="sm"
173
+ />
174
+ </TableToolbarContent>
175
+ </TableToolbar>
176
+ <Table {...getTableProps()} className={styles.queueTable}>
177
+ <TableHead>
178
+ <TableRow>
179
+ {headers.map((header) => (
180
+ <TableHeader {...getHeaderProps({ header })}>{header.header}</TableHeader>
181
+ ))}
182
+ </TableRow>
183
+ </TableHead>
184
+ <TableBody>
185
+ {rows.map((row, index) => {
186
+ return (
187
+ <React.Fragment key={row.id}>
188
+ <TableRow {...getRowProps({ row })}>
189
+ {row.cells.map((cell) => (
190
+ <TableCell key={cell.id}>{cell.value?.content ?? cell.value}</TableCell>
191
+ ))}
192
+ </TableRow>
193
+ </React.Fragment>
194
+ );
195
+ })}
196
+ </TableBody>
197
+ </Table>
198
+ {rows.length === 0 ? (
199
+ <div className={styles.tileContainer}>
200
+ <Layer>
201
+ <Tile className={styles.tile}>
202
+ <div className={styles.tileContent}>
203
+ <p className={styles.content}>{t('noPatientsToDisplay', 'No patients to display')}</p>
204
+ <p className={styles.helper}>{t('checkFilters', 'Check the filters above')}</p>
205
+ </div>
206
+ </Tile>
207
+ </Layer>
208
+ </div>
209
+ ) : null}
210
+ </TableContainer>
211
+ )}
212
+ </DataTable>
213
+
214
+ <Pagination
215
+ backwardText="Previous page"
216
+ forwardText="Next page"
217
+ page={currentPage}
218
+ pageNumberText="Page Number"
219
+ pageSize={100}
220
+ onChange={({ page }) => goTo(page)}
221
+ pageSizes={pageSizes?.length > 0 ? pageSizes : [100]}
222
+ totalItems={patientData?.length ?? 0}
223
+ />
224
+
225
+ {showOverlay && <QueueLinelist closePanel={() => setShowOverlay(false)} />}
226
+ </div>
227
+ );
228
+ };
229
+
230
+ export default QueuePatientBaseTable;
@@ -0,0 +1,110 @@
1
+ @use '@carbon/styles/scss/colors';
2
+ @use '@carbon/styles/scss/spacing';
3
+ @use '@carbon/styles/scss/type';
4
+ @import '~@openmrs/esm-styleguide/src/vars';
5
+
6
+ .container {
7
+ padding-bottom: spacing.$spacing-07;
8
+ background-color: $ui-01;
9
+ }
10
+
11
+ .menuItem {
12
+ max-width: none;
13
+ }
14
+
15
+ .headerContainer {
16
+ display: flex;
17
+ justify-content: space-between;
18
+ align-items: center;
19
+ padding: spacing.$spacing-05;
20
+ margin: spacing.$spacing-03;
21
+ border-top: 1px solid $text-03;
22
+ border-bottom: 1px solid $text-03;
23
+ }
24
+
25
+ .title {
26
+ @include type.type-style('body-compact-02');
27
+
28
+ margin: 0 spacing.$spacing-04 spacing.$spacing-04;
29
+ }
30
+
31
+ .subTitle {
32
+ @include type.type-style('label-01');
33
+ color: $text-02;
34
+ margin: spacing.$spacing-01;
35
+ margin-left: spacing.$spacing-04;
36
+ }
37
+
38
+ .filterTile {
39
+ border-bottom: 1px solid $text-03;
40
+ margin-bottom: spacing.$spacing-04;
41
+ background-color: $ui-01;
42
+ }
43
+
44
+ .actionsBtn {
45
+ float: right;
46
+ }
47
+
48
+ .tableContainer {
49
+ margin: 0 spacing.$spacing-05;
50
+ padding: 0;
51
+ }
52
+
53
+ .search {
54
+ max-width: 16rem;
55
+
56
+ input {
57
+ background-color: $ui-02 !important;
58
+ }
59
+ }
60
+
61
+ .tableContainer {
62
+ background-color: $ui-01;
63
+
64
+ a {
65
+ text-decoration: none;
66
+ }
67
+
68
+ tr {
69
+ width: spacing.$spacing-01;
70
+ }
71
+
72
+ .toolbarContent {
73
+ height: spacing.$spacing-07;
74
+ margin-bottom: spacing.$spacing-02;
75
+ }
76
+ }
77
+
78
+ .queueTable tr:last-of-type {
79
+ td {
80
+ border-bottom: none;
81
+ }
82
+ }
83
+
84
+ .tileContainer {
85
+ background-color: $ui-02;
86
+ border-top: 1px solid $ui-03;
87
+ padding: spacing.$spacing-11 0;
88
+ }
89
+
90
+ .tile {
91
+ margin: auto;
92
+ width: fit-content;
93
+ }
94
+
95
+ .tileContent {
96
+ display: flex;
97
+ flex-direction: column;
98
+ align-items: center;
99
+ }
100
+
101
+ .content {
102
+ @include type.type-style('heading-compact-02');
103
+ color: $text-02;
104
+ margin-bottom: spacing.$spacing-03;
105
+ }
106
+
107
+ .helper {
108
+ @include type.type-style('body-compact-01');
109
+ color: $text-02;
110
+ }
@@ -0,0 +1,118 @@
1
+ import React from 'react';
2
+ import { screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import { usePagination } from '@openmrs/esm-framework';
5
+ import { mockMappedAppointmentsData } from '../../../../__mocks__/appointments.mock';
6
+ import { renderWithSwr } from '../../../../tools/test-helpers';
7
+ import QueuePatientBaseTable from './queue-linelist-base-table.component';
8
+
9
+ const mockUsePagination = usePagination as jest.Mock;
10
+ const mockGoToPage = jest.fn();
11
+
12
+ const tableHeaders = [
13
+ {
14
+ id: 0,
15
+ header: 'Name',
16
+ key: 'name',
17
+ },
18
+ {
19
+ id: 1,
20
+ header: 'Return Date',
21
+ key: 'returnDate',
22
+ },
23
+ {
24
+ id: 2,
25
+ header: 'Gender',
26
+ key: 'gender',
27
+ },
28
+ {
29
+ id: 3,
30
+ header: 'Age',
31
+ key: 'age',
32
+ },
33
+ {
34
+ id: 4,
35
+ header: 'Visit Type',
36
+ key: 'visitType',
37
+ },
38
+ {
39
+ id: 5,
40
+ header: 'Phone Number',
41
+ key: 'phoneNumber',
42
+ },
43
+ ];
44
+
45
+ const testProps = {
46
+ title: 'Scheduled appointments',
47
+ patientData: mockMappedAppointmentsData.data,
48
+ headers: tableHeaders,
49
+ serviceType: '',
50
+ isLoading: false,
51
+ };
52
+
53
+ jest.mock('@openmrs/esm-framework', () => {
54
+ const originalModule = jest.requireActual('@openmrs/esm-framework');
55
+ return {
56
+ ...originalModule,
57
+ openmrsFetch: jest.fn(),
58
+ usePagination: jest.fn(),
59
+ };
60
+ });
61
+
62
+ describe('QueuePatientBaseTable: ', () => {
63
+ it('renders a tabular overview of appointments data when available', async () => {
64
+ const user = userEvent.setup();
65
+
66
+ mockUsePagination.mockReturnValue({
67
+ results: testProps.patientData,
68
+ goTo: mockGoToPage,
69
+ currentPage: 1,
70
+ });
71
+
72
+ renderQueueBaseTable();
73
+
74
+ expect(screen.queryByText(/scheduled appointments/i)).toBeInTheDocument();
75
+ const expectedColumnHeaders = [/name/, /return date/, /gender/, /age/, /visit type/, /phone number/];
76
+ expectedColumnHeaders.forEach((header) => {
77
+ expect(screen.getByRole('columnheader', { name: new RegExp(header, 'i') })).toBeInTheDocument();
78
+ });
79
+
80
+ const expectedTableRows = [
81
+ /John Wilson Today, 02:08 PM Male 45 HIV Clinic 0700123456/,
82
+ /Eric Test Ric Today, 02:08 PM Male 32 TB Clinic 0700987654/,
83
+ ];
84
+
85
+ expectedTableRows.forEach((row) => {
86
+ expect(screen.queryByRole('row', { name: new RegExp(row, 'i') })).not.toBeInTheDocument();
87
+ });
88
+
89
+ const searchBox = screen.getByRole('searchbox');
90
+ await user.type(searchBox, 'John');
91
+
92
+ expect(screen.queryByText(/john wilson/i)).toBeInTheDocument();
93
+ expect(screen.queryByText(/eric test ric/i)).not.toBeInTheDocument();
94
+
95
+ await user.clear(searchBox);
96
+ await user.type(searchBox, 'gibberish');
97
+ expect(screen.queryByText(/john wilson/i)).not.toBeInTheDocument();
98
+ expect(screen.queryByText(/eric test ric/i)).not.toBeInTheDocument();
99
+ });
100
+
101
+ it('renders an empty state view if data is unavailable', async () => {
102
+ mockUsePagination.mockReturnValue({
103
+ results: [],
104
+ goTo: mockGoToPage,
105
+ currentPage: 1,
106
+ });
107
+
108
+ renderQueueBaseTable();
109
+
110
+ expect(screen.queryByRole('progressbar')).not.toBeInTheDocument();
111
+ expect(screen.getByText(/scheduled appointments/i)).toBeInTheDocument();
112
+ expect(screen.getByText(/no patients to display/i)).toBeInTheDocument();
113
+ });
114
+ });
115
+
116
+ function renderQueueBaseTable() {
117
+ renderWithSwr(<QueuePatientBaseTable {...testProps} />);
118
+ }
@@ -0,0 +1,172 @@
1
+ import React, { useCallback, useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import {
4
+ DatePicker,
5
+ DatePickerInput,
6
+ Form,
7
+ Layer,
8
+ Stack,
9
+ RadioButtonGroup,
10
+ RadioButton,
11
+ Dropdown,
12
+ Column,
13
+ Button,
14
+ ButtonSet,
15
+ NumberInput,
16
+ Toggle,
17
+ } from '@carbon/react';
18
+ import dayjs from 'dayjs';
19
+ import { toDateObjectStrict, toOmrsIsoString, useLayoutType, useVisitTypes } from '@openmrs/esm-framework';
20
+ import styles from './queue-linelist-filter.scss';
21
+
22
+ interface QueueLinelistFilterProps {
23
+ closePanel: () => void;
24
+ }
25
+
26
+ const QueueLinelistFilter: React.FC<QueueLinelistFilterProps> = ({ closePanel }) => {
27
+ const { t } = useTranslation();
28
+ const [gender, setGender] = useState('');
29
+ const [startAge, setStartAge] = useState<number>();
30
+ const [endAge, setEndAge] = useState<number>();
31
+ const [returnDate, setReturnDate] = useState(new Date());
32
+ const [visitType, setVisitType] = useState('');
33
+ const isTablet = useLayoutType() === 'tablet';
34
+ const allVisitTypes = useVisitTypes();
35
+
36
+ const handleFilter = useCallback(
37
+ (event) => {
38
+ event.preventDefault();
39
+
40
+ const payload = {
41
+ gender: gender,
42
+ startAge: startAge,
43
+ endAge: endAge,
44
+ returnDate: toDateObjectStrict(
45
+ toOmrsIsoString(new Date(dayjs(returnDate).year(), dayjs(returnDate).month(), dayjs(returnDate).date())),
46
+ ),
47
+ visitType: visitType,
48
+ };
49
+ },
50
+ [gender, startAge, endAge, returnDate, visitType],
51
+ );
52
+
53
+ const handleTodaysDate = () => {
54
+ setReturnDate(new Date());
55
+ };
56
+
57
+ return (
58
+ <>
59
+ <Form onSubmit={handleFilter}>
60
+ <div className={styles.wrapper}>
61
+ <Stack gap={4} className={styles.grid}>
62
+ <Column>
63
+ <p className={styles.heading}> {t('gender', 'Gender')}</p>
64
+ <RadioButtonGroup name="gender" orientation="vertical" onChange={(event) => setGender(event.toString())}>
65
+ <RadioButton
66
+ className={styles.radioButton}
67
+ id="male"
68
+ labelText={t('maleLabelText', 'Male')}
69
+ value="Male"
70
+ />
71
+ <RadioButton
72
+ className={styles.radioButton}
73
+ id="female"
74
+ labelText={t('femaleLabelText', 'Female')}
75
+ value="Female"
76
+ />
77
+ </RadioButtonGroup>
78
+ </Column>
79
+ </Stack>
80
+
81
+ <Stack gap={4} className={styles.grid}>
82
+ <Column md={2}>
83
+ <p className={styles.heading}> {t('age', 'Age')}</p>
84
+ <Layer>
85
+ <Toggle
86
+ size="sm"
87
+ aria-label={t('age', 'Age')}
88
+ defaultToggled
89
+ id="age"
90
+ labelA="Off"
91
+ labelB="On"
92
+ labelText=""
93
+ />
94
+ </Layer>
95
+ <Layer className={styles.numberInputs}>
96
+ <Layer>
97
+ <NumberInput
98
+ id="startAge"
99
+ invalidText={t('startAgeRangeInvalid', 'Start age range is not valid')}
100
+ label={t('between', 'Between')}
101
+ max={100}
102
+ min={0}
103
+ onChange={(event) => setStartAge(event.target.value)}
104
+ size="md"
105
+ value={startAge}
106
+ />
107
+ </Layer>
108
+ <Layer>
109
+ <NumberInput
110
+ id="endAge"
111
+ invalidText={t('endAgeRangeInvalid', 'End age range is not valid')}
112
+ label={t('and', 'And')}
113
+ max={100}
114
+ min={0}
115
+ onChange={(event) => setEndAge(event.target.value)}
116
+ size="md"
117
+ value={endAge}
118
+ />
119
+ </Layer>
120
+ </Layer>
121
+ </Column>
122
+ </Stack>
123
+
124
+ <Stack gap={4} className={styles.grid}>
125
+ <Column md={2}>
126
+ <p className={styles.heading}> {t('returnDate', 'Return Date')}</p>
127
+ <Layer>
128
+ <DatePicker datePickerType="single" value={returnDate} onChange={([date]) => setReturnDate(date)}>
129
+ <DatePickerInput id="returnDate" placeholder="mm/dd/yyyy" labelText={t('date', 'Date')} type="date" />
130
+ </DatePicker>
131
+ </Layer>
132
+ <Button
133
+ kind="ghost"
134
+ onClick={() => {
135
+ handleTodaysDate();
136
+ }}>
137
+ {t('useTodaysDate', "Use today's date")}
138
+ </Button>
139
+ </Column>
140
+ </Stack>
141
+
142
+ <Stack gap={4} className={styles.grid}>
143
+ <Column>
144
+ <p className={styles.heading}>{t('visitType', 'Visit Type')}</p>
145
+ <Layer>
146
+ <Dropdown
147
+ id="visitType"
148
+ label={t('selectVisitTyoe', 'Select visit type')}
149
+ items={allVisitTypes}
150
+ onChange={(event) => setVisitType(event.selectedItem.toString)}
151
+ size="sm"
152
+ itemToElement={(item) => (item ? <span>{item.display}</span> : null)}
153
+ />
154
+ </Layer>
155
+ </Column>
156
+ </Stack>
157
+ </div>
158
+
159
+ <ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
160
+ <Button className={styles.button} kind="secondary" onClick={closePanel}>
161
+ {t('cancel', 'Cancel')}
162
+ </Button>
163
+ <Button className={styles.button} kind="primary" type="submit">
164
+ {t('applyFilters', 'Apply filters')}
165
+ </Button>
166
+ </ButtonSet>
167
+ </Form>
168
+ </>
169
+ );
170
+ };
171
+
172
+ export default QueueLinelistFilter;
@@ -0,0 +1,63 @@
1
+ @use '@carbon/styles/scss/type';
2
+ @use '@carbon/styles/scss/spacing';
3
+ @import '~@openmrs/esm-styleguide/src/vars';
4
+
5
+ .wrapper {
6
+ background-color: $ui-02;
7
+ padding: spacing.$spacing-06;
8
+ }
9
+
10
+ .grid {
11
+ padding: 0 spacing.$spacing-06 spacing.$spacing-03;
12
+ background-color: $ui-01;
13
+ margin-bottom: spacing.$spacing-05;
14
+ }
15
+
16
+ .heading {
17
+ color: $text-02;
18
+ @include type.type-style('heading-compact-02');
19
+ margin: spacing.$spacing-04 0 spacing.$spacing-04;
20
+ }
21
+
22
+ .radioButton {
23
+ margin-top: spacing.$spacing-03;
24
+ }
25
+
26
+ .button {
27
+ height: spacing.$spacing-10;
28
+ display: flex;
29
+ align-content: flex-start;
30
+ align-items: baseline;
31
+ min-width: 50%;
32
+ }
33
+
34
+ .numberInputs {
35
+ margin-top: spacing.$spacing-02;
36
+ display: flex;
37
+ flex-direction: row;
38
+ justify-content: space-between;
39
+ }
40
+
41
+ .tablet {
42
+ padding: spacing.$spacing-06 spacing.$spacing-05;
43
+ background-color: $ui-02;
44
+ }
45
+
46
+ .desktop {
47
+ padding: 0rem;
48
+ margin-top: spacing.$spacing-05;
49
+ }
50
+
51
+ /* Desktop */
52
+ :global(.omrs-breakpoint-gt-tablet) {
53
+ .form {
54
+ height: calc(100vh - 6rem);
55
+ }
56
+ }
57
+
58
+ /* Tablet */
59
+ :global(.omrs-breakpoint-lt-desktop) {
60
+ .form {
61
+ height: calc(100vh - 3rem);
62
+ }
63
+ }