diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs index b244a892c..c587a14b1 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingCalculateService.cs @@ -167,7 +167,8 @@ namespace IRaCIS.Core.Application.Service { if (typeNAList.Contains(item.QuestionType ?? QuestionType.SOD)) { - item.Answer = "NA"; + item.Answer = nameof(YesOrNoOrNa.NA); + } else { @@ -379,13 +380,13 @@ namespace IRaCIS.Core.Application.Service foreach (var item in tableQuestion) { - if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是"||x.Answer.ToLower()=="true".ToLower()))) + if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph &&x.Answer.EqEnum(YesOrNoOrNa.Yes))) { // 淋巴结的短径 result += (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()))) + if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && x.Answer.EqEnum(YesOrNoOrNa.Yes))) { // 非淋巴结的长径 result += item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0(); @@ -420,7 +421,7 @@ namespace IRaCIS.Core.Application.Service foreach (var item in tableQuestion) { - if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是" || x.Answer.ToLower() == "false".ToLower()))) + if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && x.Answer.EqEnum(YesOrNoOrNa.Yes))) { // 非淋巴结的长径 result += item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0(); @@ -546,7 +547,7 @@ namespace IRaCIS.Core.Application.Service { if (inDto.IsBaseLine) { - return "NA"; + return nameof(YesOrNoOrNa.NA); } var decimalAnswerList = await GetVisitTaskAnswerList(inDto); @@ -562,17 +563,20 @@ namespace IRaCIS.Core.Application.Service /// public async Task GetIsLymphTarget(ReadingCalculateDto inDto) { + var result = string.Empty; var tableQuestion = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).SelectMany(x => x.TableRowInfoList).ToList(); foreach (var item in tableQuestion) { - if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是" || x.Answer.ToLower() == "true".ToLower()))) + if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && x.Answer.EqEnum(IsLymph.Yes))) { - return "是"; + result= IsLymph.Yes.GetEnumInt(); } } - return "否"; + result = IsLymph.No.GetEnumInt(); + + return result; } #endregion @@ -586,14 +590,14 @@ namespace IRaCIS.Core.Application.Service { if (inDto.IsBaseLine) { - return "NA"; + return nameof(YesOrNoOrNa.NA); } var LastVisitTaskId = await this.GetLastVisitTaskId(inDto); var questionIds = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).Select(x => x.QuestionId).ToList(); var lastQuestionAsnwer = await _readingTableQuestionAnswerRepository.Where(x => x.VisitTaskId == LastVisitTaskId && questionIds.Contains(x.QuestionId)).Include(x=>x.ReadingQuestionTrial).Include(x => x.ReadingTableQuestionTrial).ToListAsync(); - var rowIndexs = lastQuestionAsnwer.Where(x=>x.ReadingTableQuestionTrial.QuestionMark==QuestionMark.IsLymph&& (x.Answer == "是" || x.Answer.ToLower() == "true".ToLower())).Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToList(); + var rowIndexs = lastQuestionAsnwer.Where(x=>x.ReadingTableQuestionTrial.QuestionMark==QuestionMark.IsLymph&& x.Answer.EqEnum(YesOrNoOrNa.Yes)).Select(x => x.RowIndex).Distinct().OrderBy(x => x).ToList(); var thisQuestionAsnwer = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).SelectMany(x => x.TableRowInfoList).ToList(); var isExists = false; @@ -610,7 +614,7 @@ namespace IRaCIS.Core.Application.Service } } - return isExists?"是":"否"; + return isExists? nameof(YesOrNoOrNa.Yes) : nameof(YesOrNoOrNa.No); } #endregion @@ -625,12 +629,12 @@ namespace IRaCIS.Core.Application.Service { if (inDto.IsBaseLine) { - return "NA"; + return nameof(ExistOrNA.NA); } var result = inDto.QuestionInfo.Any(x => x.QuestionType == QuestionType.TargetLesion && x.Answer.EqEnum(TargetAssessment.NE)); - return result ? "有" : "无"; + return result ? nameof(ExistOrNA.Exist) : nameof(ExistOrNA.NotExist); } #endregion @@ -646,7 +650,7 @@ namespace IRaCIS.Core.Application.Service if (inDto.IsBaseLine) { - return "NA"; + return nameof(YesOrNoOrNa.NA); } var targetLesion = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.TargetLesion).Select(x => x.Answer).FirstOrDefault(); @@ -842,7 +846,7 @@ namespace IRaCIS.Core.Application.Service var tableQuestion = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.TargetLesion).SelectMany(x => x.TableRowInfoList).ToList(); if (inDto.IsBaseLine) { - return "NA"; + return nameof(TargetAssessment.NA); } if (tableQuestion.Count() == 0) { @@ -875,7 +879,7 @@ namespace IRaCIS.Core.Application.Service LowChangeBigger5 = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.LowestIncrease).Sum(x => x.Answer.IsNullOrEmptyReturn0()) >= 5, // 被评估为NE的单个靶病灶 是否存在状态为不可评估的靶病灶 - ExixtsNETargetLesion = tableQuestion.SelectMany(x => x.TableQuestionList).Any(x => x.QuestionMark == QuestionMark.State && x.Answer == "不可评估"), + ExixtsNETargetLesion = tableQuestion.SelectMany(x => x.TableQuestionList).Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(TargetState.UnableEvaluate)), //// 上次访视点整体肿瘤评估 LastTargetLesionEvaluate = string.Empty, @@ -887,7 +891,7 @@ namespace IRaCIS.Core.Application.Service CurrenShortBigger10 = true, // 该淋巴结靶病灶短径绝对增加值≥5 mm - IsAddFive = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.IsAddFive && x.Answer == "是").Count() > 0, + IsAddFive = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.IsAddFive && x.Answer.EqEnum(YesOrNoOrNa.Yes)).Count() > 0, }; @@ -895,7 +899,7 @@ namespace IRaCIS.Core.Application.Service foreach (var item in tableQuestion) { - if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "是" || x.Answer.ToLower() == "true".ToLower()))) + if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && x.Answer.EqEnum(YesOrNoOrNa.Yes))) { // 淋巴结的短径 resultData.DiameterLessThan10 = (item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault()).IsNullOrEmptyReturn0() < 10; @@ -904,7 +908,7 @@ namespace IRaCIS.Core.Application.Service resultData.CurrenShortBigger10 = (item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.ShortAxis).Select(x => x.Answer).FirstOrDefault()).IsNullOrEmptyReturn0() >= 10; } - if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && (x.Answer == "否" || x.Answer.ToLower() == "false".ToLower()))) + if (item.TableQuestionList.Any(x => x.QuestionMark == QuestionMark.IsLymph && !x.Answer.EqEnum(YesOrNoOrNa.Yes))) { // 当前访视点非淋巴结病灶 resultData.CurrentMajoreBigger0 = (item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.MajorAxis).Select(x => x.Answer).FirstOrDefault()).IsNullOrEmptyReturn0() > 0; @@ -921,10 +925,10 @@ namespace IRaCIS.Core.Application.Service - string result = string.Empty; + TargetAssessment result = TargetAssessment.NA; if (resultData.SumOfDiameter == 0 && resultData.DiameterLessThan10 && !resultData.ExixtsNETargetLesion) { - result = "CR"; + result = TargetAssessment.CR; } else if ( (resultData.SODPercentBigger30 && resultData.LowPercentLess20 && !resultData.ExixtsNETargetLesion) @@ -932,7 +936,7 @@ namespace IRaCIS.Core.Application.Service (resultData.SODPercentBigger30 && resultData.LowChangeLess5 && !resultData.ExixtsNETargetLesion) ) { - result = "PR"; + result = TargetAssessment.PR; } else if ( (resultData.SODPercentLess30 && resultData.LowPercentLess20 && !resultData.ExixtsNETargetLesion) @@ -940,11 +944,11 @@ namespace IRaCIS.Core.Application.Service (resultData.SODPercentLess30 && resultData.LowChangeLess5 && !resultData.ExixtsNETargetLesion) ) { - result = "SD"; + result = TargetAssessment.SD; } else if (resultData.LowPercentBigger20 && resultData.LowChangeBigger5) { - result = "PD"; + result = TargetAssessment.PD; } else if ( (resultData.LowPercentLess20 && resultData.ExixtsNETargetLesion) @@ -952,25 +956,25 @@ namespace IRaCIS.Core.Application.Service (resultData.LowPercentBigger20 && resultData.LowChangeLess5 && resultData.ExixtsNETargetLesion) ) { - result = "NE"; + result = TargetAssessment.NE; } else if (!resultData.ExixtsNETargetLesion) { - result = "ND"; + result = TargetAssessment.ND; } else if ( - (resultData.LastTargetLesionEvaluate == "CR" && resultData.CurrenShortBigger10 && resultData.IsAddFive) + (resultData.LastTargetLesionEvaluate.EqEnum(TargetAssessment.CR) && resultData.CurrenShortBigger10 && resultData.IsAddFive) || - (resultData.LastTargetLesionEvaluate == "CR" && resultData.CurrentMajoreBigger0) + (resultData.LastTargetLesionEvaluate.EqEnum(TargetAssessment.CR) && resultData.CurrentMajoreBigger0) ) { - result = "PD"; + result = TargetAssessment.PD; } - return result; + return result.GetEnumInt(); } #endregion @@ -983,9 +987,12 @@ namespace IRaCIS.Core.Application.Service /// public async Task GetNoTargetLesionEvaluate(ReadingCalculateDto inDto) { + + NoTargetAssessment result = NoTargetAssessment.NA; + if (inDto.IsBaseLine) { - return "NA"; + return result.GetEnumInt(); } var tableRows = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.NonTargetLesions).SelectMany(x => x.TableRowInfoList).ToList(); @@ -993,43 +1000,45 @@ namespace IRaCIS.Core.Application.Service var tableQuestions = tableRows.SelectMany(x => x.TableQuestionList).ToList(); //任意单个病灶 / 病灶组评估为“显著增大” - if (tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer == "显著增大")) + if (tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NoTargetState.Increase))) { - return "PD"; + result = NoTargetAssessment.PD; } //所有单个病灶/病灶组状态评估状态为“消失” - else if (!tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer != "消失")) + else if (!tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NoTargetState.Loss) )) { - return "PD"; - } + result = NoTargetAssessment.PD; + } // 任意单个病灶/病灶组评估为“无法评估”并且没有“显著增大” - else if (tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer == "无法评估") && - !tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer != "显著增大") + else if (tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NoTargetState.Increase)) && + !tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && !x.Answer.EqEnum(NoTargetState.Increase) ) ) { - return "NE"; - } + result = NoTargetAssessment.NE; + } // 基线时没有非靶病灶 else if (tableQuestions.Count() == 0) { - return "ND"; - } + result = NoTargetAssessment.ND; + } // 所有单个病灶/病灶组评估为”存在”或者有些评估为“消失”有些评估为“存在”,且没有“显著增大”和“无法评估”的病灶 - else if (!tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer != "存在") - || (tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer == "存在" || x.Answer == "消失") && !tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && (x.Answer != "显著增大" || x.Answer != "无法评估"))) + else if (!tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && !x.Answer.EqEnum(NoTargetState.Exist)) + || (tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NoTargetState.Exist) || x.Answer.EqEnum(NoTargetState.Loss)) && !tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && (x.Answer != "显著增大" || x.Answer != "无法评估"))) ) { - return "NN"; - } + result = NoTargetAssessment.NN; + } else { return string.Empty; } - } + return result.GetEnumInt(); + + } #endregion @@ -1041,9 +1050,11 @@ namespace IRaCIS.Core.Application.Service /// public async Task GetNewLesionEvaluate(ReadingCalculateDto inDto) { + + NewLesionAssessment result = NewLesionAssessment.NA; if (inDto.IsBaseLine) { - return "NA"; + return result.GetEnumInt(); } var tableRows = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.NewLesions).SelectMany(x => x.TableRowInfoList).ToList(); @@ -1053,29 +1064,30 @@ namespace IRaCIS.Core.Application.Service // 当前访视存在至少一个明确新病灶 - if (tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer == "明确")) + if (tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionState.Exist))) { - return "是"; + result= NewLesionAssessment.Yes; } //当前访视不存在明确新病灶且存在至少一个疑似新病灶 - else if (!tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer != "明确") || - tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer == "疑似") + else if (!tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && !x.Answer.EqEnum(NewLesionState.Exist)) || + tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionState.Suspected)) ) { - return "疑似"; + result = NewLesionAssessment.Suspected; } //只要有任何一个新病灶状态为“无法评估” - else if (tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer == "无法评估")) + else if (tableQuestions.Any(x => x.QuestionMark == QuestionMark.State && x.Answer.EqEnum(NewLesionState.UnableEvaluate))) { - return "NE"; + result = NewLesionAssessment.NE; } else { - return "否"; + result = NewLesionAssessment.No; } + return result.GetEnumInt(); - } + } #endregion #endregion diff --git a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs index d4bb36ea0..7e57d047c 100644 --- a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs +++ b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs @@ -16,6 +16,221 @@ namespace IRaCIS.Core.Domain.Share public static readonly string Group = "group"; } + /// + /// 是否存在或者NA + /// + public enum ExistOrNA + { + + /// + /// 不存在 + /// + NotExist = 0, + + /// + /// 存在 + /// + Exist = 1, + + /// + /// NA + /// + NA = 2 + } + + /// + /// 是否存在(是否存在和NA) + /// + public enum YesOrNoOrNa + { + + /// + /// 否 + /// + No = 0, + + /// + /// 是 + /// + Yes = 1, + + /// + /// NA + /// + NA = 2 + } + + /// + /// 是否淋巴结 + /// + public enum IsLymph + { + + /// + /// 否 + /// + No = 0, + + /// + /// 是 + /// + Yes = 1 + } + + /// + /// 整体肿瘤评估 + /// + public enum OverallAssessment + { + /// + /// CR + /// + CR = 0, + + /// + /// ND + /// + ND = 1, + + /// + /// NE + /// + NE = 2, + + /// + /// NN + /// + NN = 3, + + /// + /// PD + /// + PD = 4, + + /// + /// PR + /// + PR = 5, + + /// + /// SD + /// + SD = 6, + + /// + /// NA + /// + NA = 6 + } + + /// + /// 新病灶评估 + /// + public enum NewLesionAssessment + { + + /// + /// 是 + /// + Yes = 0, + + /// + /// 疑似 + /// + Suspected = 1, + + /// + /// NE + /// + NE = 2, + + /// + /// 否 + /// + No = 3, + + /// + /// NA + /// + NA = 4 + } + + /// + /// 非靶病灶评估 + /// + public enum NoTargetAssessment + { + /// + /// PD + /// + PD = 0, + + /// + /// CR + /// + CR = 1, + + /// + /// NE + /// + NE = 2, + + /// + /// ND + /// + ND = 3, + + /// + /// NN + /// + NN = 4, + + /// + /// NA + /// + NA = 5 + } + + /// + /// 靶病灶评估 + /// + public enum TargetAssessment + { + /// + /// CR + /// + CR = 0, + + /// + /// PR + /// + PR = 1, + + /// + /// SD + /// + SD = 2, + + /// + /// PD + /// + PD = 3, + + /// + /// NE + /// + NE = 4, + + /// + /// ND + /// + ND = 5, + + /// + /// NA + /// + NA = 6 + } /// diff --git a/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs b/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs index d526d5ae5..17ee93a2d 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/ReadingCommon.cs @@ -38,6 +38,20 @@ namespace IRaCIS.Core.Infra.EFCore.Common } } + + /// + /// 获取枚举Int值 + /// + /// + /// + /// + public static string GetEnumInt(this T value) where T : Enum + { + + return ((int)(object)value).ToString(); + } + + /// /// 字符匹配枚举 /// @@ -49,7 +63,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common { try { - return int.Parse(value) == int.Parse(enumValue.ToString()); + return int.Parse(value) == (int)(object)enumValue; } catch (Exception) {