修改邮件

This commit is contained in:
2022-10-27 14:40:15 +08:00
parent 659dba85d1
commit 1bb0c52773
19 changed files with 514 additions and 268 deletions
@@ -9,6 +9,7 @@ using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Infrastructure;
using IRaCIS.Core.Application.Service;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Application.Interfaces;
namespace IRaCIS.Application.Services
{
@@ -45,6 +46,8 @@ namespace IRaCIS.Application.Services
private readonly IRepository<ReadingQuestionSystem> _readingQuestionSystem;
private readonly IRepository<ReadingQuestionTrial> _readingQuestionTrialRepository;
private readonly ITrialEmailNoticeConfigService _trialEmailNoticeConfigService;
public ReadingImageTaskService(
IMapper mapper,
@@ -72,7 +75,9 @@ namespace IRaCIS.Application.Services
IRepository<ReadingQuestionCriterionTrial> readingQuestionCriterionTrialRepository,
IRepository<ReadingQuestionCriterionSystem> readingQuestionCriterionSystemRepository,
IRepository<ReadingQuestionSystem> ReadingQuestionSystem,
IRepository<ReadingQuestionTrial> readingQuestionTrialRepository
IRepository<ReadingQuestionTrial> readingQuestionTrialRepository,
ITrialEmailNoticeConfigService trialEmailNoticeConfigService
)
{
base._mapper = mapper;
@@ -101,6 +106,8 @@ namespace IRaCIS.Application.Services
this._readingQuestionCriterionSystemRepository = readingQuestionCriterionSystemRepository;
this._readingQuestionSystem = ReadingQuestionSystem;
this._readingQuestionTrialRepository = readingQuestionTrialRepository;
_trialEmailNoticeConfigService = trialEmailNoticeConfigService;
}
@@ -135,10 +142,10 @@ namespace IRaCIS.Application.Services
[HttpPost]
public async Task<(List<GetRelatedVisitTaskOutDto>, object)> GetRelatedVisitTask(GetRelatedVisitTaskInDto inDto)
{
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x=>x.TrialReadingCriterion).FirstNotNullAsync();
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.TrialReadingCriterion).FirstNotNullAsync();
var baselineVisitId = await _subjectVisitRepository.Where(x => x.SubjectId == taskInfo.SubjectId && x.IsBaseLine && !x.IsLostVisit).Select(x => x.Id).FirstNotNullAsync();
var result = await _visitTaskRepository
.WhereIf(taskInfo.TaskState != TaskState.Effect,x=>x.Id== inDto.VisitTaskId)
.WhereIf(taskInfo.TaskState != TaskState.Effect, x => x.Id == inDto.VisitTaskId)
.Where(x =>
(x.TrialId == taskInfo.TrialId &&
x.SubjectId == taskInfo.SubjectId &&
@@ -338,7 +345,181 @@ namespace IRaCIS.Application.Services
[HttpPost]
public async Task<GetReadingReportEvaluationOutDto> GetReadingReportEvaluation(GetReadingReportEvaluationInDto indto)
{
return await _readingCalculateService.GetReadingReportEvaluation(indto);
GetReadingReportEvaluationOutDto result = new GetReadingReportEvaluationOutDto();
result.CalculateResult = await _readingCalculateService.GetReportVerify(new GetReportVerifyInDto()
{
VisitTaskId = indto.VisitTaskId
});
var visitTaskInfo = await _visitTaskRepository.Where(x => x.Id == indto.VisitTaskId).FirstNotNullAsync();
//if (visitTaskInfo.TaskState != TaskState.Effect)
//{
// throw new BusinessValidationFailedException($"当前任务已失效!");
//}
result.ReadingTaskState = visitTaskInfo.ReadingTaskState;
var taskInfoList = await _visitTaskRepository
// 失效的只查看自己
.WhereIf(visitTaskInfo.TaskState != TaskState.Effect, x => x.Id == indto.VisitTaskId)
.Where(x => (x.SubjectId == visitTaskInfo.SubjectId && x.TaskState == TaskState.Effect
&& x.IsAnalysisCreate == visitTaskInfo.IsAnalysisCreate
&& x.IsSelfAnalysis == visitTaskInfo.IsSelfAnalysis
&& x.ArmEnum == visitTaskInfo.ArmEnum
&& x.TrialReadingCriterionId == visitTaskInfo.TrialReadingCriterionId
&& x.ReadingCategory == ReadingCategory.Visit && !x.IsAnalysisCreate && x.ReadingTaskState == ReadingTaskState.HaveSigned) || x.Id == indto.VisitTaskId
).OrderBy(x => x.VisitTaskNum).Select(x => new VisitTaskInfo()
{
BlindName = x.SourceSubjectVisit.BlindName,
IsBaseLine = x.SourceSubjectVisit.IsBaseLine,
VisitTaskId = x.Id,
TaskName = x.TaskName,
VisitTaskNum = x.VisitTaskNum,
IsCurrentTask = x.Id == indto.VisitTaskId,
}).ToListAsync();
result.VisitTaskList = taskInfoList;
var visitTaskIds = taskInfoList.Select(x => x.VisitTaskId).ToList();
var criterionId = visitTaskInfo.TrialReadingCriterionId;
var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == criterionId).ToListAsync();
var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == criterionId).OrderBy(x => x.ShowOrder).ToListAsync();
var tableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == indto.VisitTaskId).ProjectTo<TableAnsweRowInfo>(_mapper.ConfigurationProvider).ToListAsync();
var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync();
var tableAnswers = await _readingTableQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync();
// 第一级
#region
List<ReadingReportDto> questions = questionList.Where(x => x.Type == ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto()
{
QuestionId = x.Id,
GroupName = x.GroupName,
IsShowInDicom = x.IsShowInDicom,
Type = x.Type,
QuestionType = x.QuestionType,
LesionType = x.LesionType,
QuestionGenre = x.QuestionGenre,
DictionaryCode = x.DictionaryCode,
TypeValue = x.TypeValue,
QuestionName = x.QuestionName,
ShowOrder = x.ShowOrder,
ValueType = x.ValueType,
Unit = x.Unit,
}).ToList();
// 分组
foreach (var item in questions)
{
item.Childrens = questionList.Where(x => x.GroupName == item.GroupName && x.Type != ReadingQestionType.Group).OrderBy(x => x.ShowOrder).Select(x => new ReadingReportDto()
{
GroupName = x.GroupName,
QuestionId = x.Id,
IsShowInDicom = x.IsShowInDicom,
QuestionName = x.QuestionName,
LesionType = x.LesionType,
QuestionGenre = x.QuestionGenre,
DictionaryCode = x.DictionaryCode,
Type = x.Type,
QuestionType = x.QuestionType,
TypeValue = x.TypeValue,
ShowOrder = x.ShowOrder,
OrderMark = x.OrderMark,
ValueType = x.ValueType,
Unit = x.Unit,
}).ToList();
// 问题
foreach (var question in item.Childrens)
{
foreach (var task in taskInfoList)
{
question.Answer.Add(new TaskQuestionAnswer()
{
Answer = answers.Where(x => x.VisitTaskId == task.VisitTaskId && x.ReadingQuestionTrialId == question.QuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(),
TaskName = task.TaskName,
VisitTaskId = task.VisitTaskId,
});
}
// 构造表格行数据
var rowlist = tableAnsweRowInfos.Where(x => x.QuestionId == question.QuestionId).OrderBy(x => x.RowIndex).ToList();
question.Childrens = rowlist.Select(x => new ReadingReportDto()
{
QuestionName = question.OrderMark + x.RowIndex.GetLesionMark(),
SplitOrMergeLesionName = x.MergeName.IsNullOrEmpty() ? x.SplitName : x.MergeName,
SplitOrMergeType = x.SplitOrMergeType,
LesionType = question.LesionType,
IsCanEditPosition = x.IsCanEditPosition,
RowIndex = x.RowIndex,
}).ToList();
foreach (var row in question.Childrens)
{
// tableQuestion
row.Childrens = tableQuestionList.Where(x => x.ReadingQuestionId == question.QuestionId).Select(x => new ReadingReportDto()
{
QuestionName = x.QuestionName,
QuestionId = x.ReadingQuestionId,
TableQuestionId = x.Id,
Type = x.Type,
LesionType = question.LesionType,
TableQuestionType = x.TableQuestionType,
DictionaryCode = x.DictionaryCode,
QuestionMark = x.QuestionMark,
TypeValue = x.TypeValue,
RowIndex = row.RowIndex,
ShowOrder = x.ShowOrder,
ValueType = x.ValueType,
Unit = x.Unit,
}).ToList();
foreach (var tableQuestion in row.Childrens)
{
foreach (var task in taskInfoList)
{
tableQuestion.Answer.Add(new TaskQuestionAnswer()
{
Answer = tableAnswers.Where(x => x.VisitTaskId == task.VisitTaskId && x.QuestionId == tableQuestion.QuestionId && x.RowIndex == tableQuestion.RowIndex && x.TableQuestionId == tableQuestion.TableQuestionId).Select(x => x.Answer).FirstIsNullReturnEmpty(),
TaskName = task.TaskName,
VisitTaskId = task.VisitTaskId,
});
}
}
}
};
}
#endregion
result.TaskQuestions = questions;
return result;
}
/// <summary>
@@ -475,7 +656,7 @@ namespace IRaCIS.Application.Services
{
readingTaskState = visitTaskInfo.ReadingTaskState,
FormType = formType,
TaskNum= visitTaskInfo.VisitTaskNum,
TaskNum = visitTaskInfo.VisitTaskNum,
}); ;
}
@@ -502,7 +683,7 @@ namespace IRaCIS.Application.Services
ShowOrder = x.ShowOrder,
GroupName = string.Empty,
Id = x.Id,
DictionaryCode=x.DictionaryCode,
DictionaryCode = x.DictionaryCode,
Type = x.Type,
TableQuestionType = x.TableQuestionType,
DependParentId = x.DependParentId,
@@ -518,8 +699,8 @@ namespace IRaCIS.Application.Services
QuestionName = x.QuestionName,
RelationQuestions = new List<GetTrialReadingQuestionOutDto>(),
Remark = x.Remark,
ValueType=x.ValueType,
Unit=x.Unit,
ValueType = x.ValueType,
Unit = x.Unit,
}).ToList();
});
var thisAnswer = tableAnswers.Where(x => x.QuestionId == item.Id).ToList();
@@ -536,8 +717,6 @@ namespace IRaCIS.Application.Services
var rowInfo = tableAnsweRowInfos.Where(y => y.RowIndex == x && y.QuestionId == item.Id).FirstOrDefault();
answers.Add("BlindName", rowInfo.BlindName);
answers.Add("IsDicomReading", rowInfo.IsDicomReading.ToString());
answers.Add("MeasureData", rowInfo == null ? string.Empty : rowInfo.MeasureData);
answers.Add("RowIndex", x.ToString());
answers.Add("RowId", rowInfo.Id.ToString());
@@ -546,8 +725,8 @@ namespace IRaCIS.Application.Services
answers.Add("InstanceId", rowInfo == null ? string.Empty : rowInfo.InstanceId.ToString());
answers.Add("SeriesId", rowInfo == null ? string.Empty : rowInfo.SeriesId.ToString());
answers.Add("IsCurrentTaskAdd", rowInfo == null ? false.ToString() : rowInfo.IsCurrentTaskAdd.ToString());
answers.Add("SplitOrMergeLesionName",rowInfo.SplitName.IsNullOrEmpty()? rowInfo.MergeName: rowInfo.SplitName);
answers.Add("SplitOrMergeType", rowInfo.SplitOrMergeType==null?string.Empty:((int)rowInfo.SplitOrMergeType).ToString());
answers.Add("SplitOrMergeLesionName", rowInfo.SplitName.IsNullOrEmpty() ? rowInfo.MergeName : rowInfo.SplitName);
answers.Add("SplitOrMergeType", rowInfo.SplitOrMergeType == null ? string.Empty : ((int)rowInfo.SplitOrMergeType).ToString());
item.TableQuestions.Answers.Add(answers);
@@ -715,7 +894,7 @@ namespace IRaCIS.Application.Services
public async Task<IResponseOutput> DeleteReadingRowAnswer(DeleteReadingRowAnswerInDto inDto)
{
var deleteRowInfo = await _readingTableAnswerRowInfoRepository.Where(x =>x.Id== inDto.RowId).FirstNotNullAsync();
var deleteRowInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == inDto.RowIndex && x.QuestionId == inDto.QuestionId).FirstNotNullAsync();
if (deleteRowInfo == null)
{
return ResponseOutput.Ok(true);
@@ -727,8 +906,8 @@ namespace IRaCIS.Application.Services
throw new BusinessValidationFailedException($"当前病灶分裂出其他病灶或者其他病灶合并到了当前病灶,删除失败");
}
await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.RowId== inDto.RowId);
await _readingTableAnswerRowInfoRepository.DeleteFromQueryAsync(x => x.Id==inDto.RowId);
await _readingTableQuestionAnswerRepository.DeleteFromQueryAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == inDto.RowIndex && x.QuestionId == inDto.QuestionId);
await _readingTableAnswerRowInfoRepository.DeleteFromQueryAsync(x => x.VisitTaskId == inDto.VisitTaskId && x.RowIndex == inDto.RowIndex && x.QuestionId == inDto.QuestionId);
await _readingTableAnswerRowInfoRepository.SaveChangesAsync();
@@ -855,8 +1034,6 @@ namespace IRaCIS.Application.Services
rowInfo.TrialId = inDto.TrialId;
rowInfo.QuestionId = inDto.QuestionId;
rowInfo.MeasureData = inDto.MeasureData;
rowInfo.BlindName = inDto.BlindName;
rowInfo.IsDicomReading = inDto.IsDicomReading;
rowInfo.IsCurrentTaskAdd = isCurrentTaskAdd;
rowInfo.FristAddTaskNum = inDto.FristAddTaskNum;
rowInfo.RowIndex = inDto.RowIndex;
@@ -993,16 +1170,16 @@ namespace IRaCIS.Application.Services
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync();
var readingQuestionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == taskInfo.TrialReadingCriterionId
&&(x.IsJudgeQuestion||x.IsRequired== IsRequired.Required)
&& (x.IsJudgeQuestion || x.IsRequired == IsRequired.Required)
).ToListAsync();
var answerQuestionIds = await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == inDto.VisitTaskId).Select(x => x.ReadingQuestionTrialId).ToListAsync();
readingQuestionList = readingQuestionList.Where(x => !answerQuestionIds.Contains(x.Id)).ToList();
if(readingQuestionList.Count()>0)
if (readingQuestionList.Count() > 0)
{
throw new BusinessValidationFailedException($" 必填问题{ string.Join(',', readingQuestionList.Select(x =>x.QuestionName))}的答案为空或未保存");
throw new BusinessValidationFailedException($" 必填问题{string.Join(',', readingQuestionList.Select(x => x.QuestionName))}的答案为空或未保存");
}
await _readingCalculateService.VerifyVisitTaskQuestions(inDto);
@@ -1199,6 +1376,18 @@ namespace IRaCIS.Application.Services
await _visitTaskRepository.SaveChangesAsync();
//基于业务场景发送邮件
//await _trialEmailNoticeConfigService.BaseBusinessScenarioSendEmailAsync( visitTaskId);
}
@@ -1267,7 +1456,7 @@ namespace IRaCIS.Application.Services
await AddOncologyTask(oncologyReadId);
}
break;
}
}