|
@@ -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;
|