diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 27dcd74ab..9a8df8a5b 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -12,6 +12,7 @@ using IRaCIS.Core.Infra.EFCore.Migrations; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore.Metadata.Internal; using NPOI.POIFS.Properties; using NPOI.SS.Formula.Functions; using NPOI.XSSF.UserModel; @@ -2388,9 +2389,9 @@ namespace IRaCIS.Core.Application.Service.Common var firstLessionAnser = lession.LessionAnswerList.FirstOrDefault(); var addLessionInfoList = new List(); - addLessionInfoList.Add(new CommonQuesionInfo() { QuestionName = _userInfo.IsEn_Us ? "Table Name" : "表格名称", QuestionValue = firstLessionAnser.TableQuestionName }); + addLessionInfoList.Add(new CommonQuesionInfo() { QuestionName = _userInfo.IsEn_Us ? "Table Name" : "表格名称", QuestionValue = firstLessionAnser.TableName }); - var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.TableQuestionName + "_" + t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode }); + var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.TableName + "_" + t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode }); //有三部分组成 外层问题+ 固定列表格名称 + 动态的表格问题 var dynamicLessionInfoList = item.QuestionAnswerList.Union(addLessionInfoList).Union(dynamicPartialLessionInfoList).ToList(); @@ -2516,12 +2517,6 @@ namespace IRaCIS.Core.Application.Service.Common #endregion - - - - - - var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.CriterionName = criterion.CriterionName; @@ -2534,11 +2529,13 @@ namespace IRaCIS.Core.Application.Service.Common var dynamicColumnConfig = new DynamicColumnConfig(); //查询配置的问题名称,不是从答案表中连接取问题名称,因为目前有些保存,有些问题,虽然配置了,但是没填,导致导表有些配置的列没出来 - var trialConfigQuestionList = _trialReadingQuestionRepository.Where(t => t.TrialId == trialId && t.ReadingQuestionCriterionTrialId == trialReadingCriterionId).Where(t => t.ExportResultStr.Contains(((int)inQuery.ReadingExportType).ToString())).OrderBy(t => t.ShowOrder).Select(t => new + var trialConfigQuestionList = _trialReadingQuestionRepository.Where(t => t.TrialId == trialId && t.ReadingQuestionCriterionTrialId == trialReadingCriterionId).Where(t => t.ExportResultStr.Contains(((int)inQuery.ReadingExportType).ToString())).OrderBy(t => t.ShowOrder).Select(t => new ExportQuestionBasicInfo() { QuestionId = t.Id, + QuestionType = t.QuestionType, + TableName = "", QuestionName = _userInfo.IsEn_Us ? t.QuestionEnName : t.QuestionName, - t.CDISCCode, + CDISCCode = t.CDISCCode, TranslateDicName = t.DictionaryCode }).ToList(); @@ -2547,26 +2544,120 @@ namespace IRaCIS.Core.Application.Service.Common if (inQuery.ReadingExportType != ExportResult.CDISC) { + //最终EXCEL 列 + var configCoumNameList = new List(); + + //最终翻译字典 + var translateDicNameList = new List(); + + //表格全问题名 - var trialConfigTableQuestionList = _trialReadingTableQuestionRepository.Where(t => t.TrialId == trialId).Where(t => t.ExportResultStr.Contains(((int)inQuery.ReadingExportType).ToString())) - .OrderBy(t => t.ShowOrder).Select(t => new + var trialConfigTableQuestionList = _trialReadingTableQuestionRepository.Where(t => t.TrialId == trialId && t.TrialCriterionId == trialReadingCriterionId).Where(t => t.ExportResultStr.Contains(((int)inQuery.ReadingExportType).ToString())) + .OrderBy(t => t.ShowOrder).Select(t => new ExportQuestionBasicInfo() { QuestionId = t.Id, + TableName = _userInfo.IsEn_Us ? t.ReadingQuestionTrial.QuestionEnName : t.ReadingQuestionTrial.QuestionName, QuestionName = _userInfo.IsEn_Us ? t.QuestionEnName : t.QuestionName, - t.CDISCCode, + CDISCCode = t.CDISCCode, TranslateDicName = t.DictionaryCode }).ToList(); - var totalConfigCoumNameList = trialConfigQuestionList.Union(trialConfigTableQuestionList).ToList(); + #region 外层问题 可能存在合并 + + var fistLeveLNameList = new List(); + + if (criterion.CriterionGroup == CriterionGroup.Tumor) + { + if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB || criterion.CriterionType == CriterionType.IRECIST1Point1) + { + + fistLeveLNameList = trialConfigQuestionList.Select(t => + (t.QuestionType == QuestionType.ExistDisease || t.QuestionType == QuestionType.Tumor) ? (_userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估") : t.QuestionName).Distinct().ToList(); + + + } + else if (criterion.CriterionType == CriterionType.Lugano2014 || criterion.CriterionType == CriterionType.Lugano2014WithoutPET) + { + fistLeveLNameList = trialConfigQuestionList.Select(t => + (t.QuestionType == QuestionType.ExistDisease || t.QuestionType == QuestionType.ImgOncology) ? (_userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估") : t.QuestionName).Distinct().ToList(); + + } + else if (criterion.CriterionType == CriterionType.PCWG3) + { + fistLeveLNameList = trialConfigQuestionList.Select(t => t.QuestionName).ToList(); + } + + var exTralDicNameList = new List() { "LesionType" }; + + translateDicNameList = trialConfigQuestionList.Union(trialConfigTableQuestionList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Union(exTralDicNameList).Distinct().ToList(); + } + else + { + fistLeveLNameList = trialConfigQuestionList.Select(t => t.QuestionName).ToList(); + + translateDicNameList = trialConfigQuestionList.Union(trialConfigTableQuestionList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Distinct().ToList(); + + } + + #endregion + + #region 表格问题 处理增加列 + + + //有多个表格问题 + if (trialConfigTableQuestionList.Select(t => t.TableName).Distinct().Count() > 1) + { + //肿瘤 表格问题直接去重、同时添加一些列 外层问题合并一些列 + if (criterion.CriterionGroup == CriterionGroup.Tumor) + { + var extralNameList = new List() { }; + + if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB + || criterion.CriterionType == CriterionType.IRECIST1Point1 || criterion.CriterionType == CriterionType.Lugano2014 || criterion.CriterionType == CriterionType.Lugano2014WithoutPET) + { + + extralNameList.Add(_userInfo.IsEn_Us ? "Lesion ID" : "病灶编号"); + extralNameList.Add(_userInfo.IsEn_Us ? "Lesion Type" : "病灶类型"); + + + } + else if (criterion.CriterionType == CriterionType.PCWG3) + { + extralNameList.Add(_userInfo.IsEn_Us ? "Lesion Type" : "病灶类型"); + } + + var tableNameList = trialConfigTableQuestionList.Select(t => t.QuestionName).Distinct().ToList(); + + configCoumNameList = fistLeveLNameList.Union(extralNameList).Union(tableNameList).ToList(); + + } + //非肿瘤的 问题名称是 表格名称_表格子问题名 + else + { + var extralNameList = new List() { _userInfo.IsEn_Us ? "Table Name" : "表格名称" }; + + var tableNameList = trialConfigTableQuestionList.Select(t => t.TableName + "_" + t.QuestionName).ToList(); + + configCoumNameList = fistLeveLNameList.Union(extralNameList).Union(tableNameList).ToList(); + } + + } + //单个表格,或者没有配置表格 直接用表格问题名称 + else + { + var tableNameList = trialConfigTableQuestionList.Select(t => t.QuestionName).ToList(); + + configCoumNameList = fistLeveLNameList.Union(tableNameList).ToList(); + } + + #endregion + - var translateDicList = totalConfigCoumNameList.Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Distinct().ToList(); //暂时不用,因为肿瘤标准添加了列,同时多表格的,列名会加上表格名,这里还没有最终确认 - var configCoumNameList = totalConfigCoumNameList.Select(t => t.QuestionName).ToList(); - //之前从问题答案取 合并之后获取最后的列名 - var columNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.QuestionName.IsNotNullOrEmpty()).Select(t => t.QuestionName).Distinct().ToList(); + //var columNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.QuestionName.IsNotNullOrEmpty()).Select(t => t.QuestionName).Distinct().ToList(); dynamicColumnConfig = new DynamicColumnConfig() { @@ -2578,8 +2669,8 @@ namespace IRaCIS.Core.Application.Service.Common DynamicItemTitleName = "QuestionName", DynamicListName = "QuestionAnswerList", RemoveColunmIndexList = removeColumnIndexList, - ColumnNameList = columNameList, - TranslateDicNameList = translateDicList + ColumnNameList = configCoumNameList, + TranslateDicNameList = translateDicNameList }; var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig); diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index bc7d8363b..bbe11f7b9 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -1168,6 +1168,16 @@ namespace IRaCIS.Core.Application.Contracts public string TranslateDicName { get; set; } } + public class ExportQuestionBasicInfo + { + public QuestionType? QuestionType { get; set; } + public string TableName { get; set; } + public Guid QuestionId { get; set; } + public string QuestionName { get; set; } + public string TranslateDicName { get; set; } + public string CDISCCode { get; set; } + } + public class CommonQuesionInfo { @@ -1288,7 +1298,7 @@ namespace IRaCIS.Core.Application.Contracts #region 自定义表格名 特殊处理 - public string TableQuestionName { get; set; } + public string TableName { get; set; } #endregion diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index 55fc960cb..1918ba859 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -303,7 +303,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.QuestionName, t => t.MapFrom(u => isEn_Us ? u.ReadingTableQuestionTrial.QuestionEnName : u.ReadingTableQuestionTrial.QuestionName)) .ForMember(o => o.QuestionValue, t => t.MapFrom(u => u.Answer)) .ForMember(o => o.CDISCCode, t => t.MapFrom(u => u.ReadingTableQuestionTrial.CDISCCode)) - .ForMember(o => o.TableQuestionName, t => t.MapFrom(u => isEn_Us ? u.ReadingQuestionTrial.QuestionEnName : u.ReadingQuestionTrial.QuestionName)) + .ForMember(o => o.TableName, t => t.MapFrom(u => isEn_Us ? u.ReadingQuestionTrial.QuestionEnName : u.ReadingQuestionTrial.QuestionName)) .ForMember(o => o.TranslateDicName, t => t.MapFrom(u => u.ReadingTableQuestionTrial.DictionaryCode)) ;