From fb6f12903e78ce298ec5cd4ff729520f65bc8dab Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Wed, 25 Sep 2024 09:44:19 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 7 +++++++ .../ReadingImageTask/ReadingImageTaskService.cs | 2 +- .../ReadingCalculate/OCTCalculateService.cs | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 226997618..738a2f15a 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -3947,6 +3947,13 @@ + + + 计算斑块的统计数据 + + + + 验证访视提交 diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs index b732a3756..fe67ccc8d 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingImageTask/ReadingImageTaskService.cs @@ -1139,7 +1139,7 @@ namespace IRaCIS.Core.Application.Service ReadingQestionType.BasicTable, ReadingQestionType.Group, }; - qusetionList = qusetionList.Where(x => x.IsShowInDicom && types.Contains(x.Type)).OrderBy(x => x.ShowOrder).ToList(); + qusetionList = qusetionList.Where(x => x.IsShowInDicom || types.Contains(x.Type)).OrderBy(x => x.ShowOrder).ToList(); if (inDto.TaskId != null) diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs index 62efe7ecd..4b3e62685 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs @@ -557,6 +557,20 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate } + /// + /// 计算斑块的统计数据 + /// + /// + /// + public async Task CalculatePatchDataStatistics(ReadingCalculateDto inDto) + { + // FCT 问题信息 + var fCTQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FCT).FirstOrDefault(); + + + } + + From e389c1e581d11fb3e8519bd21353d9a16481c073 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Wed, 25 Sep 2024 10:19:34 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E8=AE=A1=E7=AE=97=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Reading/Dto/ReadingCalculateViewModel.cs | 16 ++ .../ReadingCalculate/IVUSCalculateService.cs | 1 + .../ReadingCalculate/OCTCalculateService.cs | 197 +++++++++++++++++- IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs | 12 +- 4 files changed, 210 insertions(+), 16 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs index 3197db09d..f580bda15 100644 --- a/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs +++ b/IRaCIS.Core.Application/Service/Reading/Dto/ReadingCalculateViewModel.cs @@ -234,6 +234,22 @@ namespace IRaCIS.Core.Application.Service.Reading.Dto } } + + public class OCTInfo + { + /// + /// 斑块编号 + /// + public int PlaqueNum { get; set; } + + /// + /// 值 + /// + public decimal Data { get; set; } + } + + + /// /// 阅片计算Dto /// diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs index 7442ea160..f110c76a5 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs @@ -460,6 +460,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // 计算斑块数据统计和PVA数据 await this.CalculatePatchDataStatisticsAndPVA(inDto); + inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId); List calculateList = new List() { diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs index 4b3e62685..d8eb8c41d 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs @@ -2,6 +2,7 @@ using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infra.EFCore.Common; +using MassTransit; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Logging; @@ -446,20 +447,19 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate #region 计算 这里顺序非常重要 后面计算的值要依赖前面计算的结果 var needAddList = new List(); - + // 计算斑块统计数据 + await this.CalculatePatchDataStatistics(inDto); + inDto = await _generalCalculateService.GetReadingCalculateDto(inDto.VisitTaskId); List calculateList = new List() { - //// 匹配动脉段最小FCT - //new ReadingCalculateData (){QuestionType=QuestionType.MinFCT,GetDecimalNullFun=GetAllMinFCT}, + // 斑块1-匹配动脉段最小FCT + new ReadingCalculateData (){QuestionType=QuestionType.Plaque1MinFCT,GetDecimalNullFun=GetPlaque1MinFCT}, - // // 平均最小FCT - // new ReadingCalculateData (){QuestionType=QuestionType.AverageMinFCT,GetDecimalNullFun=GetAvgMinFCT}, + // 斑块2-匹配动脉段最小FCT + new ReadingCalculateData (){QuestionType=QuestionType.Plaque2MinFCT,GetDecimalNullFun=GetPlaque2MinFCT}, - // // 脂质角度平均值 - // new ReadingCalculateData (){QuestionType=QuestionType.AvgLipidAngle,GetDecimalNullFun=GetAvgMinLipidAngle}, - - // // 脂质角度最大值 - // new ReadingCalculateData (){QuestionType=QuestionType.MaxLipidAngle,GetDecimalNullFun=GetAllMaxLipidAngle}, + // 斑块3-匹配动脉段最小FCT + new ReadingCalculateData (){QuestionType=QuestionType.Plaque3MinFCT,GetDecimalNullFun=GetPlaque3MinFCT}, @@ -567,12 +567,189 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate // FCT 问题信息 var fCTQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.FCT).FirstOrDefault(); + List oCTFCTInfos=new List (); + + foreach (var item in fCTQuestionInfo!.TableRowInfoList) + { + oCTFCTInfos.Add(new OCTInfo() + { + PlaqueNum = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => int.Parse(x.Answer)).FirstOrDefault(), + Data = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.AvgFCT).Select(x => decimal.Parse(x.Answer)).FirstOrDefault(), + }); + } + + // 脂质角度 问题信息 + var lipidAngleQuestionInfo = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.LipidAngle).FirstOrDefault(); + List lipidAngleInfos = new List(); + foreach (var item in lipidAngleQuestionInfo!.TableRowInfoList) + { + lipidAngleInfos.Add(new OCTInfo() + { + PlaqueNum = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => int.Parse(x.Answer)).FirstOrDefault(), + Data = item.TableQuestionList.Where(x => x.QuestionMark == QuestionMark.LipidAngle).Select(x => decimal.Parse(x.Answer)).FirstOrDefault(), + }); + } + + // 所有的斑块编号 + var plaqueNumbers = oCTFCTInfos.Select(x => x.PlaqueNum).ToList().Union(lipidAngleInfos.Select(x => x.PlaqueNum).ToList()).Distinct().OrderBy(x => x).ToList(); + + List tableAnsweRowInfos = new List(); + List tableAnswers = new List(); + + // 斑块统计问题的Id + var patchDataStatisticsInfo = await _readingQuestionTrialRepository.Where(x => x.ReadingQuestionCriterionTrialId == inDto.TrialReadingCriterionId && x.LesionType == LesionType.PatchDataStatistics).FirstNotNullAsync(); + + // 斑块统计表格问题 + + var patchDataTableQuestion = await _readingTableQuestionTrialRepository.Where(x => x.ReadingQuestionId == patchDataStatisticsInfo.Id).ToListAsync(); + + #region 取小数 + string GetDigitPlacesData(string value) + { + if (inDto.DigitPlaces != -1) + { + value = decimal.Round(decimal.Parse(value ?? "0"), inDto.DigitPlaces).ToString("F" + inDto.DigitPlaces.ToString()); + + } + return value; + } + #endregion + + + foreach (var item in plaqueNumbers) + { + var newRowId = NewId.NextGuid(); + + var thisnumTableRows = inDto.QuestionInfo.Where(x => x.LesionType == LesionType.PatchDataStatistics).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer == item.ToString())).ToList(); + + // 斑块数据统计 + tableAnsweRowInfos.Add(new ReadingTableAnswerRowInfo() + { + Id = newRowId, + QuestionId = patchDataStatisticsInfo.Id, + VisitTaskId = inDto.VisitTaskId, + TrialId = inDto.TrialId, + RowIndex = item, + IsCurrentTaskAdd = true, + BlindName = inDto.BlindName, + OrderMark = patchDataStatisticsInfo.OrderMark, + FristAddTaskNum = inDto.VisitTaskNum, + FristAddTaskId = inDto.VisitTaskId, + RowMark = patchDataStatisticsInfo.OrderMark + decimal.Parse(item.ToString()).GetLesionMark() + }); + + + // 斑块编号 + tableAnswers.Add(new ReadingTableQuestionAnswer() + { + Answer = item.ToString(), + Id = NewId.NextGuid(), + QuestionId = patchDataStatisticsInfo.Id, + TrialId = inDto.TrialId, + VisitTaskId = inDto.VisitTaskId, + RowId = newRowId, + RowIndex = item, + TableQuestionId = patchDataTableQuestion.Where(x => x.QuestionMark == QuestionMark.PlaqueNumber).Select(x => x.Id).FirstOrDefault(), + }); + + + + // 匹配动脉段最小FCT + tableAnswers.Add(new ReadingTableQuestionAnswer() + { + Answer = GetDigitPlacesData(oCTFCTInfos.Where(x => x.PlaqueNum == item).MinOrDefault(x => x.Data).ToString()), + Id = NewId.NextGuid(), + QuestionId = patchDataStatisticsInfo.Id, + TrialId = inDto.TrialId, + VisitTaskId = inDto.VisitTaskId, + RowId = newRowId, + RowIndex = item, + TableQuestionId = patchDataTableQuestion.Where(x => x.QuestionMark == QuestionMark.MiniMumFCT).Select(x => x.Id).FirstOrDefault(), + }); + + // 平均最小FCT + tableAnswers.Add(new ReadingTableQuestionAnswer() + { + Answer = GetDigitPlacesData(oCTFCTInfos.Where(x => x.PlaqueNum == item).Average(x => x.Data).ToString()), + Id = NewId.NextGuid(), + QuestionId = patchDataStatisticsInfo.Id, + TrialId = inDto.TrialId, + VisitTaskId = inDto.VisitTaskId, + RowId = newRowId, + RowIndex = item, + TableQuestionId = patchDataTableQuestion.Where(x => x.QuestionMark == QuestionMark.AvgMinFCT).Select(x => x.Id).FirstOrDefault(), + }); + + // 脂质角度平均值 + tableAnswers.Add(new ReadingTableQuestionAnswer() + { + Answer = GetDigitPlacesData(lipidAngleInfos.Where(x => x.PlaqueNum == item).Average(x => x.Data).ToString()), + Id = NewId.NextGuid(), + QuestionId = patchDataStatisticsInfo.Id, + TrialId = inDto.TrialId, + VisitTaskId = inDto.VisitTaskId, + RowId = newRowId, + RowIndex = item, + TableQuestionId = patchDataTableQuestion.Where(x => x.QuestionMark == QuestionMark.AvgLipidAngle).Select(x => x.Id).FirstOrDefault(), + }); + + // 脂质角度最大值 + tableAnswers.Add(new ReadingTableQuestionAnswer() + { + Answer = GetDigitPlacesData(lipidAngleInfos.Where(x => x.PlaqueNum == item).MaxOrDefault(x => x.Data).ToString()), + Id = NewId.NextGuid(), + QuestionId = patchDataStatisticsInfo.Id, + TrialId = inDto.TrialId, + VisitTaskId = inDto.VisitTaskId, + RowId = newRowId, + RowIndex = item, + TableQuestionId = patchDataTableQuestion.Where(x => x.QuestionMark == QuestionMark.MaxAvgLipidAngle).Select(x => x.Id).FirstOrDefault(), + }); + + + } + await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x =>x.QuestionId== patchDataStatisticsInfo.Id && x.VisitTaskId == inDto.VisitTaskId); + await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.QuestionId == patchDataStatisticsInfo.Id && x.VisitTaskId == inDto.VisitTaskId); + await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableAnsweRowInfos); + await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers); + await _readingTableQuestionAnswerRepository.SaveChangesAsync(); } + /// + /// 斑块1-匹配动脉段最小FCT + /// + /// + /// + public async Task GetPlaque1MinFCT(ReadingCalculateDto inDto) + { + return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.PatchDataStatistics).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer.IsNullOrEmptyReturn0() == 1)).SelectMany(x => x.TableQuestionList) + .Where(x => x.QuestionMark == QuestionMark.MiniMumFCT).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturn0(); + } + /// + /// 斑块2-匹配动脉段最小FCT + /// + /// + /// + public async Task GetPlaque2MinFCT(ReadingCalculateDto inDto) + { + return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.PatchDataStatistics).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer.IsNullOrEmptyReturn0() == 2)).SelectMany(x => x.TableQuestionList) + .Where(x => x.QuestionMark == QuestionMark.MiniMumFCT).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturn0(); + } + + /// + /// 斑块3-匹配动脉段最小FCT + /// + /// + /// + public async Task GetPlaque3MinFCT(ReadingCalculateDto inDto) + { + return inDto.QuestionInfo.Where(x => x.LesionType == LesionType.PatchDataStatistics).SelectMany(x => x.TableRowInfoList).Where(x => x.TableQuestionList.Any(y => y.QuestionMark == QuestionMark.PlaqueNumber && y.Answer.IsNullOrEmptyReturn0() == 3)).SelectMany(x => x.TableQuestionList) + .Where(x => x.QuestionMark == QuestionMark.MiniMumFCT).Select(x => x.Answer).FirstIsNullReturnEmpty().IsNullOrEmptyReturn0(); + } /// /// 验证访视提交 diff --git a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs index c018af771..e08575d27 100644 --- a/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs +++ b/IRaCIS.Core.Domain.Share/Reading/ReadEnum.cs @@ -2115,11 +2115,11 @@ public enum SUVChangeVSBaseline /// FCT三次测量最小值 /// MinFCT = 1014, - - /// - /// FCT三次测量平均值 - /// - AvgMin=1015, + + /// + /// FCT三次测量平均值 + /// + AvgFCT = 1015, /// /// 脂质角度 @@ -2134,7 +2134,7 @@ public enum SUVChangeVSBaseline /// /// 平均最小FCT /// - AvgMinFCT=1018, + AvgMinFCT=1018, /// /// 脂质角度平均值 From 3d382635ccb88713f09c0ed9d3dfb16aff2f0c91 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Wed, 25 Sep 2024 10:34:20 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ReadingCalculate/OCTCalculateService.cs | 44 +++++++++++++++++++ .../_IRaCIS/_Config/_StaticData.cs | 4 ++ 2 files changed, 48 insertions(+) diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs index d8eb8c41d..414e7cb28 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/OCTCalculateService.cs @@ -22,6 +22,7 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate IRepository _subjectVisitRepository, IRepository _tumorAssessmentRepository, IGeneralCalculateService _generalCalculateService, + IVisitTaskHelpeService _visitTaskHelpeService, IRepository _readingTaskQuestionAnswerRepository, ILogger _logger) : BaseService, ICriterionCalculateService { @@ -433,6 +434,49 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate }; } + /// + /// 获取OCT-FCT模板 + /// + /// + /// + [HttpPost] + public async Task GetOCTFCTTemplate(GetExportTemplateInDto inDto) + { + var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).FirstNotNullAsync(); + var values = new + { + SubjectID = taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode, + TaskBlindName = taskinfo.TaskBlindName, + }; + return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto() + { + ExportFileName = "OCT_FCT_Template", + TemplateCode = StaticData.Export.OCT_FCT_Template, + Data = values + }); + } + + /// + /// 获取OCT-脂质角度模板 + /// + /// + /// + [HttpPost] + public async Task GetOCTLipidAngleTemplate(GetExportTemplateInDto inDto) + { + var taskinfo = await _visitTaskRepository.Where(x => x.Id == inDto.VisitTaskId).Include(x => x.Subject).FirstNotNullAsync(); + var values = new + { + SubjectID = taskinfo.BlindSubjectCode.IsNullOrEmpty() ? taskinfo.Subject.Code : taskinfo.BlindSubjectCode, + TaskBlindName = taskinfo.TaskBlindName, + }; + return await _visitTaskHelpeService.ExportTemplateAsync(new IRaCIS.Application.Contracts.ExportTemplateAsyncDto() + { + ExportFileName = "OCT_LipidAngle_Template", + TemplateCode = StaticData.Export.OCT_LipidAngle_Template, + Data = values + }); + } /// diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs index 3472cc21d..0d06b9e5c 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs @@ -276,6 +276,10 @@ public static class StaticData public const string IVUSTheMeasuredValueOfEachMatchedFragment = "IVUS_TheMeasuredValueOfEachMatchedFragment"; + public const string OCT_FCT_Template = "OCT_FCT_Template"; + + public const string OCT_LipidAngle_Template = "OCT_LipidAngle_Template"; + } From 9adab8cef1d8c4477c4574625d863a7eed3f98d9 Mon Sep 17 00:00:00 2001 From: he <109787524@qq.com> Date: Wed, 25 Sep 2024 10:44:40 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/ReadingCalculate/IVUSCalculateService.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs index f110c76a5..33e55912d 100644 --- a/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs +++ b/IRaCIS.Core.Application/Service/ReadingCalculate/IVUSCalculateService.cs @@ -724,6 +724,8 @@ namespace IRaCIS.Core.Application.Service.ReadingCalculate } + await _readingTableAnswerRowInfoRepository.BatchDeleteNoTrackingAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id); + await _readingTableQuestionAnswerRepository.BatchDeleteNoTrackingAsync(x => x.QuestionId == questionInfo.Id && x.VisitTaskId == taskinfo.Id); await _readingTableAnswerRowInfoRepository.AddRangeAsync(tableAnsweRowInfos); await _readingTableQuestionAnswerRepository.AddRangeAsync(tableAnswers); await _readingTableQuestionAnswerRepository.SaveChangesAsync();