@@ -11,6 +11,7 @@ using IRaCIS.Core.Infra.EFCore.Common;
using Microsoft.AspNetCore.Authorization ;
using Microsoft.AspNetCore.Hosting ;
using Microsoft.AspNetCore.Mvc ;
using NPOI.POIFS.Properties ;
using NPOI.XSSF.UserModel ;
using System.Globalization ;
using static IRaCIS . Core . Application . Service . ExcelExportHelper ;
@@ -1610,7 +1611,7 @@ namespace IRaCIS.Core.Application.Service.Common
public List < T > DealJudgeMark < T > ( ArbitrationRule arbitrationRule , IEnumerable < T > list ) where T : OverallTumorEvaluationExport
public List < T > DealJudgeMark < T > ( ArbitrationRule arbitrationRule , IEnumerable < T > list ) where T : CommonEvaluationExport
{
//处理访视任务的裁判标记
var resultExceptJudgeList = list . Where ( t = > t . ReadingCategory ! = ReadingCategory . Judge ) . ToList ( ) ;
@@ -1705,175 +1706,7 @@ namespace IRaCIS.Core.Application.Service.Common
}
/// <summary>
/// 整体肿瘤评估 (目前仅仅 RECIST1.1 多个标准一个接口 Excel 列是一样的 )
/// </summary>
/// <param name="inQuery"></param>
/// <param name="_commonDocumentRepository"></param>
/// <param name="_dictionaryService"></param>
/// <param name="_trialRepository"></param>
/// <returns></returns>
[HttpPost]
public async Task < IActionResult > GetOverallTumorEvaluationList_Export ( VisitTaskQuery inQuery ,
[FromServices] IRepository < CommonDocument > _commonDocumentRepository ,
[FromServices] IDictionaryService _dictionaryService ,
[FromServices] IRepository < Trial > _trialRepository )
{
//每次查询必须是单标准的
var criterion = await _readingQuestionCriterionTrialRepository . Where ( t = > t . Id = = inQuery . TrialReadingCriterionId ) . Select ( t = > new { t . CriterionType , t . CriterionName , t . ArbitrationRule } ) . FirstNotNullAsync ( ) ;
if ( criterion . CriterionType ! = CriterionType . RECIST1Point1
& & criterion . CriterionType ! = CriterionType . PCWG3
& & criterion . CriterionType ! = CriterionType . RECIST1Pointt1_MB
& & criterion . CriterionType ! = CriterionType . Lugano2014 /*&& criterion.CriterionType != CriterionType.Lugano2014WithoutPET*/
& & criterion . CriterionType ! = CriterionType . IRECIST1Point1 )
{
//---当前标准导出还未支持
throw new Exception ( _localizer [ "ExcelExport_UnsupportedExport" ] ) ;
}
var list = await _visitTaskRepository . Where ( t = > t . TrialId = = inQuery . TrialId & & t . IsAnalysisCreate = = false & & t . TaskState = = TaskState . Effect )
//访视和全局查询已签名完成的,裁判可以是未签名,未完成的
. Where ( t = > ( t . ReadingTaskState = = ReadingTaskState . HaveSigned & & ( t . ReadingCategory = = ReadingCategory . Visit | | t . ReadingCategory = = ReadingCategory . Global ) ) | | ( t . ReadingCategory = = ReadingCategory . Judge ) )
//.WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
//.WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
//.WhereIf(inQuery.IsSelfAnalysis != null, t => t.IsSelfAnalysis == inQuery.IsSelfAnalysis)
. WhereIf ( inQuery . TrialReadingCriterionId ! = null , t = > t . TrialReadingCriterionId = = inQuery . TrialReadingCriterionId )
. WhereIf ( inQuery . TrialSiteId ! = null , t = > t . Subject . TrialSiteId = = inQuery . TrialSiteId )
. WhereIf ( inQuery . IsUrgent ! = null , t = > t . IsUrgent = = inQuery . IsUrgent )
. WhereIf ( inQuery . DoctorUserId ! = null , t = > t . DoctorUserId = = inQuery . DoctorUserId )
. WhereIf ( inQuery . ReadingCategory ! = null , t = > t . ReadingCategory = = inQuery . ReadingCategory )
. WhereIf ( inQuery . ReadingTaskState ! = null , t = > t . ReadingTaskState = = inQuery . ReadingTaskState )
. WhereIf ( inQuery . TaskAllocationState ! = null , t = > t . TaskAllocationState = = inQuery . TaskAllocationState )
. WhereIf ( inQuery . ArmEnum ! = null , t = > t . ArmEnum = = inQuery . ArmEnum )
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . TrialSiteCode ) , t = > ( t . BlindTrialSiteCode . Contains ( inQuery . TrialSiteCode ! ) & & t . IsAnalysisCreate ) | | ( t . Subject . TrialSite . TrialSiteCode . Contains ( inQuery . TrialSiteCode ! ) & & t . IsAnalysisCreate = = false ) )
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . TaskName ) , t = > t . TaskName . Contains ( inQuery . TaskName ) | | t . TaskBlindName . Contains ( inQuery . TaskName ) )
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . SubjectCode ) , t = > t . Subject . Code . Contains ( inQuery . SubjectCode ) )
. WhereIf ( inQuery . BeginAllocateDate ! = null , t = > t . AllocateTime > inQuery . BeginAllocateDate )
. WhereIf ( inQuery . EndAllocateDate ! = null , t = > t . AllocateTime < inQuery . EndAllocateDate ! . Value . AddDays ( 1 ) )
. ProjectTo < OverallTumorEvaluationExport > ( _mapper . ConfigurationProvider , new { criterionType = criterion . CriterionType , arbitrationRule = criterion . ArbitrationRule , trialReadingCriterionId = inQuery . TrialReadingCriterionId } ) . ToListAsync ( ) ;
list = list . OrderBy ( t = > t . SubjectCode ) . ThenBy ( t = > t . ArmEnum ) . ThenBy ( t = > t . VisitTaskNum ) . ToList ( ) ;
var exportInfo = ( await _trialRepository . Where ( t = > t . Id = = inQuery . TrialId ) . IgnoreQueryFilters ( ) . ProjectTo < ExcelExportInfo > ( _mapper . ConfigurationProvider ) . FirstOrDefaultAsync ( ) ) . IfNullThrowException ( ) ;
exportInfo . CriterionName = criterion . CriterionName ;
//处理裁判标记
list = DealJudgeMark ( criterion . ArbitrationRule , list ) ;
exportInfo . List = ExportExcelConverterDate . ConvertToClientTimeInObject ( list . Where ( t = > t . ReadingCategory ! = ReadingCategory . Global ) . ToList ( ) , _userInfo . TimeZoneId ) ;
exportInfo . CurrentTime = ExportExcelConverterDate . DateTimeInternationalToString ( DateTime . Now , _userInfo . TimeZoneId ) ;
return await ExcelExportHelper . DataExportAsync ( StaticData . Export . OverallTumorEvaluation_Export , exportInfo , $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}" , _commonDocumentRepository , _hostEnvironment , _dictionaryService , typeof ( OverallTumorEvaluationExport ) , criterion . CriterionType ) ;
}
/// <summary>
/// 肿瘤疗效评估表 ( 目前仅仅 RECIST1.1)
/// </summary>
/// <param name="inQuery"></param>
/// <param name="_commonDocumentRepository"></param>
/// <param name="_dictionaryService"></param>
/// <param name="_trialRepository"></param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
[HttpPost]
public async Task < IActionResult > GetEvaluationOfTumorEfficacy_Export ( VisitTaskQuery inQuery ,
[FromServices] IRepository < CommonDocument > _commonDocumentRepository ,
[FromServices] IDictionaryService _dictionaryService ,
[FromServices] IRepository < Trial > _trialRepository )
{
//每次查询必须是单标准的
var criterion = await _readingQuestionCriterionTrialRepository . Where ( t = > t . Id = = inQuery . TrialReadingCriterionId ) . Select ( t = > new { t . CriterionType , t . CriterionName , t . ArbitrationRule } ) . FirstOrDefaultAsync ( ) ;
var query = _visitTaskRepository . Where ( t = > t . TrialId = = inQuery . TrialId & & t . TaskState = = TaskState . Effect & & t . IsAnalysisCreate = = false & & t . ReadingTaskState = = ReadingTaskState . HaveSigned )
//.WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
//.WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
//.WhereIf(inQuery.IsSelfAnalysis != null, t => t.IsSelfAnalysis == inQuery.IsSelfAnalysis)
. WhereIf ( inQuery . TrialReadingCriterionId ! = null , t = > t . TrialReadingCriterionId = = inQuery . TrialReadingCriterionId )
. WhereIf ( inQuery . TrialSiteId ! = null , t = > t . Subject . TrialSiteId = = inQuery . TrialSiteId )
. WhereIf ( inQuery . IsUrgent ! = null , t = > t . IsUrgent = = inQuery . IsUrgent )
. WhereIf ( inQuery . DoctorUserId ! = null , t = > t . DoctorUserId = = inQuery . DoctorUserId )
. WhereIf ( inQuery . ReadingCategory ! = null , t = > t . ReadingCategory = = inQuery . ReadingCategory )
. WhereIf ( inQuery . ReadingTaskState ! = null , t = > t . ReadingTaskState = = inQuery . ReadingTaskState )
. WhereIf ( inQuery . TaskAllocationState ! = null , t = > t . TaskAllocationState = = inQuery . TaskAllocationState )
. WhereIf ( inQuery . ArmEnum ! = null , t = > t . ArmEnum = = inQuery . ArmEnum )
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . TrialSiteCode ) , t = > ( t . BlindTrialSiteCode . Contains ( inQuery . TrialSiteCode ! ) & & t . IsAnalysisCreate ) | | ( t . Subject . TrialSite . TrialSiteCode . Contains ( inQuery . TrialSiteCode ! ) & & t . IsAnalysisCreate = = false ) )
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . TaskName ) , t = > t . TaskName . Contains ( inQuery . TaskName ) | | t . TaskBlindName . Contains ( inQuery . TaskName ) )
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . SubjectCode ) , t = > t . Subject . Code . Contains ( inQuery . SubjectCode ) )
. WhereIf ( inQuery . BeginAllocateDate ! = null , t = > t . AllocateTime > inQuery . BeginAllocateDate )
. WhereIf ( inQuery . EndAllocateDate ! = null , t = > t . AllocateTime < inQuery . EndAllocateDate ! . Value . AddDays ( 1 ) ) ;
var exportInfo = ( await _trialRepository . Where ( t = > t . Id = = inQuery . TrialId ) . IgnoreQueryFilters ( ) . ProjectTo < ExcelExportInfo > ( _mapper . ConfigurationProvider ) . FirstOrDefaultAsync ( ) ) . IfNullThrowException ( ) ;
exportInfo . CriterionName = criterion . CriterionName ;
if ( criterion . CriterionType = = CriterionType . RECIST1Point1 | | criterion . CriterionType = = CriterionType . RECIST1Pointt1_MB )
{
var list = await query . ProjectTo < RECIST1Point1EvaluationOfTumorEfficacyExport > ( _mapper . ConfigurationProvider , new { criterionType = criterion . CriterionType , arbitrationRule = criterion . ArbitrationRule , trialReadingCriterionId = inQuery . TrialReadingCriterionId } ) . ToListAsync ( ) ;
list = list . OrderBy ( t = > t . SubjectCode ) . ThenBy ( t = > t . ArmEnum ) . ThenBy ( t = > t . VisitTaskNum ) . ToList ( ) ;
//处理裁判标记
list = DealJudgeMark ( criterion . ArbitrationRule , list ) ;
exportInfo . List = ExportExcelConverterDate . ConvertToClientTimeInObject ( list . Where ( t = > t . ReadingCategory ! = ReadingCategory . Global ) . ToList ( ) , _userInfo . TimeZoneId ) ;
exportInfo . CurrentTime = ExportExcelConverterDate . DateTimeInternationalToString ( DateTime . Now , _userInfo . TimeZoneId ) ;
return await ExcelExportHelper . DataExportAsync ( StaticData . Export . RECIST1Point1EvaluationOfTumorEfficacy_Export , exportInfo , $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}" , _commonDocumentRepository , _hostEnvironment , _dictionaryService , typeof ( RECIST1Point1EvaluationOfTumorEfficacyExport ) , criterion . CriterionType ) ;
}
else if ( criterion . CriterionType = = CriterionType . Lugano2014 /*|| criterion.CriterionType == CriterionType.Lugano2014WithoutPET*/ )
{
var list = await query . ProjectTo < Lugano2014EvaluationOfTumorEfficacyExport > ( _mapper . ConfigurationProvider , new { criterionType = criterion . CriterionType , arbitrationRule = criterion . ArbitrationRule , trialReadingCriterionId = inQuery . TrialReadingCriterionId } ) . ToListAsync ( ) ;
list = list . OrderBy ( t = > t . SubjectCode ) . ThenBy ( t = > t . ArmEnum ) . ThenBy ( t = > t . VisitTaskNum ) . ToList ( ) ;
//处理裁判标记
list = DealJudgeMark ( criterion . ArbitrationRule , list ) ;
exportInfo . List = ExportExcelConverterDate . ConvertToClientTimeInObject ( list . Where ( t = > t . ReadingCategory ! = ReadingCategory . Global ) . ToList ( ) , _userInfo . TimeZoneId ) ;
exportInfo . CurrentTime = ExportExcelConverterDate . DateTimeInternationalToString ( DateTime . Now , _userInfo . TimeZoneId ) ;
return await ExcelExportHelper . DataExportAsync ( StaticData . Export . Lugano2014EvaluationOfTumorEfficacy_Export , exportInfo , $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}" , _commonDocumentRepository , _hostEnvironment , _dictionaryService , typeof ( Lugano2014EvaluationOfTumorEfficacyExport ) , criterion . CriterionType ) ;
}
else if ( criterion . CriterionType = = CriterionType . IRECIST1Point1 )
{
var list = await query . ProjectTo < IRECIST1Point1EvaluationOfTumorEfficacyExport > ( _mapper . ConfigurationProvider , new { criterionType = criterion . CriterionType , arbitrationRule = criterion . ArbitrationRule , trialReadingCriterionId = inQuery . TrialReadingCriterionId } ) . ToListAsync ( ) ;
list = list . OrderBy ( t = > t . SubjectCode ) . ThenBy ( t = > t . ArmEnum ) . ThenBy ( t = > t . VisitTaskNum ) . ToList ( ) ;
//处理裁判标记
list = DealJudgeMark ( criterion . ArbitrationRule , list ) ;
exportInfo . List = ExportExcelConverterDate . ConvertToClientTimeInObject ( list . Where ( t = > t . ReadingCategory ! = ReadingCategory . Global ) . ToList ( ) , _userInfo . TimeZoneId ) ;
exportInfo . CurrentTime = ExportExcelConverterDate . DateTimeInternationalToString ( DateTime . Now , _userInfo . TimeZoneId ) ;
return await ExcelExportHelper . DataExportAsync ( StaticData . Export . IRECIST1Point1EvaluationOfTumorEfficacy_Export , exportInfo , $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}" , _commonDocumentRepository , _hostEnvironment , _dictionaryService , typeof ( IRECIST1Point1EvaluationOfTumorEfficacyExport ) , criterion . CriterionType ) ;
}
else
{
//---当前标准导出还未支持
throw new Exception ( _localizer [ "ExcelExport_UnsupportedExport" ] ) ;
}
}
#region 历 史 单 独 导 出 废 弃
/// <summary>
/// 评估病灶明细表 (目前仅仅 RECIST1.1 RECIST1.1 PGW3 表都是不同的)
/// </summary>
@@ -1944,7 +1777,7 @@ namespace IRaCIS.Core.Application.Service.Common
} ) . ToList ( ) ;
//处理裁判标记
list = DealJudgeMark ( criterion . ArbitrationRule , list ) ;
//list = DealJudgeMark(criterion.ArbitrationRule, list);
exportInfo . List = ExportExcelConverterDate . ConvertToClientTimeInObject ( exportList , _userInfo . TimeZoneId ) ;
exportInfo . CurrentTime = ExportExcelConverterDate . DateTimeInternationalToString ( DateTime . Now , _userInfo . TimeZoneId ) ;
@@ -1978,7 +1811,7 @@ namespace IRaCIS.Core.Application.Service.Common
} ) . ToList ( ) ;
//处理裁判标记
list = DealJudgeMark ( criterion . ArbitrationRule , list ) ;
//list = DealJudgeMark(criterion.ArbitrationRule, list);
exportInfo . List = ExportExcelConverterDate . ConvertToClientTimeInObject ( exportList , _userInfo . TimeZoneId ) ; ;
exportInfo . CurrentTime = ExportExcelConverterDate . DateTimeInternationalToString ( DateTime . Now , _userInfo . TimeZoneId ) ;
@@ -1996,6 +1829,11 @@ namespace IRaCIS.Core.Application.Service.Common
}
#endregion
@@ -2005,7 +1843,7 @@ namespace IRaCIS.Core.Application.Service.Common
#region 通 用 阅 片 结 果 导 出
/// <summary>
/// 裁判阅片 明细表
/// 病灶 明细表
/// </summary>
/// <param name="inQuery"></param>
/// <param name="_commonDocumentRepository"></param>
@@ -2013,8 +1851,7 @@ namespace IRaCIS.Core.Application.Service.Common
/// <param name="_trialRepository"></param>
/// <returns></returns>
[HttpPost]
[Obsolete]
public async Task < IActionResult > GetCommonJudgeEvaluationList_Export ( VisitTaskQuery inQuery ,
public async Task < IActionResult > GetEvaluationLessionList_Export ( VisitTaskQuery inQuery ,
[FromServices] IRepository < CommonDocument > _commonDocumentRepository ,
[FromServices] IDictionaryService _dictionaryService ,
[FromServices] IRepository < Trial > _trialRepository )
@@ -2023,33 +1860,29 @@ namespace IRaCIS.Core.Application.Service.Common
var criterion = await _readingQuestionCriterionTrialRepository . Where ( t = > t . Id = = inQuery . TrialReadingCriterionId ) . Select ( t = > new { t . CriterionType , t . CriterionName , t . ArbitrationRule } ) . FirstNotNullAsync ( ) ;
var list = await _visitTaskRepository . Where ( t = > t . TrialId = = inQuery . TrialId & & t . IsAnalysisCreate = = false & & t . TaskState = = TaskState . Effect )
//访视和全局查询已签名完成的,裁判可以是未签名,未完成的
. Where ( t = > ( t . ReadingTaskState = = ReadingTaskState . HaveSigned & & ( t . ReadingCategory = = ReadingCategory . Visit | | t . ReadingCategory = = ReadingCategory . Global ) ) | | ( t . ReadingCategory = = ReadingCategory . Judge ) )
//.WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId)
//.WhereIf(inQuery.TaskState != null, t => t.TaskState == inQuery.TaskState)
//.WhereIf(inQuery.IsSelfAnalysis != null, t => t.IsSelfAnalysis == inQuery.IsSelfAnalysis)
var list = await _visitTaskRepository . Where ( t = > t . TrialId = = inQuery . TrialId & & t . IsAnalysisCreate = = false & & ( t . TaskState = = TaskState . Effect | | t . TaskState = = TaskState . Freeze ) )
//访视和全局查询已签名完成的,裁判可以是未签名,未完成的
. Where ( t = > ( t . ReadingTaskState = = ReadingTaskState . HaveSigned & & ( t . ReadingCategory = = ReadingCategory . Visit | | t . ReadingCategory = = ReadingCategory . Global ) ) | | t . ReadingCategory = = ReadingCategory . Judge )
. WhereIf ( inQuery . TrialReadingCriterionId ! = null , t = > t . TrialReadingCriterionId = = inQuery . TrialReadingCriterionId )
. WhereIf ( inQuery . TrialSiteId ! = null , t = > t . Subject . TrialSiteId = = inQuery . TrialSiteId )
. WhereIf ( inQuery . IsUrgent ! = null , t = > t . IsUrgent = = inQuery . IsUrgent )
. WhereIf ( inQuery . DoctorUserId ! = null , t = > t . DoctorUserId = = inQuery . DoctorUserId )
. WhereIf ( inQuery . ReadingCategory ! = null , t = > t . ReadingCategory = = inQuery . ReadingCategory )
. WhereIf ( inQuery . ReadingTaskState ! = null , t = > t . ReadingTaskState = = inQuery . ReadingTaskState )
//.WhereIf(inQuery.ReadingTaskState != null, t => t.ReadingTaskState == inQuery.ReadingTaskState)
. WhereIf ( inQuery . TaskAllocationState ! = null , t = > t . TaskAllocationState = = inQuery . TaskAllocationState )
. WhereIf ( inQuery . ArmEnum ! = null , t = > t . ArmEnum = = inQuery . ArmEnum )
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . TrialSiteCode ) , t = > ( t . BlindTrialSiteCode . Contains ( inQuery . TrialSiteCode ! ) & & t . IsAnalysisCreate ) | | ( t . Subject . TrialSite . TrialSiteCode . Contains ( inQuery . TrialSiteCode ! ) & & t . IsAnalysisCreate = = false ) )
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . TaskName ) , t = > t . TaskName . Contains ( inQuery . TaskName ) | | t . TaskBlindName . Contains ( inQuery . TaskName ) )
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . SubjectCode ) , t = > t . Subject . Code . Contains ( inQuery . SubjectCode ) )
. WhereIf ( inQuery . BeginAllocateDate ! = null , t = > t . AllocateTime > inQuery . BeginAllocateDate )
. WhereIf ( inQuery . EndAllocateDate ! = null , t = > t . AllocateTime < inQuery . EndAllocateDate ! . Value . AddDays ( 1 ) )
. ProjectTo < CommonEvaluationExport > ( _mapper . ConfigurationProvider , new { criterionType = criterion . CriterionType , arbitrationRule = criterion . ArbitrationRule , trialReadingCriterionId = inQuery . TrialReadingCriterionId , isEn_Us = _userInfo . IsEn_Us } ) . ToListAsync ( ) ;
. WhereIf ( inQuery . EndAllocateDate ! = null , t = > t . AllocateTime < inQuery . EndAllocateDate )
. ProjectTo < CommonLessionExport > ( _mapper . ConfigurationProvider , new { readingExportType = inQuery . ReadingExportType , criterionType = criterion . CriterionType , arbitrationRule = criterion . ArbitrationRule , trialReadingCriterionId = inQuery . TrialReadingCriterionId , isEn_Us = _userInfo . IsEn_Us } ) . ToListAsync ( ) ;
list = list . OrderBy ( t = > t . SubjectCode ) . ThenBy ( t = > t . ArmEnum ) . ThenBy ( t = > t . VisitTaskNum ) . ToList ( ) ;
var translateDicNameList = list . FirstOrDefault ( ) ? . QuestionAnswerList . Select ( t = > t . TranslateDicName ) . ToList ( ) ;
var exportInfo = ( await _trialRepository . Where ( t = > t . Id = = inQuery . TrialId ) . IgnoreQueryFilters ( ) . ProjectTo < ExcelExportInfo > ( _mapper . ConfigurationProvider ) . FirstOrDefaultAsync ( ) ) . IfNullThrowException ( ) ;
exportInfo . CriterionName = criterion . CriterionName ;
@@ -2060,15 +1893,35 @@ namespace IRaCIS.Core.Application.Service.Common
exportInfo . List = ExportExcelConverterDate . ConvertToClientTimeInObject ( list . Where ( t = > t . ReadingCategory ! = ReadingCategory . Global ) . ToList ( ) , _userInfo . TimeZoneId ) ;
exportInfo . CurrentTime = ExportExcelConverterDate . DateTimeInternationalToString ( DateTime . Now , _userInfo . TimeZoneId ) ;
var dynamicColumnConfig = new DynamicColumnConfig ( ) { AutoColumnTitleRowIndex = 2 , AutoColumnStartIndex = 6 , ColumnNameList = list . FirstOrDefault ( ) ? . QuestionAnswerList . Select ( t = > t . QuestionName ) . ToList ( ) } ;
var dynamicColumnConfig = new DynamicColumnConfig ( )
{
AutoColumnTitleRowIndex = 2 ,
AutoColumnStartIndex = 6 ,
TempalteLastColumnIndex = 8 ,
DynamicItemDicName = "TranslateDicName" ,
DynamicItemValueName = "QuestionValue" ,
DynamicListName = "QuestionAnswerList" ,
RemoveColunmIndexList = new List < int > ( ) { } ,
ColumnNameList = list . FirstOrDefault ( ) ? . QuestionAnswerList . Select ( t = > t . QuestionName ) . ToList ( ) ? ? new List < string > ( ) ,
TranslateDicNameList = translateDicNameList ? ? new List < string > ( )
} ;
var ( memoryStream , fileName ) = await ExcelExportHelper . DataExport_NpoiTestAsync ( StaticData . Export . CommonJudgeReadingDetail_Export , exportInfo , _commonDocumentRepository , _hostEnvironment , _dictionaryService , typeof ( CommonEvaluationExport ) , criterion . CriterionType , dynamicColumnConfig ) ;
var ( memoryStream , fileName ) = await ExcelExportHelper . DataExport_NpoiTestAsync ( StaticData . Export . ReadingLession_Export , exportInfo , _commonDocumentRepository , _hostEnvironment , _dictionaryService , typeof ( CommonEvaluationExport ) , criterion . CriterionType , dynamicColumnConfig ) ;
return new FileStreamResult ( memoryStream , "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" )
{
FileDownloadName = $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}_{fileName}_{DateTime.Now.ToString(" yyyyMMddHHmmss ")}.xlsx"
} ;
}
/// <summary>
/// 获取阅片标准可以导出的列表
@@ -2141,7 +1994,7 @@ namespace IRaCIS.Core.Application.Service.Common
}
/// <summary>
/// 通用 阅片结果、阅片结果明细,裁判明细表导出,条件通过 ReadingExportType ( 0, 1, 2)区分
/// 阅片结果表 、阅片结果明细,评估病灶明细表, 裁判明细表导出,条件通过 ReadingExportType ( 1, 2, 3,4 )区分
/// </summary>
/// <param name="inQuery"></param>
/// <param name="_commonDocumentRepository"></param>
@@ -2158,7 +2011,7 @@ namespace IRaCIS.Core.Application.Service.Common
var criterion = await _readingQuestionCriterionTrialRepository . Where ( t = > t . Id = = inQuery . TrialReadingCriterionId ) . Select ( t = > new { t . CriterionType , t . CriterionName , t . ArbitrationRule } ) . FirstNotNullAsync ( ) ;
var list = await _visitTaskRepository . Where ( t = > t . TrialId = = inQuery . TrialId & & t . IsAnalysisCreate = = false & & ( t . TaskState = = TaskState . Effect | | t . TaskState = = TaskState . Freeze ) )
var query = _visitTaskRepository . Where ( t = > t . TrialId = = inQuery . TrialId & & t . IsAnalysisCreate = = false & & ( t . TaskState = = TaskState . Effect | | t . TaskState = = TaskState . Freeze ) )
//访视和全局查询已签名完成的,裁判可以是未签名,未完成的
. Where ( t = > ( t . ReadingTaskState = = ReadingTaskState . HaveSigned & & ( t . ReadingCategory = = ReadingCategory . Visit | | t . ReadingCategory = = ReadingCategory . Global ) ) | | t . ReadingCategory = = ReadingCategory . Judge )
@@ -2175,14 +2028,16 @@ namespace IRaCIS.Core.Application.Service.Common
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . TaskName ) , t = > t . TaskName . Contains ( inQuery . TaskName ) | | t . TaskBlindName . Contains ( inQuery . TaskName ) )
. WhereIf ( ! string . IsNullOrEmpty ( inQuery . SubjectCode ) , t = > t . Subject . Code . Contains ( inQuery . SubjectCode ) )
. WhereIf ( inQuery . BeginAllocateDate ! = null , t = > t . AllocateTime > inQuery . BeginAllocateDate )
. WhereIf ( inQuery . EndAllocateDate ! = null , t = > t . AllocateTime < inQuery . EndAllocateDate )
. ProjectTo < CommonEvaluationExport > ( _mapper . ConfigurationProvider , new { readingExportType = inQuery . ReadingExportType , criterionType = criterion . CriterionType , arbitrationRule = criterion . ArbitrationRule , trialReadingCriterionId = inQuery . TrialReadingCriterionId , isEn_Us = _userInfo . IsEn_Us } ) . ToListAsync ( ) ;
. WhereIf ( inQuery . EndAllocateDate ! = null , t = > t . AllocateTime < inQuery . EndAllocateDate ) ;
list = list . OrderBy ( t = > t . SubjectCode ) . ThenBy ( t = > t . ArmEnum ) . ThenBy ( t = > t . VisitTaskNum ) . ToList ( ) ;
var list = new List < CommonEvaluationExport > ( ) ;
#region 区 分 导 表 类 型
var export_Template = StaticData . Export . CommonReading_Export ;
if ( inQuery . ReadingExportType = = ReadingExportType . JudgeReadingDetailResult )
if ( inQuery . ReadingExportType = = ExportResult . DetailedTableOfAdjudicationResults )
{
//R1 R2 两个人的访视都阅片完成了才可以,去除只有一个人阅片完成的访视
@@ -2190,12 +2045,103 @@ namespace IRaCIS.Core.Application.Service.Common
var exceptVisit = list . GroupBy ( t = > new { t . SubjectCode , t . TaskName } ) . Where ( g = > g . Count ( ) = = 1 ) . Select ( g = > new { g . Key . SubjectCode , g . Key . TaskName } ) . ToList ( ) ;
list = list . Where ( t = > ! exceptVisit . Any ( ev = > ev . SubjectCode = = t . SubjectCode & & ev . TaskName = = t . TaskName ) ) . ToList ( ) ;
//裁判明表
export_Template = StaticData . Export . CommonJudgeReadingDetail_Export ;
}
if ( inQuery . ReadingExportType = = ReadingExportType . ReadingDetailResult )
else if ( inQuery . ReadingExportType = = ExportResult . DetailedTableOfAssessmentResults )
{
//阅片明细表
export_Template = StaticData . Export . CommonReadingDetail_Export ;
}
else if ( inQuery . ReadingExportType = = ExportResult . DetailedTableOfLesions )
{
//病灶明细表
export_Template = StaticData . Export . ReadingLession_Export ;
}
if ( inQuery . ReadingExportType ! = ExportResult . DetailedTableOfLesions )
{
list = await query . ProjectTo < CommonEvaluationExport > ( _mapper . ConfigurationProvider ,
new
{
readingExportType = inQuery . ReadingExportType ,
criterionType = criterion . CriterionType ,
arbitrationRule = criterion . ArbitrationRule ,
trialReadingCriterionId = inQuery . TrialReadingCriterionId ,
isEn_Us = _userInfo . IsEn_Us
} ) . ToListAsync ( ) ;
}
else
{
var taskList = await query . ProjectTo < CommonLessionExport > ( _mapper . ConfigurationProvider ,
new
{
readingExportType = inQuery . ReadingExportType ,
criterionType = criterion . CriterionType ,
arbitrationRule = criterion . ArbitrationRule ,
trialReadingCriterionId = inQuery . TrialReadingCriterionId ,
isEn_Us = _userInfo . IsEn_Us
} ) . ToListAsync ( ) ;
//动态列,以不同的病灶配置的问题取并集
var lessionAnserList = taskList . Where ( t = > t . LesionList . Count ( ) > 0 ) . FirstOrDefault ( ) ? . LesionList . FirstOrDefault ( ) ? . LessionAnswerList ? ? new List < CommonLessionQuestionAnswerInfo > ( ) ;
var dynamicExtraAddTitleList = new List < DymamicQuestionInfo > ( ) ;
if ( lessionAnserList . Count ( ) > 0 )
{
var lessionInfo = lessionAnserList . First ( ) ;
dynamicExtraAddTitleList . Add ( new DymamicQuestionInfo ( ) { QuestionName = _userInfo . IsEn_Us ? "Lesion ID" : "病灶编号" } ) ;
dynamicExtraAddTitleList . Add ( new DymamicQuestionInfo ( ) { QuestionName = _userInfo . IsEn_Us ? "Lesion Type" : "病灶类型" } ) ;
}
//通过问题标识取并集
var dynamicLessionTitleList = lessionAnserList . Select ( t = > new DymamicQuestionInfo { QuestionMark = t . QuestionMark , QuestionName = t . QuestionName , TranslateDicName = t . TranslateDicName } ) . Distinct ( ) ;
var dynamicTitleList = dynamicExtraAddTitleList . Union ( dynamicLessionTitleList ) . ToList ( ) ;
//最终的病灶列表
list = new List < CommonEvaluationExport > ( ) ;
foreach ( var item in taskList )
{
foreach ( var lession in item . LesionList )
{
var firstLessionAnser = lession . LessionAnswerList . FirstOrDefault ( ) ? ? new CommonLessionQuestionAnswerInfo ( ) ;
var addLessionInfoList = new List < CommonQuesionInfo > ( ) ;
//病灶编号 和病灶类型没有配置,但是需要有的
addLessionInfoList . Add ( new CommonQuesionInfo ( ) { QuestionName = _userInfo . IsEn_Us ? "Lesion ID" : "病灶编号" , QuestionValue = firstLessionAnser . LessionCode } ) ;
addLessionInfoList . Add ( new CommonQuesionInfo ( ) { QuestionName = _userInfo . IsEn_Us ? "Lesion Type" : "病灶类型" , QuestionValue = firstLessionAnser . LessionType , TranslateDicName = "LesionType" } ) ;
var dynamicPartialLessionInfoList = lession . LessionAnswerList . Select ( t = > new CommonQuesionInfo ( ) { QuestionName = t . QuestionName , QuestionValue = t . QuestionValue , TranslateDicName = t . TranslateDicName } ) ;
//有三部分组成 外层问题+ 没有配置的编号和类型+ 动态的表格问题
var dynamicLessionInfoList = addLessionInfoList . Union ( dynamicPartialLessionInfoList ) . Union ( item . QuestionAnswerList ) . ToList ( ) ;
var cloneItem = item . Clone ( ) ;
cloneItem . QuestionAnswerList = dynamicLessionInfoList ;
list . Add ( cloneItem ) ;
}
}
}
#endregion
list = list . OrderBy ( t = > t . SubjectCode ) . ThenBy ( t = > t . ArmEnum ) . ThenBy ( t = > t . VisitTaskNum ) . ToList ( ) ;
var exportInfo = ( await _trialRepository . Where ( t = > t . Id = = inQuery . TrialId ) . IgnoreQueryFilters ( ) . ProjectTo < ExcelExportInfo > ( _mapper . ConfigurationProvider ) . FirstOrDefaultAsync ( ) ) . IfNullThrowException ( ) ;
exportInfo . CriterionName = criterion . CriterionName ;
@@ -2206,7 +2152,7 @@ namespace IRaCIS.Core.Application.Service.Common
#region 系 统 标 准 处 理 整 体 肿 瘤 评 估 合 并
var translateDicNameList = list . FirstOrDefault ( ) ? . QuestionAnswerList . Select ( t = > t . TranslateDicName ) . ToList ( ) ;
var translateDicNameList = list . SelectMany ( t = > t . QuestionAnswerList ) . Where ( t = > t . TranslateDicName . IsNotNullOrEmpty ( ) ) . Select ( t = > t . TranslateDicName ) . Distinct ( ) . ToList ( ) ;
//针对1.1 整体肿瘤评估 有的两列要合并一列
if ( criterion . CriterionType = = CriterionType . RECIST1Point1 | | criterion . CriterionType = = CriterionType . RECIST1Pointt1_MB | | criterion . CriterionType = = CriterionType . IRECIST1Point1 )
@@ -2274,7 +2220,6 @@ namespace IRaCIS.Core.Application.Service.Common
exportInfo . List = ExportExcelConverterDate . ConvertToClientTimeInObject ( list . Where ( t = > t . ReadingCategory ! = ReadingCategory . Global ) . ToList ( ) , _userInfo . TimeZoneId ) ;
exportInfo . CurrentTime = ExportExcelConverterDate . DateTimeInternationalToString ( DateTime . Now , _userInfo . TimeZoneId ) ;
@@ -2292,13 +2237,8 @@ namespace IRaCIS.Core.Application.Service.Common
} ;
var ( memoryStream , fileName ) = await ExcelExportHelper . DataExport_NpoiTestAsync ( export_Template , exportInfo , _commonDocumentRepository , _hostEnvironment , _dictionaryService , typeof ( CommonEvaluationExport ) , criterion . CriterionType , dynamicColumnConfig ) ;
return new FileStreamResult ( memoryStream , "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" )
{
FileDownloadName = $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}_{fileName}_{DateTime.Now.ToString(" yyyyMMddHHmmss ")}.xlsx"