From 9506f366d136ccf320d3591cdffff979865e934d Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 5 Jul 2022 16:27:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=87=8D=E9=98=85=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Allocation/VisitTaskService.cs | 336 +++++++++++++++--- IRaCIS.Core.Domain/Reading/ReadModule.cs | 1 - .../Reading/ReadingClinicalDataPDF.cs | 1 - .../Reading/ReadingPeriodPlan.cs | 1 - .../Reading/ReadingQuestionCriterionSystem.cs | 1 - .../Reading/ReadingQuestionCriterionTrial.cs | 1 - .../Reading/ReadingQuestionSystem.cs | 1 - .../Reading/ReadingTaskQuestionAnswer.cs | 1 - .../Common/ReadingCommon.cs | 1 - 9 files changed, 293 insertions(+), 51 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index 415b14dd4..b40808814 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -35,7 +35,7 @@ namespace IRaCIS.Core.Application.Service private readonly IRepository _readingTaskQuestionAnswerRepository; - public VisitTaskService(IRepository visitTaskRepository, IRepository trialRepository, IRepository subjectVisitRepository, + public VisitTaskService(IRepository subjectVisitRepository, IRepository visitTaskRepository, IRepository trialRepository, IRepository subjectRepository, IRepository subjectUserRepository, IRepository taskAllocationRuleRepository, IRepository readModuleRepository, IRepository visitTaskReReadingRepository, IRepository readingTaskQuestionAnswerRepository ) @@ -647,6 +647,11 @@ namespace IRaCIS.Core.Application.Service .Select(t => new AutoAssignResultDTO() { DoctorUserId = t.DoctorUserId, PlanReadingRatio = t.PlanReadingRatio, SubjectCount = subjectCount }) .ToList(); + if (waitAllocationDoctorList.Count == 0) + { + throw new BusinessValidationFailedException("启用的医生数量为0"); + } + //已分配的 医生的情况 var haveAssignedSubjectDoctorList = subjectList.Clone().SelectMany(t => t.DoctorUserList.Select(c => new { t.SubjectId, DoctorUserId = c.DoctorUserId, c.ArmEnum })).ToList(); @@ -903,12 +908,21 @@ namespace IRaCIS.Core.Application.Service [UnitOfWork] public async Task ApplyReReading(ApplyReReadingCommand applyReReadingCommand) { + + throw new BusinessValidationFailedException("正在更新开发ing,不允许操作"); + var taskList = await _visitTaskRepository.Where(t => applyReReadingCommand.TaskIdList.Contains(t.Id), true).Include(t => t.JudgeVisitTask).ToListAsync(); foreach (var task in taskList) { + + if (task.ReadingTaskState != ReadingTaskState.HaveSigned) + { + throw new BusinessValidationFailedException("未阅片完成,不允许申请重阅"); + } + if (task.ReReadingApplyState == ReReadingApplyState.HaveApplyed || task.ReReadingApplyState == ReReadingApplyState.Agree) { throw new BusinessValidationFailedException("重阅已申请,或者重阅已同意状态下不允许申请重阅"); @@ -921,21 +935,21 @@ namespace IRaCIS.Core.Application.Service task.ReReadingApplyState = ReReadingApplyState.HaveApplyed; - //产生了裁判 - if (task.JudgeVisitTaskId != null) - { - if (task.ReadingTaskState == ReadingTaskState.WaitReading || task.ReadingTaskState == ReadingTaskState.Reading) - { - task.JudgeVisitTask.TaskState = TaskState.Adbandon; - } - else - { + ////产生了裁判 + //if (task.JudgeVisitTaskId != null) + //{ + // if (task.ReadingTaskState == ReadingTaskState.WaitReading || task.ReadingTaskState == ReadingTaskState.Reading) + // { + // task.JudgeVisitTask.TaskState = TaskState.Adbandon; + // } + // else + // { - task.JudgeVisitTask.TaskState = TaskState.HaveReturned; + // task.JudgeVisitTask.TaskState = TaskState.HaveReturned; - } - } + // } + //} var rootReReadingTaskId = _visitTaskReReadingRepository.Where(t => t.NewReReadingTaskId == task.Id).Select(u => u.RootReReadingTaskId).FirstOrDefault(); @@ -972,8 +986,13 @@ namespace IRaCIS.Core.Application.Service [UnitOfWork] public async Task ConfirmReReading(ConfirmReReadingCommand agreeReReadingCommand, [FromServices] IVisitTaskHelpeService _visitTaskCommonService) { + + throw new BusinessValidationFailedException("正在更新开发ing,不允许操作"); + var trialId = agreeReReadingCommand.TrialId; + var trialConfig = (await _trialRepository.Where(t => t.Id == trialId).Select(t => new { TrialId = t.Id, t.IsReadingTaskViewInOrder, t.ReadingType }).FirstOrDefaultAsync()).IfNullThrowException(); + foreach (var item in agreeReReadingCommand.ConfirmReReadingList) { var origenalTask = (await _visitTaskRepository.Where(t => item.OriginalReReadingTaskId == t.Id, true).FirstOrDefaultAsync()).IfNullThrowException(); @@ -991,52 +1010,238 @@ namespace IRaCIS.Core.Application.Service if (agreeReReadingCommand.RequestReReadingResultEnum == RequestReReadingResult.Agree) { - //产生的新任务 - - await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() + //裁判任务 同意重阅 + if (origenalTask.ReadingCategory == ReadingCategory.Judge) { - TrialId = trialId, - ReadingCategory = ReadingCategory.ReReading, - - ReReadingTask = origenalTask, - - //同步才可以 - Action = (newTask) => + //项目组 SPM同意 IR PM同意 + if ((visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM) || + (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.DocotorApply && _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + ) { - visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; - - - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer) + //产生的新任务 + await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() { + TrialId = trialId, - if (visitTaskReReadingAppply.IsCopyOrigenalForms) + ReadingCategory = ReadingCategory.ReReading, + + ReReadingTask = origenalTask, + + //同步才可以 + Action = (newTask) => { - var origenalAnswerList = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + //申请表 设置新任务Id + visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; - origenalAnswerList.ForEach(t => { t.VisitTaskId = newTask.Id; t.Id = Guid.Empty; }); + //生成的任务分配给原始医生 + newTask.DoctorUserId = origenalTask.DoctorUserId; + newTask.TaskAllocationState = TaskAllocationState.Allocated; + newTask.AllocateTime = DateTime.Now; - _readingTaskQuestionAnswerRepository.AddRangeAsync(origenalAnswerList).Wait(); } - } - - //PM 立即分配 - if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) - { - newTask.DoctorUserId = origenalTask.DoctorUserId; - newTask.TaskAllocationState = TaskAllocationState.Allocated; - newTask.AllocateTime = DateTime.Now; - } - + }); } - }); + + + } + //访视任务 同意重阅 + else + { + + if (visitTaskReReadingAppply.RequestReReadingType == RequestReReadingType.TrialGroupApply) + { + + //SPM同意 + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM) + { + //有序阅片 + if (trialConfig.IsReadingTaskViewInOrder) + { + + } + //无序阅片 + else + { + //阅片任务产生了裁判 + if (origenalTask.JudgeVisitTaskId != null) + { + + //裁判任务是否已阅片完成 + var judgeTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == origenalTask.JudgeVisitTaskId); + + if (judgeTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + judgeTask.TaskState = TaskState.HaveReturned; + } + //裁判任务未完 + else + { + judgeTask.TaskState = TaskState.Adbandon; + } + + } + + //不管是否触发裁判 阅片任务退回,待影像重传后重新分 配给原阅片人 + + if (trialConfig.ReadingType == ReadingMethod.Double) + { + //考虑该访视 另外一个阅片人的任务也同时退回 + + var otherTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.SourceSubjectVisitId == origenalTask.SourceSubjectVisitId && t.Id != origenalTask.Id && t.TaskState == TaskState.Effect); + + if (otherTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + otherTask.TaskState = TaskState.HaveReturned; + } + else + { + otherTask.TaskState = TaskState.Adbandon; + } + + } + + //回退访视 + + if (origenalTask.ReadingCategory == ReadingCategory.Visit) + { + //执行类似一致性核查回退流程 + await VisitBackAsync(origenalTask.SourceSubjectVisitId); + } + // 无序阅片没有 全局 肿瘤学 + + + } + } + } + //IR申请 + else + { + + //PM 同意 + if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + { + //有序阅片 + if (trialConfig.IsReadingTaskViewInOrder) + { + + } + //无序阅片 + else + { + //阅片任务产生了裁判 + if (origenalTask.JudgeVisitTaskId != null) + { + + //裁判任务是否已阅片完成 + var judgeTask = await _visitTaskRepository.FirstOrDefaultAsync(t => t.Id == origenalTask.JudgeVisitTaskId); + + if (judgeTask.ReadingTaskState == ReadingTaskState.HaveSigned) + { + judgeTask.TaskState = TaskState.HaveReturned; + } + //裁判任务未完 + else + { + judgeTask.TaskState = TaskState.Adbandon; + } + + } + + //产生的新任务 + await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() + { + TrialId = trialId, + + ReadingCategory = ReadingCategory.ReReading, + + ReReadingTask = origenalTask, + + //同步才可以 + Action = (newTask) => + { + //申请表 设置新任务Id + visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; + + //生成的任务分配给原始医生 + newTask.DoctorUserId = origenalTask.DoctorUserId; + newTask.TaskAllocationState = TaskAllocationState.Allocated; + newTask.AllocateTime = DateTime.Now; + + } + }); + } + } + } + + } } + + + ////产生的新任务 + + //await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() + //{ + // TrialId = trialId, + + // ReadingCategory = ReadingCategory.ReReading, + + // ReReadingTask = origenalTask, + + // //同步才可以 + // Action = (newTask) => + // { + + // visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; + + + // if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IndependentReviewer) + // { + + // if (visitTaskReReadingAppply.IsCopyOrigenalForms) + // { + // var origenalAnswerList = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + + // origenalAnswerList.ForEach(t => { t.VisitTaskId = newTask.Id; t.Id = Guid.Empty; }); + + // _readingTaskQuestionAnswerRepository.AddRangeAsync(origenalAnswerList).Wait(); + // } + // } + + // //IR申请 PM同意 立即分配 + // if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) + // { + // //有序阅片 + // if (trialConfig.IsReadingTaskViewInOrder) + // { + + // } + // else + // { + // //无序阅片 + + // newTask.DoctorUserId = origenalTask.DoctorUserId; + // newTask.TaskAllocationState = TaskAllocationState.Allocated; + // newTask.AllocateTime = DateTime.Now; + // } + + + // } + + // } + + + + //}); + //} + + } @@ -1053,6 +1258,51 @@ namespace IRaCIS.Core.Application.Service + + private async Task VisitBackAsync(Guid? subjectVisitId) + { + var sv = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == subjectVisitId)).IfNullThrowException(); + + + //需要重新产生任务 + sv.IsVisitTaskGenerated = false; + + sv.AuditState = AuditStateEnum.None; + sv.SubmitState = SubmitStateEnum.ToSubmit; + sv.ReadingStatus = ReadingStatusEnum.ImageNotSubmit; + + //回退后,回退状态恢复 + sv.RequestBackState = RequestBackStateEnum.NotRequest; + sv.IsCheckBack = true; + sv.CheckState = CheckStateEnum.None; + sv.CheckChallengeState = CheckChanllengeTypeEnum.None; + + sv.SVENDTC = null; + sv.SVSTDTC = null; + + sv.PreliminaryAuditTime = null; + sv.SubmitTime = null; + sv.ReviewAuditTime = null; + sv.CurrentActionUserExpireTime = null; + + + sv.IsTake = false; + sv.CurrentActionUserId = null; + sv.PreliminaryAuditUserId = null; + sv.ReviewAuditUserId = null; + + + //await _repository.AddAsync(new CheckChallengeDialog() { SubjectVisitId = subjectVisitId, TalkContent = "PM/APM同意一致性核查回退。", UserTypeEnum = (UserTypeEnum)_userInfo.UserTypeEnumInt }); + + await _repository.BatchDeleteAsync(t => t.SubjectVisitId == subjectVisitId); + await _repository.BatchDeleteAsync(t => t.DicomSerie.IsDeleted); + await _repository.BatchDeleteAsync(t => t.IsDeleted); + + var success = await _subjectVisitRepository.SaveChangesAsync(); + + } + + /// /// 重阅影响提示列表 /// @@ -1064,7 +1314,7 @@ namespace IRaCIS.Core.Application.Service var filterObj = await _visitTaskRepository.FirstOrDefaultNoTrackingAsync(t => t.Id == taskId); var list = await _visitTaskRepository.Where(t => t.TrialId == filterObj.TrialId && t.SubjectId == filterObj.SubjectId && t.VisitTaskNum >= filterObj.VisitTaskNum) - .Where(t => t.TaskState == TaskState.Effect && ! t.IsAnalysisCreate) + .Where(t => t.TaskState == TaskState.Effect && !t.IsAnalysisCreate) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); return list; diff --git a/IRaCIS.Core.Domain/Reading/ReadModule.cs b/IRaCIS.Core.Domain/Reading/ReadModule.cs index 8f79e012a..7d5466c64 100644 --- a/IRaCIS.Core.Domain/Reading/ReadModule.cs +++ b/IRaCIS.Core.Domain/Reading/ReadModule.cs @@ -4,7 +4,6 @@ using System; using IRaCIS.Core.Domain.Share; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.Domain.Models { diff --git a/IRaCIS.Core.Domain/Reading/ReadingClinicalDataPDF.cs b/IRaCIS.Core.Domain/Reading/ReadingClinicalDataPDF.cs index aa5e31a44..39a91c072 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingClinicalDataPDF.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingClinicalDataPDF.cs @@ -4,7 +4,6 @@ using System; using IRaCIS.Core.Domain.Share; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.Domain.Models { diff --git a/IRaCIS.Core.Domain/Reading/ReadingPeriodPlan.cs b/IRaCIS.Core.Domain/Reading/ReadingPeriodPlan.cs index d5776ee4e..ec443e4a8 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingPeriodPlan.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingPeriodPlan.cs @@ -4,7 +4,6 @@ using System; using IRaCIS.Core.Domain.Share; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using IRaCIS.Core.Domain.Share; namespace IRaCIS.Core.Domain.Models { diff --git a/IRaCIS.Core.Domain/Reading/ReadingQuestionCriterionSystem.cs b/IRaCIS.Core.Domain/Reading/ReadingQuestionCriterionSystem.cs index 2cdf09e3a..ff48094de 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingQuestionCriterionSystem.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingQuestionCriterionSystem.cs @@ -4,7 +4,6 @@ using System; using IRaCIS.Core.Domain.Share; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using IRaCIS.Core.Domain.Share; using System.Collections.Generic; namespace IRaCIS.Core.Domain.Models diff --git a/IRaCIS.Core.Domain/Reading/ReadingQuestionCriterionTrial.cs b/IRaCIS.Core.Domain/Reading/ReadingQuestionCriterionTrial.cs index f9bfe580d..dee1857cc 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingQuestionCriterionTrial.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingQuestionCriterionTrial.cs @@ -4,7 +4,6 @@ using System; using IRaCIS.Core.Domain.Share; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using IRaCIS.Core.Domain.Share; using System.Collections.Generic; namespace IRaCIS.Core.Domain.Models diff --git a/IRaCIS.Core.Domain/Reading/ReadingQuestionSystem.cs b/IRaCIS.Core.Domain/Reading/ReadingQuestionSystem.cs index a103af67f..63e12257f 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingQuestionSystem.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingQuestionSystem.cs @@ -4,7 +4,6 @@ using System; using IRaCIS.Core.Domain.Share; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using IRaCIS.Core.Domain.Share; using System.Collections.Generic; namespace IRaCIS.Core.Domain.Models diff --git a/IRaCIS.Core.Domain/Reading/ReadingTaskQuestionAnswer.cs b/IRaCIS.Core.Domain/Reading/ReadingTaskQuestionAnswer.cs index e2e16a0ce..5a3437eb8 100644 --- a/IRaCIS.Core.Domain/Reading/ReadingTaskQuestionAnswer.cs +++ b/IRaCIS.Core.Domain/Reading/ReadingTaskQuestionAnswer.cs @@ -4,7 +4,6 @@ using System; using IRaCIS.Core.Domain.Share; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; -using IRaCIS.Core.Domain.Share; using System.Collections.Generic; namespace IRaCIS.Core.Domain.Models diff --git a/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs b/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs index 7a4be464e..f3daeaa32 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs @@ -1,6 +1,5 @@ using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; -using IRaCIS.Core.Domain.Share; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic;