diff --git a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs index 5f7641a7..73ae4175 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs @@ -181,7 +181,7 @@ namespace IRaCIS.Core.Application.Service var isNeedSend = true; //手动发送的时候,也有可能答案是是 此时是 这里不发送,发送已经生成的文件 - if (pdAnswer == "是" && isHandSend==null) + if (pdAnswer == "是" && isHandSend == null) { isNeedSend = true; @@ -196,9 +196,16 @@ namespace IRaCIS.Core.Application.Service //生成任务 foreach (var taskId in taskIdList) { - await _taskMedicalReviewRepository.AddAsync(new TaskMedicalReview() { TrialId = trialId, VisitTaskId = taskId, MedicalManagerUserId = minUserIdList.FirstOrDefault(), AllocateTime = DateTime.Now - ,IsAutoGenerate=true,PDRelationTaskIdListStr=string.Join('|', taskIdList.Distinct()) - },true); + await _taskMedicalReviewRepository.AddAsync(new TaskMedicalReview() + { + TrialId = trialId, + VisitTaskId = taskId, + MedicalManagerUserId = minUserIdList.FirstOrDefault(), + AllocateTime = DateTime.Now + , + IsAutoGenerate = true, + PDRelationTaskIdListStr = string.Join('|', taskIdList.Distinct()) + }, true); } } @@ -470,7 +477,7 @@ namespace IRaCIS.Core.Application.Service if (await _repository.Where().AnyAsync(x => x.VisitTaskId == visitTaskId && x.Answer == TargetState.Exist.GetEnumInt() && x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && x.ReadingQuestionTrial.LesionType == LesionType.TargetLesion)) { - answer = "是"; + answer = "是"; } @@ -478,13 +485,13 @@ namespace IRaCIS.Core.Application.Service //入组确认一直交给第一个人,如果第一个人重阅 还未做完,第二个人先做完了,此时不发 - var existFirstEnrollTask= await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.IsAnalysisCreate == false - && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId).OrderBy(t=>t.SignTime).FirstOrDefaultAsync(); + var existFirstEnrollTask = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.IsAnalysisCreate == false + && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId).OrderBy(t => t.SignTime).FirstOrDefaultAsync(); //入组确认的医生已确定 - if( (existFirstEnrollTask != null) &&(taskInfo.DoctorUserId != existFirstEnrollTask.DoctorUserId) ) - { - isNeedSend = false; + if ((existFirstEnrollTask != null) && (taskInfo.DoctorUserId != existFirstEnrollTask.DoctorUserId)) + { + isNeedSend = false; } else { @@ -506,7 +513,7 @@ namespace IRaCIS.Core.Application.Service } - + } @@ -520,48 +527,9 @@ namespace IRaCIS.Core.Application.Service { - //单重 - if (taskInfo.ReadingType == ReadingMethod.Single) - { - //仲裁在访视上 或者在阅片期 - if (taskInfo.ArbitrationRule != ArbitrationRule.None) - { - - throw new BusinessValidationFailedException("单重有序阅片配置有误(不应该有仲裁对象配置),请核查!"); - } - - - //要求PD 确认的访视 是截止访视 还是非截止访视(根据该访视有没有配置阅片期来判断) - - if (taskInfo.ReadingCategory == ReadingCategory.Visit) - { - //存在阅片期 那么就是截止访视 - if (await _repository.Where(t => t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && t.SubjectVisitId == taskInfo.SourceSubjectVisitId && t.ReadingSetType == ReadingSetType.ImageReading).AnyAsync()) - { - isNeedSend = false; - } - else//非截止访视 在访视读完后,发送 - { - answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Visit, taskInfo.CriterionType); - } - } - //截止访视 在访视读完,并完成全局阅片后发送全局的结果 - else if (taskInfo.ReadingCategory == ReadingCategory.Global) - { - answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Global, taskInfo.CriterionType); - } - else - { - throw new BusinessValidationFailedException("单重有序阅片 该类型的任务不应进入此处逻辑,请联系后台开发核查!"); - } - - isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List() { visitTaskId }, minUserIdList); - - - } //双重 - else if (taskInfo.ReadingType == ReadingMethod.Double) + if (taskInfo.ReadingType == ReadingMethod.Double) { @@ -590,7 +558,7 @@ namespace IRaCIS.Core.Application.Service var judgeResultId = taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().JudgeResultTaskId.Value; answer = await TranslatePdStateAsync(judgeResultId, ReadingCategory.Visit, taskInfo.CriterionType); - isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Where(t=>t.ReadingCategory==ReadingCategory.Judge).Select(t => t.Id).ToList(), minUserIdList); + isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Select(t => t.Id).ToList(), minUserIdList); } else @@ -657,100 +625,128 @@ namespace IRaCIS.Core.Application.Service { throw new BusinessValidationFailedException("双重有序阅片 没有定义该仲裁规则处理逻辑,请联系业务和后台开发核查!"); - - ////只发第一个人 - //if (await _visitTaskRepository.AnyAsync(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false && - //t.Id != visitTaskId && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId)) - //{ - // isNeedSend = false; - //} - //else - //{ - - // answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); - //} } } + + //屏蔽单重阅片添加 else { - throw new BusinessValidationFailedException("有序阅片配置有误(应为单重或者双重阅片),请核查!"); + isNeedSend = false; + return string.Empty; } + #region 发邮件屏蔽单重的 + ////单重 + //else if (taskInfo.ReadingType == ReadingMethod.Single) + //{ + // //仲裁在访视上 或者在阅片期 + // if (taskInfo.ArbitrationRule != ArbitrationRule.None) + // { + + // throw new BusinessValidationFailedException("单重有序阅片配置有误(不应该有仲裁对象配置),请核查!"); + // } + + + // //要求PD 确认的访视 是截止访视 还是非截止访视(根据该访视有没有配置阅片期来判断) + + // if (taskInfo.ReadingCategory == ReadingCategory.Visit) + // { + // //存在阅片期 那么就是截止访视 + // if (await _repository.Where(t => t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && t.SubjectVisitId == taskInfo.SourceSubjectVisitId && t.ReadingSetType == ReadingSetType.ImageReading).AnyAsync()) + // { + // isNeedSend = false; + // } + // else//非截止访视 在访视读完后,发送 + // { + // answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Visit, taskInfo.CriterionType); + // } + // } + // //截止访视 在访视读完,并完成全局阅片后发送全局的结果 + // else if (taskInfo.ReadingCategory == ReadingCategory.Global) + // { + // answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Global, taskInfo.CriterionType); + // } + // else + // { + // throw new BusinessValidationFailedException("单重有序阅片 该类型的任务不应进入此处逻辑,请联系后台开发核查!"); + // } + + // isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List() { visitTaskId }, minUserIdList); + + + //} + //else + //{ + // throw new BusinessValidationFailedException("有序阅片配置有误(应为单重或者双重阅片),请核查!"); + //} + + #endregion + + + } - //无序 + //屏蔽无序阅片添加 else { - //单重 - - - if (taskInfo.ReadingType == ReadingMethod.Single && taskInfo.ArbitrationRule == ArbitrationRule.None) - { - answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); - - isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List() { visitTaskId }, minUserIdList); - } - //双重 截止访视只在阅片期的时候存在 要求PD确认的访视 肯定是非截止访视 - else if (taskInfo.ReadingType == ReadingMethod.Double && taskInfo.ArbitrationRule == ArbitrationRule.Visit) - { - //在两位阅片人读完访视后,如果有裁判者等裁判读完,如果无裁判则等第二个人的读完 - - var taskList = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && t.IsAnalysisCreate == false && t.TaskState == TaskState.Effect - && (t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Judge)).ToListAsync(); - - //这里要求 到这里已经如果有裁判 已经生成裁判了保存数据库 - if (taskList.Count == 2 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit) == 2) - { - - answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); - - isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList); - } - else if (taskList.Count == 3 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned) == 3 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Count() == 1) - { - var judgeResultId = taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().JudgeResultTaskId.Value; - answer = await TranslatePdStateAsync(judgeResultId, ReadingCategory.Visit, taskInfo.CriterionType); - - isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Select(t => t.Id).ToList(), minUserIdList); - - - } - else - { - isNeedSend = false; - } - - } - else - { - throw new BusinessValidationFailedException("无序阅片配置有误(应为单重无仲裁对象,双重针对访视仲裁),请核查!"); - - - ////只发第一个人 - //if (await _visitTaskRepository.AnyAsync(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false && - //t.Id != visitTaskId && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId)) - //{ - // isNeedSend = false; - //} - //else - //{ - - // answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); - //} - - } - + isNeedSend = false; + return string.Empty; } + #region 发送邮件屏蔽无序的 + // //无序 + //else + //{ + // //单重 + // if (taskInfo.ReadingType == ReadingMethod.Single && taskInfo.ArbitrationRule == ArbitrationRule.None) + // { + // answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); + + // isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List() { visitTaskId }, minUserIdList); + // } + // //双重 截止访视只在阅片期的时候存在 要求PD确认的访视 肯定是非截止访视 + // else if (taskInfo.ReadingType == ReadingMethod.Double && taskInfo.ArbitrationRule == ArbitrationRule.Visit) + // { + // //在两位阅片人读完访视后,如果有裁判者等裁判读完,如果无裁判则等第二个人的读完 + + // var taskList = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && t.IsAnalysisCreate == false && t.TaskState == TaskState.Effect + // && (t.ReadingCategory == ReadingCategory.Visit || t.ReadingCategory == ReadingCategory.Judge)).ToListAsync(); + + // //这里要求 到这里已经如果有裁判 已经生成裁判了保存数据库 + // if (taskList.Count == 2 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit) == 2) + // { + + // answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); + + // isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList); + // } + // else if (taskList.Count == 3 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned) == 3 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Count() == 1) + // { + // var judgeResultId = taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().JudgeResultTaskId.Value; + // answer = await TranslatePdStateAsync(judgeResultId, ReadingCategory.Visit, taskInfo.CriterionType); + + // isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Select(t => t.Id).ToList(), minUserIdList); + // } + // else + // { + // isNeedSend = false; + // } + // } + // else + // { + // throw new BusinessValidationFailedException("无序阅片配置有误(应为单重无仲裁对象,双重针对访视仲裁),请核查!"); + // } + //} + #endregion } else { @@ -824,7 +820,7 @@ namespace IRaCIS.Core.Application.Service sendEmailConfig.EmailAttachMentConfigList.Add(new EmailAttachMentConfig() { - FileName =$"{taskInfo.SubjectCode}_{emailConfig.FileName}" , + FileName = $"{taskInfo.SubjectCode}_{emailConfig.FileName}", FileStream = memoryStream }); @@ -887,12 +883,12 @@ namespace IRaCIS.Core.Application.Service //找到最早签名的 var firstSignTask = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == exisitBaseline.Id /*&& t.TaskState == TaskState.Effect*/ && t.IsAnalysisCreate == false - && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).OrderBy(t=>t.SignTime).FirstOrDefaultAsync(); + && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).OrderBy(t => t.SignTime).FirstOrDefaultAsync(); if (firstSignTask != null) { - var task = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == exisitBaseline.Id && t.TaskState == TaskState.Effect && t.DoctorUserId== firstSignTask.DoctorUserId && t.IsAnalysisCreate == false + var task = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == exisitBaseline.Id && t.TaskState == TaskState.Effect && t.DoctorUserId == firstSignTask.DoctorUserId && t.IsAnalysisCreate == false && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).OrderBy(t => t.SignTime).FirstOrDefaultAsync(); //如果存在做完的该任务 @@ -914,10 +910,10 @@ namespace IRaCIS.Core.Application.Service { return ResponseOutput.NotOk("当前未有阅片人读完基线任务!"); } - - + + } } @@ -946,7 +942,7 @@ namespace IRaCIS.Core.Application.Service { TrialReadingCriterionId = t.Id, t.ReadingType, t.IsReadingTaskViewInOrder, t.CriterionType, t.ArbitrationRule }).FirstNotNullAsync(); // 项目双重 - if (trialReadingCriterionConfig.ReadingType == ReadingMethod.Double) + if (trialReadingCriterionConfig.ReadingType == ReadingMethod.Double && trialReadingCriterionConfig.IsReadingTaskViewInOrder) { //仲裁在访视上面 if (trialReadingCriterionConfig.ArbitrationRule == ArbitrationRule.Visit) @@ -1037,58 +1033,62 @@ namespace IRaCIS.Core.Application.Service return ResponseOutput.NotOk("未定义该仲裁规则发送业务逻辑!"); } } - // 项目单重 判断最新的Pd 访视是否完成 是否有阅片期即可 - else if (trialReadingCriterionConfig.ReadingType == ReadingMethod.Single) - { + + #region 发送邮件屏蔽单重阅片情况 + //// 项目单重 判断最新的Pd 访视是否完成 是否有阅片期即可 + //else if (trialReadingCriterionConfig.ReadingType == ReadingMethod.Single) + //{ - var task = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == currentLatestPdVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false - && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).FirstOrDefaultAsync(); + // var task = await _visitTaskRepository.Where(t => t.SourceSubjectVisitId == currentLatestPdVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false + // && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).FirstOrDefaultAsync(); - if (task == null) - { - return ResponseOutput.NotOk("当前受试者最新PD访视任务未阅片完成"); - } - else - { - //存在阅片期 那么就是截止访视 + // if (task == null) + // { + // return ResponseOutput.NotOk("当前受试者最新PD访视任务未阅片完成"); + // } + // else + // { + // //存在阅片期 那么就是截止访视 - var existReadModule = await _repository.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == currentLatestPdVisitId && t.ReadingSetType == ReadingSetType.ImageReading) - .FirstOrDefaultAsync(); - if (existReadModule != null) - { + // var existReadModule = await _repository.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == currentLatestPdVisitId && t.ReadingSetType == ReadingSetType.ImageReading) + // .FirstOrDefaultAsync(); + // if (existReadModule != null) + // { - var global = await _visitTaskRepository.Where(t => t.SouceReadModuleId == currentLatestPdVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false - && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).FirstOrDefaultAsync(); + // var global = await _visitTaskRepository.Where(t => t.SouceReadModuleId == currentLatestPdVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false + // && t.ReadingTaskState == ReadingTaskState.HaveSigned && t.TrialReadingCriterionId == trialReadingCriterionId).FirstOrDefaultAsync(); - if (global != null) - { - var filePath = await BaseBusinessScenarioSendEmailAsync(global.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty); + // if (global != null) + // { + // var filePath = await BaseBusinessScenarioSendEmailAsync(global.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty); - return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id }); - } - else - { - return ResponseOutput.NotOk("当前受试者阅片期任务未阅片完成"); - } + // return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id }); + // } + // else + // { + // return ResponseOutput.NotOk("当前受试者阅片期任务未阅片完成"); + // } - } - else//非截止访视 在访视读完后,发送 - { - var filePath = await BaseBusinessScenarioSendEmailAsync(task.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty); + // } + // else//非截止访视 在访视读完后,发送 + // { + // var filePath = await BaseBusinessScenarioSendEmailAsync(task.Id, true, EmailStoreSendMode.OnlyStoreLocalNotSentEmail, string.Empty); - return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id }); - } - } + // return ResponseOutput.Ok(new { RelativePath = filePath, TaskName = task.TaskName, VisitTaskId = task.Id }); + // } + // } - } + //} + #endregion + else { - return ResponseOutput.NotOk("当前项目配置,未定义单双重外发送业务逻辑!"); + return ResponseOutput.NotOk("当前项目配置,不满足双重有序阅片,不满足发送条件!"); } } @@ -1127,7 +1127,7 @@ namespace IRaCIS.Core.Application.Service /// 是否是全局产生(区分裁判任务) /// /// - private async Task TranslatePdStateAsync(Guid visitTaskId, ReadingCategory readingCategory, CriterionType criterionType, bool? IsGlobalGenerate=null) + private async Task TranslatePdStateAsync(Guid visitTaskId, ReadingCategory readingCategory, CriterionType criterionType, bool? IsGlobalGenerate = null) { var answer = string.Empty; diff --git a/IRaCIS.Core.Domain/Image/DicomStudyMonitor.cs b/IRaCIS.Core.Domain/Image/DicomStudyMonitor.cs index 23d605e5..9d6a6579 100644 --- a/IRaCIS.Core.Domain/Image/DicomStudyMonitor.cs +++ b/IRaCIS.Core.Domain/Image/DicomStudyMonitor.cs @@ -88,7 +88,7 @@ namespace IRaCIS.Core.Domain.Models public User Uploader { get; set; } - public bool IsSuccess = true; + public bool IsSuccess { get; set; } public string Note = string.Empty;