@bathiran212/esm-patient-chart-app 7.0.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 (382) hide show
  1. package/README.md +3 -0
  2. package/dist/108.js +1 -0
  3. package/dist/108.js.map +1 -0
  4. package/dist/1339.js +1 -0
  5. package/dist/1339.js.map +1 -0
  6. package/dist/1480.js +1 -0
  7. package/dist/1480.js.map +1 -0
  8. package/dist/1543.js +1 -0
  9. package/dist/1543.js.map +1 -0
  10. package/dist/1582.js +1 -0
  11. package/dist/1582.js.map +1 -0
  12. package/dist/1646.js +1 -0
  13. package/dist/1646.js.map +1 -0
  14. package/dist/1797.js +1 -0
  15. package/dist/1797.js.map +1 -0
  16. package/dist/1869.js +1 -0
  17. package/dist/1869.js.map +1 -0
  18. package/dist/1877.js +1 -0
  19. package/dist/1877.js.map +1 -0
  20. package/dist/2020.js +1 -0
  21. package/dist/2020.js.map +1 -0
  22. package/dist/2246.js +1 -0
  23. package/dist/2246.js.map +1 -0
  24. package/dist/2317.js +1 -0
  25. package/dist/2317.js.map +1 -0
  26. package/dist/2416.js +1 -0
  27. package/dist/2416.js.map +1 -0
  28. package/dist/2790.js +1 -0
  29. package/dist/2790.js.map +1 -0
  30. package/dist/282.js +1 -0
  31. package/dist/282.js.map +1 -0
  32. package/dist/2881.js +1 -0
  33. package/dist/2881.js.map +1 -0
  34. package/dist/3137.js +1 -0
  35. package/dist/3137.js.map +1 -0
  36. package/dist/3378.js +1 -0
  37. package/dist/3378.js.map +1 -0
  38. package/dist/3390.js +1 -0
  39. package/dist/3390.js.map +1 -0
  40. package/dist/3536.js +1 -0
  41. package/dist/3536.js.map +1 -0
  42. package/dist/3720.js +1 -0
  43. package/dist/3720.js.map +1 -0
  44. package/dist/3857.js +1 -0
  45. package/dist/3857.js.map +1 -0
  46. package/dist/3925.js +1 -0
  47. package/dist/3925.js.map +1 -0
  48. package/dist/3963.js +1 -0
  49. package/dist/3963.js.map +1 -0
  50. package/dist/3989.js +1 -0
  51. package/dist/3989.js.map +1 -0
  52. package/dist/4092.js +1 -0
  53. package/dist/4092.js.map +1 -0
  54. package/dist/4106.js +1 -0
  55. package/dist/4106.js.map +1 -0
  56. package/dist/4111.js +1 -0
  57. package/dist/4111.js.map +1 -0
  58. package/dist/4145.js +1 -0
  59. package/dist/4145.js.map +1 -0
  60. package/dist/434.js +1 -0
  61. package/dist/434.js.map +1 -0
  62. package/dist/4348.js +1 -0
  63. package/dist/4348.js.map +1 -0
  64. package/dist/4383.js +1 -0
  65. package/dist/4383.js.map +1 -0
  66. package/dist/4540.js +1 -0
  67. package/dist/4540.js.map +1 -0
  68. package/dist/4658.js +1 -0
  69. package/dist/4658.js.map +1 -0
  70. package/dist/466.js +1 -0
  71. package/dist/466.js.map +1 -0
  72. package/dist/4913.js +1 -0
  73. package/dist/4913.js.map +1 -0
  74. package/dist/4928.js +1 -0
  75. package/dist/4928.js.map +1 -0
  76. package/dist/5069.js +1 -0
  77. package/dist/5069.js.map +1 -0
  78. package/dist/5117.js +1 -0
  79. package/dist/5117.js.map +1 -0
  80. package/dist/5132.js +1 -0
  81. package/dist/5132.js.map +1 -0
  82. package/dist/5145.js +1 -0
  83. package/dist/5145.js.map +1 -0
  84. package/dist/52.js +1 -0
  85. package/dist/52.js.map +1 -0
  86. package/dist/5422.js +1 -0
  87. package/dist/5422.js.map +1 -0
  88. package/dist/5503.js +1 -0
  89. package/dist/5503.js.map +1 -0
  90. package/dist/5549.js +1 -0
  91. package/dist/5549.js.map +1 -0
  92. package/dist/556.js +1 -0
  93. package/dist/556.js.map +1 -0
  94. package/dist/5644.js +1 -0
  95. package/dist/5644.js.map +1 -0
  96. package/dist/5697.js +1 -0
  97. package/dist/5697.js.map +1 -0
  98. package/dist/5793.js +1 -0
  99. package/dist/5793.js.map +1 -0
  100. package/dist/5940.js +1 -0
  101. package/dist/5940.js.map +1 -0
  102. package/dist/5952.js +1 -0
  103. package/dist/5952.js.map +1 -0
  104. package/dist/6047.js +1 -0
  105. package/dist/6047.js.map +1 -0
  106. package/dist/6371.js +1 -0
  107. package/dist/6371.js.map +1 -0
  108. package/dist/6377.js +1 -0
  109. package/dist/6377.js.map +1 -0
  110. package/dist/6444.js +1 -0
  111. package/dist/6444.js.map +1 -0
  112. package/dist/6479.js +1 -0
  113. package/dist/6479.js.map +1 -0
  114. package/dist/6508.js +1 -0
  115. package/dist/6508.js.map +1 -0
  116. package/dist/6724.js +1 -0
  117. package/dist/6724.js.map +1 -0
  118. package/dist/6759.js +27 -0
  119. package/dist/6759.js.map +1 -0
  120. package/dist/689.js +1 -0
  121. package/dist/689.js.map +1 -0
  122. package/dist/6904.js +1 -0
  123. package/dist/6904.js.map +1 -0
  124. package/dist/7045.js +1 -0
  125. package/dist/7045.js.map +1 -0
  126. package/dist/7175.js +1 -0
  127. package/dist/7175.js.map +1 -0
  128. package/dist/7182.js +1 -0
  129. package/dist/7182.js.map +1 -0
  130. package/dist/7302.js +1 -0
  131. package/dist/7302.js.map +1 -0
  132. package/dist/7646.js +17 -0
  133. package/dist/7646.js.map +1 -0
  134. package/dist/7742.js +1 -0
  135. package/dist/7742.js.map +1 -0
  136. package/dist/7912.js +1 -0
  137. package/dist/7912.js.map +1 -0
  138. package/dist/8105.js +21 -0
  139. package/dist/8105.js.map +1 -0
  140. package/dist/8202.js +1 -0
  141. package/dist/8202.js.map +1 -0
  142. package/dist/8349.js +1 -0
  143. package/dist/8349.js.map +1 -0
  144. package/dist/8358.js +1 -0
  145. package/dist/8358.js.map +1 -0
  146. package/dist/8359.js +1 -0
  147. package/dist/8359.js.map +1 -0
  148. package/dist/8695.js +1 -0
  149. package/dist/8695.js.map +1 -0
  150. package/dist/8702.js +1 -0
  151. package/dist/8702.js.map +1 -0
  152. package/dist/8894.js +1 -0
  153. package/dist/8894.js.map +1 -0
  154. package/dist/8958.js +1 -0
  155. package/dist/8958.js.map +1 -0
  156. package/dist/903.js +1 -0
  157. package/dist/903.js.map +1 -0
  158. package/dist/9061.js +1 -0
  159. package/dist/9061.js.map +1 -0
  160. package/dist/9072.js +1 -0
  161. package/dist/9072.js.map +1 -0
  162. package/dist/9105.js +1 -0
  163. package/dist/9105.js.map +1 -0
  164. package/dist/9107.js +1 -0
  165. package/dist/9107.js.map +1 -0
  166. package/dist/9456.js +1 -0
  167. package/dist/9456.js.map +1 -0
  168. package/dist/9586.js +1 -0
  169. package/dist/9586.js.map +1 -0
  170. package/dist/9712.js +1 -0
  171. package/dist/9712.js.map +1 -0
  172. package/dist/9771.js +1 -0
  173. package/dist/9771.js.map +1 -0
  174. package/dist/9806.js +1 -0
  175. package/dist/9806.js.map +1 -0
  176. package/dist/9873.js +1 -0
  177. package/dist/9873.js.map +1 -0
  178. package/dist/9927.js +1 -0
  179. package/dist/9927.js.map +1 -0
  180. package/dist/main.js +6 -0
  181. package/dist/main.js.map +1 -0
  182. package/dist/openmrs-esm-patient-chart-app.js +6 -0
  183. package/dist/openmrs-esm-patient-chart-app.js.buildmanifest.json +2386 -0
  184. package/dist/openmrs-esm-patient-chart-app.js.map +1 -0
  185. package/dist/routes.json +1 -0
  186. package/package.json +63 -0
  187. package/rspack.config.js +1 -0
  188. package/src/actions-buttons/action-button.scss +3 -0
  189. package/src/actions-buttons/delete-visit.component.tsx +41 -0
  190. package/src/actions-buttons/delete-visit.test.tsx +26 -0
  191. package/src/actions-buttons/mark-patient-alive.component.tsx +42 -0
  192. package/src/actions-buttons/mark-patient-deceased.component.tsx +35 -0
  193. package/src/actions-buttons/start-visit.component.tsx +41 -0
  194. package/src/actions-buttons/start-visit.test.tsx +44 -0
  195. package/src/actions-buttons/stop-visit.component.tsx +39 -0
  196. package/src/actions-buttons/stop-visit.test.tsx +27 -0
  197. package/src/clinical-views/encounter-list/encounter-list-tabs.extension.tsx +78 -0
  198. package/src/clinical-views/encounter-list/encounter-list-tabs.scss +7 -0
  199. package/src/clinical-views/encounter-list/encounter-list.component.tsx +306 -0
  200. package/src/clinical-views/encounter-list/encounter-list.scss +36 -0
  201. package/src/clinical-views/encounter-list/table.component.tsx +63 -0
  202. package/src/clinical-views/encounter-list/table.scss +11 -0
  203. package/src/clinical-views/encounter-list/tag.component.test.tsx +307 -0
  204. package/src/clinical-views/encounter-list/tag.component.tsx +43 -0
  205. package/src/clinical-views/encounter-tile/clinical-views-summary.component.tsx +40 -0
  206. package/src/clinical-views/encounter-tile/encounter-tile.component.tsx +94 -0
  207. package/src/clinical-views/encounter-tile/tile.scss +82 -0
  208. package/src/clinical-views/hooks/index.ts +3 -0
  209. package/src/clinical-views/hooks/useEncounterRows.ts +60 -0
  210. package/src/clinical-views/hooks/useEncountersByVisit.ts +13 -0
  211. package/src/clinical-views/hooks/useFormsJson.ts +15 -0
  212. package/src/clinical-views/hooks/useLastEncounter.ts +29 -0
  213. package/src/clinical-views/types.ts +305 -0
  214. package/src/clinical-views/utils/concept-utils.ts +24 -0
  215. package/src/clinical-views/utils/encounter-list-config-builder.ts +160 -0
  216. package/src/clinical-views/utils/encounter-list.resource.ts +26 -0
  217. package/src/clinical-views/utils/helpers.ts +226 -0
  218. package/src/clinical-views/utils/index.ts +90 -0
  219. package/src/config-schema.ts +235 -0
  220. package/src/constants.ts +11 -0
  221. package/src/dashboard.meta.ts +15 -0
  222. package/src/data.resource.ts +117 -0
  223. package/src/declarations.d.ts +4 -0
  224. package/src/index.ts +204 -0
  225. package/src/loader/loader.component.tsx +11 -0
  226. package/src/loader/loader.scss +9 -0
  227. package/src/mark-patient-alive/mark-patient-alive.modal.tsx +54 -0
  228. package/src/mark-patient-deceased/mark-patient-deceased-form.scss +175 -0
  229. package/src/mark-patient-deceased/mark-patient-deceased-form.test.tsx +203 -0
  230. package/src/mark-patient-deceased/mark-patient-deceased-form.workspace.tsx +295 -0
  231. package/src/offline.ts +41 -0
  232. package/src/patient-banner-tags/visit-attribute-tags.extension.tsx +62 -0
  233. package/src/patient-banner-tags/visit-attribute-tags.scss +8 -0
  234. package/src/patient-chart/chart-review/chart-review.component.tsx +138 -0
  235. package/src/patient-chart/chart-review/chart-review.test.tsx +77 -0
  236. package/src/patient-chart/chart-review/dashboard-view.component.tsx +85 -0
  237. package/src/patient-chart/chart-review/dashboard-view.scss +84 -0
  238. package/src/patient-chart/patient-chart.component.tsx +71 -0
  239. package/src/patient-chart/patient-chart.resources.test.ts +238 -0
  240. package/src/patient-chart/patient-chart.resources.ts +231 -0
  241. package/src/patient-chart/patient-chart.scss +65 -0
  242. package/src/patient-details-tile/patient-details-tile.component.tsx +25 -0
  243. package/src/patient-details-tile/patient-details-tile.scss +24 -0
  244. package/src/root.component.tsx +35 -0
  245. package/src/root.scss +54 -0
  246. package/src/routes.json +267 -0
  247. package/src/side-nav/side-menu.component.tsx +10 -0
  248. package/src/side-nav/side-menu.scss +38 -0
  249. package/src/side-nav/side-menu.test.tsx +27 -0
  250. package/src/utils.test.ts +17 -0
  251. package/src/utils.ts +5 -0
  252. package/src/visit/hooks/useDefaultFacilityLocation.tsx +15 -0
  253. package/src/visit/hooks/useDefaultVisitLocation.tsx +24 -0
  254. package/src/visit/hooks/useDeleteVisit.test.tsx +267 -0
  255. package/src/visit/hooks/useDeleteVisit.tsx +103 -0
  256. package/src/visit/hooks/useOfflineVisitType.tsx +18 -0
  257. package/src/visit/hooks/useRecommendedVisitTypes.tsx +34 -0
  258. package/src/visit/hooks/useVisitAttributeType.tsx +102 -0
  259. package/src/visit/start-visit-button.component.tsx +47 -0
  260. package/src/visit/start-visit-button.test.tsx +32 -0
  261. package/src/visit/visit-action-items/delete-visit-action-item.component.tsx +60 -0
  262. package/src/visit/visit-action-items/delete-visit-action-item.test.tsx +48 -0
  263. package/src/visit/visit-action-items/edit-visit-details.component.tsx +79 -0
  264. package/src/visit/visit-form/base-visit-type.component.tsx +121 -0
  265. package/src/visit/visit-form/base-visit-type.scss +75 -0
  266. package/src/visit/visit-form/base-visit-type.test.tsx +153 -0
  267. package/src/visit/visit-form/exported-visit-form.workspace.tsx +755 -0
  268. package/src/visit/visit-form/location-selector.component.tsx +86 -0
  269. package/src/visit/visit-form/location-selector.test.tsx +146 -0
  270. package/src/visit/visit-form/recommended-visit-type.component.tsx +32 -0
  271. package/src/visit/visit-form/visit-attribute-type.component.tsx +258 -0
  272. package/src/visit/visit-form/visit-attribute-type.scss +5 -0
  273. package/src/visit/visit-form/visit-date-time.component.tsx +206 -0
  274. package/src/visit/visit-form/visit-form.resource.ts +401 -0
  275. package/src/visit/visit-form/visit-form.scss +167 -0
  276. package/src/visit/visit-form/visit-form.test.tsx +1233 -0
  277. package/src/visit/visit-form/visit-form.workspace.tsx +61 -0
  278. package/src/visit/visit-form/visit-type.test.tsx +88 -0
  279. package/src/visit/visit-history-table/visit-actions-cell.component.tsx +20 -0
  280. package/src/visit/visit-history-table/visit-actions-cell.scss +4 -0
  281. package/src/visit/visit-history-table/visit-date-cell.component.tsx +19 -0
  282. package/src/visit/visit-history-table/visit-diagnoses-cell.component.tsx +18 -0
  283. package/src/visit/visit-history-table/visit-history-table.component.tsx +145 -0
  284. package/src/visit/visit-history-table/visit-history-table.scss +25 -0
  285. package/src/visit/visit-history-table/visit-type-cell.component.tsx +15 -0
  286. package/src/visit/visit-prompt/delete-visit-dialog.modal.tsx +46 -0
  287. package/src/visit/visit-prompt/delete-visit-dialog.test.tsx +79 -0
  288. package/src/visit/visit-prompt/end-visit-dialog.modal.tsx +82 -0
  289. package/src/visit/visit-prompt/end-visit-dialog.scss +7 -0
  290. package/src/visit/visit-prompt/end-visit-dialog.test.tsx +131 -0
  291. package/src/visit/visit-prompt/modify-visit-date.modal.tsx +40 -0
  292. package/src/visit/visit-prompt/start-visit-dialog.modal.tsx +64 -0
  293. package/src/visit/visit-prompt/start-visit-dialog.scss +10 -0
  294. package/src/visit/visit-prompt/start-visit-dialog.test.tsx +40 -0
  295. package/src/visit/visits-widget/active-visit-buttons/active-visit-buttons.scss +7 -0
  296. package/src/visit/visits-widget/active-visit-buttons/active-visit-buttons.tsx +178 -0
  297. package/src/visit/visits-widget/current-visit-summary.extension.tsx +48 -0
  298. package/src/visit/visits-widget/current-visit-summary.scss +10 -0
  299. package/src/visit/visits-widget/current-visit-summary.test.tsx +85 -0
  300. package/src/visit/visits-widget/encounter-observations/encounter-observations.component.tsx +67 -0
  301. package/src/visit/visits-widget/encounter-observations/index.ts +3 -0
  302. package/src/visit/visits-widget/encounter-observations/styles.scss +22 -0
  303. package/src/visit/visits-widget/past-visits-components/delete-encounter.modal.tsx +47 -0
  304. package/src/visit/visits-widget/past-visits-components/delete-encounter.scss +9 -0
  305. package/src/visit/visits-widget/past-visits-components/encounters-table/all-encounters-table.component.tsx +49 -0
  306. package/src/visit/visits-widget/past-visits-components/encounters-table/completed-forms-table.component.tsx +67 -0
  307. package/src/visit/visits-widget/past-visits-components/encounters-table/completed-forms-table.test.tsx +146 -0
  308. package/src/visit/visits-widget/past-visits-components/encounters-table/encounters-table.component.tsx +452 -0
  309. package/src/visit/visits-widget/past-visits-components/encounters-table/encounters-table.resource.test.ts +156 -0
  310. package/src/visit/visits-widget/past-visits-components/encounters-table/encounters-table.resource.ts +215 -0
  311. package/src/visit/visits-widget/past-visits-components/encounters-table/encounters-table.scss +113 -0
  312. package/src/visit/visits-widget/past-visits-components/encounters-table/encounters-table.test.tsx +432 -0
  313. package/src/visit/visits-widget/past-visits-components/encounters-table/visit-completed-forms-table.component.tsx +61 -0
  314. package/src/visit/visits-widget/past-visits-components/encounters-table/visit-completed-forms-table.test.tsx +125 -0
  315. package/src/visit/visits-widget/past-visits-components/encounters-table/visit-encounters-table.component.tsx +47 -0
  316. package/src/visit/visits-widget/past-visits-components/medications-summary.component.tsx +163 -0
  317. package/src/visit/visits-widget/past-visits-components/notes-summary.component.tsx +66 -0
  318. package/src/visit/visits-widget/past-visits-components/patient-notes-summary.component.tsx +318 -0
  319. package/src/visit/visits-widget/past-visits-components/tests-summary.component.tsx +16 -0
  320. package/src/visit/visits-widget/past-visits-components/visit-summary.component.tsx +192 -0
  321. package/src/visit/visits-widget/past-visits-components/visit-summary.scss +72 -0
  322. package/src/visit/visits-widget/past-visits-components/visit-summary.test.tsx +105 -0
  323. package/src/visit/visits-widget/single-visit-details/visit-timeline/visit-timeline.component.tsx +94 -0
  324. package/src/visit/visits-widget/single-visit-details/visit-timeline/visit-timeline.scss +60 -0
  325. package/src/visit/visits-widget/visit-context/retrospective-data-date-time-picker/restrospective-date-time-picker.scss +35 -0
  326. package/src/visit/visits-widget/visit-context/retrospective-data-date-time-picker/retrospective-date-time-picker.component.tsx +140 -0
  327. package/src/visit/visits-widget/visit-context/visit-context-header.extension.tsx +61 -0
  328. package/src/visit/visits-widget/visit-context/visit-context-header.scss +45 -0
  329. package/src/visit/visits-widget/visit-context/visit-context-header.test.tsx +59 -0
  330. package/src/visit/visits-widget/visit-context/visit-context-info.component.tsx +37 -0
  331. package/src/visit/visits-widget/visit-context/visit-context-info.scss +12 -0
  332. package/src/visit/visits-widget/visit-context/visit-context-switcher.modal.tsx +166 -0
  333. package/src/visit/visits-widget/visit-context/visit-context-switcher.scss +83 -0
  334. package/src/visit/visits-widget/visit-context/visit-context-switcher.test.tsx +79 -0
  335. package/src/visit/visits-widget/visit-detail-overview.component.tsx +67 -0
  336. package/src/visit/visits-widget/visit-detail-overview.scss +301 -0
  337. package/src/visit/visits-widget/visit-detail-overview.test.tsx +205 -0
  338. package/src/visit/visits-widget/visit.resource.tsx +146 -0
  339. package/translations/am.json +209 -0
  340. package/translations/ar.json +209 -0
  341. package/translations/ar_SY.json +209 -0
  342. package/translations/bn.json +209 -0
  343. package/translations/cs.json +209 -0
  344. package/translations/de.json +209 -0
  345. package/translations/en.json +209 -0
  346. package/translations/en_US.json +209 -0
  347. package/translations/es.json +209 -0
  348. package/translations/es_MX.json +209 -0
  349. package/translations/fr.json +209 -0
  350. package/translations/he.json +209 -0
  351. package/translations/hi.json +209 -0
  352. package/translations/hi_IN.json +209 -0
  353. package/translations/id.json +209 -0
  354. package/translations/it.json +209 -0
  355. package/translations/ka.json +209 -0
  356. package/translations/km.json +209 -0
  357. package/translations/ku.json +209 -0
  358. package/translations/ky.json +209 -0
  359. package/translations/lg.json +209 -0
  360. package/translations/ne.json +209 -0
  361. package/translations/pl.json +209 -0
  362. package/translations/pt.json +209 -0
  363. package/translations/pt_BR.json +209 -0
  364. package/translations/qu.json +209 -0
  365. package/translations/ro_RO.json +209 -0
  366. package/translations/ru_RU.json +209 -0
  367. package/translations/si.json +209 -0
  368. package/translations/sq.json +209 -0
  369. package/translations/sw.json +209 -0
  370. package/translations/sw_KE.json +209 -0
  371. package/translations/tr.json +209 -0
  372. package/translations/tr_TR.json +209 -0
  373. package/translations/uk.json +209 -0
  374. package/translations/uz.json +209 -0
  375. package/translations/uz@Latn.json +209 -0
  376. package/translations/uz_UZ.json +209 -0
  377. package/translations/vi.json +209 -0
  378. package/translations/zh.json +209 -0
  379. package/translations/zh_CN.json +209 -0
  380. package/translations/zh_TW.json +209 -0
  381. package/tsconfig.json +4 -0
  382. package/vitest.config.ts +4 -0
@@ -0,0 +1,231 @@
1
+ import { useCallback, useEffect, useMemo, useRef } from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import useSWR from 'swr';
4
+ import {
5
+ launchWorkspaceGroup2,
6
+ openmrsFetch,
7
+ restBaseUrl,
8
+ showSnackbar,
9
+ usePatient,
10
+ useVisit,
11
+ type Visit,
12
+ } from '@openmrs/esm-framework';
13
+ import { type PatientWorkspaceGroupProps, usePatientChartStore } from '@openmrs/esm-patient-common-lib';
14
+
15
+ const defaultVisitCustomRepresentation =
16
+ 'custom:(uuid,display,voided,indication,startDatetime,stopDatetime,' +
17
+ 'encounters:(uuid,display,encounterDatetime,' +
18
+ 'form:(uuid,name),location:ref,' +
19
+ 'encounterType:ref,' +
20
+ 'encounterProviders:(uuid,display,' +
21
+ 'provider:(uuid,display))),' +
22
+ 'patient:(uuid,display),' +
23
+ 'visitType:(uuid,name,display),' +
24
+ 'attributes:(uuid,display,attributeType:(name,datatypeClassname,uuid),value),' +
25
+ 'location:(uuid,name,display))';
26
+
27
+ type WorkspaceGroupLaunchKey = {
28
+ patientUuid: string | null;
29
+ visitContextUuid: string | null;
30
+ };
31
+
32
+ // The workspace group is current only when it was launched for this patient and visit context.
33
+ function getWorkspaceGroupLaunchKey(groupProps: PatientWorkspaceGroupProps | null): WorkspaceGroupLaunchKey {
34
+ return {
35
+ patientUuid: groupProps?.patientUuid ?? null,
36
+ visitContextUuid: groupProps?.visitContext?.uuid ?? null,
37
+ };
38
+ }
39
+
40
+ function workspaceGroupLaunchKeysEqual(a: WorkspaceGroupLaunchKey | null, b: WorkspaceGroupLaunchKey | null) {
41
+ return a?.patientUuid === b?.patientUuid && a?.visitContextUuid === b?.visitContextUuid;
42
+ }
43
+
44
+ export function useVisitByUuid(visitUuid: string | null, representation: string = defaultVisitCustomRepresentation) {
45
+ const url = `${restBaseUrl}/visit/${visitUuid}?v=${representation}`;
46
+ const { data, ...rest } = useSWR<{ data: Visit }>(visitUuid ? url : null, openmrsFetch);
47
+ return { visit: data?.data, ...rest };
48
+ }
49
+
50
+ /**
51
+ * This hook manages fetching of the patient and the visitContext
52
+ * when entering the patient chart, and the associated updated to patient chart store.
53
+ *
54
+ * The patient chart store sets the patient when we enter the patient chart
55
+ * and unsets the patient when we leave. (This gives extensions and workspaces a way
56
+ * to check whether they are rendered within the patient chart app.)
57
+ * Note: We do not unset visitContext when leaving the chart, so it persists across
58
+ * in‑app navigation. On a full page reload, visitContext is rehydrated by refetching
59
+ * (via useVisit/useVisitByUuId) rather than restored from storage.
60
+ * When we enter the chart, we want to update the visit context as follows:
61
+ * does the the stored visitContext exist and belong to the patient?
62
+ * 1. If so, the visitContext should be valid but possibly stale; fetch the visit again
63
+ * and update the context
64
+ * 2. If not, fetch the active visit of the patient, If it exists, set it as the
65
+ * visitContext; otherwise, clear it.
66
+ * @param patientUuid
67
+ * @returns
68
+ */
69
+ export function usePatientChartPatientAndVisit(patientUuid: string) {
70
+ const { t } = useTranslation();
71
+ const { isLoading: isLoadingPatient, patient } = usePatient(patientUuid);
72
+ const {
73
+ patientUuid: storePatientUuid,
74
+ setPatient,
75
+ visitContext,
76
+ mutateVisitContext,
77
+ setVisitContext,
78
+ } = usePatientChartStore(patientUuid);
79
+
80
+ const isVisitContextValid = visitContext?.patient.uuid === patientUuid;
81
+ const {
82
+ visit: newVisitContext,
83
+ mutate: newMutateVisitContext,
84
+ isValidating: isValidatingVisitContext,
85
+ } = useVisitByUuid(isVisitContextValid ? visitContext.uuid : null);
86
+ const {
87
+ activeVisit,
88
+ isValidating: isValidatingActiveVisit,
89
+ mutate: mutateActiveVisit,
90
+ } = useVisit(isVisitContextValid ? null : patientUuid);
91
+
92
+ const launchedWorkspaceGroupKey = useRef<WorkspaceGroupLaunchKey | null>(null);
93
+ const latestWorkspaceGroupProps = useRef<PatientWorkspaceGroupProps | null>(null);
94
+ const isWorkspaceGroupLaunchPending = useRef(false);
95
+ const isMounted = useRef(false);
96
+
97
+ useEffect(() => {
98
+ isMounted.current = true;
99
+ return () => {
100
+ isMounted.current = false;
101
+ };
102
+ }, []);
103
+
104
+ const launchLatestWorkspaceGroup = useCallback(async () => {
105
+ if (isWorkspaceGroupLaunchPending.current) {
106
+ return;
107
+ }
108
+
109
+ isWorkspaceGroupLaunchPending.current = true;
110
+
111
+ try {
112
+ let needsLaunch = true;
113
+ while (needsLaunch) {
114
+ const groupProps = latestWorkspaceGroupProps.current;
115
+ const launchKey = getWorkspaceGroupLaunchKey(groupProps);
116
+
117
+ if (workspaceGroupLaunchKeysEqual(launchKey, launchedWorkspaceGroupKey.current)) {
118
+ needsLaunch = false;
119
+ continue;
120
+ }
121
+
122
+ if (!isMounted.current) {
123
+ return;
124
+ }
125
+
126
+ const launched = await launchWorkspaceGroup2('patient-chart', groupProps);
127
+
128
+ if (!isMounted.current) {
129
+ return;
130
+ }
131
+
132
+ // launchWorkspaceGroup2 returns false when the user keeps the current workspace group open.
133
+ if (!launched) {
134
+ needsLaunch = false;
135
+ continue;
136
+ }
137
+
138
+ launchedWorkspaceGroupKey.current = launchKey;
139
+
140
+ const latestLaunchKey = getWorkspaceGroupLaunchKey(latestWorkspaceGroupProps.current);
141
+ if (workspaceGroupLaunchKeysEqual(latestLaunchKey, launchedWorkspaceGroupKey.current)) {
142
+ needsLaunch = false;
143
+ }
144
+ }
145
+ } finally {
146
+ isWorkspaceGroupLaunchPending.current = false;
147
+ }
148
+ }, []);
149
+
150
+ useEffect(() => {
151
+ const initializeWorkspaceGroup = async () => {
152
+ if (!isValidatingVisitContext && !isValidatingActiveVisit && patient) {
153
+ let groupProps: PatientWorkspaceGroupProps = null;
154
+ if (activeVisit) {
155
+ groupProps = {
156
+ patientUuid: patient.id,
157
+ patient,
158
+ visitContext: activeVisit,
159
+ mutateVisitContext: mutateActiveVisit,
160
+ };
161
+ } else if (newVisitContext) {
162
+ groupProps = {
163
+ patientUuid: patient.id,
164
+ patient,
165
+ visitContext: newVisitContext,
166
+ mutateVisitContext: newMutateVisitContext,
167
+ };
168
+ } else {
169
+ groupProps = {
170
+ patientUuid: patient.id,
171
+ patient,
172
+ visitContext: null,
173
+ mutateVisitContext: null,
174
+ };
175
+ }
176
+
177
+ setVisitContext(groupProps.visitContext, groupProps.mutateVisitContext);
178
+
179
+ latestWorkspaceGroupProps.current = groupProps;
180
+ await launchLatestWorkspaceGroup();
181
+ }
182
+ };
183
+
184
+ initializeWorkspaceGroup().catch((error) => {
185
+ showSnackbar({
186
+ title: t('errorLaunchingWorkspaceGroup', 'Error launching workspace group'),
187
+ subtitle: error.message,
188
+ kind: 'error',
189
+ isLowContrast: false,
190
+ });
191
+ });
192
+
193
+ return () => {};
194
+ }, [
195
+ newVisitContext,
196
+ isValidatingVisitContext,
197
+ newMutateVisitContext,
198
+ setVisitContext,
199
+ activeVisit,
200
+ isValidatingActiveVisit,
201
+ storePatientUuid,
202
+ mutateActiveVisit,
203
+ patient,
204
+ t,
205
+ launchLatestWorkspaceGroup,
206
+ ]);
207
+
208
+ useEffect(() => {
209
+ if (!isLoadingPatient) {
210
+ setPatient(patient);
211
+ }
212
+
213
+ return () => {
214
+ setPatient(null);
215
+ };
216
+ }, [patient, setPatient, isLoadingPatient]);
217
+
218
+ const state = useMemo(
219
+ () => ({
220
+ patientUuid,
221
+ patient: patient ?? {},
222
+ visitContext,
223
+ mutateVisitContext,
224
+ isLoadingPatient,
225
+ setPatient,
226
+ }),
227
+ [patient, patientUuid, visitContext, mutateVisitContext, isLoadingPatient, setPatient],
228
+ );
229
+
230
+ return state;
231
+ }
@@ -0,0 +1,65 @@
1
+ @use '@carbon/layout';
2
+ @use '@carbon/colors';
3
+ @use '@openmrs/esm-styleguide/src/vars' as *;
4
+
5
+ $actionNavOffset: 45px;
6
+ $actionPanelOffset: 256px;
7
+ $actionPanelExpandedOffset: $actionNavOffset + $actionPanelOffset;
8
+
9
+ .patientInfoSlot {
10
+ > div:not(:last-child) {
11
+ border-bottom: 1px solid colors.$gray-20;
12
+ }
13
+ }
14
+
15
+ .grid {
16
+ display: grid;
17
+ grid-template-columns: 1fr min-content;
18
+ grid-template-rows: 1fr;
19
+ align-items: stretch;
20
+ width: inherit;
21
+ }
22
+
23
+ .chartReview {
24
+ grid-row: 1;
25
+ grid-column: 1;
26
+ align-self: start;
27
+ height: 90%;
28
+ width: 100%;
29
+ margin: 0 auto;
30
+ padding-bottom: layout.$spacing-10;
31
+ }
32
+
33
+ .widthContained {
34
+ max-width: 60rem;
35
+ }
36
+
37
+ :global(.omrs-breakpoint-gt-small-desktop) .widthContained {
38
+ max-width: 80rem;
39
+ }
40
+
41
+ .chartContainer {
42
+ flex: 1;
43
+ display: flex;
44
+ align-items: flex-start;
45
+ flex-direction: column;
46
+ }
47
+
48
+ .innerChartContainer {
49
+ display: flex;
50
+ width: 100%;
51
+ flex-direction: column;
52
+ }
53
+
54
+ // Overriding styles for RTL support
55
+ html[dir='rtl'] {
56
+ .chartContainer {
57
+ padding-right: unset;
58
+ padding-left: layout.$spacing-01;
59
+ }
60
+
61
+ :global(.omrs-breakpoint-lt-desktop) .innerChartContainer {
62
+ padding-left: 0;
63
+ margin-right: unset;
64
+ }
65
+ }
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { useTranslation } from 'react-i18next';
3
+ import { capitalize } from 'lodash-es';
4
+ import { age, getPatientName, formatDate, parseDate } from '@openmrs/esm-framework';
5
+ import styles from './patient-details-tile.scss';
6
+
7
+ interface PatientDetailsTileInterface {
8
+ patient?: fhir.Patient;
9
+ }
10
+
11
+ const PatientDetailsTile: React.FC<PatientDetailsTileInterface> = ({ patient }) => {
12
+ const { t } = useTranslation();
13
+
14
+ return (
15
+ <div className={styles.container}>
16
+ <p className={styles.name}>{patient ? getPatientName(patient) : ''}</p>
17
+ <div className={styles.details}>
18
+ <span>{capitalize(patient?.gender)}</span> &middot; <span>{age(patient?.birthDate)}</span> &middot;{' '}
19
+ <span>{formatDate(parseDate(patient?.birthDate), { mode: 'wide', time: false })}</span>
20
+ </div>
21
+ </div>
22
+ );
23
+ };
24
+
25
+ export default PatientDetailsTile;
@@ -0,0 +1,24 @@
1
+ @use '@carbon/layout';
2
+ @use '@carbon/type';
3
+ @use '@openmrs/esm-styleguide/src/vars' as *;
4
+
5
+ .container:after {
6
+ content: '';
7
+ height: 100%;
8
+ width: 1px;
9
+ position: absolute;
10
+ right: 0;
11
+ top: 0;
12
+ background-color: $color-gray-30;
13
+ margin: 0 layout.$spacing-05;
14
+ }
15
+
16
+ .details {
17
+ margin-top: 5px;
18
+ @include type.type-style('body-compact-01');
19
+ color: $text-02;
20
+ }
21
+
22
+ .name {
23
+ @include type.type-style('body-compact-02');
24
+ }
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { BrowserRouter, Route, Routes } from 'react-router-dom';
3
+ import { dashboardPath, spaRoot, basePath } from './constants';
4
+ import PatientChart from './patient-chart/patient-chart.component';
5
+ import styles from './root.scss';
6
+
7
+ export default function Root() {
8
+ return (
9
+ <>
10
+ <div className={styles.patientChartWrapper}>
11
+ <BrowserRouter basename={spaRoot}>
12
+ <Routes>
13
+ <Route path={basePath} element={<PatientChart />} />
14
+ <Route path={dashboardPath} element={<PatientChart />} />
15
+ </Routes>
16
+ </BrowserRouter>
17
+ </div>
18
+ </>
19
+ );
20
+ }
21
+
22
+ /**
23
+ * DO NOT REMOVE THIS COMMENT
24
+ * THE TRANSLATION KEYS AND VALUES USED IN THE COMMON LIB IS WRITTEN HERE
25
+ * t('paginationPageText', 'of {{count}} pages', {count})
26
+ * t("emptyStateText", 'There are no {{displayText}} to display for this patient', {displayText: "sample text"})
27
+ * t('record', 'Record')
28
+ * t('errorCopy','Sorry, there was a problem displaying this information. You can try to reload this page, or contact the site administrator and quote the error code above.')
29
+ * t('error', 'Error')
30
+ * t('seeAll', 'See all')
31
+ * t('paginationItemsCount', `{{pageItemsCount}} / {{count}} items`, { count: totalItems, pageItemsCount });
32
+ * t('Routine')
33
+ * t('Stat')
34
+ * t('On scheduled date')
35
+ */
package/src/root.scss ADDED
@@ -0,0 +1,54 @@
1
+ @use '@carbon/colors';
2
+ @use '@carbon/layout';
3
+ @use '@carbon/type';
4
+
5
+ .patientChartWrapper {
6
+ display: flex;
7
+ position: relative;
8
+ }
9
+
10
+ .patientChartWrapper {
11
+ & > nav {
12
+ padding-bottom: layout.$spacing-09;
13
+ scrollbar-width: none;
14
+ }
15
+
16
+ :global(.cds--side-nav__overlay-active) {
17
+ background-color: transparent;
18
+ }
19
+ }
20
+
21
+ :global(.omrs-breakpoint-gt-tablet) .patientChartWrapper {
22
+ margin-left: var(--omrs-sidenav-width);
23
+ }
24
+
25
+ // Tablet side nav scrolling
26
+ :global(.omrs-breakpoint-lt-desktop) {
27
+ .patientChartWrapper {
28
+ :global(.cds--side-nav) {
29
+ height: calc(100vh - layout.$spacing-09 - var(--bottom-nav-height));
30
+ }
31
+ }
32
+ }
33
+
34
+ // Overriding styles for RTL support
35
+ html[dir='rtl'] {
36
+ :global(.cds--date-picker-input__wrapper) {
37
+ svg {
38
+ left: layout.$spacing-05;
39
+ right: unset;
40
+ }
41
+ }
42
+ :global(.cds--side-nav) {
43
+ right: 0;
44
+ :global(.active-left-nav-link) {
45
+ border-right: layout.$spacing-02 solid var(--brand-01);
46
+ border-left: unset;
47
+ }
48
+ }
49
+
50
+ :global(.omrs-breakpoint-gt-tablet) .patientChartWrapper {
51
+ margin-right: var(--omrs-sidenav-width);
52
+ margin-left: unset;
53
+ }
54
+ }
@@ -0,0 +1,267 @@
1
+ {
2
+ "$schema": "https://json.openmrs.org/routes.schema.json",
3
+ "optionalBackendDependencies": {
4
+ "emrapi": {
5
+ "version": ">=2.0.0 <4.0.0",
6
+ "feature": {
7
+ "flagName": "emrapi-module",
8
+ "label": "EMR API Module",
9
+ "description": "This module, if installed, provides core EMR business logic."
10
+ }
11
+ }
12
+ },
13
+ "extensions": [
14
+ {
15
+ "name": "charts-summary-dashboard",
16
+ "component": "patientSummaryDashboardLink",
17
+ "slot": "patient-chart-dashboard-slot",
18
+ "order": 0,
19
+ "meta": {
20
+ "slot": "patient-chart-summary-dashboard-slot",
21
+ "path": "patient-summary"
22
+ },
23
+ "online": true,
24
+ "offline": true
25
+ },
26
+ {
27
+ "name": "encounter-list",
28
+ "component": "encounterListTableTabs",
29
+ "online": true,
30
+ "offline": true
31
+ },
32
+ {
33
+ "name": "start-visit-button",
34
+ "component": "startVisitActionButton",
35
+ "slot": "patient-actions-slot",
36
+ "online": true,
37
+ "offline": true
38
+ },
39
+ {
40
+ "name": "clinical-views-summary",
41
+ "component": "clinicalViewsSummary",
42
+ "online": true,
43
+ "offline": true
44
+ },
45
+ {
46
+ "name": "stop-visit-button",
47
+ "component": "stopVisitActionButton",
48
+ "slot": "patient-actions-slot",
49
+ "online": true,
50
+ "offline": true
51
+ },
52
+ {
53
+ "name": "mark-alive-button",
54
+ "slot": "patient-actions-slot",
55
+ "component": "markPatientAliveActionButton",
56
+ "online": true,
57
+ "offline": true
58
+ },
59
+ {
60
+ "name": "stop-visit-button-patient-search",
61
+ "slot": "patient-search-actions-slot",
62
+ "component": "stopVisitPatientSearchActionButton",
63
+ "online": true,
64
+ "offline": true
65
+ },
66
+ {
67
+ "name": "delete-visit-button",
68
+ "slot": "patient-actions-slot",
69
+ "component": "deleteVisitActionMenuButton",
70
+ "online": true,
71
+ "offline": true,
72
+ "order": 1100
73
+ },
74
+ {
75
+ "name": "delete-visit-button",
76
+ "slot": "patient-search-actions-slot",
77
+ "component": "deleteVisitActionMenuButton",
78
+ "online": true,
79
+ "offline": true,
80
+ "order": 1100
81
+ },
82
+ {
83
+ "name": "mark-patient-deceased-button",
84
+ "slot": "patient-actions-slot",
85
+ "component": "markPatientDeceasedActionButton",
86
+ "online": true,
87
+ "offline": true
88
+ },
89
+ {
90
+ "name": "encounters-summary-dashboard",
91
+ "slot": "patient-chart-dashboard-slot",
92
+ "component": "encountersSummaryDashboardLink",
93
+ "meta": {
94
+ "slot": "patient-chart-encounters-dashboard-slot",
95
+ "path": "visits",
96
+ "layoutMode": "anchored"
97
+ },
98
+ "order": 5,
99
+ "online": true,
100
+ "offline": true
101
+ },
102
+ {
103
+ "name": "past-visits-detail-overview",
104
+ "slot": "patient-chart-encounters-dashboard-slot",
105
+ "component": "pastVisitsDetailOverview",
106
+ "order": 1,
107
+ "meta": {
108
+ "title": "Visits",
109
+ "view": "visits"
110
+ },
111
+ "online": true,
112
+ "offline": true
113
+ },
114
+ {
115
+ "name": "patient-details-tile",
116
+ "slot": "visit-form-header-slot",
117
+ "component": "patientDetailsTile",
118
+ "order": 1,
119
+ "online": true,
120
+ "offline": true
121
+ },
122
+ {
123
+ "name": "start-visit-button-patient-search",
124
+ "slot": "start-visit-button-slot",
125
+ "component": "startVisitPatientSearchActionButton",
126
+ "online": true,
127
+ "offline": true
128
+ },
129
+ {
130
+ "name": "visit-attribute-tags",
131
+ "slot": "patient-banner-tags-slot",
132
+ "component": "visitAttributeTags",
133
+ "online": true,
134
+ "offline": true
135
+ },
136
+ {
137
+ "name": "current-visit-summary",
138
+ "component": "currentVisitSummary",
139
+ "online": true,
140
+ "offline": true,
141
+ "meta": {
142
+ "fullWidth": true
143
+ }
144
+ },
145
+ {
146
+ "name": "edit-visit-action-button",
147
+ "slot": "visit-detail-overview-actions",
148
+ "component": "editVisitDetailsActionButton",
149
+ "online": true,
150
+ "offline": true,
151
+ "order": 0
152
+ },
153
+ {
154
+ "name": "delete-visit-action-button",
155
+ "slot": "visit-detail-overview-actions",
156
+ "component": "deleteVisitActionButton",
157
+ "online": true,
158
+ "offline": true,
159
+ "order": 1
160
+ },
161
+ {
162
+ "name": "active-visit-action-button",
163
+ "slot": "active-visit-actions",
164
+ "component": "activeVisitActionsComponent",
165
+ "online": true,
166
+ "offline": true,
167
+ "order": 1
168
+ },
169
+ {
170
+ "name": "visit-context-header",
171
+ "slot": "visit-context-header-slot",
172
+ "component": "visitContextHeader"
173
+ },
174
+ {
175
+ "name": "retrospective-date-time-picker",
176
+ "slot": "restrospective-date-time-picker-slot",
177
+ "component": "retrospectiveDateTimePicker"
178
+ }
179
+ ],
180
+ "featureFlags": [
181
+ {
182
+ "description": "Features to enter data for past visits. Includes the 'Edit Past Visit' button in the start visit dialog, and the 'Add Past Visit' button in the patient header",
183
+ "flagName": "rde",
184
+ "label": "Retrospective Data Entry"
185
+ },
186
+ {
187
+ "description": "When enabled, encounter summaries will display the full form layout instead of a simple observation list.",
188
+ "flagName": "enable-embedded-form-view",
189
+ "label": "Enable Embedded Form View"
190
+ }
191
+ ],
192
+ "modals": [
193
+ {
194
+ "name": "delete-encounter-modal",
195
+ "component": "deleteEncounterModal"
196
+ },
197
+ {
198
+ "name": "delete-visit-dialog",
199
+ "component": "deleteVisitModal"
200
+ },
201
+ {
202
+ "name": "end-visit-dialog",
203
+ "component": "endVisitModal"
204
+ },
205
+ {
206
+ "name": "mark-patient-alive-modal",
207
+ "component": "markPatientAliveModal"
208
+ },
209
+ {
210
+ "name": "modify-visit-date-dialog",
211
+ "component": "modifyVisitDateModal"
212
+ },
213
+ {
214
+ "name": "start-visit-dialog",
215
+ "component": "startVisitModal"
216
+ },
217
+ {
218
+ "name": "visit-context-switcher",
219
+ "component": "visitContextSwitcherModal"
220
+ }
221
+ ],
222
+ "pages": [
223
+ {
224
+ "component": "root",
225
+ "routeRegex": "^patient\/.+\/chart",
226
+ "online": true,
227
+ "offline": true
228
+ }
229
+ ],
230
+ "workspaces2": [
231
+ {
232
+ "name": "mark-patient-deceased-workspace-form",
233
+ "component": "markPatientDeceasedForm",
234
+ "window": "mark-patient-deceased"
235
+ },
236
+ {
237
+ "name": "start-visit-workspace-form",
238
+ "component": "startVisitWorkspace",
239
+ "window": "start-visit"
240
+ },
241
+ {
242
+ "name": "patient-chart-appointments-form-workspace",
243
+ "component": "@openmrs/esm-appointments-app#exportedAppointmentsFormWorkspace",
244
+ "window": "patient-chart-appointment-form"
245
+ }
246
+ ],
247
+ "workspaceWindows2": [
248
+ {
249
+ "name": "start-visit",
250
+ "group": "patient-chart"
251
+ },
252
+ {
253
+ "name": "mark-patient-deceased",
254
+ "group": "patient-chart"
255
+ },
256
+ {
257
+ "name": "patient-chart-appointment-form",
258
+ "group": "patient-chart"
259
+ }
260
+ ],
261
+ "workspaceGroups2": [
262
+ {
263
+ "name": "patient-chart",
264
+ "scopePattern": "/patient/([^/]+)/chart"
265
+ }
266
+ ]
267
+ }