diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs index baea61a56..80c66feed 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs @@ -208,10 +208,10 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto /// public class IVUSMeasuredValue { - /// - /// 斑块编号 - /// - public int PlaqueNum { get; set; } + ///// + ///// 斑块编号 + ///// + //public int PlaqueNum { get; set; } /// /// 外弹力膜面积Emm diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs index e8ac11541..6b0a47865 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs @@ -11,6 +11,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; using Microsoft.IdentityModel.Tokens; using MiniExcelLibs; +using System; namespace IRaCIS.Core.Application.Service.ReadingCalculate { @@ -273,7 +274,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate /// public async Task ReadingCalculate(ReadingCalculateDto inDto, List? calculateType = null) { - return; + #region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果 var needAddList = new List(); @@ -284,23 +285,34 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate ComputationTrigger.SaveEICRFQuestions, }; - if (!computationTriggers.Contains(inDto.ComputationTrigger)) - { - // 计算斑块统计数据 - await this.CalculatePatchDataStatisticsAndPVA(inDto); - inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId); - } + //if (!computationTriggers.Contains(inDto.ComputationTrigger)) + //{ + // // 计算斑块统计数据 + // await this.CalculatePatchDataStatisticsAndPVA(inDto); + // inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId); + //} List calculateList = new List() { - // 斑块1-PAV - new ReadingCalculateData (){QuestionType=QuestionType.Plaque1PVA,GetDecimalNullFun=GetPlaque1PVA}, + //// 斑块1-PAV + //new ReadingCalculateData (){QuestionType=QuestionType.Plaque1PVA,GetDecimalNullFun=GetPlaque1PVA}, + + // // 斑块2-PAV + //new ReadingCalculateData (){QuestionType=QuestionType.Plaque2PVA,GetDecimalNullFun=GetPlaque2PVA}, + + // // 斑块3-PAV + //new ReadingCalculateData (){QuestionType=QuestionType.Plaque3PVA,GetDecimalNullFun=GetPlaque3PVA}, + + + // (EEM-Lumen)求和 + new ReadingCalculateData (){QuestionType=QuestionType.EEMSum,GetDecimalNullFun=GetEmmSum}, // 斑块2-PAV - new ReadingCalculateData (){QuestionType=QuestionType.Plaque2PVA,GetDecimalNullFun=GetPlaque2PVA}, + new ReadingCalculateData (){QuestionType=QuestionType.EEMSubLumenSum,GetDecimalNullFun=GetEEMLumenSum}, + + // PAV(冠状动脉粥样硬化体积百分比) + new ReadingCalculateData (){QuestionType=QuestionType.PAV,GetDecimalNullFun=GetPAV}, - // 斑块3-PAV - new ReadingCalculateData (){QuestionType=QuestionType.Plaque3PVA,GetDecimalNullFun=GetPlaque3PVA}, @@ -471,9 +483,9 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate { iVUSMeasuredValue = new IVUSMeasuredValue() { - PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()), - Emm = getdecimalData(dataTable.Rows[i]["B"].ToString()), - Lumen = getdecimalData(dataTable.Rows[i]["C"].ToString()), + //PlaqueNum = int.Parse(dataTable.Rows[i]["A"].ToString()), + Emm = getdecimalData(dataTable.Rows[i]["A"].ToString()), + Lumen = getdecimalData(dataTable.Rows[i]["B"].ToString()), }; } catch (Exception) @@ -494,12 +506,12 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate var errorRows= string.Join(',', errorRow.Select(i => i.ToString())); throw new BusinessValidationFailedException(_localizer["Service_TemplateException", errorRows]); } - List nums = new List() { 1, 2, 3 }; - if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum))) - { - throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]); - } - measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList(); + //List nums = new List() { 1, 2, 3 }; + //if (measuredValueList.Any(x => !nums.Contains(x.PlaqueNum))) + //{ + // throw new BusinessValidationFailedException(_localizer["IVUSOCT_PlaqueNum123"]); + //} + //measuredValueList = measuredValueList.OrderBy(x => x.PlaqueNum).ToList(); var questionInfo = await _readingQuestionTrialRepository.Where(x =>x.ReadingQuestionCriterionTrialId == taskinfo.TrialReadingCriterionId&& x.LesionType == LesionType.MatchValues).FirstNotNullAsync(); @@ -530,16 +542,16 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate }); // 编号 - tableAnswers.Add(new ReadingTableQuestionAnswer() - { - Answer = item.PlaqueNum.ToString(), - QuestionId = questionInfo.Id, - TrialId = taskinfo.TrialId, - VisitTaskId = taskinfo.Id, - RowId = newRowId, - RowIndex = maxnum, - TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(), - }); + //tableAnswers.Add(new ReadingTableQuestionAnswer() + //{ + // Answer = item.PlaqueNum.ToString(), + // QuestionId = questionInfo.Id, + // TrialId = taskinfo.TrialId, + // VisitTaskId = taskinfo.Id, + // RowId = newRowId, + // RowIndex = maxnum, + // TableQuestionId = tableQuestionList.Where(x => x.ReadingQuestionId == questionInfo.Id && x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(), + //}); var emm = item.Emm.ToString(); var lumen=item.Lumen.ToString(); @@ -891,6 +903,58 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate .Where(x => x.QuestionMark == QuestionMark.PAV).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturnNull(); } + /// + /// 获取EMM求和 + /// + /// + /// + public async Task GetEmmSum(ReadingCalculateDto inDto) + { + return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList) + .Where(x => x.QuestionMark == QuestionMark.ElasticArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum(); + } + + /// + /// (EEM-Lumen)求和 + /// + /// + /// + public async Task GetEEMLumenSum(ReadingCalculateDto inDto) + { + var emm = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList) + .Where(x => x.QuestionMark == QuestionMark.ElasticArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum(); + + var lumen = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.MatchValues).SelectMany(x => x.TableRowInfoList).SelectMany(x => x.TableQuestionList) + .Where(x => x.QuestionMark == QuestionMark.LumenArea).Select(x => x.Answer.IsNullOrEmptyReturn0()).Sum(); + + return emm - lumen; + } + + + /// + /// PAV(冠状动脉粥样硬化体积百分比) + /// + /// + /// + public async Task GetPAV(ReadingCalculateDto inDto) + { + var eEMLumenSum = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.EEMSubLumenSum).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0(); + var eEMSum = inDto.QuestionInfo.Where(x => x.QuestionType == QuestionType.EEMSum).Select(x => x.Answer).FirstOrDefault().IsNullOrEmptyReturn0(); + + string pav = string.Empty; + if (eEMSum != 0) + { + pav = (eEMLumenSum * 100 / eEMSum).ToString(); + } + + if (inDto.DigitPlaces != -1) + { + + pav = decimal.Round(decimal.Parse(pav ?? "0"), inDto.DigitPlaces, MidpointRounding.AwayFromZero).ToString("F" + inDto.DigitPlaces.ToString()); + } + + return decimal.Parse(pav); + } ///// ///// 计算NTAV的EEM diff --git a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs index efce1bca0..baf1693b0 100644 --- a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs +++ b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs @@ -2985,6 +2985,21 @@ namespace IRaCIS.Core.Domain.Share /// ROIAllLength = 1015, + /// + /// PAV(冠状动脉粥样硬化体积百分比) + /// + PAV =1019, + + /// + /// EEM求和 + /// + EEMSum = 1020, + + /// + /// (EEM-Lumen)求和 + /// + EEMSubLumenSum = 1021, + /// /// 匹配动脉段最小FCT ///