Browse Source

实现从任务清单双击检查项进入检查

dengdx 1 week ago
parent
commit
af16992ee1

+ 14 - 0
src/API/patient/workActions.ts

@@ -179,3 +179,17 @@ const fetchTaskList = async (
 };
 
 export { registerWork, fetchTaskList };
+
+const fetchTaskDetails = async (
+  studyId: string
+): Promise<RegisterWorkResponseData> => {
+  try {
+    const response = await axiosInstance.get(`/auth/study/${studyId}`);
+    return response.data.data;
+  } catch (error) {
+    console.error('Error fetching task details:', error);
+    throw error;
+  }
+};
+
+export { fetchTaskDetails };

+ 46 - 0
src/domain/patient/worklistToExam.ts

@@ -0,0 +1,46 @@
+import { addWork, clearWorks } from '../../states/exam/examWorksCacheSlice';
+import { setBusinessFlow } from '../../states/BusinessFlowSlice';
+import { fetchTaskDetails } from '../../API/patient/workActions';
+import { Series } from '@/domain/series';
+import { XImage } from '@/domain/xImage';
+import store from '@/states/store';
+import { Task } from '@/domain/work';
+
+const worklistToExam = async (task: Task) => {
+  const dispatch = store.dispatch;
+
+  try {
+    // Fetch task details from the backend todo 在worklistTable中实现,触发fetchThunk,可以显示 loading
+    const taskDetails = await fetchTaskDetails(task.StudyID);
+
+    // Map the fetched task details to the Task type
+    const updatedTask: Task = {
+      ...task,
+      Views: taskDetails.series.flatMap((series: Series) =>
+        series.images.map((image: XImage) => ({
+          view_id: image.view_id,
+          series_instance_uid: series.series_instance_uid,
+          study_instance_uid: taskDetails.study_instance_uid,
+          study_id: taskDetails.study_id,
+          procedure_id: series.procedure_id,
+          view_description: image.view_description,
+          view_type: '',
+        }))
+      ),
+    };
+
+    // Clear existing works in the cache
+    dispatch(clearWorks());
+
+    // Save the updated task to the cache
+    dispatch(addWork(updatedTask));
+
+    // Proceed to Examination
+    dispatch(setBusinessFlow('exam'));
+  } catch (error) {
+    console.error('Error in worklistToExam:', error);
+    throw error;
+  }
+};
+
+export default worklistToExam;

+ 7 - 0
src/pages/patient/components/WorklistTable.tsx

@@ -9,6 +9,7 @@ import { Table } from 'antd';
 import { FormattedMessage } from 'react-intl';
 import { RootState, AppDispatch } from '../../../states/store';
 import { Task } from '@/domain/work';
+import worklistToExam from '../../../domain/patient/worklistToExam';
 
 const columns = [
   {
@@ -354,6 +355,11 @@ const WorklistTable: React.FC = () => {
     );
   };
 
+  const handleRowDoubleClick = (record: Task) => {
+    console.log('Row double-clicked:', JSON.stringify(record, null, 2));
+    worklistToExam(record);
+  };
+
   return (
     <Table
       columns={columns}
@@ -361,6 +367,7 @@ const WorklistTable: React.FC = () => {
       rowKey="StudyInstanceUID"
       onRow={(record) => ({
         onClick: () => handleRowClick(record),
+        onDoubleClick: () => handleRowDoubleClick(record),
       })}
       rowHoverable={false}
       rowClassName={(record) =>

+ 1 - 1
src/states/exam/examWorksCacheSlice.ts

@@ -1,5 +1,5 @@
 import { createSlice, PayloadAction } from '@reduxjs/toolkit';
-import { Task as Work } from '../../API/patient/workActions';
+import { Task as Work } from '@/domain/work';
 
 interface ExamWorksCacheState {
   works: Work[];