diff --git a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs index 87d4a0637..eb0a20540 100644 --- a/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs +++ b/IRaCIS.Core.Application/Service/Allocation/DTO/VisitTaskViewModel.cs @@ -184,7 +184,7 @@ namespace IRaCIS.Core.Application.ViewModel public Guid? SourceSubjectVisitId { get; set; } public Guid? SouceReadModuleId { get; set; } - + //public bool IsAfterConvertedTask { get; set; } } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index bb77a3871..356d0c5b3 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -146,11 +146,12 @@ namespace IRaCIS.Core.Application.Service var taskAnswer = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == taskId && x.ReadingQuestionTrial.Type != "calculation").IgnoreAutoIncludes().AsNoTracking().ToListAsync(); - taskAnswer.ForEach(x => { + taskAnswer.ForEach(x => + { x.VisitTaskId = taskInfo.Id; - - x.Id= NewId.NextGuid(); + + x.Id = NewId.NextGuid(); }); @@ -179,13 +180,13 @@ namespace IRaCIS.Core.Application.Service x.VisitTaskId = taskInfo.Id; x.RowId = tableRowAnswers.Where(y => y.OriginalId == x.RowId).Select(x => x.Id).FirstOrDefault(); }); - var addrowInfo = _mapper.Map>(tableRowAnswers); + var addrowInfo = _mapper.Map>(tableRowAnswers); switch (originalTask.TrialReadingCriterion.CriterionType) { case CriterionType.IRECIST1Point1: //非靶病灶全部数据复制,不可更改。支持如果状态为:显著增大需要自动改为: 显著增大(iUPD) var stateQuestionId = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == originalTask.TrialReadingCriterionId - && x.ReadingQuestionTrial.LesionType == LesionType.NonTargetLesions && x.QuestionMark == QuestionMark.State).Select(x=>x.Id).FirstOrDefaultAsync(); + && x.ReadingQuestionTrial.LesionType == LesionType.NonTargetLesions && x.QuestionMark == QuestionMark.State).Select(x => x.Id).FirstOrDefaultAsync(); tableAnswer.ForEach(x => { @@ -199,11 +200,11 @@ namespace IRaCIS.Core.Application.Service // 找到新病灶问题 var newLesionQuestion = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == originalTask.TrialReadingCriterionId && x.LesionType == LesionType.NewLesions).FirstOrDefaultAsync(); - + // 找到其他既往新病灶 var otherLesionQuestion = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == originalTask.TrialReadingCriterionId && x.LesionType == LesionType.OtherPreviousNewLesion).FirstOrDefaultAsync(); - + if (newLesionQuestion != null && otherLesionQuestion != null) @@ -215,7 +216,7 @@ namespace IRaCIS.Core.Application.Service var otherLesionTableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == otherLesionQuestion.Id).ToListAsync(); // 找到病灶状态 - var newstateQuestionId = newLesionTableQuestionList.Where(x => x.QuestionMark == QuestionMark.State).Select(x=>x.Id).FirstOrDefault(); + var newstateQuestionId = newLesionTableQuestionList.Where(x => x.QuestionMark == QuestionMark.State).Select(x => x.Id).FirstOrDefault(); var stateAnswers = new List() { @@ -224,10 +225,10 @@ namespace IRaCIS.Core.Application.Service NewLesionState.UnableEvaluate.GetEnumInt() }; - var needRowIds= tableAnswer.Where(x => x.TableQuestionId == newstateQuestionId && stateAnswers.Contains(x.Answer)).Select(x => x.RowId).Distinct().ToList(); + var needRowIds = tableAnswer.Where(x => x.TableQuestionId == newstateQuestionId && stateAnswers.Contains(x.Answer)).Select(x => x.RowId).Distinct().ToList(); + - addrowInfo.ForEach(x => { @@ -238,7 +239,7 @@ namespace IRaCIS.Core.Application.Service x.RowMark = otherLesionQuestion.OrderMark + x.RowIndex.GetLesionMark(); } - + }); tableAnswer.ForEach(x => @@ -258,7 +259,7 @@ namespace IRaCIS.Core.Application.Service }); } - + break; } await _readingTaskQuestionAnswerRepository.AddRangeAsync(taskAnswer); @@ -356,7 +357,7 @@ namespace IRaCIS.Core.Application.Service if (trialReadingCriterionConfig.ReadingType == ReadingMethod.Double) { - + VisitTask? task1 = existCurrentVisitTaskList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm1); VisitTask? task2 = existCurrentVisitTaskList.FirstOrDefault(t => t.ArmEnum == Arm.DoubleReadingArm2); @@ -457,7 +458,7 @@ namespace IRaCIS.Core.Application.Service { currentMaxCodeInt = currentMaxCodeInt + 1; - singleTask = await _visitTaskRepository.AddAsync(new VisitTask() + singleTask = await _visitTaskRepository.AddAsync(new VisitTask() { TrialId = trialId, SubjectId = subjectVisit.SubjectId, @@ -479,7 +480,7 @@ namespace IRaCIS.Core.Application.Service }); } - + @@ -622,6 +623,38 @@ namespace IRaCIS.Core.Application.Service } + //private async Task IsConvertedTask(Guid trialReadingCriterionId, Guid subjectId, decimal visitTaskNum, Guid? doctorUserId) + //{ + + // var criterion = await _trialReadingCriterionRepository.FindAsync(trialReadingCriterionId); + // if (criterion.CriterionType == CriterionType.IRECIST1Point1) + // { + + // if (doctorUserId == null) + // { + // return false; + // } + // else + // { + // if (await _visitTaskRepository.AnyAsync(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectId == subjectId && t.DoctorUserId == doctorUserId && t.VisitTaskNum <= visitTaskNum && t.IsConvertedTask && t.TaskState == TaskState.Effect)) + // { + // return true; + // } + // else + // { + // return false; + // } + // } + + + // } + // else + // { + // return false; + // } + //} + + public DateTime GetSuggessFinishTime(bool isInOrder, UrgentType urgentType) { @@ -1401,6 +1434,7 @@ namespace IRaCIS.Core.Application.Service { taskUrgent = TaskUrgentType.VisitUrgent; } + bool isCanEditUrgent = taskUrgent == TaskUrgentType.EnrollmentConfirm || taskUrgent == TaskUrgentType.PDProgress ? false : true; var newTask = await _visitTaskRepository.AddAsync(new VisitTask() { @@ -1434,6 +1468,18 @@ namespace IRaCIS.Core.Application.Service IsNeedClinicalDataSign = reReadingVisitTask.IsNeedClinicalDataSign, IsClinicalDataSign = reReadingVisitTask.IsClinicalDataSign, + + + //生成的任务分配给原始医生 + DoctorUserId = reReadingVisitTask.DoctorUserId, + TaskAllocationState = TaskAllocationState.Allocated, + AllocateTime = DateTime.Now, + SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget), + + //IR 重阅的任务这两个字段和之前任务保持一致 + //IsConvertedTask = await IsConvertedTask(reReadingVisitTask.TrialReadingCriterionId, reReadingVisitTask.SubjectId, reReadingVisitTask.VisitTaskNum, reReadingVisitTask.DoctorUserId), + //BeforeConvertedTaskId = reReadingVisitTask.BeforeConvertedTaskId, + // TaskAllocationState = reReadingVisitTask.TaskAllocationState, // AllocateTime = DateTime.Now, //DoctorUserId = reReadingVisitTask.DoctorUserId, @@ -1636,7 +1682,7 @@ namespace IRaCIS.Core.Application.Service var task1 = await _visitTaskRepository.AddAsync(new VisitTask() { TrialId = trialId, - IsConvertedTask= originalTaskInfo.IsConvertedTask, + IsConvertedTask = originalTaskInfo.IsConvertedTask, SubjectId = item.SubjectId, IsUrgent = originalTaskInfo.IsUrgent, VisitTaskNum = item.VisitNum + ReadingCommon.TaskNumDic[ReadingCategory.Global], @@ -1688,7 +1734,7 @@ namespace IRaCIS.Core.Application.Service SubjectId = item.SubjectId, IsUrgent = originalTaskInfo.IsUrgent, TaskName = item.ReadingName, - IsConvertedTask= originalTaskInfo.IsConvertedTask, + IsConvertedTask = originalTaskInfo.IsConvertedTask, // 原任务是全局任务 加0.03 就好 VisitTaskNum = originalTaskInfo.VisitTaskNum + 0.03m, ArmEnum = Arm.TumorArm, //特殊 diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index f1f40d65a..0eb89d9e4 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -1749,8 +1749,69 @@ namespace IRaCIS.Core.Application.Service.Allocation #endregion + #region 申请任务 重新生成 拷贝表单 必须放在影响的访视生成任务之前,因为会影响 IsConvertedTask 标志 + await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() + { + TrialId = trialId, + + ReadingCategory = GenerateTaskCategory.ReReading, + + ReReadingTask = origenalTask, + + //同步才可以 + Action = (newTask) => + { + //申请表 设置新任务Id + visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; + + ////生成的任务分配给原始医生 + //newTask.DoctorUserId = origenalTask.DoctorUserId; + //newTask.TaskAllocationState = TaskAllocationState.Allocated; + //newTask.AllocateTime = DateTime.Now; + //newTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); + + + //裁判任务 需要进行特殊处理 在重阅逻辑里面处理 + + + //拷贝表单 + if (visitTaskReReadingAppply.IsCopyOrigenalForms) + { + if (origenalTask.ReadingCategory == ReadingCategory.Visit) + { + var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + + foreach (var item in list) + { + item.Id = Guid.Empty; + item.VisitTaskId = newTask.Id; + } + + _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; + } + //else if (origenalTask.ReadingCategory == ReadingCategory.Global) + //{ + // var list = _repository.Where(t => t.GlobalTaskId == origenalTask.Id).ToList(); + + // foreach (var item in list) + // { + // item.Id = Guid.Empty; + // item.GlobalTaskId = newTask.Id; + // } + + // _ = _repository.AddRangeAsync(list).Result; + //} + + + } + + } + }); + + #endregion + //有序阅片 if (criterionConfig.IsReadingTaskViewInOrder) { @@ -1817,7 +1878,7 @@ namespace IRaCIS.Core.Application.Service.Allocation #region 这里时影响其他的任务 /*不包括申请的任务 申请的任务,在上面会统一处理*/ - var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).ToListAsync(); + var influenceTaskList = await _visitTaskRepository.Where(filterExpression, true).OrderBy(t=>t.VisitTaskNum).ToListAsync(); var trakingOrigenalTask = influenceTaskList.Where(t => t.Id == origenalTask.Id).FirstOrDefault(); @@ -1855,7 +1916,7 @@ namespace IRaCIS.Core.Application.Service.Allocation trakingOrigenalTask?.TaskInfluenceList.Add(new TaskInfluence() { InfluenceTaskId = influenceTask.Id, OptType = ReReadingOrBackOptType.Abandon }); } - //冻结的任务不生成任务 附加评估的任务在同意的时候生成 + //冻结的任务不生成任务 影响的其他标准的附加评估的任务不立即生成 比如1.1基线 重阅 if ( influenceTask.ReadingCategory == ReadingCategory.Visit && beforeTaskState == TaskState.Effect && influenceTask.TrialReadingCriterionId== origenalTask.TrialReadingCriterionId) { await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() @@ -1889,7 +1950,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { item.Id = Guid.Empty; item.VisitTaskId = newTask.Id; - } + } _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; } @@ -1969,69 +2030,8 @@ namespace IRaCIS.Core.Application.Service.Allocation - #region 申请任务 重新生成 拷贝表单 - await _visitTaskCommonService.AddTaskAsync(new GenerateTaskCommand() - { - TrialId = trialId, - - ReadingCategory = GenerateTaskCategory.ReReading, - - ReReadingTask = origenalTask, - - //同步才可以 - Action = (newTask) => - { - //申请表 设置新任务Id - visitTaskReReadingAppply.NewReReadingTaskId = newTask.Id; - - //生成的任务分配给原始医生 - newTask.DoctorUserId = origenalTask.DoctorUserId; - newTask.TaskAllocationState = TaskAllocationState.Allocated; - newTask.AllocateTime = DateTime.Now; - newTask.SuggesteFinishedTime = GetSuggessFinishTime(true, UrgentType.NotUrget); - - - //裁判任务 需要进行特殊处理 在重阅逻辑里面处理 - - - //拷贝表单 - if (visitTaskReReadingAppply.IsCopyOrigenalForms) - { - if (origenalTask.ReadingCategory == ReadingCategory.Visit) - { - var list = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); - - foreach (var item in list) - { - item.Id = Guid.Empty; - item.VisitTaskId = newTask.Id; - } - - _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(list).Result; - } - //else if (origenalTask.ReadingCategory == ReadingCategory.Global) - //{ - // var list = _repository.Where(t => t.GlobalTaskId == origenalTask.Id).ToList(); - - // foreach (var item in list) - // { - // item.Id = Guid.Empty; - // item.GlobalTaskId = newTask.Id; - // } - - // _ = _repository.AddRangeAsync(list).Result; - //} - - - } - - } - }); - - #endregion - } else diff --git a/IRaCIS.Core.Domain/Allocation/VisitTask.cs b/IRaCIS.Core.Domain/Allocation/VisitTask.cs index 728211e5e..d23b1fd75 100644 --- a/IRaCIS.Core.Domain/Allocation/VisitTask.cs +++ b/IRaCIS.Core.Domain/Allocation/VisitTask.cs @@ -9,6 +9,7 @@ using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using System.Collections.Generic; using System.Linq; +using EntityFrameworkCore.Projectables; namespace IRaCIS.Core.Domain.Models { @@ -355,15 +356,21 @@ namespace IRaCIS.Core.Domain.Models //前序任务需要签名 但是未签名 public bool IsFrontTaskNeedSignButNotSign { get; set; } - - - - [JsonIgnore] public Trial Trial { get; set; } + [Projectable] + + public bool IsAfterConvertedTask=>Subject.SubjectVisitTaskList.Where(t=>t.TrialReadingCriterionId == TrialReadingCriterionId + && t.DoctorUserId==DoctorUserId && t.IsConvertedTask + && t.TaskState==TaskState.Effect && + t.VisitTaskNum().HasMany(t => t.GlobalVisitResultList).WithOne(s => s.GlobalVisitTask).HasForeignKey(t => t.GlobalTaskId); + modelBuilder.Entity().HasMany(t => t.ChildList).WithOne(t => t.Parent); modelBuilder.Entity().HasMany(t => t.EarlierSubjectUserList).WithOne(t => t.OrignalSubjectUser);