修改邮件发送

Uat_Study
hang 2023-03-01 11:49:55 +08:00
parent 15a2294688
commit 45a52e1f58
3 changed files with 34 additions and 28 deletions

View File

@ -607,7 +607,7 @@
测试邮件 带附件 填充word --前端不需
</summary>
<param name="visitTaskId"></param>
<param name="isMedicalReviewAndSuggestApplyReReading"></param>
<param name="isHandSend"> 为空 代表 正常任务自动发送为true 代表医学审核手动发送 为false 代表医学审核自动发送 </param>
<param name="emailStoreMode"></param>
<param name="sendFileRelativePath"></param>
<returns></returns>

View File

@ -175,13 +175,13 @@ namespace IRaCIS.Core.Application.Service
private async Task<bool> DealMedicalReviewTasKGenerateAndIsSendAsync(Guid trialId, bool? isMedicalReviewAndSuggestApplyReReading, string pdAnswer, List<Guid> taskIdList, List<Guid> minUserIdList)
private async Task<bool> DealMedicalReviewTasKGenerateAndIsSendAsync(Guid trialId, bool? isHandSend, string pdAnswer, List<Guid> taskIdList, List<Guid> minUserIdList)
{
var isNeedSend = true;
//手动发送的时候,也有可能答案是是 此时是 这里不发送,发送已经生成的文件
if (pdAnswer == "是" && isMedicalReviewAndSuggestApplyReReading==null)
if (pdAnswer == "是" && isHandSend==null)
{
isNeedSend = true;
@ -189,7 +189,7 @@ namespace IRaCIS.Core.Application.Service
else
{
//正常阅片为否的
if (isMedicalReviewAndSuggestApplyReReading == null)
if (isHandSend == null)
{
isNeedSend = false;
@ -200,7 +200,7 @@ namespace IRaCIS.Core.Application.Service
}
}
else if (isMedicalReviewAndSuggestApplyReReading == true)
else if (isHandSend == true)
{
//手动发送
isNeedSend = false;
@ -223,12 +223,12 @@ namespace IRaCIS.Core.Application.Service
/// 测试邮件 带附件 填充word --前端不需
/// </summary>
/// <param name="visitTaskId"></param>
/// <param name="isMedicalReviewAndSuggestApplyReReading"></param>
/// <param name="isHandSend"> 为空 代表 正常任务自动发送为true 代表医学审核手动发送 为false 代表医学审核自动发送 </param>
/// <param name="emailStoreMode"></param>
/// <param name="sendFileRelativePath"></param>
/// <returns></returns>
/// <exception cref="BusinessValidationFailedException"></exception>
public async Task<string> BaseBusinessScenarioSendEmailAsync(Guid visitTaskId, bool? isMedicalReviewAndSuggestApplyReReading, EmailStoreSendMode emailStoreMode, string sendFileRelativePath)
public async Task<string> BaseBusinessScenarioSendEmailAsync(Guid visitTaskId, bool? isHandSend, EmailStoreSendMode emailStoreMode, string sendFileRelativePath)
{
CommonDocumentBusinessScenario? businessScenarioEnum = null;
@ -464,6 +464,13 @@ namespace IRaCIS.Core.Application.Service
//入组确认 根据每个标准配置的是否自动发送,发送邮件与否
if (businessScenarioEnum == CommonDocumentBusinessScenario.EnrollConfirmed)
{
if (await _repository.Where<ReadingTableQuestionAnswer>().AnyAsync(x => x.VisitTaskId == visitTaskId && x.Answer == TargetState.Exist.GetEnumInt() &&
x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && x.ReadingQuestionTrial.LesionType == LesionType.TargetLesion))
{
answer = "是";
}
//如果其他阅片人已经做了,说明发送了入组确认报告,第二个人做完就不发送了
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))
@ -472,13 +479,8 @@ namespace IRaCIS.Core.Application.Service
}
else
{
if (await _repository.Where<ReadingTableQuestionAnswer>().AnyAsync(x => x.VisitTaskId == visitTaskId && x.Answer == TargetState.Exist.GetEnumInt() &&
x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && x.ReadingQuestionTrial.LesionType == LesionType.TargetLesion))
if (answer == "是")
{
answer = "是";
//把另外一个人的任务设置为不加急(如果项目加急是否 subject 加急是否)
var urgent = _repository.Where<SubjectVisit>(t => t.Id == taskInfo.SourceSubjectVisitId).Select(t => new { IsSubjectUrgent = t.Subject.IsUrgent, t.Trial.IsUrgent }).FirstOrDefault();
@ -487,9 +489,10 @@ namespace IRaCIS.Core.Application.Service
await _visitTaskRepository.BatchUpdateNoTrackingAsync(t => t.SourceSubjectVisitId == taskInfo.SourceSubjectVisitId && t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false &&
t.Id != visitTaskId && t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId, u => new VisitTask() { IsUrgent = false });
}
}
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, new List<Guid>() { visitTaskId }, minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List<Guid>() { visitTaskId }, minUserIdList);
}
@ -541,7 +544,7 @@ namespace IRaCIS.Core.Application.Service
throw new BusinessValidationFailedException("单重有序阅片 该类型的任务不应进入此处逻辑,请联系后台开发核查!");
}
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, new List<Guid>() { visitTaskId }, minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List<Guid>() { visitTaskId }, minUserIdList);
}
@ -566,7 +569,7 @@ namespace IRaCIS.Core.Application.Service
answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
}
//双人 产生裁判,并且裁判完成 发
@ -575,7 +578,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, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
}
else
@ -612,7 +615,7 @@ namespace IRaCIS.Core.Application.Service
answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
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 && taskList.Where(t => t.ReadingCategory == ReadingCategory.Global).Count() == 2)
@ -621,7 +624,7 @@ namespace IRaCIS.Core.Application.Service
var judgeResultId = taskList.Where(t => t.ReadingCategory == ReadingCategory.Judge).First().JudgeResultTaskId.Value;
answer = await TranslatePdStateAsync(judgeResultId, ReadingCategory.Global, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
}
else
@ -675,7 +678,7 @@ namespace IRaCIS.Core.Application.Service
{
answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, new List<Guid>() { visitTaskId }, minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, new List<Guid>() { visitTaskId }, minUserIdList);
}
//双重 截止访视只在阅片期的时候存在 要求PD确认的访视 肯定是非截止访视
else if (taskInfo.ReadingType == ReadingMethod.Double && taskInfo.ArbitrationRule == ArbitrationRule.Visit)
@ -691,14 +694,14 @@ namespace IRaCIS.Core.Application.Service
answer = await TranslatePdStateAsync(visitTaskId, taskInfo.ReadingCategory, taskInfo.CriterionType);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
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, isMedicalReviewAndSuggestApplyReReading, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
isNeedSend = await DealMedicalReviewTasKGenerateAndIsSendAsync(taskInfo.TrialId, isHandSend, answer, taskList.Select(t => t.Id).ToList(), minUserIdList);
}
@ -949,7 +952,7 @@ namespace IRaCIS.Core.Application.Service
}
else
{
return ResponseOutput.NotOk("当前Subject最新PD访视阅片任务完成状态不符合发送条件");
return ResponseOutput.NotOk("当前受试者最新PD访视阅片任务完成状态不符合发送条件");
}
}
@ -961,7 +964,7 @@ namespace IRaCIS.Core.Application.Service
if (existReadModule == null)
{
return ResponseOutput.NotOk("项目配置了阅片期仲裁,但是当前Subject最新PD访视没有影像学阅片期");
return ResponseOutput.NotOk("项目配置了阅片期仲裁,但是当前受试者最新PD访视没有影像学阅片期");
}
else
{
@ -995,7 +998,7 @@ namespace IRaCIS.Core.Application.Service
else
{
return ResponseOutput.NotOk("当前Subject最新PD访视阅片期任务完成状态不符合发送条件");
return ResponseOutput.NotOk("当前受试者最新PD访视阅片期任务完成状态不符合发送条件");
}
}
@ -1018,7 +1021,7 @@ namespace IRaCIS.Core.Application.Service
if (task == null)
{
return ResponseOutput.NotOk("当前Subject最新PD访视任务未阅片完成");
return ResponseOutput.NotOk("当前受试者最新PD访视任务未阅片完成");
}
else
{
@ -1041,7 +1044,7 @@ namespace IRaCIS.Core.Application.Service
}
else
{
return ResponseOutput.NotOk("当前Subject阅片期任务未阅片完成");
return ResponseOutput.NotOk("当前受试者阅片期任务未阅片完成");
}
}

View File

@ -11,6 +11,7 @@ using Newtonsoft.Json;
using IRaCIS.Core.Application.Service;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Application.Filter;
using IRaCIS.Core.Domain.Models;
namespace IRaCIS.Application.Services
{
@ -451,6 +452,8 @@ namespace IRaCIS.Application.Services
// 创建任务关联关系
await this.CreateTaskRelated(inDto.VisitTaskId);
await _trialEmailNoticeConfigService.BaseBusinessScenarioSendEmailAsync(inDto.VisitTaskId);
return ResponseOutput.Ok(result);
}