增加Global Using
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-20 10:19:08 +08:00
parent 115017197b
commit fc30cb39ee
408 changed files with 11031 additions and 12556 deletions
@@ -1,22 +1,15 @@
using IRaCIS.Core.Domain.Share;
using Microsoft.AspNetCore.Mvc;
using IRaCIS.Core.Application.Service.Reading.Dto;
using MassTransit;
using IRaCIS.Core.Infra.EFCore.Common;
using Panda.DynamicWebApi.Attributes;
using AutoMapper;
using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Infrastructure;
using Newtonsoft.Json;
using IRaCIS.Core.Application.Service;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Application.Filter;
using IRaCIS.Core.Application.Service.Reading.Dto;
using IRaCIS.Core.Domain.Share;
using IRaCIS.Core.Infra.EFCore.Common;
using IRaCIS.Core.Infrastructure;
using Microsoft.AspNetCore.Mvc;
using System.Linq.Dynamic.Core;
using NPOI.SS.Formula.Functions;
namespace IRaCIS.Application.Services
namespace IRaCIS.Core.Application.Service
{
/// <summary>
/// 全局阅片
/// </summary>
@@ -34,8 +27,8 @@ namespace IRaCIS.Application.Services
await VerifyTaskIsSign(inDto.GlobalTaskId);
await this.SubmitTaskChangeState(inDto.GlobalTaskId);
var globalAnswerList = await _readingGlobalTaskInfoRepository.Where(x =>
x.QuestionId!=null &&x.Answer!=string.Empty&& x.Answer != null &&
var globalAnswerList = await _readingGlobalTaskInfoRepository.Where(x =>
x.QuestionId != null && x.Answer != string.Empty && x.Answer != null &&
x.GlobalTaskId == inDto.GlobalTaskId).ToListAsync();
foreach (var item in globalAnswerList)
@@ -80,16 +73,16 @@ namespace IRaCIS.Application.Services
&& x.Answer != answer.Answer && answer.Answer != string.Empty && answer.Answer != null
, x => new ReadingTaskQuestionAnswer()
{
Answer= answer.Answer,
GlobalChangeAnswer = answer.Answer,
IsGlobalChange = true,
Answer = answer.Answer,
GlobalChangeAnswer = answer.Answer,
IsGlobalChange = true,
});
}
}
}
var answers= inDto.VisitTaskAnswerList.SelectMany(x => x.AnswerList.Select(y => new ReadingGlobalTaskInfo()
var answers = inDto.VisitTaskAnswerList.SelectMany(x => x.AnswerList.Select(y => new ReadingGlobalTaskInfo()
{
Answer = y.Answer,
QuestionId = y.QuestionId,
@@ -144,7 +137,7 @@ namespace IRaCIS.Application.Services
GlobalAnswerType = x.GlobalAnswerType,
TaskId = x.VisitTaskId,
TrialId = inDto.TrialId,
CreateTime= createtime,
CreateTime = createtime,
}).ToList());
await _visitTaskRepository.UpdatePartialFromQueryAsync(t => t.Id == inDto.GlobalTaskId, u => new VisitTask() { ReadingTaskState = ReadingTaskState.Reading });
@@ -163,7 +156,7 @@ namespace IRaCIS.Application.Services
[HttpPost]
public async Task<GetGlobalReadingInfoOutDto> GetGlobalReadingInfo(GetGlobalReadingInfoInDto inDto)
{
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x=>x.Subject).FirstNotNullAsync();
var taskInfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).FirstNotNullAsync();
if (taskInfo.ReadingCategory != ReadingCategory.Global)
{
throw new BusinessValidationFailedException(_localizer["ReadingGlobal_NotGlobal"]);
@@ -174,15 +167,15 @@ namespace IRaCIS.Application.Services
ReadingTaskState = taskInfo.ReadingTaskState,
};
var otherGlobalTask = await _visitTaskRepository.Where(x => x.SouceReadModuleId == taskInfo.SouceReadModuleId && x.IsAnalysisCreate == taskInfo.IsAnalysisCreate
&& x.IsSelfAnalysis == taskInfo.IsSelfAnalysis && x.TaskState == TaskState.Effect && x.DoctorUserId != taskInfo.DoctorUserId
).FirstOrDefaultAsync();
var otherGlobalTask = await _visitTaskRepository.Where(x => x.SouceReadModuleId == taskInfo.SouceReadModuleId && x.IsAnalysisCreate == taskInfo.IsAnalysisCreate
&& x.IsSelfAnalysis == taskInfo.IsSelfAnalysis && x.TaskState == TaskState.Effect && x.DoctorUserId != taskInfo.DoctorUserId
).FirstOrDefaultAsync();
if (otherGlobalTask != null)
{
result.OtherGlobalTaskId = otherGlobalTask.Id;
}
}
result.TaskBlindName = taskInfo.TaskBlindName;
if (taskInfo.IsAnalysisCreate)
@@ -195,18 +188,18 @@ namespace IRaCIS.Application.Services
result.SubjectCode = taskInfo.Subject.Code;
}
var judgeInfo = await _visitTaskRepository.Where(x =>
x.SubjectId == taskInfo.SubjectId
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
&& x.TaskState == TaskState.Effect
&& x.ArmEnum == taskInfo.ArmEnum
&& x.ReadingCategory == ReadingCategory.Judge
&& x.IsAnalysisCreate == taskInfo.IsAnalysisCreate
&& x.IsSelfAnalysis == taskInfo.IsSelfAnalysis
&& x.DoctorUserId == taskInfo.DoctorUserId
&& x.ReadingTaskState == ReadingTaskState.HaveSigned
&& x.VisitTaskNum == taskInfo.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge]
&& x.ReReadingApplyState != ReReadingApplyState.Agree).FirstOrDefaultAsync();
var judgeInfo = await _visitTaskRepository.Where(x =>
x.SubjectId == taskInfo.SubjectId
&& x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId
&& x.TaskState == TaskState.Effect
&& x.ArmEnum == taskInfo.ArmEnum
&& x.ReadingCategory == ReadingCategory.Judge
&& x.IsAnalysisCreate == taskInfo.IsAnalysisCreate
&& x.IsSelfAnalysis == taskInfo.IsSelfAnalysis
&& x.DoctorUserId == taskInfo.DoctorUserId
&& x.ReadingTaskState == ReadingTaskState.HaveSigned
&& x.VisitTaskNum == taskInfo.VisitTaskNum + ReadingCommon.TaskNumDic[ReadingCategory.Judge]
&& x.ReReadingApplyState != ReReadingApplyState.Agree).FirstOrDefaultAsync();
if (judgeInfo != null)
{
result.JudgeTaskId = judgeInfo.Id;
@@ -217,7 +210,7 @@ namespace IRaCIS.Application.Services
// 一致性分析按照doctorId 其他按照分组
var queruTask = _visitTaskRepository.Where(x =>
var queruTask = _visitTaskRepository.Where(x =>
x.TrialId == taskInfo.TrialId &&
x.SubjectId == taskInfo.SubjectId &&
x.ReadingCategory == ReadingCategory.Visit &&
@@ -248,37 +241,37 @@ namespace IRaCIS.Application.Services
VisitNum = x.SourceSubjectVisit.VisitNum,
IsBaseLine = x.SourceSubjectVisit.IsBaseLine,
VisitId = x.SourceSubjectVisitId!.Value,
LesionCountList=x.LesionList.GroupBy(y=>y.ReadingQuestionTrial.LesionType).Select(x => new LesionDto
{
LesionType = x.Key!.Value,
Count = x.ToList().Count()
}).ToList(),
//CrterionDictionaryGroup= x.CrterionDictionaryGroup,
BeforeQuestionList = x.ReadingTaskQuestionAnswerList.Where(y => y.ReadingQuestionTrial.GlobalReadingShowType!=GlobalReadingShowType.NotShow).OrderBy(y => y.ReadingQuestionTrial.ShowOrder)
LesionCountList = x.LesionList.GroupBy(y => y.ReadingQuestionTrial.LesionType).Select(x => new LesionDto
{
LesionType = x.Key!.Value,
Count = x.ToList().Count()
}).ToList(),
//CrterionDictionaryGroup= x.CrterionDictionaryGroup,
BeforeQuestionList = x.ReadingTaskQuestionAnswerList.Where(y => y.ReadingQuestionTrial.GlobalReadingShowType != GlobalReadingShowType.NotShow).OrderBy(y => y.ReadingQuestionTrial.ShowOrder)
.Select(y => new GlobalQuestionInfo()
{
JudgeDifferenceValue= y.ReadingQuestionTrial.JudgeDifferenceValue,
QuestionId = y.ReadingQuestionTrialId,
JudgeDifferenceValue = y.ReadingQuestionTrial.JudgeDifferenceValue,
QuestionId = y.ReadingQuestionTrialId,
QuestionName = y.ReadingQuestionTrial.QuestionName.LanguageName(y.ReadingQuestionTrial.QuestionEnName, _userInfo.IsEn_Us),
QuestionEnName=y.ReadingQuestionTrial.QuestionEnName,
QuestionEnName = y.ReadingQuestionTrial.QuestionEnName,
AnswerGroup = y.ReadingQuestionTrial.AnswerGroup,
QuestionType = y.ReadingQuestionTrial.QuestionType,
LimitEdit= y.ReadingQuestionTrial.LimitEdit,
MaxAnswerLength=y.ReadingQuestionTrial.MaxAnswerLength,
FileType=y.ReadingQuestionTrial.FileType,
LimitEdit = y.ReadingQuestionTrial.LimitEdit,
MaxAnswerLength = y.ReadingQuestionTrial.MaxAnswerLength,
FileType = y.ReadingQuestionTrial.FileType,
QuestionGenre = y.ReadingQuestionTrial.QuestionGenre,
DictionaryCode = y.ReadingQuestionTrial.DictionaryCode,
GlobalReadingShowType=y.ReadingQuestionTrial.GlobalReadingShowType,
GlobalReadingShowType = y.ReadingQuestionTrial.GlobalReadingShowType,
AnswerCombination = y.ReadingQuestionTrial.AnswerCombination,
JudgeType = y.ReadingQuestionTrial.JudgeType,
ShowOrder= y.ReadingQuestionTrial.ShowOrder,
Type = y.ReadingQuestionTrial.Type,
ShowOrder = y.ReadingQuestionTrial.ShowOrder,
Type = y.ReadingQuestionTrial.Type,
TypeValue = y.ReadingQuestionTrial.TypeValue,
ValueType = y.ReadingQuestionTrial.ValueType,
IsJudgeQuestion =y.ReadingQuestionTrial.IsJudgeQuestion,
Answer =y.Answer,
IsJudgeQuestion = y.ReadingQuestionTrial.IsJudgeQuestion,
Answer = y.Answer,
}).ToList()
}).ToListAsync();
var globalQuestionList = await _readingQuestionTrialRepository.Where(x => x.GlobalReadingShowType != GlobalReadingShowType.NotShow && x.ReadingQuestionCriterionTrialId == taskInfo.TrialReadingCriterionId).IgnoreAutoIncludes().ToListAsync();
@@ -299,40 +292,40 @@ namespace IRaCIS.Application.Services
{
x.BeforeQuestionList.Add(new GlobalQuestionInfo()
{
QuestionId = y.Id,
JudgeDifferenceValue=y.JudgeDifferenceValue,
QuestionName = y.QuestionName.LanguageName(y.QuestionEnName, _userInfo.IsEn_Us),
QuestionEnName = y.QuestionEnName,
AnswerGroup = y.AnswerGroup,
QuestionType = y.QuestionType,
LimitEdit = y.LimitEdit,
MaxAnswerLength = y.MaxAnswerLength,
FileType = y.FileType,
QuestionGenre = y.QuestionGenre,
ShowOrder=y.ShowOrder,
DictionaryCode = y.DictionaryCode,
GlobalReadingShowType = y.GlobalReadingShowType,
AnswerCombination = y.AnswerCombination,
JudgeType = y.JudgeType,
Type = y.Type,
TypeValue = y.TypeValue,
ValueType = y.ValueType,
IsJudgeQuestion = y.IsJudgeQuestion,
Answer = string.Empty,
QuestionId = y.Id,
JudgeDifferenceValue = y.JudgeDifferenceValue,
QuestionName = y.QuestionName.LanguageName(y.QuestionEnName, _userInfo.IsEn_Us),
QuestionEnName = y.QuestionEnName,
AnswerGroup = y.AnswerGroup,
QuestionType = y.QuestionType,
LimitEdit = y.LimitEdit,
MaxAnswerLength = y.MaxAnswerLength,
FileType = y.FileType,
QuestionGenre = y.QuestionGenre,
ShowOrder = y.ShowOrder,
DictionaryCode = y.DictionaryCode,
GlobalReadingShowType = y.GlobalReadingShowType,
AnswerCombination = y.AnswerCombination,
JudgeType = y.JudgeType,
Type = y.Type,
TypeValue = y.TypeValue,
ValueType = y.ValueType,
IsJudgeQuestion = y.IsJudgeQuestion,
Answer = string.Empty,
});
});
}
}
});
}
}
x.BeforeQuestionList = x.BeforeQuestionList.OrderBy(y => y.ShowOrder).ToList();
});
});
var globalReadingQuestion = await _readingGlobalTaskInfoRepository.Where(x => x.GlobalTaskId == inDto.VisitTaskId).ToListAsync();
var globalReadingQuestion = await _readingGlobalTaskInfoRepository.Where(x => x.GlobalTaskId == inDto.VisitTaskId).ToListAsync();
var criterionType = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == taskInfo.TrialReadingCriterionId).Select(x => x.CriterionType).FirstOrDefaultAsync();
// Before的Answer取自于 上一次全局阅片的结果, 如果没有上一次全局阅片的结果 取访视的答案
@@ -341,7 +334,7 @@ namespace IRaCIS.Application.Services
x.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId &&
x.SubjectId == taskInfo.SubjectId && x.IsAnalysisCreate == taskInfo.IsAnalysisCreate && x.TaskState == TaskState.Effect && x.VisitTaskNum < taskInfo.VisitTaskNum)
.Where(x => x.DoctorUserId == taskInfo.DoctorUserId)
.OrderByDescending(x=>x.VisitTaskNum)
.OrderByDescending(x => x.VisitTaskNum)
.FirstOrDefaultAsync();
List<ReadingGlobalTaskInfo>? globalAnswers = new List<ReadingGlobalTaskInfo>();
@@ -358,13 +351,13 @@ namespace IRaCIS.Application.Services
x.BeforeQuestionList.ForEach(y =>
{
var globalAnswer = globalAnswers.Where(z => z.QuestionId == y.QuestionId&&z.TaskId==x.VisitTaskId).Select(z => z.Answer).FirstOrDefault();
var globalAnswer = globalAnswers.Where(z => z.QuestionId == y.QuestionId && z.TaskId == x.VisitTaskId).Select(z => z.Answer).FirstOrDefault();
if (!globalAnswer.IsNullOrEmpty())
{
y.Answer = globalAnswer??string.Empty;
y.Answer = globalAnswer ?? string.Empty;
y.IsGlobalAnswer = true;
}
});
});
}
@@ -372,7 +365,7 @@ namespace IRaCIS.Application.Services
result.TaskList.ForEach(x =>
{
x.AfterQuestionList = x.BeforeQuestionList
.GroupJoin(
.GroupJoin(
globalReadingQuestion
, l => new { a = l.QuestionId, b = x.VisitTaskId }
, r => new { a = r.QuestionId, b = r.TaskId }
@@ -384,15 +377,15 @@ namespace IRaCIS.Application.Services
(lr.global.Select(x => x.Answer).FirstOrDefault().IsNullOrEmpty() && inDto.UsingOriginalData ?
lr.question.Answer : lr.global.Select(x => x.Answer).FirstOrDefault()
),
JudgeDifferenceValue= lr.question.JudgeDifferenceValue,
VisitAnswer = lr.question.Answer,
IsHaveChange = lr.global.Any(x=>x.QuestionId!=null&&!x.Answer.IsNullOrEmpty()) ? true : false,
JudgeDifferenceValue = lr.question.JudgeDifferenceValue,
VisitAnswer = lr.question.Answer,
IsHaveChange = lr.global.Any(x => x.QuestionId != null && !x.Answer.IsNullOrEmpty()) ? true : false,
QuestionId = lr.question.QuestionId,
QuestionName = lr.question.QuestionName.LanguageName(lr.question.QuestionEnName, _userInfo.IsEn_Us),
QuestionType = lr.question.QuestionType,
LimitEdit=lr.question.LimitEdit,
MaxAnswerLength=lr.question.MaxAnswerLength,
FileType=lr.question.FileType,
LimitEdit = lr.question.LimitEdit,
MaxAnswerLength = lr.question.MaxAnswerLength,
FileType = lr.question.FileType,
QuestionGenre = lr.question.QuestionGenre,
DictionaryCode = lr.question.DictionaryCode,
GlobalReadingShowType = lr.question.GlobalReadingShowType,
@@ -400,10 +393,10 @@ namespace IRaCIS.Application.Services
GlobalAnswerType = GlobalAnswerType.Question,
AnswerGroup = lr.question.AnswerGroup,
AnswerCombination = lr.question.AnswerCombination,
IsJudgeQuestion=lr.question.IsJudgeQuestion,
IsJudgeQuestion = lr.question.IsJudgeQuestion,
JudgeType = lr.question.JudgeType,
TypeValue = lr.question.TypeValue,
ValueType= lr.question.ValueType,
ValueType = lr.question.ValueType,
}).ToList();
@@ -415,7 +408,7 @@ namespace IRaCIS.Application.Services
{
var agreeOrNotAnswer = globalReadingQuestion.Where(y => y.TaskId == x.VisitTaskId && y.GlobalAnswerType == GlobalAnswerType.AgreeOrNot).Select(x => x.Answer).FirstOrDefault() ?? string.Empty;
if (agreeOrNotAnswer.IsNullOrEmpty()&& lastGlobalTask!=null&& lastGlobalTask.RelatedVisitTaskIdList.Contains(x.VisitTaskId))
if (agreeOrNotAnswer.IsNullOrEmpty() && lastGlobalTask != null && lastGlobalTask.RelatedVisitTaskIdList.Contains(x.VisitTaskId))
{
agreeOrNotAnswer = "1";
}
@@ -430,7 +423,7 @@ namespace IRaCIS.Application.Services
GlobalAnswerType=GlobalAnswerType.AgreeOrNot,
GlobalReadingShowType= GlobalReadingShowType.AllShow,
}
};
questionTypes.Add(new GetGlobalQuestionType() { GlobalAnswerType = GlobalAnswerType.UpdateType, QuestionName = "评估更新类型" });
@@ -443,8 +436,8 @@ namespace IRaCIS.Application.Services
questionTypes.Add(new GetGlobalQuestionType() { GlobalAnswerType = GlobalAnswerType.Reason, QuestionName = "全局阅片备注" });
foreach (var item in questionTypes)
{
@@ -454,7 +447,7 @@ namespace IRaCIS.Application.Services
QuestionName = item.QuestionName,
Type = "input",
GlobalAnswerType = item.GlobalAnswerType,
GlobalReadingShowType= GlobalReadingShowType.AllShow,
GlobalReadingShowType = GlobalReadingShowType.AllShow,
});
}
@@ -469,8 +462,8 @@ namespace IRaCIS.Application.Services
// 找到上一个全局阅片
result.TaskList.ForEach(x =>
{
foreach (var item in x.AfterQuestionList.Where(x => x.QuestionType == QuestionType.SiteVisitForTumorEvaluation))
@@ -502,7 +495,7 @@ namespace IRaCIS.Application.Services
x.BeforeQuestionList = x.BeforeQuestionList.Where(x => x.QuestionType != QuestionType.SiteVisitForTumorEvaluation).ToList();
x.AfterQuestionList = x.AfterQuestionList.Where(x => x.QuestionType == QuestionType.SiteVisitForTumorEvaluation|| x.GlobalAnswerType != GlobalAnswerType.Question).ToList();
x.AfterQuestionList = x.AfterQuestionList.Where(x => x.QuestionType == QuestionType.SiteVisitForTumorEvaluation || x.GlobalAnswerType != GlobalAnswerType.Question).ToList();
});
}
@@ -514,16 +507,16 @@ namespace IRaCIS.Application.Services
List<CriterionDictionaryInfo> assessTypeList = await _readingTrialCriterionDictionaryRepository.Where(x => x.CriterionId == taskInfo.TrialReadingCriterionId
&& x.ParentCode == ReadingCommon.CriterionDictionary.GlobalAssess
)
//.WhereIf(isBaseLine,x=>x.IsBaseLineUse)
//.WhereIf(!isBaseLine,x=>x.IsFollowVisitUse)
//.WhereIf(isBaseLine,x=>x.IsBaseLineUse)
//.WhereIf(!isBaseLine,x=>x.IsFollowVisitUse)
.Select(x => new CriterionDictionaryInfo()
{
Id = x.Id,
DictionaryId = x.DictionaryId,
ChildGroup = x.Dictionary.ChildGroup,
IsBaseLineUse=x.IsBaseLineUse,
IsFollowVisitUse=x.IsFollowVisitUse,
IsBaseLineUse = x.IsBaseLineUse,
IsFollowVisitUse = x.IsFollowVisitUse,
Code = x.Dictionary.Code,
Description = x.Dictionary.Description,
ShowOrder = x.Dictionary.ShowOrder,