@@ -1,4 +1,5 @@
using IRaCIS.Application.Contracts ;
using DocumentFormat.OpenXml.Spreadsheet ;
using IRaCIS.Application.Contracts ;
using IRaCIS.Application.Interfaces ;
using IRaCIS.Core.API._ServiceExtensions.NewtonsoftJson ;
using IRaCIS.Core.Application.Contracts ;
@@ -1996,6 +1997,73 @@ namespace IRaCIS.Core.Application.Service.Common
#endregion
#region 通 用 阅 片 结 果 导 出
/// <summary>
/// 裁判阅片明细表
/// </summary>
/// <param name="inQuery"></param>
/// <param name="_commonDocumentRepository"></param>
/// <param name="_dictionaryService"></param>
/// <param name="_trialRepository"></param>
/// <returns></returns>
[HttpPost]
[Obsolete]
public async Task < IActionResult > GetCommonJudgeEvaluationList_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 ( ) ;
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 < CommonEvaluationExport > ( _mapper . ConfigurationProvider , new { 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 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 ) ;
var dynamicColumnConfig = new DynamicColumnConfig ( ) { AutoColumnTitleRowIndex = 2 , AutoColumnStartIndex = 6 , ColumnNameList = list . FirstOrDefault ( ) ? . QuestionAnswerList . Select ( t = > t . QuestionName ) . ToList ( ) } ;
var ( memoryStream , fileName ) = await ExcelExportHelper . DataExport_NpoiTestAsync ( StaticData . Export . CommonJudgeReadingDetail_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>
/// 获取阅片标准可以导出的列表
/// </summary>
@@ -2065,6 +2133,15 @@ namespace IRaCIS.Core.Application.Service.Common
}
return list ;
}
/// <summary>
/// 通用阅片结果、阅片结果明细,裁判明细表导出,条件通过 ReadingExportType ( 0, 1, 2)区分
/// </summary>
/// <param name="inQuery"></param>
/// <param name="_commonDocumentRepository"></param>
/// <param name="_dictionaryService"></param>
/// <param name="_trialRepository"></param>
/// <returns></returns>
[HttpPost]
public async Task < IActionResult > GetCommonEvaluationList_Export ( VisitTaskQuery inQuery ,
[FromServices] IRepository < CommonDocument > _commonDocumentRepository ,
@@ -2075,28 +2152,24 @@ 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 ) )
//访视和全局查询已签名完成的,裁判可以是未签名,未完成的
. 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 ) )
. 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 ( ) ;
list = list . OrderBy ( t = > t . SubjectCode ) . ThenBy ( t = > t . ArmEnum ) . ThenBy ( t = > t . VisitTaskNum ) . ToList ( ) ;
@@ -2127,23 +2200,31 @@ namespace IRaCIS.Core.Application.Service.Common
#region 系 统 标 准 处 理 整 体 肿 瘤 评 估 合 并
var translateDicNameList = list . FirstOrDefault ( ) ? . QuestionAnswerList . Select ( t = > t . TranslateDicName ) . ToList ( ) ;
//针对1.1 整体肿瘤评估 有的两列要合并一列
if ( criterion . CriterionType = = CriterionType . RECIST1Point1 | | criterion . CriterionType = = CriterionType . RECIST1Pointt1_MB | | criterion . CriterionType = = CriterionType . IRECIST1Point1 )
{
foreach ( var item in list )
{
var removeList = item . QuestionAnswerList . Where ( t = > t . QuestionType = = QuestionType . ExistDisease | | t . QuestionType = = QuestionType . Tumor ) . ToList ( ) ;
//处理合并表头
if ( list . IndexOf ( item ) = = 0 )
{
var questionType = item . IsBaseline = = true ? QuestionType . ExistDisease : QuestionType . Tumor ;
var findItem = item . QuestionAnswerList . Where ( t = > t . QuestionType = = questionType ) . FirstOrDefault ( ) ;
findItem . QuestionName = _userInfo . IsEn_Us ? "Overall Response" : "整体肿瘤评估" ;
}
if ( item . IsBaseline = = true )
{
item . OverallTumorEvaluationResult = removeList . Where ( t = > t . QuestionType = = QuestionType . ExistDisease ) . FirstOrDefault ( ) ? . QuestionValue ;
item . QuestionAnswerList = item . QuestionAnswerList . Where ( t = > t . QuestionType ! = QuestionType . Tumor ) . ToList ( ) ;
}
else
{
item . OverallTumorEvaluationResult = removeList . Where ( t = > t . QuestionType ! = QuestionType . ExistDisease ) . FirstOrDefault ( ) ? . QuestionValue ;
item . QuestionAnswerList = item . QuestionAnswerList = item . QuestionAnswerList . Where ( t = > t . QuestionType ! = QuestionType . ExistDisease ) . ToList ( ) ;
}
item . QuestionAnswerList = item . QuestionAnswerList . Where ( t = > ! ( t . QuestionType = = QuestionType . ExistDisease | | t . QuestionType = = QuestionType . Tumor ) ) . ToList ( ) ;
}
}
else if ( criterion . CriterionType = = CriterionType . Lugano2014 | | criterion . CriterionType = = CriterionType . Lugano2014WithoutPET )
@@ -2151,18 +2232,24 @@ namespace IRaCIS.Core.Application.Service.Common
foreach ( var item in list )
{
var removeList = item . QuestionAnswerList . Where ( t = > t . QuestionType = = QuestionType . ExistDisease | | t . QuestionType = = QuestionType . ImgOncology ) . ToList ( ) ;
//处理合并表头
if ( list . IndexOf ( item ) = = 0 )
{
var questionType = item . IsBaseline = = true ? QuestionType . ExistDisease : QuestionType . ImgOncology ;
var findItem = item . QuestionAnswerList . Where ( t = > t . QuestionType = = questionType ) . FirstOrDefault ( ) ;
findItem . QuestionName = _userInfo . IsEn_Us ? "Overall Response" : "整体肿瘤评估" ;
}
if ( item . IsBaseline = = true )
{
item . OverallTumorEvaluationResult = removeList . Where ( t = > t . QuestionType = = QuestionType . ExistDisease ) . FirstOrDefault ( ) ? . QuestionValue ;
item . QuestionAnswerList = item . QuestionAnswerList . Where ( t = > t . QuestionType ! = QuestionType . ImgOncology ) . ToList ( ) ;
}
else
{
item . OverallTumorEvaluationResult = removeList . Where ( t = > t . QuestionType ! = QuestionType . ExistDisease ) . FirstOrDefault ( ) ? . QuestionValue ;
item . QuestionAnswerList = item . QuestionAnswerList = item . QuestionAnswerList . Where ( t = > t . QuestionType ! = QuestionType . ExistDisease ) . ToList ( ) ;
}
item . QuestionAnswerList = item . QuestionAnswerList . Where ( t = > ! ( t . QuestionType = = QuestionType . ExistDisease | | t . QuestionType = = QuestionType . ImgOncology ) ) . ToList ( ) ;
}
}
else if ( criterion . CriterionType = = CriterionType . PCWG3 )
@@ -2188,7 +2275,7 @@ namespace IRaCIS.Core.Application.Service.Common
DynamicListName = "QuestionAnswerList" ,
RemoveColunmIndexList = new List < int > ( ) { } ,
ColumnNameList = list . FirstOrDefault ( ) ? . QuestionAnswerList . Select ( t = > t . QuestionName ) . ToList ( ) ? ? new List < string > ( ) ,
TranslateDicNameList = list . FirstOrDefault ( ) ? . QuestionAnswerList . Select ( t = > t . TranslateDicName ) . ToList ( ) ? ? new List < string > ( )
TranslateDicNameList = translateDicNameList ? ? new List < string > ( )
} ;
@@ -2205,74 +2292,18 @@ namespace IRaCIS.Core.Application.Service.Common
} ;
}
/// <summary>
/// 裁判阅片明细表
/// 裁判一致率导出
/// </summary>
/// <param name="inQuery"></param>
/// <param name="_commonDocumentRepository"></param>
/// <param name="_dictionaryService"></param>
/// <param name="_trialRepository"></param>
/// <returns></returns>
[HttpPost]
public async Task < IActionResult > GetCommonJudgeEvaluationList_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 ( ) ;
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 < CommonEvaluationExport > ( _mapper . ConfigurationProvider , new { 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 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 ) ;
var dynamicColumnConfig = new DynamicColumnConfig ( ) { AutoColumnTitleRowIndex = 2 , AutoColumnStartIndex = 6 , ColumnNameList = list . FirstOrDefault ( ) ? . QuestionAnswerList . Select ( t = > t . QuestionName ) . ToList ( ) } ;
var ( memoryStream , fileName ) = await ExcelExportHelper . DataExport_NpoiTestAsync ( StaticData . Export . CommonJudgeReadingDetail_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"
} ;
}
/// <exception cref="Exception"></exception>
[HttpPost]
public async Task < IActionResult > GetCommonJudgeRatioList_Export ( VisitTaskQuery inQuery ,
[FromServices] IRepository < CommonDocument > _commonDocumentRepository ,