diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs index 8ee6520bf..80105ea76 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs @@ -10,6 +10,7 @@ using IRaCIS.Core.Application.Interfaces; using IRaCIS.Core.Application.ViewModel; using Panda.DynamicWebApi.Attributes; using IRaCIS.Core.Domain.Share; +using IRaCIS.Core.Infra.EFCore.Common; namespace IRaCIS.Core.Application.Service { @@ -254,13 +255,13 @@ namespace IRaCIS.Core.Application.Service if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是"||x.Answer.ToLower()=="true".ToLower()))) { // 淋巴结的短径 - result += decimal.Parse(item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault() ?? "0"); + result += decimal.Parse((item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault()).IsNullOrEmptyReturn0()); } if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是" || x.Answer.ToLower() == "true".ToLower()))) { // 非淋巴结的长径 - result += decimal.Parse(item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Answer).FirstOrDefault() ?? "0"); + result += decimal.Parse(item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0()); } } @@ -288,7 +289,7 @@ namespace IRaCIS.Core.Application.Service if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是" || x.Answer.ToLower() == "false".ToLower()))) { // 非淋巴结的长径 - result += decimal.Parse(item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Answer).FirstOrDefault() ?? "0"); + result += decimal.Parse(item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0()); } } @@ -434,10 +435,10 @@ namespace IRaCIS.Core.Application.Service var isExists = false; foreach (var item in rowIndexs) { - var lastValue = decimal.Parse(lastQuestionAsnwer.Where(x => x.RowIndex == item && x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault() ?? "0"); + var lastValue = decimal.Parse(lastQuestionAsnwer.Where(x => x.RowIndex == item && x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0()); var thisRowData = thisQuestionAsnwer.Where(x => x.RowIndex == item).SelectMany(x => x.TableQuestionList).ToList(); - var thisValue = decimal.Parse(thisRowData.Where(x => x.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault() ?? "0"); + var thisValue = decimal.Parse(thisRowData.Where(x => x.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0()); if (thisValue - lastValue > 5) { @@ -504,7 +505,7 @@ namespace IRaCIS.Core.Application.Service .Select(x => x.Id).FirstOrDefaultAsync(); - var baseLineSOD = decimal.Parse(await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == baseLineTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.SOD).Select(x => x.Answer).FirstOrDefaultAsync() ?? "0"); + var baseLineSOD = decimal.Parse((await _readingTaskQuestionAnswerRepository.Where(x => x.VisitTaskId == baseLineTaskId && x.ReadingQuestionTrial.QuestionType == QuestionType.SOD).Select(x => x.Answer).FirstOrDefaultAsync()).IsNullOrEmptyReturn0()); return baseLineSOD; } #endregion @@ -528,7 +529,7 @@ namespace IRaCIS.Core.Application.Service var decimalAnswerList = answerList.Select(x => new VisitTaskAnswerInfo { VisitName = x.VisitName, - SOD = decimal.Parse(x.SOD ?? "0"), + SOD = decimal.Parse(x.SOD.IsNullOrEmptyReturn0()), }).ToList(); return decimalAnswerList; diff --git a/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs b/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs index 8c679c9f6..f02fe9c2c 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs @@ -38,7 +38,20 @@ namespace IRaCIS.Core.Infra.EFCore.Common } } - + public static string IsNullOrEmptyReturn0(this string value) + { + if (value == null || value == string.Empty) + { + return "0"; + + } + else + { + return value; + } + } + + /// /// 获取DisplayName