diff --git a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs index b2566df36..cbd10fed4 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs @@ -115,6 +115,8 @@ namespace IRaCIS.Core.Application.Service t.TrialReadingCriterion.ArbitrationRule, //单双中 t.TrialReadingCriterion.ReadingType, + + t.TrialReadingCriterion.CriterionType, //有序与否 t.TrialReadingCriterion.IsReadingTaskViewInOrder, @@ -122,7 +124,6 @@ namespace IRaCIS.Core.Application.Service - t.TrialReadingCriterion.CriterionType, t.TrialReadingCriterionId, }).FirstNotNullAsync(); @@ -339,13 +340,13 @@ namespace IRaCIS.Core.Application.Service } else//非截止访视 在访视读完后,发送 { - answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Visit); + answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Visit,taskInfo.CriterionType); } } //截止访视 在访视读完,并完成全局阅片后发送全局的结果 else if (taskInfo.ReadingCategory == ReadingCategory.Global) { - answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Global); + answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Global, taskInfo.CriterionType); } else { @@ -372,13 +373,13 @@ namespace IRaCIS.Core.Application.Service if (taskList.Count == 2 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit) == 2) { - answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory); + answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); } //双人 产生裁判,并且裁判完成 发 else if (taskList.Count == 3 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned) == 3 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Count() == 1) { - answer = await TranslatePdStateAsync(taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().Id, ReadingCategory.Judge); + answer = await TranslatePdStateAsync(taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().Id, ReadingCategory.Judge, taskInfo.CriterionType); } else @@ -435,13 +436,13 @@ namespace IRaCIS.Core.Application.Service if (taskList.Count == 2 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Global) == 2) { - answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory); + answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); } //双人全局产生裁判 else if (taskList.Count == 3 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned) == 3 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Count() == 1 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Global).Count() == 2) { - answer = await TranslatePdStateAsync(taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().Id, ReadingCategory.Judge); + answer = await TranslatePdStateAsync(taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().Id, ReadingCategory.Judge, taskInfo.CriterionType); } else @@ -472,7 +473,7 @@ namespace IRaCIS.Core.Application.Service else { - answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory); + answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); } } @@ -493,7 +494,7 @@ namespace IRaCIS.Core.Application.Service if (taskInfo.ReadingType == ReadingMethod.Single && taskInfo.ArbitrationRule == ArbitrationRule.None) { - answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory); + answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); } //双重 截止访视只在阅片期的时候存在 要求PD确认的访视 肯定是非截止访视 else if (taskInfo.ReadingType == ReadingMethod.Double && taskInfo.ArbitrationRule == ArbitrationRule.Visit) @@ -506,12 +507,12 @@ namespace IRaCIS.Core.Application.Service if (taskList.Count == 2 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned && t.ReadingCategory == ReadingCategory.Visit) == 2) { - answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory); + answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); } else if (taskList.Count == 3 && taskList.Count(t => t.ReadingTaskState == ReadingTaskState.HaveSigned) == 3 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).Count() == 1) { - answer = await TranslatePdStateAsync(taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().Id, ReadingCategory.Judge); + answer = await TranslatePdStateAsync(taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().Id, ReadingCategory.Judge, taskInfo.CriterionType); } else @@ -534,7 +535,7 @@ namespace IRaCIS.Core.Application.Service else { - answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory); + answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType); } } @@ -588,38 +589,106 @@ namespace IRaCIS.Core.Application.Service - private async Task TranslatePdStateAsync(Guid visitTaskId, ReadingCategory readingCategory) + private async Task TranslatePdStateAsync(Guid visitTaskId, ReadingCategory readingCategory, CriterionType criterionType) { var answer = string.Empty; - if (readingCategory == ReadingCategory.Visit) - { - var questionAnsewer = await _repository.Where(t => t.VisitTaskId == visitTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.Tumor).FirstNotNullAsync(); + ReadingTaskQuestionAnswer visitQuestionAnswer = null; - answer = questionAnsewer.Answer; - } - else if (readingCategory == ReadingCategory.Global) - { - var questionAnsewer = await _repository.Where(t => t.TaskId == visitTaskId && t.TrialReadingQuestion.QuestionType == QuestionType.Tumor).FirstNotNullAsync(); + ReadingTaskQuestionAnswer globalQuestionAnswer = null; - answer = questionAnsewer.Answer; - } - else if (readingCategory == ReadingCategory.Judge) - { - var judgeResultTaskId = await _visitTaskRepository.Where(t => t.Id == visitTaskId).Select(t => t.JudgeResultTaskId).FirstNotNullAsync(); - var questionAnsewer = await _repository.Where(t => t.VisitTaskId == judgeResultTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.Tumor).FirstNotNullAsync(); - answer = questionAnsewer.Answer; - } - else + switch (criterionType) { - throw new BusinessValidationFailedException("不应有 除访视、裁判、全局其他类型的任务进行发送邮件,请核查业务逻辑"); + + + case CriterionType.RECIST1Pointt1: + + if (readingCategory == ReadingCategory.Visit) + { + + visitQuestionAnswer = await _repository.Where(t => t.VisitTaskId == visitTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.Tumor).FirstNotNullAsync(); + + + answer = visitQuestionAnswer.Answer; + } + else if (readingCategory == ReadingCategory.Global) + { + var questionAnsewer = await _repository.Where(t => t.TaskId == visitTaskId && t.TrialReadingQuestion.QuestionType == QuestionType.Tumor).FirstNotNullAsync(); + + answer = questionAnsewer.Answer; + } + else if (readingCategory == ReadingCategory.Judge) + { + var judgeResultTaskId = await _visitTaskRepository.Where(t => t.Id == visitTaskId).Select(t => t.JudgeResultTaskId).FirstNotNullAsync(); + + var questionAnsewer = await _repository.Where(t => t.VisitTaskId == judgeResultTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.Tumor).FirstNotNullAsync(); + + answer = questionAnsewer.Answer; + } + else + { + throw new BusinessValidationFailedException("不应有 除访视、裁判、全局其他类型的任务进行发送邮件,请核查业务逻辑"); + } + + break; + case CriterionType.PCWG3: + if (readingCategory == ReadingCategory.Visit) + { + + visitQuestionAnswer = await _repository.Where(t => t.VisitTaskId == visitTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.SiteVisitForTumorEvaluation).FirstNotNullAsync(); + + + answer = visitQuestionAnswer.Answer; + } + else if (readingCategory == ReadingCategory.Global) + { + var questionAnsewer = await _repository.Where(t => t.TaskId == visitTaskId && t.TrialReadingQuestion.QuestionType == QuestionType.SiteVisitForTumorEvaluation).FirstNotNullAsync(); + + answer = questionAnsewer.Answer; + } + else if (readingCategory == ReadingCategory.Judge) + { + var judgeResultTaskId = await _visitTaskRepository.Where(t => t.Id == visitTaskId).Select(t => t.JudgeResultTaskId).FirstNotNullAsync(); + + var questionAnsewer = await _repository.Where(t => t.VisitTaskId == judgeResultTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.SiteVisitForTumorEvaluation).FirstNotNullAsync(); + + answer = questionAnsewer.Answer; + } + else + { + throw new BusinessValidationFailedException("不应有 除访视、裁判、全局其他类型的任务进行发送邮件,请核查业务逻辑"); + } + break; + case CriterionType.SelfDefine: + case CriterionType.mRECISTMesothelioma: + case CriterionType.RECIL: + case CriterionType.RECIST1Point0: + case CriterionType.WHO: + case CriterionType.PERCIST: + case CriterionType.Forrest: + case CriterionType.Lugano2014: + case CriterionType.iRECIST: + case CriterionType.RANO_BM: + case CriterionType.RANO: + case CriterionType.IWCLL2018: + case CriterionType.mRECISTHCC: + case CriterionType.Cheson2007: + case CriterionType.IMWG2016: + default: + + throw new BusinessValidationFailedException("该标准任务还未定义PD获取逻辑,联系业务和后台开发协商后补充"); + break; } + + + + if (answer == OverallAssessment.PD.GetEnumInt()) { return "是";