发送邮件修改

Uat_Study
hang 2022-11-07 14:14:30 +08:00
parent d279a737e1
commit c5bf938be3
1 changed files with 100 additions and 31 deletions

View File

@ -115,6 +115,8 @@ namespace IRaCIS.Core.Application.Service
t.TrialReadingCriterion.ArbitrationRule, t.TrialReadingCriterion.ArbitrationRule,
//单双中 //单双中
t.TrialReadingCriterion.ReadingType, t.TrialReadingCriterion.ReadingType,
t.TrialReadingCriterion.CriterionType,
//有序与否 //有序与否
t.TrialReadingCriterion.IsReadingTaskViewInOrder, t.TrialReadingCriterion.IsReadingTaskViewInOrder,
@ -122,7 +124,6 @@ namespace IRaCIS.Core.Application.Service
t.TrialReadingCriterion.CriterionType,
t.TrialReadingCriterionId, t.TrialReadingCriterionId,
}).FirstNotNullAsync(); }).FirstNotNullAsync();
@ -339,13 +340,13 @@ namespace IRaCIS.Core.Application.Service
} }
else//非截止访视 在访视读完后,发送 else//非截止访视 在访视读完后,发送
{ {
answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Visit); answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Visit,taskInfo.CriterionType);
} }
} }
//截止访视 在访视读完,并完成全局阅片后发送全局的结果 //截止访视 在访视读完,并完成全局阅片后发送全局的结果
else if (taskInfo.ReadingCategory == ReadingCategory.Global) else if (taskInfo.ReadingCategory == ReadingCategory.Global)
{ {
answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Global); answer = await TranslatePdStateAsync(visitTaskId, ReadingCategory.Global, taskInfo.CriterionType);
} }
else 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) 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) 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 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) 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) 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 else
@ -472,7 +473,7 @@ namespace IRaCIS.Core.Application.Service
else 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) if (taskInfo.ReadingType == ReadingMethod.Single && taskInfo.ArbitrationRule == ArbitrationRule.None)
{ {
answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory); answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType);
} }
//双重 截止访视只在阅片期的时候存在 要求PD确认的访视 肯定是非截止访视 //双重 截止访视只在阅片期的时候存在 要求PD确认的访视 肯定是非截止访视
else if (taskInfo.ReadingType == ReadingMethod.Double && taskInfo.ArbitrationRule == ArbitrationRule.Visit) 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) 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) 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 else
@ -534,7 +535,7 @@ namespace IRaCIS.Core.Application.Service
else 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<string> TranslatePdStateAsync(Guid visitTaskId, ReadingCategory readingCategory) private async Task<string> TranslatePdStateAsync(Guid visitTaskId, ReadingCategory readingCategory, CriterionType criterionType)
{ {
var answer = string.Empty; var answer = string.Empty;
if (readingCategory == ReadingCategory.Visit) ReadingTaskQuestionAnswer visitQuestionAnswer = null;
{
var questionAnsewer = await _repository.Where<ReadingTaskQuestionAnswer>(t => t.VisitTaskId == visitTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.Tumor).FirstNotNullAsync();
answer = questionAnsewer.Answer; ReadingTaskQuestionAnswer globalQuestionAnswer = null;
}
else if (readingCategory == ReadingCategory.Global)
{
var questionAnsewer = await _repository.Where<ReadingGlobalTaskInfo>(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<ReadingTaskQuestionAnswer>(t => t.VisitTaskId == judgeResultTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.Tumor).FirstNotNullAsync();
answer = questionAnsewer.Answer; switch (criterionType)
}
else
{ {
throw new BusinessValidationFailedException("不应有 除访视、裁判、全局其他类型的任务进行发送邮件,请核查业务逻辑");
case CriterionType.RECIST1Pointt1:
if (readingCategory == ReadingCategory.Visit)
{
visitQuestionAnswer = await _repository.Where<ReadingTaskQuestionAnswer>(t => t.VisitTaskId == visitTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.Tumor).FirstNotNullAsync();
answer = visitQuestionAnswer.Answer;
}
else if (readingCategory == ReadingCategory.Global)
{
var questionAnsewer = await _repository.Where<ReadingGlobalTaskInfo>(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<ReadingTaskQuestionAnswer>(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<ReadingTaskQuestionAnswer>(t => t.VisitTaskId == visitTaskId && t.ReadingQuestionTrial.QuestionType == QuestionType.SiteVisitForTumorEvaluation).FirstNotNullAsync();
answer = visitQuestionAnswer.Answer;
}
else if (readingCategory == ReadingCategory.Global)
{
var questionAnsewer = await _repository.Where<ReadingGlobalTaskInfo>(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<ReadingTaskQuestionAnswer>(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()) if (answer == OverallAssessment.PD.GetEnumInt())
{ {
return "是"; return "是";