From c97186a55766a2f4880eda7f7841147666ea9176 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 6 Jan 2025 16:05:02 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=9F=E9=99=A4?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E7=AD=BE=E7=BD=B2=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/ExcelExportService.cs | 10 +++++++++- .../Service/Document/SystemDocumentService.cs | 8 ++++++-- .../Service/TrialSiteUser/PersonalWorkstation.cs | 6 +++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 09d3d2185..d0534d11b 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -1837,6 +1837,8 @@ namespace IRaCIS.Core.Application.Service.Common var export_Template = StaticData.Export.TrialSelfAnalysisList_Export; + #region 自身一致性分析和组间一致性分析 + if (inQuery.ReadingExportType == ExportResult.DetailedTableOfIntraReaderAnalysisResults) { //找到非一致性分析的任务 @@ -1918,6 +1920,8 @@ namespace IRaCIS.Core.Application.Service.Common } + #endregion + var columNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.QuestionName.IsNotNullOrEmpty()).Select(t => t.QuestionName).Distinct().ToList(); exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list.Where(t => t.ReadingCategory != ReadingCategory.Global).ToList(), _userInfo.TimeZoneId); @@ -2086,7 +2090,11 @@ namespace IRaCIS.Core.Application.Service.Common inQuery.ReadingExportType == ExportResult.DetailedTableOfLesions || inQuery.ReadingExportType == ExportResult.TableOfAssessmentResults) { - removeColumnIndexList = new List() { 6, 7, 8 }; + if (!criterion.IsArbitrationReading) + { + //仲裁阅片 才有裁判阅片明细表 同时要把模板里面的三列给去掉 + removeColumnIndexList = new List() { 6, 7, 8 }; + } } var export_Template = StaticData.Export.CommonReading_Export; diff --git a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs index 7f288fbb1..827c6b40a 100644 --- a/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/SystemDocumentService.cs @@ -147,7 +147,8 @@ namespace IRaCIS.Core.Application.Services var isInternal = _userInfo.IsZhiZhun; - var query = from sysDoc in _systemDocumentRepository.Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)) + var query = from sysDoc in _systemDocumentRepository.AsQueryable(true) + .Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .WhereIf(!string.IsNullOrEmpty(inQuery.Name), t => t.Name.Contains(inQuery.Name)) //外部人员 只签署 文档类型枚举值有值的 .WhereIf(isInternal == false, t => t.DocUserSignType == DocUserSignType.InnerAndOuter) @@ -181,7 +182,10 @@ namespace IRaCIS.Core.Application.Services //UserTypeShortName = user.UserTypeRole.UserTypeShortName }; - var list = await query.WhereIf(inQuery.IsSigned == true, t => t.ConfirmTime != null) + var list = await query + //过滤掉删除的,并且没有签名的 + .Where(t => !(t.IsDeleted == true && t.ConfirmTime == null)) + .WhereIf(inQuery.IsSigned == true, t => t.ConfirmTime != null) .WhereIf(inQuery.IsSigned == false, t => t.ConfirmTime == null) .ToPagedListAsync(inQuery); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs index 7bd07c31e..8b6d5b8bd 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs @@ -1121,7 +1121,7 @@ namespace IRaCIS.Core.Application .Where(c => c.TrialDocumentList.Where(t => t.IsDeleted == false && t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId) && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null)).Count() > 0).CountAsync(); - var needSignSysDocCont = await _systemDocumentRepository + var needSignSysDocCont = await _systemDocumentRepository.AsQueryable(true) .Where(t => t.IsDeleted == false && !t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null)) //外部人员 只签署 文档类型枚举值有值的 .WhereIf(isInternal == false, t => t.DocUserSignType == DocUserSignType.InnerAndOuter) @@ -1133,8 +1133,8 @@ namespace IRaCIS.Core.Application .Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .Where(t => t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null)).CountAsync(); - var signedSysDocCont = await _systemDocumentRepository - .Where(t => t.IsDeleted == false && t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null)) + var signedSysDocCont = await _systemDocumentRepository.AsQueryable(true) + .Where(t => t.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null)) .SelectMany(t => t.NeedConfirmedUserTypeList) .CountAsync(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId); From 1676516441796e44f7cc16732d11373ebc3295c5 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 6 Jan 2025 16:41:33 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Helper/FileDocProcess/ExcelExportHelper.cs | 6 +++++- .../Service/TrialSiteUser/TrialConfigService.cs | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs index 48700c78c..cc94a4302 100644 --- a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs @@ -421,7 +421,7 @@ public static class ExcelExportHelper workbook.RemoveSheetAt(1); } - //中文替换项目术语 + #region 中文替换项目术语 if (data.TrialObjectNameList?.Count > 0) { var replaceObjectList = data.TrialObjectNameList; @@ -457,6 +457,9 @@ public static class ExcelExportHelper } } } + #endregion + + if (dynamicColumnConfig != null) { @@ -468,6 +471,7 @@ public static class ExcelExportHelper //动态移除列的数量 var dynamicRemoveColunmCount = dynamicColumnConfig.RemoveColunmIndexList.Count(); + //在动态列开始前移除的数量 var beforeDynamicRemoveCount = dynamicColumnConfig.RemoveColunmIndexList.Where(t => t < dynamicColumnConfig.AutoColumnStartIndex).Count(); //动态添加列的数量 diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index 2ab7a341a..acff62e72 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -1362,12 +1362,14 @@ namespace IRaCIS.Core.Application [AllowAnonymous] public async Task GetTrialExtralConfig(Guid trialId) { - var extralObj = _trialRepository.Where(t => t.Id == trialId).Select(t => new { t.TrialExtraConfigJsonStr, t.TrialObjectNameList }).FirstOrDefault(); + var extralObj = _trialRepository.Where(t => t.Id == trialId).Select(t => new { t.TrialExtraConfigJsonStr, t.TrialObjectNameList, t.CollectImagesEnum }).FirstOrDefault(); var extralConfig = JsonConvert.DeserializeObject(extralObj?.TrialExtraConfigJsonStr) ?? new TrialExtraConfig(); extralConfig.TrialObjectNameList = extralObj.TrialObjectNameList; + extralConfig.CollectImagesEnum = extralConfig.CollectImagesEnum; + return extralConfig; } /// From 6ead8ffd5319720cc8b068aa4da363a006da6253 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 6 Jan 2025 17:29:53 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E4=B8=B4=E6=97=B6=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/ExcelExportService.cs | 3 ++- .../Service/QC/DTO/QCListViewModel.cs | 12 ++++++++++ .../Service/QC/_MapConfig.cs | 23 +++++++++++-------- .../TrialSiteUser/TrialConfigService.cs | 2 +- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index d0534d11b..428317322 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -1929,6 +1929,7 @@ namespace IRaCIS.Core.Application.Service.Common var dynamicColumnConfig = new DynamicColumnConfig() { + //可读的列表名行索引,不是{{}} 模板行索引 AutoColumnTitleRowIndex = 2, AutoColumnStartIndex = 5, TempalteLastColumnIndex = 4, @@ -2182,7 +2183,7 @@ namespace IRaCIS.Core.Application.Service.Common 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(); diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index dfcb9885b..9fe4dab16 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -1168,6 +1168,8 @@ namespace IRaCIS.Core.Application.Contracts public string QuestionValue { get; set; } public string TranslateDicName { get; set; } + + public string CDISCCode { get; set; } } public class CommonEvaluationExport { @@ -1215,6 +1217,16 @@ namespace IRaCIS.Core.Application.Contracts public string JudgeNote { get; set; } = string.Empty; public string VisitNote { get; set; } + + #region CDISC_阅片结果表 + + //最晚拍片日期 + public DateTime? LatestScanDate { get; set; } + + //阅片完成时间 + public DateTime? SignTime { get; set; } + + #endregion } public class CommonLessionExport : CommonEvaluationExport diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index f2457e0b1..8d3f6badc 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -28,7 +28,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.QCProcessEnum, u => u.MapFrom(s => s.Trial.QCProcessEnum)) .ForMember(d => d.SubjectCode, u => u.MapFrom(s => s.Subject.Code)) .ForMember(d => d.SubjectStatus, u => u.MapFrom(s => s.Subject.Status)) - + .ForMember(d => d.SubmitUserName, u => u.MapFrom(s => s.SubmitUser.FullName)) .ForMember(d => d.ClinicalInformationTransmissionEnum, u => u.MapFrom(s => s.Trial.ClinicalInformationTransmissionEnum)) @@ -242,7 +242,8 @@ namespace IRaCIS.Core.Application.Service QuestionType = c.ReadingQuestionTrial.QuestionType, QuestionName = isEn_Us ? c.ReadingQuestionTrial.QuestionEnName : c.ReadingQuestionTrial.QuestionName, QuestionValue = c.IsGlobalChange ? c.GlobalChangeAnswer : c.Answer, - TranslateDicName = c.ReadingQuestionTrial.DictionaryCode + TranslateDicName = c.ReadingQuestionTrial.DictionaryCode, + CDISCCode = c.ReadingQuestionTrial.CDISCCode }))) ; @@ -255,15 +256,16 @@ namespace IRaCIS.Core.Application.Service (arbitrationRule == ArbitrationRule.Reading ? u.Subject.SubjectVisitTaskList.Any(t => t.TaskState == TaskState.Effect && t.IsAnalysisCreate == false && t.ReadingCategory == ReadingCategory.Judge && t.TrialReadingCriterionId == trialReadingCriterionId && u.VisitTaskNum < t.VisitTaskNum) : false))) - .ForMember(o => o.JudgeNote, t => t.MapFrom(u => u.ReadingCategory==ReadingCategory.Judge? u.JudgeResultRemark : u.JudgeVisitTask.JudgeResultRemark)) + .ForMember(o => o.JudgeNote, t => t.MapFrom(u => u.ReadingCategory == ReadingCategory.Judge ? u.JudgeResultRemark : u.JudgeVisitTask.JudgeResultRemark)) .ForMember(o => o.VisitNote, t => t.MapFrom(u => u.ReadingTaskQuestionAnswerList.Where(c => c.ReadingQuestionTrial.QuestionType == QuestionType.AdjustReason).FirstOrDefault()!.Answer)) //.ForMember(o => o.IsSubjectHaveReadingPeriod, t => t.MapFrom(u => arbitrationRule == ArbitrationRule.Reading ? //u.Subject.ReadModuleList.Any(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.ReadingSetType == ReadingSetType.ImageReading) : false)) - - .ForMember(o => o.SubjectCriterionReadingPeriodVisitNumList, t => t.MapFrom(u => - u.Subject.ReadModuleList.Where(t=>t.TrialReadingCriterionId == trialReadingCriterionId && t.ReadingSetType == ReadingSetType.ImageReading).Select(c=>c.SubjectVisit.VisitNum))) + + .ForMember(o => o.SubjectCriterionReadingPeriodVisitNumList, t => t.MapFrom(u => + u.Subject.ReadModuleList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.ReadingSetType == ReadingSetType.ImageReading).Select(c => c.SubjectVisit.VisitNum))) .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.Subject.TrialSite.TrialSiteCode)) + .ForMember(o => o.LatestScanDate, t => t.MapFrom(u => u.SourceSubjectVisit.LatestScanDate)) .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.Subject.Code)) .ForMember(o => o.UserName, t => t.MapFrom(u => u.DoctorUser.UserName)) .ForMember(o => o.QuestionAnswerList, t => t.MapFrom(u => u.ReadingTaskQuestionAnswerList @@ -273,8 +275,9 @@ namespace IRaCIS.Core.Application.Service { QuestionType = c.ReadingQuestionTrial.QuestionType, QuestionName = isEn_Us ? c.ReadingQuestionTrial.QuestionEnName : c.ReadingQuestionTrial.QuestionName, - QuestionValue = c.IsGlobalChange?c.GlobalChangeAnswer: c.Answer, - TranslateDicName = c.ReadingQuestionTrial.DictionaryCode + QuestionValue = c.IsGlobalChange ? c.GlobalChangeAnswer : c.Answer, + TranslateDicName = c.ReadingQuestionTrial.DictionaryCode, + CDISCCode=c.ReadingQuestionTrial.CDISCCode }))) ; @@ -669,7 +672,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.CreateUserName, u => u.MapFrom(s => s.CreateUserRole.IdentityUser.UserName)) .ForMember(d => d.LatestReplyUserName, u => u.MapFrom(t => t.LatestReplyUser.UserName)) .ForMember(d => d.LatestReplyUserFullName, u => u.MapFrom(t => t.LatestReplyUser.FullName)) - + .ForMember(d => d.ChallengeCode, u => u.MapFrom(s => s.ChallengeCode)); //排序的时候有坑 把这个带到sql 中去了 //.AfterMap((src, dest) => dest.ChallengeCode = "Q" + src.ChallengeCode.ToString("D5"));//实测没有效果 @@ -707,7 +710,7 @@ namespace IRaCIS.Core.Application.Service Guid? visiTaskId = null; CreateMap() .ForMember(d => d.NoneDicomStudyFileList, u => u.MapFrom(s => isFilterZip ? - s.TaskNoneDicomFileList.Where(t => visiTaskId != null ? t.VisitTaskId == visiTaskId : true).Where(t => !t.FileType.Contains(StaticData.FileType.Zip)).OrderBy(t => t.CreateTime).ThenBy(t=>t.FileName) + s.TaskNoneDicomFileList.Where(t => visiTaskId != null ? t.VisitTaskId == visiTaskId : true).Where(t => !t.FileType.Contains(StaticData.FileType.Zip)).OrderBy(t => t.CreateTime).ThenBy(t => t.FileName) : s.TaskNoneDicomFileList.Where(t => visiTaskId != null ? t.VisitTaskId == visiTaskId : true).OrderBy(t => t.CreateTime).ThenBy(t => t.FileName))) .ForMember(d => d.CodeView, u => u.MapFrom(s => s.StudyCode)); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index acff62e72..81d477125 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -1368,7 +1368,7 @@ namespace IRaCIS.Core.Application extralConfig.TrialObjectNameList = extralObj.TrialObjectNameList; - extralConfig.CollectImagesEnum = extralConfig.CollectImagesEnum; + extralConfig.CollectImagesEnum = extralObj.CollectImagesEnum; return extralConfig; } From 1a64c07c8e6193c7a2273ae066f739efddac4bde Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 6 Jan 2025 17:58:17 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E5=AF=BC=E8=A1=A8=E5=87=86=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/Common/ExcelExportService.cs | 29 ++++++++++++++----- .../Service/QC/DTO/QCListViewModel.cs | 10 ++++--- .../Service/QC/_MapConfig.cs | 1 + 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 428317322..0d6cc4f25 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -2122,10 +2122,20 @@ namespace IRaCIS.Core.Application.Service.Common export_Template = StaticData.Export.ReadingLession_Export; } + else if (inQuery.ReadingExportType == ExportResult.OCT_ReadingLession_Export) + { + //OCT + export_Template = StaticData.Export.OCT_ReadingLession_Export; + + } - //病灶明细表 需要单独处理 - if (inQuery.ReadingExportType != ExportResult.DetailedTableOfLesions && inQuery.ReadingExportType != ExportResult.OCT_ReadingLession_Export) + + if (inQuery.ReadingExportType == ExportResult.TableOfAssessmentResults || + inQuery.ReadingExportType == ExportResult.DetailedTableOfAssessmentResults || + inQuery.ReadingExportType == ExportResult.DetailedTableOfAdjudicationResults + ) + { //其他可以统一处理 list = await query.ProjectTo(_mapper.ConfigurationProvider, @@ -2138,13 +2148,10 @@ namespace IRaCIS.Core.Application.Service.Common isEn_Us = _userInfo.IsEn_Us }).ToListAsync(); } - else + //病灶明细表 斑块表 需要单独处理 + else if (inQuery.ReadingExportType == ExportResult.DetailedTableOfLesions || + inQuery.ReadingExportType == ExportResult.OCT_ReadingLession_Export) { - //病灶明细表 - if (inQuery.ReadingExportType == ExportResult.OCT_ReadingLession_Export) - { - export_Template = StaticData.Export.OCT_ReadingLession_Export; - } var taskList = await query.ProjectTo(_mapper.ConfigurationProvider, new @@ -2241,6 +2248,12 @@ namespace IRaCIS.Core.Application.Service.Common } + } + else if (inQuery.ReadingExportType == ExportResult.CDISC) + { + // 配置在外层问题 或者表格问题上 + + } #endregion diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index 9fe4dab16..ffe5176de 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -1231,10 +1231,10 @@ namespace IRaCIS.Core.Application.Contracts public class CommonLessionExport : CommonEvaluationExport { - /// - /// 最终导出的病灶信息 - /// - public List LessionAnswerList { get; set; } + ///// + ///// 最终导出的病灶信息 + ///// + //public List LessionAnswerList { get; set; } [JsonIgnore] @@ -1267,6 +1267,8 @@ namespace IRaCIS.Core.Application.Contracts public string QuestionValue { get; set; } public string TranslateDicName { get; set; } + + public string CDISCCode { get; set; } } diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index 8d3f6badc..241024ac7 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -295,6 +295,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.QuestionMark, t => t.MapFrom(u => u.ReadingTableQuestionTrial.QuestionMark)) .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.TranslateDicName, t => t.MapFrom(u => u.ReadingTableQuestionTrial.DictionaryCode)) ; From 83749e15cb7909fbcccae68f8a8a29f567f760b3 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 7 Jan 2025 10:34:19 +0800 Subject: [PATCH 05/13] CDISC_Reading_Export --- .../FileDocProcess/ExcelExportHelper.cs | 313 +++++++++++++++++- .../IRaCIS.Core.Application.xml | 10 +- .../Service/Common/ExcelExportService.cs | 298 +++++++++++------ .../Service/QC/DTO/QCListViewModel.cs | 18 +- .../Service/QC/_MapConfig.cs | 4 +- .../_IRaCIS/_Config/_StaticData.cs | 2 +- 6 files changed, 535 insertions(+), 110 deletions(-) diff --git a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs index cc94a4302..58223c3bf 100644 --- a/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs +++ b/IRaCIS.Core.Application/Helper/FileDocProcess/ExcelExportHelper.cs @@ -64,7 +64,7 @@ public static class ExcelExportHelper foreach (var key in dic.Keys) { //是数组 那么找到对应的属性 进行翻译 - if (dic[key]!=null && dic[key].GetType().GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList<>))) + if (dic[key] != null && dic[key].GetType().GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList<>))) { var newObjList = new List(); @@ -255,9 +255,13 @@ public static class ExcelExportHelper /// public int AutoColumnTitleRowIndex { get; set; } - + /// + /// 模板列最后的索引 + /// public int TempalteLastColumnIndex { get; set; } + public List CDISCList { get; set; } = new List(); + /// /// 动态的列名 /// @@ -639,6 +643,311 @@ public static class ExcelExportHelper } + public static async Task<(MemoryStream, string)> CDISC_DataExport_Async(string code, ExcelExportInfo data, IRepository _commonDocumentRepository, IWebHostEnvironment _hostEnvironment, IDictionaryService? _dictionaryService = null, Type? translateType = null, CriterionType? criterionType = null, DynamicColumnConfig? dynamicColumnConfig = null) + { + var isEn_US = CultureInfo.CurrentCulture.Name == StaticData.CultureInfo.en_US; + //判断是否有字典翻译 + + object translateData = data; + + Dictionary translatedDic = default; + + if (_dictionaryService != null && translateType != null) + { + + //一个值 对应不同的字典翻译 + var needTranslatePropertyList = translateType.GetProperties().Where(t => t.IsDefined(typeof(DictionaryTranslateAttribute), true)) + .SelectMany(c => + c.GetCustomAttributes(typeof(DictionaryTranslateAttribute), false).Select(f => (DictionaryTranslateAttribute?)f).Where(t => t.CriterionType == criterionType || t.CriterionType == null) + .Select(k => new { c.Name, k.DicParentCode, k.IsTranslateDenpendOtherProperty, k.DependPropertyName, k.DependPropertyValueStr }) + ).ToList(); + + + + //字典表查询出所有需要翻译的数据 + + var translateDataList = await _dictionaryService.GetBasicDataSelect(needTranslatePropertyList.Select(t => t.DicParentCode).Distinct().ToArray()); + + var dic = data.ConvertToDictionary(); + //var dic = (JsonConvert.DeserializeObject>(data.ToJsonNotIgnoreNull())).IfNullThrowException(); + + foreach (var key in dic.Keys) + { + //是数组 那么找到对应的属性 进行翻译 + if (dic[key] != null && dic[key].GetType().GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(IList<>))) + //if (dic[key].GetType().IsAssignableFrom(typeof(JArray))) + { + + var newObjList = new List(); + var no = 1; + foreach (var item in dic[key] as IList) + //foreach (var item in dic[key] as JArray) + { + //var itemDic = JsonConvert.DeserializeObject>(item.ToJsonNotIgnoreNull()); + var itemDic = item.ConvertToDictionary(); + + foreach (var needTranslateProperty in needTranslatePropertyList) + { + if (itemDic.Keys.Any(t => t == needTranslateProperty.Name)) + { + //翻译的属性依赖其他属性 + if (needTranslateProperty.IsTranslateDenpendOtherProperty) + { + if (itemDic[needTranslateProperty.DependPropertyName]?.ToString().ToLower() == needTranslateProperty.DependPropertyValueStr.ToLower()) + { + var beforeValue = itemDic[needTranslateProperty.Name]?.ToString(); + + itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty; + } + } + //普通翻译 或者某一标准翻译 + else + { + var beforeValue = itemDic[needTranslateProperty.Name]?.ToString(); + + + itemDic[needTranslateProperty.Name] = translateDataList[needTranslateProperty.DicParentCode].Where(t => t.Code.ToLower() == beforeValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty; + } + } + + + + + } + + itemDic.Add("No", no++); + newObjList.Add(itemDic); + } + + dic[key] = newObjList; + + } + } + + + //data = dic; + translateData = dic; + translatedDic = dic; + + } + + + var (physicalPath, fileName) = await FileStoreHelper.GetCommonDocPhysicalFilePathAsync(_hostEnvironment, _commonDocumentRepository, code); + + + //模板路径 + var tplPath = physicalPath; + + #region 根据中英文 删除模板sheet + + // 打开模板文件 + var templateFile = new FileStream(tplPath, FileMode.Open, FileAccess.Read); + + // 获取文件流 + var templateStream = new MemoryStream(); + templateFile.CopyTo(templateStream); + templateStream.Seek(0, SeekOrigin.Begin); + + var workbook = new XSSFWorkbook(templateStream); + + int sheetCount = workbook.NumberOfSheets; + + if (sheetCount == 2) + { + if (isEn_US) + { + workbook.RemoveSheetAt(0); + } + else + { + workbook.RemoveSheetAt(1); + } + + if (dynamicColumnConfig != null) + { + var sheet = workbook.GetSheetAt(0); + + + var cdicsRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex - 1); + var titelRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex); + var templateRow = sheet.GetRow(dynamicColumnConfig.AutoColumnTitleRowIndex + 1); + + //动态移除列的数量 + var dynamicRemoveColunmCount = dynamicColumnConfig.RemoveColunmIndexList.Count(); + + //在动态列开始前移除的数量 + var beforeDynamicRemoveCount = dynamicColumnConfig.RemoveColunmIndexList.Where(t => t < dynamicColumnConfig.AutoColumnStartIndex).Count(); + + //动态添加列的数量 + var needAddCount = dynamicColumnConfig.ColumnNameList.Count; + + //原始表 最终索引 + var originTotalEndIndex = dynamicColumnConfig.TempalteLastColumnIndex; + + //减去动态移除后原始结束索引 + var originRemoveEndIndex = originTotalEndIndex - dynamicRemoveColunmCount; + + //最终表 动态列开始索引 + var dynamicColunmStartIndex = dynamicColumnConfig.AutoColumnStartIndex - beforeDynamicRemoveCount; + + //最终表 动态列的终止索引 + var dynamicColunmEndIndex = dynamicColunmStartIndex + needAddCount - 1; + + //最终表 最终索引 + var totalColunmEndIndex = originTotalEndIndex + needAddCount - dynamicRemoveColunmCount; + + + //动态列后需要移动的数量 + var backMoveCount = totalColunmEndIndex - dynamicColunmEndIndex; + + //删除需要动态删除的列 从大到小移除,否则索引会变 + foreach (var removeIndex in dynamicColumnConfig.RemoveColunmIndexList.OrderByDescending(t => t)) + { + //将后面的列向前移动 + for (var i = 0; i < originTotalEndIndex - removeIndex; i++) + { + Console.WriteLine(titelRow.GetCell(removeIndex + i + 1).StringCellValue); + titelRow.GetCell(removeIndex + i).SetCellValue(titelRow.GetCell(removeIndex + i + 1).StringCellValue); + templateRow.GetCell(removeIndex + i).SetCellValue(templateRow.GetCell(removeIndex + i + 1).StringCellValue); + + //后面的数据要清空 + titelRow.GetCell(removeIndex + i + 1).SetCellValue(""); + templateRow.GetCell(removeIndex + i + 1).SetCellValue(""); + + } + + } + + //创建新的列 + for (int i = originTotalEndIndex; i < originTotalEndIndex + needAddCount; i++) + { + cdicsRow.CreateCell(i + 1); + titelRow.CreateCell(i + 1); + templateRow.CreateCell(i + 1); + } + //移动Title 和下面的模板标识 + + var gap = totalColunmEndIndex - originRemoveEndIndex; + + for (int i = totalColunmEndIndex; i > dynamicColunmEndIndex; i--) + { + + titelRow.GetCell(i).SetCellValue(titelRow.GetCell(i - gap).StringCellValue); + + templateRow.GetCell(i).SetCellValue(templateRow.GetCell(i - gap).StringCellValue); + } + + + + //设置动态Tilte + + for (int i = dynamicColunmStartIndex; i < dynamicColunmStartIndex + needAddCount; i++) + { + var name = dynamicColumnConfig.ColumnNameList[i - dynamicColunmStartIndex]; + + var cdicsCode= dynamicColumnConfig.CDISCList[i - dynamicColunmStartIndex]; + + cdicsRow.GetCell(i).SetCellValue(cdicsCode); + titelRow.GetCell(i).SetCellValue(name); + templateRow.GetCell(i).SetCellValue(""); + } + } + + using (var memoryStream2 = new MemoryStream()) + { + workbook.Write(memoryStream2, true); + + memoryStream2.Seek(0, SeekOrigin.Begin); + + templateStream = memoryStream2; + } + + } + + #endregion + + #region MiniExcel + + var memoryStream = new MemoryStream(); + + var config = new OpenXmlConfiguration() + { + IgnoreTemplateParameterMissing = true, + }; + + await MiniExcel.SaveAsByTemplateAsync(memoryStream, templateStream.ToArray(), translateData, config); + + memoryStream.Seek(0, SeekOrigin.Begin); + + if (dynamicColumnConfig != null) + { + var dynamicTranslateDataList = await _dictionaryService.GetBasicDataSelect(dynamicColumnConfig.TranslateDicNameList.ToArray()); + + // 使用NPOI 进行二次处理 + var wb = new XSSFWorkbook(memoryStream); + var sheet = wb.GetSheetAt(0); + + var list = translatedDic["List"] as IList; + + foreach (var itemResult in list) + { + var index = list.IndexOf(itemResult); + + //从第四行开始处理动态列 + var row = sheet.GetRow(index + dynamicColumnConfig.AutoColumnTitleRowIndex + 1); + + var itemDic = itemResult.ToDictionary(); + + var itemList = itemDic[dynamicColumnConfig.DynamicListName] as IList; + + //这个数组是动态的,有的多,有的少,所以在此对比Title 一致才赋值 + foreach (var itemObj in itemList) + { + + var iteObjDic = itemObj.ToDictionary(); + + var itemDicName = iteObjDic[dynamicColumnConfig.DynamicItemDicName]?.ToString(); + var itemValue = iteObjDic[dynamicColumnConfig.DynamicItemValueName]?.ToString(); + + //var writeIndex = itemList.IndexOf(itemObj) + dynamicColumnConfig.AutoColumnStartIndex; + + var writeIndex = dynamicColumnConfig.ColumnNameList.IndexOf(iteObjDic[dynamicColumnConfig.DynamicItemTitleName].ToString()) + dynamicColumnConfig.AutoColumnStartIndex; + + if (itemDicName.IsNotNullOrEmpty()) + { + + var translatedItemData = dynamicTranslateDataList[itemDicName].Where(t => t.Code.ToLower() == itemValue?.ToLower()).Select(t => isEn_US ? t.Value : t.ValueCN).FirstOrDefault() ?? String.Empty; + + row.GetCell(writeIndex).SetCellValue(translatedItemData); + } + else + { + row.GetCell(writeIndex).SetCellValue(itemValue); + + } + + } + } + + var memoryStream2 = new MemoryStream(); + wb.Write(memoryStream2, true); + memoryStream2.Seek(0, SeekOrigin.Begin); + + memoryStream = memoryStream2; + + } + + + return (memoryStream, fileName); + + + + + #endregion + } + + + /// /// 导出文件模板 /// diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index a464a5c18..e355cc746 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -67,6 +67,11 @@ 动态列开始的行index 从0开始 + + + 模板列最后的索引 + + 动态的列名 @@ -15292,11 +15297,6 @@ 组件一致性和原Arm2是否有差异 - - - 最终导出的病灶信息 - - QCChallengeId diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 0d6cc4f25..70692f8d6 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -1989,6 +1989,10 @@ namespace IRaCIS.Core.Application.Service.Common { list.Add(new ExportDocumentDes() { Code = StaticData.Export.OCT_ReadingLession_Export, ExportCatogory = ExportResult.OCT_ReadingLession_Export }); } + else if (criterion.CriterionType == CriterionType.SelfDefine) + { + list.Add(new ExportDocumentDes() { Code = StaticData.Export.CDISC_Reading_Export, ExportCatogory = ExportResult.CDISC }); + } switch (criterion.ArbitrationRule) { @@ -2120,13 +2124,16 @@ namespace IRaCIS.Core.Application.Service.Common { //病灶明细表 export_Template = StaticData.Export.ReadingLession_Export; - } else if (inQuery.ReadingExportType == ExportResult.OCT_ReadingLession_Export) { //OCT export_Template = StaticData.Export.OCT_ReadingLession_Export; - + } + else + { + //CDISC + export_Template = StaticData.Export.CDISC_Reading_Export; } @@ -2252,7 +2259,59 @@ namespace IRaCIS.Core.Application.Service.Common else if (inQuery.ReadingExportType == ExportResult.CDISC) { // 配置在外层问题 或者表格问题上 + var taskList = await query.ProjectTo(_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(); + + //通过问题标识取并集 + + var dynamicTitleList = lessionAnserList.Select(t => new DymamicQuestionInfo { QuestionMark = t.QuestionMark, QuestionName = t.QuestionName, TranslateDicName = t.TranslateDicName }).Distinct(); + + //最终的病灶列表 要把裁判的也要加进去,需要处理裁判标记 + list = new List(); + + foreach (var item in taskList.OrderBy(t => t.SubjectCode).ThenBy(t => t.ArmEnum).ThenBy(t => t.VisitTaskNum)) + { + if (item.LesionList.Count > 0) + { + foreach (var lession in item.LesionList.OrderBy(t => t.LessionType).ThenBy(t => t.LessionCode)) + { + + var dynamicPartialLessionInfoList = lession.LessionAnswerList.Select(t => new CommonQuesionInfo() { QuestionName = t.QuestionName, QuestionValue = t.QuestionValue, TranslateDicName = t.TranslateDicName, CDISCCode = t.CDISCCode }); + + + //有三部分组成 外层问题+ 没有配置病灶编号和类型+ 动态的表格问题 + var dynamicLessionInfoList = item.QuestionAnswerList.Union(dynamicPartialLessionInfoList).ToList(); + + //OCT 多个表格,但是只导出一个表格,有的问题答案就是空的 + if (dynamicLessionInfoList.Count > 0) + { + + var cloneItem = item.Clone(); + cloneItem.QuestionAnswerList = dynamicLessionInfoList; + + list.Add(cloneItem); + } + + } + } + else + { + //要把裁判任务加进去 裁判任务上没有病灶 + + list.Add(item); + } + + } } @@ -2261,111 +2320,160 @@ namespace IRaCIS.Core.Application.Service.Common list = list.OrderBy(t => t.SubjectCode).ThenBy(t => t.ArmEnum).ThenBy(t => t.VisitTaskNum).ToList(); + //处理裁判标记 + list = DealJudgeMark(criterion.ArbitrationRule, criterion.IsGlobalReading, list); + + //合并之前获取翻译的字典名,否则有的没法翻译 + var translateDicNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.TranslateDicName.IsNotNullOrEmpty()).Select(t => t.TranslateDicName).Distinct().ToList(); + + + if (inQuery.ReadingExportType != ExportResult.CDISC) + { + #region 系统标准处理整体肿瘤评估合并 + + //针对1.1 整体肿瘤评估 有的两列要合并一列 + if (criterion.CriterionType == CriterionType.RECIST1Point1 || criterion.CriterionType == CriterionType.RECIST1Pointt1_MB || criterion.CriterionType == CriterionType.IRECIST1Point1) + { + foreach (var item in list) + { + //处理合并表头 + + var questionType = item.IsBaseline == true ? QuestionType.ExistDisease : QuestionType.Tumor; + + var findItem = item.QuestionAnswerList.Where(t => t.QuestionType == questionType).FirstOrDefault(); + + if (findItem != null) + { + findItem.QuestionName = _userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估"; + } + + + if (item.IsBaseline == true) + { + item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.Tumor).ToList(); + } + else + { + item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ExistDisease).ToList(); + } + } + } + else if (criterion.CriterionType == CriterionType.Lugano2014 || criterion.CriterionType == CriterionType.Lugano2014WithoutPET) + { + + foreach (var item in list) + { + //处理合并表头 + + var questionType = item.IsBaseline == true ? QuestionType.ExistDisease : QuestionType.ImgOncology; + + var findItem = item.QuestionAnswerList.Where(t => t.QuestionType == questionType).FirstOrDefault(); + + if (findItem != null) + { + findItem.QuestionName = _userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估"; + } + + if (item.IsBaseline == true) + { + item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ImgOncology).ToList(); + } + else + { + item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ExistDisease).ToList(); + } + } + } + else if (criterion.CriterionType == CriterionType.PCWG3) + { + + } + + + if (export_Template == StaticData.Export.CommonJudgeReadingDetail_Export) + { + //裁判产生标记为空的数据过滤掉 + list = list.Where(t => t.IsTrigerJudge != null).ToList(); + } + + #endregion + + } + + + + var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.CriterionName = criterion.CriterionName; - //处理裁判标记 - list = DealJudgeMark(criterion.ArbitrationRule, criterion.IsGlobalReading, list); - - - #region 系统标准处理整体肿瘤评估合并 - - 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) - { - foreach (var item in list) - { - //处理合并表头 - - var questionType = item.IsBaseline == true ? QuestionType.ExistDisease : QuestionType.Tumor; - - var findItem = item.QuestionAnswerList.Where(t => t.QuestionType == questionType).FirstOrDefault(); - - if (findItem != null) - { - findItem.QuestionName = _userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估"; - } - - - if (item.IsBaseline == true) - { - item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.Tumor).ToList(); - } - else - { - item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ExistDisease).ToList(); - } - } - } - else if (criterion.CriterionType == CriterionType.Lugano2014 || criterion.CriterionType == CriterionType.Lugano2014WithoutPET) - { - - foreach (var item in list) - { - //处理合并表头 - - var questionType = item.IsBaseline == true ? QuestionType.ExistDisease : QuestionType.ImgOncology; - - var findItem = item.QuestionAnswerList.Where(t => t.QuestionType == questionType).FirstOrDefault(); - - if (findItem != null) - { - findItem.QuestionName = _userInfo.IsEn_Us ? "Overall Response" : "整体肿瘤评估"; - } - - if (item.IsBaseline == true) - { - item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ImgOncology).ToList(); - } - else - { - item.QuestionAnswerList = item.QuestionAnswerList.Where(t => t.QuestionType != QuestionType.ExistDisease).ToList(); - } - } - } - else if (criterion.CriterionType == CriterionType.PCWG3) - { - - } - - var columNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.QuestionName.IsNotNullOrEmpty()).Select(t => t.QuestionName).Distinct().ToList(); - - #endregion - - if (export_Template == StaticData.Export.CommonJudgeReadingDetail_Export) - { - //裁判产生标记为空的数据过滤掉 - list = list.Where(t => t.IsTrigerJudge != null).ToList(); - } - 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() + var dynamicColumnConfig = new DynamicColumnConfig(); + + if (inQuery.ReadingExportType != ExportResult.CDISC) { - AutoColumnTitleRowIndex = 2, - AutoColumnStartIndex = 6, - TempalteLastColumnIndex = 8, - DynamicItemDicName = "TranslateDicName", - DynamicItemValueName = "QuestionValue", - DynamicItemTitleName = "QuestionName", - DynamicListName = "QuestionAnswerList", - RemoveColunmIndexList = removeColumnIndexList, - ColumnNameList = columNameList ?? new List(), - TranslateDicNameList = translateDicNameList ?? new List() - }; + //合并之后获取最后的列名 + var columNameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.QuestionName.IsNotNullOrEmpty()).Select(t => t.QuestionName).Distinct().ToList(); - var (memoryStream, fileName) = await ExcelExportHelper.DataExport_NpoiTestAsync(export_Template, exportInfo, _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CommonEvaluationExport), criterion.CriterionType, dynamicColumnConfig); + dynamicColumnConfig = new DynamicColumnConfig() + { + AutoColumnTitleRowIndex = 2, + AutoColumnStartIndex = 6, + TempalteLastColumnIndex = 8, + DynamicItemDicName = "TranslateDicName", + DynamicItemValueName = "QuestionValue", + DynamicItemTitleName = "QuestionName", + DynamicListName = "QuestionAnswerList", + RemoveColunmIndexList = removeColumnIndexList, + ColumnNameList = columNameList ?? new List(), + TranslateDicNameList = translateDicNameList ?? new List() + }; - return new FileStreamResult(memoryStream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") + 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" + }; + + } + else { - FileDownloadName = $"{exportInfo.ResearchProgramNo}_{exportInfo.CriterionName}_{fileName}_{DateTime.Now.ToString("yyyyMMddHHmmss")}.xlsx" - }; + + var nameList = list.SelectMany(t => t.QuestionAnswerList).Where(t => t.QuestionName.IsNotNullOrEmpty() && t.CDISCCode.IsNotNullOrEmpty()).Select(t => new { t.QuestionName, t.CDISCCode }).Distinct().ToList(); + + var columNameList = nameList.Select(t => t.QuestionName).Distinct().ToList(); + var cdiscCodeList = nameList.Select(t => t.CDISCCode).Distinct().ToList(); + + dynamicColumnConfig = new DynamicColumnConfig() + { + AutoColumnTitleRowIndex = 1, + AutoColumnStartIndex = 6, + TempalteLastColumnIndex = 10, + DynamicItemDicName = "TranslateDicName", + DynamicItemValueName = "QuestionValue", + DynamicItemTitleName = "QuestionName", + DynamicListName = "QuestionAnswerList", + RemoveColunmIndexList = removeColumnIndexList, + ColumnNameList = columNameList ?? new List(), + CDISCList = cdiscCodeList, + TranslateDicNameList = translateDicNameList ?? new List() + }; + + var (memoryStream, fileName) = await ExcelExportHelper.CDISC_DataExport_Async(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" + }; + } + + + + } diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index ffe5176de..9ac293710 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -302,18 +302,20 @@ namespace IRaCIS.Core.Application.Contracts public string LatestReplyUserName { get; set; } = String.Empty; public string Content { get; set; } = string.Empty; - public string ContentReplaced { + public string ContentReplaced + { - get { - - var msg= Content.Replace("
", "").Replace("
", ""); + get + { + + var msg = Content.Replace("
", "").Replace("
", ""); string[] substrings = msg.Split(new string[] { "
", "
" }, StringSplitOptions.None); return string.Join("\n\n", substrings); } - - } + + } [DictionaryTranslateAttribute("ChallengeIsClosed")] public bool IsClosed { get; set; } @@ -1220,6 +1222,10 @@ namespace IRaCIS.Core.Application.Contracts #region CDISC_阅片结果表 + public string TrialCode { get; set; } + + public string TrialSiteSubjectCode => TrialSiteCode + SubjectCode; + //最晚拍片日期 public DateTime? LatestScanDate { get; set; } diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index 241024ac7..87d69ffea 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -264,6 +264,8 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.SubjectCriterionReadingPeriodVisitNumList, t => t.MapFrom(u => u.Subject.ReadModuleList.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.ReadingSetType == ReadingSetType.ImageReading).Select(c => c.SubjectVisit.VisitNum))) + + .ForMember(o => o.TrialCode, t => t.MapFrom(u => u.Trial.TrialCode)) .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.Subject.TrialSite.TrialSiteCode)) .ForMember(o => o.LatestScanDate, t => t.MapFrom(u => u.SourceSubjectVisit.LatestScanDate)) .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.Subject.Code)) @@ -277,7 +279,7 @@ namespace IRaCIS.Core.Application.Service QuestionName = isEn_Us ? c.ReadingQuestionTrial.QuestionEnName : c.ReadingQuestionTrial.QuestionName, QuestionValue = c.IsGlobalChange ? c.GlobalChangeAnswer : c.Answer, TranslateDicName = c.ReadingQuestionTrial.DictionaryCode, - CDISCCode=c.ReadingQuestionTrial.CDISCCode + CDISCCode = c.ReadingQuestionTrial.CDISCCode }))) ; diff --git a/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs b/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs index d73a3cea9..c337afc0f 100644 --- a/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs +++ b/IRaCIS.Core.Infrastructure/_IRaCIS/_Config/_StaticData.cs @@ -280,7 +280,7 @@ public static class StaticData public const string OCT_ReadingLession_Export = "OCT_ReadingLession_Export"; - + public const string CDISC_Reading_Export = "CDISC_Reading_Export"; public const string IVUSTheMeasuredValueOfEachMatchedFragment = "IVUS_TheMeasuredValueOfEachMatchedFragment"; From 561e1748d61dafc669fc66482fe86434df2003e8 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 7 Jan 2025 10:49:40 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=83=A8=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/ImageAndDoc/NoneDicomStudyService.cs | 12 ++++++++---- .../Service/ImageAndDoc/StudyService.cs | 12 +++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs index 838df7229..1e76770b7 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs @@ -4,6 +4,7 @@ // 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。 //-------------------------------------------------------------------- using IRaCIS.Core.Application.Filter; +using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; using Medallion.Threading; using Microsoft.AspNetCore.Mvc; @@ -58,7 +59,7 @@ namespace IRaCIS.Core.Application.Contracts [UnitOfWork] - [TrialGlobalLimit( "AfterStopCannNotOpt" )] + [TrialGlobalLimit("AfterStopCannNotOpt")] public async Task> AddOrUpdateNoneDicomStudy(NoneDicomStudyAddOrEdit addOrEditNoneDicomStudy) { @@ -70,6 +71,8 @@ namespace IRaCIS.Core.Application.Contracts } + + NoneDicomStudy? optEntity = null; var @lock = _distributedLockProvider.CreateLock($"NoneDicomCode"); @@ -85,6 +88,7 @@ namespace IRaCIS.Core.Application.Contracts optEntity = await _noneDicomStudyRepository.InsertFromDTOAsync(addOrEditNoneDicomStudy); optEntity.StudyCode = AppSettings.GetCodeStr(optEntity.Code, nameof(NoneDicomStudy)); + } else { @@ -105,7 +109,7 @@ namespace IRaCIS.Core.Application.Contracts } - [TrialGlobalLimit( "AfterStopCannNotOpt" )] + [TrialGlobalLimit("AfterStopCannNotOpt")] [HttpDelete("{trialId:guid}/{subjectVisitId:guid}/{noneDicomStudyId:guid}")] public async Task DeleteNoneDicomStudy(Guid noneDicomStudyId, Guid subjectVisitId) { @@ -128,7 +132,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{trialId:guid}/{subjectVisitId:guid}/{noneDicomStudyFileId:guid}")] - [TrialGlobalLimit( "AfterStopCannNotOpt" )] + [TrialGlobalLimit("AfterStopCannNotOpt")] public async Task DeleteNoneDicomStudyFile(Guid noneDicomStudyFileId, Guid subjectVisitId) { //提交了 但是IQC同意的时候 是可以删除的 | 普通提交后也不能删除 @@ -155,7 +159,7 @@ namespace IRaCIS.Core.Application.Contracts public async Task> GetNoneDicomStudyFileList(Guid noneDicomStudyId) { return await _noneDicomStudyFileRepository.Where(t => t.NoneDicomStudyId == noneDicomStudyId) - .ProjectTo(_mapper.ConfigurationProvider).OrderBy(t=>t.CreateTime).ToListAsync(); + .ProjectTo(_mapper.ConfigurationProvider).OrderBy(t => t.CreateTime).ToListAsync(); } [HttpGet("{subjectVisitId:guid}")] diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs index 95211567e..ccee68d94 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs @@ -254,6 +254,8 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc } } + findStudy = addStudy; + } else { @@ -321,15 +323,19 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc } - + #region 只配置单个部位自动赋值 //项目配置的影像部位 - var trialBodyPartList = _trialRepository.Where(t => t.Id == trialId).SelectMany(t => t.TrialBodyPartList).ToList(); + var trialBodyParts = _trialRepository.Where(t => t.Id == trialId).Select(t => t.BodyPartTypes).FirstOrDefault(); + + var trialBodyPartList = trialBodyParts.Split('|', StringSplitOptions.RemoveEmptyEntries); if (trialBodyPartList.Count() == 1) { var first = trialBodyPartList.First(); - findStudy.BodyPartForEdit = first.Code; + findStudy.BodyPartForEdit = first; } + #endregion + var @lock2 = _distributedLockProvider.CreateLock($"StudyCommit"); From faf5430248a7efade2bc150941d23ed04f0757af Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 7 Jan 2025 10:51:52 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=9C=9F=E5=AE=9E=E5=90=8D=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs | 2 ++ IRaCIS.Core.Application/Service/QC/_MapConfig.cs | 1 + 2 files changed, 3 insertions(+) diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index 9ac293710..47918e5c2 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -1740,6 +1740,8 @@ namespace IRaCIS.Core.Application.Contracts public Guid CreateUserId { get; set; } + public string CreateUserFullName { get; set; } = String.Empty; + public string CreateUserName { get; set; } = String.Empty; //public bool NeedReUpload { get; set; } diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index 87d69ffea..d3c07514f 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -672,6 +672,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.BlindName, u => u.MapFrom(s => s.SubjectVisit.BlindName)) //.ForMember(d => d.ClosedUserUserName, u => u.MapFrom(s => s.ClosedUser.UserName)) .ForMember(d => d.IsQCConfirmedReupload, u => u.MapFrom(s => s.SubjectVisit.IsQCConfirmedReupload)) + .ForMember(d => d.CreateUserFullName, u => u.MapFrom(s => s.CreateUserRole.IdentityUser.FullName)) .ForMember(d => d.CreateUserName, u => u.MapFrom(s => s.CreateUserRole.IdentityUser.UserName)) .ForMember(d => d.LatestReplyUserName, u => u.MapFrom(t => t.LatestReplyUser.UserName)) .ForMember(d => d.LatestReplyUserFullName, u => u.MapFrom(t => t.LatestReplyUser.FullName)) From dac94530481149bd98a2bd290c9d415d0fb4f56c Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 7 Jan 2025 11:31:31 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/QC/_MapConfig.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index d3c07514f..40ca803f6 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -561,7 +561,7 @@ namespace IRaCIS.Core.Application.Service //一致性核查 质疑对话 CreateMap() .ForMember(d => d.CreateUserName, u => u.MapFrom(t => t.CreateUserRole.IdentityUser.UserName)) - .ForMember(d => d.CreateUserFullName, u => u.MapFrom(t => t.CreateUserRole.FullName)); + .ForMember(d => d.CreateUserFullName, u => u.MapFrom(t => t.CreateUserRole.IdentityUser.FullName)); CreateMap() .ForMember(d => d.SubjectVisitCheck, u => u.MapFrom(t => t)) @@ -592,13 +592,13 @@ namespace IRaCIS.Core.Application.Service // 临床数据上传 路径拼接返回 CreateMap() - .ForMember(d => d.CreateUser, u => u.MapFrom(s => s.CreateUserRole.FullName)) + .ForMember(d => d.CreateUser, u => u.MapFrom(s => s.CreateUserRole.IdentityUser.FullName)) .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path)); CreateMap() - .ForMember(d => d.CreateUser, u => u.MapFrom(s => s.CreateUserRole.FullName)) + .ForMember(d => d.CreateUser, u => u.MapFrom(s => s.CreateUserRole.IdentityUser.FullName)) .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path)); CreateMap() - .ForMember(d => d.CreateUser, u => u.MapFrom(s => s.CreateUserRole.FullName)) + .ForMember(d => d.CreateUser, u => u.MapFrom(s => s.CreateUserRole.IdentityUser.FullName)) .ForMember(d => d.FullFilePath, u => u.MapFrom(s => s.Path)); From bcc576dfd1a4f5fa1161b6af3e0e7160a72b8ec3 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 7 Jan 2025 11:40:26 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=A0=E5=B0=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/QC/_MapConfig.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index 40ca803f6..0800d8851 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -630,7 +630,8 @@ namespace IRaCIS.Core.Application.Service CreateMap() .ForMember(d => d.LatestReplyUserName, u => u.MapFrom(t => t.LatestReplyUser.FullName)) - .ForMember(d => d.CreateUserName, u => u.MapFrom(t => t.CreateUserRole.FullName)) + .ForMember(d => d.CreateUserName, u => u.MapFrom(t => t.CreateUserRole.UserName)) + .ForMember(d => d.CreateUserFullName, u => u.MapFrom(t => t.CreateUserRole.FullName)) .ForMember(d => d.CurrentActionUserId, u => u.MapFrom(t => t.SubjectVisit.CurrentActionUserId)) .ForMember(d => d.CurrentActionUserName, u => u.MapFrom(t => t.SubjectVisit.CurrentActionUser.FullName)) From e966779cc866818c216458f0413cbc826db6574a Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 7 Jan 2025 14:25:50 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E8=B0=83=E7=A0=94=E5=8F=91=E7=8E=B0=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/SiteSurvey/TrialSiteSurveyService.cs | 5 +++-- .../Service/TrialSiteUser/TrialExternalUserService.cs | 2 +- IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 8ef7d98b2..8a8181101 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -988,7 +988,8 @@ namespace IRaCIS.Core.Application.Contracts foreach (var userTypeId in userTypeIdList) { - var findTrialUserRole = findTrialUser.TrialUserRoleList.Where(t => t.UserRole.UserTypeId == userTypeId).FirstOrDefault(); + //userRole 可能为null + var findTrialUserRole = findTrialUser.TrialUserRoleList.Where(t => t.UserRole?.UserTypeId == userTypeId).FirstOrDefault(); if (findTrialUserRole == null) { @@ -1193,7 +1194,7 @@ namespace IRaCIS.Core.Application.Contracts foreach (var userTypeId in userTypeIdList) { - var findTrialUserRole = findTrialUser.TrialUserRoleList.Where(t => t.UserRole.UserTypeId == userTypeId).FirstOrDefault(); + var findTrialUserRole = findTrialUser.TrialUserRoleList.Where(t => t.UserRole?.UserTypeId == userTypeId).FirstOrDefault(); if (findTrialUserRole == null) { diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index f77d0e177..31d253d81 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -360,7 +360,7 @@ namespace IRaCIS.Core.Application.Service foreach (var userTypeId in userTypeIdList) { - var findTrialUserRole = findTrialUser.TrialUserRoleList.Where(t => t.UserRole.UserTypeId == userTypeId).FirstOrDefault(); + var findTrialUserRole = findTrialUser.TrialUserRoleList.Where(t => t.UserRole?.UserTypeId == userTypeId).FirstOrDefault(); if (findTrialUserRole == null) { diff --git a/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs b/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs index 05ebbfe2a..bcb634798 100644 --- a/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs +++ b/IRaCIS.Core.Application/Service/WorkLoad/EnrollService.cs @@ -442,7 +442,7 @@ namespace IRaCIS.Core.Application.Service } - var findTrialUserRole = findTrialUser.TrialUserRoleList.Where(t => t.UserRole.UserTypeId == userRoleId).FirstOrDefault(); + var findTrialUserRole = findTrialUser.TrialUserRoleList.Where(t => t.UserRole?.UserTypeId == userRoleId).FirstOrDefault(); if (findTrialUserRole == null) { From bbb3a41293d312183e3f030d3371d56cb3770605 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 7 Jan 2025 15:26:30 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E4=B8=AD=E5=BF=83=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SiteSurvey/TrialSiteSurveyService.cs | 33 +++++++++++++++++++ .../SiteSurvey/TrialSiteUserSurvey.cs | 5 ++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 8a8181101..b83e1601e 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -683,8 +683,10 @@ namespace IRaCIS.Core.Application.Contracts private async Task UnlockSyncSiteUserAsync(Guid trialId, Guid siteId, Guid trialSiteSurveyId, List userList) { + //获取调研表用户的数据 var existList = await _trialSiteUserSurveyRepository.Where(t => t.IsHistoryUser && t.TrialSiteSurvey.TrialId == trialId && t.TrialSiteSurvey.TrialSiteId == siteId, true).ToListAsync(); + //遍历中心用户最新的状态 foreach (var item in userList) { var find = existList.FirstOrDefault(t => t.SystemUserId == item.SystemUserId); @@ -692,11 +694,13 @@ namespace IRaCIS.Core.Application.Contracts //不存在就加入 if (find == null) { + //中心用户不在调研表里面,那么就添加到历史人员里面 item.TrialSiteSurveyId = trialSiteSurveyId; await _trialSiteUserSurveyRepository.AddAsync(item); } else { + //中心用户在调研表里面,那么就更新调研表用户的状态 find.IsHistoryUserOriginDeleted = item.IsHistoryUserOriginDeleted; } } @@ -864,6 +868,9 @@ namespace IRaCIS.Core.Application.Contracts var existSysUser = await _identityUserRepository.Where(t => t.EMail == userEmail, true).Include(t => t.UserRoleList).FirstOrDefaultAsync(); + #region 人员生成 + + if (existSysUser != null) { @@ -941,11 +948,14 @@ namespace IRaCIS.Core.Application.Contracts } + #endregion + await _identityUserRepository.SaveChangesAsync(); var identityUserId = existSysUser.Id; + #region 项目加入 var findTrialUser = await _trialIdentityUserRepository.Where(t => t.TrialId == trialId && t.IdentityUserId == identityUserId, true, true).Include(t => t.TrialUserRoleList).ThenInclude(t => t.UserRole).FirstOrDefaultAsync(); @@ -1011,6 +1021,29 @@ namespace IRaCIS.Core.Application.Contracts } } + #endregion + + #region 中心加入 + + foreach (var userTypeId in userTypeIdList) + { + var findUserRole = existSysUser.UserRoleList.Where(t => t.UserTypeId == userTypeId).FirstOrDefault(); + + var findTrialSiteUserRole = await _trialSiteUserRoleRepository.Where(t => t.TrialId == trialId && t.TrialSiteId == trialSiteId && t.UserId == findUserRole.Id, true, true).FirstOrDefaultAsync(); + + if (findTrialSiteUserRole != null) + { + findTrialSiteUserRole.IsDeleted = false; + findTrialSiteUserRole.DeletedTime = null; + + } + else + { + await _trialSiteUserRoleRepository.AddAsync(new TrialSiteUserRole() { TrialId = trialId, TrialSiteId = trialSiteId, UserId = findUserRole.Id }); + } + } + + #endregion if (isNeedSendEmail) { diff --git a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs index cd8dc791a..df88dbed4 100644 --- a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs +++ b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs @@ -42,10 +42,13 @@ public class TrialSiteUserSurvey : BaseFullAuditEntity ///
public bool IsHistoryUser { get; set; } + /// + /// 调研设置用户退出 + /// public bool? IsHistoryUserDeleted { get; set; } /// - /// 中心人员删除了 + /// 中心人员设置退出了 /// public bool? IsHistoryUserOriginDeleted { get; set; } } From f513829c94b19cebf0aedd137d0b0a8d0ac0c7f9 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 7 Jan 2025 18:04:14 +0800 Subject: [PATCH 12/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 2 +- .../Common/InternationalizationService.cs | 11 +- .../Service/Document/TrialDocumentService.cs | 4 +- .../TrialSiteUser/PersonalWorkstation.cs | 117 +++++++++--------- .../Service/TrialSiteUser/TrialService.cs | 2 +- 5 files changed, 72 insertions(+), 64 deletions(-) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index e355cc746..0a00e57d8 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -979,7 +979,7 @@ InternationalizationService
- + InternationalizationService diff --git a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs index f7d6a38b0..2aaa66db6 100644 --- a/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs +++ b/IRaCIS.Core.Application/Service/Common/InternationalizationService.cs @@ -18,7 +18,7 @@ namespace IRaCIS.Core.Application.Service /// [ApiExplorerSettings(GroupName = "Common")] public class InternationalizationService(IRepository _internationalizationRepository, - IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IInternationalizationService + IMapper _mapper, IRepository _publishLogRepository, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, IInternationalizationService { @@ -61,6 +61,8 @@ namespace IRaCIS.Core.Application.Service [AllowAnonymous] public async Task BatchAddOrUpdateFrontInternationalization(List batchList) { + var result = (await _publishLogRepository.Where(t => t.IsCurrentVersion == true).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); + foreach (var item in batchList) { var find = await _internationalizationRepository.FirstOrDefaultAsync(t => t.Code == item.Code && t.Description == item.Description && t.InternationalizationType == 0); @@ -77,7 +79,12 @@ namespace IRaCIS.Core.Application.Service // 0 是预翻译 1是已确认 2是后端废弃 mapItem.State = 0; - await _internationalizationRepository.AddAsync(mapItem); + find = await _internationalizationRepository.AddAsync(mapItem); + } + + if (find.PublishLogId == null || find.PublishLogId == Guid.Empty) + { + find.PublishLogId = result.Id; } } await _internationalizationRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index de2d2d788..b2ac2837d 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -430,7 +430,7 @@ namespace IRaCIS.Core.Application.Services var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == inQuery.TrialId && t.Trial.TrialStatusStr != StaticData.TrialState.TrialStopped) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .CountAsync(); @@ -587,7 +587,7 @@ namespace IRaCIS.Core.Application.Services #endregion var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .CountAsync(); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs index 8b6d5b8bd..b6483a3cd 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/PersonalWorkstation.cs @@ -39,7 +39,7 @@ namespace IRaCIS.Core.Application { return await _trialRepository .Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM, c => c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.SPMApproved).Count() > 0) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM, c => c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.CRCSubmitted).Count() > 0) .ProjectTo(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId }) @@ -70,7 +70,7 @@ namespace IRaCIS.Core.Application else { var trialDocStat = await _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .WhereIf(!_userInfo.IsAdmin, c => c.TrialDocumentList.Where(t => t.IsDeleted == false && t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId) && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null)).Count() > 0 @@ -103,7 +103,7 @@ namespace IRaCIS.Core.Application var query = _trialRepository .Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Select(t => new CheckToBeDoneDto() { TrialId = t.Id, @@ -124,11 +124,11 @@ namespace IRaCIS.Core.Application var result = await query.ToPagedListAsync(inQuery, defalutSortArray); var totalToBeCheckedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(u => u.CheckState == CheckStateEnum.ToCheck).CountAsync(); var totalToBeRepliedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(u => u.CheckState == CheckStateEnum.CVIng && u.CheckChallengeDialogList.OrderByDescending(t => t.CreateTime).First().UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).CountAsync(); @@ -150,7 +150,7 @@ namespace IRaCIS.Core.Application { var query = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed) .GroupBy(t => new { t.OriginalReReadingTask.Trial.ExperimentName, t.OriginalReReadingTask.Trial.ResearchProgramNo, t.OriginalReReadingTask.Trial.TrialCode, t.OriginalReReadingTask.TrialId }) .Select(g => new ReReadingApplyToBeDoneDto() @@ -171,7 +171,7 @@ namespace IRaCIS.Core.Application var toBeApprovalCount = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed).Count(); return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); @@ -192,7 +192,7 @@ namespace IRaCIS.Core.Application [FromServices] IRepository _trialRepository) { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Select(t => new ReviewerSelectToBeDoneDto() { TrialId = t.Id, @@ -210,7 +210,7 @@ namespace IRaCIS.Core.Application var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync(); return ResponseOutput.Ok(result, new { ToBeApprovalCount = toBeApprovalCount }); ; @@ -228,7 +228,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Select(t => new GetPMClinicalDataToBeDoneListOutDto() { TrialId = t.Id, @@ -248,7 +248,7 @@ namespace IRaCIS.Core.Application var all = await _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Select(t => new GetPMClinicalDataToBeDoneListOutDto() { @@ -277,7 +277,7 @@ namespace IRaCIS.Core.Application [FromServices] IRepository _trialRepository) { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Select(t => new ReviewerSelectToBeDoneDto() { TrialId = t.Id, @@ -296,7 +296,7 @@ namespace IRaCIS.Core.Application var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync(); return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); ; @@ -317,7 +317,7 @@ namespace IRaCIS.Core.Application { var query = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed) .GroupBy(t => new { t.OriginalReReadingTask.Trial.ExperimentName, t.OriginalReReadingTask.Trial.ResearchProgramNo, t.OriginalReReadingTask.Trial.TrialCode, t.OriginalReReadingTask.TrialId }) .Select(g => new ReReadingApprovalToBeDoneDto() @@ -338,7 +338,7 @@ namespace IRaCIS.Core.Application var toBeApprovalCount = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed).Count(); return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); @@ -365,7 +365,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) //.Where(t => t.clinicalDataTrialSets.Any(t => t.ClinicalDataLevel == ClinicalLevel.Subject && t.IsConfirm)) .Select(t => new ImageClinicalDataToBeDoneDto() { @@ -407,7 +407,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) //.Where(t => t.clinicalDataTrialSets.Any(t => t.ClinicalDataLevel == ClinicalLevel.Subject && t.IsConfirm)) .Select(t => new ImageClinicalDataToBeDoneDto() { @@ -468,7 +468,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Select(t => new ImageQuestionToBeDoneDto() { TrialId = t.Id, @@ -493,7 +493,7 @@ namespace IRaCIS.Core.Application var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .SelectMany(c => c.QCChallengeList) .Where(u => u.IsClosed == false && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IQC).Count(); @@ -516,7 +516,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Select(t => new ImageCheckQuestionToBeDoneDto() { TrialId = t.Id, @@ -539,7 +539,7 @@ namespace IRaCIS.Core.Application var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .Where(u => u.CheckState == CheckStateEnum.CVIng && u.CheckChallengeState == CheckChanllengeTypeEnum.PMWaitCRCReply).Count(); @@ -562,7 +562,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Select(t => new ImageReUploadToBeDoneDto() { TrialId = t.Id, @@ -585,7 +585,7 @@ namespace IRaCIS.Core.Application var result = await query.ToPagedListAsync(inQuery, defalutSortArray); var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(u => (u.SubmitState == SubmitStateEnum.ToSubmit && u.IsPMBackOrReReading) || (u.IsQCConfirmedReupload)).Count(); return ResponseOutput.Ok(result, new { TotalToBeReUploadCount = toBeDealedCount }); @@ -609,7 +609,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId) && (t.IsUrgent || t.IsSubjectExpeditedView || t.IsEnrollementQualificationConfirm || t.IsPDProgressView)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId)) && (t.IsUrgent || t.IsSubjectExpeditedView || t.IsEnrollementQualificationConfirm || t.IsPDProgressView)) .Select(t => new ImageSubmittedToBeDoneDto() { TrialId = t.Id, @@ -635,7 +635,7 @@ namespace IRaCIS.Core.Application var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .Where(u => u.SubmitState == SubmitStateEnum.ToSubmit).Count(); @@ -665,7 +665,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t=>t.UserRole.UserTypeId==_userInfo.UserTypeId))) .Where(t => t.QCProcessEnum != TrialQCProcess.NotAudit) .Select(t => new ImageQualityToBeDoneDto() { @@ -695,12 +695,13 @@ namespace IRaCIS.Core.Application var toBeClaimedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId) && t.SubmitState == SubmitStateEnum.Submitted && t.AuditState != AuditStateEnum.QCPassed && t.AuditState != AuditStateEnum.QCFailed) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId)) + && t.SubmitState == SubmitStateEnum.Submitted && t.AuditState != AuditStateEnum.QCPassed && t.AuditState != AuditStateEnum.QCFailed) .Where(u => u.CurrentActionUserId == null && (u.PreliminaryAuditUserId == null || (u.PreliminaryAuditUserId != _userInfo.UserRoleId && u.ReviewAuditUserId == null))).Count(); var toBeReviwedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(u => u.CurrentActionUserId == _userInfo.UserRoleId).Count(); @@ -723,7 +724,7 @@ namespace IRaCIS.Core.Application { var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Select(t => new ImageQuestionToBeDoneDto() { TrialId = t.Id, @@ -744,7 +745,7 @@ namespace IRaCIS.Core.Application var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .SelectMany(c => c.QCChallengeList) .Where(u => u.CreateUserId == _userInfo.UserRoleId && u.IsClosed == false && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).Count(); @@ -777,7 +778,7 @@ namespace IRaCIS.Core.Application { - var newQuery = _trialReadingCriterionRepository.Where(t => t.IsSigned && t.IsConfirm && t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + var newQuery = _trialReadingCriterionRepository.Where(t => t.IsSigned && t.IsConfirm && t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Select(c => new IRImageReadingToBeDoneDto() { TrialId = c.TrialId, @@ -887,7 +888,7 @@ namespace IRaCIS.Core.Application var result = await newQuery.ToPagedListAsync(inQuery, defalutSortArray); var toBeDealedCount = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .SelectMany(t => t.VisitTaskList) .Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect && t.TrialReadingCriterion.IsSigned == true && t.TrialReadingCriterion.IsConfirm == true) // 前序 不存在 未一致性核查未通过的 @@ -915,7 +916,7 @@ namespace IRaCIS.Core.Application { var query = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.VisitTask.DoctorUserId == _userInfo.UserRoleId) .GroupBy(t => new { @@ -959,7 +960,7 @@ namespace IRaCIS.Core.Application var toBeDealedCount = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.IsClosedDialog == false && t.VisitTask.DoctorUserId == _userInfo.UserRoleId) .Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.MIM) //.Where(u => u.ReadingMedicalReviewDialogList.OrderByDescending(l => l.CreateTime).First().UserTypeEnumInt == (int)UserTypeEnum.MIM) @@ -992,7 +993,7 @@ namespace IRaCIS.Core.Application #region 废弃不能对包含聚合或子查询的表达式执行聚合函数 var query = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .GroupBy(t => new { @@ -1030,7 +1031,7 @@ namespace IRaCIS.Core.Application var toBeReplyedQuery = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IndependentReviewer && u.AuditState == MedicalReviewAuditState.Auditing); @@ -1038,7 +1039,7 @@ namespace IRaCIS.Core.Application var toBeReplyedCount = toBeReplyedQuery.Count(); var tobeReviewedCount = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .Where(u => u.AuditState != MedicalReviewAuditState.HaveSigned && u.LatestReplyUser.UserTypeEnum != UserTypeEnum.IndependentReviewer).Count(); @@ -1091,7 +1092,7 @@ namespace IRaCIS.Core.Application if (!_userInfo.IsAdmin) { var list = await _trialRepository.Where(t => t.TrialStatusStr != StaticData.TrialState.TrialStopped) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .WhereIf(!_userInfo.IsAdmin, c => c.TrialDocumentList.Where(t => t.IsDeleted == false && t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId) && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.UserRoleId && t.ConfirmTime != null)).Count() > 0) .Select(t => t.Id).ToListAsync(); @@ -1117,7 +1118,7 @@ namespace IRaCIS.Core.Application var isInternal = _userInfo.IsZhiZhun; var needSignTrialCount = await _trialRepository.Where(t => t.TrialStatusStr != StaticData.TrialState.TrialStopped) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(c => c.TrialDocumentList.Where(t => t.IsDeleted == false && t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId) && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null)).Count() > 0).CountAsync(); @@ -1129,7 +1130,7 @@ namespace IRaCIS.Core.Application .CountAsync(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId); var signedTrialCount = await _trialDocumentRepository.AsQueryable(true) - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .Where(t => t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.IdentityUserId && t.ConfirmTime != null)).CountAsync(); @@ -1140,7 +1141,7 @@ namespace IRaCIS.Core.Application var siteSurveyCount = await _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM, c => c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.SPMApproved).Count() > 0) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM, c => c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.CRCSubmitted).Count() > 0) .CountAsync(); @@ -1189,16 +1190,16 @@ namespace IRaCIS.Core.Application PM_SiteSurveryCount = isPM ? siteSurveyCount : 0, PM_CheckCount = isPM ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(u => u.SubjectVisitList.Any(t => t.CheckState == CheckStateEnum.ToCheck || (t.CheckState == CheckStateEnum.CVIng && t.CheckChallengeDialogList.OrderByDescending(t => t.CreateTime).First().UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator))).CountAsync() : 0, PM_ReviewerSelectCount = isPM ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.InviteIntoGroup).Count() > 0).CountAsync() : 0, PM_ReReadingApprovalCount = isPM ? await _visitTaskReReadingRepository - .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed) .GroupBy(t => t.OriginalReReadingTask.TrialId) .Select(g => new ReReadingApplyToBeDoneDto() @@ -1209,7 +1210,7 @@ namespace IRaCIS.Core.Application }).Where(x => x.ToBeApprovalCount > 0).CountAsync() : 0, PM_ClinicalDataCount = isPM ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.ReadModuleList.Where(u => u.IsCRCConfirm && !u.IsPMConfirm).Count() > 0).CountAsync() : 0, #endregion @@ -1217,34 +1218,34 @@ namespace IRaCIS.Core.Application #region CRC CRC_ImageSubmitCount = isCRC ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId) && (t.IsUrgent || t.IsSubjectExpeditedView || t.IsEnrollementQualificationConfirm || t.IsPDProgressView)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId)) && (t.IsUrgent || t.IsSubjectExpeditedView || t.IsEnrollementQualificationConfirm || t.IsPDProgressView)) .Where(t => t.SubjectVisitList.Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)).Where(u => u.SubmitState == SubmitStateEnum.ToSubmit).Count() > 0).CountAsync() : 0, CRC_ImageQuestionCount = isCRC ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.SubjectVisitList.Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)).SelectMany(c => c.QCChallengeList) .Where(u => u.IsClosed == false && (u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IQC || u.LatestReplyUserId == null)).Count() > 0).CountAsync() : 0, CRC_CheckQuestionCount = isCRC ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.SubjectVisitList.Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .Where(u => u.CheckState == CheckStateEnum.CVIng && u.CheckChallengeState == CheckChanllengeTypeEnum.PMWaitCRCReply).Count() > 0).CountAsync() : 0, CRC_ImageReUploadCount = isCRC ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.SubjectVisitList .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .Where(u => (u.SubmitState == SubmitStateEnum.ToSubmit && u.IsPMBackOrReReading) || (u.IsQCConfirmedReupload)).Count() > 0).CountAsync() : 0, CRC_ClinicalDataTobeDoneCount = isCRC ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.ReadingClinicalDataList.Where(x => !x.IsSign && x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC).Count() > 0).CountAsync() : 0, CRC_ClinialDataTobeConfirmCount = isCRC ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.ReadModuleList.Where(x => !x.IsCRCConfirm).Count() > 0).CountAsync() : 0, @@ -1258,11 +1259,11 @@ namespace IRaCIS.Core.Application SPM_SiteSurveryCount = isSPMOrCPM ? siteSurveyCount : 0, SPM_ReviewerApprovalCount = isSPMOrCPM ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).Count() > 0).CountAsync() : 0, SPM_ReReadingApprovalCount = isSPMOrCPM ? await _visitTaskReReadingRepository - .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed) .GroupBy(t => t.OriginalReReadingTask.TrialId) .Select(g => new ReReadingApplyToBeDoneDto() @@ -1279,7 +1280,7 @@ namespace IRaCIS.Core.Application IQC_IamgeQCCount = isIQC ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.QCProcessEnum != TrialQCProcess.NotAudit) .Select(t => new { @@ -1293,7 +1294,7 @@ namespace IRaCIS.Core.Application }).Where(x => x.ToBeClaimedCount + x.ToBeReviewedCount > 0).CountAsync() : 0, IQC_QCQuestionCount = isIQC ? await _trialRepository - .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.SubjectVisitList.SelectMany(c => c.QCChallengeList) .Where(u => u.CreateUserId == _userInfo.UserRoleId && u.IsClosed == false && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).Count() > 0).CountAsync() : 0, @@ -1317,7 +1318,7 @@ namespace IRaCIS.Core.Application // .Where(y => y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true)).Count()>0).CountAsync() : 0, - await _trialReadingCriterionRepository.Where(t => t.IsSigned == true && t.IsConfirm == true && t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + await _trialReadingCriterionRepository.Where(t => t.IsSigned == true && t.IsConfirm == true && t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(c => c.VisitTaskList.Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect) // 前序 不存在 未一致性核查未通过的 .Where(t => !t.Subject.SubjectVisitList.Any(sv => sv.CheckState != CheckStateEnum.CVPassed && t.VisitTaskNum > sv.VisitNum)) @@ -1330,7 +1331,7 @@ namespace IRaCIS.Core.Application : 0, - IR_MedicalReviewCount = isIR ? await _taskMedicalReviewRepository.Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + IR_MedicalReviewCount = isIR ? await _taskMedicalReviewRepository.Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.VisitTask.DoctorUserId == _userInfo.UserRoleId) .GroupBy(t => new { t.TrialId, t.VisitTask.TrialReadingCriterionId }) .Where(g => g.Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.MIM && u.AuditState == MedicalReviewAuditState.Auditing).Count() > 0).CountAsync() : 0, @@ -1341,7 +1342,7 @@ namespace IRaCIS.Core.Application #region MIM MIM_MedicalReviewCount = isMIM ? await _taskMedicalReviewRepository - .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .GroupBy(t => new { t.TrialId, t.VisitTask.TrialReadingCriterionId }) .Select(g => new diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index b6ba8a471..3bb6cc9d6 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -628,7 +628,7 @@ namespace IRaCIS.Core.Application.Service .WhereIf(inQuery.Expedited != null, o => o.Expedited == inQuery.Expedited) .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Indication), o => o.Indication.Contains(inQuery.Indication)) - .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId)) + .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.TrialUserRoleList.Any(t => t.UserRole.UserTypeId == _userInfo.UserTypeId))) .ProjectTo(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId, isEn_Us = _userInfo.IsEn_Us }); From 62fafeb7d217d84b3c4b60e1a4a82cd91fbec184 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Wed, 8 Jan 2025 09:50:25 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=94=A8=E6=88=B7=20?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=8F=91=E9=80=81=E9=82=AE=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IRaCIS.Core.Application.xml | 7 +++++++ .../Service/Management/DTO/UserModel.cs | 11 ++++++++++ .../Service/Management/UserService.cs | 8 ++++++++ .../TrialSiteUser/DTO/UserTrialViewModel.cs | 12 +++++++++++ .../TrialSiteUser/TrialMaintenanceService.cs | 20 +++++++++++++++++++ 5 files changed, 58 insertions(+) diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 0a00e57d8..910afcf53 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -12914,6 +12914,13 @@ + + + 项目人员 邮件过期 重新发送邀请邮件 + + + + Setting页面 项目参与人员勾选列表 diff --git a/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs b/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs index b008307ce..a05e65145 100644 --- a/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs +++ b/IRaCIS.Core.Application/Service/Management/DTO/UserModel.cs @@ -230,6 +230,15 @@ namespace IRaCIS.Application.Contracts } + + public class NewUserSendEmailCommand + { + public Guid IdentityUserId { get; set; } + public string BaseUrl { get; set; } = string.Empty; + public string RouteUrl { get; set; } = string.Empty; + + } + public class IdentityUserTypeDTO : UserAddUserType { public Guid Id { get; set; } @@ -312,6 +321,8 @@ namespace IRaCIS.Application.Contracts { //public bool CanEditUserType { get; set; } + public bool IsFirstAdd { get; set; } + public DateTime? LastLoginTime { get; set; } public DateTime CreateTime { get; set; } diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs index bf7441a9e..c17d5a2a6 100644 --- a/IRaCIS.Core.Application/Service/Management/UserService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserService.cs @@ -582,6 +582,14 @@ namespace IRaCIS.Core.Application.Service } + [HttpPost] + public async Task AddNewUserSendEmail(NewUserSendEmailCommand incommand) + { + await _mailVerificationService.AddUserSendEmailAsync(incommand.IdentityUserId, incommand.BaseUrl, incommand.RouteUrl); + + return ResponseOutput.Ok(); + } + /// /// 更新用户 /// diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs index e55def7b9..140ad9408 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/UserTrialViewModel.cs @@ -531,6 +531,18 @@ namespace IRaCIS.Application.Contracts } + public class TrialUserSendJoinEmailCommand + { + [NotDefault] + public Guid TrialId { get; set; } + + [NotDefault] + public Guid IdentityUserId { get; set; } + + public string BaseUrl { get; set; } = string.Empty; + public string RouteUrl { get; set; } = string.Empty; + + } public class UpdateTrialUserRoleCommand { public List IdList { get; set; } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs index 1be7735ef..9deef590d 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs @@ -3,6 +3,7 @@ using IRaCIS.Application.Contracts; using IRaCIS.Application.Interfaces; using IRaCIS.Core.Application.Contracts.DTO; using IRaCIS.Core.Application.Filter; +using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; using MassTransit.Serialization; using Microsoft.AspNetCore.Mvc; @@ -118,6 +119,25 @@ namespace IRaCIS.Core.Application.Service return ResponseOutput.Ok(); } + /// + /// 项目人员 邮件过期 重新发送邀请邮件 + /// + /// + /// + [HttpPost] + public async Task TrialUserSendJoinEmail(TrialUserSendJoinEmailCommand incommand, [FromServices] IMailVerificationService _mailVerificationService) + { + + var userTypeList = _trialIdentityUserRepository.Where(t => t.TrialId == incommand.TrialId && t.IdentityUserId == incommand.IdentityUserId).SelectMany(t => t.TrialUserRoleList).Select(t => t.UserRole.UserTypeRole.UserTypeName).ToList(); + + var usertyps = string.Join(',', userTypeList); + + await _mailVerificationService.ExternalUserJoinEmail(incommand.TrialId, incommand.IdentityUserId, usertyps, incommand.BaseUrl, incommand.RouteUrl); + + return ResponseOutput.Ok(); + } + + /// Setting页面 项目参与人员勾选列表 [HttpPost]