WorklistTable.tsx 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. import React from 'react';
  2. import { useSelector, useDispatch } from 'react-redux';
  3. import { useEffect } from 'react';
  4. import {
  5. fetchWorkThunk,
  6. workSelectionSlice,
  7. } from '../../../states/patient/worklist/slices/workSlice';
  8. import { Table } from 'antd';
  9. import { FormattedMessage } from 'react-intl';
  10. import { RootState, AppDispatch } from '../../../states/store';
  11. import { Task } from '@/domain/work';
  12. const columns = [
  13. {
  14. title: (
  15. <FormattedMessage
  16. id="worklistTable.StudyInstanceUID"
  17. defaultMessage="worklistTable.StudyInstanceUID"
  18. />
  19. ),
  20. dataIndex: 'StudyInstanceUID',
  21. },
  22. {
  23. title: (
  24. <FormattedMessage
  25. id="worklistTable.StudyID"
  26. defaultMessage="worklistTable.StudyID"
  27. />
  28. ),
  29. dataIndex: 'StudyID',
  30. },
  31. {
  32. title: (
  33. <FormattedMessage
  34. id="worklistTable.SpecificCharacterSet"
  35. defaultMessage="worklistTable.SpecificCharacterSet"
  36. />
  37. ),
  38. dataIndex: 'SpecificCharacterSet',
  39. },
  40. {
  41. title: (
  42. <FormattedMessage
  43. id="worklistTable.AccessionNumber"
  44. defaultMessage="worklistTable.AccessionNumber"
  45. />
  46. ),
  47. dataIndex: 'AccessionNumber',
  48. },
  49. {
  50. title: (
  51. <FormattedMessage
  52. id="worklistTable.PatientID"
  53. defaultMessage="worklistTable.PatientID"
  54. />
  55. ),
  56. dataIndex: 'PatientID',
  57. },
  58. {
  59. title: (
  60. <FormattedMessage
  61. id="worklistTable.PatientName"
  62. defaultMessage="worklistTable.PatientName"
  63. />
  64. ),
  65. dataIndex: 'PatientName',
  66. },
  67. {
  68. title: (
  69. <FormattedMessage
  70. id="worklistTable.DisplayPatientName"
  71. defaultMessage="worklistTable.DisplayPatientName"
  72. />
  73. ),
  74. dataIndex: 'DisplayPatientName',
  75. },
  76. {
  77. title: (
  78. <FormattedMessage
  79. id="worklistTable.PatientSize"
  80. defaultMessage="worklistTable.PatientSize"
  81. />
  82. ),
  83. dataIndex: 'PatientSize',
  84. },
  85. {
  86. title: (
  87. <FormattedMessage
  88. id="worklistTable.PatientAge"
  89. defaultMessage="worklistTable.PatientAge"
  90. />
  91. ),
  92. dataIndex: 'PatientAge',
  93. },
  94. {
  95. title: (
  96. <FormattedMessage
  97. id="worklistTable.PatientSex"
  98. defaultMessage="worklistTable.PatientSex"
  99. />
  100. ),
  101. dataIndex: 'PatientSex',
  102. },
  103. {
  104. title: (
  105. <FormattedMessage
  106. id="worklistTable.AdmittingTime"
  107. defaultMessage="worklistTable.AdmittingTime"
  108. />
  109. ),
  110. dataIndex: 'AdmittingTime',
  111. },
  112. {
  113. title: (
  114. <FormattedMessage
  115. id="worklistTable.RegSource"
  116. defaultMessage="worklistTable.RegSource"
  117. />
  118. ),
  119. dataIndex: 'RegSource',
  120. },
  121. {
  122. title: (
  123. <FormattedMessage
  124. id="worklistTable.StudyStatus"
  125. defaultMessage="worklistTable.StudyStatus"
  126. />
  127. ),
  128. dataIndex: 'StudyStatus',
  129. },
  130. {
  131. title: (
  132. <FormattedMessage
  133. id="worklistTable.RequestedProcedureID"
  134. defaultMessage="worklistTable.RequestedProcedureID"
  135. />
  136. ),
  137. dataIndex: 'RequestedProcedureID',
  138. },
  139. {
  140. title: (
  141. <FormattedMessage
  142. id="worklistTable.PerformedProtocolCodeValue"
  143. defaultMessage="worklistTable.PerformedProtocolCodeValue"
  144. />
  145. ),
  146. dataIndex: 'PerformedProtocolCodeValue',
  147. },
  148. {
  149. title: (
  150. <FormattedMessage
  151. id="worklistTable.PerformedProtocolCodeMeaning"
  152. defaultMessage="worklistTable.PerformedProtocolCodeMeaning"
  153. />
  154. ),
  155. dataIndex: 'PerformedProtocolCodeMeaning',
  156. },
  157. {
  158. title: (
  159. <FormattedMessage
  160. id="worklistTable.PerformedProcedureStepID"
  161. defaultMessage="worklistTable.PerformedProcedureStepID"
  162. />
  163. ),
  164. dataIndex: 'PerformedProcedureStepID',
  165. },
  166. {
  167. title: (
  168. <FormattedMessage
  169. id="worklistTable.StudyDescription"
  170. defaultMessage="worklistTable.StudyDescription"
  171. />
  172. ),
  173. dataIndex: 'StudyDescription',
  174. },
  175. {
  176. title: (
  177. <FormattedMessage
  178. id="worklistTable.StudyStartDatetime"
  179. defaultMessage="worklistTable.StudyStartDatetime"
  180. />
  181. ),
  182. dataIndex: 'StudyStartDatetime',
  183. },
  184. {
  185. title: (
  186. <FormattedMessage
  187. id="worklistTable.ScheduledProcedureStepStartDate"
  188. defaultMessage="worklistTable.ScheduledProcedureStepStartDate"
  189. />
  190. ),
  191. dataIndex: 'ScheduledProcedureStepStartDate',
  192. },
  193. {
  194. title: (
  195. <FormattedMessage
  196. id="worklistTable.StudyLock"
  197. defaultMessage="worklistTable.StudyLock"
  198. />
  199. ),
  200. dataIndex: 'StudyLock',
  201. },
  202. {
  203. title: (
  204. <FormattedMessage
  205. id="worklistTable.OperatorID"
  206. defaultMessage="worklistTable.OperatorID"
  207. />
  208. ),
  209. dataIndex: 'OperatorID',
  210. },
  211. {
  212. title: (
  213. <FormattedMessage
  214. id="worklistTable.Modality"
  215. defaultMessage="worklistTable.Modality"
  216. />
  217. ),
  218. dataIndex: 'Modality',
  219. },
  220. {
  221. title: (
  222. <FormattedMessage
  223. id="worklistTable.Views"
  224. defaultMessage="worklistTable.Views"
  225. />
  226. ),
  227. dataIndex: 'Views',
  228. },
  229. {
  230. title: (
  231. <FormattedMessage
  232. id="worklistTable.Thickness"
  233. defaultMessage="worklistTable.Thickness"
  234. />
  235. ),
  236. dataIndex: 'Thickness',
  237. },
  238. {
  239. title: (
  240. <FormattedMessage
  241. id="worklistTable.PatientType"
  242. defaultMessage="worklistTable.PatientType"
  243. />
  244. ),
  245. dataIndex: 'PatientType',
  246. },
  247. {
  248. title: (
  249. <FormattedMessage
  250. id="worklistTable.StudyType"
  251. defaultMessage="worklistTable.StudyType"
  252. />
  253. ),
  254. dataIndex: 'StudyType',
  255. },
  256. {
  257. title: (
  258. <FormattedMessage
  259. id="worklistTable.QRCode"
  260. defaultMessage="worklistTable.QRCode"
  261. />
  262. ),
  263. dataIndex: 'QRCode',
  264. },
  265. {
  266. title: (
  267. <FormattedMessage
  268. id="worklistTable.IsExported"
  269. defaultMessage="worklistTable.IsExported"
  270. />
  271. ),
  272. dataIndex: 'IsExported',
  273. },
  274. {
  275. title: (
  276. <FormattedMessage
  277. id="worklistTable.IsEdited"
  278. defaultMessage="worklistTable.IsEdited"
  279. />
  280. ),
  281. dataIndex: 'IsEdited',
  282. },
  283. {
  284. title: (
  285. <FormattedMessage
  286. id="worklistTable.WorkRef"
  287. defaultMessage="worklistTable.WorkRef"
  288. />
  289. ),
  290. dataIndex: 'WorkRef',
  291. },
  292. {
  293. title: (
  294. <FormattedMessage
  295. id="worklistTable.IsAppended"
  296. defaultMessage="worklistTable.IsAppended"
  297. />
  298. ),
  299. dataIndex: 'IsAppended',
  300. },
  301. {
  302. title: (
  303. <FormattedMessage
  304. id="worklistTable.CreationTime"
  305. defaultMessage="worklistTable.CreationTime"
  306. />
  307. ),
  308. dataIndex: 'CreationTime',
  309. },
  310. {
  311. title: (
  312. <FormattedMessage
  313. id="worklistTable.MappedStatus"
  314. defaultMessage="worklistTable.MappedStatus"
  315. />
  316. ),
  317. dataIndex: 'MappedStatus',
  318. },
  319. {
  320. title: (
  321. <FormattedMessage
  322. id="worklistTable.IsDelete"
  323. defaultMessage="worklistTable.IsDelete"
  324. />
  325. ),
  326. dataIndex: 'IsDelete',
  327. },
  328. ];
  329. const WorklistTable: React.FC = () => {
  330. const dispatch: AppDispatch = useDispatch();
  331. const worklistData = useSelector(
  332. (state: RootState) => state.workEntities.data
  333. );
  334. const filters = useSelector((state: RootState) => state.search);
  335. const page = useSelector((state: RootState) => state.workPagination.page);
  336. const pageSize = useSelector(
  337. (state: RootState) => state.workPagination.pageSize
  338. );
  339. const selectedIds = useSelector(
  340. (state: RootState) => state.workSelection.selectedIds
  341. );
  342. useEffect(() => {
  343. dispatch(fetchWorkThunk({ page, pageSize, filters }));
  344. }, [dispatch, filters, page, pageSize]);
  345. const handleRowClick = (record: Task) => {
  346. console.log('Row clicked:', JSON.stringify(record, null, 2));
  347. console.log('Selected IDs before:', record.StudyInstanceUID);
  348. dispatch(
  349. workSelectionSlice.actions.setSelectedIds([record.StudyInstanceUID])
  350. );
  351. };
  352. return (
  353. <Table
  354. columns={columns}
  355. dataSource={worklistData}
  356. rowKey="StudyInstanceUID"
  357. onRow={(record) => ({
  358. onClick: () => handleRowClick(record),
  359. })}
  360. rowHoverable={false}
  361. rowClassName={(record) =>
  362. selectedIds.includes(record.StudyInstanceUID)
  363. ? 'bg-yellow-500 hover:bg-yellow-800'
  364. : ''
  365. }
  366. />
  367. );
  368. };
  369. export default WorklistTable;