@kenyaemr/esm-ward-app 8.1.2-pre.210 → 8.5.1-pre.13

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 (350) hide show
  1. package/.turbo/turbo-build.log +25 -35
  2. package/README.md +38 -0
  3. package/dist/1119.js +1 -0
  4. package/dist/1197.js +1 -0
  5. package/dist/1663.js +1 -0
  6. package/dist/1663.js.map +1 -0
  7. package/dist/1741.js +1 -0
  8. package/dist/1741.js.map +1 -0
  9. package/dist/1776.js +1 -0
  10. package/dist/1776.js.map +1 -0
  11. package/dist/1899.js +1 -0
  12. package/dist/1899.js.map +1 -0
  13. package/dist/2146.js +1 -0
  14. package/dist/2372.js +1 -0
  15. package/dist/2372.js.map +1 -0
  16. package/dist/2470.js +1 -0
  17. package/dist/2470.js.map +1 -0
  18. package/dist/2499.js +2 -0
  19. package/dist/{372.js.LICENSE.txt → 2499.js.LICENSE.txt} +2 -2
  20. package/dist/2499.js.map +1 -0
  21. package/dist/2537.js +1 -0
  22. package/dist/2537.js.map +1 -0
  23. package/dist/2557.js +1 -0
  24. package/dist/2557.js.map +1 -0
  25. package/dist/2690.js +1 -0
  26. package/dist/2728.js +2 -0
  27. package/dist/{649.js.LICENSE.txt → 2728.js.LICENSE.txt} +2 -2
  28. package/dist/2728.js.map +1 -0
  29. package/dist/2775.js +2 -0
  30. package/dist/2775.js.LICENSE.txt +59 -0
  31. package/dist/2775.js.map +1 -0
  32. package/dist/2904.js +2 -0
  33. package/dist/2904.js.LICENSE.txt +15 -0
  34. package/dist/2904.js.map +1 -0
  35. package/dist/2913.js +2 -0
  36. package/dist/2913.js.map +1 -0
  37. package/dist/2932.js +1 -0
  38. package/dist/2932.js.map +1 -0
  39. package/dist/2941.js +1 -0
  40. package/dist/2941.js.map +1 -0
  41. package/dist/2948.js +1 -0
  42. package/dist/2948.js.map +1 -0
  43. package/dist/3099.js +1 -0
  44. package/dist/3103.js +1 -0
  45. package/dist/3103.js.map +1 -0
  46. package/dist/3296.js +2 -0
  47. package/dist/3296.js.LICENSE.txt +9 -0
  48. package/dist/3296.js.map +1 -0
  49. package/dist/3365.js +1 -0
  50. package/dist/3365.js.map +1 -0
  51. package/dist/3373.js +2 -0
  52. package/dist/3373.js.LICENSE.txt +5 -0
  53. package/dist/3373.js.map +1 -0
  54. package/dist/3399.js +1 -0
  55. package/dist/3399.js.map +1 -0
  56. package/dist/3413.js +1 -0
  57. package/dist/3413.js.map +1 -0
  58. package/dist/3584.js +1 -0
  59. package/dist/3737.js +1 -0
  60. package/dist/3737.js.map +1 -0
  61. package/dist/3982.js +1 -0
  62. package/dist/3982.js.map +1 -0
  63. package/dist/4041.js +2 -0
  64. package/dist/4041.js.map +1 -0
  65. package/dist/4055.js +1 -0
  66. package/dist/4132.js +1 -0
  67. package/dist/4300.js +1 -0
  68. package/dist/4335.js +1 -0
  69. package/dist/4430.js +2 -0
  70. package/dist/4430.js.LICENSE.txt +29 -0
  71. package/dist/4430.js.map +1 -0
  72. package/dist/4618.js +1 -0
  73. package/dist/4652.js +1 -0
  74. package/dist/4701.js +2 -0
  75. package/dist/4701.js.LICENSE.txt +9 -0
  76. package/dist/4701.js.map +1 -0
  77. package/dist/4944.js +1 -0
  78. package/dist/5173.js +1 -0
  79. package/dist/5241.js +1 -0
  80. package/dist/5442.js +1 -0
  81. package/dist/559.js +1 -1
  82. package/dist/559.js.map +1 -1
  83. package/dist/5661.js +1 -0
  84. package/dist/6012.js +2 -0
  85. package/dist/6012.js.LICENSE.txt +5 -0
  86. package/dist/6012.js.map +1 -0
  87. package/dist/6022.js +1 -0
  88. package/dist/6468.js +1 -0
  89. package/dist/6679.js +1 -0
  90. package/dist/6840.js +1 -0
  91. package/dist/6859.js +1 -0
  92. package/dist/7097.js +1 -0
  93. package/dist/7159.js +1 -0
  94. package/dist/7179.js +2 -0
  95. package/dist/7179.js.LICENSE.txt +9 -0
  96. package/dist/7179.js.map +1 -0
  97. package/dist/723.js +1 -0
  98. package/dist/7232.js +2 -0
  99. package/dist/7232.js.LICENSE.txt +9 -0
  100. package/dist/7232.js.map +1 -0
  101. package/dist/7524.js +1 -0
  102. package/dist/7524.js.map +1 -0
  103. package/dist/7617.js +1 -0
  104. package/dist/7661.js +1 -0
  105. package/dist/7661.js.map +1 -0
  106. package/dist/7886.js +1 -0
  107. package/dist/7886.js.map +1 -0
  108. package/dist/795.js +1 -0
  109. package/dist/8163.js +1 -0
  110. package/dist/8205.js +1 -0
  111. package/dist/8205.js.map +1 -0
  112. package/dist/8349.js +1 -0
  113. package/dist/8501.js +1 -0
  114. package/dist/8501.js.map +1 -0
  115. package/dist/8522.js +1 -0
  116. package/dist/8522.js.map +1 -0
  117. package/dist/8618.js +1 -0
  118. package/dist/8622.js +1 -0
  119. package/dist/8622.js.map +1 -0
  120. package/dist/89.js +1 -0
  121. package/dist/89.js.map +1 -0
  122. package/dist/890.js +1 -0
  123. package/dist/9045.js +1 -0
  124. package/dist/9045.js.map +1 -0
  125. package/dist/9117.js +1 -0
  126. package/dist/9117.js.map +1 -0
  127. package/dist/9214.js +1 -0
  128. package/dist/9538.js +1 -0
  129. package/dist/9569.js +1 -0
  130. package/dist/986.js +1 -0
  131. package/dist/9876.js +2 -0
  132. package/dist/9876.js.LICENSE.txt +9 -0
  133. package/dist/9876.js.map +1 -0
  134. package/dist/9879.js +1 -0
  135. package/dist/9880.js +1 -0
  136. package/dist/9880.js.map +1 -0
  137. package/dist/9895.js +1 -0
  138. package/dist/9900.js +1 -0
  139. package/dist/9913.js +1 -0
  140. package/dist/kenyaemr-esm-ward-app.js +1 -1
  141. package/dist/kenyaemr-esm-ward-app.js.buildmanifest.json +1457 -237
  142. package/dist/kenyaemr-esm-ward-app.js.map +1 -1
  143. package/dist/main.js +1 -1
  144. package/dist/main.js.LICENSE.txt +0 -35
  145. package/dist/main.js.map +1 -1
  146. package/dist/routes.json +1 -1
  147. package/mock.tsx +15 -2
  148. package/package.json +10 -5
  149. package/src/beds/{empty-bed-skeleton.tsx → empty-bed-skeleton.component.tsx} +2 -2
  150. package/src/config-schema.ts +48 -0
  151. package/src/declarations.d.ts +8 -0
  152. package/src/hooks/useAdmissionLocation.ts +22 -1
  153. package/src/hooks/useInpatientAdmission.ts +12 -8
  154. package/src/hooks/useInpatientAdmissionByPatients.ts +29 -0
  155. package/src/hooks/useInpatientRequest.ts +3 -0
  156. package/src/hooks/useInpatientRequestByPatients.ts +34 -0
  157. package/src/hooks/useIpdDischargeEncounter.ts +137 -0
  158. package/src/hooks/usePatientPendingOrders.ts +1 -1
  159. package/src/hooks/useRestPatient.ts +11 -3
  160. package/src/hooks/useWardLocation.test.ts +1 -1
  161. package/src/hooks/useWardLocation.ts +15 -2
  162. package/src/hooks/useWardPatientGrouping.ts +60 -7
  163. package/src/index.ts +24 -4
  164. package/src/location-selector/location-selector.component.tsx +38 -5
  165. package/src/root.component.tsx +2 -2
  166. package/src/routes.json +60 -26
  167. package/src/types/index.ts +17 -6
  168. package/src/ward-patient-card/card-rows/admission-request-note-row.component.tsx +1 -1
  169. package/src/ward-patient-card/card-rows/coded-obs-tags-row.component.tsx +4 -4
  170. package/src/ward-patient-card/card-rows/mother-child-row.component.tsx +6 -6
  171. package/src/ward-patient-card/card-rows/pending-items-row.component.tsx +2 -3
  172. package/src/ward-patient-card/row-elements/{ward-patient-coded-obs-tags.tsx → ward-patient-coded-obs-tags.component.tsx} +5 -5
  173. package/src/ward-patient-card/row-elements/{ward-patient-header-address.tsx → ward-patient-header-address.component.tsx} +2 -2
  174. package/src/ward-patient-card/row-elements/{ward-patient-identifier.tsx → ward-patient-identifier.component.tsx} +7 -1
  175. package/src/ward-patient-card/row-elements/ward-patient-identifier.scss +3 -0
  176. package/src/ward-patient-card/row-elements/{ward-patient-obs.tsx → ward-patient-obs.component.tsx} +5 -5
  177. package/src/ward-patient-card/row-elements/{ward-patient-pending-transfer.tsx → ward-patient-pending-transfer.component.tsx} +3 -5
  178. package/src/ward-patient-card/row-elements/ward-patient-time-on-ward.component.tsx +73 -0
  179. package/src/ward-patient-card/row-elements/ward-patient-time-since-admission.component.tsx +29 -0
  180. package/src/ward-patient-card/ward-patient-card.component.tsx +5 -5
  181. package/src/ward-patient-card/ward-patient-card.scss +2 -6
  182. package/src/ward-patients/admitted-patients.tsx +218 -0
  183. package/src/ward-patients/awaiting-admission-patients.tsx +158 -0
  184. package/src/ward-patients/discharge-in-patients.tsx +183 -0
  185. package/src/ward-patients/discharge-patients.tsx +129 -0
  186. package/src/ward-patients/patient-cells.tsx +75 -0
  187. package/src/ward-patients/table-state-components.tsx +40 -0
  188. package/src/ward-patients/ward-patient.scss +24 -0
  189. package/src/ward-patients/ward-patients-table.tsx +38 -0
  190. package/src/ward-view/default-ward/default-ward-patient-card-header.component.tsx +8 -8
  191. package/src/ward-view/default-ward/default-ward-pending-patients.component.tsx +3 -3
  192. package/src/ward-view/default-ward/default-ward-view.component.tsx +31 -6
  193. package/src/ward-view/linelist-wards/Filters.tsx +25 -0
  194. package/src/ward-view/linelist-wards/Header.tsx +27 -0
  195. package/src/ward-view/linelist-wards/LineListTable.tsx +147 -0
  196. package/src/ward-view/linelist-wards/Metrics.tsx +21 -0
  197. package/src/ward-view/linelist-wards/WardsLineList.tsx +29 -0
  198. package/src/ward-view/linelist-wards/linelist-wards.scss +100 -0
  199. package/src/ward-view/materal-ward/maternal-ward-patient-card-header.component.tsx +8 -8
  200. package/src/ward-view/materal-ward/maternal-ward-patient-card.component.tsx +2 -2
  201. package/src/ward-view/materal-ward/maternal-ward-patient-card.test.tsx +1 -1
  202. package/src/ward-view/materal-ward/maternal-ward-pending-patients.component.tsx +1 -1
  203. package/src/ward-view/materal-ward/maternal-ward-view.component.tsx +4 -4
  204. package/src/ward-view/ward-view-content-wrapper.tsx +36 -0
  205. package/src/ward-view/ward-view.resource.ts +26 -8
  206. package/src/ward-view/ward-view.scss +15 -8
  207. package/src/ward-view/ward-view.test.tsx +8 -8
  208. package/src/ward-view/ward.component.tsx +2 -2
  209. package/src/ward-view-header/admission-requests-bar.component.tsx +18 -8
  210. package/src/ward-view-header/admission-requests-bar.test.tsx +3 -3
  211. package/src/ward-view-header/ward-metric.component.tsx +2 -3
  212. package/src/ward-workspace/admission-request-card/admission-request-card-actions.component.tsx +12 -14
  213. package/src/ward-workspace/admission-request-card/admission-request-card-header.component.tsx +5 -5
  214. package/src/ward-workspace/admission-request-card/admission-request-card.component.tsx +1 -1
  215. package/src/ward-workspace/admission-request-workspace/admission-requests-action-button.extension.tsx +18 -0
  216. package/src/ward-workspace/admission-request-workspace/admission-requests-context.ts +20 -0
  217. package/src/ward-workspace/admission-request-workspace/admission-requests-workspace.test.tsx +7 -6
  218. package/src/ward-workspace/admission-request-workspace/admission-requests.workspace.tsx +15 -25
  219. package/src/ward-workspace/admit-patient-button.component.tsx +41 -18
  220. package/src/ward-workspace/admit-patient-form-workspace/admit-patient-form.test.tsx +14 -16
  221. package/src/ward-workspace/admit-patient-form-workspace/admit-patient-form.workspace.tsx +2 -2
  222. package/src/ward-workspace/bed-selector.component.tsx +1 -1
  223. package/src/ward-workspace/cancel-admission-request-workspace/cancel-admission-request.test.tsx +1 -1
  224. package/src/ward-workspace/cancel-admission-request-workspace/cancel-admission-request.workspace.tsx +4 -6
  225. package/src/ward-workspace/create-admission-encounter/create-admission-encounter-action-button.extension.tsx +46 -0
  226. package/src/ward-workspace/create-admission-encounter/create-admission-encounter.test.tsx +241 -0
  227. package/src/ward-workspace/create-admission-encounter/create-admission-encounter.workspace.tsx +152 -0
  228. package/src/ward-workspace/kenya-emr-patient-discharge/discharge-workspace-siderail.component.tsx +23 -0
  229. package/src/ward-workspace/kenya-emr-patient-discharge/patient-discharge.resource.tsx +123 -0
  230. package/src/ward-workspace/kenya-emr-patient-discharge/patient-discharge.workspace.tsx +101 -0
  231. package/src/ward-workspace/patient-discharge/patient-discharge.workspace.tsx +6 -15
  232. package/src/ward-workspace/patient-transfer-bed-swap/{patient-transfer-request-form.component.tsx → patient-admit-or-transfer-request-form.component.tsx} +56 -37
  233. package/src/ward-workspace/patient-transfer-bed-swap/patient-bed-swap-form.component.tsx +13 -3
  234. package/src/ward-workspace/patient-transfer-bed-swap/patient-transfer-swap.workspace.tsx +11 -5
  235. package/src/ward-workspace/patient-transfer-request-workspace/patient-transfer-request.scss +5 -0
  236. package/src/ward-workspace/patient-transfer-request-workspace/patient-transfer-request.workspace.tsx +20 -6
  237. package/src/ward-workspace/ward-patient-notes/form/notes-form.component.tsx +2 -1
  238. package/src/ward-workspace/ward-patient-notes/history/note.component.tsx +3 -3
  239. package/src/ward.resource.ts +9 -3
  240. package/translations/am.json +123 -0
  241. package/translations/ar.json +123 -0
  242. package/translations/ar_SY.json +123 -0
  243. package/translations/bn.json +123 -0
  244. package/translations/de.json +123 -0
  245. package/translations/en.json +31 -3
  246. package/translations/en_US.json +123 -0
  247. package/translations/es.json +123 -0
  248. package/translations/es_MX.json +123 -0
  249. package/translations/fr.json +123 -0
  250. package/translations/he.json +123 -0
  251. package/translations/hi.json +123 -0
  252. package/translations/hi_IN.json +123 -0
  253. package/translations/id.json +123 -0
  254. package/translations/it.json +123 -0
  255. package/translations/ka.json +123 -0
  256. package/translations/km.json +123 -0
  257. package/translations/ku.json +123 -0
  258. package/translations/ky.json +123 -0
  259. package/translations/lg.json +123 -0
  260. package/translations/ne.json +123 -0
  261. package/translations/pl.json +123 -0
  262. package/translations/pt.json +123 -0
  263. package/translations/pt_BR.json +123 -0
  264. package/translations/qu.json +123 -0
  265. package/translations/ro_RO.json +123 -0
  266. package/translations/ru_RU.json +123 -0
  267. package/translations/si.json +123 -0
  268. package/translations/sw.json +123 -0
  269. package/translations/sw_KE.json +123 -0
  270. package/translations/tr.json +123 -0
  271. package/translations/tr_TR.json +123 -0
  272. package/translations/uk.json +123 -0
  273. package/translations/uz.json +123 -0
  274. package/translations/uz@Latn.json +123 -0
  275. package/translations/uz_UZ.json +123 -0
  276. package/translations/vi.json +123 -0
  277. package/translations/zh.json +123 -0
  278. package/translations/zh_CN.json +123 -0
  279. package/dist/109.js +0 -1
  280. package/dist/109.js.map +0 -1
  281. package/dist/124.js +0 -1
  282. package/dist/124.js.map +0 -1
  283. package/dist/125.js +0 -1
  284. package/dist/125.js.map +0 -1
  285. package/dist/126.js +0 -1
  286. package/dist/126.js.map +0 -1
  287. package/dist/130.js +0 -2
  288. package/dist/130.js.LICENSE.txt +0 -5
  289. package/dist/130.js.map +0 -1
  290. package/dist/146.js +0 -1
  291. package/dist/146.js.map +0 -1
  292. package/dist/15.js +0 -1
  293. package/dist/15.js.map +0 -1
  294. package/dist/325.js +0 -1
  295. package/dist/325.js.map +0 -1
  296. package/dist/348.js +0 -1
  297. package/dist/348.js.map +0 -1
  298. package/dist/362.js +0 -1
  299. package/dist/362.js.map +0 -1
  300. package/dist/372.js +0 -2
  301. package/dist/372.js.map +0 -1
  302. package/dist/443.js +0 -1
  303. package/dist/443.js.map +0 -1
  304. package/dist/471.js +0 -1
  305. package/dist/471.js.map +0 -1
  306. package/dist/481.js +0 -1
  307. package/dist/481.js.map +0 -1
  308. package/dist/53.js +0 -1
  309. package/dist/53.js.map +0 -1
  310. package/dist/574.js +0 -1
  311. package/dist/576.js +0 -1
  312. package/dist/576.js.map +0 -1
  313. package/dist/577.js +0 -1
  314. package/dist/577.js.map +0 -1
  315. package/dist/591.js +0 -2
  316. package/dist/591.js.map +0 -1
  317. package/dist/598.js +0 -1
  318. package/dist/598.js.map +0 -1
  319. package/dist/649.js +0 -2
  320. package/dist/649.js.map +0 -1
  321. package/dist/662.js +0 -1
  322. package/dist/662.js.map +0 -1
  323. package/dist/767.js +0 -1
  324. package/dist/767.js.map +0 -1
  325. package/dist/784.js +0 -2
  326. package/dist/784.js.map +0 -1
  327. package/dist/921.js +0 -1
  328. package/dist/921.js.map +0 -1
  329. package/dist/922.js +0 -1
  330. package/dist/922.js.map +0 -1
  331. package/dist/925.js +0 -2
  332. package/dist/925.js.LICENSE.txt +0 -40
  333. package/dist/925.js.map +0 -1
  334. package/dist/940.js +0 -1
  335. package/dist/940.js.map +0 -1
  336. package/dist/969.js +0 -1
  337. package/dist/969.js.map +0 -1
  338. package/dist/983.js +0 -1
  339. package/dist/983.js.map +0 -1
  340. package/package-lock.json +0 -5001
  341. package/src/ward-patient-card/row-elements/ward-patient-time-on-ward.tsx +0 -22
  342. package/src/ward-patient-card/row-elements/ward-patient-time-since-admission.tsx +0 -22
  343. /package/dist/{591.js.LICENSE.txt → 2913.js.LICENSE.txt} +0 -0
  344. /package/dist/{784.js.LICENSE.txt → 4041.js.LICENSE.txt} +0 -0
  345. /package/src/ward-patient-card/row-elements/{ward-patient-age.tsx → ward-patient-age.component.tsx} +0 -0
  346. /package/src/ward-patient-card/row-elements/{ward-patient-bed-number.tsx → ward-patient-bed-number.component.tsx} +0 -0
  347. /package/src/ward-patient-card/row-elements/{ward-patient-location.tsx → ward-patient-location.component.tsx} +0 -0
  348. /package/src/ward-patient-card/row-elements/{ward-patient-name.tsx → ward-patient-name.component.tsx} +0 -0
  349. /package/src/ward-patient-card/row-elements/{ward-patient-responsive-tooltip.tsx → ward-patient-responsive-tooltip.component.tsx} +0 -0
  350. /package/src/ward-patient-card/row-elements/{ward-patient-skeleton-text.tsx → ward-patient-skeleton-text.component.tsx} +0 -0
@@ -1,19 +1,20 @@
1
- import { useAppContext } from '@openmrs/esm-framework';
2
- import { screen } from '@testing-library/react';
3
1
  import React from 'react';
4
- import { renderWithSwr } from '../../../../../tools';
2
+ import { screen } from '@testing-library/react';
3
+ import { useAppContext } from '@openmrs/esm-framework';
4
+ import { renderWithSwr } from 'tools';
5
5
  import { mockWardViewContext } from '../../../mock';
6
- import useEmrConfiguration from '../../hooks/useEmrConfiguration';
6
+ import { type AdmissionRequestsWorkspaceContextProps } from './admission-requests-context';
7
7
  import { type WardViewContext } from '../../types';
8
+ import useEmrConfiguration from '../../hooks/useEmrConfiguration';
8
9
  import DefaultWardPendingPatients from '../../ward-view/default-ward/default-ward-pending-patients.component';
9
- import AdmissionRequestsWorkspace, { type AdmissionRequestsWorkspaceProps } from './admission-requests.workspace';
10
+ import AdmissionRequestsWorkspace from './admission-requests.workspace';
10
11
 
11
12
  jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
12
13
 
13
14
  jest.mock('../../hooks/useEmrConfiguration', () => jest.fn());
14
15
  const mockedUseEmrConfiguration = jest.mocked(useEmrConfiguration);
15
16
 
16
- const workspaceProps: AdmissionRequestsWorkspaceProps = {
17
+ const workspaceProps: AdmissionRequestsWorkspaceContextProps = {
17
18
  closeWorkspace: jest.fn(),
18
19
  promptBeforeClosing: jest.fn(),
19
20
  closeWorkspaceWithSavedChanges: jest.fn(),
@@ -1,35 +1,23 @@
1
- import { InlineNotification, Search } from '@carbon/react';
2
- import { type DefaultWorkspaceProps } from '@openmrs/esm-framework';
3
- import React, { createContext, type ReactNode } from 'react';
1
+ import React from 'react';
4
2
  import { useTranslation } from 'react-i18next';
3
+ import { InlineNotification } from '@carbon/react';
4
+ import { useAppContext } from '@openmrs/esm-framework';
5
+ import { type WardViewContext } from '../../types';
6
+ import {
7
+ AdmissionRequestsWorkspaceContextProvider,
8
+ type AdmissionRequestsWorkspaceContextProps,
9
+ } from './admission-requests-context';
5
10
  import useEmrConfiguration from '../../hooks/useEmrConfiguration';
6
11
  import styles from './admission-requests-workspace.scss';
7
12
 
8
- export interface AdmissionRequestsWorkspaceProps extends DefaultWorkspaceProps {
9
- wardPendingPatients: ReactNode;
10
- }
11
-
12
- export const AdmissionRequestsWorkspaceContext = createContext<AdmissionRequestsWorkspaceProps>(null);
13
-
14
- const AdmissionRequestsWorkspace: React.FC<AdmissionRequestsWorkspaceProps> = (props) => {
15
- const { wardPendingPatients } = props;
13
+ const AdmissionRequestsWorkspace: React.FC<AdmissionRequestsWorkspaceContextProps> = ({ wardPendingPatients }) => {
16
14
  const { t } = useTranslation();
17
- const [searchTerm, setSearchTerm] = React.useState('');
18
- const handleSearch = (event: React.ChangeEvent<HTMLInputElement>) => {
19
- setSearchTerm(event.target.value);
20
- };
21
15
  const { errorFetchingEmrConfiguration } = useEmrConfiguration();
16
+ const { wardPatientGroupDetails } = useAppContext<WardViewContext>('ward-view-context') ?? {};
17
+ const { inpatientRequests, isLoading, error } = wardPatientGroupDetails?.inpatientRequestResponse ?? {};
22
18
 
23
19
  return (
24
20
  <div className={styles.admissionRequestsWorkspaceContainer}>
25
- <Search
26
- labelText=""
27
- value={searchTerm}
28
- onChange={handleSearch}
29
- size="lg"
30
- placeholder={t('searchForPatient', 'Search for a patient')}
31
- disabled
32
- />
33
21
  {errorFetchingEmrConfiguration && (
34
22
  <div className={styles.formError}>
35
23
  <InlineNotification
@@ -44,9 +32,11 @@ const AdmissionRequestsWorkspace: React.FC<AdmissionRequestsWorkspaceProps> = (p
44
32
  />
45
33
  </div>
46
34
  )}
47
- <AdmissionRequestsWorkspaceContext.Provider value={props}>
35
+ {inpatientRequests?.length == 0 && <div>{t('noPendingPatientRequests', 'No pending patient requests')}</div>}
36
+ <AdmissionRequestsWorkspaceContextProvider
37
+ value={{ wardPendingPatients } as unknown as AdmissionRequestsWorkspaceContextProps}>
48
38
  <div className={styles.content}>{wardPendingPatients}</div>
49
- </AdmissionRequestsWorkspaceContext.Provider>
39
+ </AdmissionRequestsWorkspaceContextProvider>
50
40
  </div>
51
41
  );
52
42
  };
@@ -1,4 +1,4 @@
1
- import { Button } from '@carbon/react';
1
+ import { Button, OverflowMenuItem } from '@carbon/react';
2
2
  import {
3
3
  ArrowRightIcon,
4
4
  launchWorkspace,
@@ -10,36 +10,48 @@ import {
10
10
  import React from 'react';
11
11
  import { useTranslation } from 'react-i18next';
12
12
  import useWardLocation from '../hooks/useWardLocation';
13
- import type { WardPatient, WardPatientWorkspaceProps, WardViewContext } from '../types';
13
+ import type { DispositionType, WardPatient, WardPatientWorkspaceProps, WardViewContext } from '../types';
14
14
  import { useAdmitPatient } from '../ward.resource';
15
15
 
16
- interface AdmissionPatientButtonProps {
16
+ interface AdmitPatientButtonProps {
17
17
  wardPatient: WardPatient;
18
+
19
+ /**
20
+ * whether to create an admit or transfer encounter for the given patient
21
+ */
22
+ dispositionType: DispositionType;
18
23
  onAdmitPatientSuccess();
24
+ disabled?: boolean;
25
+ component?: 'btn' | 'menu';
19
26
  }
20
27
 
21
- const AdmissionPatientButton: React.FC<AdmissionPatientButtonProps> = ({ wardPatient, onAdmitPatientSuccess }) => {
22
- const { patient, inpatientRequest, bed } = wardPatient ?? {};
23
- const dispositionType = inpatientRequest?.dispositionType ?? 'ADMIT';
28
+ const AdmitPatientButton: React.FC<AdmitPatientButtonProps> = ({
29
+ wardPatient,
30
+ onAdmitPatientSuccess,
31
+ disabled,
32
+ dispositionType,
33
+ component = 'btn',
34
+ }) => {
35
+ const { patient, visit, bed } = wardPatient ?? {};
24
36
  const { t } = useTranslation();
25
37
  const { location } = useWardLocation();
26
38
  const responsiveSize = useLayoutType() === 'tablet' ? 'lg' : 'md';
27
- const { WardPatientHeader, wardPatientGroupDetails } = useAppContext<WardViewContext>('ward-view-context') ?? {};
39
+ const { wardPatientGroupDetails } = useAppContext<WardViewContext>('ward-view-context') ?? {};
28
40
  const { admitPatient, isLoadingEmrConfiguration, errorFetchingEmrConfiguration } = useAdmitPatient();
29
41
 
30
42
  const launchPatientAdmissionForm = () =>
31
- launchWorkspace<WardPatientWorkspaceProps>('admit-patient-form-workspace', { wardPatient, WardPatientHeader });
43
+ launchWorkspace<WardPatientWorkspaceProps>('admit-patient-form-workspace', { wardPatient });
32
44
 
33
45
  const isBedManagementModuleInstalled = useFeatureFlag('bedmanagement-module');
34
46
 
35
- // If bed management module is installed and the patient does not currently assigned a bed,
47
+ // If bed management module is installed and the patient is not currently assigned a bed,
36
48
  // open the next form for bed selection. If not, admit patient directly
37
49
  // (Note that it is possible, albeit an edge case, for a patient to have a bed assigned while not admitted)
38
50
  const onAdmit = () => {
39
51
  if (isBedManagementModuleInstalled && !bed) {
40
52
  launchPatientAdmissionForm();
41
53
  } else {
42
- admitPatient(patient, dispositionType)
54
+ admitPatient(patient, dispositionType, visit.uuid)
43
55
  .then(
44
56
  (response) => {
45
57
  if (response && response?.ok) {
@@ -67,16 +79,27 @@ const AdmissionPatientButton: React.FC<AdmissionPatientButtonProps> = ({ wardPat
67
79
  }
68
80
  };
69
81
 
82
+ const disabledButton = isLoadingEmrConfiguration || errorFetchingEmrConfiguration || disabled;
83
+
84
+ if (component === 'menu')
85
+ return (
86
+ <OverflowMenuItem
87
+ itemText={
88
+ dispositionType == 'ADMIT' || disabledButton
89
+ ? t('admitPatient', 'Admit patient')
90
+ : t('transferPatient', 'Transfer patient')
91
+ }
92
+ onClick={onAdmit}
93
+ />
94
+ );
95
+
70
96
  return (
71
- <Button
72
- kind="ghost"
73
- renderIcon={ArrowRightIcon}
74
- size={responsiveSize}
75
- disabled={isLoadingEmrConfiguration || errorFetchingEmrConfiguration}
76
- onClick={onAdmit}>
77
- {t('admitPatient', 'Admit patient')}
97
+ <Button kind="ghost" renderIcon={ArrowRightIcon} size={responsiveSize} disabled={disabledButton} onClick={onAdmit}>
98
+ {dispositionType == 'ADMIT' || disabledButton
99
+ ? t('admitPatient', 'Admit patient')
100
+ : t('transferPatient', 'Transfer patient')}
78
101
  </Button>
79
102
  );
80
103
  };
81
104
 
82
- export default AdmissionPatientButton;
105
+ export default AdmitPatientButton;
@@ -1,22 +1,21 @@
1
+ import React from 'react';
2
+ import userEvent from '@testing-library/user-event';
3
+ import { screen } from '@testing-library/react';
1
4
  import {
2
- CloseWorkspaceOptions,
3
5
  type DefaultWorkspaceProps,
4
6
  showSnackbar,
5
7
  useAppContext,
6
8
  useFeatureFlag,
7
9
  useSession,
8
10
  } from '@openmrs/esm-framework';
9
- import { screen } from '@testing-library/react';
10
- import userEvent from '@testing-library/user-event';
11
- import React from 'react';
12
- import { mockInpatientRequestAlice, mockLocationInpatientWard, mockPatientAlice } from '../../../../../__mocks__';
13
- import { renderWithSwr } from '../../../../../tools';
11
+ import { mockInpatientRequestAlice, mockLocationInpatientWard, mockPatientAlice } from '__mocks__';
12
+ import { renderWithSwr } from 'tools';
14
13
  import { mockWardPatientGroupDetails, mockWardViewContext } from '../../../mock';
15
14
  import { useAssignedBedByPatient } from '../../hooks/useAssignedBedByPatient';
16
- import useWardLocation from '../../hooks/useWardLocation';
17
- import type { DispositionType, WardPatient, WardViewContext } from '../../types';
15
+ import type { WardPatient, WardViewContext } from '../../types';
18
16
  import { assignPatientToBed, removePatientFromBed, useAdmitPatient } from '../../ward.resource';
19
17
  import AdmitPatientFormWorkspace from './admit-patient-form.workspace';
18
+ import useWardLocation from '../../hooks/useWardLocation';
20
19
 
21
20
  jest.mock('../../hooks/useAdmissionLocation', () => ({
22
21
  useAdmissionLocation: jest.fn(),
@@ -88,10 +87,8 @@ function renderAdmissionForm() {
88
87
  );
89
88
  }
90
89
 
91
- describe('Testing AdmitPatientForm', () => {
90
+ describe.skip('Testing AdmitPatientForm', () => {
92
91
  beforeEach(() => {
93
- jest.clearAllMocks();
94
-
95
92
  mockedUseSession.mockReturnValue({
96
93
  currentProvider: {
97
94
  uuid: 'current-provider-uuid',
@@ -100,6 +97,7 @@ describe('Testing AdmitPatientForm', () => {
100
97
  authenticated: true,
101
98
  sessionId: 'session-id',
102
99
  });
100
+
103
101
  mockedUseFeatureFlag.mockReturnValue(true);
104
102
 
105
103
  mockedUseWardLocation.mockReturnValue({
@@ -116,7 +114,7 @@ describe('Testing AdmitPatientForm', () => {
116
114
  results: [
117
115
  {
118
116
  bedId: 1,
119
- bedNumber: 1,
117
+ bedNumber: '1',
120
118
  bedType: null,
121
119
  patients: [mockPatientAlice],
122
120
  physicalLocation: mockLocationInpatientWard,
@@ -162,7 +160,7 @@ describe('Testing AdmitPatientForm', () => {
162
160
  expect(screen.getByRole('radio', { name: 'bed4 · Empty' })).toBeInTheDocument();
163
161
  });
164
162
 
165
- it('should block the form if emr configuration is not fetched properly', () => {
163
+ it.skip('should block the form if emr configuration is not fetched properly', () => {
166
164
  mockedUseAdmitPatient.mockReturnValueOnce({
167
165
  admitPatient: mockedAdmitPatient,
168
166
  isLoadingEmrConfiguration: false,
@@ -192,11 +190,11 @@ describe('Testing AdmitPatientForm', () => {
192
190
  const admitButton = screen.getByRole('button', { name: 'Admit' });
193
191
  expect(admitButton).toBeEnabled();
194
192
  await user.click(admitButton);
195
- expect(mockedAdmitPatient).toHaveBeenCalledWith(mockPatientAlice, 'ADMIT');
193
+ expect(mockedAdmitPatient).toHaveBeenCalledWith(mockPatientAlice, 'ADMIT', mockInpatientRequestAlice.visit.uuid);
196
194
  expect(mockedAssignPatientToBed).toHaveBeenCalledWith(3, mockPatientAlice.uuid, 'encounter-uuid');
197
195
  expect(mockedShowSnackbar).toHaveBeenCalledWith({
198
196
  kind: 'success',
199
- subtitle: '{{patientName}} has been successfully admitted and assigned to bed bed3',
197
+ subtitle: 'Alice Johnson has been successfully admitted and assigned to bed bed3',
200
198
  title: 'Patient admitted successfully',
201
199
  });
202
200
  });
@@ -240,7 +238,7 @@ describe('Testing AdmitPatientForm', () => {
240
238
  const admitButton = screen.getByRole('button', { name: 'Admit' });
241
239
  expect(admitButton).toBeEnabled();
242
240
  await user.click(admitButton);
243
- expect(mockedAdmitPatient).toHaveBeenCalledWith(mockPatientAlice, 'ADMIT');
241
+ expect(mockedAdmitPatient).toHaveBeenCalledWith(mockPatientAlice, 'ADMIT', mockInpatientRequestAlice.visit.uuid);
244
242
  expect(mockedRemovePatientFromBed).toHaveBeenCalledWith(1, mockPatientAlice.uuid);
245
243
  expect(mockedShowSnackbar).toHaveBeenCalledWith({
246
244
  kind: 'success',
@@ -25,7 +25,7 @@ const AdmitPatientFormWorkspace: React.FC<WardPatientWorkspaceProps> = ({
25
25
  closeWorkspaceWithSavedChanges,
26
26
  promptBeforeClosing,
27
27
  }) => {
28
- const { patient, inpatientRequest } = wardPatient ?? {};
28
+ const { patient, inpatientRequest, visit } = wardPatient ?? {};
29
29
  const dispositionType = inpatientRequest?.dispositionType ?? 'ADMIT';
30
30
 
31
31
  const { t } = useTranslation();
@@ -67,7 +67,7 @@ const AdmitPatientFormWorkspace: React.FC<WardPatientWorkspaceProps> = ({
67
67
  setShowErrorNotifications(false);
68
68
  setIsSubmitting(true);
69
69
  const bedSelected = beds.find((bed) => bed.bedId === values.bedId);
70
- admitPatient(patient, dispositionType)
70
+ admitPatient(patient, dispositionType, visit.uuid)
71
71
  .then(
72
72
  async (response) => {
73
73
  if (response.ok) {
@@ -13,7 +13,7 @@ interface BedSelectorProps {
13
13
  currentPatient: Patient;
14
14
  selectedBedId: number;
15
15
  error: FieldError;
16
- onChange(bedId: number);
16
+ onChange(bedId: number): void;
17
17
  control: Control<{ bedId?: number }>;
18
18
  minBedCountToUseDropdown?: number;
19
19
  }
@@ -75,7 +75,7 @@ function renderCancelAdmissionRequestWorkspace() {
75
75
  );
76
76
  }
77
77
 
78
- describe('CancelAdmissionRequestWorkspace', () => {
78
+ describe.skip('CancelAdmissionRequestWorkspace', () => {
79
79
  it('should cancel admission request form creates encounter when form is filled out and submitted ', async () => {
80
80
  const user = userEvent.setup();
81
81
  renderCancelAdmissionRequestWorkspace();
@@ -5,10 +5,9 @@ import { zodResolver } from '@hookform/resolvers/zod';
5
5
  import { Controller, useForm } from 'react-hook-form';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { z } from 'zod';
8
- import { ResponsiveWrapper, showSnackbar, useAppContext, useSession } from '@openmrs/esm-framework';
8
+ import { ResponsiveWrapper, showSnackbar, useAppContext } from '@openmrs/esm-framework';
9
9
  import type { ObsPayload, WardPatientWorkspaceProps, WardViewContext } from '../../types';
10
10
  import { useCreateEncounter } from '../../ward.resource';
11
- import useWardLocation from '../../hooks/useWardLocation';
12
11
  import WardPatientWorkspaceBanner from '../patient-banner/patient-banner.component';
13
12
  import styles from './cancel-admission-request.scss';
14
13
 
@@ -17,14 +16,12 @@ export default function CancelAdmissionRequestWorkspace({
17
16
  wardPatient,
18
17
  promptBeforeClosing,
19
18
  }: WardPatientWorkspaceProps) {
20
- const { patient } = wardPatient ?? {};
19
+ const { patient, visit } = wardPatient ?? {};
21
20
  const { t } = useTranslation();
22
21
  const [showErrorNotifications, setShowErrorNotifications] = useState(false);
23
22
  const [isSubmitting, setIsSubmitting] = useState(false);
24
23
  const { createEncounter, emrConfiguration, isLoadingEmrConfiguration, errorFetchingEmrConfiguration } =
25
24
  useCreateEncounter();
26
- const { currentProvider } = useSession();
27
- const { location } = useWardLocation();
28
25
  const { wardPatientGroupDetails } = useAppContext<WardViewContext>('ward-view-context') ?? {};
29
26
 
30
27
  const zodSchema = useMemo(
@@ -77,7 +74,7 @@ export default function CancelAdmissionRequestWorkspace({
77
74
  },
78
75
  ];
79
76
 
80
- createEncounter(patient, emrConfiguration?.cancelADTRequestEncounterType, obs)
77
+ createEncounter(patient, emrConfiguration?.cancelADTRequestEncounterType, visit?.uuid, obs)
81
78
  .then(() => {
82
79
  showSnackbar({
83
80
  title: t('admissionRequestCancelled', 'Admission request cancelled.'),
@@ -107,6 +104,7 @@ export default function CancelAdmissionRequestWorkspace({
107
104
  t,
108
105
  closeWorkspaceWithSavedChanges,
109
106
  wardPatientGroupDetails,
107
+ visit?.uuid,
110
108
  ],
111
109
  );
112
110
 
@@ -0,0 +1,46 @@
1
+ import React, { useState } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { ActionMenuButton, AddIcon, launchWorkspace } from '@openmrs/esm-framework';
4
+ import { type CreateAdmissionEncounterWorkspaceProps } from './create-admission-encounter.workspace';
5
+
6
+ function CreateAdmissionRequestActionButton() {
7
+ const { t } = useTranslation();
8
+
9
+ // TODO: this is an attempt to save the previous search term for the
10
+ // "Back to patient search" button, but it doesn't work. See:
11
+ // https://openmrs.atlassian.net/browse/O3-4300
12
+ const [searchTerm, setSearchTerm] = useState<string>('');
13
+
14
+ // See PatientSearchWorkspaceProps in patient-search-app
15
+ const workspaceProps = {
16
+ initialQuery: searchTerm,
17
+ nonNavigationSelectPatientAction: async (patientUuid) => {
18
+ launchWorkspace<CreateAdmissionEncounterWorkspaceProps>('create-admission-encounter-workspace', {
19
+ patientUuid,
20
+ handleReturnToSearchList: launchSearchWorkspace,
21
+ });
22
+ },
23
+ handleSearchTermUpdated: (value: string) => {
24
+ setSearchTerm(value);
25
+ },
26
+ };
27
+
28
+ const launchSearchWorkspace = () => {
29
+ launchWorkspace('patient-search-workspace', {
30
+ ...workspaceProps,
31
+ workspaceTitle: t('addPatientToWard', 'Add patient to ward'),
32
+ });
33
+ };
34
+
35
+ return (
36
+ <ActionMenuButton
37
+ getIcon={(props) => <AddIcon {...props} />}
38
+ label={t('addPatientToWard', 'Add patient to ward')}
39
+ iconDescription={t('addPatientToWard', 'Add patient to ward')}
40
+ handler={launchSearchWorkspace}
41
+ type={'patient-search-workspace'}
42
+ />
43
+ );
44
+ }
45
+
46
+ export default CreateAdmissionRequestActionButton;
@@ -0,0 +1,241 @@
1
+ import { useAppContext, useVisit } from '@openmrs/esm-framework';
2
+ import { screen } from '@testing-library/react';
3
+ import userEvent from '@testing-library/user-event';
4
+ import {
5
+ mockInpatientAdmissions,
6
+ mockInpatientRequests,
7
+ mockLocationInpatientWard,
8
+ mockLocationMosoriot,
9
+ mockPatientAlice,
10
+ } from '__mocks__';
11
+ import React from 'react';
12
+ import { renderWithSwr } from '../../../../../tools';
13
+ import { mockWardViewContext } from '../../../mock';
14
+ import { useAssignedBedByPatient } from '../../hooks/useAssignedBedByPatient';
15
+ import useEmrConfiguration from '../../hooks/useEmrConfiguration';
16
+ import { useInpatientAdmissionByPatients } from '../../hooks/useInpatientAdmissionByPatients';
17
+ import { useInpatientRequestByPatients } from '../../hooks/useInpatientRequestByPatients';
18
+ import useRestPatient from '../../hooks/useRestPatient';
19
+ import useWardLocation from '../../hooks/useWardLocation';
20
+ import { type WardViewContext } from '../../types';
21
+ import { useAdmitPatient } from '../../ward.resource';
22
+ import CreateAdmissionEncounterWorkspace from './create-admission-encounter.workspace';
23
+
24
+ jest.mocked(useAppContext<WardViewContext>).mockReturnValue(mockWardViewContext);
25
+
26
+ const mockUseVisit = jest.mocked(useVisit).mockReturnValue({
27
+ activeVisit: {
28
+ encounters: [],
29
+ startDatetime: new Date().toISOString(),
30
+ uuid: 'mock-visit',
31
+ visitType: { display: 'Some Visit Type', uuid: 'some-visit-type-uuid' },
32
+ },
33
+ currentVisit: null,
34
+ currentVisitIsRetrospective: null,
35
+ mutate: jest.fn(),
36
+ error: undefined,
37
+ isLoading: false,
38
+ isValidating: false,
39
+ });
40
+
41
+ jest.mock('../../hooks/useWardLocation', () => jest.fn());
42
+ const mockedUseWardLocation = jest.mocked(useWardLocation);
43
+ mockedUseWardLocation.mockReturnValue({
44
+ location: mockLocationInpatientWard,
45
+ isLoadingLocation: false,
46
+ errorFetchingLocation: null,
47
+ invalidLocation: false,
48
+ });
49
+
50
+ jest.mock('../../hooks/useRestPatient', () => jest.fn());
51
+ const mockUseRestPatient = jest.mocked(useRestPatient).mockReturnValue({
52
+ patient: mockPatientAlice,
53
+ isLoading: false,
54
+ error: null,
55
+ isValidating: false,
56
+ mutate: jest.fn(),
57
+ });
58
+
59
+ jest.mock('../../hooks/useAssignedBedByPatient', () => ({
60
+ useAssignedBedByPatient: jest.fn(),
61
+ }));
62
+ // @ts-ignore - we don't need to mock the entire object
63
+ jest.mocked(useAssignedBedByPatient).mockReturnValue({
64
+ data: {
65
+ data: {
66
+ results: [
67
+ {
68
+ bedId: 1,
69
+ bedNumber: '1',
70
+ bedType: null,
71
+ patients: [mockPatientAlice],
72
+ physicalLocation: mockLocationInpatientWard,
73
+ },
74
+ ],
75
+ },
76
+ },
77
+ isLoading: false,
78
+ });
79
+
80
+ jest.mock('../../hooks/useInpatientAdmissionByPatients', () => ({
81
+ useInpatientAdmissionByPatients: jest.fn(),
82
+ }));
83
+ const mockedUseInpatientAdmissionByPatients = jest.mocked(useInpatientAdmissionByPatients).mockReturnValue({
84
+ data: [],
85
+ hasMore: false,
86
+ loadMore: jest.fn(),
87
+ isValidating: false,
88
+ isLoading: false,
89
+ error: undefined,
90
+ mutate: jest.fn(),
91
+ totalCount: mockInpatientAdmissions.length,
92
+ nextUri: null,
93
+ });
94
+
95
+ jest.mock('../../hooks/useInpatientRequestByPatients', () => ({
96
+ useInpatientRequestByPatients: jest.fn(),
97
+ }));
98
+ const mockedUseInpatientRequestByPatients = jest.mocked(useInpatientRequestByPatients).mockReturnValue({
99
+ inpatientRequests: [],
100
+ hasMore: false,
101
+ loadMore: jest.fn(),
102
+ isValidating: false,
103
+ isLoading: false,
104
+ error: undefined,
105
+ mutate: jest.fn(),
106
+ totalCount: mockInpatientAdmissions.length,
107
+ nextUri: null,
108
+ });
109
+
110
+ jest.mock('../../hooks/useEmrConfiguration', () => jest.fn());
111
+ jest.mocked(useEmrConfiguration).mockReturnValue({
112
+ isLoadingEmrConfiguration: false,
113
+ errorFetchingEmrConfiguration: null,
114
+ // @ts-ignore - we only need these keys for now
115
+ emrConfiguration: {
116
+ admissionEncounterType: {
117
+ uuid: 'admission-encounter-type-uuid',
118
+ display: 'Admission Encounter',
119
+ },
120
+ transferWithinHospitalEncounterType: {
121
+ uuid: 'transfer-within-hospital-encounter-type-uuid',
122
+ display: 'Transfer Within Hospital Encounter Type',
123
+ },
124
+ clinicianEncounterRole: {
125
+ uuid: 'clinician-encounter-role-uuid',
126
+ },
127
+ },
128
+ mutateEmrConfiguration: jest.fn(),
129
+ });
130
+
131
+ jest.mock('../../ward.resource', () => ({
132
+ useAdmitPatient: jest.fn(),
133
+ assignPatientToBed: jest.fn(),
134
+ removePatientFromBed: jest.fn(),
135
+ }));
136
+ const mockedUseAdmitPatient: ReturnType<typeof useAdmitPatient> = {
137
+ admitPatient: jest.fn(),
138
+ isLoadingEmrConfiguration: false,
139
+ errorFetchingEmrConfiguration: false,
140
+ };
141
+ jest.mocked(useAdmitPatient).mockReturnValue(mockedUseAdmitPatient);
142
+ const mockedAdmitPatient = mockedUseAdmitPatient.admitPatient;
143
+ // @ts-ignore - we only need these two keys for now
144
+ mockedAdmitPatient.mockResolvedValue({
145
+ ok: true,
146
+ data: {
147
+ uuid: 'encounter-uuid',
148
+ },
149
+ });
150
+
151
+ describe('CreateAdmissionEncounterWorkspace', () => {
152
+ it('should render patient header and admit patient button', async () => {
153
+ const user = userEvent.setup();
154
+ renderCreateAdmissionEncounterWorkspace(mockPatientAlice.uuid);
155
+ expect(screen.getByText(mockPatientAlice.person?.preferredName?.display)).toBeInTheDocument();
156
+ const admitPatientButton = screen.getByRole('button', { name: /admit patient/i });
157
+ expect(admitPatientButton).toBeEnabled();
158
+
159
+ await user.click(admitPatientButton);
160
+ expect(mockedAdmitPatient).toHaveBeenCalledWith(expect.any(Object), 'ADMIT', 'mock-visit');
161
+ });
162
+ it('should have warning when patient has a pending admission request', async () => {
163
+ mockedUseInpatientRequestByPatients.mockReturnValueOnce({
164
+ inpatientRequests: mockInpatientRequests,
165
+ hasMore: false,
166
+ loadMore: jest.fn(),
167
+ isValidating: false,
168
+ isLoading: false,
169
+ error: undefined,
170
+ mutate: jest.fn(),
171
+ totalCount: mockInpatientAdmissions.length,
172
+ nextUri: null,
173
+ });
174
+ const user = userEvent.setup();
175
+ renderCreateAdmissionEncounterWorkspace(mockPatientAlice.uuid);
176
+ expect(screen.getByText(mockPatientAlice.person?.preferredName?.display)).toBeInTheDocument();
177
+ expect(
178
+ screen.getByText(
179
+ 'Patient already has a pending admission request to location ' + mockLocationInpatientWard.display,
180
+ ),
181
+ ).toBeInTheDocument();
182
+ const admitPatientButton = screen.getByRole('button', { name: /admit patient/i });
183
+ expect(admitPatientButton).toBeEnabled();
184
+
185
+ await user.click(admitPatientButton);
186
+ expect(mockedAdmitPatient).toHaveBeenCalledWith(expect.any(Object), 'ADMIT', 'mock-visit');
187
+ });
188
+
189
+ it('should have warning when patient is already admitted elsewhere', async () => {
190
+ mockedUseInpatientAdmissionByPatients.mockReturnValueOnce({
191
+ data: [{ ...mockInpatientAdmissions[0], currentInpatientLocation: mockLocationMosoriot }],
192
+ hasMore: false,
193
+ loadMore: jest.fn(),
194
+ isValidating: false,
195
+ isLoading: false,
196
+ error: undefined,
197
+ mutate: jest.fn(),
198
+ totalCount: mockInpatientAdmissions.length,
199
+ nextUri: null,
200
+ });
201
+ const user = userEvent.setup();
202
+ renderCreateAdmissionEncounterWorkspace(mockPatientAlice.uuid);
203
+ expect(screen.getByText(mockPatientAlice.person?.preferredName?.display)).toBeInTheDocument();
204
+ expect(screen.getByText('Patient currently admitted to ' + mockLocationMosoriot.display)).toBeInTheDocument();
205
+ const admitPatientButton = screen.getByRole('button', { name: /transfer patient/i });
206
+ expect(admitPatientButton).toBeEnabled();
207
+
208
+ await user.click(admitPatientButton);
209
+ expect(mockedAdmitPatient).toHaveBeenCalledWith(expect.any(Object), 'TRANSFER', 'mock-visit');
210
+ });
211
+
212
+ it('should disable admit patient button when patient is already admitted to current location', () => {
213
+ mockedUseInpatientAdmissionByPatients.mockReturnValueOnce({
214
+ data: mockInpatientAdmissions,
215
+ hasMore: false,
216
+ loadMore: jest.fn(),
217
+ isValidating: false,
218
+ isLoading: false,
219
+ error: undefined,
220
+ mutate: jest.fn(),
221
+ totalCount: mockInpatientAdmissions.length,
222
+ nextUri: null,
223
+ });
224
+ renderCreateAdmissionEncounterWorkspace(mockPatientAlice.uuid);
225
+ expect(screen.getByText(mockPatientAlice.person?.preferredName?.display)).toBeInTheDocument();
226
+ expect(screen.getByText('Patient already admitted to current location')).toBeInTheDocument();
227
+ expect(screen.getByRole('button', { name: /admit patient/i })).toBeDisabled();
228
+ });
229
+ });
230
+
231
+ function renderCreateAdmissionEncounterWorkspace(patentUuid: string) {
232
+ renderWithSwr(
233
+ <CreateAdmissionEncounterWorkspace
234
+ patientUuid={patentUuid}
235
+ closeWorkspace={jest.fn()}
236
+ promptBeforeClosing={jest.fn()}
237
+ closeWorkspaceWithSavedChanges={jest.fn()}
238
+ setTitle={jest.fn()}
239
+ />,
240
+ );
241
+ }