| 
						
					 | 
				
			
			 | 
			 | 
			
				@ -13,8 +13,10 @@ using Microsoft.AspNetCore.Hosting;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using Microsoft.AspNetCore.Mvc;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using NPOI.POIFS.Properties;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using NPOI.XSSF.UserModel;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using System.ComponentModel.Design;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using System.Globalization;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using static IRaCIS.Core.Application.Service.ExcelExportHelper;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				using IDictionaryService = IRaCIS.Application.Interfaces.IDictionaryService;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				namespace IRaCIS.Core.Application.Service.Common
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				{
 | 
			
		
		
	
	
		
			
				
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@ -1324,6 +1326,9 @@ namespace IRaCIS.Core.Application.Service.Common
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        ///影像检查列表-患者为维度组织
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// </summary>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="inQuery"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_patientRepository"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_dictionaryService"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_trialRepository"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <returns></returns>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        [HttpPost]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public async Task<IActionResult> GetPatientList_Export(PatientTrialQuery inQuery,
 | 
			
		
		
	
	
		
			
				
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@ -1387,194 +1392,42 @@ namespace IRaCIS.Core.Application.Service.Common
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <summary>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// 自身一致性分析(仅做了resist1.1)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// 邮件导出
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// </summary>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="inQuery"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_commonDocumentRepository"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_emailNoticeConfigrepository"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_dictionaryService"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_trialRepository"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <returns></returns>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        [HttpPost]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public async Task<IActionResult> GetSelfAnalysisTaskList_Export(VisitTaskQuery inQuery,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                [FromServices] IRepository<CommonDocument> _commonDocumentRepository,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                [FromServices] IDictionaryService _dictionaryService,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                [FromServices] IRepository<Trial> _trialRepository)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public async Task<IActionResult> GetEmailNoticeConfigList_Export(EmailNoticeConfigQuery inQuery,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            [FromServices] IRepository<EmailNoticeConfig> _emailNoticeConfigrepository,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				             [FromServices] IDictionaryService _dictionaryService)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var emailNoticeConfigQueryable = _emailNoticeConfigrepository
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //.WhereIf(inQuery.SystemLevel == null, t => t.SystemLevel == SysEmailLevel.not_sys)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //.WhereIf(inQuery.SystemLevel != null, t => t.SystemLevel == inQuery.SystemLevel)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //.WhereIf(inQuery.IsDistinguishCriteria != null, t => t.IsDistinguishCriteria == inQuery.IsDistinguishCriteria)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            .WhereIf(inQuery.CriterionTypeEnum != null, t => t.CriterionTypeEnum == inQuery.CriterionTypeEnum)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            .WhereIf(inQuery.BusinessScenarioEnum != null, t => t.BusinessScenarioEnum == inQuery.BusinessScenarioEnum)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            .WhereIf(inQuery.IsReturnRequired != null, t => t.IsReturnRequired == inQuery.IsReturnRequired)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            .WhereIf(inQuery.IsEnable != null, t => t.IsEnable == inQuery.IsEnable)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            .ProjectTo<EmailNoticeConfigExportDto>(_mapper.ConfigurationProvider);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var criterion = await _readingQuestionCriterionTrialRepository.Where(t => t.Id == inQuery.TrialReadingCriterionId).Select(t => new { t.CriterionType, t.CriterionName }).FirstNotNullAsync();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var list = await emailNoticeConfigQueryable.SortToListAsync(inQuery);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (criterion.CriterionType != CriterionType.RECIST1Point1)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //---当前标准导出还未支持
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                throw new Exception(_localizer["ExcelExport_UnsupportedExport"]);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //产生一致性分析的Subject
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var exportInfo = new ExcelExportInfo();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var subjectQuerybal = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.TaskState == TaskState.Effect && t.IsSelfAnalysis == true).Select(t => t.SubjectId).Distinct();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var allList = await _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.TaskState == TaskState.Effect && subjectQuerybal.Contains(t.SubjectId) && t.ReadingCategory == ReadingCategory.Visit)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .Where(t => (t.IsSelfAnalysis == true || t.IsSelfAnalysis == null) && t.VisitTaskNum > 0) //一致性分析的结果 + 正常任务的结果 + 仅仅访视的结果 +去除基线
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				               //.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<SelftAnalysisExport>(_mapper.ConfigurationProvider).ToListAsync();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var list = allList.Where(t => t.IsSelfAnalysis == null).OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.VisitTaskNum).ToList();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //To do 根据任务Id  找对评估结果,这里需要考虑标准  以及对应的翻译
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //基线和访视的评估结果翻译枚举 分别对应着
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            foreach (var item in list)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //找到一致性分析的结果
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                var selfAnalysisTask = allList.Where(t => t.IsSelfAnalysis == true && t.SubjectCode == item.SubjectCode && t.VisitTaskNum == item.VisitTaskNum && t.TaskName == t.TaskName && t.UserName == item.UserName).FirstOrDefault();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //因为基线的评估结果是 是否存在疾病 而 其他访视的结果是 整体肿瘤评估结果 是用不同的枚举翻译的 所以这里手动翻译 不把翻译逻辑耦合到通用的翻译代码里面 在此特殊处理
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                item.AgainEvaluateResult = selfAnalysisTask?.EvaluateResult ?? String.Empty;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //将自身一致性分析的字段 赋值到访视任务这个字段
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                item.IsAnalysisDiffToOriginalData = selfAnalysisTask?.IsAnalysisDiffToOriginalData;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo<ExcelExportInfo>(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            exportInfo.CriterionName = await _readingQuestionCriterionTrialRepository.Where(u => u.TrialId == inQuery.TrialId && u.IsConfirm && u.Id == inQuery.TrialReadingCriterionId).Select(t => t.CriterionName).FirstOrDefaultAsync();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSelfAnalysisList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SelftAnalysisExport));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <summary>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// 组件一致性分析(仅做了resist1.1)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// </summary>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="inQuery"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_commonDocumentRepository"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_dictionaryService"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_trialRepository"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <returns></returns>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        [HttpPost]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public async Task<IActionResult> GetGroupAnalysisTaskList_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 }).FirstNotNullAsync();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            if (criterion.CriterionType != CriterionType.RECIST1Point1)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //---当前标准导出还未支持
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                throw new Exception(_localizer["ExcelExport_UnsupportedExport"]);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //产生组间一致性分析的Subject
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var subjectQuerybal = _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.TaskState == TaskState.Effect && t.IsSelfAnalysis == false).Select(t => t.SubjectId).Distinct();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var allList = await _visitTaskRepository.Where(t => t.TrialId == inQuery.TrialId && t.TaskState == TaskState.Effect && subjectQuerybal.Contains(t.SubjectId) && t.ReadingCategory == ReadingCategory.Visit)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .Where(t => (t.IsSelfAnalysis == false || t.IsSelfAnalysis == null) && t.VisitTaskNum > 0) //一致性分析的结果 + 正常任务的结果 +仅仅访视的结果
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				               //.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<GroupAnalysisExport>(_mapper.ConfigurationProvider).ToListAsync();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            //找到原任务(非组间一致性分析的)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var list = allList.Where(t => t.IsSelfAnalysis == null).OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.VisitTaskNum).ToList();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var newList = new List<GroupAnalysisExport>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            // 每个subject访视进行分组
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            foreach (var group in list.GroupBy(t => new { t.SubjectCode, t.VisitTaskNum, t.TaskName, t.ArmEnum })
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .OrderBy(g => g.Key.SubjectCode)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                .ThenBy(g => g.Key.VisitTaskNum)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //.ThenBy(g => g.Key.ArmEnum)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                )
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                var subjectVisitGroupList = group.ToList();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                //找到当前访视组间一致性分析的任务结果
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                var groupTaskList = allList.Where(t => t.IsSelfAnalysis == false && t.SubjectCode == group.Key.SubjectCode && t.VisitTaskNum == group.Key.VisitTaskNum && t.TaskName == group.Key.TaskName).ToList();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                foreach (var subjectVisitTaskArm in subjectVisitGroupList.OrderBy(t => t.ArmEnum))
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    foreach (var item in groupTaskList)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        var cloneObj = subjectVisitTaskArm.Clone();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        cloneObj.AgainUserName = item.UserName;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        cloneObj.AgainEvaluateResult = item.EvaluateResult;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        cloneObj.AgainArmEnum = item.ArmEnum;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        cloneObj.IsGroupAnalysisDiffToOriginalData = cloneObj.ArmEnum == Arm.DoubleReadingArm1 ? item.IsGroupDiffArm1 : item.IsGroupDiffArm2;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        newList.Add(cloneObj);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo<ExcelExportInfo>(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            exportInfo.CriterionName = await _readingQuestionCriterionTrialRepository.Where(u => u.TrialId == inQuery.TrialId && u.IsConfirm && u.Id == inQuery.TrialReadingCriterionId).Select(t => t.CriterionName).FirstOrDefaultAsync();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(newList, _userInfo.TimeZoneId); ;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            exportInfo.CurrentTime = ExportExcelConverterDate.DateTimeInternationalToString(DateTime.Now, _userInfo.TimeZoneId);
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialGroupAnalysisList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(GroupAnalysisExport));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            return await ExcelExportHelper.DataExportAsync(StaticData.Export.EmailNoticeConfig_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(EmailNoticeConfigExportDto));
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        #region 导表公用
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        public class ExportDocumentDes
 | 
			
		
		
	
	
		
			
				
					| 
						
					 | 
				
			
			 | 
			 | 
			
				@ -1737,7 +1590,7 @@ namespace IRaCIS.Core.Application.Service.Common
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        #region 通用阅片结果导出
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <summary>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// 一致性分析结果导出   9 10  分别是自身 和组件一致性
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// 一致性分析结果导出   7 8  分别是自身 和组件一致性
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// </summary>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="inQuery"></param>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        /// <param name="_commonDocumentRepository"></param>
 | 
			
		
		
	
	
		
			
				
					| 
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |