@kenyaemr/esm-shr-app 5.4.4-pre.43 → 5.4.4-pre.430

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 (428) hide show
  1. package/.turbo/turbo-build.log +5 -5
  2. package/dist/1072.js +1 -1
  3. package/dist/1072.js.map +1 -1
  4. package/dist/1278.js +1 -0
  5. package/dist/1278.js.map +1 -0
  6. package/dist/15.js +1 -0
  7. package/dist/15.js.map +1 -0
  8. package/dist/1620.js +1 -0
  9. package/dist/1620.js.map +1 -0
  10. package/dist/1789.js +1 -0
  11. package/dist/1789.js.map +1 -0
  12. package/dist/1823.js +1 -0
  13. package/dist/1823.js.map +1 -0
  14. package/dist/1831.js +1 -0
  15. package/dist/1831.js.map +1 -0
  16. package/dist/1844.js +1 -0
  17. package/dist/1844.js.map +1 -0
  18. package/dist/1854.js +1 -0
  19. package/dist/1854.js.map +1 -0
  20. package/dist/1919.js +1 -0
  21. package/dist/1919.js.map +1 -0
  22. package/dist/1946.js +1 -0
  23. package/dist/1946.js.map +1 -0
  24. package/dist/2007.js +1 -1
  25. package/dist/2007.js.map +1 -1
  26. package/dist/2127.js +1 -0
  27. package/dist/2127.js.map +1 -0
  28. package/dist/2146.js +1 -0
  29. package/dist/2146.js.map +1 -0
  30. package/dist/2202.js +1 -0
  31. package/dist/2202.js.map +1 -0
  32. package/dist/2394.js +1 -0
  33. package/dist/2394.js.map +1 -0
  34. package/dist/2468.js +1 -0
  35. package/dist/2468.js.map +1 -0
  36. package/dist/2498.js +1 -0
  37. package/dist/2498.js.map +1 -0
  38. package/dist/2534.js +1 -1
  39. package/dist/2534.js.map +1 -1
  40. package/dist/2556.js +1 -0
  41. package/dist/2556.js.map +1 -0
  42. package/dist/26.js +1 -0
  43. package/dist/26.js.map +1 -0
  44. package/dist/{2561.js → 2648.js} +1 -1
  45. package/dist/2648.js.map +1 -0
  46. package/dist/2709.js +1 -0
  47. package/dist/2709.js.map +1 -0
  48. package/dist/2744.js +1 -0
  49. package/dist/2744.js.map +1 -0
  50. package/dist/2823.js +1 -0
  51. package/dist/2823.js.map +1 -0
  52. package/dist/2840.js +1 -0
  53. package/dist/2840.js.map +1 -0
  54. package/dist/2842.js +1 -0
  55. package/dist/2842.js.map +1 -0
  56. package/dist/2916.js +1 -0
  57. package/dist/2916.js.map +1 -0
  58. package/dist/2924.js +1 -0
  59. package/dist/2924.js.map +1 -0
  60. package/dist/3137.js +1 -0
  61. package/dist/3137.js.map +1 -0
  62. package/dist/3219.js +1 -0
  63. package/dist/3219.js.map +1 -0
  64. package/dist/3285.js +1 -0
  65. package/dist/3285.js.map +1 -0
  66. package/dist/3302.js +1 -0
  67. package/dist/3302.js.map +1 -0
  68. package/dist/3335.js +1 -0
  69. package/dist/3335.js.map +1 -0
  70. package/dist/3378.js +1 -0
  71. package/dist/3378.js.map +1 -0
  72. package/dist/3504.js +1 -0
  73. package/dist/3504.js.map +1 -0
  74. package/dist/356.js +1 -0
  75. package/dist/356.js.map +1 -0
  76. package/dist/3569.js +1 -0
  77. package/dist/3569.js.map +1 -0
  78. package/dist/3580.js +1 -0
  79. package/dist/3580.js.map +1 -0
  80. package/dist/3690.js +1 -0
  81. package/dist/3690.js.map +1 -0
  82. package/dist/3723.js +1 -0
  83. package/dist/3723.js.map +1 -0
  84. package/dist/3745.js +1 -0
  85. package/dist/3745.js.map +1 -0
  86. package/dist/3796.js +1 -0
  87. package/dist/3796.js.map +1 -0
  88. package/dist/3813.js +1 -0
  89. package/dist/3813.js.map +1 -0
  90. package/dist/3847.js +1 -0
  91. package/dist/3847.js.map +1 -0
  92. package/dist/393.js +6 -0
  93. package/dist/393.js.map +1 -0
  94. package/dist/3953.js +1 -0
  95. package/dist/3953.js.map +1 -0
  96. package/dist/4178.js +1 -1
  97. package/dist/4178.js.map +1 -1
  98. package/dist/4212.js +1 -0
  99. package/dist/4212.js.map +1 -0
  100. package/dist/4308.js +1 -1
  101. package/dist/4308.js.map +1 -1
  102. package/dist/4487.js +11 -0
  103. package/dist/4487.js.map +1 -0
  104. package/dist/4588.js +1 -0
  105. package/dist/4588.js.map +1 -0
  106. package/dist/4637.js +1 -1
  107. package/dist/4637.js.map +1 -1
  108. package/dist/466.js +1 -1
  109. package/dist/466.js.map +1 -1
  110. package/dist/4711.js +1 -0
  111. package/dist/4711.js.map +1 -0
  112. package/dist/4759.js +1 -0
  113. package/dist/4759.js.map +1 -0
  114. package/dist/4817.js +1 -0
  115. package/dist/4817.js.map +1 -0
  116. package/dist/4818.js +1 -0
  117. package/dist/4818.js.map +1 -0
  118. package/dist/500.js +1 -0
  119. package/dist/500.js.map +1 -0
  120. package/dist/5086.js +1 -1
  121. package/dist/5086.js.map +1 -1
  122. package/dist/5117.js +1 -0
  123. package/dist/5117.js.map +1 -0
  124. package/dist/5256.js +1 -0
  125. package/dist/5256.js.map +1 -0
  126. package/dist/5262.js +1 -0
  127. package/dist/5262.js.map +1 -0
  128. package/dist/5362.js +1 -0
  129. package/dist/5362.js.map +1 -0
  130. package/dist/5366.js +1 -0
  131. package/dist/5366.js.map +1 -0
  132. package/dist/5567.js +1 -0
  133. package/dist/5567.js.map +1 -0
  134. package/dist/5598.js +1 -0
  135. package/dist/5598.js.map +1 -0
  136. package/dist/5676.js +1 -1
  137. package/dist/5676.js.map +1 -1
  138. package/dist/5731.js +5 -0
  139. package/dist/5731.js.map +1 -0
  140. package/dist/5821.js +1 -0
  141. package/dist/5821.js.map +1 -0
  142. package/dist/5825.js +1 -0
  143. package/dist/5825.js.map +1 -0
  144. package/dist/5932.js +1 -0
  145. package/dist/5932.js.map +1 -0
  146. package/dist/5941.js +1 -0
  147. package/dist/5941.js.map +1 -0
  148. package/dist/6104.js +1 -1
  149. package/dist/6104.js.map +1 -1
  150. package/dist/6273.js +1 -0
  151. package/dist/6273.js.map +1 -0
  152. package/dist/6337.js +1 -0
  153. package/dist/6337.js.map +1 -0
  154. package/dist/6357.js +1 -0
  155. package/dist/6357.js.map +1 -0
  156. package/dist/6427.js +1 -1
  157. package/dist/6427.js.map +1 -1
  158. package/dist/6478.js +7 -0
  159. package/dist/6478.js.map +1 -0
  160. package/dist/6479.js +1 -1
  161. package/dist/6479.js.map +1 -1
  162. package/dist/6508.js +1 -0
  163. package/dist/6508.js.map +1 -0
  164. package/dist/6567.js +1 -0
  165. package/dist/6567.js.map +1 -0
  166. package/dist/6570.js +1 -0
  167. package/dist/6570.js.map +1 -0
  168. package/dist/6634.js +1 -0
  169. package/dist/6634.js.map +1 -0
  170. package/dist/6688.js +1 -0
  171. package/dist/6688.js.map +1 -0
  172. package/dist/6698.js +1 -0
  173. package/dist/6698.js.map +1 -0
  174. package/dist/682.js +1 -1
  175. package/dist/682.js.map +1 -1
  176. package/dist/689.js +1 -1
  177. package/dist/689.js.map +1 -1
  178. package/dist/7085.js +1 -0
  179. package/dist/7085.js.map +1 -0
  180. package/dist/740.js +1 -0
  181. package/dist/740.js.map +1 -0
  182. package/dist/7478.js +1 -1
  183. package/dist/7478.js.map +1 -1
  184. package/dist/7539.js +1 -0
  185. package/dist/7539.js.map +1 -0
  186. package/dist/7686.js +1 -0
  187. package/dist/7686.js.map +1 -0
  188. package/dist/7782.js +1 -0
  189. package/dist/7782.js.map +1 -0
  190. package/dist/7808.js +1 -0
  191. package/dist/7808.js.map +1 -0
  192. package/dist/781.js +1 -1
  193. package/dist/781.js.map +1 -1
  194. package/dist/8183.js +1 -0
  195. package/dist/8183.js.map +1 -0
  196. package/dist/8196.js +1 -1
  197. package/dist/8196.js.map +1 -1
  198. package/dist/820.js +1 -0
  199. package/dist/820.js.map +1 -0
  200. package/dist/8240.js +1 -1
  201. package/dist/8240.js.map +1 -1
  202. package/dist/8455.js +1 -0
  203. package/dist/8455.js.map +1 -0
  204. package/dist/8472.js +1 -0
  205. package/dist/8472.js.map +1 -0
  206. package/dist/8521.js +1 -0
  207. package/dist/8521.js.map +1 -0
  208. package/dist/8602.js +1 -0
  209. package/dist/8602.js.map +1 -0
  210. package/dist/8607.js +1 -0
  211. package/dist/8607.js.map +1 -0
  212. package/dist/8743.js +1 -0
  213. package/dist/8743.js.map +1 -0
  214. package/dist/8762.js +1 -0
  215. package/dist/8762.js.map +1 -0
  216. package/dist/8812.js +1 -0
  217. package/dist/8812.js.map +1 -0
  218. package/dist/8985.js +1 -0
  219. package/dist/8985.js.map +1 -0
  220. package/dist/9.js +1 -0
  221. package/dist/9.js.map +1 -0
  222. package/dist/901.js +1 -0
  223. package/dist/901.js.map +1 -0
  224. package/dist/9011.js +1 -1
  225. package/dist/9011.js.map +1 -1
  226. package/dist/9087.js +1 -0
  227. package/dist/9087.js.map +1 -0
  228. package/dist/9148.js +1 -0
  229. package/dist/9148.js.map +1 -0
  230. package/dist/9168.js +1 -0
  231. package/dist/9168.js.map +1 -0
  232. package/dist/935.js +1 -0
  233. package/dist/935.js.map +1 -0
  234. package/dist/9425.js +1 -1
  235. package/dist/9520.js +1 -1
  236. package/dist/9520.js.map +1 -1
  237. package/dist/9547.js +1 -0
  238. package/dist/9547.js.map +1 -0
  239. package/dist/9549.js +1 -0
  240. package/dist/9549.js.map +1 -0
  241. package/dist/9612.js +1 -0
  242. package/dist/9612.js.map +1 -0
  243. package/dist/9621.js +1 -0
  244. package/dist/9621.js.map +1 -0
  245. package/dist/9774.js +1 -0
  246. package/dist/9774.js.map +1 -0
  247. package/dist/9800.js +1 -0
  248. package/dist/9800.js.map +1 -0
  249. package/dist/9806.js +1 -0
  250. package/dist/9806.js.map +1 -0
  251. package/dist/9885.js +1 -0
  252. package/dist/9885.js.map +1 -0
  253. package/dist/992.js +1 -0
  254. package/dist/992.js.map +1 -0
  255. package/dist/kenyaemr-esm-shr-app.js +6 -5
  256. package/dist/kenyaemr-esm-shr-app.js.buildmanifest.json +1495 -598
  257. package/dist/kenyaemr-esm-shr-app.js.map +1 -1
  258. package/dist/main.js +6 -5
  259. package/dist/main.js.map +1 -1
  260. package/dist/routes.json +1 -1
  261. package/package.json +2 -2
  262. package/src/config-schema.ts +6 -6
  263. package/src/hooks/usePatient.ts +23 -9
  264. package/src/hooks/useSHRSummary.ts +1 -3
  265. package/src/index.ts +1 -4
  266. package/src/referrals/dependents/dependents.component.tsx +8 -1
  267. package/src/referrals/referral-reasons/referral-reasons.component.tsx +2 -2
  268. package/src/referrals/referral-tabs/referrals-tabs.component.tsx +9 -2
  269. package/src/referrals/referrals-actions.component.tsx +66 -7
  270. package/src/referrals/referrals.component.tsx +2 -2
  271. package/src/routes.json +92 -78
  272. package/src/shr-summary/shr-summary.component.tsx +12 -35
  273. package/src/shr-summary/shr-summary.resource.ts +74 -74
  274. package/src/shr-summary/tables/shr-summary-table.component.tsx +53 -23
  275. package/src/utils/function.tsx +9 -4
  276. package/src/workspace/referral-workspace.resource.ts +1 -2
  277. package/src/workspace/referral.workspace.scss +4 -2
  278. package/src/workspace/referrals.workspace.component.tsx +190 -183
  279. package/translations/am.json +4 -2
  280. package/translations/en.json +4 -2
  281. package/translations/fr.json +4 -2
  282. package/translations/sw.json +4 -2
  283. package/tsconfig.json +1 -1
  284. package/dist/1172.js +0 -1
  285. package/dist/1172.js.map +0 -1
  286. package/dist/132.js +0 -1
  287. package/dist/132.js.map +0 -1
  288. package/dist/1525.js +0 -1
  289. package/dist/1525.js.map +0 -1
  290. package/dist/1729.js +0 -17
  291. package/dist/1729.js.map +0 -1
  292. package/dist/1761.js +0 -1
  293. package/dist/1761.js.map +0 -1
  294. package/dist/1809.js +0 -7
  295. package/dist/1809.js.map +0 -1
  296. package/dist/1866.js +0 -1
  297. package/dist/1866.js.map +0 -1
  298. package/dist/1962.js +0 -1
  299. package/dist/1962.js.map +0 -1
  300. package/dist/2045.js +0 -1
  301. package/dist/2045.js.map +0 -1
  302. package/dist/2163.js +0 -1
  303. package/dist/2163.js.map +0 -1
  304. package/dist/2267.js +0 -1
  305. package/dist/2267.js.map +0 -1
  306. package/dist/235.js +0 -1
  307. package/dist/235.js.map +0 -1
  308. package/dist/2561.js.map +0 -1
  309. package/dist/2564.js +0 -1
  310. package/dist/2564.js.map +0 -1
  311. package/dist/2810.js +0 -2
  312. package/dist/2810.js.map +0 -1
  313. package/dist/2867.js +0 -1
  314. package/dist/2867.js.map +0 -1
  315. package/dist/3040.js +0 -1
  316. package/dist/3228.js +0 -1
  317. package/dist/3228.js.map +0 -1
  318. package/dist/329.js +0 -1
  319. package/dist/329.js.map +0 -1
  320. package/dist/3491.js +0 -1
  321. package/dist/3491.js.map +0 -1
  322. package/dist/3509.js +0 -1
  323. package/dist/3509.js.map +0 -1
  324. package/dist/3576.js +0 -1
  325. package/dist/3576.js.map +0 -1
  326. package/dist/4146.js +0 -1
  327. package/dist/4146.js.map +0 -1
  328. package/dist/4224.js +0 -1
  329. package/dist/4224.js.map +0 -1
  330. package/dist/4402.js +0 -1
  331. package/dist/4402.js.map +0 -1
  332. package/dist/4724.js +0 -1
  333. package/dist/4724.js.map +0 -1
  334. package/dist/4972.js +0 -1
  335. package/dist/4972.js.map +0 -1
  336. package/dist/509.js +0 -1
  337. package/dist/509.js.map +0 -1
  338. package/dist/5096.js +0 -1
  339. package/dist/5096.js.map +0 -1
  340. package/dist/5119.js +0 -1
  341. package/dist/5119.js.map +0 -1
  342. package/dist/5159.js +0 -13
  343. package/dist/5159.js.map +0 -1
  344. package/dist/5361.js +0 -1
  345. package/dist/5361.js.map +0 -1
  346. package/dist/5576.js +0 -1
  347. package/dist/5576.js.map +0 -1
  348. package/dist/5600.js +0 -1
  349. package/dist/5600.js.map +0 -1
  350. package/dist/5604.js +0 -1
  351. package/dist/5604.js.map +0 -1
  352. package/dist/5633.js +0 -1
  353. package/dist/5633.js.map +0 -1
  354. package/dist/5809.js +0 -1
  355. package/dist/5809.js.map +0 -1
  356. package/dist/5882.js +0 -1
  357. package/dist/5939.js +0 -5
  358. package/dist/5939.js.map +0 -1
  359. package/dist/6004.js +0 -1
  360. package/dist/6004.js.map +0 -1
  361. package/dist/6121.js +0 -3
  362. package/dist/6121.js.map +0 -1
  363. package/dist/6129.js +0 -1
  364. package/dist/6129.js.map +0 -1
  365. package/dist/6137.js +0 -1
  366. package/dist/6137.js.map +0 -1
  367. package/dist/6232.js +0 -1
  368. package/dist/6232.js.map +0 -1
  369. package/dist/6356.js +0 -1
  370. package/dist/6356.js.map +0 -1
  371. package/dist/6548.js +0 -1
  372. package/dist/6548.js.map +0 -1
  373. package/dist/6571.js +0 -1
  374. package/dist/6571.js.map +0 -1
  375. package/dist/6589.js +0 -1
  376. package/dist/6589.js.map +0 -1
  377. package/dist/6626.js +0 -1
  378. package/dist/6626.js.map +0 -1
  379. package/dist/6643.js +0 -1
  380. package/dist/6643.js.map +0 -1
  381. package/dist/6721.js +0 -1
  382. package/dist/6721.js.map +0 -1
  383. package/dist/6868.js +0 -1
  384. package/dist/6868.js.map +0 -1
  385. package/dist/7127.js +0 -1
  386. package/dist/7177.js +0 -1
  387. package/dist/7177.js.map +0 -1
  388. package/dist/7402.js +0 -1
  389. package/dist/7402.js.map +0 -1
  390. package/dist/7419.js +0 -1
  391. package/dist/7419.js.map +0 -1
  392. package/dist/7544.js +0 -1
  393. package/dist/7544.js.map +0 -1
  394. package/dist/7560.js +0 -1
  395. package/dist/7560.js.map +0 -1
  396. package/dist/8179.js +0 -6
  397. package/dist/8179.js.map +0 -1
  398. package/dist/8189.js +0 -1
  399. package/dist/8189.js.map +0 -1
  400. package/dist/8249.js +0 -1
  401. package/dist/8249.js.map +0 -1
  402. package/dist/8502.js +0 -1
  403. package/dist/8502.js.map +0 -1
  404. package/dist/8512.js +0 -1
  405. package/dist/8512.js.map +0 -1
  406. package/dist/8522.js +0 -1
  407. package/dist/8522.js.map +0 -1
  408. package/dist/8633.js +0 -1
  409. package/dist/8633.js.map +0 -1
  410. package/dist/8775.js +0 -11
  411. package/dist/8775.js.map +0 -1
  412. package/dist/8776.js +0 -1
  413. package/dist/8776.js.map +0 -1
  414. package/dist/8869.js +0 -1
  415. package/dist/8869.js.map +0 -1
  416. package/dist/887.js +0 -1
  417. package/dist/887.js.map +0 -1
  418. package/dist/8927.js +0 -1
  419. package/dist/8927.js.map +0 -1
  420. package/dist/916.js +0 -1
  421. package/dist/9355.js +0 -1
  422. package/dist/9355.js.map +0 -1
  423. package/dist/9675.js +0 -1
  424. package/dist/9675.js.map +0 -1
  425. package/dist/9931.js +0 -1
  426. package/dist/9931.js.map +0 -1
  427. package/jest.config.js +0 -3
  428. package/src/shr-summary/shr-authorization-form.workspace.tsx +0 -149
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenyaemr/esm-shr-app",
3
- "version": "5.4.4-pre.43",
3
+ "version": "5.4.4-pre.430",
4
4
  "description": "Patient care panels microfrontend for the OpenMRS SPA",
5
5
  "keywords": [
6
6
  "openmrs"
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "peerDependencies": {
41
41
  "@carbon/react": "1.x",
42
- "@openmrs/esm-framework": "8.x",
42
+ "@openmrs/esm-framework": "9.x",
43
43
  "react": "^18.1.0",
44
44
  "react-i18next": "11.x",
45
45
  "react-router-dom": "6.x"
@@ -6,6 +6,11 @@ export const configSchema = {
6
6
  _description: 'The national patient unique identifier',
7
7
  _default: 'f85081e2-b4be-4e48-b3a4-7994b69bb101',
8
8
  },
9
+ nationalIdIdentifierType: {
10
+ _type: Type.UUID,
11
+ _description: 'The national patient unique identifier',
12
+ _default: '49af6cdc-7968-4abb-bf46-de10d7f4859f',
13
+ },
9
14
  phoneNumberAttributeType: {
10
15
  _type: Type.UUID,
11
16
  _description: 'The patient phone number attribute type uuid',
@@ -16,16 +21,11 @@ export const configSchema = {
16
21
  _description: 'Social Health Authority Unique Identification Number',
17
22
  _default: '24aedd37-b5be-4e08-8311-3721b8d5100d',
18
23
  },
19
- artDirectoryUrl: {
20
- _type: Type.String,
21
- _description: 'URL for the ART Directory',
22
- _default: 'https://art.kenyahmis.org/api/patients',
23
- },
24
24
  };
25
25
 
26
26
  export type ReferralConfigObject = {
27
27
  nationalPatientUniqueIdentifier: string;
28
+ nationalIdIdentifierType: string;
28
29
  phoneNumberAttributeType: string;
29
30
  socialHealthAuthorityIdentifierType: string;
30
- artDirectoryUrl: string;
31
31
  };
@@ -1,6 +1,7 @@
1
1
  import { type FetchResponse, openmrsFetch, type Patient, restBaseUrl, useConfig } from '@openmrs/esm-framework';
2
2
  import useSWR from 'swr';
3
3
  import { ReferralConfigObject } from '../config-schema';
4
+ import { useMemo } from 'react';
4
5
 
5
6
  function extractValue(display: string) {
6
7
  const pattern = /=\s*(.*)$/;
@@ -15,20 +16,33 @@ const usePatient = (uuid: string) => {
15
16
  const customPresentation =
16
17
  'custom:(uuid,display,identifiers,person:(uuid,display,attributes:(uuid,display,attributeType:(uuid,display))))';
17
18
  const url = `${restBaseUrl}/patient/${uuid}?v=${customPresentation}`;
18
- const { phoneNumberAttributeType } = useConfig<ReferralConfigObject>();
19
+ const { phoneNumberAttributeType, nationalIdIdentifierType } = useConfig<ReferralConfigObject>();
19
20
  const { data, error, isLoading } = useSWR<FetchResponse<Patient>>(url, openmrsFetch);
21
+ const nationalId = useMemo(
22
+ () =>
23
+ data?.data?.identifiers
24
+ ?.find((id) => id.identifierType?.uuid === nationalIdIdentifierType)
25
+ ?.display?.split('=')?.[1]
26
+ ?.trim(),
27
+ [data, nationalIdIdentifierType],
28
+ );
29
+ const patientPhoneNumber = useMemo(() => {
30
+ const phone = data?.data?.person?.attributes?.find(
31
+ (attr) => attr.attributeType?.uuid === phoneNumberAttributeType,
32
+ )?.display;
33
+ if (phone) {
34
+ return extractValue(phone);
35
+ }
36
+ return undefined;
37
+ }, [data?.data?.person?.attributes, phoneNumberAttributeType]);
38
+
20
39
  return {
21
40
  isLoading,
22
41
  error,
23
42
  patient: data?.data,
24
- patientName: data?.data?.person.display,
25
- patientPhoneNumber: data?.data?.person?.attributes?.find(
26
- (attr) => attr.attributeType.uuid === phoneNumberAttributeType,
27
- )?.display
28
- ? extractValue(
29
- data?.data?.person?.attributes?.find((attr) => attr.attributeType.uuid === phoneNumberAttributeType)?.display,
30
- )
31
- : undefined,
43
+ patientName: data?.data?.person?.display,
44
+ patientPhoneNumber,
45
+ nationalId,
32
46
  };
33
47
  };
34
48
 
@@ -1,11 +1,9 @@
1
1
  import { openmrsFetch } from '@openmrs/esm-framework';
2
2
  import useSWR from 'swr';
3
3
  import { SHRSummary } from '../types/index';
4
- import { useState } from 'react';
5
- import { deepMerge } from '../utils/function';
6
4
 
7
5
  export const useSHRSummary = (patientUuid: string) => {
8
- const shrSummaryUrl = `/ws/rest/v1/kenyaemril/shrPatientSummary?patientUuid=${patientUuid}`;
6
+ const shrSummaryUrl = `/ws/rest/v1/kenyaemril/hie-patient-history?patientUuid=${patientUuid}`;
9
7
  const { data, mutate, error, isLoading } = useSWR<{ data: SHRSummary }>(shrSummaryUrl, openmrsFetch);
10
8
 
11
9
  return {
package/src/index.ts CHANGED
@@ -82,8 +82,5 @@ export const facilityRefferalForm = getAsyncLifecycle(
82
82
 
83
83
  // SHR Summary
84
84
  export const patientSHRSummary = getAsyncLifecycle(() => import('./shr-summary/shr-summary.component'), options);
85
- export const shrAuthorizationForm = getAsyncLifecycle(
86
- () => import('./shr-summary/shr-authorization-form.workspace'),
87
- options,
88
- );
85
+
89
86
  export const referralWrap = getAsyncLifecycle(() => import('./referrals-wrap'), options);
@@ -13,6 +13,8 @@ import {
13
13
  } from '@carbon/react';
14
14
  import { useTranslation } from 'react-i18next';
15
15
  import capitalize from 'lodash/capitalize';
16
+ import { FHIRResource } from '@openmrs/esm-framework';
17
+ import { EmptyState } from '@openmrs/esm-patient-common-lib';
16
18
 
17
19
  type DependentProps = {
18
20
  patientUuid: string;
@@ -76,7 +78,12 @@ const DependentsComponent: React.FC<DependentProps> = ({ patient, patientUuid })
76
78
  }
77
79
 
78
80
  if (dependents.length === 0) {
79
- return <div>{t('noDependentsFoundFromHIE', 'No dependents found from HIE')}</div>;
81
+ return (
82
+ <EmptyState
83
+ headerTitle={t('hieDependants', 'HIE Dependants')}
84
+ displayText={t('hieDependants', 'HIE Dependants')}
85
+ />
86
+ );
80
87
  }
81
88
 
82
89
  return (
@@ -21,10 +21,10 @@ const ReferralReasonsDialogPopup: React.FC<ReferralReasonsDialogPopupProps> = ({
21
21
  }) => {
22
22
  const { t } = useTranslation();
23
23
 
24
- const handleServeClient = async () => {
24
+ const handleServeClient = () => {
25
25
  try {
26
- await handleProcessReferral();
27
26
  closeModal();
27
+ handleProcessReferral();
28
28
  } catch (error) {
29
29
  showNotification({
30
30
  title: t('referralError', 'Error processing referral'),
@@ -3,7 +3,14 @@ import { mutate } from 'swr';
3
3
  import useSWRMutation from 'swr/mutation';
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { Tab, TabList, Tabs, Button, TabPanel, TabPanels, InlineLoading } from '@carbon/react';
6
- import { isDesktop, launchWorkspace, useLayoutType, showSnackbar, restBaseUrl } from '@openmrs/esm-framework';
6
+ import {
7
+ isDesktop,
8
+ launchWorkspace,
9
+ useLayoutType,
10
+ showSnackbar,
11
+ restBaseUrl,
12
+ launchWorkspace2,
13
+ } from '@openmrs/esm-framework';
7
14
  import { AirlineManageGates, UpdateNow } from '@carbon/react/icons';
8
15
 
9
16
  import ReferralTable from '../referrals.component';
@@ -46,7 +53,7 @@ const ReferralTabs: React.FC = () => {
46
53
  );
47
54
 
48
55
  const handleReferral = () => {
49
- launchWorkspace('facility-referral-form', {
56
+ launchWorkspace2('facility-referral-form', {
50
57
  workspaceTitle: t('referralForm', 'Referral Form'),
51
58
  });
52
59
  };
@@ -1,18 +1,26 @@
1
- import React, { useCallback } from 'react';
2
- import { Button } from '@carbon/react';
1
+ import React, { useCallback, useRef, useState } from 'react';
2
+ import { Button, InlineLoading } from '@carbon/react';
3
3
 
4
4
  import { useTranslation } from 'react-i18next';
5
5
  import { navigate, showModal, showSnackbar } from '@openmrs/esm-framework';
6
6
  import { ReferralReasonsProps } from '../types';
7
7
  import { processCommunityReferral } from './refferals.resource';
8
+ import usePatient from '../hooks/usePatient';
9
+ import { sendSHAOtp, verifyOtp } from '../shr-summary/shr-summary.resource';
8
10
 
9
11
  interface ReferralReasonData {
10
12
  referralData: ReferralReasonsProps;
11
13
  status: string;
14
+ patientUuid: string;
12
15
  }
13
16
 
14
- const CommunityReferralActions: React.FC<ReferralReasonData> = ({ status, referralData }) => {
17
+ const CommunityReferralActions: React.FC<ReferralReasonData> = ({ status, referralData, patientUuid }) => {
15
18
  const { t } = useTranslation();
19
+ const idRef = useRef<string>();
20
+ const [accessGranted, setAccessGranted] = useState(true);
21
+ const [isAuthorizing, setIsAuthorizing] = useState(false);
22
+
23
+ const { error, isLoading, patientPhoneNumber, patientName, nationalId } = usePatient(patientUuid);
16
24
 
17
25
  const handleProcessReferral = useCallback(() => {
18
26
  processCommunityReferral(referralData.messageId)
@@ -39,22 +47,73 @@ const CommunityReferralActions: React.FC<ReferralReasonData> = ({ status, referr
39
47
  });
40
48
  }, [referralData, t]);
41
49
 
50
+ const handleInitiateAuthorization = useCallback(() => {
51
+ const dispose = showModal('otp-verification-modal', {
52
+ onClose: () => {
53
+ if (!accessGranted) {
54
+ setIsAuthorizing(false);
55
+ }
56
+ dispose();
57
+ },
58
+ phoneNumber: patientPhoneNumber || '',
59
+ otpLength: 5,
60
+ expiryMinutes: 5,
61
+ centerBoxes: true,
62
+ onRequestOtp: async (_phone: string) => {
63
+ const { status, id } = await sendSHAOtp(_phone, nationalId as string);
64
+ idRef.current = id;
65
+ if (status !== 'success') {
66
+ throw new Error(t('otpFailed', 'Failed to send OTP'));
67
+ }
68
+ },
69
+
70
+ onVerify: async (enteredOtp: string) => {
71
+ const { status, data, error } = await verifyOtp(enteredOtp, idRef.current as string);
72
+ if (status !== 'success') {
73
+ throw new Error(t('authorizeFailed', 'Authorization failed'));
74
+ }
75
+ },
76
+
77
+ onVerificationSuccess: () => {
78
+ dispose();
79
+ setIsAuthorizing(false);
80
+ setAccessGranted(true);
81
+ handleProcessReferral();
82
+ showSnackbar({
83
+ title: t('success', 'Success'),
84
+ subtitle: t('otpVerificationSuccessMessage', 'OTP Vefification succesfull'),
85
+ kind: 'success',
86
+ });
87
+ },
88
+
89
+ onCleanup: () => {
90
+ if (!accessGranted) {
91
+ setIsAuthorizing(false);
92
+ }
93
+ },
94
+ });
95
+ }, [accessGranted, handleProcessReferral, nationalId, patientPhoneNumber, t]);
96
+
42
97
  const refearralReasonsHandleClick = useCallback(() => {
43
98
  const dispose = showModal('referral-reasons-dialog', {
44
99
  closeModal: () => dispose(),
45
100
  referralReasons: referralData,
46
101
  status: status,
47
- handleProcessReferral,
102
+ handleProcessReferral: handleInitiateAuthorization,
48
103
  });
49
- }, [referralData, handleProcessReferral, status]);
104
+ }, [referralData, handleInitiateAuthorization, status]);
105
+
106
+ if (isLoading || isAuthorizing) {
107
+ return <InlineLoading description={t('loading', 'Loading...')} />;
108
+ }
50
109
 
51
110
  return (
52
111
  <>
53
- <Button kind="primary" size="md" onClick={() => refearralReasonsHandleClick()}>
112
+ <Button kind="primary" size="md" onClick={refearralReasonsHandleClick}>
54
113
  {t('viewReasons', 'View reasons')}
55
114
  </Button>
56
115
  {status === 'completed' ? null : (
57
- <Button kind="primary" size="md" onClick={() => handleProcessReferral()}>
116
+ <Button kind="primary" size="md" onClick={handleInitiateAuthorization}>
58
117
  {t('serveClient', 'Serve client')}
59
118
  </Button>
60
119
  )}
@@ -23,7 +23,7 @@ import { useTranslation } from 'react-i18next';
23
23
  import { useCommunityReferrals } from './refferals.resource';
24
24
  import CommunityReferralActions from './referrals-actions.component';
25
25
  import { ReferralReasonsProps } from '../types';
26
- import { usePaginationInfo } from '@openmrs/esm-patient-common-lib/src';
26
+ import { usePaginationInfo } from '@openmrs/esm-patient-common-lib';
27
27
 
28
28
  type ReferralProps = {
29
29
  status: string;
@@ -124,7 +124,7 @@ const ReferralTable: React.FC<ReferralProps> = ({ status }) => {
124
124
  dateReferred: record.dateReferred,
125
125
  referredFrom: record.referredFrom,
126
126
  referralService: record.referralReasons?.category,
127
- actions: <CommunityReferralActions status={status} referralData={referralReasonsx} />,
127
+ actions: <CommunityReferralActions status={status} referralData={referralReasonsx} patientUuid={record.uuid} />,
128
128
  };
129
129
  rowData.push(s);
130
130
  });
package/src/routes.json CHANGED
@@ -1,80 +1,94 @@
1
1
  {
2
- "$schema": "https://json.openmrs.org/routes.schema.json",
3
- "backendDependencies": {
4
- "kenyaemr": "^19.0.0"
2
+ "$schema": "https://json.openmrs.org/routes.schema.json",
3
+ "backendDependencies": {
4
+ "kenyaemr": "^19.0.0"
5
+ },
6
+ "pages": [
7
+ {
8
+ "component": "shrHome",
9
+ "route": "referrals"
10
+ }
11
+ ],
12
+ "extensions": [
13
+ {
14
+ "name": "patient-chart-shr-summary-dashboard-link",
15
+ "component": "shrSummaryDashboardLink",
16
+ "meta": {
17
+ "columns": 1,
18
+ "columnSpan": 1,
19
+ "slot": "patient-chart-shr-summary-dashboard-slot",
20
+ "path": "SHR Portal"
21
+ },
22
+ "featureFlag": "healthInformationExchange"
5
23
  },
6
- "pages": [
7
- {
8
- "component": "shrHome",
9
- "route": "referrals"
10
- }
11
- ],
12
- "extensions": [
13
- {
14
- "component": "shrAuthorizationForm",
15
- "name": "shr-authorization-form"
16
- },
17
- {
18
- "name": "patient-chart-shr-summary-dashboard-link",
19
- "component": "shrSummaryDashboardLink",
20
- "meta": {
21
- "columns": 1,
22
- "columnSpan": 1,
23
- "slot": "patient-chart-shr-summary-dashboard-slot",
24
- "path": "SHR Portal"
25
- },
26
- "featureFlag": "healthInformationExchange"
27
- },
28
- {
29
- "name": "SHR Portal",
30
- "slot": "patient-chart-shr-summary-dashboard-slot",
31
- "component": "patientSHRSummary",
32
- "meta": {
33
- "columnSpan": 4
34
- }
35
- },
36
- {
37
- "name": "referrals",
38
- "slot": "referrals-slot",
39
- "component": "referralWrap"
40
- },
41
- {
42
- "name": "referrals-link",
43
- "slot": "homepage-dashboard-slot",
44
- "component": "ReferralsDashboardLink",
45
- "meta": {
46
- "name": "referrals",
47
- "title": "referrals",
48
- "slot": "referrals-slot"
49
- }
50
- },
51
- {
52
- "name": "referral-reasons-dialog",
53
- "component": "referralReasonsDialogPopup"
54
- },
55
- {
56
- "name": "facility-referral-form",
57
- "component": "facilityRefferalForm"
58
- },
59
- {
60
- "name": "referral-view-link",
61
- "component": "referralLink",
62
- "order": 13,
63
- "meta": {
64
- "columns": 1,
65
- "columnSpan": 1,
66
- "slot": "patient-chart-referral-slot",
67
- "path": "referral",
68
- "layoutMode": "anchored"
69
- }
70
- },
71
- {
72
- "name": "referral-view",
73
- "slot": "patient-chart-referral-slot",
74
- "component": "referralWidget",
75
- "order": 0,
76
- "online": true,
77
- "offline": false
78
- }
79
- ]
80
- }
24
+ {
25
+ "name": "SHR Portal",
26
+ "slot": "patient-chart-shr-summary-dashboard-slot",
27
+ "component": "patientSHRSummary",
28
+ "meta": {
29
+ "columnSpan": 4
30
+ }
31
+ },
32
+ {
33
+ "name": "referrals",
34
+ "slot": "referrals-slot",
35
+ "component": "referralWrap"
36
+ },
37
+ {
38
+ "name": "referrals-link",
39
+ "slot": "homepage-dashboard-slot",
40
+ "component": "ReferralsDashboardLink",
41
+ "meta": {
42
+ "name": "referrals",
43
+ "title": "referrals",
44
+ "slot": "referrals-slot"
45
+ }
46
+ },
47
+ {
48
+ "name": "referral-reasons-dialog",
49
+ "component": "referralReasonsDialogPopup"
50
+ },
51
+ {
52
+ "name": "referral-view-link",
53
+ "component": "referralLink",
54
+ "order": 13,
55
+ "meta": {
56
+ "columns": 1,
57
+ "columnSpan": 1,
58
+ "slot": "patient-chart-referral-slot",
59
+ "path": "referral",
60
+ "layoutMode": "anchored"
61
+ }
62
+ },
63
+ {
64
+ "name": "referral-view",
65
+ "slot": "patient-chart-referral-slot",
66
+ "component": "referralWidget",
67
+ "order": 0,
68
+ "online": true,
69
+ "offline": false
70
+ }
71
+ ],
72
+ "workspaces2": [
73
+ {
74
+ "name": "facility-referral-form",
75
+ "component": "facilityRefferalForm",
76
+ "window": "referral-workspace-window"
77
+ }
78
+ ],
79
+ "workspaceWindows2": [
80
+ {
81
+ "name": "referral-workspace-window",
82
+ "group": "referral-workspace-group",
83
+ "canMaximize": false,
84
+ "width": "wider"
85
+ }
86
+ ],
87
+ "workspaceGroups2": [
88
+ {
89
+ "name": "referral-workspace-group",
90
+ "persistence": "closeable",
91
+ "closeable": true
92
+ }
93
+ ]
94
+ }
@@ -1,23 +1,19 @@
1
- import { DataTableSkeleton, Layer, Tile, Tabs, TabList, Tab, TabPanel, TabPanels } from '@carbon/react';
2
- import {
3
- CardHeader,
4
- EmptyDataIllustration,
5
- ErrorState,
6
- getPatientUuidFromStore,
7
- } from '@openmrs/esm-patient-common-lib';
8
- import React from 'react';
1
+ import { DataTableSkeleton, Tab, TabList, TabPanel, TabPanels, Tabs } from '@carbon/react';
2
+ import { ErrorState } from '@openmrs/esm-patient-common-lib';
3
+ import React, { FC } from 'react';
9
4
  import { useTranslation } from 'react-i18next';
10
5
  import usePatientIdentifiers from '../hooks/usePatientIdentifiers';
11
- import styles from './tables/shr-tables.scss';
12
- import { useConfig } from '@openmrs/esm-framework';
13
- import { ReferralConfigObject } from '../config-schema';
14
- import PatientSHRSummaryTable from './tables/shr-summary-table.component';
15
6
  import DependentsComponent from '../referrals/dependents/dependents.component';
7
+ import PatientSHRSummaryTable from './tables/shr-summary-table.component';
16
8
 
17
- const SHRSummaryPanel = ({ patient, patientUuid }) => {
9
+ type SHRSummaryPanelProps = {
10
+ patientUuid: string;
11
+ patient: fhir.Patient;
12
+ };
13
+
14
+ const SHRSummaryPanel: FC<SHRSummaryPanelProps> = ({ patient, patientUuid }) => {
18
15
  const { t } = useTranslation();
19
- const { socialHealthAuthorityIdentifierType } = useConfig<ReferralConfigObject>();
20
- const { error, isLoading, hasType } = usePatientIdentifiers(patientUuid);
16
+ const { error, isLoading } = usePatientIdentifiers(patientUuid);
21
17
 
22
18
  if (isLoading) {
23
19
  return <DataTableSkeleton />;
@@ -27,25 +23,6 @@ const SHRSummaryPanel = ({ patient, patientUuid }) => {
27
23
  return <ErrorState error={error} headerTitle={t('shrSummary', 'SHR Summary')} />;
28
24
  }
29
25
 
30
- // if (!hasType(socialHealthAuthorityIdentifierType)) {
31
- // return (
32
- // <div>
33
- // <Layer>
34
- // <Tile className={styles.tile}>
35
- // <CardHeader title={t('shrRecords', 'SHR Records')}>{''}</CardHeader>
36
- // <EmptyDataIllustration />
37
- // <p className={styles.content}>
38
- // {t(
39
- // 'shrError',
40
- // 'Patient must have CR Number.Please register the patient with the client registry to retrieve their SHR Records',
41
- // )}
42
- // </p>
43
- // </Tile>
44
- // </Layer>
45
- // </div>
46
- // );
47
- // }
48
-
49
26
  return (
50
27
  <div>
51
28
  <Tabs>
@@ -58,7 +35,7 @@ const SHRSummaryPanel = ({ patient, patientUuid }) => {
58
35
  <DependentsComponent patientUuid={patientUuid} patient={patient} />
59
36
  </TabPanel>
60
37
  <TabPanel>
61
- <PatientSHRSummaryTable />
38
+ <PatientSHRSummaryTable patient={patient} patientUuid={patientUuid} />
62
39
  </TabPanel>
63
40
  </TabPanels>
64
41
  </Tabs>