@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,54 @@
1
+ import useSWR from 'swr';
2
+ import useSWRImmutable from 'swr/immutable';
3
+ import { openmrsFetch } from '@openmrs/esm-framework';
4
+ import { Appointment, QueueServiceInfo } from '../types';
5
+ import { startOfDay } from '../constants';
6
+
7
+ export function useServices(location: string) {
8
+ const apiUrl = `/ws/rest/v1/queue?location=${location}`;
9
+
10
+ const { data, isLoading } = useSWRImmutable<{ data: { results: Array<QueueServiceInfo> } }, Error>(
11
+ location ? apiUrl : null,
12
+ openmrsFetch,
13
+ );
14
+
15
+ return {
16
+ services: data ? data?.data?.results?.map((service) => service.display) : [],
17
+ allServices: data ? data?.data.results : [],
18
+ isLoading: isLoading,
19
+ };
20
+ }
21
+
22
+ export function useServiceMetricsCount(service: string, location: string) {
23
+ const status = 'Waiting';
24
+ const apiUrl = `/ws/rest/v1/queue-entry-metrics?service=${service}&status=${status}&location=${location}`;
25
+
26
+ const { data } = useSWRImmutable<
27
+ {
28
+ data: {
29
+ count: number;
30
+ };
31
+ },
32
+ Error
33
+ >(service ? apiUrl : null, openmrsFetch);
34
+
35
+ return {
36
+ serviceCount: data ? data?.data?.count : 0,
37
+ };
38
+ }
39
+
40
+ export const useAppointmentMetrics = () => {
41
+ const apiUrl = `/ws/rest/v1/appointment/all?forDate=${startOfDay}`;
42
+
43
+ const { data, error, isLoading } = useSWR<{
44
+ data: Array<Appointment>;
45
+ }>(apiUrl, openmrsFetch);
46
+
47
+ const totalScheduledAppointments = data?.data.length ?? 0;
48
+
49
+ return {
50
+ isLoading,
51
+ error,
52
+ totalScheduledAppointments,
53
+ };
54
+ };
@@ -0,0 +1,190 @@
1
+ import React, { useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import {
4
+ Button,
5
+ ButtonSet,
6
+ Column,
7
+ ContentSwitcher,
8
+ DatePicker,
9
+ DatePickerInput,
10
+ Form,
11
+ FormGroup,
12
+ Layer,
13
+ Stack,
14
+ Switch,
15
+ TextInput,
16
+ } from '@carbon/react';
17
+ import { ArrowLeft } from '@carbon/react/icons';
18
+ import { useLayoutType } from '@openmrs/esm-framework';
19
+ import { SearchTypes } from '../types';
20
+ import styles from './advanced-search.scss';
21
+
22
+ interface PatientSearchProps {
23
+ toggleSearchType: (searchMode: SearchTypes) => void;
24
+ }
25
+
26
+ enum fieldMatcherRange {
27
+ ANY = 'any',
28
+ ALL = 'all',
29
+ }
30
+
31
+ enum genders {
32
+ ANY = 'any',
33
+ MALE = 'male',
34
+ FEMALE = 'female',
35
+ }
36
+
37
+ const AdvancedSearch: React.FC<PatientSearchProps> = ({ toggleSearchType }) => {
38
+ const { t } = useTranslation();
39
+ const isTablet = useLayoutType() === 'tablet';
40
+ const [firstName, setFirstName] = useState('');
41
+ const [middleName, setMiddleName] = useState('');
42
+ const [lastName, setLastName] = useState('');
43
+ const [gender, setGender] = useState('');
44
+ const [dateOfBirth, setDateOfBirth] = useState('');
45
+ const [phoneNumber, setPhoneNumber] = useState('');
46
+ const [postCode, setPostCode] = useState('');
47
+ const [lastVisitDate, setLastVisitDate] = useState('');
48
+ const [fieldMatcherRangeSwitcherValue, setFieldMatcherRangeSwitcherValue] = useState(0);
49
+ const [genderSwitcherValue, setGenderSwitcherValue] = useState(0);
50
+ const [searchParams, setSearchParams] = useState([]);
51
+ const [open, setOpen] = useState(false);
52
+
53
+ const handleSearch = () => {
54
+ setSearchParams([firstName, middleName, lastName, gender, dateOfBirth, phoneNumber, postCode, lastVisitDate]);
55
+ };
56
+
57
+ return (
58
+ <Form onSubmit={handleSearch} className={styles.form}>
59
+ <div>
60
+ <div className={styles.backButton}>
61
+ <Button
62
+ kind="ghost"
63
+ renderIcon={(props) => <ArrowLeft size={24} {...props} />}
64
+ iconDescription="Back to simple search"
65
+ size="sm"
66
+ onClick={() => toggleSearchType(SearchTypes.BASIC)}>
67
+ <span>{t('backToSimpleSearch', 'Back to simple search')}</span>
68
+ </Button>
69
+ </div>
70
+ <Stack gap={4} className={styles.grid}>
71
+ <Column>
72
+ <div className={styles.contentSwitcherContainer}>
73
+ <span>{t('match', 'Match')}</span>
74
+ <ContentSwitcher
75
+ size="sm"
76
+ className={styles.fieldRangeSwitcher}
77
+ onChange={({ index }) => setFieldMatcherRangeSwitcherValue(index)}>
78
+ <Switch name={fieldMatcherRange.ANY} text={t('any', 'Any')} />
79
+ <Switch name={fieldMatcherRange.ALL} text={t('all', 'All')} />
80
+ </ContentSwitcher>
81
+ <span>{t('fields', 'of the following fields')}:</span>
82
+ </div>
83
+ </Column>
84
+
85
+ <Column>
86
+ <h3 className={styles.heading}>{t('name', 'Name')}</h3>
87
+ <Layer>
88
+ <TextInput
89
+ className={styles.input}
90
+ id="firstName"
91
+ labelText={t('firstName', 'First name')}
92
+ onChange={(event) => setFirstName(event.target.value)}
93
+ value={firstName}
94
+ />
95
+ </Layer>
96
+ <Layer>
97
+ <TextInput
98
+ className={styles.input}
99
+ id="middleName"
100
+ labelText={t('middleName', 'Middle name')}
101
+ onChange={(event) => setMiddleName(event.target.value)}
102
+ value={middleName}
103
+ />
104
+ </Layer>
105
+ <Layer>
106
+ <TextInput
107
+ className={styles.input}
108
+ id="lastName"
109
+ labelText={t('lastName', 'Last name')}
110
+ onChange={(event) => setLastName(event.target.value)}
111
+ value={lastName}
112
+ />
113
+ </Layer>
114
+ </Column>
115
+ <span className={styles.spacer} />
116
+
117
+ <Column>
118
+ <h3 className={styles.heading}>{t('personalDetails', 'Personal details')}</h3>
119
+ <FormGroup legendText={t('sex', 'Sex')}>
120
+ <ContentSwitcher
121
+ size="sm"
122
+ className={styles.genderSwitcher}
123
+ onChange={({ index }) => setGenderSwitcherValue(index)}>
124
+ <Switch name={genders.ANY} text={t('any', 'Any')} />
125
+ <Switch name={genders.MALE} text={t('male', 'Male')} />
126
+ <Switch name={genders.FEMALE} text={t('female', 'Female')} />
127
+ </ContentSwitcher>
128
+ </FormGroup>
129
+ <Layer>
130
+ <DatePicker datePickerType="single">
131
+ <DatePickerInput
132
+ id="dateOfBirth"
133
+ placeholder="mm/dd/yyyy"
134
+ labelText={t('dateOfBirth', 'Date of birth')}
135
+ onChange={(event) => setDateOfBirth(event.target.value)}
136
+ type="date"
137
+ />
138
+ </DatePicker>
139
+ </Layer>
140
+ <Layer>
141
+ <TextInput
142
+ className={styles.input}
143
+ id="phoneNumber"
144
+ labelText={t('phoneNumber', 'Phone number')}
145
+ onChange={(event) => setPhoneNumber(event.target.value)}
146
+ value={phoneNumber}
147
+ />
148
+ </Layer>
149
+ <Layer>
150
+ <TextInput
151
+ className={styles.input}
152
+ id="postCode"
153
+ labelText={t('postCode', 'Post code')}
154
+ onChange={(event) => setPostCode(event.target.value)}
155
+ value={postCode}
156
+ />
157
+ </Layer>
158
+ </Column>
159
+ <span className={styles.spacer} />
160
+
161
+ <Column>
162
+ <h3 className={styles.heading}>{t('lastVisit', 'Last visit')}</h3>
163
+ <Layer>
164
+ <DatePicker datePickerType="single">
165
+ <DatePickerInput
166
+ id="lastVisitDate"
167
+ placeholder="mm/dd/yyyy"
168
+ labelText={t('lastVisitDate', 'Date')}
169
+ onChange={(event) => setLastVisitDate(event.target.value)}
170
+ type="date"
171
+ width={'120px'}
172
+ />
173
+ </DatePicker>
174
+ </Layer>
175
+ </Column>
176
+ </Stack>
177
+ </div>
178
+ <ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
179
+ <Button className={styles.button} kind="secondary" onClick={() => toggleSearchType(SearchTypes.BASIC)}>
180
+ {t('cancel', 'Cancel')}
181
+ </Button>
182
+ <Button className={styles.button} kind="primary" type="submit">
183
+ {t('search', 'Search')}
184
+ </Button>
185
+ </ButtonSet>
186
+ </Form>
187
+ );
188
+ };
189
+
190
+ export default AdvancedSearch;
@@ -0,0 +1,154 @@
1
+ @use '@carbon/styles/scss/spacing';
2
+ @use '@carbon/styles/scss/type';
3
+ @import '~@openmrs/esm-styleguide/src/vars';
4
+
5
+ .form {
6
+ display: flex;
7
+ flex-direction: column;
8
+ justify-content: space-between;
9
+ height: calc(100vh - 6rem);
10
+ }
11
+
12
+ .grid {
13
+ margin: 0 1rem;
14
+ padding: 0rem;
15
+ }
16
+
17
+ .row {
18
+ margin: 0;
19
+
20
+ :global(.cds--col) {
21
+ :global(.cds--form-item) {
22
+ &:not(:first-of-type):not(:last-of-type) {
23
+ margin: 1rem 0;
24
+ }
25
+ }
26
+
27
+ :global(.cds--fieldset) {
28
+ margin: 0;
29
+ }
30
+
31
+ :global(.cds--date-picker.cds--date-picker--single .cds--date-picker__input) {
32
+ width: 10rem;
33
+ }
34
+ }
35
+ }
36
+
37
+ .heading {
38
+ @include type.type-style('heading-compact-02');
39
+ margin-bottom: 0.5rem;
40
+ }
41
+
42
+ .spacer {
43
+ margin-top: 2rem;
44
+ display: inline-block;
45
+ }
46
+
47
+ .backButton {
48
+ align-items: center;
49
+ display: flex;
50
+ justify-content: flex-start;
51
+ margin: spacing.$spacing-03 0;
52
+ padding: 0;
53
+ @include type.type-style('body-compact-01');
54
+
55
+ button {
56
+ display: flex;
57
+
58
+ svg {
59
+ order: 1;
60
+ margin-right: 0.5rem;
61
+ margin-left: 0rem !important;
62
+ }
63
+
64
+ span {
65
+ order: 2;
66
+ }
67
+ }
68
+ }
69
+
70
+ .advancePatientSearchContainer {
71
+ margin: 0 spacing.$spacing-05;
72
+
73
+ & .backButton {
74
+ margin: 0;
75
+ }
76
+
77
+ & > button {
78
+ padding-left: 0;
79
+ }
80
+ }
81
+
82
+ .label01 {
83
+ @include type.type-style('label-01');
84
+ color: $text-02;
85
+ margin: spacing.$spacing-03 0;
86
+ }
87
+
88
+ .formTextInput {
89
+ margin-bottom: spacing.$spacing-04;
90
+ }
91
+
92
+ .contentSwitcherContainer {
93
+ display: flex;
94
+ align-items: center;
95
+ height: spacing.$spacing-09;
96
+ margin-bottom: spacing.$spacing-05;
97
+
98
+ & > span {
99
+ @include type.type-style('heading-compact-01');
100
+ color: $text-02;
101
+ }
102
+ }
103
+
104
+ .formTitle {
105
+ font-weight: bold;
106
+ @include type.type-style('heading-compact-02');
107
+ margin-bottom: spacing.$spacing-02;
108
+ }
109
+
110
+ .fieldRangeSwitcher {
111
+ width: 8rem;
112
+ margin: 0 spacing.$spacing-03 0;
113
+ }
114
+
115
+ .genderSwitcher {
116
+ width: 18rem;
117
+ margin: 0.25rem 0 1rem;
118
+ }
119
+
120
+ .button {
121
+ height: 4rem;
122
+ display: flex;
123
+ align-content: flex-start;
124
+ align-items: baseline;
125
+ min-width: 50%;
126
+ }
127
+
128
+ .tablet {
129
+ padding: 1.5rem 1rem;
130
+ background-color: $ui-02;
131
+ }
132
+
133
+ .desktop {
134
+ padding: 0rem;
135
+ margin-top: spacing.$spacing-05;
136
+ }
137
+
138
+ /* Desktop */
139
+ :global(.omrs-breakpoint-gt-tablet) {
140
+ .form {
141
+ height: calc(100vh - 6rem);
142
+ }
143
+ }
144
+
145
+ /* Tablet */
146
+ :global(.omrs-breakpoint-lt-desktop) {
147
+ .form {
148
+ height: calc(100vh - 3rem);
149
+ }
150
+ }
151
+
152
+ .input {
153
+ width: 13.5rem;
154
+ }
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import AdvancedSearch from './advanced-search.component';
4
+
5
+ describe('AdvancedSearch: ', () => {
6
+ test('renders the advanced patient search in an overlay', () => {
7
+ renderAdvancedSearch();
8
+
9
+ expect(screen.getByRole('button', { name: /back to simple search/i })).toBeInTheDocument();
10
+ expect(screen.getByRole('button', { name: /cancel/i })).toBeInTheDocument();
11
+ expect(screen.getByRole('button', { name: /^search$/i })).toBeInTheDocument();
12
+ expect(screen.findAllByText(/any/i));
13
+ expect(screen.getByRole('tab', { name: /^male$/i })).toBeInTheDocument();
14
+ expect(screen.getByRole('tab', { name: /^female$/i })).toBeInTheDocument();
15
+ expect(screen.getByRole('heading', { name: /name/i })).toBeInTheDocument();
16
+ expect(screen.getByRole('heading', { name: /personal details/i })).toBeInTheDocument();
17
+ expect(screen.getByRole('heading', { name: /last visit/i })).toBeInTheDocument();
18
+ expect(screen.getByRole('textbox', { name: /first name/i })).toBeInTheDocument();
19
+ expect(screen.getByRole('textbox', { name: /middle name/i })).toBeInTheDocument();
20
+ expect(screen.getByRole('textbox', { name: /last name/i })).toBeInTheDocument();
21
+ expect(screen.getByRole('textbox', { name: /phone number/i })).toBeInTheDocument();
22
+ expect(screen.getByRole('textbox', { name: /post code/i })).toBeInTheDocument();
23
+ });
24
+ });
25
+
26
+ function renderAdvancedSearch() {
27
+ const toggleSearchType = jest.fn();
28
+ render(<AdvancedSearch toggleSearchType={toggleSearchType} />);
29
+ }
@@ -0,0 +1,112 @@
1
+ import React, { useMemo, useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import debounce from 'lodash-es/debounce';
4
+ import { Search, Button, InlineLoading, Layer, Tile } from '@carbon/react';
5
+ import { Search as SearchIcon } from '@carbon/react/icons';
6
+ import EmptyDataIllustration from './empty-data-illustration.component';
7
+ import SearchIllustration from './search-illustration.component';
8
+ import SearchResults from './search-results.component';
9
+ import usePatients from './hooks/usePatients';
10
+ import { SearchTypes } from '../types';
11
+ import styles from './basic-search.scss';
12
+
13
+ interface BasicSearchProps {
14
+ toggleSearchType: (searchMode: SearchTypes) => void;
15
+ }
16
+
17
+ const searchTimeoutInMs = 300;
18
+
19
+ const BasicSearch: React.FC<BasicSearchProps> = ({ toggleSearchType }) => {
20
+ const { t } = useTranslation();
21
+ const [searchTerm, setSearchTerm] = useState('');
22
+ const [query, setQuery] = useState<string>(null);
23
+ const { patients, isLoading } = usePatients(query);
24
+
25
+ const handleSearch = useMemo(() => debounce((searchTerm) => setSearchTerm(searchTerm), searchTimeoutInMs), []);
26
+
27
+ const performSearch = () => setQuery(searchTerm);
28
+
29
+ return (
30
+ <div className={patients?.length ? styles.lightBackground : styles.resultsContainer}>
31
+ <div className={styles.searchboxContainer}>
32
+ <Layer className={styles.searchboxLayer}>
33
+ <Search
34
+ autoFocus
35
+ className={styles.searchInput}
36
+ labelText={t('searchForPatient', 'Search for a patient')}
37
+ placeholder={t('searchboxPlaceholder', 'Search for a patient name or ID number')}
38
+ onChange={(event) => handleSearch(event.target.value)}
39
+ onClear={() => setQuery(null)}
40
+ />
41
+ </Layer>
42
+ <Button onClick={performSearch} iconDescription="Basic search" size="md" kind="secondary">
43
+ {t('search', 'Search')}
44
+ </Button>
45
+ </div>
46
+ {
47
+ <>
48
+ {query === null && (
49
+ <div>
50
+ <div className={styles.tileContainer}>
51
+ <Layer>
52
+ <Tile className={styles.tile}>
53
+ <SearchIllustration />
54
+ <div className={styles.helperText}>
55
+ <p className={styles.primaryText}>{t('primaryHelperText', 'Search for a patient')}</p>
56
+ <p className={styles.secondaryText}>
57
+ {t('secondaryHelperText', "Type the patient's name or unique ID number")}
58
+ </p>
59
+ </div>
60
+ </Tile>
61
+ </Layer>
62
+ </div>
63
+ <p className={styles.separator}>{t('or', 'or')}</p>
64
+ <div className={styles.buttonContainer}>
65
+ <Button
66
+ kind="ghost"
67
+ disabled
68
+ iconDescription="Advanced search"
69
+ renderIcon={(props) => <SearchIcon size={16} {...props} />}
70
+ onClick={() => toggleSearchType(SearchTypes.ADVANCED)}>
71
+ {t('advancedSearch', 'Advanced search')}
72
+ </Button>
73
+ </div>
74
+ </div>
75
+ )}
76
+ {isLoading && (
77
+ <div className={styles.loadingContainer}>
78
+ <InlineLoading description={t('loading', 'Loading...')} />
79
+ </div>
80
+ )}
81
+
82
+ {patients.length > 0 && <SearchResults toggleSearchType={toggleSearchType} patients={patients} />}
83
+
84
+ {patients.length === 0 && query !== null && !isLoading && (
85
+ <div className={styles.resultsContainer}>
86
+ <div style={{ margin: '1rem' }}>
87
+ <p className={styles.resultsText}>{t('noResultsFound', 'No results found')}</p>
88
+ <Layer>
89
+ <Tile className={styles.emptySearchResultsTile}>
90
+ <EmptyDataIllustration />
91
+ <p className={styles.emptyResultText}>
92
+ {t('noPatientFoundMessage', 'Sorry, no patient has been found')}
93
+ </p>
94
+ <p className={styles.actionText}>
95
+ <span>
96
+ {t('trySearchWithPatientUniqueID', "Try searching with the patient's unique ID number")}
97
+ </span>
98
+ <br />
99
+ <span>{t('orPatientName', "OR the patient's name(s)")}</span>
100
+ </p>
101
+ </Tile>
102
+ </Layer>
103
+ </div>
104
+ </div>
105
+ )}
106
+ </>
107
+ }
108
+ </div>
109
+ );
110
+ };
111
+
112
+ export default BasicSearch;
@@ -0,0 +1,139 @@
1
+ @use '@carbon/styles/scss/spacing';
2
+ @use '@carbon/styles/scss/type';
3
+ @import '~@openmrs/esm-styleguide/src/vars';
4
+
5
+ .searchboxContainer {
6
+ display: flex;
7
+ align-items: center;
8
+ margin-bottom: spacing.$spacing-05;
9
+ }
10
+
11
+ .searchboxLayer {
12
+ flex-grow: 1;
13
+ }
14
+
15
+ .tileContainer {
16
+ :global(.omrs-breakpoint-gt-tablet) & {
17
+ margin: 0 1.5rem 0;
18
+ }
19
+
20
+ :global(.omrs-breakpoint-lt-desktop) & {
21
+ width: 60%;
22
+ margin: auto;
23
+ }
24
+ }
25
+
26
+ .tile {
27
+ display: flex;
28
+ flex-flow: column wrap;
29
+ align-items: center;
30
+ justify-content: center;
31
+ padding: 2rem 0 1.5rem;
32
+ text-align: center;
33
+ border: 1px solid $ui-03;
34
+ }
35
+
36
+ .helperText {
37
+ margin-top: 1.25rem;
38
+ color: $text-02;
39
+
40
+ .primaryText {
41
+ @include type.type-style('heading-compact-01');
42
+ }
43
+
44
+ .secondaryText {
45
+ width: 12rem;
46
+ margin-top: 0.25rem;
47
+ @include type.type-style('body-01');
48
+ }
49
+ }
50
+
51
+ .separator {
52
+ @include type.type-style('heading-03');
53
+ color: $text-02;
54
+ width: 12rem;
55
+ margin: 3rem auto;
56
+ overflow: hidden;
57
+ text-align: center;
58
+
59
+ &::before,
60
+ &::after {
61
+ background-color: $text-03;
62
+ content: '';
63
+ display: inline-block;
64
+ height: 1px;
65
+ position: relative;
66
+ vertical-align: middle;
67
+ width: 50%;
68
+ }
69
+
70
+ &::before {
71
+ right: 1rem;
72
+ margin-left: -50%;
73
+ }
74
+
75
+ &::after {
76
+ left: 1rem;
77
+ margin-right: -50%;
78
+ }
79
+ }
80
+
81
+ .buttonContainer {
82
+ display: flex;
83
+ align-items: center;
84
+ justify-content: center;
85
+ }
86
+
87
+ .resultsContainer {
88
+ height: 100vh;
89
+ }
90
+
91
+ .lightBackground {
92
+ @extend .resultsContainer;
93
+ background-color: white;
94
+ }
95
+
96
+ .loadingContainer {
97
+ height: 80vh;
98
+ display: flex;
99
+ justify-content: center;
100
+ align-items: center;
101
+
102
+ & > div {
103
+ width: fit-content !important;
104
+ }
105
+ }
106
+
107
+ .helperText {
108
+ color: var(--omrs-color-ink-medium-contrast);
109
+ margin-left: 2.375rem;
110
+ }
111
+
112
+ .resultsText {
113
+ @include type.type-style('label-01');
114
+ color: $text-02;
115
+ border-bottom: 0.063rem solid $ui-03;
116
+ padding: spacing.$spacing-03 0rem;
117
+ }
118
+
119
+ .emptyResultText {
120
+ @include type.type-style('heading-compact-01');
121
+ color: $text-02;
122
+ margin-top: spacing.$spacing-05;
123
+ margin-bottom: 0.313rem;
124
+ }
125
+
126
+ .actionText {
127
+ @include type.type-style('body-01');
128
+ color: $text-02;
129
+ }
130
+
131
+ .emptySearchResultsTile {
132
+ text-align: center;
133
+ margin-top: spacing.$spacing-05;
134
+ padding: spacing.$spacing-09 0rem;
135
+ }
136
+
137
+ :global(.omrs-breakpoint-gt-tablet) .emptySearchResultsTile {
138
+ background-color: $ui-02;
139
+ }
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { render, screen } from '@testing-library/react';
3
+ import BasicSearch from './basic-search.component';
4
+
5
+ describe('BasicSearch: ', () => {
6
+ test('renders the basic patient search in an overlay', () => {
7
+ renderBasicSearch();
8
+
9
+ const searchbox = screen.getByRole('searchbox', { name: /search for a patient/i });
10
+ const searchButton = screen.getByRole('button', { name: /^search$/i });
11
+ expect(searchbox).toBeInTheDocument();
12
+ expect(searchButton).toBeInTheDocument();
13
+ expect(screen.getByPlaceholderText(/search for a patient name or id number/i)).toBeInTheDocument();
14
+ expect(screen.getByRole('button', { name: /advanced search/i })).toBeDisabled();
15
+ expect(screen.getByText('or')).toBeInTheDocument();
16
+ expect(screen.getByText(/type the patient's name or unique id number/i)).toBeInTheDocument();
17
+ });
18
+ });
19
+
20
+ function renderBasicSearch() {
21
+ const toggleSearchType = jest.fn();
22
+ render(<BasicSearch toggleSearchType={toggleSearchType} />);
23
+ }