From 8cc9cb8cafa46e5f53aef1477be664dd3c0fc1a3 Mon Sep 17 00:00:00 2001 From: he <10978375@qq.com> Date: Tue, 5 Dec 2023 11:03:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=AD=A6=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .editorconfig | 1 + .../SubjectCriteriaEvaluationService.cs | 2 +- .../ReadingCriterionService.cs | 4 +- .../ReadingQuestionService.cs | 12 ++- .../ReadingGlobalTaskService.cs | 6 +- .../ReadingImageTaskService.cs | 18 ++-- .../ReadingJudgeTaskService.cs | 20 ++-- .../ReadingPeriod/ReadModuleService.cs | 2 +- .../Reading/ShortcutKey/ShortcutKeyService.cs | 14 +-- .../IRECIST1Point1CalculateService.cs | 94 +++++++++---------- .../LuganoCalculateService.cs | 26 ++--- .../ReadingCalculate/PCWG3CalculateService.cs | 21 +++-- .../RECIST1Point1CalculateService.cs | 8 +- .../RECIST1Point1_BMCalculateService.cs | 6 +- .../SelfDefineCalculateService.cs | 4 +- 15 files changed, 125 insertions(+), 113 deletions(-) diff --git a/.editorconfig b/.editorconfig index 15b266e76..8527d4643 100644 --- a/.editorconfig +++ b/.editorconfig @@ -133,6 +133,7 @@ dotnet_diagnostic.CS8619.severity = none dotnet_diagnostic.CS8620.severity = none dotnet_diagnostic.CS8632.severity = none dotnet_diagnostic.CS8604.severity = none +dotnet_diagnostic.CS1998.severity = none [*.vb] #### 命名样式 #### diff --git a/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationService.cs b/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationService.cs index ff72f893e..fa99eaf00 100644 --- a/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationService.cs +++ b/IRaCIS.Core.Application/Service/Reading/AdditionalEvaluate/SubjectCriteriaEvaluationService.cs @@ -522,7 +522,7 @@ namespace IRaCIS.Core.Application.Service var generateVisitIdList = idList.Except(haveGenerateVisitIdList); - await _IVisitTaskHelpeService.BaseCritrionGenerateVisitTask(batchGenerateTaskCommand.TrialId, batchGenerateTaskCommand.TrialReadingCriterionId, true, generateVisitIdList.Select(t => (Guid)t).ToList()); + await _IVisitTaskHelpeService.BaseCritrionGenerateVisitTask(batchGenerateTaskCommand.TrialId, batchGenerateTaskCommand.TrialReadingCriterionId, true, generateVisitIdList.Select(t => (Guid)t.Value).ToList()); await _subjectCriteriaEvaluationVisitFilterRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingCriterionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingCriterionService.cs index fc25124b6..2f9caca99 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingCriterionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingCriterionService.cs @@ -342,7 +342,7 @@ namespace IRaCIS.Core.Application.Service.RC } } - var systemCriterion = await _readingQuestionCriterionSystemRepository.Where(x => x.Id == inDto.Id).AsNoTracking().FirstOrDefaultAsync(); + var systemCriterion = await _readingQuestionCriterionSystemRepository.Where(x => x.Id == inDto.Id).AsNoTracking().FirstNotNullAsync(); var confirmTime = systemCriterion.ConfirmTime; @@ -470,7 +470,7 @@ namespace IRaCIS.Core.Application.Service.RC public async Task SetTrialJudgyInfo(SetTrialJudgyInfoInDto inDto) { - var trialCriterion = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == inDto.TrialId && x.Id == inDto.TrialReadingCriterionId).FirstOrDefaultAsync(); + var trialCriterion = await _readingQuestionCriterionTrialRepository.Where(x => x.TrialId == inDto.TrialId && x.Id == inDto.TrialReadingCriterionId).FirstNotNullAsync(); var judgeCount = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == trialCriterion.Id && x.IsJudgeQuestion) .WhereIf(trialCriterion.FormType == FormType.SinglePage, x => x.ReadingCriterionPageId == null) diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs index 90df4ca8b..0148fdfc3 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCriterion/ReadingQuestionService.cs @@ -460,7 +460,11 @@ namespace IRaCIS.Application.Services } - relation.CalculateQuestionList = calculateInfoList; + if (relation != null) + { + relation.CalculateQuestionList = calculateInfoList; + } + this.VerifyCalculateRelation(relationList, indto.Id.Value, indto.Id.Value); } @@ -731,7 +735,11 @@ namespace IRaCIS.Application.Services } - relation.CalculateQuestionList = calculateInfoList; + if (relation != null) + { + relation.CalculateQuestionList = calculateInfoList; + } + this.VerifyCalculateRelation(relationList, indto.Id.Value, indto.Id.Value); } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingGlobalTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingGlobalTaskService.cs index f05a5e11c..499dae0f4 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingGlobalTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingGlobalTaskService.cs @@ -231,10 +231,10 @@ namespace IRaCIS.Application.Services ArmEnum = taskInfo.ArmEnum, VisitNum = x.SourceSubjectVisit.VisitNum, IsBaseLine = x.SourceSubjectVisit.IsBaseLine, - VisitId = x.SourceSubjectVisitId.Value, + VisitId = x.SourceSubjectVisitId!.Value, LesionCountList=x.LesionList.GroupBy(y=>y.ReadingQuestionTrial.LesionType).Select(x => new LesionDto { - LesionType = x.Key.Value, + LesionType = x.Key!.Value, Count = x.ToList().Count() }).ToList(), //CrterionDictionaryGroup= x.CrterionDictionaryGroup, @@ -342,7 +342,7 @@ namespace IRaCIS.Application.Services var globalAnswer = globalAnswers.Where(z => z.QuestionId == y.QuestionId&&z.TaskId==x.VisitTaskId).Select(z => z.Answer).FirstOrDefault(); if (!globalAnswer.IsNullOrEmpty()) { - y.Answer = globalAnswer; + y.Answer = globalAnswer??string.Empty; y.IsGlobalAnswer = true; } diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index faa1d10bd..b7c96d35e 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -627,7 +627,7 @@ namespace IRaCIS.Application.Services { x.IsReadingShowPreviousResults, x.IsReadingShowSubjectInfo - }).FirstOrDefaultAsync(); + }).FirstNotNullAsync(); var trialInfo = await _trialRepository.Where(x => x.Id == visitTask.TrialId).Select(x => new { x.ClinicalInformationTransmissionEnum, @@ -637,7 +637,7 @@ namespace IRaCIS.Application.Services { VisitTaskId = visitTask.Id, SubjectId = visitTask.SubjectId, - SubjectCode = visitTask.BlindSubjectCode.IsNullOrEmpty() ? subjectCode : visitTask.BlindSubjectCode, + SubjectCode = visitTask.BlindSubjectCode.IsNullOrEmpty() ? subjectCode??string.Empty : visitTask.BlindSubjectCode, ReadingCategory = visitTask.ReadingCategory, TaskBlindName = visitTask.TaskBlindName, IsReadingShowPreviousResults = criterionInfo.IsReadingShowPreviousResults, @@ -796,7 +796,7 @@ namespace IRaCIS.Application.Services var groupids = questions.Where(x => x.Type != ReadingQestionType.Group).Select(x => x.GroupId).ToList(); var result = questions.Where(x => x.Type == ReadingQestionType.Group && groupids.Contains(x.Id)) - .WhereIf(groupClassifyList!=null,x=>x.GroupClassify!=null&& groupClassifyList.Contains(x.GroupClassify.Value)) + .WhereIf(groupClassifyList!=null,x=>x.GroupClassify!=null&& groupClassifyList!=null&& groupClassifyList.Contains(x.GroupClassify.Value)) .ToList(); foreach (var item in result) @@ -1342,7 +1342,7 @@ namespace IRaCIS.Application.Services answers.Add("OtherNumberOfFrames", rowInfo == null || rowInfo.OtherNumberOfFrames == null ? string.Empty : rowInfo.OtherNumberOfFrames.ToString()); answers.Add("OtherMarkTool", rowInfo == null || rowInfo.OtherMarkTool == null ? string.Empty : rowInfo.OtherMarkTool.ToString()); answers.Add("RowIndex", x.ToString()); - answers.Add("RowId", rowInfo.Id.ToString()); + answers.Add("RowId", rowInfo==null?string.Empty: rowInfo.Id.ToString()); answers.Add("MarkTool", rowInfo.MarkTool); answers.Add("StudyId", rowInfo.StudyId.ToString()); answers.Add("OrganInfoId", rowInfo.OrganInfoId.ToString()); @@ -1351,8 +1351,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 == null ? string.Empty : rowInfo.SplitName.IsNullOrEmpty() ? rowInfo.MergeName : rowInfo.SplitName); + answers.Add("SplitOrMergeType", rowInfo == null ? string.Empty : rowInfo.SplitOrMergeType == null ? string.Empty : ((int)rowInfo.SplitOrMergeType).ToString()); answers.Add("LastTaskState", lastTaskTableAnswer.Where(n=>n.QuestionId== item.Id&&n.ReadingTableQuestionTrial.QuestionMark==QuestionMark.State&&n.RowIndex==x).Select(n=>n.Answer).FirstOrDefault()??string.Empty); answers.Add("LastTaskMajorAxis", lastTaskTableAnswer.Where(n => n.QuestionId == item.Id && n.ReadingTableQuestionTrial.QuestionMark == QuestionMark.MajorAxis && n.RowIndex == x).Select(n => n.Answer).FirstOrDefault() ?? string.Empty); answers.Add("LastTaskShortAxis", lastTaskTableAnswer.Where(n => n.QuestionId == item.Id && n.ReadingTableQuestionTrial.QuestionMark == QuestionMark.ShortAxis && n.RowIndex == x).Select(n => n.Answer).FirstOrDefault() ?? string.Empty); @@ -2086,7 +2086,7 @@ namespace IRaCIS.Application.Services } - ReadingTableAnswerRowInfo rowInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.Id == (inDto.RowId ?? default(Guid))).IgnoreAutoIncludes().FirstOrDefaultAsync(); + ReadingTableAnswerRowInfo? rowInfo = await _readingTableAnswerRowInfoRepository.Where(x => x.Id == (inDto.RowId ?? default(Guid))).IgnoreAutoIncludes().FirstOrDefaultAsync(); rowInfo = rowInfo == null ? new ReadingTableAnswerRowInfo() : rowInfo; @@ -2499,7 +2499,7 @@ namespace IRaCIS.Application.Services if (task.SubjectCode.IsNullOrEmpty()) { - task.SubjectCode = await _subjectRepository.Where(x => x.Id == task.SubjectId).Select(x => x.Code).FirstOrDefaultAsync(); + task.SubjectCode = await _subjectRepository.Where(x => x.Id == task.SubjectId).Select(x => x.Code).FirstNotNullAsync(); } await _visitTaskRepository.BatchUpdateNoTrackingAsync(x => x.Id == task.VisitTaskId && x.FirstReadingTime == null, x => new VisitTask() @@ -2521,7 +2521,7 @@ namespace IRaCIS.Application.Services x.CriterionType, x.IseCRFShowInDicomReading, x.IsReadingTaskViewInOrder, - }).FirstOrDefaultAsync(); + }).FirstNotNullAsync(); task.IsReadingShowPreviousResults = criterionInfo.IsReadingShowPreviousResults; task.IsReadingShowSubjectInfo = criterionInfo.IsReadingShowSubjectInfo; diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingJudgeTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingJudgeTaskService.cs index 79591cffe..6dae8b2d8 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingJudgeTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingJudgeTaskService.cs @@ -88,7 +88,7 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task GetJudgeReadingInfo(GetJudgeReadingInfo inDto) { - var visitTask = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstOrDefaultAsync(); + var visitTask = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).FirstNotNullAsync(); var criterionType = await _readingQuestionCriterionTrialRepository.Where(x => x.Id == visitTask.TrialReadingCriterionId).Select(x => x.CriterionType).FirstNotNullAsync(); @@ -185,7 +185,7 @@ namespace IRaCIS.Application.Services JudgeReadingInfoDto judgeReadingInfoDto = new JudgeReadingInfoDto() { - VisitId = globalTaskInfos[0].SourceSubjectVisitId.Value, + VisitId = globalTaskInfos[0].SourceSubjectVisitId!.Value, VisitName = globalTaskInfos[0].TaskBlindName, VisitTaskInfoList = new List(), }; @@ -213,7 +213,7 @@ namespace IRaCIS.Application.Services judgeReadingInfoDto.VisitTaskInfoList.Add(new JudgeReadingQuestion() { - ArmEnum = towtask.ArmEnum, + ArmEnum = towtask!.ArmEnum, VisitTaskId = towtask.Id, JudgeQuestionList = judgeQuestionTwoAnswer.Where(x => x.VisitTaskId == towtask.Id).OrderBy(x => x.ShowOrder) .Select(x => new JudgeQuestion() @@ -235,7 +235,7 @@ namespace IRaCIS.Application.Services { JudgeReadingInfoDto judgeReadingInfoDto = new JudgeReadingInfoDto() { - VisitId = taskList[0].SourceSubjectVisitId.Value, + VisitId = taskList[0].SourceSubjectVisitId!.Value, VisitName = taskList[0].TaskBlindName, VisitTaskInfoList = new List(), }; @@ -298,7 +298,7 @@ namespace IRaCIS.Application.Services { Answer = x.Answer, - QuestionId = x.QuestionId.Value, + QuestionId = x.QuestionId!.Value, QuestionName = x.QuestionName, QuestionGenre=x.QuestionGenre, DictionaryCode=x.DictionaryCode, @@ -320,7 +320,7 @@ namespace IRaCIS.Application.Services judgeReadingQuestion.JudgeQuestionList.Add(new JudgeQuestion() { - Answer = item.AfterQuestionList.Where(x => x.GlobalAnswerType == GlobalAnswerType.Reason).Select(x => x.Answer).FirstOrDefault(), + Answer = item.AfterQuestionList.Where(x => x.GlobalAnswerType == GlobalAnswerType.Reason).Select(x => x.Answer).FirstOrDefault()??string.Empty, QuestionType = JudgeReadingQuestionType.VisitRemark, QuestionName = "", }); @@ -338,7 +338,7 @@ namespace IRaCIS.Application.Services { Answer = x.Answer, - QuestionId = x.QuestionId.Value, + QuestionId = x.QuestionId==null?default(Guid): x.QuestionId.Value, QuestionName = x.QuestionName, QuestionGenre = x.QuestionGenre, DictionaryCode = x.DictionaryCode, @@ -363,7 +363,7 @@ namespace IRaCIS.Application.Services rTwoJudge.JudgeQuestionList.Add(new JudgeQuestion() { - Answer = twoItem.AfterQuestionList.Where(x => x.GlobalAnswerType == GlobalAnswerType.Reason).Select(x => x.Answer).FirstOrDefault(), + Answer = twoItem.AfterQuestionList.Where(x => x.GlobalAnswerType == GlobalAnswerType.Reason).Select(x => x.Answer).FirstOrDefault()??string.Empty, QuestionType = JudgeReadingQuestionType.VisitRemark, QuestionName = "", }); @@ -682,7 +682,7 @@ namespace IRaCIS.Application.Services List globalGroupTasks = newlist.GroupBy(x => new { x.QuestionId, x.AnswerGroup, x.JudgeType, x.AnswerCombination }).Select(x => new GroupTaskAnswerDto { - QuestionId = x.Key.QuestionId.Value, + QuestionId = x.Key.QuestionId!.Value, AnswerGroup = x.Key.AnswerGroup, AnswerCombination = x.Key.AnswerCombination, JudgeType = x.Key.JudgeType, @@ -741,7 +741,7 @@ namespace IRaCIS.Application.Services List globalGroupTasks = newlist.GroupBy(x => new { x.QuestionId, x.AnswerGroup, x.JudgeType, x.AnswerCombination }).Select(x => new GroupTaskAnswerDto { - QuestionId = x.Key.QuestionId.Value, + QuestionId = x.Key.QuestionId!.Value, AnswerGroup = x.Key.AnswerGroup, AnswerCombination = x.Key.AnswerCombination, JudgeType = x.Key.JudgeType, diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs index 4bd4fc119..fc8869b44 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs @@ -301,7 +301,7 @@ namespace IRaCIS.Application.Services //增加标准 var readModulequery = _readModuleRepository.AsQueryable().Where(x=>x.TrialReadingCriterionId == inDto.TrialReadingCriterionId); - var resultlist= await visitQuery.WhereIf(finalVisitNum != null&& finalVisitNum!=0, x => x.VisitNum <= finalVisitNum) + var resultlist= await visitQuery.WhereIf(finalVisitNum!=0, x => x.VisitNum <= finalVisitNum) .WhereIf(inDto.ReadingSetType== ReadingSetType.TumorReading, x => readModulequery.Where(y => y.SubjectVisitId == x.Id&&y.TrialReadingCriterionId== inDto.TrialReadingCriterionId && y.ReadingSetType == ReadingSetType.ImageReading).Count() > 0) .Where(x=>x.VisitNum> maxReadVisitNum) .Where(x=>!x.IsBaseLine) // 排除基线 diff --git a/IRaCIS.Core.Application/Service/Reading/ShortcutKey/ShortcutKeyService.cs b/IRaCIS.Core.Application/Service/Reading/ShortcutKey/ShortcutKeyService.cs index 6b484c41e..84f773f4e 100644 --- a/IRaCIS.Core.Application/Service/Reading/ShortcutKey/ShortcutKeyService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ShortcutKey/ShortcutKeyService.cs @@ -60,13 +60,13 @@ namespace IRaCIS.Core.Application.Service Id = x.Id, ImageToolType = inQuery.ImageToolType, ShortcutKeyEnum = int.Parse(x.Code), - Keyboardkey = isnull ? defaultkey.Keyboardkey : key.Keyboardkey, - AltKey = isnull ? false : key.AltKey, - CtrlKey = isnull ? false : key.CtrlKey, - MetaKey = isnull ? false : key.MetaKey, - ShiftKey = isnull && int.Parse(x.Code) == 11 ? true : isnull ? false : key.ShiftKey, - Text = isnull ? defaultkey.Text : key.Text, - Code = isnull ? defaultkey.Code : key.Code, + Keyboardkey = isnull ? defaultkey!.Keyboardkey : key!.Keyboardkey, + AltKey = isnull ? false : key!.AltKey, + CtrlKey = isnull ? false : key!.CtrlKey, + MetaKey = isnull ? false : key!.MetaKey, + ShiftKey = isnull && int.Parse(x.Code) == 11 ? true : isnull ? false : key!.ShiftKey, + Text = isnull ? defaultkey!.Text : key!.Text, + Code = isnull ? defaultkey!.Code : key!.Code, }); }); diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs index f5abb7d0f..6775d2157 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/IRECIST1Point1CalculateService.cs @@ -471,7 +471,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// /// /// - public async Task ReadingCalculate(ReadingCalculateDto inDto,List calculateType=null) + public async Task ReadingCalculate(ReadingCalculateDto inDto,List? calculateType=null) { #region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果 @@ -688,7 +688,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate else { - item.Answer = value.ToString(); + item.Answer = value==null?"": value.Value.ToString(); } } else if (calculate.GetStringFun != null) @@ -704,7 +704,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate ValueOfType.Percentage }; - if (inDto.DigitPlaces != null && inDto.DigitPlaces != -1) + if (inDto.DigitPlaces != -1) { try { @@ -2751,55 +2751,55 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 逻辑改了 现在转变后全部都是NA; return NewLesionAssessment.NA.GetEnumInt(); - NewLesionAssessment result = NewLesionAssessment.No; - if (inDto.IsBaseLine) - { - return NewLesionAssessment.NA.GetEnumInt(); - } + //NewLesionAssessment result = NewLesionAssessment.No; + //if (inDto.IsBaseLine) + //{ + // return NewLesionAssessment.NA.GetEnumInt(); + //} - var newTargetQuestions = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.NewTargetLesion).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList).ToList(); + //var newTargetQuestions = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.NewTargetLesion).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList).ToList(); - var newNonTargetQuestions = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.NewNonTargetLesion).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList).ToList(); + //var newNonTargetQuestions = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.NewNonTargetLesion).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList).ToList(); - var OtherPreviousNewLesionQuestions = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.OtherPreviousNewLesion).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList).ToList(); + //var OtherPreviousNewLesionQuestions = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.OtherPreviousNewLesion).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList).ToList(); - var triggeringQuestions = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TriggeringIRECSIT).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList).ToList(); + //var triggeringQuestions = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TriggeringIRECSIT).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList).ToList(); - // 当前访视存在至少一个明确新病灶 - if (newTargetQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewTargetLesionState.Exist)) - || newNonTargetQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewNoTargetLesionState.Exist)) - || OtherPreviousNewLesionQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(OtherPreviousNewLesionState.Exists)) - || triggeringQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionAfterTriggeringiRECSITState.Exist)) + //// 当前访视存在至少一个明确新病灶 + //if (newTargetQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewTargetLesionState.Exist)) + // || newNonTargetQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewNoTargetLesionState.Exist)) + // || OtherPreviousNewLesionQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(OtherPreviousNewLesionState.Exists)) + // || triggeringQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionAfterTriggeringiRECSITState.Exist)) - ) - { - result = NewLesionAssessment.Yes; - } - //只要有任何一个新病灶状态为“无法评估” - else if (newTargetQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewTargetLesionState.NotEvaluable)) - || newNonTargetQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewNoTargetLesionState.NotEvaluable)) - || OtherPreviousNewLesionQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(OtherPreviousNewLesionState.NotEvaluable)) - || triggeringQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionAfterTriggeringiRECSITState.NotEvaluable)) + // ) + //{ + // result = NewLesionAssessment.Yes; + //} + ////只要有任何一个新病灶状态为“无法评估” + //else if (newTargetQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewTargetLesionState.NotEvaluable)) + // || newNonTargetQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewNoTargetLesionState.NotEvaluable)) + // || OtherPreviousNewLesionQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(OtherPreviousNewLesionState.NotEvaluable)) + // || triggeringQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionAfterTriggeringiRECSITState.NotEvaluable)) - ) - { - result = NewLesionAssessment.NE; - } - //当前访视不存在明确新病灶且存在至少一个疑似新病灶 - else if ( (!OtherPreviousNewLesionQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(OtherPreviousNewLesionState.Exists)) && OtherPreviousNewLesionQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(OtherPreviousNewLesionState.Equivocal))) - || (!triggeringQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionAfterTriggeringiRECSITState.Exist)) && triggeringQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionAfterTriggeringiRECSITState.Equivocal))) + // ) + //{ + // result = NewLesionAssessment.NE; + //} + ////当前访视不存在明确新病灶且存在至少一个疑似新病灶 + //else if ( (!OtherPreviousNewLesionQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(OtherPreviousNewLesionState.Exists)) && OtherPreviousNewLesionQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(OtherPreviousNewLesionState.Equivocal))) + // || (!triggeringQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionAfterTriggeringiRECSITState.Exist)) && triggeringQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionAfterTriggeringiRECSITState.Equivocal))) - ) - { - result = NewLesionAssessment.Suspected; - } + // ) + //{ + // result = NewLesionAssessment.Suspected; + //} - else - { - result = NewLesionAssessment.No; - } - return result.GetEnumInt(); + //else + //{ + // result = NewLesionAssessment.No; + //} + //return result.GetEnumInt(); } #endregion @@ -3156,7 +3156,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate catch (Exception) { - return beforeConvertedAnswer; + return beforeConvertedAnswer==null?string.Empty: beforeConvertedAnswer; } @@ -3191,9 +3191,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate catch (Exception) { - return beforeConvertedAnswer; + return beforeConvertedAnswer == null ? string.Empty : beforeConvertedAnswer; - } + } } #endregion @@ -3225,9 +3225,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate catch (Exception) { - return beforeConvertedAnswer; + return beforeConvertedAnswer == null ? string.Empty : beforeConvertedAnswer; - } + } } #endregion #endregion diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs index 6498593d7..b598ef10b 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/LuganoCalculateService.cs @@ -123,7 +123,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var tableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == indto.VisitTaskId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); result.LesionCountList = tableAnsweRowInfos.GroupBy(x => x.LesionType).Select(x => new LesionDto { - LesionType = x.Key.Value, + LesionType = x.Key, Count = x.ToList().Count() }).ToList(); var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); @@ -396,7 +396,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate x.VisitTaskId }).OrderBy(x => x.Answer).Select(x => x.VisitTaskId).FirstOrDefault(); - if (lowPddTaskid != null && lowPddTaskid != default(Guid)) + if (lowPddTaskid != default(Guid)) { var lowPPDAnswerList = await _readingTableQuestionAnswerRepository.Where(x =>x.VisitTaskId== lowPddTaskid @@ -456,7 +456,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// /// /// - public async Task ReadingCalculate(ReadingCalculateDto inDto, List calculateType = null) + public async Task ReadingCalculate(ReadingCalculateDto inDto, List? calculateType = null) { #region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果 @@ -662,7 +662,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate else { - item.Answer = value.ToString(); + item.Answer = value==null?string.Empty: value.ToString(); } } else if (calculate.GetStringFun != null) @@ -678,7 +678,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate ValueOfType.Percentage }; - if (inDto.DigitPlaces != null && inDto.DigitPlaces != -1) + if (inDto.DigitPlaces != -1) { try { @@ -949,16 +949,16 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate switch (x.QuestionMark) { case QuestionMark.LowPPDLDi: - x.Answer = lowPPD.LowPPDLDi.ToString(); + x.Answer = lowPPD.LowPPDLDi==null?string.Empty: lowPPD.LowPPDLDi.Value.ToString(); break; case QuestionMark.LowPPDSDi: - x.Answer = lowPPD.LowPPDSDi.ToString(); + x.Answer = lowPPD.LowPPDSDi == null ? string.Empty : lowPPD.LowPPDSDi.Value.ToString(); break; case QuestionMark.NadirPPD: - x.Answer = lowPPD.NadirPPD.ToString(); + x.Answer = lowPPD.NadirPPD == null ? string.Empty : lowPPD.NadirPPD.Value.ToString(); break; case QuestionMark.LowPPDVisit: - x.Answer = lowPPD.LowPPDVisit.ToString(); + x.Answer = lowPPD.LowPPDVisit == null ? string.Empty : lowPPD.LowPPDVisit.ToString(); break; @@ -2059,7 +2059,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var answer =await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == lastTaskId).Include(x => x.ReadingQuestionTrial).Where(x => x.ReadingQuestionTrial.QuestionType == QuestionType.FDGPET).Select(x => x.Answer).FirstOrDefaultAsync(); - return answer; + return answer?? string.Empty; } #region FDG-PET总体评估结果 @@ -2077,7 +2077,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate return FDGPETOverallAssessment.NA.GetEnumInt(); } - FDGPETOverallAssessment result = FDGPETOverallAssessment.NA; + //FDGPETOverallAssessment result = FDGPETOverallAssessment.NA; // PET5PS var PET5PS = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.PET5PS).Select(x => x.Answer).FirstOrDefault(); @@ -2174,7 +2174,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate } else { - return inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.EvidenceFocalFDG).Select(x => x.Answer).FirstOrDefault(); + return inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.EvidenceFocalFDG).Select(x => x.Answer).FirstOrDefault()??string.Empty; } } #endregion @@ -2218,7 +2218,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate } else { - var orderMark = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).FirstOrDefault().OrderMark; + var orderMark = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).FirstOrDefault()!.OrderMark; return orderMark+ maxSuv.RowIndex.GetLesionMark(); } diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs index 6a535fc53..62c0e9369 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/PCWG3CalculateService.cs @@ -61,7 +61,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository; } - private List siteVisitForTumorList = null; + private List siteVisitForTumorList = new List(); #region 删除病灶获取起始病灶序号 @@ -536,7 +536,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// /// /// - public async Task ReadingCalculate(ReadingCalculateDto inDto, List calculateType = null) + public async Task ReadingCalculate(ReadingCalculateDto inDto, List? calculateType = null) { #region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果 @@ -815,7 +815,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate if (lastTask != null) { var thisTask = taskList.FirstOrDefault(); - if (thisTask.StudyTime != null && lastTask.StudyTime != null) + if (thisTask!=null&& thisTask.StudyTime != null && lastTask.StudyTime != null) { return (int)Math.Floor((thisTask.StudyTime.Value - lastTask.StudyTime.Value).TotalDays); } @@ -898,14 +898,14 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var firstVisit = taskList.FirstOrDefault(); - if (baseLineTask.StudyTime != null) + if (baseLineTask!=null&&baseLineTask.StudyTime != null) { //基线后第二个访视(应满足访视间隔6周以上,否则顺延) var secondVisit = taskList.Where(x => x.VisitTaskNum >= 2 && x.StudyTime >= baseLineTask.StudyTime.Value.AddDays(42)).FirstOrDefault(); if (secondVisit != null) { - var firstTaskNewLesionsCount = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == firstVisit.VisitTaskId && x.ReadingQuestionTrialId == newLesionsCountQuestionId).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); + var firstTaskNewLesionsCount = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == firstVisit!.VisitTaskId && x.ReadingQuestionTrialId == newLesionsCountQuestionId).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); // 第二访视数量 var secondVisitLesionsCount = (await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == lastTask.VisitTaskId && x.ReadingQuestionTrialId == newLesionsCountQuestionId).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0(); @@ -934,7 +934,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var thisVisitTask = taskList.LastOrDefault(); - if (thisVisitTask.StudyTime!=null&&lastTask.StudyTime!=null&& + if (thisVisitTask!=null &&thisVisitTask.StudyTime!=null&&lastTask.StudyTime!=null&& lastTasknewLesionsCount >= 2 && thisVisitTaskNewLesionsCount >= 2 && lastTask.StudyTime.Value.AddDays(42) <= thisVisitTask.StudyTime) @@ -949,10 +949,13 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate { var visitForTumorEvaluationQuestionId = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.SiteVisitForTumorEvaluation).Select(x => x.QuestionId).FirstOrDefault(); - await _readingTaskQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.VisitTaskId == lastTask.VisitTaskId && x.ReadingQuestionTrialId == visitForTumorEvaluationQuestionId,x=> new ReadingTaskQuestionAnswer + if(lastTask!=null) { - Answer= VisitTumorEvaluation.PD.GetEnumInt(), - }); + await _readingTaskQuestionAnswerRepository.BatchUpdateNoTrackingAsync(x => x.VisitTaskId == lastTask.VisitTaskId && x.ReadingQuestionTrialId == visitForTumorEvaluationQuestionId, x => new ReadingTaskQuestionAnswer + { + Answer = VisitTumorEvaluation.PD.GetEnumInt(), + }); + } } diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1CalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1CalculateService.cs index 957bb2abf..515db4c46 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1CalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1CalculateService.cs @@ -111,7 +111,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var tableAnsweRowInfos = await _readingTableAnswerRowInfoRepository.Where(x => x.VisitTaskId == indto.VisitTaskId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); result.LesionCountList = tableAnsweRowInfos.GroupBy(x => x.LesionType).Select(x => new LesionDto { - LesionType = x.Key.Value, + LesionType = x.Key!.Value, Count = x.ToList().Count() }).ToList(); var answers = await _readingTaskQuestionAnswerRepository.Where(x => visitTaskIds.Contains(x.VisitTaskId)).ToListAsync(); @@ -387,7 +387,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// /// /// - public async Task ReadingCalculate(ReadingCalculateDto inDto,List calculateType=null) + public async Task ReadingCalculate(ReadingCalculateDto inDto,List? calculateType=null) { #region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果 @@ -526,7 +526,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate else { - item.Answer = value.ToString(); + item.Answer = value==null?string.Empty: value.Value.ToString(); } } else if (calculate.GetStringFun != null) @@ -542,7 +542,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate ValueOfType.Percentage }; - if (inDto.DigitPlaces != null && inDto.DigitPlaces != -1) + if (inDto.DigitPlaces != -1) { try { diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1_BMCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1_BMCalculateService.cs index 635651259..36bdf7a80 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1_BMCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/RECIST1Point1_BMCalculateService.cs @@ -383,7 +383,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// /// /// - public async Task ReadingCalculate(ReadingCalculateDto inDto,List calculateType=null) + public async Task ReadingCalculate(ReadingCalculateDto inDto,List? calculateType=null) { #region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果 @@ -522,7 +522,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate else { - item.Answer = value.ToString(); + item.Answer = value==null?string.Empty: value.ToString(); } } else if (calculate.GetStringFun != null) @@ -538,7 +538,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate ValueOfType.Percentage }; - if (inDto.DigitPlaces != null && inDto.DigitPlaces != -1) + if (inDto.DigitPlaces != -1) { try { diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs index 7e2263f4d..7166ecf13 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/SelfDefineCalculateService.cs @@ -61,7 +61,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository; } - private List siteVisitForTumorList = null; + private List siteVisitForTumorList = new List() ; #region 删除病灶获取起始病灶序号 @@ -488,7 +488,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// /// /// - public async Task ReadingCalculate(ReadingCalculateDto inDto, List calculateType = null) + public async Task ReadingCalculate(ReadingCalculateDto inDto, List? calculateType = null) { //var questionList = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.CriterionId && x.CustomCalculateMark != null).ToListAsync(); //var tableQuestionList = await _readingTableQuestionTrialRepository.Where(x => x.TrialCriterionId == inDto.CriterionId && x.CustomCalculateMark != null).ToListAsync();