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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (289) hide show
  1. package/.turbo/turbo-build.log +40 -0
  2. package/README.md +20 -0
  3. package/dist/130.js +2 -0
  4. package/dist/130.js.LICENSE.txt +3 -0
  5. package/dist/130.js.map +1 -0
  6. package/dist/152.js +1 -0
  7. package/dist/152.js.map +1 -0
  8. package/dist/169.js +1 -0
  9. package/dist/169.js.map +1 -0
  10. package/dist/185.js +1 -0
  11. package/dist/185.js.map +1 -0
  12. package/dist/233.js +1 -0
  13. package/dist/233.js.map +1 -0
  14. package/dist/237.js +1 -0
  15. package/dist/237.js.map +1 -0
  16. package/dist/255.js +2 -0
  17. package/dist/255.js.LICENSE.txt +9 -0
  18. package/dist/255.js.map +1 -0
  19. package/dist/271.js +1 -0
  20. package/dist/276.js +1 -0
  21. package/dist/276.js.map +1 -0
  22. package/dist/303.js +1 -0
  23. package/dist/303.js.map +1 -0
  24. package/dist/319.js +1 -0
  25. package/dist/401.js +1 -0
  26. package/dist/401.js.map +1 -0
  27. package/dist/430.js +2 -0
  28. package/dist/430.js.LICENSE.txt +50 -0
  29. package/dist/430.js.map +1 -0
  30. package/dist/460.js +1 -0
  31. package/dist/501.js +1 -0
  32. package/dist/501.js.map +1 -0
  33. package/dist/574.js +1 -0
  34. package/dist/591.js +2 -0
  35. package/dist/591.js.LICENSE.txt +32 -0
  36. package/dist/591.js.map +1 -0
  37. package/dist/644.js +1 -0
  38. package/dist/647.js +1 -0
  39. package/dist/647.js.map +1 -0
  40. package/dist/650.js +1 -0
  41. package/dist/650.js.map +1 -0
  42. package/dist/669.js +1 -0
  43. package/dist/669.js.map +1 -0
  44. package/dist/696.js +1 -0
  45. package/dist/696.js.map +1 -0
  46. package/dist/703.js +1 -0
  47. package/dist/703.js.map +1 -0
  48. package/dist/729.js +1 -0
  49. package/dist/729.js.map +1 -0
  50. package/dist/738.js +1 -0
  51. package/dist/738.js.map +1 -0
  52. package/dist/757.js +1 -0
  53. package/dist/764.js +1 -0
  54. package/dist/764.js.map +1 -0
  55. package/dist/784.js +2 -0
  56. package/dist/784.js.LICENSE.txt +9 -0
  57. package/dist/784.js.map +1 -0
  58. package/dist/788.js +1 -0
  59. package/dist/806.js +1 -0
  60. package/dist/806.js.map +1 -0
  61. package/dist/807.js +1 -0
  62. package/dist/833.js +1 -0
  63. package/dist/877.js +1 -0
  64. package/dist/877.js.map +1 -0
  65. package/dist/917.js +1 -0
  66. package/dist/917.js.map +1 -0
  67. package/dist/940.js +1 -0
  68. package/dist/940.js.map +1 -0
  69. package/dist/981.js +1 -0
  70. package/dist/981.js.map +1 -0
  71. package/dist/kenyaemr-esm-service-queues-app.js +1 -0
  72. package/dist/kenyaemr-esm-service-queues-app.js.buildmanifest.json +965 -0
  73. package/dist/kenyaemr-esm-service-queues-app.js.map +1 -0
  74. package/dist/main.js +2 -0
  75. package/dist/main.js.LICENSE.txt +60 -0
  76. package/dist/main.js.map +1 -0
  77. package/dist/routes.json +1 -0
  78. package/jest.config.js +3 -0
  79. package/package.json +54 -0
  80. package/src/active-visits/active-visits-row-actions.component.tsx +25 -0
  81. package/src/active-visits/active-visits-row-actions.scss +4 -0
  82. package/src/active-visits/active-visits-table.resource.ts +273 -0
  83. package/src/active-visits/change-status-dialog.component.tsx +272 -0
  84. package/src/active-visits/change-status-dialog.scss +47 -0
  85. package/src/active-visits/change-status-dialog.test.tsx +154 -0
  86. package/src/add-patient-toqueue/add-patient-toqueue-dialog.component.tsx +228 -0
  87. package/src/add-patient-toqueue/add-patient-toqueue-dialog.scss +32 -0
  88. package/src/add-provider-queue-room/add-provider-queue-room.component.tsx +238 -0
  89. package/src/add-provider-queue-room/add-provider-queue-room.resource.ts +76 -0
  90. package/src/add-provider-queue-room/add-provider-queue-room.scss +17 -0
  91. package/src/add-provider-queue-room/add-provider-queue-room.test.tsx +105 -0
  92. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.component.tsx +76 -0
  93. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.resource.ts +7 -0
  94. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.scss +8 -0
  95. package/src/clear-queue-entries-dialog/clear-queue-entries-dialog.test.tsx +43 -0
  96. package/src/clear-queue-entries-dialog/clear-queue-entries.component.tsx +43 -0
  97. package/src/config-schema.ts +465 -0
  98. package/src/constants.ts +10 -0
  99. package/src/createDashboardLink.component.tsx +39 -0
  100. package/src/current-visit/current-visit-summary.component.tsx +38 -0
  101. package/src/current-visit/current-visit-summary.test.tsx +43 -0
  102. package/src/current-visit/current-visit.resource.ts +84 -0
  103. package/src/current-visit/current-visit.scss +34 -0
  104. package/src/current-visit/hooks/useVitalsConceptMetadata.tsx +101 -0
  105. package/src/current-visit/visit-details/biometrics-config-schema.ts +14 -0
  106. package/src/current-visit/visit-details/current-visit-details.component.tsx +96 -0
  107. package/src/current-visit/visit-details/triage-note.component.tsx +53 -0
  108. package/src/current-visit/visit-details/triage-note.scss +89 -0
  109. package/src/current-visit/visit-details/vitals-config-schema.ts +17 -0
  110. package/src/current-visit/visit-details/vitals.component.tsx +165 -0
  111. package/src/dashboard.meta.ts +5 -0
  112. package/src/declarations.d.ts +4 -0
  113. package/src/helpers/functions.ts +28 -0
  114. package/src/helpers/helpers.ts +177 -0
  115. package/src/helpers/time-helpers.ts +15 -0
  116. package/src/home.component.tsx +16 -0
  117. package/src/home.test.tsx +48 -0
  118. package/src/hooks/useConcept.ts +13 -0
  119. package/src/hooks/useQueue.ts +10 -0
  120. package/src/hooks/useQueueEntries.ts +187 -0
  121. package/src/hooks/useQueues.ts +22 -0
  122. package/src/hooks/useSystemSetting.ts +18 -0
  123. package/src/index.ts +172 -0
  124. package/src/past-visit/past-visit-details/encounter-list.component.tsx +54 -0
  125. package/src/past-visit/past-visit-details/medications-list.component.tsx +98 -0
  126. package/src/past-visit/past-visit-details/notes-list.component.tsx +41 -0
  127. package/src/past-visit/past-visit-details/past-visit-summary.component.tsx +181 -0
  128. package/src/past-visit/past-visit-details/past-visit-summary.scss +58 -0
  129. package/src/past-visit/past-visit.component.tsx +37 -0
  130. package/src/past-visit/past-visit.resource.ts +83 -0
  131. package/src/past-visit/past-visit.scss +126 -0
  132. package/src/past-visit/past-visit.test.tsx +41 -0
  133. package/src/patient-info/appointment-details.component.tsx +98 -0
  134. package/src/patient-info/appointment-details.scss +34 -0
  135. package/src/patient-info/appointment-details.test.tsx +36 -0
  136. package/src/patient-info/appointments.resource.ts +43 -0
  137. package/src/patient-info/hooks/usePatientAttributes.tsx +42 -0
  138. package/src/patient-info/patient-info.component.tsx +82 -0
  139. package/src/patient-info/patient-info.scss +60 -0
  140. package/src/patient-info/patient-info.test.tsx +43 -0
  141. package/src/patient-queue-header/patient-queue-header.component.tsx +99 -0
  142. package/src/patient-queue-header/patient-queue-header.scss +90 -0
  143. package/src/patient-queue-header/patient-queue-illustration.component.tsx +22 -0
  144. package/src/patient-queue-metrics/clinic-metrics.component.tsx +98 -0
  145. package/src/patient-queue-metrics/clinic-metrics.resource.ts +58 -0
  146. package/src/patient-queue-metrics/clinic-metrics.scss +11 -0
  147. package/src/patient-queue-metrics/clinic-metrics.test.tsx +76 -0
  148. package/src/patient-queue-metrics/metrics-card.component.tsx +68 -0
  149. package/src/patient-queue-metrics/metrics-card.scss +80 -0
  150. package/src/patient-queue-metrics/metrics-header.component.tsx +61 -0
  151. package/src/patient-queue-metrics/metrics-header.scss +26 -0
  152. package/src/patient-queue-metrics/queue-metrics.resource.ts +42 -0
  153. package/src/patient-search/advanced-search.component.tsx +191 -0
  154. package/src/patient-search/advanced-search.scss +154 -0
  155. package/src/patient-search/advanced-search.test.tsx +29 -0
  156. package/src/patient-search/basic-search.component.tsx +112 -0
  157. package/src/patient-search/basic-search.scss +139 -0
  158. package/src/patient-search/basic-search.test.tsx +23 -0
  159. package/src/patient-search/empty-data-illustration.component.tsx +41 -0
  160. package/src/patient-search/hooks/useActivePatientEnrollment.tsx +29 -0
  161. package/src/patient-search/hooks/useDefaultLocation.ts +14 -0
  162. package/src/patient-search/hooks/usePatients.tsx +25 -0
  163. package/src/patient-search/hooks/useQueueLocations.tsx +23 -0
  164. package/src/patient-search/hooks/useRecommendedVisitTypes.tsx +35 -0
  165. package/src/patient-search/hooks/useScheduledVisits.ts +52 -0
  166. package/src/patient-search/patient-scheduled-visits.component.tsx +324 -0
  167. package/src/patient-search/patient-scheduled-visits.scss +131 -0
  168. package/src/patient-search/patient-scheduled-visits.test.tsx +44 -0
  169. package/src/patient-search/patient-search.scss +43 -0
  170. package/src/patient-search/patient-search.workspace.tsx +135 -0
  171. package/src/patient-search/search-illustration.component.tsx +27 -0
  172. package/src/patient-search/search-results.component.tsx +75 -0
  173. package/src/patient-search/search-results.scss +80 -0
  174. package/src/patient-search/search-results.test.tsx +77 -0
  175. package/src/patient-search/search.resource.ts +10 -0
  176. package/src/patient-search/visit-form/existing-visit-form.component.tsx +112 -0
  177. package/src/patient-search/visit-form/queue.resource.ts +64 -0
  178. package/src/patient-search/visit-form/visit-form.component.tsx +344 -0
  179. package/src/patient-search/visit-form/visit-form.scss +73 -0
  180. package/src/patient-search/visit-form/visit-type-selector.component.tsx +155 -0
  181. package/src/patient-search/visit-form/visit-type-selector.scss +100 -0
  182. package/src/patient-search/visit-form/visit-type-selector.test.tsx +83 -0
  183. package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.component.tsx +178 -0
  184. package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.scss +19 -0
  185. package/src/patient-search/visit-form-queue-fields/visit-form-queue-fields.test.tsx +63 -0
  186. package/src/queue-entry-table-components/edit-entry.scss +14 -0
  187. package/src/queue-entry-table-components/queue-duration.component.tsx +41 -0
  188. package/src/queue-entry-table-components/queue-priority.component.tsx +38 -0
  189. package/src/queue-entry-table-components/queue-priority.scss +12 -0
  190. package/src/queue-entry-table-components/queue-status.component.tsx +39 -0
  191. package/src/queue-entry-table-components/transition-entry.component.tsx +55 -0
  192. package/src/queue-entry-table-components/transition-entry.scss +22 -0
  193. package/src/queue-patient-linelists/queue-linelist-base-table.component.tsx +241 -0
  194. package/src/queue-patient-linelists/queue-linelist-base-table.scss +110 -0
  195. package/src/queue-patient-linelists/queue-linelist-base-table.test.tsx +93 -0
  196. package/src/queue-patient-linelists/queue-linelist-filter.scss +63 -0
  197. package/src/queue-patient-linelists/queue-linelist-filter.test.tsx +94 -0
  198. package/src/queue-patient-linelists/queue-linelist-filter.workspace.tsx +185 -0
  199. package/src/queue-patient-linelists/queue-linelist.resource.ts +84 -0
  200. package/src/queue-patient-linelists/queue-services-table.component.tsx +63 -0
  201. package/src/queue-patient-linelists/scheduled-appointments-table.component.tsx +305 -0
  202. package/src/queue-patient-linelists/scheduled-appointments-table.test.tsx +41 -0
  203. package/src/queue-rooms/queue-room-form.scss +56 -0
  204. package/src/queue-rooms/queue-room-form.test.tsx +80 -0
  205. package/src/queue-rooms/queue-room-form.workspace.tsx +169 -0
  206. package/src/queue-rooms/queue-room.resource.ts +20 -0
  207. package/src/queue-screen/queue-screen.component.tsx +47 -0
  208. package/src/queue-screen/queue-screen.scss +39 -0
  209. package/src/queue-screen/queue-screen.test.tsx +51 -0
  210. package/src/queue-screen/useActiveTickets.tsx +13 -0
  211. package/src/queue-services/queue-service-form.scss +61 -0
  212. package/src/queue-services/queue-service-form.test.tsx +60 -0
  213. package/src/queue-services/queue-service-form.workspace.tsx +179 -0
  214. package/src/queue-services/queue-service.resource.ts +33 -0
  215. package/src/queue-table/cells/columns.resource.ts +135 -0
  216. package/src/queue-table/cells/queue-table-action-cell.component.tsx +88 -0
  217. package/src/queue-table/cells/queue-table-action-cell.scss +7 -0
  218. package/src/queue-table/cells/queue-table-coming-from-cell.component.tsx +13 -0
  219. package/src/queue-table/cells/queue-table-extension-cell.component.tsx +16 -0
  220. package/src/queue-table/cells/queue-table-name-cell.component.tsx +20 -0
  221. package/src/queue-table/cells/queue-table-patient-age-cell.component.tsx +18 -0
  222. package/src/queue-table/cells/queue-table-patient-identifier-cell.component.tsx +25 -0
  223. package/src/queue-table/cells/queue-table-priority-cell.component.tsx +23 -0
  224. package/src/queue-table/cells/queue-table-queue-name-cell.component.tsx +14 -0
  225. package/src/queue-table/cells/queue-table-status-cell.component.tsx +18 -0
  226. package/src/queue-table/cells/queue-table-visit-attribute-queue-number-cell.component.tsx +37 -0
  227. package/src/queue-table/cells/queue-table-visit-start-time-cell.component.tsx +20 -0
  228. package/src/queue-table/cells/queue-table-wait-time-cell.component.tsx +17 -0
  229. package/src/queue-table/default-queue-table.component.tsx +174 -0
  230. package/src/queue-table/default-queue-table.test.tsx +131 -0
  231. package/src/queue-table/queue-entry-actions/edit-queue-entry-modal.component.tsx +52 -0
  232. package/src/queue-table/queue-entry-actions/end-queue-entry-modal.component.tsx +39 -0
  233. package/src/queue-table/queue-entry-actions/queue-entry-actions-modal.component.tsx +362 -0
  234. package/src/queue-table/queue-entry-actions/queue-entry-actions-modal.test.tsx +152 -0
  235. package/src/queue-table/queue-entry-actions/queue-entry-actions.resource.ts +83 -0
  236. package/src/queue-table/queue-entry-actions/queue-entry-actons-modal.scss +36 -0
  237. package/src/queue-table/queue-entry-actions/queue-entry-confirm-action-modal.component.tsx +97 -0
  238. package/src/queue-table/queue-entry-actions/queue-entry-confirm-action-modal.test.tsx +106 -0
  239. package/src/queue-table/queue-entry-actions/queue-entry-undo-actions-modal.test.tsx +76 -0
  240. package/src/queue-table/queue-entry-actions/transition-queue-entry-modal.component.tsx +51 -0
  241. package/src/queue-table/queue-entry-actions/undo-transition-queue-entry-modal.component.tsx +58 -0
  242. package/src/queue-table/queue-entry-actions/void-queue-entry-modal.component.tsx +34 -0
  243. package/src/queue-table/queue-table-by-status-menu.component.tsx +42 -0
  244. package/src/queue-table/queue-table-by-status-menu.scss +11 -0
  245. package/src/queue-table/queue-table-by-status-skeleton.component.tsx +32 -0
  246. package/src/queue-table/queue-table-by-status.component.tsx +96 -0
  247. package/src/queue-table/queue-table-expanded-row.component.tsx +29 -0
  248. package/src/queue-table/queue-table-metrics-card.component.tsx +50 -0
  249. package/src/queue-table/queue-table-metrics-card.scss +48 -0
  250. package/src/queue-table/queue-table-metrics.component.tsx +30 -0
  251. package/src/queue-table/queue-table-metrics.scss +11 -0
  252. package/src/queue-table/queue-table.component.tsx +179 -0
  253. package/src/queue-table/queue-table.scss +192 -0
  254. package/src/queue-table/queue-table.test.tsx +210 -0
  255. package/src/remove-queue-entry-dialog/remove-queue-entry.component.tsx +87 -0
  256. package/src/remove-queue-entry-dialog/remove-queue-entry.resource.ts +93 -0
  257. package/src/remove-queue-entry-dialog/remove-queue-entry.scss +7 -0
  258. package/src/remove-queue-entry-dialog/remove-queue-entry.test.tsx +45 -0
  259. package/src/root.component.tsx +28 -0
  260. package/src/root.scss +15 -0
  261. package/src/root.test.tsx +24 -0
  262. package/src/routes.json +133 -0
  263. package/src/side-menu/nav-group/createNavGroup.tsx +17 -0
  264. package/src/side-menu/nav-group/nav-group.component.tsx +24 -0
  265. package/src/side-menu/nav-group/nav-group.test.tsx +32 -0
  266. package/src/side-menu/nav-group/nav-group.ts +10 -0
  267. package/src/side-menu/side-menu.component.tsx +6 -0
  268. package/src/side-menu/side-menu.test.tsx +17 -0
  269. package/src/transition-queue-entry/transition-queue-entry-dialog.component.tsx +134 -0
  270. package/src/transition-queue-entry/transition-queue-entry-dialog.scss +12 -0
  271. package/src/transition-queue-entry/transition-queue-entry-dialog.test.tsx +102 -0
  272. package/src/transition-queue-entry/transition-queue-entry.resource.ts +16 -0
  273. package/src/types/index.ts +494 -0
  274. package/src/views/queue-table-by-status-view.component.tsx +25 -0
  275. package/src/views/queue-tables-for-all-statuses.component.tsx +150 -0
  276. package/src/visits-missing-inqueue/visits-missing-inqueue.component.tsx +277 -0
  277. package/src/visits-missing-inqueue/visits-missing-inqueue.resource.ts +93 -0
  278. package/src/visits-missing-inqueue/visits-missing-inqueue.scss +108 -0
  279. package/translations/am.json +295 -0
  280. package/translations/ar.json +295 -0
  281. package/translations/en.json +305 -0
  282. package/translations/es.json +295 -0
  283. package/translations/fr.json +295 -0
  284. package/translations/he.json +295 -0
  285. package/translations/km.json +295 -0
  286. package/translations/zh.json +295 -0
  287. package/translations/zh_CN.json +295 -0
  288. package/tsconfig.json +5 -0
  289. package/webpack.config.js +1 -0
@@ -0,0 +1,191 @@
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
+ import { datePickerFormat, datePickerPlaceHolder } from '../constants';
22
+
23
+ interface PatientSearchProps {
24
+ toggleSearchType: (searchMode: SearchTypes) => void;
25
+ }
26
+
27
+ enum fieldMatcherRange {
28
+ ANY = 'any',
29
+ ALL = 'all',
30
+ }
31
+
32
+ enum genders {
33
+ ANY = 'any',
34
+ MALE = 'male',
35
+ FEMALE = 'female',
36
+ }
37
+
38
+ const AdvancedSearch: React.FC<PatientSearchProps> = ({ toggleSearchType }) => {
39
+ const { t } = useTranslation();
40
+ const isTablet = useLayoutType() === 'tablet';
41
+ const [firstName, setFirstName] = useState('');
42
+ const [middleName, setMiddleName] = useState('');
43
+ const [lastName, setLastName] = useState('');
44
+ const [gender, setGender] = useState('');
45
+ const [dateOfBirth, setDateOfBirth] = useState('');
46
+ const [phoneNumber, setPhoneNumber] = useState('');
47
+ const [postCode, setPostCode] = useState('');
48
+ const [lastVisitDate, setLastVisitDate] = useState('');
49
+ const [fieldMatcherRangeSwitcherValue, setFieldMatcherRangeSwitcherValue] = useState(0);
50
+ const [genderSwitcherValue, setGenderSwitcherValue] = useState(0);
51
+ const [searchParams, setSearchParams] = useState([]);
52
+ const [open, setOpen] = useState(false);
53
+
54
+ const handleSearch = () => {
55
+ setSearchParams([firstName, middleName, lastName, gender, dateOfBirth, phoneNumber, postCode, lastVisitDate]);
56
+ };
57
+
58
+ return (
59
+ <Form onSubmit={handleSearch} className={styles.form}>
60
+ <div>
61
+ <div className={styles.backButton}>
62
+ <Button
63
+ kind="ghost"
64
+ renderIcon={(props) => <ArrowLeft size={24} {...props} />}
65
+ iconDescription="Back to simple search"
66
+ size="sm"
67
+ onClick={() => toggleSearchType(SearchTypes.BASIC)}>
68
+ <span>{t('backToSimpleSearch', 'Back to simple search')}</span>
69
+ </Button>
70
+ </div>
71
+ <Stack gap={4} className={styles.grid}>
72
+ <Column>
73
+ <div className={styles.contentSwitcherContainer}>
74
+ <span>{t('match', 'Match')}</span>
75
+ <ContentSwitcher
76
+ size="sm"
77
+ className={styles.fieldRangeSwitcher}
78
+ onChange={({ index }) => setFieldMatcherRangeSwitcherValue(index)}>
79
+ <Switch name={fieldMatcherRange.ANY} text={t('any', 'Any')} />
80
+ <Switch name={fieldMatcherRange.ALL} text={t('all', 'All')} />
81
+ </ContentSwitcher>
82
+ <span>{t('fields', 'of the following fields')}:</span>
83
+ </div>
84
+ </Column>
85
+
86
+ <Column>
87
+ <h3 className={styles.heading}>{t('name', 'Name')}</h3>
88
+ <Layer>
89
+ <TextInput
90
+ className={styles.input}
91
+ id="firstName"
92
+ labelText={t('firstName', 'First name')}
93
+ onChange={(event) => setFirstName(event.target.value)}
94
+ value={firstName}
95
+ />
96
+ </Layer>
97
+ <Layer>
98
+ <TextInput
99
+ className={styles.input}
100
+ id="middleName"
101
+ labelText={t('middleName', 'Middle name')}
102
+ onChange={(event) => setMiddleName(event.target.value)}
103
+ value={middleName}
104
+ />
105
+ </Layer>
106
+ <Layer>
107
+ <TextInput
108
+ className={styles.input}
109
+ id="lastName"
110
+ labelText={t('lastName', 'Last name')}
111
+ onChange={(event) => setLastName(event.target.value)}
112
+ value={lastName}
113
+ />
114
+ </Layer>
115
+ </Column>
116
+ <span className={styles.spacer} />
117
+
118
+ <Column>
119
+ <h3 className={styles.heading}>{t('personalDetails', 'Personal details')}</h3>
120
+ <FormGroup legendText={t('sex', 'Sex')}>
121
+ <ContentSwitcher
122
+ size="sm"
123
+ className={styles.genderSwitcher}
124
+ onChange={({ index }) => setGenderSwitcherValue(index)}>
125
+ <Switch name={genders.ANY} text={t('any', 'Any')} />
126
+ <Switch name={genders.MALE} text={t('male', 'Male')} />
127
+ <Switch name={genders.FEMALE} text={t('female', 'Female')} />
128
+ </ContentSwitcher>
129
+ </FormGroup>
130
+ <Layer>
131
+ <DatePicker datePickerType="single" dateFormat={datePickerFormat}>
132
+ <DatePickerInput
133
+ id="dateOfBirth"
134
+ placeholder={datePickerPlaceHolder}
135
+ labelText={t('dateOfBirth', 'Date of birth')}
136
+ onChange={(event) => setDateOfBirth(event.target.value)}
137
+ type="date"
138
+ />
139
+ </DatePicker>
140
+ </Layer>
141
+ <Layer>
142
+ <TextInput
143
+ className={styles.input}
144
+ id="phoneNumber"
145
+ labelText={t('phoneNumber', 'Phone number')}
146
+ onChange={(event) => setPhoneNumber(event.target.value)}
147
+ value={phoneNumber}
148
+ />
149
+ </Layer>
150
+ <Layer>
151
+ <TextInput
152
+ className={styles.input}
153
+ id="postCode"
154
+ labelText={t('postCode', 'Post code')}
155
+ onChange={(event) => setPostCode(event.target.value)}
156
+ value={postCode}
157
+ />
158
+ </Layer>
159
+ </Column>
160
+ <span className={styles.spacer} />
161
+
162
+ <Column>
163
+ <h3 className={styles.heading}>{t('lastVisit', 'Last visit')}</h3>
164
+ <Layer>
165
+ <DatePicker datePickerType="single" dateFormat={datePickerFormat}>
166
+ <DatePickerInput
167
+ id="lastVisitDate"
168
+ placeholder={datePickerPlaceHolder}
169
+ labelText={t('lastVisitDate', 'Date')}
170
+ onChange={(event) => setLastVisitDate(event.target.value)}
171
+ type="date"
172
+ width={'120px'}
173
+ />
174
+ </DatePicker>
175
+ </Layer>
176
+ </Column>
177
+ </Stack>
178
+ </div>
179
+ <ButtonSet className={isTablet ? styles.tablet : styles.desktop}>
180
+ <Button className={styles.button} kind="secondary" onClick={() => toggleSearchType(SearchTypes.BASIC)}>
181
+ {t('cancel', 'Cancel')}
182
+ </Button>
183
+ <Button className={styles.button} kind="primary" type="submit">
184
+ {t('search', 'Search')}
185
+ </Button>
186
+ </ButtonSet>
187
+ </Form>
188
+ );
189
+ };
190
+
191
+ 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
+ }
@@ -0,0 +1,41 @@
1
+ import * as React from 'react';
2
+
3
+ const EmptyDataIllustration = ({ width = '61', height = '59' }) => {
4
+ return (
5
+ <svg width={width} height={height} viewBox="0 0 61 59">
6
+ <title>Empty data illustration</title>
7
+ <g fill="none" fillRule="evenodd">
8
+ <path
9
+ d="M38.133 13.186H21.947c-.768.001-1.39.623-1.39 1.391V50.55l-.186.057-3.97 1.216a.743.743 0 01-.927-.493L3.664 12.751a.742.742 0 01.492-.926l6.118-1.874 17.738-5.43 6.119-1.873a.741.741 0 01.926.492L38.076 13l.057.186z"
10
+ fill="#E0E0E0"
11
+ />
12
+ <path
13
+ d="M41.664 13L38.026 1.117A1.576 1.576 0 0036.056.07l-8.601 2.633-17.737 5.43-8.603 2.634a1.578 1.578 0 00-1.046 1.97l12.436 40.616a1.58 1.58 0 001.969 1.046l5.897-1.805.185-.057v-.194l-.185.057-5.952 1.822a1.393 1.393 0 01-1.737-.923L.247 12.682a1.39 1.39 0 01.923-1.738L9.772 8.31 27.51 2.881 36.112.247a1.393 1.393 0 011.737.923L41.47 13l.057.186h.193l-.057-.185z"
14
+ fill="#8D8D8D"
15
+ />
16
+ <path
17
+ d="M11.378 11.855a.836.836 0 01-.798-.59L9.385 7.361a.835.835 0 01.554-1.042l16.318-4.996a.836.836 0 011.042.554l1.195 3.902a.836.836 0 01-.554 1.043l-16.318 4.995a.831.831 0 01-.244.037z"
18
+ fill="#C6C6C6"
19
+ />
20
+ <circle fill="#C6C6C6" cx={17.636} cy={2.314} r={1.855} />
21
+ <circle fill="#FFF" fillRule="nonzero" cx={17.636} cy={2.314} r={1.175} />
22
+ <path
23
+ d="M55.893 53.995H24.544a.79.79 0 01-.788-.789V15.644a.79.79 0 01.788-.788h31.349a.79.79 0 01.788.788v37.562a.79.79 0 01-.788.789z"
24
+ fill="#E0E0E0"
25
+ />
26
+ <path
27
+ d="M41.47 13H21.948a1.579 1.579 0 00-1.576 1.577V52.4l.185-.057V14.577c.001-.768.623-1.39 1.391-1.39h19.581L41.471 13zm17.02 0H21.947a1.579 1.579 0 00-1.576 1.577v42.478c0 .87.706 1.576 1.576 1.577H58.49a1.579 1.579 0 001.576-1.577V14.577a1.579 1.579 0 00-1.576-1.576zm1.39 44.055c0 .768-.622 1.39-1.39 1.392H21.947c-.768-.001-1.39-.624-1.39-1.392V14.577c0-.768.622-1.39 1.39-1.39H58.49c.768 0 1.39.622 1.39 1.39v42.478z"
28
+ fill="#8D8D8D"
29
+ />
30
+ <path
31
+ d="M48.751 17.082H31.686a.836.836 0 01-.835-.835v-4.081c0-.46.374-.834.835-.835H48.75c.461 0 .834.374.835.835v4.08c0 .462-.374.835-.835.836z"
32
+ fill="#C6C6C6"
33
+ />
34
+ <circle fill="#C6C6C6" cx={40.218} cy={9.755} r={1.855} />
35
+ <circle fill="#FFF" fillRule="nonzero" cx={40.218} cy={9.755} r={1.13} />
36
+ </g>
37
+ </svg>
38
+ );
39
+ };
40
+
41
+ export default EmptyDataIllustration;