@ampath/esm-dha-workflow-app 4.0.0-next.15 → 4.0.0-next.151

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 (379) hide show
  1. package/dist/1197.js +1 -0
  2. package/dist/1277.js +1 -0
  3. package/dist/1277.js.map +1 -0
  4. package/dist/1558.js +2 -0
  5. package/dist/1558.js.map +1 -0
  6. package/dist/1729.js +1 -0
  7. package/dist/1729.js.map +1 -0
  8. package/dist/182.js +1 -0
  9. package/dist/182.js.map +1 -0
  10. package/dist/1826.js +1 -0
  11. package/dist/1826.js.map +1 -0
  12. package/dist/1833.js +1 -0
  13. package/dist/1833.js.map +1 -0
  14. package/dist/1856.js +1 -0
  15. package/dist/1856.js.map +1 -0
  16. package/dist/1925.js +1 -0
  17. package/dist/1925.js.map +1 -0
  18. package/dist/2021.js +1 -0
  19. package/dist/2021.js.map +1 -0
  20. package/dist/2054.js +1 -0
  21. package/dist/2054.js.map +1 -0
  22. package/dist/2177.js +2 -0
  23. package/dist/2177.js.map +1 -0
  24. package/dist/2333.js +1 -0
  25. package/dist/2333.js.map +1 -0
  26. package/dist/2364.js +2 -0
  27. package/dist/{388.js.LICENSE.txt → 2364.js.LICENSE.txt} +15 -0
  28. package/dist/2364.js.map +1 -0
  29. package/dist/2801.js +1 -0
  30. package/dist/2801.js.map +1 -0
  31. package/dist/3041.js +1 -0
  32. package/dist/3041.js.map +1 -0
  33. package/dist/3099.js +1 -0
  34. package/dist/3184.js +2 -0
  35. package/dist/3184.js.map +1 -0
  36. package/dist/3654.js +1 -0
  37. package/dist/3654.js.map +1 -0
  38. package/dist/4055.js +1 -0
  39. package/dist/4205.js +1 -0
  40. package/dist/4205.js.map +1 -0
  41. package/dist/4225.js +1 -0
  42. package/dist/4225.js.map +1 -0
  43. package/dist/4300.js +1 -0
  44. package/dist/4335.js +1 -0
  45. package/dist/4353.js +1 -0
  46. package/dist/4353.js.map +1 -0
  47. package/dist/4517.js +1 -0
  48. package/dist/4517.js.map +1 -0
  49. package/dist/4652.js +1 -0
  50. package/dist/4674.js +1 -0
  51. package/dist/4674.js.map +1 -0
  52. package/dist/4947.js +1 -0
  53. package/dist/4947.js.map +1 -0
  54. package/dist/5015.js +1 -0
  55. package/dist/5015.js.map +1 -0
  56. package/dist/5422.js +1 -0
  57. package/dist/5422.js.map +1 -0
  58. package/dist/5428.js +1 -0
  59. package/dist/5428.js.map +1 -0
  60. package/dist/5752.js +1 -0
  61. package/dist/5752.js.map +1 -0
  62. package/dist/5851.js +1 -0
  63. package/dist/5851.js.map +1 -0
  64. package/dist/6260.js +1 -0
  65. package/dist/6260.js.map +1 -0
  66. package/dist/6264.js +1 -0
  67. package/dist/6264.js.map +1 -0
  68. package/dist/6540.js +2 -0
  69. package/dist/6540.js.map +1 -0
  70. package/dist/6606.js +1 -0
  71. package/dist/6606.js.map +1 -0
  72. package/dist/{709.js → 693.js} +1 -1
  73. package/dist/693.js.map +1 -0
  74. package/dist/6991.js +1 -0
  75. package/dist/6991.js.map +1 -0
  76. package/dist/7199.js +1 -0
  77. package/dist/7199.js.map +1 -0
  78. package/dist/7255.js +1 -0
  79. package/dist/7255.js.map +1 -0
  80. package/dist/7258.js +1 -0
  81. package/dist/7258.js.map +1 -0
  82. package/dist/7420.js +1 -0
  83. package/dist/7420.js.map +1 -0
  84. package/dist/8114.js +1 -0
  85. package/dist/8114.js.map +1 -0
  86. package/dist/8235.js +1 -0
  87. package/dist/8235.js.map +1 -0
  88. package/dist/8339.js +1 -0
  89. package/dist/8339.js.map +1 -0
  90. package/dist/8558.js +1 -0
  91. package/dist/8558.js.map +1 -0
  92. package/dist/8865.js +1 -0
  93. package/dist/8865.js.map +1 -0
  94. package/dist/8895.js +1 -0
  95. package/dist/8895.js.map +1 -0
  96. package/dist/9037.js +1 -0
  97. package/dist/9037.js.map +1 -0
  98. package/dist/9091.js +1 -0
  99. package/dist/9091.js.map +1 -0
  100. package/dist/9093.js +1 -0
  101. package/dist/9093.js.map +1 -0
  102. package/dist/9117.js +1 -0
  103. package/dist/9117.js.map +1 -0
  104. package/dist/9721.js +1 -0
  105. package/dist/9721.js.map +1 -0
  106. package/dist/esm-dha-workflow-app.js +1 -1
  107. package/dist/esm-dha-workflow-app.js.buildmanifest.json +990 -215
  108. package/dist/esm-dha-workflow-app.js.map +1 -1
  109. package/dist/main.js +1 -1
  110. package/dist/main.js.map +1 -1
  111. package/dist/routes.json +1 -1
  112. package/package.json +10 -3
  113. package/src/accounting/accounting.component.tsx +13 -0
  114. package/src/admissions/admission-request-list/admission-request-list.scss +0 -0
  115. package/src/admissions/admission-request-list/admission-request-list.tsx +134 -0
  116. package/src/admissions/admissions-dashboard.component.scss +15 -0
  117. package/src/admissions/admissions-dashboard.component.tsx +160 -0
  118. package/src/admissions/admissions.resource.ts +101 -0
  119. package/src/admissions/admitted-list/admitted-patients-list.tsx +141 -0
  120. package/src/admissions/constants/index.ts +33 -0
  121. package/src/admissions/discharged-list/discharged-list.scss +0 -0
  122. package/src/admissions/discharged-list/discharged-list.tsx +58 -0
  123. package/src/admissions/inpatient/admission-history/patient-admission-history.tsx +76 -0
  124. package/src/admissions/inpatient/admission-requests/patient-admission-requests.scss +19 -0
  125. package/src/admissions/inpatient/admission-requests/patient-admission-requests.tsx +72 -0
  126. package/src/admissions/inpatient/inpatient-admissions.component.scss +7 -0
  127. package/src/admissions/inpatient/inpatient-admissions.component.tsx +46 -0
  128. package/src/admissions/modal/admit-elsewhere/admit-elsewhere.modal.scss +23 -0
  129. package/src/admissions/modal/admit-elsewhere/admit-elsewhere.modal.tsx +156 -0
  130. package/src/admissions/modal/admit-patient/admit-patient.modal.scss +0 -0
  131. package/src/admissions/modal/admit-patient/admit-patient.modal.tsx +109 -0
  132. package/src/admissions/modal/bed-swap/bed-swap.modal.scss +0 -0
  133. package/src/admissions/modal/bed-swap/bed-swap.modal.tsx +102 -0
  134. package/src/admissions/modal/cancel-admission-request/cancel-admission-request.scss +11 -0
  135. package/src/admissions/modal/cancel-admission-request/cancel-admission-request.tsx +105 -0
  136. package/src/admissions/modal/discharge/discharge-patient.modal.scss +13 -0
  137. package/src/admissions/modal/discharge/discharge-patient.modal.tsx +84 -0
  138. package/src/admissions/types/index.ts +192 -0
  139. package/src/appointments/appointments.component.tsx +13 -0
  140. package/src/billing/api/billing.api.ts +107 -0
  141. package/src/billing/billing-root.tsx +20 -0
  142. package/src/billing/dashboard/billingDashboard.component.scss +0 -0
  143. package/src/billing/dashboard/billingDashboard.component.tsx +25 -0
  144. package/src/billing/extensions/visit-billing/visit-billing.extension.scss +0 -0
  145. package/src/billing/extensions/visit-billing/visit-billing.extension.tsx +508 -0
  146. package/src/billing/invoice/bill.resource.ts +47 -0
  147. package/src/billing/invoice/invoice-header/header-card/header-card.scss +17 -0
  148. package/src/billing/invoice/invoice-header/header-card/header-card.tsx +21 -0
  149. package/src/billing/invoice/invoice.scss +113 -0
  150. package/src/billing/invoice/invoice.tsx +1441 -0
  151. package/src/billing/invoice/line-items/line-items.scss +0 -0
  152. package/src/billing/invoice/line-items/line-items.tsx +120 -0
  153. package/src/billing/invoice/modal/delete-bill-item/delete-bill-item.modal.scss +23 -0
  154. package/src/billing/invoice/modal/delete-bill-item/delete-bill-item.modal.tsx +114 -0
  155. package/src/billing/invoice/modal/edit-bill-item/edit-bill-item.modal.scss +0 -0
  156. package/src/billing/invoice/modal/edit-bill-item/edit-bill-item.modal.tsx +122 -0
  157. package/src/billing/invoice/payment-details/payment-details.scss +0 -0
  158. package/src/billing/invoice/payment-details/payment-details.tsx +43 -0
  159. package/src/billing/invoice/print-invoice/print-receipt.component.tsx +44 -0
  160. package/src/billing/invoice/print-invoice/print-receipt.scss +14 -0
  161. package/src/billing/types/index.ts +84 -0
  162. package/src/billing/utils/index.ts +17 -0
  163. package/src/billing/widgets/billingTotalsRow.component.scss +0 -0
  164. package/src/billing/widgets/billingTotalsRow.component.tsx +712 -0
  165. package/src/billing/workspaces/create-order-bill-form-workspace/create-order-bill-form.resource.ts +103 -0
  166. package/src/billing/workspaces/create-order-bill-form-workspace/create-order-bill-form.scss +58 -0
  167. package/src/billing/workspaces/create-order-bill-form-workspace/create-order-bill-form.workspace.tsx +349 -0
  168. package/src/billing/workspaces/create-order-bill-form-workspace/schema.ts +11 -0
  169. package/src/bookings/bookings.component.scss +7 -0
  170. package/src/bookings/bookings.component.tsx +31 -0
  171. package/src/bookings/daily/daily-bookings.component.scss +38 -0
  172. package/src/bookings/daily/daily-bookings.component.tsx +138 -0
  173. package/src/bookings/daily/daily-bookings.resource.ts +28 -0
  174. package/src/bookings/daily/filters/daily-bookings-filter.component.scss +15 -0
  175. package/src/bookings/daily/filters/daily-bookings-filter.component.tsx +80 -0
  176. package/src/bookings/daily/patient-list/daily-bookings-patient-list.component.tsx +97 -0
  177. package/src/bookings/types/index.ts +68 -0
  178. package/src/config-schema.ts +91 -1
  179. package/src/createDashboardLink.tsx +9 -0
  180. package/src/dashboard/charts/chart.component.scss +13 -0
  181. package/src/dashboard/charts/chart.component.tsx +56 -0
  182. package/src/dashboard/dashboard.component.scss +7 -0
  183. package/src/dashboard/dashboard.component.tsx +51 -0
  184. package/src/dashboard/overview/overview.component.scss +150 -0
  185. package/src/dashboard/overview/overview.component.tsx +134 -0
  186. package/src/dashboard/patient-list/patient-list.component.tsx +41 -0
  187. package/src/dashboard-meta/accounting-dashboard.meta.ts +6 -0
  188. package/src/dashboard-meta/admissions-dashboard.meta.ts +6 -0
  189. package/src/dashboard-meta/billing-dashboard.meta.ts +6 -0
  190. package/src/dashboard-meta/bookings-dashboard.meta.ts +6 -0
  191. package/src/dashboard-meta/consultation-dashboard.meta.ts +6 -0
  192. package/src/dashboard-meta/dha-workflow-dashboard.meta.ts +6 -0
  193. package/src/dashboard-meta/inpatient-admissions.meta.ts +6 -0
  194. package/src/dashboard-meta/maternity-dashboard.meta.ts +6 -0
  195. package/src/dashboard-meta/mch-dashboard.meta.ts +6 -0
  196. package/src/dashboard-meta/pharmacy-dashboard.meta.ts +6 -0
  197. package/src/dashboard-meta/queue-dashboard.meta.ts +6 -0
  198. package/src/dashboard-meta/registers-dashboard.meta.ts +6 -0
  199. package/src/dashboard-meta/registry-dashboard.meta.ts +6 -0
  200. package/src/dashboard-meta/service-queue-admin.meta.ts +6 -0
  201. package/src/dashboard-meta/triage-dashboard.meta.ts +6 -0
  202. package/src/hooks/useActions.ts +19 -2
  203. package/src/index.ts +110 -15
  204. package/src/laboratory/laboratory.component.tsx +13 -0
  205. package/src/mnch/maternity/maternity-queues.component.scss +7 -0
  206. package/src/mnch/maternity/maternity-queues.component.tsx +28 -0
  207. package/src/mnch/maternity/queues/triage/maternity-triage.tsx +15 -0
  208. package/src/mnch/mch/mch-queues.component.scss +7 -0
  209. package/src/mnch/mch/mch-queues.component.tsx +32 -0
  210. package/src/mnch/mch/queues/consultation/mch-consultation.tsx +18 -0
  211. package/src/mnch/mch/queues/triage/mch-triage.tsx +15 -0
  212. package/src/mnch/mnch-root.tsx +17 -0
  213. package/src/mortuary/mortuary.component.tsx +13 -0
  214. package/src/pharmacy/pharmacy.component.tsx +13 -0
  215. package/src/registers/registers.component.tsx +8 -0
  216. package/src/registry/eligibility/eliigibility-tags/eligibility-tags.scss +6 -0
  217. package/src/registry/eligibility/eliigibility-tags/eligibility-tags.tsx +137 -0
  218. package/src/registry/eligibility/modal/eligibility-details.modal.scss +38 -0
  219. package/src/registry/eligibility/modal/eligibility-details.modal.tsx +131 -0
  220. package/src/registry/modal/client-details-modal/client-details-modal.tsx +9 -26
  221. package/src/registry/modal/otp-verification-modal/otp-verification-modal.scss +31 -1
  222. package/src/registry/modal/otp-verification-modal/otp-verification-modal.tsx +139 -54
  223. package/src/registry/modal/send-to-triage/send-to-triage.modal.scss +9 -1
  224. package/src/registry/modal/send-to-triage/send-to-triage.modal.tsx +665 -45
  225. package/src/registry/payment-details/payment-options/payment-options.scss +13 -0
  226. package/src/registry/payment-details/payment-options/payment-options.tsx +61 -14
  227. package/src/registry/registry.component.scss +6 -0
  228. package/src/registry/registry.component.tsx +94 -27
  229. package/src/registry/registry.resource.ts +10 -6
  230. package/src/registry/types/index.ts +120 -0
  231. package/src/registry/utils/hie-client-adapter.ts +3 -0
  232. package/src/registry/utils/mask-data.ts +11 -0
  233. package/src/resources/dashboard.resource.ts +20 -0
  234. package/src/resources/identifier-types.ts +2 -0
  235. package/src/resources/patient-resource.ts +3 -1
  236. package/src/resources/queue.resource.ts +24 -1
  237. package/src/resources/superset.resource.ts +21 -0
  238. package/src/resources/visit.resource.ts +19 -1
  239. package/src/root.component.tsx +27 -6
  240. package/src/routes.json +222 -15
  241. package/src/{consultation → service-queues}/action-button.component.tsx +2 -2
  242. package/src/{consultation → service-queues}/action-overflow-menu-item.component.tsx +2 -2
  243. package/src/service-queues/admin/queue/modal/create-queue/create-queue.modal.scss +31 -0
  244. package/src/service-queues/admin/queue/modal/create-queue/create-queue.modal.tsx +143 -0
  245. package/src/service-queues/admin/queue/modal/edit-queue/edit-queue.modal.scss +0 -0
  246. package/src/service-queues/admin/queue/modal/edit-queue/edit-queue.modal.tsx +154 -0
  247. package/src/service-queues/admin/queue/queue-list/queue-list.scss +33 -0
  248. package/src/service-queues/admin/queue/queue-list/queue-list.tsx +113 -0
  249. package/src/service-queues/admin/queue-entry/queue-entry-list.component.scss +6 -0
  250. package/src/service-queues/admin/queue-entry/queue-entry-list.component.tsx +137 -0
  251. package/src/service-queues/admin/queue-room/modal/create-queue-room/create-queue-room.modal.scss +31 -0
  252. package/src/service-queues/admin/queue-room/modal/create-queue-room/create-queue-room.modal.tsx +137 -0
  253. package/src/service-queues/admin/queue-room/modal/edit-queue-room/edit-queue-room.modal.scss +0 -0
  254. package/src/service-queues/admin/queue-room/modal/edit-queue-room/edit-queue-room.modal.tsx +146 -0
  255. package/src/service-queues/admin/queue-room/queue-room-list/queue-room-list.scss +22 -0
  256. package/src/service-queues/admin/queue-room/queue-room-list/queue-room-list.tsx +120 -0
  257. package/src/service-queues/admin/service-queue-admin-dashboard.component.scss +6 -0
  258. package/src/service-queues/admin/service-queue-admin-dashboard.component.tsx +34 -0
  259. package/src/service-queues/consultation/consultation.component.scss +7 -0
  260. package/src/service-queues/consultation/consultation.component.tsx +15 -0
  261. package/src/service-queues/extensions/service-queue-patient-banner/service-queue-patient-banner.scss +30 -0
  262. package/src/service-queues/extensions/service-queue-patient-banner/service-queue-patient-banner.tsx +108 -0
  263. package/src/service-queues/metrics/metrics-cards/attended-patients.extension.tsx +38 -0
  264. package/src/service-queues/metrics/metrics-cards/waiting-patients.extension.tsx +34 -0
  265. package/src/service-queues/metrics/metrics-container.component.tsx +23 -0
  266. package/src/{metrics → service-queues/metrics}/metrics.resource.ts +0 -36
  267. package/src/service-queues/modals/daily-report-patient-list/daily-report-patient-list.scss +26 -0
  268. package/src/service-queues/modals/daily-report-patient-list/daily-report-patient-list.tsx +108 -0
  269. package/src/service-queues/modals/move/move-patient.component.scss +35 -0
  270. package/src/service-queues/modals/move/move-patient.component.tsx +152 -0
  271. package/src/service-queues/modals/serve/serve-patient.comppnent.scss +0 -0
  272. package/src/service-queues/modals/serve/serve-patient.comppnent.tsx +80 -0
  273. package/src/service-queues/modals/sign-off/sign-off.modal.scss +0 -0
  274. package/src/service-queues/modals/sign-off/sign-off.modal.tsx +79 -0
  275. package/src/service-queues/modals/transition/transition-patient.component.scss +0 -0
  276. package/src/service-queues/modals/transition/transition-patient.component.tsx +122 -0
  277. package/src/service-queues/queue-list/check-in.service.ts +26 -0
  278. package/src/service-queues/queue-list/queue-list.component.scss +50 -0
  279. package/src/service-queues/queue-list/queue-list.component.tsx +302 -0
  280. package/src/service-queues/queue-room.component.tsx +39 -0
  281. package/src/service-queues/room/room.component.tsx +58 -0
  282. package/src/service-queues/service-queue/service-queue.component.scss +14 -0
  283. package/src/service-queues/service-queue/service-queue.component.tsx +399 -0
  284. package/src/service-queues/service-queue/stats/stat-details/stat-details.component.scss +12 -0
  285. package/src/service-queues/service-queue/stats/stat-details/stat-details.component.tsx +63 -0
  286. package/src/service-queues/service-queue.scss +27 -0
  287. package/src/service-queues/service-queue.tsx +37 -0
  288. package/src/service-queues/service-queues.resource.ts +303 -4
  289. package/src/service-queues/service.resource.ts +28 -0
  290. package/src/shared/constants/concepts.ts +18 -0
  291. package/src/shared/constants/index.ts +1 -2
  292. package/src/shared/constants/patient-category.ts +6 -0
  293. package/src/shared/constants/patient-type.ts +10 -0
  294. package/src/shared/constants/visit-types.ts +7 -0
  295. package/src/shared/services/billing.resource.ts +38 -0
  296. package/src/shared/services/client-payment-mode.resource.ts +27 -0
  297. package/src/shared/services/client-payment.resource.ts +17 -0
  298. package/src/shared/services/eligibility.resource.ts +19 -0
  299. package/src/shared/services/encounters.resource.ts +27 -0
  300. package/src/shared/services/location.resource.ts +9 -0
  301. package/src/shared/types/index.ts +152 -0
  302. package/src/shared/ui/aggregate-stat-card/aggregate-stat-card.scss +42 -0
  303. package/src/shared/ui/aggregate-stat-card/aggregate-stat-card.tsx +42 -0
  304. package/src/shared/ui/confirm-modal/confirm.modal.scss +18 -0
  305. package/src/shared/ui/confirm-modal/confirm.modal.tsx +38 -0
  306. package/src/shared/ui/otp-input/otp-input.component.scss +14 -0
  307. package/src/shared/ui/otp-input/otp-input.component.tsx +90 -0
  308. package/src/shared/ui/stat-card/stat-card.component.scss +10 -0
  309. package/src/shared/ui/stat-card/stat-card.component.tsx +26 -0
  310. package/src/shared/ui/timer/timer.component.scss +5 -0
  311. package/src/shared/ui/timer/timer.component.tsx +40 -0
  312. package/src/shared/utils/get-base-url.ts +27 -0
  313. package/src/shared/utils/get-tag-type.ts +66 -0
  314. package/src/side-nav-menu/mnch-nav-link-config.ts +16 -0
  315. package/src/side-nav-menu/mnch-nav-links.tsx +42 -0
  316. package/src/side-nav-menu/nav-link-config.ts +6 -4
  317. package/src/triage/metrics/attended-patients.extension.tsx +42 -0
  318. package/src/triage/metrics/metrics.scss +36 -0
  319. package/src/triage/metrics/triage-metrics.component.tsx +21 -0
  320. package/src/triage/metrics/waiting-patients.extension.tsx +39 -0
  321. package/src/triage/room/room.scss +29 -0
  322. package/src/triage/triage.component.tsx +15 -0
  323. package/src/triage/triage.resource.ts +19 -0
  324. package/src/triage/types.ts +16 -0
  325. package/src/types/types.ts +82 -2
  326. package/dist/104.js +0 -2
  327. package/dist/104.js.map +0 -1
  328. package/dist/184.js +0 -2
  329. package/dist/184.js.map +0 -1
  330. package/dist/197.js +0 -1
  331. package/dist/255.js +0 -1
  332. package/dist/255.js.map +0 -1
  333. package/dist/300.js +0 -1
  334. package/dist/306.js +0 -1
  335. package/dist/306.js.map +0 -1
  336. package/dist/335.js +0 -1
  337. package/dist/353.js +0 -1
  338. package/dist/353.js.map +0 -1
  339. package/dist/388.js +0 -2
  340. package/dist/388.js.map +0 -1
  341. package/dist/420.js +0 -1
  342. package/dist/420.js.map +0 -1
  343. package/dist/460.js +0 -1
  344. package/dist/460.js.map +0 -1
  345. package/dist/540.js +0 -2
  346. package/dist/540.js.map +0 -1
  347. package/dist/55.js +0 -1
  348. package/dist/560.js +0 -1
  349. package/dist/560.js.map +0 -1
  350. package/dist/635.js +0 -1
  351. package/dist/635.js.map +0 -1
  352. package/dist/652.js +0 -1
  353. package/dist/695.js +0 -1
  354. package/dist/695.js.map +0 -1
  355. package/dist/709.js.map +0 -1
  356. package/dist/710.js +0 -2
  357. package/dist/710.js.map +0 -1
  358. package/dist/91.js +0 -1
  359. package/dist/91.js.map +0 -1
  360. package/dist/93.js +0 -1
  361. package/dist/93.js.map +0 -1
  362. package/dist/978.js +0 -1
  363. package/dist/978.js.map +0 -1
  364. package/dist/99.js +0 -1
  365. package/src/consultation/consultation-room.component.tsx +0 -60
  366. package/src/consultation/consultation.scss +0 -5
  367. package/src/consultation/consultation.tsx +0 -14
  368. package/src/hooks/useQueueEntries.ts +0 -35
  369. package/src/metrics/metrics-cards/attended-patients.extension.tsx +0 -18
  370. package/src/metrics/metrics-cards/waiting-patients.extension.tsx +0 -18
  371. package/src/metrics/metrics-container.component.tsx +0 -16
  372. package/src/registry/mock-client.ts +0 -627
  373. /package/dist/{710.js.LICENSE.txt → 1558.js.LICENSE.txt} +0 -0
  374. /package/dist/{104.js.LICENSE.txt → 2177.js.LICENSE.txt} +0 -0
  375. /package/dist/{184.js.LICENSE.txt → 3184.js.LICENSE.txt} +0 -0
  376. /package/dist/{540.js.LICENSE.txt → 6540.js.LICENSE.txt} +0 -0
  377. /package/src/{metrics → service-queues/metrics}/metrics-cards/metrics-card.component.tsx +0 -0
  378. /package/src/{metrics → service-queues/metrics}/metrics-cards/metrics-card.scss +0 -0
  379. /package/src/{metrics → service-queues/metrics}/metrics-container.scss +0 -0
@@ -1,8 +1,8 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useMemo, useState } from 'react';
2
2
  import {
3
3
  Button,
4
4
  Checkbox,
5
- InlineLoading,
5
+ ComboBox,
6
6
  Modal,
7
7
  ModalBody,
8
8
  Select,
@@ -13,13 +13,45 @@ import {
13
13
  TableHead,
14
14
  TableHeader,
15
15
  TableRow,
16
+ TextInput,
16
17
  } from '@carbon/react';
17
18
  import styles from './send-to-triage.modal.scss';
18
- import { type Patient, useVisitTypes, useSession, showSnackbar } from '@openmrs/esm-framework';
19
- import { type HieClient, type CreateVisitDto, type QueueEntryDto, type ServiceQueue } from '../../types';
20
- import { createQueueEntry, fetchServiceQueuesByLocationUuid } from '../../../resources/queue.resource';
19
+ import { type Patient, useSession, showSnackbar, type Visit, useConfig } from '@openmrs/esm-framework';
20
+ import {
21
+ type HieClient,
22
+ type CreateVisitDto,
23
+ type QueueEntryDto,
24
+ type ServiceQueue,
25
+ PaymentDetail,
26
+ type VisitAttribute,
27
+ } from '../../types';
28
+ import { createQueueEntry, getFacilityServiceQueues } from '../../../resources/queue.resource';
21
29
  import { QUEUE_PRIORITIES_UUIDS, QUEUE_STATUS_UUIDS } from '../../../shared/constants/concepts';
22
30
  import { createVisit } from '../../../resources/visit.resource';
31
+ import {
32
+ createBill,
33
+ fetchBillableServices,
34
+ fetchCashPoints,
35
+ fetchPaymentModes,
36
+ } from '../../../shared/services/billing.resource';
37
+ import {
38
+ type PayableBillableService,
39
+ type ServicePrice,
40
+ type BillableService,
41
+ type PaymentMode,
42
+ type CreateBillDto,
43
+ type CashPoint,
44
+ type CreateOrderEncounterDto,
45
+ } from '../../../shared/types';
46
+ import { PatientCategories } from '../../../shared/constants/patient-category';
47
+ import { VisitTypeUuids } from '../../../shared/constants/visit-types';
48
+ import { type Bill } from '../../../billing/types';
49
+ import { fetchPatientBills } from '../../../billing/invoice/bill.resource';
50
+ import { type QueueEntry } from '../../../types/types';
51
+ import { getActiveQueueEntryByPatientUuid } from '../../../service-queues/service-queues.resource';
52
+ import { createOrderEncounter } from '../../../shared/services/encounters.resource';
53
+ import { type ConfigObject } from '../../../config-schema';
54
+ import { PatientTypes } from '../../../shared/constants/patient-type';
23
55
 
24
56
  interface SendToTriageModalProps {
25
57
  patients: Patient[];
@@ -42,51 +74,243 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
42
74
  }) => {
43
75
  const [selectedPatient, setSelectedPatient] = useState<Patient>();
44
76
  const [selectedVisitType, setSelectedVisitType] = useState<string>();
77
+ const [selectedPatientType, setSelectedPatientType] = useState<string>();
45
78
  const [serviceQueues, setServiceQueues] = useState<ServiceQueue[]>();
46
79
  const [selectedServiceQueue, setSelectedServiceQueue] = useState<string>();
80
+ const [paymentModes, setPaymentModes] = useState<PaymentMode[]>([]);
81
+ const [cashPoints, setCashPoints] = useState<CashPoint[]>([]);
82
+ const [selectedCashPoint, setSelectedCashPoint] = useState<CashPoint>(null);
83
+ const [selectedPaymentMode, setSelectedPaymentMode] = useState<PaymentMode>(null);
47
84
  const [selectedPriority, setSelectedPriority] = useState<string>('');
85
+ const [selectedPaymentDetail, setSelectedPaymentDetail] = useState<string>();
86
+ const [billableServices, setBillableServices] = useState<BillableService[]>([]);
87
+ const [servicePrices, setServicePrices] = useState<ServicePrice[]>([]);
88
+ const [filteredBillableServices, setFilteredBillableServices] = useState<ServicePrice[]>(null);
89
+ const [selectedBillableService, setSelectedBillableService] = useState<ServicePrice | null>(null);
90
+ const [selectedInsuranceScheme, setSelectedInsuranceScheme] = useState<string>('');
91
+ const [selectedInsurancePolicy, setSelectedInsurancePolicy] = useState<string>('');
92
+ const [selectedPatientCategory, setSelectedPatientCategory] = useState<string>('');
93
+ const [currentQueueEntry, setCurrentQueueEntry] = useState<QueueEntry>();
94
+ const [patientBills, setPatientBills] = useState<Bill[]>([]);
95
+ const [billCreated, setBillCreated] = useState<boolean>(false);
96
+ const [disableSubmission, setDisableSubmission] = useState<boolean>(false);
48
97
  const [loading, setLoading] = useState<boolean>(false);
49
- const visitTypes = useVisitTypes();
50
98
  const session = useSession();
51
99
  const locationUuid = session.sessionLocation.uuid;
100
+ const {
101
+ registrationBillableServices,
102
+ cashConsulationConceptUuid,
103
+ shaConsulationConceptUuid,
104
+ outPatientCareSettingUuid,
105
+ orderEncounterTypeUuid,
106
+ registrationServicequeues
107
+ } = useConfig<ConfigObject>();
108
+
109
+ const facilityCashPoints = useMemo(() => getfacilityCashpoints(), [cashPoints, locationUuid]);
110
+
111
+ const visitTypeOptions = useMemo(
112
+ () => [
113
+ {
114
+ text: 'OPD',
115
+ id: VisitTypeUuids.OPD_VISIT_TYPE_UUID,
116
+ },
117
+ {
118
+ text: 'Inpatient',
119
+ id: VisitTypeUuids.INPATIENT_VISIT_TYPE_UUID,
120
+ },
121
+ ],
122
+ [client],
123
+ );
124
+
125
+ const patientTypeOptions = useMemo(
126
+ () => [
127
+ {
128
+ text: 'Walk-In',
129
+ id: PatientTypes.WALK_IN_UUID,
130
+ },
131
+ {
132
+ text: 'Self-Referral',
133
+ id: PatientTypes.SELF_RERERRAL_UUID,
134
+ },
135
+ {
136
+ text: 'Referral from another Facility',
137
+ id: PatientTypes.REFERRAL_FROM_ANOTHER_FACILITY_UUID,
138
+ },
139
+ {
140
+ text: 'Referral from Community',
141
+ id: PatientTypes.REFERRED_BY_COMMUNITY_HEALTH_WORKER_UUID,
142
+ },
143
+ ],
144
+ [client],
145
+ );
146
+
147
+ const paymentDetails = Object.values(PaymentDetail).map((value) => {
148
+ return {
149
+ id: value,
150
+ label: value,
151
+ };
152
+ });
52
153
  useEffect(() => {
53
154
  getServiceQueues();
155
+ getPaymentMethods();
156
+ getBillableServices();
157
+ getCashPoints();
158
+ getPatientBills();
159
+ getPatientActiveQueue();
54
160
  }, [patients]);
55
161
  if (!patients) {
56
162
  return <>No Client data</>;
57
163
  }
58
- const registerOnAfyaYangu = () => {
59
- window.open('https://afyayangu.go.ke/', '_blank');
60
- };
164
+
165
+ async function getPatientActiveQueue() {
166
+ if (patients && patients.length > 0) {
167
+ const activePatient = patients[0];
168
+ try {
169
+ const resp = await getActiveQueueEntryByPatientUuid(activePatient.uuid);
170
+ setCurrentQueueEntry(resp.length > 0 ? resp[0] : null);
171
+ } catch (error) {
172
+ showAlert('error', 'Error getting patient active queue', '');
173
+ }
174
+ }
175
+ }
176
+
177
+ async function getPatientBills() {
178
+ if (patients) {
179
+ let bills: Bill[] = [];
180
+ setPatientBills([]);
181
+ for (let i = 0; i < patients.length; i++) {
182
+ const resp = await fetchPatientBills(patients[i].uuid);
183
+ const todaysBills = getTodaysBills(resp);
184
+ setPatientBills(todaysBills);
185
+ }
186
+ }
187
+ }
188
+ function getTodaysBills(bills: Bill[]) {
189
+ const today = new Date();
190
+ return bills.filter((b) => {
191
+ const billDate = new Date(b.dateCreated);
192
+ return (
193
+ billDate.getFullYear() === today.getFullYear() &&
194
+ billDate.getMonth() === today.getMonth() &&
195
+ billDate.getDate() === today.getDate()
196
+ );
197
+ });
198
+ }
61
199
  const sendToTriage = async () => {
200
+ if (disableSubmission) {
201
+ showAlert(
202
+ 'error',
203
+ 'Form already Submitted',
204
+ 'Form has already been submitted, please wait for the visit,queue and bill to be created',
205
+ );
206
+ return;
207
+ }
208
+ setDisableSubmission(true);
209
+ if (!validateVisitQueueBill()) {
210
+ setDisableSubmission(false);
211
+ return;
212
+ }
62
213
  setLoading(true);
63
214
  try {
64
- const newVisit = await createPatientVisit();
215
+ const newVisit: Visit = await createPatientVisit();
65
216
  if (newVisit) {
66
- const addToTriageQueueDto: QueueEntryDto = generateAddToTriageDto(newVisit.uuid);
217
+ const addToTriageQueueDto: QueueEntryDto = generateAddToTriageDto(newVisit);
67
218
  const queueEntryResp = await createQueueEntry(addToTriageQueueDto);
219
+
68
220
  if (queueEntryResp) {
69
221
  showAlert('success', 'Patient has succesfully been moved to the Triage queue', '');
222
+ }
223
+
224
+ // add bill if it was a paying client
225
+ let createBillResp = null;
226
+ if (selectedPaymentDetail === PaymentDetail.Paying) {
227
+ const createBillDto = generateCreateBillDto();
228
+ if (isValidCreateBillDto(createBillDto) && !billCreated) {
229
+ createBillResp = await createBill(createBillDto);
230
+ if (createBillResp) {
231
+ setBillCreated(true);
232
+ showAlert('success', 'Bill succesfully created', '');
233
+ }
234
+ // create consulation order
235
+ await createOrder(selectedPatient.uuid, newVisit.uuid);
236
+ } else {
237
+ return false;
238
+ }
239
+ }
240
+
241
+ if (
242
+ (queueEntryResp && PaymentDetail.Paying && (createBillResp || billCreated)) ||
243
+ (queueEntryResp && PaymentDetail.NonPaying)
244
+ ) {
70
245
  onModalClose({ success: true });
71
246
  }
72
247
  }
73
248
  } catch (error) {
74
- showAlert('error', 'Error creating visit', '');
249
+ setDisableSubmission(false);
250
+ showAlert('error', error.message ?? 'Error creating visit', '');
75
251
  } finally {
76
252
  setLoading(false);
77
253
  }
78
254
  };
79
- const generateAddToTriageDto = (newVisitUuid: string): QueueEntryDto => {
255
+ function validateVisitQueueBill(): boolean {
256
+ if (!selectedPatient) {
257
+ showAlert('error', 'Please select a patient', '');
258
+ return false;
259
+ }
260
+ if (!selectedPaymentDetail) {
261
+ showAlert('error', 'Please select a paying or non paying option', '');
262
+ return false;
263
+ }
264
+
265
+ if (!isValidServiceQueueSelected()) {
266
+ return false;
267
+ }
268
+
269
+ if (selectedPaymentDetail === PaymentDetail.Paying) {
270
+ if (!selectedPaymentMode) {
271
+ showAlert('error', 'Please select a payment method', '');
272
+ return false;
273
+ }
274
+ if (!selectedBillableService) {
275
+ showAlert('error', 'Please select a billable service', '');
276
+ return false;
277
+ }
278
+ if (!selectedCashPoint) {
279
+ showAlert('error', 'Please select a cashpoint', '');
280
+ return false;
281
+ }
282
+ }
283
+ if (selectedPaymentDetail === PaymentDetail.NonPaying) {
284
+ if (!selectedPatientCategory) {
285
+ showAlert('error', 'Please select a patient category', '');
286
+ return false;
287
+ }
288
+ }
289
+ if (!selectedVisitType) {
290
+ showAlert('error', 'Please select a visit type', '');
291
+ return false;
292
+ }
293
+ if (!selectedServiceQueue) {
294
+ showAlert('error', 'Please select a service queue', '');
295
+ return false;
296
+ }
297
+ if (!selectedPriority) {
298
+ showAlert('error', 'Please select a service queue priority', '');
299
+ return false;
300
+ }
301
+ return true;
302
+ }
303
+ const generateAddToTriageDto = (newVisit: Visit): QueueEntryDto => {
80
304
  const payload: QueueEntryDto = {
81
305
  visit: {
82
- uuid: newVisitUuid,
306
+ uuid: newVisit.uuid,
83
307
  },
84
308
  queueEntry: {
85
309
  status: {
86
310
  uuid: QUEUE_STATUS_UUIDS.WAITING_UUID,
87
311
  },
88
312
  priority: {
89
- uuid: selectedPriority,
313
+ uuid: selectedPriority ?? QUEUE_PRIORITIES_UUIDS.NORMAL_PRIORITY_UUID,
90
314
  },
91
315
  queue: {
92
316
  uuid: selectedServiceQueue,
@@ -94,7 +318,7 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
94
318
  patient: {
95
319
  uuid: selectedPatient.uuid,
96
320
  },
97
- startedAt: new Date().toISOString(),
321
+ startedAt: newVisit.startDatetime,
98
322
  sortWeight: 0,
99
323
  },
100
324
  };
@@ -103,23 +327,104 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
103
327
  const onPatientSelect = (patient: Patient) => {
104
328
  setSelectedPatient(patient);
105
329
  };
106
- const getServiceQueues = async () => {
107
- const resp = await fetchServiceQueuesByLocationUuid(locationUuid);
108
- if (resp && resp.results) {
109
- setServiceQueues(resp.results);
110
- }
111
- };
112
- const visitTypeChangeHandler = ($event: any) => {
113
- const vt = $event.target.value as unknown as string;
330
+ const visitTypeChangeHandler = (selectedVisitType: { selectedItem: { id: string; text: string } }) => {
331
+ const vt = selectedVisitType.selectedItem.id;
114
332
  setSelectedVisitType(vt);
115
333
  };
334
+ const isValidServiceQueueSelected = () => {
335
+ if (!currentQueueEntry) {
336
+ return true;
337
+ }
338
+ if (currentQueueEntry.queue.uuid) {
339
+ showAlert(
340
+ 'error',
341
+ 'Patient already in queue',
342
+ `Patient is already in the ${currentQueueEntry.queue.display} queue, remove them first or contact support`,
343
+ );
344
+ return false;
345
+ }
346
+ return true;
347
+ };
116
348
  const serviceChangeHandler = ($event: any) => {
117
- const sq = $event.target.value as unknown as string;
118
- setSelectedServiceQueue(sq);
349
+ if (isValidServiceQueueSelected()) {
350
+ const sq = $event.target.value as unknown as string;
351
+ setSelectedServiceQueue(sq);
352
+ }
119
353
  };
120
354
  const priorityChangeHandler = (priorityUuid: string) => {
121
355
  setSelectedPriority(priorityUuid);
122
356
  };
357
+ const paymentDetailsHandler = (paymentDetailSelected: string) => {
358
+ setSelectedPaymentDetail(paymentDetailSelected);
359
+ };
360
+ const paymentMethodHandler = (selectedPaymentModeUuid: string) => {
361
+ const selectedPaymentMode = paymentModes.find((pm) => {
362
+ return pm.uuid === selectedPaymentModeUuid;
363
+ });
364
+ setSelectedPaymentMode(selectedPaymentMode);
365
+ const paymentModeBillableServices = getBillableServiceByPaymentMode(selectedPaymentMode);
366
+ setFilteredBillableServices(paymentModeBillableServices);
367
+ setSelectedInsuranceScheme('');
368
+ setSelectedInsurancePolicy('');
369
+ setSelectedPriority('');
370
+ };
371
+ const getBillableServiceByPaymentMode = (paymentMode: PaymentMode): PayableBillableService[] => {
372
+ const paymentBillableServices: ServicePrice[] = [];
373
+ servicePrices.forEach((sp) => {
374
+ if (sp.paymentMode) {
375
+ if (
376
+ sp.paymentMode.uuid === paymentMode.uuid &&
377
+ registrationBillableServices.includes(sp.billableService.uuid)
378
+ ) {
379
+ paymentBillableServices.push(sp);
380
+ }
381
+ }
382
+ });
383
+ return paymentBillableServices;
384
+ };
385
+ const billableServicesHandler = (selectedBillableServiceUuid: string) => {
386
+ const selectedBillableService = servicePrices.find((sp) => {
387
+ return sp.uuid === selectedBillableServiceUuid;
388
+ });
389
+ if (isValidBillableService(selectedBillableService)) {
390
+ setSelectedBillableService(selectedBillableService);
391
+ } else {
392
+ setSelectedBillableService(null);
393
+ showAlert('error', 'Existing bill', 'Patient has a similar bill');
394
+ }
395
+ };
396
+ const isValidBillableService = (selectedService: ServicePrice) => {
397
+ // check if patient has been billed for similar service
398
+ let isValid = true;
399
+ patientBills.forEach((b) => {
400
+ const lineItems = b.lineItems;
401
+ lineItems.forEach((l) => {
402
+ if (l.billableService === selectedService.billableService.display) {
403
+ isValid = false;
404
+ }
405
+ });
406
+ });
407
+ return isValid;
408
+ };
409
+ const cashPointsHandler = (selectedCashPointUuid: string) => {
410
+ const selectedCashPoint = cashPoints.find((cp) => {
411
+ return cp.uuid === selectedCashPointUuid;
412
+ });
413
+ setSelectedCashPoint(selectedCashPoint);
414
+ };
415
+ const patientTypeHandler = (selectedPatientType: { selectedItem: { id: string; text: string } }) => {
416
+ const pt = selectedPatientType.selectedItem.id;
417
+ setSelectedPatientType(pt);
418
+ };
419
+ const insuranceSchemeHandler = (selectedInsuranceScheme: string) => {
420
+ setSelectedInsuranceScheme(selectedInsuranceScheme);
421
+ };
422
+ const insurancePolicyHandler = (selectedInsurancePolicy: string) => {
423
+ setSelectedInsurancePolicy(selectedInsurancePolicy);
424
+ };
425
+ const patientCategoryHandler = (categoryUuid: string) => {
426
+ setSelectedPatientCategory(categoryUuid);
427
+ };
123
428
  const createPatientVisit = async () => {
124
429
  const visitDto = getCreateVisitDto();
125
430
  if (!isValidCreateVisitDto(visitDto)) {
@@ -149,16 +454,25 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
149
454
  showAlert('error', 'Please select a visit', '');
150
455
  return false;
151
456
  }
457
+ if(!selectedPatientType){
458
+ showAlert('error', 'Please select a patient type', '');
459
+ return false;
460
+ }
152
461
  return true;
153
462
  };
154
463
  const getCreateVisitDto = (): CreateVisitDto => {
155
- return {
464
+ const visitAttributes = getVisitAttributes();
465
+ const visitDto: CreateVisitDto = {
156
466
  visitType: selectedVisitType,
157
467
  location: locationUuid,
158
468
  startDatetime: null,
159
469
  stopDatetime: null,
160
- patient: selectedPatient?.uuid ?? '',
470
+ patient: selectedPatient?.uuid,
161
471
  };
472
+ if (visitAttributes.length > 0) {
473
+ visitDto['attributes'] = visitAttributes;
474
+ }
475
+ return visitDto;
162
476
  };
163
477
  const showAlert = (alertType: 'error' | 'success', title: string, subtitle: string) => {
164
478
  showSnackbar({
@@ -168,6 +482,192 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
168
482
  });
169
483
  };
170
484
 
485
+ function getVisitAttributes(): VisitAttribute[] {
486
+ const attributes: VisitAttribute[] = [];
487
+ if (selectedInsuranceScheme) {
488
+ attributes.push({
489
+ attributeType: '3a988e33-a6c0-4b76-b924-01abb998944b',
490
+ value: selectedInsuranceScheme,
491
+ });
492
+ }
493
+ if (selectedInsurancePolicy) {
494
+ attributes.push({
495
+ attributeType: 'aac48226-d143-4274-80e0-264db4e368ee',
496
+ value: selectedInsurancePolicy,
497
+ });
498
+ }
499
+ if (selectedPaymentMode) {
500
+ attributes.push({
501
+ attributeType: '8553afa0-bdb9-4d3c-8a98-05fa9350aa85',
502
+ value: selectedPaymentMode.uuid,
503
+ });
504
+ }
505
+ if(selectedPatientType) {
506
+ attributes.push({
507
+ attributeType: 'fbc0702d-b4c9-4968-be63-af8ad3ad6239',
508
+ value: selectedPatientType,
509
+ });
510
+ }
511
+ if(selectedPaymentDetail === PaymentDetail.NonPaying){
512
+ attributes.push({
513
+ attributeType: 'df0362f9-782e-4d92-8bb2-3112e9e9eb3c',
514
+ value: 'true',
515
+ });
516
+ }
517
+ return attributes;
518
+ }
519
+ async function getServiceQueues() {
520
+ try {
521
+ const sqs = await getFacilityServiceQueues(locationUuid);
522
+ if (sqs && sqs.length > 0) {
523
+ const triageServiceQueues = getTriageServiceQueues(sqs);
524
+ setServiceQueues(triageServiceQueues);
525
+ }
526
+ } catch (e) {
527
+ showSnackbar({
528
+ kind: 'error',
529
+ title: 'An error occurred while fetching service queues',
530
+ subtitle: e.message ?? 'An error occurred while fetching service queues, please try agin',
531
+ });
532
+ }
533
+ }
534
+ function getTriageServiceQueues(serviceQueues: ServiceQueue[]){
535
+ return serviceQueues.filter((sq)=>{
536
+ return registrationServicequeues.includes(sq.uuid ?? '')
537
+ });
538
+ }
539
+
540
+ async function getPaymentMethods() {
541
+ const methods = await fetchPaymentModes();
542
+ setPaymentModes(methods);
543
+ }
544
+
545
+ async function getBillableServices() {
546
+ const billableServices = await fetchBillableServices();
547
+ setBillableServices(billableServices);
548
+ generateServiceTypesList(billableServices);
549
+ }
550
+
551
+ async function getCashPoints() {
552
+ const cp = await fetchCashPoints();
553
+ setCashPoints(cp);
554
+ }
555
+
556
+ function getfacilityCashpoints() {
557
+ return cashPoints.filter((cp) => {
558
+ return cp && cp.location?.uuid === locationUuid;
559
+ });
560
+ }
561
+
562
+ function generateServiceTypesList(billableServices: BillableService[]) {
563
+ const sp: ServicePrice[] = [];
564
+ for (let bs of billableServices) {
565
+ if (bs.servicePrices) {
566
+ const servicePrices = bs.servicePrices;
567
+ for (let servicePrice of servicePrices) {
568
+ sp.push(servicePrice);
569
+ }
570
+ }
571
+ }
572
+ setServicePrices(sp);
573
+ }
574
+
575
+ function generateCreateBillDto(): CreateBillDto {
576
+ const payload: CreateBillDto = {
577
+ lineItems: [
578
+ {
579
+ billableService: selectedBillableService.billableService.uuid,
580
+ quantity: 1,
581
+ price: selectedBillableService.price,
582
+ priceName: selectedBillableService.name,
583
+ priceUuid: selectedBillableService.uuid,
584
+ lineItemOrder: 0,
585
+ paymentStatus: 'PENDING',
586
+ },
587
+ ],
588
+ cashPoint: selectedCashPoint.uuid,
589
+ patient: selectedPatient.uuid,
590
+ status: 'PENDING',
591
+ payments: [],
592
+ };
593
+ return payload;
594
+ }
595
+ function isValidCreateBillDto(createBillDto: CreateBillDto): boolean {
596
+ if (!createBillDto.patient) {
597
+ showAlert('error', 'Please select a patient', '');
598
+ return false;
599
+ }
600
+ if (!createBillDto.status) {
601
+ showAlert('error', 'Bill does not have a status', '');
602
+ return false;
603
+ }
604
+ if (!createBillDto.cashPoint) {
605
+ showAlert('error', 'Please select a valid cashpoint', '');
606
+ return false;
607
+ }
608
+ if (!createBillDto.lineItems || createBillDto.lineItems.length === 0) {
609
+ showAlert('error', 'Please select a valid billable service', '');
610
+ return false;
611
+ }
612
+ return true;
613
+ }
614
+
615
+ function hasSelectedPaymentMode(paymentMode: string): boolean {
616
+ if (!selectedPaymentMode) {
617
+ return false;
618
+ }
619
+ return selectedPaymentMode.name.trim().toLowerCase().includes(paymentMode.trim().toLowerCase());
620
+ }
621
+
622
+ function generateOrderEncounterPayload(patientUuid: string, visitUuid: string): CreateOrderEncounterDto {
623
+ return {
624
+ patient: patientUuid,
625
+ location: locationUuid,
626
+ encounterType: orderEncounterTypeUuid,
627
+ visit: visitUuid,
628
+ obs: [],
629
+ orders: [
630
+ {
631
+ action: 'NEW',
632
+ type: 'order',
633
+ patient: patientUuid,
634
+ careSetting: outPatientCareSettingUuid,
635
+ orderer: session.currentProvider.uuid ?? 'pd25871c-1359-11df-a1f1-0026b9348838',
636
+ encounter: null,
637
+ concept: getOrderConcept(selectedPaymentMode),
638
+ accessionNumber: null,
639
+ urgency: 'ROUTINE',
640
+ scheduledDate: null,
641
+ },
642
+ ],
643
+ };
644
+ }
645
+ function getOrderConcept(paymentMode: PaymentMode) {
646
+ const paymentModeName = paymentMode.name.toLowerCase().trim();
647
+ if (paymentModeName.includes('cash')) {
648
+ return cashConsulationConceptUuid;
649
+ } else if (paymentModeName.includes('sha')) {
650
+ return shaConsulationConceptUuid;
651
+ } else {
652
+ return '';
653
+ }
654
+ }
655
+ async function createOrder(patientUuid: string, visitUuid: string) {
656
+ const createOrderPayload = generateOrderEncounterPayload(patientUuid, visitUuid);
657
+ try {
658
+ const resp = await createOrderEncounter(createOrderPayload);
659
+ if (resp) {
660
+ showAlert('success', 'Consultation order created', 'Consultation order has been succesfully created');
661
+ }
662
+ } catch (error) {
663
+ showAlert(
664
+ 'error',
665
+ 'Error creating consulation order',
666
+ 'An error occurred while generating the consultation order. Please contact support',
667
+ );
668
+ }
669
+ }
670
+
171
671
  return (
172
672
  <>
173
673
  <Modal
@@ -175,8 +675,8 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
175
675
  size="md"
176
676
  onSecondarySubmit={() => onModalClose({ success: false })}
177
677
  onRequestClose={() => onModalClose({ success: false })}
178
- onRequestSubmit={registerOnAfyaYangu}
179
- primaryButtonText="Register on Afya Yangu"
678
+ onRequestSubmit={sendToTriage}
679
+ primaryButtonText={loading ? 'Sending...please wait' : 'Send to Triage'}
180
680
  secondaryButtonText="Cancel"
181
681
  >
182
682
  <ModalBody>
@@ -212,21 +712,144 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
212
712
  </div>
213
713
  <div className={styles.formSection}>
214
714
  <div className={styles.formRow}>
715
+ <div className={styles.formControl}>
716
+ <ComboBox
717
+ onChange={patientTypeHandler}
718
+ id="patient-type-combobox"
719
+ items={patientTypeOptions}
720
+ itemToString={(item) => (item ? item.text : '')}
721
+ titleText="Patient Type"
722
+ />
723
+ </div>
215
724
  <div className={styles.formControl}>
216
- <Select id="visit-type" labelText="Select a Visit Type" onChange={visitTypeChangeHandler}>
725
+ <Select
726
+ id="payment-details"
727
+ labelText="Payment Details"
728
+ onChange={($event) => paymentDetailsHandler($event.target.value)}
729
+ >
217
730
  <SelectItem value="" text="Select" />;
218
- {visitTypes &&
219
- visitTypes.map((vt) => {
220
- return <SelectItem value={vt.uuid} text={vt.display} />;
221
- })}
731
+ {paymentDetails.map((pd) => {
732
+ return <SelectItem value={pd.id} text={pd.label} />;
733
+ })}
222
734
  </Select>
223
735
  </div>
736
+ </div>
737
+ </div>
738
+ <div className={styles.formSection}>
739
+ {selectedPaymentDetail === PaymentDetail.Paying ? (
740
+ <>
741
+ <div className={styles.formRow}>
742
+ <div className={styles.formControl}>
743
+ <Select
744
+ id="payment-method"
745
+ labelText="Payment Method"
746
+ onChange={($event) => paymentMethodHandler($event.target.value)}
747
+ >
748
+ <SelectItem value="" text="Select" />;
749
+ {paymentModes &&
750
+ paymentModes.map((pm) => {
751
+ return <SelectItem value={pm.uuid} text={pm.name} />;
752
+ })}
753
+ </Select>
754
+ </div>
755
+ <div className={styles.formControl}>
756
+ <Select
757
+ id="billable-service"
758
+ labelText="Billable Services"
759
+ onChange={($event) => billableServicesHandler($event.target.value)}
760
+ >
761
+ <SelectItem value="" text="Select" />;
762
+ {filteredBillableServices &&
763
+ filteredBillableServices.map((sp) => {
764
+ return (
765
+ <SelectItem
766
+ value={sp.uuid}
767
+ text={`${sp.billableService.display}(${sp.name}:${sp.price})`}
768
+ />
769
+ );
770
+ })}
771
+ </Select>
772
+ </div>
773
+ </div>
774
+ {hasSelectedPaymentMode('insurance') ? (
775
+ <>
776
+ <div className={styles.formRow}>
777
+ <div className={styles.formControl}>
778
+ <TextInput
779
+ id="insurance-scheme"
780
+ labelText="Insurance scheme"
781
+ onChange={(e) => insuranceSchemeHandler(e.target.value)}
782
+ />
783
+ </div>
784
+ <div className={styles.formControl}>
785
+ <TextInput
786
+ id="policy-number"
787
+ labelText="Policy number"
788
+ onChange={(e) => insurancePolicyHandler(e.target.value)}
789
+ />
790
+ </div>
791
+ </div>
792
+ </>
793
+ ) : (
794
+ <></>
795
+ )}
796
+ <div className={styles.formRow}>
797
+ <div className={styles.formControl}>
798
+ <Select
799
+ id="cash-point"
800
+ labelText="Cash Point"
801
+ onChange={($event) => cashPointsHandler($event.target.value)}
802
+ >
803
+ <SelectItem value="" text="Select" />;
804
+ {facilityCashPoints &&
805
+ facilityCashPoints.map((cp) => {
806
+ return <SelectItem value={cp.uuid} text={cp.name} />;
807
+ })}
808
+ </Select>
809
+ </div>
810
+ </div>
811
+ </>
812
+ ) : (
813
+ <></>
814
+ )}
815
+
816
+ {selectedPaymentDetail === PaymentDetail.NonPaying ? (
817
+ <>
818
+ <div className={styles.formRow}>
819
+ <div className={styles.formControl}>
820
+ <Select
821
+ id="patient-category"
822
+ labelText="Patient Category"
823
+ onChange={($event) => patientCategoryHandler($event.target.value)}
824
+ >
825
+ <SelectItem value="" text="Select" />;
826
+ <SelectItem value={PatientCategories.CCC_PATIENT_UUID} text="CCC" />;
827
+ <SelectItem value={PatientCategories.MCH_PATIENT_UUID} text="MCH" />;
828
+ </Select>
829
+ </div>
830
+ </div>
831
+ </>
832
+ ) : (
833
+ <></>
834
+ )}
835
+ </div>
836
+ <div className={styles.formSection}>
837
+ <div className={styles.formRow}>
838
+ <div className={styles.formControl}>
839
+ <ComboBox
840
+ onChange={visitTypeChangeHandler}
841
+ id="visit-type-combobox"
842
+ items={visitTypeOptions}
843
+ itemToString={(item) => (item ? item.text : '')}
844
+ titleText="Visit Type"
845
+ />
846
+ </div>
224
847
  <div className={styles.formControl}>
225
- <Select id="service" labelText="Select a Service" onChange={serviceChangeHandler}>
848
+ <Select id="service" labelText="Select a Queue Service" onChange={serviceChangeHandler}>
226
849
  <SelectItem value="" text="Select" />;
227
850
  {serviceQueues &&
228
851
  serviceQueues.map((sq) => {
229
- return <SelectItem value={sq.uuid} text={sq.display} />;
852
+ return <SelectItem value={sq.uuid} text={`${sq.display}`} />;
230
853
  })}
231
854
  </Select>
232
855
  </div>
@@ -239,7 +862,8 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
239
862
  onChange={($event) => priorityChangeHandler($event.target.value)}
240
863
  >
241
864
  <SelectItem value="" text="Select" />;
242
- <SelectItem value={QUEUE_PRIORITIES_UUIDS.NORMAL_PRIORITY_UUID} text="NORMAL" />;
865
+ <SelectItem value={QUEUE_PRIORITIES_UUIDS.NORMAL_PRIORITY_UUID} text="PRIORITY" />;
866
+ <SelectItem value={QUEUE_PRIORITIES_UUIDS.NOT_URGENT_PRIORITY_UUID} text="NON URGENT" />;
243
867
  <SelectItem value={QUEUE_PRIORITIES_UUIDS.EMERGENCY_PRIORITY_UUID} text="EMERGENCY" />;
244
868
  </Select>
245
869
  </div>
@@ -250,13 +874,7 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
250
874
  <></>
251
875
  )}
252
876
  <div className={styles.actionSection}>
253
- {patients.length > 0 ? (
254
- <div className={styles.btnContainer}>
255
- <Button kind="primary" onClick={sendToTriage}>
256
- {loading ? <InlineLoading description="Sending To Triage..." /> : 'Send To Triage'}
257
- </Button>
258
- </div>
259
- ) : (
877
+ {patients.length === 0 ? (
260
878
  <>
261
879
  <div className={styles.patientAction}>
262
880
  <div className={styles.btnContainer}>
@@ -271,6 +889,8 @@ const SendToTriageModal: React.FC<SendToTriageModalProps> = ({
271
889
  </div>
272
890
  </div>
273
891
  </>
892
+ ) : (
893
+ <></>
274
894
  )}
275
895
  </div>
276
896
  </div>