|
@@ -6,6 +6,10 @@ import { XImage } from '@/domain/xImage';
|
|
|
import store from '@/states/store';
|
|
|
import { Task } from '@/domain/work';
|
|
|
import { dview } from '../dview';
|
|
|
+import {
|
|
|
+ transformWorksToBodyPositions,
|
|
|
+ setBodyPositions,
|
|
|
+} from '../../states/exam/bodyPositionListSlice';
|
|
|
|
|
|
const worklistToExam = async (task: Task) => {
|
|
|
const dispatch = store.dispatch;
|
|
@@ -53,4 +57,68 @@ const worklistToExam = async (task: Task) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+// 批量处理多个选中工单进入图像处理
|
|
|
+const worklistToProcess = async (selectedIds: string[]) => {
|
|
|
+ const dispatch = store.dispatch;
|
|
|
+
|
|
|
+ try {
|
|
|
+ // Clear existing works in the cache
|
|
|
+ dispatch(clearWorks());
|
|
|
+
|
|
|
+ // 批量处理选中的工单
|
|
|
+ for (const studyId of selectedIds) {
|
|
|
+ // 获取基础Task信息
|
|
|
+ const state = store.getState();
|
|
|
+ const baseTask = state.workEntities.data.find(
|
|
|
+ (task) => task.StudyID === studyId
|
|
|
+ );
|
|
|
+
|
|
|
+ if (!baseTask) {
|
|
|
+ console.warn(`Task with StudyID ${studyId} not found in workEntities`);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Fetch task details from the backend
|
|
|
+ const taskDetails = await fetchTaskDetails(studyId);
|
|
|
+
|
|
|
+ // Map the fetched task details to the Task type (复用现有映射逻辑)
|
|
|
+ const updatedTask: Task = {
|
|
|
+ ...baseTask,
|
|
|
+ Views: taskDetails.series.flatMap<dview>((series: Series) =>
|
|
|
+ series.images.map<dview>(
|
|
|
+ (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: '',
|
|
|
+ PrimarySopUID: image.sop_instance_uid,
|
|
|
+ expose_status: image.expose_status,
|
|
|
+ image_file_path: image.image_file_path,
|
|
|
+ image_file: image.image_file_path,
|
|
|
+ thumbnail_file: image.thumbnail_file || '',
|
|
|
+ }) satisfies dview
|
|
|
+ )
|
|
|
+ ),
|
|
|
+ };
|
|
|
+
|
|
|
+ // Save the updated task to the cache
|
|
|
+ dispatch(addWork(updatedTask));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 转换为体位列表
|
|
|
+ const works = store.getState().examWorksCache.works;
|
|
|
+ transformWorksToBodyPositions(works).then((bodyPositions) => {
|
|
|
+ store.dispatch(setBodyPositions(bodyPositions));
|
|
|
+ });
|
|
|
+ } catch (error) {
|
|
|
+ console.error('Error in worklistToProcess:', error);
|
|
|
+ throw error;
|
|
|
+ }
|
|
|
+};
|
|
|
+
|
|
|
export default worklistToExam;
|
|
|
+export { worklistToProcess };
|