@openmrs/esm-billing-app 1.1.2-pre.9 → 1.2.0

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 (390) hide show
  1. package/.turbo/cache/31f1dfc7f71601df-meta.json +1 -0
  2. package/.turbo/cache/31f1dfc7f71601df.tar.zst +0 -0
  3. package/.turbo/turbo-build.log +13 -42
  4. package/__mocks__/bills.mock.ts +3 -2
  5. package/dist/1480.js +1 -0
  6. package/dist/1480.js.map +1 -0
  7. package/dist/1564.js +1 -0
  8. package/dist/1564.js.map +1 -0
  9. package/dist/1578.js +1 -0
  10. package/dist/1578.js.map +1 -0
  11. package/dist/1646.js +1 -0
  12. package/dist/1646.js.map +1 -0
  13. package/dist/1869.js +1 -0
  14. package/dist/1869.js.map +1 -0
  15. package/dist/1877.js +1 -0
  16. package/dist/1877.js.map +1 -0
  17. package/dist/1899.js +1 -0
  18. package/dist/1899.js.map +1 -0
  19. package/dist/196.js +2 -0
  20. package/dist/196.js.map +1 -0
  21. package/dist/2250.js +43 -0
  22. package/dist/2250.js.map +1 -0
  23. package/dist/2269.js +1 -0
  24. package/dist/2269.js.map +1 -0
  25. package/dist/2317.js +1 -0
  26. package/dist/2317.js.map +1 -0
  27. package/dist/2416.js +1 -0
  28. package/dist/2416.js.map +1 -0
  29. package/dist/2489.js +1 -0
  30. package/dist/2489.js.map +1 -0
  31. package/dist/282.js +1 -0
  32. package/dist/282.js.map +1 -0
  33. package/dist/2881.js +1 -0
  34. package/dist/2881.js.map +1 -0
  35. package/dist/2997.js +1 -0
  36. package/dist/2997.js.map +1 -0
  37. package/dist/3378.js +1 -0
  38. package/dist/3378.js.map +1 -0
  39. package/dist/3379.js +1 -0
  40. package/dist/3379.js.map +1 -0
  41. package/dist/3784.js +1 -0
  42. package/dist/3784.js.map +1 -0
  43. package/dist/3963.js +1 -0
  44. package/dist/3963.js.map +1 -0
  45. package/dist/4106.js +1 -0
  46. package/dist/4106.js.map +1 -0
  47. package/dist/4111.js +1 -0
  48. package/dist/4111.js.map +1 -0
  49. package/dist/434.js +1 -0
  50. package/dist/434.js.map +1 -0
  51. package/dist/4348.js +1 -0
  52. package/dist/4348.js.map +1 -0
  53. package/dist/4383.js +1 -0
  54. package/dist/4383.js.map +1 -0
  55. package/dist/4658.js +1 -0
  56. package/dist/4658.js.map +1 -0
  57. package/dist/4870.js +1 -0
  58. package/dist/4870.js.map +1 -0
  59. package/dist/4928.js +1 -0
  60. package/dist/4928.js.map +1 -0
  61. package/dist/5098.js +1 -0
  62. package/dist/5098.js.map +1 -0
  63. package/dist/5117.js +1 -0
  64. package/dist/5117.js.map +1 -0
  65. package/dist/5132.js +1 -0
  66. package/dist/5132.js.map +1 -0
  67. package/dist/5145.js +1 -0
  68. package/dist/5145.js.map +1 -0
  69. package/dist/5390.js +1 -0
  70. package/dist/5390.js.map +1 -0
  71. package/dist/5503.js +1 -0
  72. package/dist/5503.js.map +1 -0
  73. package/dist/556.js +1 -0
  74. package/dist/556.js.map +1 -0
  75. package/dist/5644.js +1 -0
  76. package/dist/5644.js.map +1 -0
  77. package/dist/5898.js +1 -0
  78. package/dist/5898.js.map +1 -0
  79. package/dist/5940.js +1 -0
  80. package/dist/5940.js.map +1 -0
  81. package/dist/6047.js +1 -0
  82. package/dist/6047.js.map +1 -0
  83. package/dist/6237.js +1 -0
  84. package/dist/6237.js.map +1 -0
  85. package/dist/6362.js +1 -0
  86. package/dist/6362.js.map +1 -0
  87. package/dist/6371.js +1 -0
  88. package/dist/6371.js.map +1 -0
  89. package/dist/6377.js +1 -0
  90. package/dist/6377.js.map +1 -0
  91. package/dist/6444.js +1 -0
  92. package/dist/6444.js.map +1 -0
  93. package/dist/6508.js +1 -0
  94. package/dist/6508.js.map +1 -0
  95. package/dist/6594.js +1 -0
  96. package/dist/6594.js.map +1 -0
  97. package/dist/6724.js +1 -0
  98. package/dist/6724.js.map +1 -0
  99. package/dist/6904.js +1 -0
  100. package/dist/6904.js.map +1 -0
  101. package/dist/7045.js +1 -0
  102. package/dist/7045.js.map +1 -0
  103. package/dist/7175.js +1 -0
  104. package/dist/7175.js.map +1 -0
  105. package/dist/7182.js +1 -0
  106. package/dist/7182.js.map +1 -0
  107. package/dist/7247.js +1 -0
  108. package/dist/7247.js.map +1 -0
  109. package/dist/7742.js +1 -0
  110. package/dist/7742.js.map +1 -0
  111. package/dist/7912.js +1 -0
  112. package/dist/7912.js.map +1 -0
  113. package/dist/8358.js +1 -0
  114. package/dist/8358.js.map +1 -0
  115. package/dist/8359.js +1 -0
  116. package/dist/8359.js.map +1 -0
  117. package/dist/8695.js +1 -0
  118. package/dist/8695.js.map +1 -0
  119. package/dist/903.js +1 -0
  120. package/dist/903.js.map +1 -0
  121. package/dist/9072.js +1 -0
  122. package/dist/9072.js.map +1 -0
  123. package/dist/9414.js +1 -0
  124. package/dist/9414.js.map +1 -0
  125. package/dist/9655.js +11 -0
  126. package/dist/9655.js.map +1 -0
  127. package/dist/9806.js +1 -0
  128. package/dist/9806.js.map +1 -0
  129. package/dist/990.js +1 -0
  130. package/dist/990.js.map +1 -0
  131. package/dist/main.js +17 -2
  132. package/dist/main.js.map +1 -1
  133. package/dist/openmrs-esm-billing-app.js +6 -1
  134. package/dist/openmrs-esm-billing-app.js.buildmanifest.json +643 -436
  135. package/dist/openmrs-esm-billing-app.js.map +1 -1
  136. package/dist/routes.json +1 -1
  137. package/e2e/commands/billing-operations.ts +21 -0
  138. package/e2e/commands/types.ts +9 -1
  139. package/e2e/pages/discounts-page.ts +75 -0
  140. package/e2e/pages/index.ts +1 -0
  141. package/e2e/pages/invoice-page.ts +7 -7
  142. package/e2e/specs/bill-discounts.spec.ts +255 -0
  143. package/e2e/specs/billing-dashboard.spec.ts +3 -3
  144. package/e2e/specs/billing-patient-chart.spec.ts +2 -2
  145. package/package.json +13 -22
  146. package/rspack.config.js +1 -0
  147. package/src/bill-history/bill-action-menu.component.tsx +20 -2
  148. package/src/bill-history/bill-history.test.tsx +23 -22
  149. package/src/bill-item-actions/edit-bill-item.modal.tsx +1 -1
  150. package/src/bill-item-actions/edit-bill-item.test.tsx +29 -27
  151. package/src/billable-services/billable-service-form/billable-service-form.test.tsx +74 -73
  152. package/src/billable-services/billable-services-home.component.tsx +4 -2
  153. package/src/billable-services/billable-services.test.tsx +8 -7
  154. package/src/billable-services/dashboard/dashboard.test.tsx +3 -2
  155. package/src/billable-services-admin-card-link.test.tsx +2 -1
  156. package/src/billing-dashboard/billing-dashboard.test.tsx +19 -3
  157. package/src/billing-form/billing-checkin-form.component.tsx +7 -3
  158. package/src/billing-form/billing-checkin-form.test.tsx +22 -21
  159. package/src/billing-form/billing-form.resource.test.ts +7 -6
  160. package/src/billing-form/billing-form.test.tsx +77 -40
  161. package/src/billing-form/billing-form.workspace.tsx +25 -6
  162. package/src/billing-form/visit-attributes/visit-attributes-form.component.tsx +6 -2
  163. package/src/billing.resource.test.ts +43 -41
  164. package/src/billing.resource.ts +65 -16
  165. package/src/bills-table/bills-table.component.tsx +15 -4
  166. package/src/bills-table/bills-table.test.tsx +72 -71
  167. package/src/config-schema.ts +0 -7
  168. package/src/discounts/admin/discount-requests-left-panel-link.component.tsx +43 -0
  169. package/src/discounts/admin/discount-requests.component.tsx +316 -0
  170. package/src/discounts/admin/discount-requests.scss +133 -0
  171. package/src/discounts/admin/discount-requests.test.tsx +104 -0
  172. package/src/discounts/admin/review-bill-discounts/bill-line-items-table/bill-line-items-table.component.tsx +42 -0
  173. package/src/discounts/admin/review-bill-discounts/bill-line-items-table/bill-line-items-table.scss +76 -0
  174. package/src/discounts/admin/review-bill-discounts/bill-payments-table/bill-payments-table.component.tsx +50 -0
  175. package/src/discounts/admin/review-bill-discounts/bill-payments-table/bill-payments-table.scss +63 -0
  176. package/src/discounts/admin/review-bill-discounts/bill-receipt-rail/bill-receipt-rail.component.tsx +73 -0
  177. package/src/discounts/admin/review-bill-discounts/bill-receipt-rail/bill-receipt-rail.scss +54 -0
  178. package/src/discounts/admin/review-bill-discounts/bill-totals-summary/bill-totals-summary.component.tsx +95 -0
  179. package/src/discounts/admin/review-bill-discounts/bill-totals-summary/bill-totals-summary.scss +128 -0
  180. package/src/discounts/admin/review-bill-discounts/discount-card/discount-card.component.tsx +158 -0
  181. package/src/discounts/admin/review-bill-discounts/discount-card/discount-card.scss +164 -0
  182. package/src/discounts/admin/review-bill-discounts/discount-review-stack/discount-review-stack.component.tsx +86 -0
  183. package/src/discounts/admin/review-bill-discounts/discount-review-stack/discount-review-stack.scss +40 -0
  184. package/src/discounts/admin/review-bill-discounts/review-bill-discounts.modal.scss +14 -0
  185. package/src/discounts/admin/review-bill-discounts/review-bill-discounts.modal.test.tsx +153 -0
  186. package/src/discounts/admin/review-bill-discounts/review-bill-discounts.modal.tsx +167 -0
  187. package/src/discounts/admin/review-bill-discounts/review-bill-discounts.utils.ts +42 -0
  188. package/src/discounts/discounts-table.component.tsx +109 -0
  189. package/src/discounts/discounts-table.scss +37 -0
  190. package/src/discounts/discounts-table.test.tsx +67 -0
  191. package/src/discounts/discounts.resource.ts +71 -0
  192. package/src/discounts/request-discount.modal.scss +88 -0
  193. package/src/discounts/request-discount.modal.test.tsx +161 -0
  194. package/src/discounts/request-discount.modal.tsx +253 -0
  195. package/src/index.ts +52 -21
  196. package/src/invoice/invoice-table.component.tsx +116 -18
  197. package/src/invoice/invoice-table.test.tsx +165 -13
  198. package/src/invoice/invoice.component.tsx +111 -7
  199. package/src/invoice/invoice.test.tsx +366 -66
  200. package/src/invoice/line-item-action-menu.component.tsx +31 -1
  201. package/src/invoice/payments/payment-form/payment-form.test.tsx +20 -19
  202. package/src/invoice/payments/payment-history/payment-history.test.tsx +13 -10
  203. package/src/invoice/payments/payments.component.tsx +20 -6
  204. package/src/invoice/payments/payments.test.tsx +88 -23
  205. package/src/invoice/printable-invoice/print-receipt.test.tsx +10 -28
  206. package/src/invoice/printable-invoice/printable-footer.test.tsx +5 -4
  207. package/src/invoice/printable-invoice/printable-invoice-header.component.tsx +3 -3
  208. package/src/invoice/printable-invoice/printable-invoice-header.test.tsx +26 -11
  209. package/src/invoice/printable-invoice/printable-invoice.component.tsx +38 -15
  210. package/src/left-panel-link.test.tsx +3 -3
  211. package/src/metrics-cards/metrics-cards.test.tsx +11 -10
  212. package/src/modal/delete-bill-confirmation.modal.test.tsx +134 -0
  213. package/src/modal/delete-bill-confirmation.modal.tsx +98 -0
  214. package/src/modal/delete-line-item-confirmation.modal.test.tsx +11 -9
  215. package/src/modal/finalize-bill-confirmation.modal.test.tsx +10 -8
  216. package/src/modal/require-payment-modal.test.tsx +12 -11
  217. package/src/payment-status-tag/payment-status-tag.component.tsx +50 -0
  218. package/src/payment-status-tag/payment-status-tag.scss +6 -0
  219. package/src/payment-status-tag/payment-status-tag.test.tsx +113 -0
  220. package/src/refunds/admin/refund-requests-left-panel-link.component.tsx +43 -0
  221. package/src/refunds/admin/refund-requests.component.tsx +324 -0
  222. package/src/refunds/admin/refund-requests.scss +133 -0
  223. package/src/refunds/admin/refund-requests.test.tsx +99 -0
  224. package/src/refunds/admin/review-bill-refunds/bill-line-items-table/bill-line-items-table.component.tsx +42 -0
  225. package/src/refunds/admin/review-bill-refunds/bill-line-items-table/bill-line-items-table.scss +76 -0
  226. package/src/refunds/admin/review-bill-refunds/bill-payments-table/bill-payments-table.component.tsx +50 -0
  227. package/src/refunds/admin/review-bill-refunds/bill-payments-table/bill-payments-table.scss +63 -0
  228. package/src/refunds/admin/review-bill-refunds/bill-receipt-rail/bill-receipt-rail.component.tsx +84 -0
  229. package/src/refunds/admin/review-bill-refunds/bill-receipt-rail/bill-receipt-rail.scss +54 -0
  230. package/src/refunds/admin/review-bill-refunds/bill-totals-summary/bill-totals-summary.component.tsx +83 -0
  231. package/src/refunds/admin/review-bill-refunds/bill-totals-summary/bill-totals-summary.scss +65 -0
  232. package/src/refunds/admin/review-bill-refunds/refund-card/refund-card.component.tsx +170 -0
  233. package/src/refunds/admin/review-bill-refunds/refund-card/refund-card.scss +155 -0
  234. package/src/refunds/admin/review-bill-refunds/refund-review-stack/refund-review-stack.component.tsx +86 -0
  235. package/src/refunds/admin/review-bill-refunds/refund-review-stack/refund-review-stack.scss +40 -0
  236. package/src/refunds/admin/review-bill-refunds/review-bill-refunds.modal.scss +14 -0
  237. package/src/refunds/admin/review-bill-refunds/review-bill-refunds.modal.test.tsx +313 -0
  238. package/src/refunds/admin/review-bill-refunds/review-bill-refunds.modal.tsx +188 -0
  239. package/src/refunds/admin/review-bill-refunds/review-bill-refunds.utils.ts +66 -0
  240. package/src/refunds/refunds-table.component.tsx +137 -0
  241. package/src/refunds/refunds-table.scss +37 -0
  242. package/src/refunds/refunds-table.test.tsx +105 -0
  243. package/src/refunds/refunds.resource.test.ts +44 -0
  244. package/src/refunds/refunds.resource.ts +42 -0
  245. package/src/refunds/refunds.types.test.ts +15 -0
  246. package/src/refunds/request-refund.modal.scss +84 -0
  247. package/src/refunds/request-refund.modal.test.tsx +204 -0
  248. package/src/refunds/request-refund.modal.tsx +218 -0
  249. package/src/routes.json +36 -2
  250. package/src/types/index.ts +116 -1
  251. package/src/visit-bills/visit-bills-panel.component.tsx +151 -0
  252. package/src/visit-bills/visit-bills-panel.scss +31 -0
  253. package/src/visit-bills/visit-bills-panel.test.tsx +113 -0
  254. package/tools/empty-module.ts +1 -0
  255. package/tools/setup-tests.ts +9 -9
  256. package/translations/am.json +154 -16
  257. package/translations/ar.json +154 -16
  258. package/translations/ar_SY.json +154 -16
  259. package/translations/bn.json +154 -16
  260. package/translations/cs.json +154 -16
  261. package/translations/de.json +154 -16
  262. package/translations/en.json +154 -16
  263. package/translations/en_US.json +154 -16
  264. package/translations/es.json +154 -16
  265. package/translations/es_MX.json +154 -16
  266. package/translations/fr.json +154 -16
  267. package/translations/he.json +154 -16
  268. package/translations/hi.json +154 -16
  269. package/translations/hi_IN.json +154 -16
  270. package/translations/id.json +154 -16
  271. package/translations/it.json +154 -16
  272. package/translations/ka.json +154 -16
  273. package/translations/km.json +154 -16
  274. package/translations/ku.json +154 -16
  275. package/translations/ky.json +154 -16
  276. package/translations/lg.json +154 -16
  277. package/translations/ne.json +154 -16
  278. package/translations/pl.json +154 -16
  279. package/translations/pt.json +154 -16
  280. package/translations/pt_BR.json +154 -16
  281. package/translations/qu.json +154 -16
  282. package/translations/ro_RO.json +154 -16
  283. package/translations/ru_RU.json +154 -16
  284. package/translations/si.json +154 -16
  285. package/translations/sq.json +154 -16
  286. package/translations/sw.json +154 -16
  287. package/translations/sw_KE.json +154 -16
  288. package/translations/tr.json +154 -16
  289. package/translations/tr_TR.json +154 -16
  290. package/translations/uk.json +154 -16
  291. package/translations/uz.json +154 -16
  292. package/translations/uz@Latn.json +154 -16
  293. package/translations/uz_UZ.json +154 -16
  294. package/translations/vi.json +154 -16
  295. package/translations/zh.json +154 -16
  296. package/translations/zh_CN.json +179 -41
  297. package/translations/zh_TW.json +154 -16
  298. package/tsconfig.json +3 -3
  299. package/vitest.config.js +28 -0
  300. package/.turbo/cache/4e30f71f570fc412-meta.json +0 -1
  301. package/.turbo/cache/4e30f71f570fc412.tar.zst +0 -0
  302. package/dist/1119.js +0 -1
  303. package/dist/1197.js +0 -1
  304. package/dist/1435.js +0 -1
  305. package/dist/1435.js.map +0 -1
  306. package/dist/1807.js +0 -1
  307. package/dist/1807.js.map +0 -1
  308. package/dist/2146.js +0 -1
  309. package/dist/2177.js +0 -2
  310. package/dist/2177.js.LICENSE.txt +0 -9
  311. package/dist/2177.js.map +0 -1
  312. package/dist/2690.js +0 -1
  313. package/dist/2704.js +0 -1
  314. package/dist/2704.js.map +0 -1
  315. package/dist/3002.js +0 -1
  316. package/dist/3002.js.map +0 -1
  317. package/dist/3041.js +0 -1
  318. package/dist/3041.js.map +0 -1
  319. package/dist/3099.js +0 -1
  320. package/dist/3184.js +0 -2
  321. package/dist/3184.js.LICENSE.txt +0 -14
  322. package/dist/3184.js.map +0 -1
  323. package/dist/3584.js +0 -1
  324. package/dist/4055.js +0 -1
  325. package/dist/4132.js +0 -1
  326. package/dist/4225.js +0 -1
  327. package/dist/4225.js.map +0 -1
  328. package/dist/4300.js +0 -1
  329. package/dist/4335.js +0 -1
  330. package/dist/439.js +0 -1
  331. package/dist/4618.js +0 -1
  332. package/dist/4652.js +0 -1
  333. package/dist/4944.js +0 -1
  334. package/dist/5173.js +0 -1
  335. package/dist/5241.js +0 -1
  336. package/dist/5422.js +0 -1
  337. package/dist/5422.js.map +0 -1
  338. package/dist/5442.js +0 -1
  339. package/dist/5661.js +0 -1
  340. package/dist/6022.js +0 -1
  341. package/dist/6404.js +0 -1
  342. package/dist/6404.js.map +0 -1
  343. package/dist/6468.js +0 -1
  344. package/dist/6540.js +0 -2
  345. package/dist/6540.js.LICENSE.txt +0 -9
  346. package/dist/6540.js.map +0 -1
  347. package/dist/6589.js +0 -1
  348. package/dist/6606.js +0 -1
  349. package/dist/6606.js.map +0 -1
  350. package/dist/6679.js +0 -1
  351. package/dist/6792.js +0 -1
  352. package/dist/6792.js.map +0 -1
  353. package/dist/6840.js +0 -1
  354. package/dist/6859.js +0 -1
  355. package/dist/7097.js +0 -1
  356. package/dist/7159.js +0 -1
  357. package/dist/723.js +0 -1
  358. package/dist/7255.js +0 -1
  359. package/dist/7255.js.map +0 -1
  360. package/dist/7617.js +0 -1
  361. package/dist/795.js +0 -1
  362. package/dist/8163.js +0 -1
  363. package/dist/8341.js +0 -2
  364. package/dist/8341.js.LICENSE.txt +0 -52
  365. package/dist/8341.js.map +0 -1
  366. package/dist/8349.js +0 -1
  367. package/dist/8371.js +0 -1
  368. package/dist/8421.js +0 -1
  369. package/dist/8421.js.map +0 -1
  370. package/dist/8618.js +0 -1
  371. package/dist/890.js +0 -1
  372. package/dist/9214.js +0 -1
  373. package/dist/9538.js +0 -1
  374. package/dist/9569.js +0 -1
  375. package/dist/961.js +0 -2
  376. package/dist/961.js.LICENSE.txt +0 -19
  377. package/dist/961.js.map +0 -1
  378. package/dist/986.js +0 -1
  379. package/dist/9879.js +0 -1
  380. package/dist/9895.js +0 -1
  381. package/dist/9900.js +0 -1
  382. package/dist/9913.js +0 -1
  383. package/dist/main.js.LICENSE.txt +0 -62
  384. package/src/billable-services/bill-waiver/bill-selection.component.tsx +0 -76
  385. package/src/billable-services/bill-waiver/bill-waiver-form.component.tsx +0 -107
  386. package/src/billable-services/bill-waiver/bill-waiver-form.scss +0 -34
  387. package/src/billable-services/bill-waiver/bill-waiver.component.tsx +0 -34
  388. package/src/billable-services/bill-waiver/bill-waiver.scss +0 -10
  389. package/src/billable-services/bill-waiver/patient-bills.component.tsx +0 -134
  390. package/webpack.config.js +0 -1
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { Tag, Toggletip, ToggletipButton, ToggletipContent } from '@carbon/react';
4
+ import { usePatientPaymentStatus } from '../billing.resource';
5
+ import styles from './payment-status-tag.scss';
6
+
7
+ /**
8
+ * DO NOT DELETE — intentional extraction hints for i18next-parser.
9
+ * The t() calls in this component use a dynamic key (paymentStatus.status),
10
+ * which the parser cannot statically detect. These dummy calls ensure 'PAID'
11
+ * and 'UNPAID' are included in the translation catalogue.
12
+ * t('PAID', 'PAID')
13
+ * t('UNPAID', 'UNPAID')
14
+ */
15
+
16
+ type PaymentStatusTagProps = {
17
+ patientUuid: string;
18
+ renderedFrom: string;
19
+ };
20
+
21
+ const PaymentStatusTag: React.FC<PaymentStatusTagProps> = ({ patientUuid, renderedFrom }) => {
22
+ const isPatientChart = renderedFrom === 'patient-chart';
23
+
24
+ if (!isPatientChart) {
25
+ return null;
26
+ }
27
+
28
+ return <PaymentStatusTagInner patientUuid={patientUuid} />;
29
+ };
30
+
31
+ const PaymentStatusTagInner: React.FC<Omit<PaymentStatusTagProps, 'renderedFrom'>> = ({ patientUuid }) => {
32
+ const { t } = useTranslation();
33
+ const { paymentStatus, isLoading, error } = usePatientPaymentStatus(patientUuid);
34
+ return !isLoading && !error && paymentStatus && paymentStatus.status !== 'UNKNOWN' ? (
35
+ <Toggletip className={styles.tag}>
36
+ <ToggletipButton label={t(paymentStatus.status, paymentStatus.status)}>
37
+ <Tag type={paymentStatus.status === 'PAID' ? 'green' : 'red'}>
38
+ {t(paymentStatus.status, paymentStatus.status)}
39
+ </Tag>
40
+ </ToggletipButton>
41
+ <ToggletipContent>
42
+ <div role="tooltip">
43
+ <p>{paymentStatus.reason}</p>
44
+ </div>
45
+ </ToggletipContent>
46
+ </Toggletip>
47
+ ) : null;
48
+ };
49
+
50
+ export default PaymentStatusTag;
@@ -0,0 +1,6 @@
1
+ @use '@carbon/layout';
2
+
3
+ .tag {
4
+ margin: 0 layout.$spacing-01 0 0;
5
+ }
6
+
@@ -0,0 +1,113 @@
1
+ import React from 'react';
2
+ import { describe, expect, it, vi } from 'vitest';
3
+ import { render, screen } from '@testing-library/react';
4
+ import { usePatientPaymentStatus } from '../billing.resource';
5
+ import PaymentStatusTag from './payment-status-tag.component';
6
+
7
+ const mockUsePatientPaymentStatus = vi.mocked(usePatientPaymentStatus);
8
+
9
+ vi.mock('../billing.resource', () => ({
10
+ usePatientPaymentStatus: vi.fn(),
11
+ }));
12
+
13
+ const patientUuid = 'test-patient-uuid';
14
+
15
+ describe('PaymentStatusTag', () => {
16
+ it('renders nothing while loading', () => {
17
+ mockUsePatientPaymentStatus.mockReturnValue({
18
+ paymentStatus: undefined,
19
+ isLoading: true,
20
+ error: undefined,
21
+ isValidating: false,
22
+ mutate: vi.fn(),
23
+ });
24
+ const { container } = render(<PaymentStatusTag patientUuid={patientUuid} renderedFrom="patient-chart" />);
25
+ expect(container).toBeEmptyDOMElement();
26
+ });
27
+
28
+ it('renders nothing when there is an error', () => {
29
+ mockUsePatientPaymentStatus.mockReturnValue({
30
+ paymentStatus: undefined,
31
+ isLoading: false,
32
+ error: new Error('fetch failed'),
33
+ isValidating: false,
34
+ mutate: vi.fn(),
35
+ });
36
+ const { container } = render(<PaymentStatusTag patientUuid={patientUuid} renderedFrom="patient-chart" />);
37
+ expect(container).toBeEmptyDOMElement();
38
+ });
39
+
40
+ it('renders nothing when paymentStatus is undefined', () => {
41
+ mockUsePatientPaymentStatus.mockReturnValue({
42
+ paymentStatus: undefined,
43
+ isLoading: false,
44
+ error: undefined,
45
+ isValidating: false,
46
+ mutate: vi.fn(),
47
+ });
48
+ const { container } = render(<PaymentStatusTag patientUuid={patientUuid} renderedFrom="patient-chart" />);
49
+ expect(container).toBeEmptyDOMElement();
50
+ });
51
+
52
+ it('renders nothing for UNKNOWN status', () => {
53
+ mockUsePatientPaymentStatus.mockReturnValue({
54
+ paymentStatus: { status: 'UNKNOWN', reason: 'Status could not be determined' },
55
+ isLoading: false,
56
+ error: undefined,
57
+ isValidating: false,
58
+ mutate: vi.fn(),
59
+ });
60
+ const { container } = render(<PaymentStatusTag patientUuid={patientUuid} renderedFrom="patient-chart" />);
61
+ expect(container).toBeEmptyDOMElement();
62
+ });
63
+
64
+ it('renders nothing when not in patient-chart status', () => {
65
+ mockUsePatientPaymentStatus.mockReturnValue({
66
+ paymentStatus: { status: 'PAID', reason: 'Status could not be determined' },
67
+ isLoading: false,
68
+ error: undefined,
69
+ isValidating: false,
70
+ mutate: vi.fn(),
71
+ });
72
+ const { container } = render(<PaymentStatusTag patientUuid={patientUuid} renderedFrom="patient-search" />);
73
+ expect(container).toBeEmptyDOMElement();
74
+ });
75
+
76
+ it('renders a PAID tag with the reason in the tooltip content', () => {
77
+ mockUsePatientPaymentStatus.mockReturnValue({
78
+ paymentStatus: { status: 'PAID', reason: 'Bill fully settled' },
79
+ isLoading: false,
80
+ error: undefined,
81
+ isValidating: false,
82
+ mutate: vi.fn(),
83
+ });
84
+ render(<PaymentStatusTag patientUuid={patientUuid} renderedFrom="patient-chart" />);
85
+ expect(screen.getByText('PAID')).toBeInTheDocument();
86
+ expect(screen.getByText('Bill fully settled')).toBeInTheDocument();
87
+ });
88
+
89
+ it('renders an UNPAID tag with the reason in the tooltip content', () => {
90
+ mockUsePatientPaymentStatus.mockReturnValue({
91
+ paymentStatus: { status: 'UNPAID', reason: 'Outstanding balance of 500' },
92
+ isLoading: false,
93
+ error: undefined,
94
+ isValidating: false,
95
+ mutate: vi.fn(),
96
+ });
97
+ render(<PaymentStatusTag patientUuid={patientUuid} renderedFrom="patient-chart" />);
98
+ expect(screen.getByText('UNPAID')).toBeInTheDocument();
99
+ expect(screen.getByText('Outstanding balance of 500')).toBeInTheDocument();
100
+ });
101
+
102
+ it('does not blink on revalidation — renders stale value while isValidating is true', () => {
103
+ mockUsePatientPaymentStatus.mockReturnValue({
104
+ paymentStatus: { status: 'PAID', reason: 'Fully paid' },
105
+ isLoading: false,
106
+ error: undefined,
107
+ isValidating: true,
108
+ mutate: vi.fn(),
109
+ });
110
+ render(<PaymentStatusTag patientUuid={patientUuid} renderedFrom="patient-chart" />);
111
+ expect(screen.getByText('PAID')).toBeInTheDocument();
112
+ });
113
+ });
@@ -0,0 +1,43 @@
1
+ import React, { useMemo } from 'react';
2
+ import { BrowserRouter, useLocation } from 'react-router-dom';
3
+ import { useTranslation } from 'react-i18next';
4
+ import { SideNavLink } from '@carbon/react';
5
+ import { navigate } from '@openmrs/esm-framework';
6
+
7
+ export interface LinkConfig {
8
+ name: string;
9
+ title: string;
10
+ path: string;
11
+ icon?: React.ComponentType;
12
+ }
13
+
14
+ function RefundRequestsLinkExtension({ config }: Readonly<{ config: LinkConfig }>) {
15
+ const { title, path, icon: Icon } = config;
16
+ const { t } = useTranslation();
17
+ const location = useLocation();
18
+ const spaBasePath = `${globalThis.spaBase}/billable-services`;
19
+
20
+ const isActive = useMemo(() => {
21
+ const currentPath = location.pathname.replace(spaBasePath, '');
22
+ if (path === '' || path === '/') {
23
+ return currentPath === '' || currentPath === '/';
24
+ }
25
+ return currentPath.startsWith(`/${path}`);
26
+ }, [location.pathname, path, spaBasePath]);
27
+
28
+ const handleNavigation = () => {
29
+ navigate({ to: `${spaBasePath}/${path}` });
30
+ };
31
+
32
+ return (
33
+ <SideNavLink onClick={handleNavigation} renderIcon={Icon} isActive={isActive}>
34
+ {t(title)}
35
+ </SideNavLink>
36
+ );
37
+ }
38
+
39
+ export const createRefundRequestsLeftPanelLink = (config: LinkConfig) => () => (
40
+ <BrowserRouter>
41
+ <RefundRequestsLinkExtension config={config} />
42
+ </BrowserRouter>
43
+ );
@@ -0,0 +1,324 @@
1
+ import React, { useCallback, useMemo, useState } from 'react';
2
+ import classNames from 'classnames';
3
+ import {
4
+ DataTable,
5
+ DataTableSkeleton,
6
+ Dropdown,
7
+ InlineLoading,
8
+ Layer,
9
+ Link,
10
+ Pagination,
11
+ Search,
12
+ Table,
13
+ TableBody,
14
+ TableCell,
15
+ TableContainer,
16
+ TableHead,
17
+ TableHeader,
18
+ TableRow,
19
+ Tile,
20
+ } from '@carbon/react';
21
+ import { useTranslation } from 'react-i18next';
22
+ import {
23
+ EmptyCardIllustration,
24
+ ErrorState,
25
+ formatDate,
26
+ isDesktop,
27
+ parseDate,
28
+ showModal,
29
+ useConfig,
30
+ useLayoutType,
31
+ usePagination,
32
+ usePaginationInfo,
33
+ type LayoutType,
34
+ } from '@openmrs/esm-framework';
35
+ import { convertToCurrency } from '../../helpers';
36
+ import { useRefundRequests } from '../refunds.resource';
37
+ import type { BillingConfig } from '../../config-schema';
38
+ import { RefundStatus, type PatientInvoice } from '../../types';
39
+ import styles from './refund-requests.scss';
40
+
41
+ type FilterValue = 'REQUESTED' | 'APPROVED' | 'REJECTED' | 'COMPLETED' | 'ALL';
42
+
43
+ interface RefundStatusFilterItem {
44
+ id: FilterValue;
45
+ text: string;
46
+ }
47
+
48
+ const filterToStatuses = (value: FilterValue): RefundStatus[] => {
49
+ if (value === 'ALL') {
50
+ return [RefundStatus.REQUESTED, RefundStatus.APPROVED, RefundStatus.REJECTED, RefundStatus.COMPLETED];
51
+ }
52
+ return [value];
53
+ };
54
+
55
+ const RefundRequests: React.FC = () => {
56
+ const { t } = useTranslation();
57
+ const { defaultCurrency, pageSize: configuredPageSize } = useConfig<BillingConfig>();
58
+ const layout = useLayoutType();
59
+ const responsiveSize = isDesktop(layout) ? 'sm' : 'lg';
60
+
61
+ const filterItems: RefundStatusFilterItem[] = useMemo(
62
+ () => [
63
+ { id: 'REQUESTED', text: t('requested', 'Requested') },
64
+ { id: 'APPROVED', text: t('approved', 'Approved') },
65
+ { id: 'REJECTED', text: t('rejected', 'Rejected') },
66
+ { id: 'COMPLETED', text: t('completed', 'Completed') },
67
+ { id: 'ALL', text: t('all', 'All') },
68
+ ],
69
+ [t],
70
+ );
71
+ const [filter, setFilter] = useState<RefundStatusFilterItem>(filterItems[0]);
72
+ const [currentPageSize, setCurrentPageSize] = useState(configuredPageSize ?? 10);
73
+ const [searchString, setSearchString] = useState('');
74
+
75
+ const { bills, isLoading, error, mutate, isValidating } = useRefundRequests({
76
+ statuses: filterToStatuses(filter.id),
77
+ });
78
+
79
+ const filteredBills = useMemo(() => {
80
+ const q = searchString.trim().toLowerCase();
81
+ if (!q) return bills;
82
+ return bills.filter(
83
+ (b) => b.patient?.display?.toLowerCase().includes(q) || b.receiptNumber?.toLowerCase().includes(q),
84
+ );
85
+ }, [bills, searchString]);
86
+
87
+ const { paginated, goTo, results: paginatedBills, currentPage } = usePagination(filteredBills, currentPageSize);
88
+ const { pageSizes } = usePaginationInfo(currentPageSize, filteredBills.length, currentPage, paginatedBills.length);
89
+
90
+ const headers = useMemo(
91
+ () => [
92
+ { key: 'dateCreated', header: t('date', 'Date') },
93
+ { key: 'receiptNumber', header: t('invoiceNo', 'Invoice #') },
94
+ { key: 'patient', header: t('patient', 'Patient') },
95
+ { key: 'billAmount', header: t('billAmount', 'Bill amount') },
96
+ { key: 'cashier', header: t('cashier', 'Cashier') },
97
+ ],
98
+ [t],
99
+ );
100
+
101
+ const handleRowClick = useCallback(
102
+ (bill: PatientInvoice) => {
103
+ const dispose = showModal('review-bill-refunds-modal', {
104
+ bill,
105
+ onMutate: mutate,
106
+ closeModal: () => dispose(),
107
+ });
108
+ },
109
+ [mutate],
110
+ );
111
+
112
+ const rows = useMemo(
113
+ () =>
114
+ paginatedBills.map((bill: PatientInvoice) => ({
115
+ id: bill.uuid,
116
+ dateCreated: bill.dateCreated ? formatDate(parseDate(bill.dateCreated), { mode: 'wide' }) : '--',
117
+ patient: bill.patient?.display ?? '--',
118
+ receiptNumber: bill.receiptNumber ? (
119
+ <Link
120
+ href="#"
121
+ onClick={(e) => {
122
+ e.preventDefault();
123
+ e.stopPropagation();
124
+ handleRowClick(bill);
125
+ }}>
126
+ {bill.receiptNumber}
127
+ </Link>
128
+ ) : (
129
+ '--'
130
+ ),
131
+ billAmount: convertToCurrency(bill.total ?? 0, defaultCurrency),
132
+ cashier: bill.cashier?.display ?? '--',
133
+ _raw: bill,
134
+ })),
135
+ [paginatedBills, defaultCurrency, handleRowClick],
136
+ );
137
+
138
+ const handleSearch = useCallback(
139
+ (e) => {
140
+ setSearchString(e.target.value);
141
+ goTo(1);
142
+ },
143
+ [goTo],
144
+ );
145
+
146
+ const handleTableRowClick = useCallback(
147
+ (rowId: string) => {
148
+ const match = rows.find((r) => r.id === rowId);
149
+ if (match) handleRowClick(match._raw);
150
+ },
151
+ [rows, handleRowClick],
152
+ );
153
+
154
+ let tableContent: React.ReactNode;
155
+ if (isLoading && !bills?.length) {
156
+ tableContent = (
157
+ <div className={styles.loaderContainer} aria-busy="true" aria-label={t('loading', 'Loading')}>
158
+ <DataTableSkeleton
159
+ rowCount={currentPageSize}
160
+ showHeader={false}
161
+ showToolbar={false}
162
+ zebra
163
+ columnCount={headers.length}
164
+ />
165
+ </div>
166
+ );
167
+ } else if (error) {
168
+ tableContent = (
169
+ <div className={styles.errorContainer}>
170
+ <Layer>
171
+ <ErrorState error={error} headerTitle={t('refundRequests', 'Refund requests')} />
172
+ </Layer>
173
+ </div>
174
+ );
175
+ } else if (rows.length > 0) {
176
+ tableContent = (
177
+ <>
178
+ <DataTable isSortable rows={rows} headers={headers} size={responsiveSize} useZebraStyles={rows.length > 1}>
179
+ {({ rows: dataRows, headers: dataHeaders, getRowProps, getTableProps }) => (
180
+ <TableContainer>
181
+ <Table {...getTableProps()} aria-label={t('refundRequests', 'Refund requests')}>
182
+ <TableHead>
183
+ <TableRow>
184
+ {dataHeaders.map((header) => (
185
+ <TableHeader key={header.key}>{header.header}</TableHeader>
186
+ ))}
187
+ </TableRow>
188
+ </TableHead>
189
+ <TableBody>
190
+ {dataRows.map((row) => (
191
+ <TableRow
192
+ key={row.id}
193
+ {...getRowProps({ row })}
194
+ className={styles.row}
195
+ onClick={() => handleTableRowClick(row.id)}>
196
+ {row.cells.map((cell) => (
197
+ <TableCell key={cell.id}>{cell.value}</TableCell>
198
+ ))}
199
+ </TableRow>
200
+ ))}
201
+ </TableBody>
202
+ </Table>
203
+ </TableContainer>
204
+ )}
205
+ </DataTable>
206
+ {paginated && (
207
+ <Pagination
208
+ forwardText={t('nextPage', 'Next page')}
209
+ backwardText={t('previousPage', 'Previous page')}
210
+ page={currentPage}
211
+ pageSize={currentPageSize}
212
+ pageSizes={pageSizes}
213
+ totalItems={filteredBills.length}
214
+ size={responsiveSize}
215
+ onChange={({ pageSize: newPageSize, page: newPage }) => {
216
+ if (newPageSize !== currentPageSize) {
217
+ setCurrentPageSize(newPageSize);
218
+ }
219
+ if (newPage !== currentPage) {
220
+ goTo(newPage);
221
+ }
222
+ }}
223
+ />
224
+ )}
225
+ </>
226
+ );
227
+ } else {
228
+ tableContent = (
229
+ <Layer className={styles.emptyStateContainer}>
230
+ <Tile className={styles.tile}>
231
+ <div className={styles.illo}>
232
+ <EmptyCardIllustration />
233
+ </div>
234
+ <p className={styles.content}>{t('noRefundRequestsToDisplay', 'There are no refund requests to display.')}</p>
235
+ </Tile>
236
+ </Layer>
237
+ );
238
+ }
239
+
240
+ return (
241
+ <main className={styles.container}>
242
+ <div className={styles.servicesTableContainer}>
243
+ <div className={styles.filterContainer}>
244
+ <Dropdown
245
+ className={styles.filterDropdown}
246
+ direction="bottom"
247
+ id="refund-status-filter"
248
+ selectedItem={filter}
249
+ items={filterItems}
250
+ itemToString={(item: RefundStatusFilterItem) => (item ? item.text : '')}
251
+ label=""
252
+ onChange={({ selectedItem }: { selectedItem: RefundStatusFilterItem }) => {
253
+ setFilter(selectedItem);
254
+ goTo(1);
255
+ }}
256
+ size={responsiveSize}
257
+ titleText={t('filterBy', 'Filter by:')}
258
+ type="inline"
259
+ />
260
+ </div>
261
+
262
+ <div className={styles.billListContainer}>
263
+ <FilterableTableHeader
264
+ handleSearch={handleSearch}
265
+ isValidating={isValidating}
266
+ layout={layout}
267
+ responsiveSize={responsiveSize}
268
+ searchString={searchString}
269
+ t={t}
270
+ />
271
+ {tableContent}
272
+ </div>
273
+ </div>
274
+ </main>
275
+ );
276
+ };
277
+
278
+ interface FilterableTableHeaderProps {
279
+ readonly layout: LayoutType;
280
+ readonly handleSearch: (e: React.ChangeEvent<HTMLInputElement>) => void;
281
+ readonly isValidating: boolean;
282
+ readonly responsiveSize: 'sm' | 'md' | 'lg';
283
+ readonly searchString: string;
284
+ readonly t: (key: string, fallback: string) => string;
285
+ }
286
+
287
+ function FilterableTableHeader({
288
+ layout,
289
+ handleSearch,
290
+ isValidating,
291
+ responsiveSize,
292
+ searchString,
293
+ t,
294
+ }: FilterableTableHeaderProps) {
295
+ return (
296
+ <>
297
+ <div className={styles.headerContainer}>
298
+ <div
299
+ className={classNames({
300
+ [styles.tabletHeading]: !isDesktop(layout),
301
+ [styles.desktopHeading]: isDesktop(layout),
302
+ })}>
303
+ <h4>{t('refundRequests', 'Refund requests')}</h4>
304
+ </div>
305
+ {isValidating && (
306
+ <span>
307
+ <InlineLoading />
308
+ </span>
309
+ )}
310
+ </div>
311
+ <Search
312
+ closeButtonLabelText={t('clearSearch', 'Clear')}
313
+ data-testid="refundRequestsSearchBar"
314
+ labelText={t('searchRefundRequests', 'Search refund requests')}
315
+ placeholder={t('searchByPatientOrBill', 'Search by patient name or bill #')}
316
+ value={searchString}
317
+ onChange={handleSearch}
318
+ size={responsiveSize}
319
+ />
320
+ </>
321
+ );
322
+ }
323
+
324
+ export default RefundRequests;
@@ -0,0 +1,133 @@
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
+ @use '@openmrs/esm-styleguide/src/vars' as *;
4
+
5
+ .container {
6
+ height: calc(100vh - layout.$spacing-09);
7
+ margin: layout.$spacing-05;
8
+ }
9
+
10
+ .servicesTableContainer {
11
+ margin: layout.$spacing-07 layout.$spacing-05;
12
+ }
13
+
14
+ .sectionMargin {
15
+ margin: layout.$spacing-07 0;
16
+ }
17
+
18
+ .emptyStateContainer,
19
+ .loaderContainer,
20
+ .errorContainer {
21
+ @extend .sectionMargin;
22
+ }
23
+
24
+ .billListContainer {
25
+ background-color: $ui-02;
26
+ border: 1px solid $ui-03;
27
+ width: 100%;
28
+ margin: 0 auto;
29
+ max-width: 95vw;
30
+ padding-bottom: 0;
31
+
32
+ :has(.filterEmptyState) {
33
+ border-bottom: none;
34
+ }
35
+ }
36
+
37
+ .filterContainer {
38
+ flex: 1;
39
+
40
+ :global(.cds--dropdown__wrapper--inline) {
41
+ gap: 0;
42
+ }
43
+
44
+ :global(.cds--list-box__menu-icon) {
45
+ height: 1rem;
46
+ }
47
+
48
+ :global(.cds--list-box__menu) {
49
+ min-width: max-content;
50
+ }
51
+
52
+ :global(.cds--list-box) {
53
+ margin-left: layout.$spacing-03;
54
+ }
55
+ }
56
+
57
+ .headerContainer {
58
+ display: flex;
59
+ justify-content: space-between;
60
+ align-items: center;
61
+ padding: layout.$spacing-04 layout.$spacing-05;
62
+ background-color: $ui-02;
63
+ gap: layout.$spacing-05;
64
+ }
65
+
66
+ .row {
67
+ cursor: pointer;
68
+ }
69
+
70
+ .statusTags {
71
+ display: inline-flex;
72
+ gap: layout.$spacing-02;
73
+ }
74
+
75
+ .illo {
76
+ margin-top: layout.$spacing-05;
77
+ }
78
+
79
+ .content {
80
+ @include type.type-style('heading-compact-01');
81
+ color: $text-02;
82
+ margin-top: layout.$spacing-05;
83
+ margin-bottom: layout.$spacing-03;
84
+ }
85
+
86
+ .desktopHeading,
87
+ .tabletHeading {
88
+ text-align: left;
89
+ text-transform: capitalize;
90
+ flex: 1;
91
+
92
+ h4 {
93
+ @include type.type-style('heading-compact-02');
94
+ color: $text-02;
95
+
96
+ &:after {
97
+ content: '';
98
+ display: block;
99
+ width: 2rem;
100
+ padding-top: 3px;
101
+ border-bottom: 0.375rem solid;
102
+ @include brand-03(border-bottom-color);
103
+ }
104
+ }
105
+ }
106
+
107
+ .tile {
108
+ text-align: center;
109
+ }
110
+
111
+ .filterEmptyState {
112
+ display: flex;
113
+ justify-content: center;
114
+ align-items: center;
115
+ padding: layout.$spacing-05;
116
+ margin: layout.$spacing-09;
117
+ text-align: center;
118
+ }
119
+
120
+ .filterEmptyStateTile {
121
+ margin: auto;
122
+ }
123
+
124
+ .filterEmptyStateContent {
125
+ @include type.type-style('heading-compact-02');
126
+ color: $text-02;
127
+ margin-bottom: layout.$spacing-03;
128
+ }
129
+
130
+ .filterEmptyStateHelper {
131
+ @include type.type-style('body-compact-01');
132
+ color: $text-02;
133
+ }