@kenyaemr/esm-express-workflow-app 5.4.4-pre.96 → 5.4.5-pre.16

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 (368) hide show
  1. package/package.json +3 -3
  2. package/src/components/admissions/admissions-dashboard.component.tsx +2 -2
  3. package/src/components/anaesthetic/anaesthetic-dashboard.meta.ts +8 -0
  4. package/src/components/anaesthetic/anaesthetic-data-form.component.tsx +442 -0
  5. package/src/components/anaesthetic/anaesthetic-data-form.scss +278 -0
  6. package/src/components/anaesthetic/anaesthetic-link.component.tsx +21 -0
  7. package/src/components/anaesthetic/anaesthetic.component.tsx +618 -0
  8. package/src/components/anaesthetic/anaesthetic.resource.ts +1503 -0
  9. package/src/components/anaesthetic/anaesthetic.scss +1885 -0
  10. package/src/components/anaesthetic/forms/anaesthetic-form.component.tsx +304 -0
  11. package/src/components/anaesthetic/forms/anaesthetic-record-form.component.tsx +707 -0
  12. package/src/components/anaesthetic/forms/icd11-diagnosis-search.component.tsx +178 -0
  13. package/src/components/anaesthetic/forms/icd11-diagnosis-search.scss +126 -0
  14. package/src/components/anaesthetic/forms/index.ts +2 -0
  15. package/src/components/anaesthetic/forms/interoperative-record-drug-given-form.component.tsx +231 -0
  16. package/src/components/anaesthetic/forms/post-operative-summary-form.component.tsx +171 -0
  17. package/src/components/anaesthetic/forms/time-picker-dropdown.component.tsx +202 -0
  18. package/src/components/anaesthetic/forms/time-picker-dropdown.scss +107 -0
  19. package/src/components/anaesthetic/forms/time-picker-with-clock.component.tsx +174 -0
  20. package/src/components/anaesthetic/forms/time-picker-with-clock.scss +178 -0
  21. package/src/components/anaesthetic/forms/useAnaestheticData.ts +16 -0
  22. package/src/components/anaesthetic/graphs/anaesthetic-graph-wrapper.component.tsx +266 -0
  23. package/src/components/anaesthetic/graphs/anaesthetic-graph.component.tsx +185 -0
  24. package/src/components/anaesthetic/graphs/index.ts +2 -0
  25. package/src/components/anaesthetic/graphs/interoperative-record-drug-given-graph-wrapper.component.tsx +197 -0
  26. package/src/components/anaesthetic/graphs/interoperative-record-drug-given-graph.component.tsx +93 -0
  27. package/src/components/anaesthetic/resources/anaesthetic-amniotic-fluid.resource.ts +277 -0
  28. package/src/components/anaesthetic/resources/anaesthetic-form.resource.ts +716 -0
  29. package/src/components/anaesthetic/resources/anaesthetic.resource.ts +378 -0
  30. package/src/components/anaesthetic/types/index.ts +1349 -0
  31. package/src/components/consultation/clinical-encounter/clinical-encounter.component.tsx +4 -20
  32. package/src/components/consultation/index.ts +1 -1
  33. package/src/components/consultation/tabs/index.ts +67 -0
  34. package/src/components/facility-dashboard/components/header/home-header.component.tsx +8 -13
  35. package/src/components/laboratory/index.ts +11 -0
  36. package/src/components/laboratory/lab-table.component.tsx +32 -12
  37. package/src/components/laboratory/laboratory-tabs.component.tsx +3 -17
  38. package/src/components/mch/mch.component.tsx +1 -3
  39. package/src/components/pharmacy/index.ts +1 -1
  40. package/src/components/pharmacy/orders/pharmacy-orders.component.tsx +13 -2
  41. package/src/components/pharmacy/pharmacy-tabs.component.tsx +4 -20
  42. package/src/components/pharmacy/tabs/index.ts +21 -0
  43. package/src/components/preauth/index.ts +22 -0
  44. package/src/components/preauth/preauth-dashboard.component.tsx +20 -0
  45. package/src/components/procedures/index.ts +16 -0
  46. package/src/components/procedures/procedure-queues/index.ts +13 -0
  47. package/src/components/procedures/procedure-queues/procedure-form-extras.component.tsx +33 -0
  48. package/src/components/procedures/procedure-queues/procedure-form-extras.scss +5 -0
  49. package/src/components/procedures/procedure-queues/procedure-queues.component.tsx +35 -0
  50. package/src/components/procedures/procedure-queues/procedure-queues.resources.ts +37 -0
  51. package/src/components/procedures/procedure-queues/procedure-room-tabs.component.tsx +80 -0
  52. package/src/components/procedures/procedure-queues/procedure-rooms.scss +13 -0
  53. package/src/components/procedures/procedure-queues/queue-procedure-tabs.component.tsx +34 -0
  54. package/src/components/procedures/procedure-queues/summary-cards.component.tsx +81 -0
  55. package/src/components/procedures/procedure-queues/summary-cards.scss +35 -0
  56. package/src/components/procedures/procedures-table.component.tsx +42 -15
  57. package/src/components/procedures/procedures-tabs.component.test.tsx +57 -0
  58. package/src/components/procedures/procedures-tabs.component.tsx +3 -18
  59. package/src/components/radiology-and-imaging/index.ts +11 -0
  60. package/src/components/radiology-and-imaging/radiology-and-imaging-table.component.tsx +46 -14
  61. package/src/components/radiology-and-imaging/radiology-and-imaging.component.tsx +3 -19
  62. package/src/components/registration/card/Local-card/local-card.component.tsx +3 -3
  63. package/src/components/registration/checkin-form-extra/checkin-form-extra.extension.tsx +8 -2
  64. package/src/components/registration/checkin-form-extra/queue-fields.component.tsx +18 -19
  65. package/src/components/registration/checkin-form-extra/queue-fields.scss +0 -3
  66. package/src/components/registration/constant/index.ts +0 -9
  67. package/src/components/registration/dependants/dependants.component.tsx +43 -8
  68. package/src/components/registration/dependants/dependants.resource.ts +161 -15
  69. package/src/components/registration/end-visit-modal/end-visit-dialog.modal.tsx +320 -0
  70. package/src/components/registration/end-visit-modal/end-visit-dialog.scss +12 -0
  71. package/src/components/registration/end-visit-modal/end-visit.resource.tsx +59 -0
  72. package/src/components/registration/end-visit-modal/sha-end-visit.resource.ts +285 -0
  73. package/src/components/registration/helper/index.ts +27 -21
  74. package/src/components/registration/search-bar/search-bar.resource.ts +13 -5
  75. package/src/components/registration/start-visit-form/overflow-menu-extension/custom-end-active-visit.extension.tsx +44 -0
  76. package/src/components/registration/start-visit-form/overflow-menu-extension/overflow-menu-item.extension.tsx +32 -20
  77. package/src/components/registration/start-visit-form/start-visit-workspace/exported-visit-form.workspace.tsx +91 -26
  78. package/src/components/registration/start-visit-form/start-visit-workspace/visit-form.resource.ts +18 -0
  79. package/src/components/registration/start-visit-form/start-visit-workspace/visit-form.scss +2 -26
  80. package/src/components/registration/start-visit-form/visit-form-workspace/visit-form.workspace.tsx +1 -8
  81. package/src/components/registration/type/index.ts +102 -0
  82. package/src/components/reports/index.ts +1 -0
  83. package/src/config-schema.ts +433 -16
  84. package/src/hooks/useOrders.tsx +2 -2
  85. package/src/hooks/useServiceQueues.tsx +1 -1
  86. package/src/index.ts +69 -16
  87. package/src/routes.json +512 -45
  88. package/src/shared/dashboard-link/dashboard-link.component.tsx +11 -8
  89. package/src/shared/orders/OrderTable.scss +7 -0
  90. package/src/shared/orders/OrderTable.tsx +68 -8
  91. package/src/shared/orders/print-order/print-order.component.tsx +158 -0
  92. package/src/shared/orders/print-order/print-order.scss +225 -0
  93. package/src/shared/orders/print-prescription/print-prescription.component.tsx +65 -0
  94. package/src/shared/orders/print-prescription/print-prescription.resource.ts +45 -0
  95. package/src/shared/orders/print-prescription/print-prescription.scss +25 -0
  96. package/src/shared/otp-verification/index.ts +112 -29
  97. package/src/shared/otp-verification/otp-verification.modal.tsx +1110 -122
  98. package/src/shared/otp-verification/otp-verification.scss +374 -0
  99. package/src/shared/patient-chart/patient-summary-dashboard/patient-summary-dashboard.component.tsx +5 -84
  100. package/src/shared/tabs/create-tab-extension.tsx +33 -0
  101. package/src/shared/tabs/extension-tabs.component.tsx +51 -33
  102. package/src/shared/utils/index.ts +139 -3
  103. package/src/types/index.ts +12 -0
  104. package/translations/am.json +386 -123
  105. package/translations/en.json +276 -13
  106. package/translations/fr.json +372 -63
  107. package/translations/sw.json +295 -32
  108. package/tsconfig.json +1 -0
  109. package/.turbo/turbo-build.log +0 -8
  110. package/dist/1074.js +0 -1
  111. package/dist/1074.js.map +0 -1
  112. package/dist/12.js +0 -17
  113. package/dist/12.js.map +0 -1
  114. package/dist/1311.js +0 -1
  115. package/dist/1311.js.map +0 -1
  116. package/dist/1323.js +0 -1
  117. package/dist/1323.js.map +0 -1
  118. package/dist/1469.js +0 -1
  119. package/dist/1469.js.map +0 -1
  120. package/dist/1506.js +0 -13
  121. package/dist/1506.js.map +0 -1
  122. package/dist/1562.js +0 -1
  123. package/dist/1562.js.map +0 -1
  124. package/dist/1760.js +0 -1
  125. package/dist/1760.js.map +0 -1
  126. package/dist/1780.js +0 -1
  127. package/dist/1780.js.map +0 -1
  128. package/dist/1804.js +0 -1
  129. package/dist/1804.js.map +0 -1
  130. package/dist/1884.js +0 -1
  131. package/dist/1884.js.map +0 -1
  132. package/dist/1972.js +0 -1
  133. package/dist/1972.js.map +0 -1
  134. package/dist/1990.js +0 -1
  135. package/dist/1990.js.map +0 -1
  136. package/dist/2016.js +0 -1
  137. package/dist/2016.js.map +0 -1
  138. package/dist/2024.js +0 -1
  139. package/dist/2024.js.map +0 -1
  140. package/dist/2153.js +0 -1
  141. package/dist/2153.js.map +0 -1
  142. package/dist/216.js +0 -1
  143. package/dist/216.js.map +0 -1
  144. package/dist/2225.js +0 -1
  145. package/dist/2225.js.map +0 -1
  146. package/dist/2294.js +0 -1
  147. package/dist/2294.js.map +0 -1
  148. package/dist/2345.js +0 -1
  149. package/dist/2345.js.map +0 -1
  150. package/dist/2499.js +0 -1
  151. package/dist/2499.js.map +0 -1
  152. package/dist/2500.js +0 -1
  153. package/dist/2500.js.map +0 -1
  154. package/dist/2586.js +0 -1
  155. package/dist/2586.js.map +0 -1
  156. package/dist/2625.js +0 -1
  157. package/dist/2625.js.map +0 -1
  158. package/dist/2685.js +0 -1
  159. package/dist/2685.js.map +0 -1
  160. package/dist/2809.js +0 -1
  161. package/dist/2809.js.map +0 -1
  162. package/dist/2851.js +0 -1
  163. package/dist/2851.js.map +0 -1
  164. package/dist/2881.js +0 -1
  165. package/dist/2881.js.map +0 -1
  166. package/dist/2948.js +0 -1
  167. package/dist/2948.js.map +0 -1
  168. package/dist/2968.js +0 -1
  169. package/dist/2968.js.map +0 -1
  170. package/dist/2978.js +0 -1
  171. package/dist/2978.js.map +0 -1
  172. package/dist/2998.js +0 -1
  173. package/dist/2998.js.map +0 -1
  174. package/dist/3089.js +0 -1
  175. package/dist/3089.js.map +0 -1
  176. package/dist/3548.js +0 -1
  177. package/dist/3548.js.map +0 -1
  178. package/dist/3567.js +0 -1
  179. package/dist/3567.js.map +0 -1
  180. package/dist/3569.js +0 -1
  181. package/dist/3569.js.map +0 -1
  182. package/dist/3571.js +0 -1
  183. package/dist/3571.js.map +0 -1
  184. package/dist/3691.js +0 -1
  185. package/dist/3691.js.map +0 -1
  186. package/dist/3730.js +0 -1
  187. package/dist/3730.js.map +0 -1
  188. package/dist/3923.js +0 -1
  189. package/dist/3923.js.map +0 -1
  190. package/dist/3963.js +0 -1
  191. package/dist/3963.js.map +0 -1
  192. package/dist/4024.js +0 -1
  193. package/dist/4024.js.map +0 -1
  194. package/dist/405.js +0 -1
  195. package/dist/405.js.map +0 -1
  196. package/dist/4071.js +0 -1
  197. package/dist/4071.js.map +0 -1
  198. package/dist/4271.js +0 -1
  199. package/dist/4271.js.map +0 -1
  200. package/dist/4296.js +0 -1
  201. package/dist/4296.js.map +0 -1
  202. package/dist/4337.js +0 -1
  203. package/dist/4337.js.map +0 -1
  204. package/dist/4432.js +0 -1
  205. package/dist/4432.js.map +0 -1
  206. package/dist/4581.js +0 -1
  207. package/dist/4581.js.map +0 -1
  208. package/dist/4637.js +0 -11
  209. package/dist/4637.js.map +0 -1
  210. package/dist/4666.js +0 -1
  211. package/dist/4666.js.map +0 -1
  212. package/dist/4680.js +0 -1
  213. package/dist/4680.js.map +0 -1
  214. package/dist/4735.js +0 -1
  215. package/dist/4735.js.map +0 -1
  216. package/dist/4737.js +0 -1
  217. package/dist/4737.js.map +0 -1
  218. package/dist/4744.js +0 -1
  219. package/dist/4744.js.map +0 -1
  220. package/dist/4795.js +0 -1
  221. package/dist/4795.js.map +0 -1
  222. package/dist/4813.js +0 -2
  223. package/dist/4813.js.map +0 -1
  224. package/dist/4818.js +0 -1
  225. package/dist/4818.js.map +0 -1
  226. package/dist/4858.js +0 -1
  227. package/dist/4858.js.map +0 -1
  228. package/dist/487.js +0 -1
  229. package/dist/487.js.map +0 -1
  230. package/dist/4970.js +0 -1
  231. package/dist/4970.js.map +0 -1
  232. package/dist/5038.js +0 -1
  233. package/dist/5038.js.map +0 -1
  234. package/dist/5202.js +0 -1
  235. package/dist/5202.js.map +0 -1
  236. package/dist/5491.js +0 -1
  237. package/dist/5491.js.map +0 -1
  238. package/dist/5592.js +0 -1
  239. package/dist/5592.js.map +0 -1
  240. package/dist/5669.js +0 -1
  241. package/dist/5669.js.map +0 -1
  242. package/dist/586.js +0 -1
  243. package/dist/586.js.map +0 -1
  244. package/dist/5932.js +0 -1
  245. package/dist/5932.js.map +0 -1
  246. package/dist/5995.js +0 -1
  247. package/dist/5995.js.map +0 -1
  248. package/dist/6258.js +0 -1
  249. package/dist/6258.js.map +0 -1
  250. package/dist/629.js +0 -1
  251. package/dist/629.js.map +0 -1
  252. package/dist/6328.js +0 -1
  253. package/dist/6328.js.map +0 -1
  254. package/dist/6355.js +0 -1
  255. package/dist/6355.js.map +0 -1
  256. package/dist/6419.js +0 -1
  257. package/dist/6419.js.map +0 -1
  258. package/dist/644.js +0 -1
  259. package/dist/644.js.map +0 -1
  260. package/dist/6456.js +0 -1
  261. package/dist/6466.js +0 -3
  262. package/dist/6466.js.map +0 -1
  263. package/dist/655.js +0 -1
  264. package/dist/655.js.map +0 -1
  265. package/dist/6798.js +0 -66
  266. package/dist/6798.js.map +0 -1
  267. package/dist/6910.js +0 -1
  268. package/dist/6910.js.map +0 -1
  269. package/dist/6925.js +0 -1
  270. package/dist/6925.js.map +0 -1
  271. package/dist/70.js +0 -1
  272. package/dist/70.js.map +0 -1
  273. package/dist/7201.js +0 -1
  274. package/dist/7201.js.map +0 -1
  275. package/dist/7234.js +0 -1
  276. package/dist/7234.js.map +0 -1
  277. package/dist/7261.js +0 -1
  278. package/dist/7261.js.map +0 -1
  279. package/dist/7326.js +0 -1
  280. package/dist/7359.js +0 -1
  281. package/dist/7487.js +0 -1
  282. package/dist/7487.js.map +0 -1
  283. package/dist/7591.js +0 -1
  284. package/dist/7591.js.map +0 -1
  285. package/dist/7607.js +0 -1
  286. package/dist/7701.js +0 -1
  287. package/dist/7701.js.map +0 -1
  288. package/dist/7717.js +0 -1
  289. package/dist/7717.js.map +0 -1
  290. package/dist/7739.js +0 -1
  291. package/dist/7739.js.map +0 -1
  292. package/dist/7788.js +0 -1
  293. package/dist/7788.js.map +0 -1
  294. package/dist/7819.js +0 -1
  295. package/dist/7819.js.map +0 -1
  296. package/dist/7971.js +0 -1
  297. package/dist/7971.js.map +0 -1
  298. package/dist/7983.js +0 -1
  299. package/dist/7983.js.map +0 -1
  300. package/dist/807.js +0 -1
  301. package/dist/807.js.map +0 -1
  302. package/dist/8159.js +0 -7
  303. package/dist/8159.js.map +0 -1
  304. package/dist/8338.js +0 -1
  305. package/dist/8338.js.map +0 -1
  306. package/dist/845.js +0 -1
  307. package/dist/845.js.map +0 -1
  308. package/dist/8570.js +0 -1
  309. package/dist/8570.js.map +0 -1
  310. package/dist/8661.js +0 -1
  311. package/dist/8661.js.map +0 -1
  312. package/dist/87.js +0 -1
  313. package/dist/87.js.map +0 -1
  314. package/dist/8727.js +0 -1
  315. package/dist/8766.js +0 -1
  316. package/dist/8766.js.map +0 -1
  317. package/dist/8828.js +0 -1
  318. package/dist/8828.js.map +0 -1
  319. package/dist/8860.js +0 -1
  320. package/dist/8860.js.map +0 -1
  321. package/dist/8911.js +0 -1
  322. package/dist/8911.js.map +0 -1
  323. package/dist/8930.js +0 -1
  324. package/dist/8930.js.map +0 -1
  325. package/dist/8971.js +0 -1
  326. package/dist/8971.js.map +0 -1
  327. package/dist/9124.js +0 -1
  328. package/dist/9124.js.map +0 -1
  329. package/dist/9157.js +0 -1
  330. package/dist/9157.js.map +0 -1
  331. package/dist/9182.js +0 -1
  332. package/dist/921.js +0 -1
  333. package/dist/921.js.map +0 -1
  334. package/dist/9212.js +0 -1
  335. package/dist/9212.js.map +0 -1
  336. package/dist/9255.js +0 -1
  337. package/dist/9255.js.map +0 -1
  338. package/dist/9257.js +0 -1
  339. package/dist/9257.js.map +0 -1
  340. package/dist/9316.js +0 -1
  341. package/dist/9316.js.map +0 -1
  342. package/dist/9333.js +0 -1
  343. package/dist/9333.js.map +0 -1
  344. package/dist/9404.js +0 -1
  345. package/dist/9404.js.map +0 -1
  346. package/dist/9446.js +0 -1
  347. package/dist/9446.js.map +0 -1
  348. package/dist/9447.js +0 -1
  349. package/dist/9447.js.map +0 -1
  350. package/dist/9449.js +0 -1
  351. package/dist/9449.js.map +0 -1
  352. package/dist/9535.js +0 -1
  353. package/dist/9535.js.map +0 -1
  354. package/dist/9606.js +0 -1
  355. package/dist/9606.js.map +0 -1
  356. package/dist/973.js +0 -1
  357. package/dist/973.js.map +0 -1
  358. package/dist/9845.js +0 -1
  359. package/dist/9845.js.map +0 -1
  360. package/dist/kenyaemr-esm-express-workflow-app.js +0 -5
  361. package/dist/kenyaemr-esm-express-workflow-app.js.buildmanifest.json +0 -3521
  362. package/dist/kenyaemr-esm-express-workflow-app.js.map +0 -1
  363. package/dist/main.js +0 -5
  364. package/dist/main.js.map +0 -1
  365. package/dist/routes.json +0 -1
  366. package/src/shared/orders/OrdersTabs.tsx +0 -63
  367. package/src/shared/patient-chart/patient-chart.resources.ts +0 -180
  368. /package/src/shared/{patient-chart/patient-summary-dashboard → tabs}/patient-summary-dashboard.scss +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-express-workflow-app",
3
- "version": "5.4.4-pre.96",
3
+ "version": "5.4.5-pre.16",
4
4
  "description": "Express workflow app for OpenMRS 3",
5
5
  "keywords": [
6
6
  "openmrs",
@@ -23,7 +23,7 @@
23
23
  "build": "rspack --mode=production",
24
24
  "coverage": "echo \"Jest has been removed; no unit test runner is configured\" && exit 0",
25
25
  "debug": "npm run serve",
26
- "extract-translations": "i18next 'src/**/*.component.tsx' 'src/**/*.extension.tsx' 'src/**/*modal.tsx' 'src/**/*.workspace.tsx' 'src/index.ts' --config ../../tools/i18next-parser.config.js",
26
+ "extract-translations": "i18next 'src/**/*.{ts,tsx}' --config ../../tools/i18next-parser.config.js",
27
27
  "lint": "cross-env eslint src --ext ts,tsx",
28
28
  "serve": "rspack serve --mode=development",
29
29
  "start": "openmrs develop",
@@ -53,5 +53,5 @@
53
53
  "publishConfig": {
54
54
  "access": "public"
55
55
  },
56
- "stableVersion": "5.4.3"
56
+ "stableVersion": "5.4.4"
57
57
  }
@@ -1,10 +1,10 @@
1
- import React, { useMemo } from 'react';
2
1
  import { Layer } from '@carbon/react';
3
2
  import { ExtensionSlot } from '@openmrs/esm-framework';
3
+ import React, { useMemo } from 'react';
4
4
 
5
5
  type AdmissionsDashboardProps = {
6
6
  patientUuid: string;
7
- patient: fhir.Patient;
7
+ patient: Record<string, unknown>;
8
8
  };
9
9
 
10
10
  const AdmissionsDashboard: React.FC<AdmissionsDashboardProps> = ({ patientUuid, patient }) => {
@@ -0,0 +1,8 @@
1
+ export const anaestheticDashboardMeta = {
2
+ name: 'anaesthetic',
3
+ slot: 'patient-chart-anaesthetic-slot',
4
+ config: { columns: 1, type: 'grid', programme: 'anaesthetic' },
5
+ title: 'Anaesthetic',
6
+ path: 'anaesthetic',
7
+ icon: 'GraphColumn_32',
8
+ };
@@ -0,0 +1,442 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { useForm, Controller } from 'react-hook-form';
4
+ import { Modal, TextArea, TextInput, NumberInput, Select, SelectItem, Form, Grid, Column } from '@carbon/react';
5
+ import {
6
+ AMNIOTIC_FLUID_OPTIONS,
7
+ MOULDING_OPTIONS,
8
+ DESCENT_OF_HEAD_OPTIONS,
9
+ CONTRACTION_INTENSITY_OPTIONS,
10
+ URINE_LEVEL_OPTIONS,
11
+ BLOOD_GROUP_OPTIONS,
12
+ ADMISSION_OPTIONS,
13
+ TIME_SLOT_OPTIONS,
14
+ EVENT_TYPE_OPTIONS,
15
+ INPUT_RANGES,
16
+ getMeasurementLabel,
17
+ getFieldLabel,
18
+ getFieldPlaceholder,
19
+ getInputRangePlaceholder,
20
+ getGraphDataProcessor,
21
+ } from './types';
22
+ import styles from './anaesthetic-data-form.scss';
23
+
24
+ type Patient = {
25
+ name?: Array<{
26
+ given?: string[];
27
+ family?: string;
28
+ }>;
29
+ gender?: string;
30
+ birthDate?: string;
31
+ };
32
+ type PartographyFormData = {
33
+ admission: string;
34
+ bg: string;
35
+ am: string;
36
+ measurementValue: string;
37
+ systolic: string;
38
+ diastolic: string;
39
+ proteinLevel: string;
40
+ glucoseLevel: string;
41
+ ketoneLevel: string;
42
+ medication: string;
43
+ dosage: string;
44
+ eventType: string;
45
+ eventDescription: string;
46
+ amnioticFluid: string;
47
+ moulding: string;
48
+ };
49
+
50
+ type PartographyDataFormProps = {
51
+ isOpen: boolean;
52
+ onClose: () => void;
53
+ onSubmit: (data: any) => void;
54
+ graphType: string;
55
+ graphTitle: string;
56
+ patient?: Patient;
57
+ };
58
+
59
+ const PartographyDataForm: React.FC<PartographyDataFormProps> = ({
60
+ isOpen,
61
+ onClose,
62
+ onSubmit,
63
+ graphType,
64
+ graphTitle,
65
+ patient,
66
+ }) => {
67
+ const { t } = useTranslation();
68
+
69
+ const getPatientInfo = (patient?: Patient) => {
70
+ const getName = (): string => {
71
+ if (!patient?.name?.[0]) {
72
+ return '';
73
+ }
74
+ const name = patient.name[0];
75
+ const given = name.given?.join(' ') || '';
76
+ const family = name.family || '';
77
+ return `${given} ${family}`.trim();
78
+ };
79
+
80
+ const getGender = (): string => (patient?.gender ? t(patient.gender, patient.gender) : '');
81
+
82
+ const getAge = (): string => {
83
+ if (!patient?.birthDate) {
84
+ return '';
85
+ }
86
+ const birthDate = new Date(patient.birthDate);
87
+ const today = new Date();
88
+ const age = today.getFullYear() - birthDate.getFullYear();
89
+ const monthDiff = today.getMonth() - birthDate.getMonth();
90
+ const adjustedAge = monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate()) ? age - 1 : age;
91
+ return `${adjustedAge} ${t('yearsOld', 'years old')}`;
92
+ };
93
+
94
+ return { name: getName(), gender: getGender(), age: getAge() };
95
+ };
96
+
97
+ const patientInfo = getPatientInfo(patient);
98
+
99
+ const { control, handleSubmit, reset } = useForm<PartographyFormData>({
100
+ defaultValues: {
101
+ admission: '',
102
+ bg: '',
103
+ am: '',
104
+ measurementValue: '',
105
+ systolic: '',
106
+ diastolic: '',
107
+ proteinLevel: '',
108
+ glucoseLevel: '',
109
+ ketoneLevel: '',
110
+ medication: '',
111
+ dosage: '',
112
+ eventType: '',
113
+ eventDescription: '',
114
+ amnioticFluid: '',
115
+ moulding: '',
116
+ },
117
+ });
118
+
119
+ const createNumberInput = (
120
+ id: string,
121
+ name: keyof PartographyFormData,
122
+ label: string,
123
+ placeholder: string,
124
+ range: any,
125
+ required = true,
126
+ ) => (
127
+ <Controller
128
+ name={name}
129
+ control={control}
130
+ rules={required ? { required: t('fieldRequired', 'This field is required') } : {}}
131
+ render={({ field, fieldState }) => (
132
+ <NumberInput
133
+ id={id}
134
+ label={label}
135
+ placeholder={placeholder}
136
+ value={field.value || ''}
137
+ onChange={(e, { value }) => field.onChange(String(value))}
138
+ min={range.min}
139
+ max={range.max}
140
+ step={range.step}
141
+ invalid={!!fieldState.error}
142
+ invalidText={fieldState.error?.message}
143
+ required={required}
144
+ />
145
+ )}
146
+ />
147
+ );
148
+
149
+ const createSelect = (
150
+ id: string,
151
+ name: keyof PartographyFormData,
152
+ label: string,
153
+ options: readonly any[],
154
+ required = false,
155
+ ) => (
156
+ <Controller
157
+ name={name}
158
+ control={control}
159
+ rules={required ? { required: t('fieldRequired', 'This field is required') } : {}}
160
+ render={({ field, fieldState }) => (
161
+ <Select
162
+ id={id}
163
+ labelText={label}
164
+ value={field.value}
165
+ onChange={(e) => field.onChange((e.target as HTMLSelectElement).value)}
166
+ invalid={!!fieldState.error}
167
+ invalidText={fieldState.error?.message}
168
+ required={required}>
169
+ {options.map((option) => (
170
+ <SelectItem
171
+ key={option.value || option.text}
172
+ value={option.value}
173
+ text={t(option.text as string, (option as any).display || option.text) as string}
174
+ />
175
+ ))}
176
+ </Select>
177
+ )}
178
+ />
179
+ );
180
+
181
+ const createTextInput = (
182
+ id: string,
183
+ name: keyof PartographyFormData,
184
+ label: string,
185
+ placeholder: string,
186
+ required = true,
187
+ ) => (
188
+ <Controller
189
+ name={name}
190
+ control={control}
191
+ rules={required ? { required: t('fieldRequired', 'This field is required') } : {}}
192
+ render={({ field, fieldState }) => (
193
+ <TextInput
194
+ id={id}
195
+ labelText={label}
196
+ placeholder={placeholder}
197
+ value={field.value || ''}
198
+ onChange={(e) => field.onChange((e.target as HTMLInputElement).value)}
199
+ invalid={!!fieldState.error}
200
+ invalidText={fieldState.error?.message}
201
+ required={required}
202
+ />
203
+ )}
204
+ />
205
+ );
206
+
207
+ const onSubmitForm = (data: PartographyFormData) => {
208
+ const processor = getGraphDataProcessor(graphType);
209
+ if (!processor.validate(data)) {
210
+ return;
211
+ }
212
+
213
+ const dataPoint = {
214
+ time: new Date().toLocaleTimeString('en-US', { hour12: false, hour: '2-digit', minute: '2-digit' }),
215
+ value: processor.getValue(data),
216
+ graphType,
217
+ admission: data.admission,
218
+ bg: data.bg,
219
+ am: data.am,
220
+ timestamp: new Date(),
221
+ ...processor.getAdditionalData(data),
222
+ };
223
+
224
+ onSubmit(dataPoint);
225
+ handleClose();
226
+ };
227
+
228
+ const handleClose = () => {
229
+ reset();
230
+ onClose();
231
+ };
232
+
233
+ const renderSpecificFields = () => {
234
+ const fieldConfigs = {
235
+ 'fetal-heart-rate': () =>
236
+ createNumberInput(
237
+ 'fetal-heart-rate-input',
238
+ 'measurementValue',
239
+ getFieldLabel('fetalHeartRate', t),
240
+ getInputRangePlaceholder('fetal-heart-rate', t),
241
+ INPUT_RANGES['fetal-heart-rate'],
242
+ ),
243
+
244
+ 'cervical-dilation': () => (
245
+ <Grid>
246
+ <Column sm={4} md={4} lg={8}>
247
+ {createNumberInput(
248
+ 'cervical-dilation-measurement',
249
+ 'measurementValue',
250
+ getFieldLabel('cervicalDilation', t),
251
+ getInputRangePlaceholder('cervical-dilation', t),
252
+ INPUT_RANGES['cervical-dilation'],
253
+ )}
254
+ </Column>
255
+ <Column sm={4} md={4} lg={8}>
256
+ {createSelect('amniotic-fluid', 'amnioticFluid', getFieldLabel('amnioticFluid', t), AMNIOTIC_FLUID_OPTIONS)}
257
+ </Column>
258
+ <Column sm={4} md={4} lg={8}>
259
+ {createSelect('moulding', 'moulding', getFieldLabel('moulding', t), MOULDING_OPTIONS)}
260
+ </Column>
261
+ </Grid>
262
+ ),
263
+
264
+ 'descent-of-head': () =>
265
+ createSelect(
266
+ 'descent-select',
267
+ 'measurementValue',
268
+ getFieldLabel('descentOfHead', t),
269
+ DESCENT_OF_HEAD_OPTIONS,
270
+ true,
271
+ ),
272
+
273
+ 'uterine-contractions': () => (
274
+ <Grid>
275
+ <Column sm={4} md={4} lg={8}>
276
+ {createNumberInput(
277
+ 'contraction-frequency',
278
+ 'measurementValue',
279
+ getFieldLabel('frequency', t),
280
+ getInputRangePlaceholder('uterine-contractions', t),
281
+ INPUT_RANGES['uterine-contractions'],
282
+ )}
283
+ </Column>
284
+ <Column sm={4} md={4} lg={8}>
285
+ {createSelect(
286
+ 'contraction-intensity',
287
+ 'eventDescription',
288
+ getFieldLabel('intensity', t),
289
+ CONTRACTION_INTENSITY_OPTIONS,
290
+ )}
291
+ </Column>
292
+ </Grid>
293
+ ),
294
+
295
+ 'maternal-pulse': () =>
296
+ createNumberInput(
297
+ 'maternal-pulse-input',
298
+ 'measurementValue',
299
+ getFieldLabel('maternalPulse', t),
300
+ getInputRangePlaceholder('maternal-pulse', t),
301
+ INPUT_RANGES['maternal-pulse'],
302
+ ),
303
+
304
+ 'blood-pressure': () => (
305
+ <Grid>
306
+ <Column sm={4} md={4} lg={8}>
307
+ {createNumberInput(
308
+ 'systolic-pressure',
309
+ 'systolic',
310
+ getFieldLabel('systolic', t),
311
+ getInputRangePlaceholder('systolic-bp', t),
312
+ INPUT_RANGES['systolic-bp'],
313
+ )}
314
+ </Column>
315
+ <Column sm={4} md={4} lg={8}>
316
+ {createNumberInput(
317
+ 'diastolic-pressure',
318
+ 'diastolic',
319
+ getFieldLabel('diastolic', t),
320
+ getInputRangePlaceholder('diastolic-bp', t),
321
+ INPUT_RANGES['diastolic-bp'],
322
+ )}
323
+ </Column>
324
+ </Grid>
325
+ ),
326
+
327
+ temperature: () =>
328
+ createNumberInput(
329
+ 'temperature-input',
330
+ 'measurementValue',
331
+ getFieldLabel('temperature', t),
332
+ getInputRangePlaceholder('temperature', t),
333
+ INPUT_RANGES.temperature,
334
+ ),
335
+
336
+ 'urine-analysis': () => (
337
+ <Grid>
338
+ <Column sm={4} md={2} lg={5}>
339
+ {createSelect('protein-level', 'proteinLevel', getFieldLabel('proteinLevel', t), URINE_LEVEL_OPTIONS)}
340
+ </Column>
341
+ <Column sm={4} md={3} lg={5}>
342
+ {createSelect('glucose-level', 'glucoseLevel', getFieldLabel('glucoseLevel', t), URINE_LEVEL_OPTIONS)}
343
+ </Column>
344
+ <Column sm={4} md={3} lg={6}>
345
+ {createSelect('ketone-level', 'ketoneLevel', getFieldLabel('ketoneLevel', t), URINE_LEVEL_OPTIONS)}
346
+ </Column>
347
+ </Grid>
348
+ ),
349
+
350
+ 'drugs-fluids': () => (
351
+ <Grid>
352
+ <Column sm={4} md={4} lg={8}>
353
+ {createTextInput(
354
+ 'medication-input',
355
+ 'medication',
356
+ getFieldLabel('medication', t),
357
+ getFieldPlaceholder('medicationType', t),
358
+ )}
359
+ </Column>
360
+ <Column sm={4} md={4} lg={8}>
361
+ {createTextInput(
362
+ 'dosage-input',
363
+ 'dosage',
364
+ getFieldLabel('dosageRate', t),
365
+ getFieldPlaceholder('dosageRate', t),
366
+ )}
367
+ </Column>
368
+ </Grid>
369
+ ),
370
+
371
+ 'progress-events': () => (
372
+ <Grid>
373
+ <Column sm={4} md={8} lg={16}>
374
+ {createSelect('event-type', 'eventType', getFieldLabel('eventType', t), EVENT_TYPE_OPTIONS, true)}
375
+ </Column>
376
+ <Column sm={4} md={8} lg={16}>
377
+ <Controller
378
+ name="eventDescription"
379
+ control={control}
380
+ rules={{ required: t('fieldRequired', 'This field is required') }}
381
+ render={({ field, fieldState }) => (
382
+ <TextArea
383
+ id="event-description"
384
+ labelText={getFieldLabel('eventDescription', t)}
385
+ placeholder={getFieldPlaceholder('eventDescription', t)}
386
+ value={field.value || ''}
387
+ onChange={(e) => field.onChange((e.target as HTMLTextAreaElement).value)}
388
+ invalid={!!fieldState.error}
389
+ invalidText={fieldState.error?.message}
390
+ rows={3}
391
+ required
392
+ />
393
+ )}
394
+ />
395
+ </Column>
396
+ </Grid>
397
+ ),
398
+ };
399
+
400
+ const config = fieldConfigs[graphType as keyof typeof fieldConfigs];
401
+ return config
402
+ ? config()
403
+ : createTextInput(
404
+ 'general-measurement',
405
+ 'measurementValue',
406
+ getMeasurementLabel(graphType, t, graphTitle),
407
+ getFieldPlaceholder('generalMeasurement', t),
408
+ );
409
+ };
410
+
411
+ return (
412
+ <Modal
413
+ open={isOpen}
414
+ onRequestClose={onClose}
415
+ modalHeading={`${getMeasurementLabel(graphType, t, graphTitle)} Data`}
416
+ modalLabel={`${patientInfo.name}, ${patientInfo.gender}, ${patientInfo.age}`}
417
+ primaryButtonText={t('save', 'Save')}
418
+ secondaryButtonText={t('cancel', 'Cancel')}
419
+ onRequestSubmit={handleSubmit(onSubmitForm)}
420
+ onSecondarySubmit={handleClose}
421
+ size="lg">
422
+ <div className={styles.modalContent}>
423
+ <Form onSubmit={handleSubmit(onSubmitForm)}>
424
+ <Grid>
425
+ <Column sm={4} md={8} lg={5}>
426
+ {createSelect('admission-select', 'admission', getFieldLabel('admission', t), ADMISSION_OPTIONS)}
427
+ </Column>
428
+ <Column sm={4} md={8} lg={5}>
429
+ {createSelect('bg-select', 'bg', getFieldLabel('bg', t), BLOOD_GROUP_OPTIONS)}
430
+ </Column>
431
+ <Column sm={4} md={8} lg={6}>
432
+ {createSelect('am-select', 'am', getFieldLabel('am', t), TIME_SLOT_OPTIONS)}
433
+ </Column>
434
+ </Grid>
435
+ <div className={styles.measurementSection}>{renderSpecificFields()}</div>
436
+ </Form>
437
+ </div>
438
+ </Modal>
439
+ );
440
+ };
441
+
442
+ export default PartographyDataForm;