From 7b78e4b399fb76e6841abd96faf839ec24f1ec67 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 6 Aug 2024 14:38:30 +0800 Subject: [PATCH] =?UTF-8?q?20240806=20=E5=AF=BC=E8=A1=A8=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Allocation/TaskMedicalReviewService.cs | 3 - .../Service/Allocation/VisitTaskService.cs | 54 +-- .../Service/Common/ExcelExportService.cs | 443 ++++++++++++------ .../Service/Document/TrialDocumentService.cs | 34 +- .../Service/ImageAndDoc/StudyService.cs | 26 +- .../Service/QC/DTO/QCListViewModel.cs | 93 +++- .../Service/QC/QCListService.cs | 154 +++--- .../Service/QC/_MapConfig.cs | 24 +- .../Service/Visit/SubjectService.cs | 22 +- IRaCIS.Core.Domain/_Config/_StaticData.cs | 4 + 10 files changed, 562 insertions(+), 295 deletions(-) diff --git a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs index 10a9f59a4..b8e31ed21 100644 --- a/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/TaskMedicalReviewService.cs @@ -56,9 +56,6 @@ namespace IRaCIS.Core.Application.Service var taskMedicalReviewQueryable = _taskMedicalReviewRepository.Where(t => t.VisitTask.TrialId == inQuery.TrialId) - //.WhereIf(inQuery.IsEffect == true, t => t.VisitTask.TaskState == TaskState.Effect || t.VisitTask.TaskState == TaskState.Freeze) - //.WhereIf(inQuery.IsEffect == false, t => t.VisitTask.TaskState == TaskState.Adbandon || t.VisitTask.TaskState == TaskState.HaveReturned) - .WhereIf(inQuery.TrialSiteId != null, t => t.VisitTask.Subject.TrialSiteId == inQuery.TrialSiteId) .WhereIf(inQuery.SubjectId != null, t => t.VisitTask.SubjectId == inQuery.SubjectId) .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.VisitTask.Subject.Code.Contains(inQuery.SubjectCode) || t.VisitTask.Subject.MedicalNo.Contains(inQuery.SubjectCode)) diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index efdd7ff84..4898ac25c 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -803,43 +803,43 @@ namespace IRaCIS.Core.Application.Service.Allocation /// /// PM 重阅追踪 /// - /// + /// /// [HttpPost] - public async Task> GetReReadingTaskList(VisitTaskQuery queryVisitTask) + public async Task> GetReReadingTaskList(VisitTaskQuery inQuery) { var visitTaskQueryable = _visitTaskReReadingRepository - .Where(t => t.OriginalReReadingTask.TrialId == queryVisitTask.TrialId /*&& t.OriginalReReadingTask.IsAnalysisCreate == false*/) - .WhereIf(queryVisitTask.RootReReadingTaskId != null, t => t.RootReReadingTaskId == queryVisitTask.RootReReadingTaskId || t.OriginalReReadingTaskId == queryVisitTask.RootReReadingTaskId) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(queryVisitTask.TaskCode!) || t.RootReReadingTask.TaskCode.Contains(queryVisitTask.TaskCode!)) - .WhereIf(queryVisitTask.TrialSiteId != null, t => t.OriginalReReadingTask.Subject.TrialSiteId == queryVisitTask.TrialSiteId) - .WhereIf(queryVisitTask.TaskState != null, t => t.OriginalReReadingTask.TaskState == queryVisitTask.TaskState) - .WhereIf(queryVisitTask.ReReadingApplyState != null, t => t.OriginalReReadingTask.ReReadingApplyState == queryVisitTask.ReReadingApplyState) - .WhereIf(queryVisitTask.RequestReReadingType != null, t => t.RequestReReadingType == queryVisitTask.RequestReReadingType) - .WhereIf(queryVisitTask.SubjectId != null, t => t.OriginalReReadingTask.SubjectId == queryVisitTask.SubjectId) - .WhereIf(queryVisitTask.IsUrgent != null, t => t.OriginalReReadingTask.IsUrgent == queryVisitTask.IsUrgent) - .WhereIf(queryVisitTask.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == queryVisitTask.DoctorUserId) - .WhereIf(queryVisitTask.ArmEnum != null, t => t.OriginalReReadingTask.ArmEnum == queryVisitTask.ArmEnum) - .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == queryVisitTask.ReadingTaskState) - .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == queryVisitTask.TaskAllocationState) - .WhereIf(queryVisitTask.TrialReadingCriterionId != null, t => t.OriginalReReadingTask.TrialReadingCriterionId == queryVisitTask.TrialReadingCriterionId) - .WhereIf(queryVisitTask.ReadingCategory != null, t => t.OriginalReReadingTask.ReadingCategory == queryVisitTask.ReadingCategory) + .Where(t => t.OriginalReReadingTask.TrialId == inQuery.TrialId /*&& t.OriginalReReadingTask.IsAnalysisCreate == false*/) + .WhereIf(inQuery.RootReReadingTaskId != null, t => t.RootReReadingTaskId == inQuery.RootReReadingTaskId || t.OriginalReReadingTaskId == inQuery.RootReReadingTaskId) + .WhereIf(!string.IsNullOrEmpty(inQuery.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(inQuery.TaskCode!) || t.RootReReadingTask.TaskCode.Contains(inQuery.TaskCode!)) + .WhereIf(inQuery.TrialSiteId != null, t => t.OriginalReReadingTask.Subject.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.TaskState != null, t => t.OriginalReReadingTask.TaskState == inQuery.TaskState) + .WhereIf(inQuery.ReReadingApplyState != null, t => t.OriginalReReadingTask.ReReadingApplyState == inQuery.ReReadingApplyState) + .WhereIf(inQuery.RequestReReadingType != null, t => t.RequestReReadingType == inQuery.RequestReReadingType) + .WhereIf(inQuery.SubjectId != null, t => t.OriginalReReadingTask.SubjectId == inQuery.SubjectId) + .WhereIf(inQuery.IsUrgent != null, t => t.OriginalReReadingTask.IsUrgent == inQuery.IsUrgent) + .WhereIf(inQuery.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == inQuery.DoctorUserId) + .WhereIf(inQuery.ArmEnum != null, t => t.OriginalReReadingTask.ArmEnum == inQuery.ArmEnum) + .WhereIf(inQuery.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == inQuery.ReadingTaskState) + .WhereIf(inQuery.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == inQuery.TaskAllocationState) + .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.OriginalReReadingTask.TrialReadingCriterionId == inQuery.TrialReadingCriterionId) + .WhereIf(inQuery.ReadingCategory != null, t => t.OriginalReReadingTask.ReadingCategory == inQuery.ReadingCategory) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.RequestReReadingReason), t => t.RequestReReadingReason.Contains(queryVisitTask.RequestReReadingReason)) + .WhereIf(!string.IsNullOrEmpty(inQuery.RequestReReadingReason), t => t.RequestReReadingReason.Contains(inQuery.RequestReReadingReason)) - .WhereIf(queryVisitTask.RequestReReadingResultEnum != null, t => t.RequestReReadingResultEnum == queryVisitTask.RequestReReadingResultEnum) + .WhereIf(inQuery.RequestReReadingResultEnum != null, t => t.RequestReReadingResultEnum == inQuery.RequestReReadingResultEnum) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(queryVisitTask.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(queryVisitTask.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate == false)) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(queryVisitTask.TaskName) || t.OriginalReReadingTask.TaskBlindName.Contains(queryVisitTask.TaskName)) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => ((t.OriginalReReadingTask.Subject.Code.Contains(queryVisitTask.SubjectCode) || t.OriginalReReadingTask.Subject.MedicalNo.Contains(queryVisitTask.SubjectCode)) && t.OriginalReReadingTask.IsAnalysisCreate == false) || (t.OriginalReReadingTask.BlindSubjectCode.Contains(queryVisitTask.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate)) - .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > queryVisitTask.BeginAllocateDate) - .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < queryVisitTask.EndAllocateDate!.Value.AddDays(1)) + .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate == false)) + .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(inQuery.TaskName) || t.OriginalReReadingTask.TaskBlindName.Contains(inQuery.TaskName)) + .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => ((t.OriginalReReadingTask.Subject.Code.Contains(inQuery.SubjectCode) || t.OriginalReReadingTask.Subject.MedicalNo.Contains(inQuery.SubjectCode)) && t.OriginalReReadingTask.IsAnalysisCreate == false) || (t.OriginalReReadingTask.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate)) + .WhereIf(inQuery.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > inQuery.BeginAllocateDate) + .WhereIf(inQuery.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1)) - .WhereIf(queryVisitTask.BeginRequestReReadingTime != null, t => t.RequestReReadingTime >= queryVisitTask.BeginRequestReReadingTime) - .WhereIf(queryVisitTask.EndRequestReReadingTime != null, t => t.RequestReReadingTime <= queryVisitTask.EndRequestReReadingTime!.Value.AddDays(1)) + .WhereIf(inQuery.BeginRequestReReadingTime != null, t => t.RequestReReadingTime >= inQuery.BeginRequestReReadingTime) + .WhereIf(inQuery.EndRequestReReadingTime != null, t => t.RequestReReadingTime <= inQuery.EndRequestReReadingTime!.Value.AddDays(1)) .ProjectTo(_mapper.ConfigurationProvider); @@ -853,7 +853,7 @@ namespace IRaCIS.Core.Application.Service.Allocation - var pageList = await visitTaskQueryable.ToPagedListAsync(queryVisitTask.PageIndex, queryVisitTask.PageSize, queryVisitTask.SortField, queryVisitTask.Asc, string.IsNullOrWhiteSpace(queryVisitTask.SortField), defalutSortArray); + var pageList = await visitTaskQueryable.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); return pageList; } diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 96ece98b1..d2616588e 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -51,8 +51,8 @@ namespace IRaCIS.Core.Application.Service.Common public async Task TrialUserListExport(TrialMaintenanceExportQuery param, [FromServices] IRepository _commonDocumentRepository, [FromServices] IDictionaryService _dictionaryService, - [FromServices] IRepository _trialRepository, - [FromServices] IRepository _trialUseRepository + [FromServices] IRepository _trialRepository, + [FromServices] IRepository _trialUseRepository ) { @@ -95,8 +95,8 @@ namespace IRaCIS.Core.Application.Service.Common public async Task TrialSiteUserListExport(SiteCRCExportQueryDTO param, [FromServices] IRepository _commonDocumentRepository, [FromServices] IDictionaryService _dictionaryService, - [FromServices] IRepository _trialRepository, - [FromServices] IRepository _trialSiteUserRepository + [FromServices] IRepository _trialRepository, + [FromServices] IRepository _trialSiteUserRepository ) { @@ -144,8 +144,8 @@ namespace IRaCIS.Core.Application.Service.Common [FromServices] IRepository _commonDocumentRepository, [FromServices] IRepository _trialSiteSurveyRepository, [FromServices] IRepository _trialSiteUserSurveyRepository, - [FromServices] IRepository _trialRepository, - [FromServices] IDictionaryService _dictionaryService + [FromServices] IRepository _trialRepository, + [FromServices] IDictionaryService _dictionaryService ) { @@ -189,9 +189,118 @@ namespace IRaCIS.Core.Application.Service.Common #region 导表查询 + /// + /// getDocumentConfirmList 培训记录导出 + /// + /// + /// + /// + /// + /// + /// + [HttpPost] + [AllowAnonymous] + public async Task PMTrainingRecordList_Export(DocumentTrialUnionQuery inQuery, + [FromServices] IRepository _commonDocumentRepository, + [FromServices] IDictionaryService _dictionaryService, + [FromServices] IRepository _subjectVisitRepository, + [FromServices] IRepository _trialRepository + ) + { + var trialInfo = (await _repository.Where(t => t.Id == inQuery.TrialId).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstNotNullAsync()); + + var trialDocQuery = from trialDocumentNeedConfirmedUserType in _repository.Where(t => t.TrialDocument.TrialId == inQuery.TrialId) + join trialUser in _repository.Where(t => t.TrialId == inQuery.TrialId) + .WhereIf(inQuery.UserId != null, t => t.UserId == inQuery.UserId) + .WhereIf(inQuery.UserTypeId != null, t => t.User.UserTypeId == inQuery.UserTypeId) + on trialDocumentNeedConfirmedUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId + + join confirm in _repository.Where(t => t.TrialDocument.TrialId == inQuery.TrialId) on + new { trialUser.UserId, TrialDocumentId = trialDocumentNeedConfirmedUserType.TrialDocumentId } equals new { UserId = confirm.ConfirmUserId, confirm.TrialDocumentId } into cc + from confirm in cc.DefaultIfEmpty() + select new TrainingRecordExportDTO() + { + IsSystemDoc = false, + + Id = trialDocumentNeedConfirmedUserType.TrialDocument.Id, + CreateTime = trialDocumentNeedConfirmedUserType.TrialDocument.CreateTime, + IsDeleted = trialDocumentNeedConfirmedUserType.TrialDocument.IsDeleted, + //SignViewMinimumMinutes = trialDocumentNeedConfirmedUserType.TrialDocument.SignViewMinimumMinutes, + Name = trialDocumentNeedConfirmedUserType.TrialDocument.Name, + //Path = trialDocumentNeedConfirmedUserType.TrialDocument.Path, + FileTypeId = trialDocumentNeedConfirmedUserType.TrialDocument.FileTypeId, + FileType = _userInfo.IsEn_Us ? trialDocumentNeedConfirmedUserType.TrialDocument.FileType.Value : trialDocumentNeedConfirmedUserType.TrialDocument.FileType.ValueCN, + //UpdateTime = trialDocumentNeedConfirmedUserType.TrialDocument.UpdateTime, + //IsConfirmed= confirm.ConfirmTime!=null, + //ConfirmUserId = confirm.ConfirmUserId, + ConfirmTime = confirm.ConfirmTime, + RealName = trialUser.User.FullName, + UserName = trialUser.User.UserName, + UserTypeId = trialUser.User.UserTypeId, + UserTypeShortName = trialUser.User.UserTypeRole.UserTypeShortName, + + //FullFilePath = trialDocumentNeedConfirmedUserType.TrialDocument.Path + }; + + + + var systemDocQuery = from needConfirmEdUserType in _repository.WhereIf(trialInfo.TrialFinishedTime != null, u => u.SystemDocument.CreateTime < trialInfo.TrialFinishedTime) + + join trialUser in _repository.Where(t => t.TrialId == inQuery.TrialId) + .WhereIf(inQuery.UserId != null, t => t.UserId == inQuery.UserId) + on needConfirmEdUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId + join confirm in _repository.GetQueryable() on new { ConfirmUserId = trialUser.UserId, SystemDocumentId = needConfirmEdUserType.SystemDocumentId } equals new { confirm.ConfirmUserId, confirm.SystemDocumentId } into cc + from confirm in cc.DefaultIfEmpty() + select new TrainingRecordExportDTO() + { + IsSystemDoc = true, + + Id = needConfirmEdUserType.SystemDocument.Id, + CreateTime = needConfirmEdUserType.SystemDocument.CreateTime, + IsDeleted = needConfirmEdUserType.SystemDocument.IsDeleted, + //SignViewMinimumMinutes = needConfirmEdUserType.SystemDocument.SignViewMinimumMinutes, + Name = needConfirmEdUserType.SystemDocument.Name, + //Path = needConfirmEdUserType.SystemDocument.Path, + FileType = _userInfo.IsEn_Us ? needConfirmEdUserType.SystemDocument.FileType.Value : needConfirmEdUserType.SystemDocument.FileType.ValueCN, + FileTypeId = needConfirmEdUserType.SystemDocument.FileTypeId, + //UpdateTime = needConfirmEdUserType.SystemDocument.UpdateTime, + //IsConfirmed = confirm.ConfirmTime != null, + + //ConfirmUserId = confirm.ConfirmUserId, + ConfirmTime = confirm.ConfirmTime, + RealName = trialUser.User.FullName, + UserName = trialUser.User.UserName, + UserTypeId = trialUser.User.UserTypeId, + UserTypeShortName = trialUser.User.UserTypeRole.UserTypeShortName, + + //FullFilePath = needConfirmEdUserType.SystemDocument.Path + }; + + var unionQuery = trialDocQuery.Union(systemDocQuery) + .WhereIf(!string.IsNullOrEmpty(inQuery.Name), t => t.Name.Contains(inQuery.Name)) + .WhereIf(inQuery.FileTypeId != null, t => t.FileTypeId == inQuery.FileTypeId) + .WhereIf(inQuery.IsConfirmed == true, t => t.ConfirmTime != null) + .WhereIf(inQuery.IsConfirmed == false, t => t.ConfirmTime == null) + .WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == inQuery.IsDeleted) + .WhereIf(inQuery.UserTypeId != null, t => t.UserTypeId == inQuery.UserTypeId); + + var list = await unionQuery.ToListAsync(); + + + var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); + + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); + exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; + + + return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialTrainingRecordList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(TrainingRecordExportDTO)); + + } + @@ -201,7 +310,7 @@ namespace IRaCIS.Core.Application.Service.Common /// /// 影像上传列表 只导出已上传状态的访视记录 /// - /// + /// /// /// /// @@ -209,7 +318,7 @@ namespace IRaCIS.Core.Application.Service.Common /// [HttpPost] [AllowAnonymous] - public async Task CRCVisitList_Export(CRCVisitSearchDTO visitSearchDTO, + public async Task CRCVisitList_Export(CRCVisitSearchDTO inQuery, [FromServices] IRepository _commonDocumentRepository, [FromServices] IDictionaryService _dictionaryService, [FromServices] IRepository _subjectVisitRepository, @@ -217,26 +326,26 @@ namespace IRaCIS.Core.Application.Service.Common ) { - var svExpression = QCCommon.GetSubjectVisitFilter(visitSearchDTO.VisitPlanArray); + var svExpression = QCCommon.GetSubjectVisitFilter(inQuery.VisitPlanArray); - var list = await _subjectVisitRepository.Where(x => x.TrialId == visitSearchDTO.TrialId) + var query = _subjectVisitRepository.Where(x => x.TrialId == inQuery.TrialId) .Where(t => t.Subject.FinalSubjectVisitId != null ? t.VisitNum <= t.Subject.FinalSubjectVisit.VisitNum : true) - .WhereIf(visitSearchDTO.TrialSiteId != null, t => t.TrialSiteId == visitSearchDTO.TrialSiteId) - .WhereIf(visitSearchDTO.SubjectId != null, t => t.Subject.Id == visitSearchDTO.SubjectId) - .WhereIf(!string.IsNullOrEmpty(visitSearchDTO.SubjectInfo), t => t.Subject.Code.Contains(visitSearchDTO.SubjectInfo)) + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.SubjectId != null, t => t.Subject.Id == inQuery.SubjectId) + .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectInfo), t => t.Subject.Code.Contains(inQuery.SubjectInfo)) - .WhereIf(visitSearchDTO.VisitPlanArray != null && visitSearchDTO.VisitPlanArray?.Length > 0, svExpression) + .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) //.WhereIf(!string.IsNullOrEmpty(visitSearchDTO.VisitPlanInfo), visitSearchDTO.VisitPlanInfo.Contains('.') ? t => t.InPlan == false : t => t.VisitNum == decimal.Parse(visitSearchDTO.VisitPlanInfo)) - .WhereIf(visitSearchDTO.AuditStateArray != null && visitSearchDTO.AuditStateArray?.Length > 0, t => visitSearchDTO.AuditStateArray!.Contains(t.AuditState)) - .WhereIf(visitSearchDTO.SubmitState != null, t => t.SubmitState == visitSearchDTO.SubmitState) - .WhereIf(visitSearchDTO.ChallengeState != null, t => t.ChallengeState == visitSearchDTO.ChallengeState) - .WhereIf(visitSearchDTO.IsUrgent != null, t => t.IsUrgent == visitSearchDTO.IsUrgent) + .WhereIf(inQuery.AuditStateArray != null && inQuery.AuditStateArray?.Length > 0, t => inQuery.AuditStateArray!.Contains(t.AuditState)) + .WhereIf(inQuery.SubmitState != null, t => t.SubmitState == inQuery.SubmitState) + .WhereIf(inQuery.ChallengeState != null, t => t.ChallengeState == inQuery.ChallengeState) + .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + .ProjectTo(_mapper.ConfigurationProvider); - list = list.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.BlindName).ToList(); + var list = query.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.BlindName).ToList(); - var exportInfo = (await _trialRepository.Where(t => t.Id == visitSearchDTO.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); + var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; @@ -247,20 +356,77 @@ namespace IRaCIS.Core.Application.Service.Common } + /// + /// 影像质控导出 + /// + /// + /// + /// + /// + /// + /// + [HttpPost] + [AllowAnonymous] + public async Task QCVisitList_Export(QCVisitSearchDTO inQuery, + [FromServices] IRepository _commonDocumentRepository, + [FromServices] IDictionaryService _dictionaryService, + [FromServices] IRepository _subjectVisitRepository, + [FromServices] IRepository _trialRepository + ) + { + var svExpression = QCCommon.GetSubjectVisitFilter(inQuery.VisitPlanArray); + var query = _subjectVisitRepository.Where(x => x.TrialId == inQuery.TrialId) + .WhereIf(inQuery.VisitId != null, t => t.Id == inQuery.VisitId) + .WhereIf(inQuery.CurrentActionUserId != null, t => t.CurrentActionUserId == inQuery.CurrentActionUserId) + .WhereIf(inQuery.ChallengeState != null, t => t.ChallengeState == inQuery.ChallengeState) + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.SubjectId != null, t => t.Subject.Id == inQuery.SubjectId) + .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectInfo), t => /*t.Subject.FirstName.Contains(subjectInfo) || t.Subject.LastName.Contains(subjectInfo) ||*/ t.Subject.Code.Contains(inQuery.SubjectInfo)) + .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) + //.WhereIf(!string.IsNullOrEmpty(visitSearchDTO.VisitPlanInfo), visitSearchDTO.VisitPlanInfo.Contains('.') ? t => t.VisitNum.ToString().Contains(".") : t => t.VisitNum == decimal.Parse(visitSearchDTO.VisitPlanInfo)) + //.WhereIf(visitSearchDTO.AuditState != null, t => t.AuditState == visitSearchDTO.AuditState) + .WhereIf(inQuery.AuditStateArray != null && inQuery.AuditStateArray?.Length > 0, t => inQuery.AuditStateArray!.Contains(t.AuditState)) + .WhereIf(inQuery.HandleUserId != null, t => t.PreliminaryAuditUserId == inQuery.HandleUserId || t.CurrentActionUserId == inQuery.HandleUserId + || t.ReviewAuditUserId == inQuery.HandleUserId + || t.QCChallengeList.Any(t => t.CreateUserId == inQuery.HandleUserId) + || t.QCChallengeDialogList.Any(t => t.CreateUserId == inQuery.HandleUserId)) + .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent) + .Where(t => t.SubmitState != SubmitStateEnum.None) + .WhereIf(inQuery.BeginAuditTime != null, t => t.Trial.QCProcessEnum == TrialQCProcess.SingleAudit ? t.PreliminaryAuditTime >= inQuery.BeginAuditTime : + (t.Trial.QCProcessEnum == TrialQCProcess.DoubleAudit ? t.ReviewAuditTime >= inQuery.BeginAuditTime : true)) + + .WhereIf(inQuery.EndAuditTime != null, t => t.Trial.QCProcessEnum == TrialQCProcess.SingleAudit ? t.PreliminaryAuditTime <= inQuery.EndAuditTime : + (t.Trial.QCProcessEnum == TrialQCProcess.DoubleAudit ? t.ReviewAuditTime <= inQuery.EndAuditTime : true)) + + .ProjectTo(_mapper.ConfigurationProvider); + + + var list = query.ToList(); + + var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); + + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); + exportInfo.IsEn_US = _userInfo.IsEn_Us; + exportInfo.ClientZoneId = _userInfo.TimeZoneId; + + + return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialQCVisitImageList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(CRCVisitExportDTO)); + + } /// /// 质疑列表 /// - /// + /// /// /// /// /// [HttpPost] [AllowAnonymous] - public async Task GetQCChallengeList_Export(ChallengeQuery challengeQuery, + public async Task GetQCChallengeList_Export(ChallengeQuery inQuery, [FromServices] IRepository _commonDocumentRepository, [FromServices] IDictionaryService _dictionaryService, [FromServices] IRepository _trialRepository @@ -268,26 +434,28 @@ namespace IRaCIS.Core.Application.Service.Common { - var svExpression = QCCommon.GetQCChallengeFilter(challengeQuery.VisitPlanArray); + var svExpression = QCCommon.GetQCChallengeFilter(inQuery.VisitPlanArray); - var list = await _repository.Where(x => x.TrialId == challengeQuery.TrialId) + var query = _repository.Where(x => x.TrialId == inQuery.TrialId) //.WhereIf(challengeQuery.ChallengeState != null, t => t.SubjectVisit.ChallengeState == challengeQuery.ChallengeState) - .WhereIf(challengeQuery.ReuploadEnum != null, t => t.ReuploadEnum == challengeQuery.ReuploadEnum) - .WhereIf(challengeQuery.IsClosed != null, t => t.IsClosed == challengeQuery.IsClosed) - .WhereIf(challengeQuery.TrialSiteId != null, t => t.SubjectVisit.TrialSiteId == challengeQuery.TrialSiteId) - .WhereIf(challengeQuery.SubjectId != null, t => t.SubjectVisit.SubjectId == challengeQuery.SubjectId) - .WhereIf(challengeQuery.CreateUserId != null, t => t.CreateUserId == challengeQuery.CreateUserId) - .WhereIf(!string.IsNullOrEmpty(challengeQuery.SubjectCode), t => t.SubjectVisit.Subject.Code.Contains(challengeQuery.SubjectCode)) - .WhereIf(challengeQuery.VisitPlanArray != null && challengeQuery.VisitPlanArray?.Length > 0, svExpression) - //.WhereIf(!string.IsNullOrEmpty(challengeQuery.VisitPlanInfo), challengeQuery.VisitPlanInfo.Contains('.') ? t => t.SubjectVisit.InPlan == false : t => t.SubjectVisit.VisitNum == decimal.Parse(challengeQuery.VisitPlanInfo)) - .WhereIf(challengeQuery.IsUrgent != null, t => t.SubjectVisit.IsUrgent == challengeQuery.IsUrgent) - .WhereIf(challengeQuery.IsOverTime != null && challengeQuery.IsOverTime == true, t => t.IsClosed ? t.ClosedTime > t.DeadlineTime : DateTime.Now > t.DeadlineTime) - .WhereIf(challengeQuery.IsOverTime != null && challengeQuery.IsOverTime == false, t => t.IsClosed ? t.ClosedTime < t.DeadlineTime : DateTime.Now < t.DeadlineTime) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + .WhereIf(inQuery.ReuploadEnum != null, t => t.ReuploadEnum == inQuery.ReuploadEnum) + .WhereIf(inQuery.IsClosed != null, t => t.IsClosed == inQuery.IsClosed) + .WhereIf(inQuery.TrialSiteId != null, t => t.SubjectVisit.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.SubjectId != null, t => t.SubjectVisit.SubjectId == inQuery.SubjectId) + .WhereIf(inQuery.CreateUserId != null, t => t.CreateUserId == inQuery.CreateUserId) + .WhereIf(inQuery.SubjectCode != null, t => t.SubjectVisit.Subject.Code.Contains(inQuery.SubjectCode!)) + .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) + //.WhereIf(!string.IsNullOrEmpty(challengeQuery.VisitPlanInfo), challengeQuery.VisitPlanInfo.Contains('.') ? t => t.SubjectVisit.VisitNum.ToString().Contains(".") : t => t.SubjectVisit.VisitNum == decimal.Parse(challengeQuery.VisitPlanInfo)) + .WhereIf(inQuery.IsOverTime != null && inQuery.IsOverTime == true, t => t.IsClosed ? t.ClosedTime > t.DeadlineTime : DateTime.Now > t.DeadlineTime) + .WhereIf(inQuery.IsOverTime != null && inQuery.IsOverTime == false, t => t.IsClosed ? t.ClosedTime < t.DeadlineTime : DateTime.Now < t.DeadlineTime) + .WhereIf(inQuery.IsUrgent != null, t => t.SubjectVisit.IsUrgent == inQuery.IsUrgent) + .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.SubjectVisit.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) - list = list.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.ChallengeCode).ToList(); + .ProjectTo(_mapper.ConfigurationProvider); - var exportInfo = (await _trialRepository.Where(t => t.Id == challengeQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); + var list = query.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.ChallengeCode).ToList(); + + var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; @@ -300,32 +468,37 @@ namespace IRaCIS.Core.Application.Service.Common /// /// 受试者信息导出表 /// - /// + /// /// + /// /// /// /// [HttpPost] - public async Task GetSubjectList_Export(SubjectQueryParam param, + public async Task GetSubjectList_Export(SubjectQueryParam inQuery, [FromServices] IRepository _commonDocumentRepository, + [FromServices] IRepository _subjectRepository, [FromServices] IDictionaryService _dictionaryService, [FromServices] IRepository _trialRepository) { - var list = await _repository.Where(u => u.TrialId == param.TrialId) - .WhereIf(!string.IsNullOrWhiteSpace(param.Code), t => t.Code.Contains(param.Code)) - .WhereIf(!string.IsNullOrWhiteSpace(param.Name), t => t.ShortName.Contains(param.Name)) - .WhereIf(!string.IsNullOrWhiteSpace(param.Sex), t => t.Sex.Contains(param.Sex)) - .WhereIf(param.Status != null, t => t.Status == param.Status) - .WhereIf(param.TrialSiteId != null, t => t.TrialSiteId == param.TrialSiteId) + var subjectQuery = _subjectRepository.Where(u => u.TrialId == inQuery.TrialId) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Code), t => t.Code.Contains(inQuery.Code)) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Name), t => t.ShortName.Contains(inQuery.Name)) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Sex), t => t.Sex.Contains(inQuery.Sex)) + .WhereIf(inQuery.Status != null, t => t.Status == inQuery.Status) + + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId) // CRC 只负责他管理site的受试者 .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + .ProjectTo(_mapper.ConfigurationProvider) + .WhereIf(inQuery.IsMissingImages != null, t => t.IsMissingImages == inQuery.IsMissingImages) + .ProjectTo(_mapper.ConfigurationProvider); - list = list.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.Code).ToList(); + var list = subjectQuery.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.Code).ToList(); - var exportInfo = (await _trialRepository.Where(t => t.Id == param.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); + var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; @@ -337,39 +510,6 @@ namespace IRaCIS.Core.Application.Service.Common - ///// - ///// 受试者 阅片期 进度表 导出 - ///// - ///// - ///// - ///// - ///// - //[HttpPost] - //public async Task GetSubjectReadingPeriod_Export(GetReadModuleDto dto, - // [FromServices] IRepository _commonDocumentRepository, - // [FromServices] IDictionaryService _dictionaryService, - // [FromServices] IRepository _trialRepository) - //{ - - - // var list = await _repository.Where(u => u.TrialId == dto.TrialId) - // .WhereIf(dto.SubjectId != null, x => x.Id == dto.SubjectId) - // .WhereIf(dto.TrialSiteCode != null && dto.TrialSiteCode != string.Empty, x => x.TrialSite.TrialSiteCode == dto.TrialSiteCode) - // .WhereIf(dto.SubjectCode != null && dto.SubjectCode != string.Empty, x => x.Code == dto.SubjectCode) - // //.WhereIf(dto.ReadingStatus != null, x => x.ReadingStatus == dto.ReadingStatus) - - // .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); - - - // list = list.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.Code).ToList(); - - // var exportInfo = (await _trialRepository.Where(t => t.Id == dto.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); - - // exportInfo.List = list; - - // return await ExcelExportHelper.DataExportAsync(StaticData.Export.TrialSubjectList_Export, exportInfo, $"{exportInfo.ResearchProgramNo}", _commonDocumentRepository, _hostEnvironment, _dictionaryService, typeof(SubjectExportDTO)); - //} - /// @@ -517,26 +657,31 @@ namespace IRaCIS.Core.Application.Service.Common /// /// 影像上传监控表 /// - /// + /// /// /// /// /// [HttpPost] - public async Task GetStudyUploadMonitor_Export(StudyQuery studyQuery, + public async Task GetStudyUploadMonitor_Export(StudyQuery inQuery, [FromServices] IRepository _commonDocumentRepository, [FromServices] IDictionaryService _dictionaryService, [FromServices] IRepository _trialRepository) { - var svExpression = QCCommon.GetStudyMonitorSubjectVisitFilter(studyQuery.VisitPlanArray); - var StudyMonitorQuery = _repository.Where(t => t.TrialId == studyQuery.TrialId) + var svExpression = QCCommon.GetStudyMonitorSubjectVisitFilter(inQuery.VisitPlanArray); + var StudyMonitorQuery = _repository.Where(t => t.TrialId == inQuery.TrialId, ignoreQueryFilters: true) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.Subject.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) - .WhereIf(studyQuery.VisitPlanArray != null && studyQuery.VisitPlanArray?.Length > 0, svExpression) - .WhereIf(!string.IsNullOrWhiteSpace(studyQuery.SubjectInfo), t => t.Subject.Code.Contains(studyQuery.SubjectInfo)) - .WhereIf(studyQuery.SubjectId != null, t => t.SubjectId == studyQuery.SubjectId) - .WhereIf(studyQuery.SubjectVisitId != null, t => t.SubjectId == studyQuery.SubjectVisitId) - .WhereIf(studyQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == studyQuery.TrialSiteId) + //.WhereIf(!string.IsNullOrEmpty(studyQuery.VisitPlanInfo), studyQuery.VisitPlanInfo.Contains('.') ? t => t.SubjectVisit.VisitNum.ToString().Contains(".") : t => t.SubjectVisit.VisitNum == decimal.Parse(studyQuery.VisitPlanInfo)) + .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.SubjectInfo), t => t.Subject.Code.Contains(inQuery.SubjectInfo)) + .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId) + .WhereIf(inQuery.SubjectVisitId != null, t => t.SubjectId == inQuery.SubjectVisitId) + .WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.IsDicom != null, t => t.IsDicom == inQuery.IsDicom) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Uploader), t => t.Uploader.UserName.Contains(inQuery.Uploader)) + .WhereIf(inQuery.IsSuccess != null, t => t.IsSuccess == inQuery.IsSuccess) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.StudyCode), t => t.StudyCode.Contains(inQuery.StudyCode)) .Select(t => new UnionStudyMonitorExportDto() { TrialSiteCode = t.Subject.TrialSite.TrialSiteCode, @@ -575,7 +720,7 @@ namespace IRaCIS.Core.Application.Service.Common var list = await StudyMonitorQuery.ToListAsync(); - var exportInfo = (await _trialRepository.Where(t => t.Id == studyQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); + var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; @@ -715,34 +860,35 @@ namespace IRaCIS.Core.Application.Service.Common /// /// 一致性核查记录表 /// - /// + /// /// /// /// /// /// [HttpPost] - public async Task GetConsistencyVerificationList_Export(CheckQuery checkQuery, + public async Task GetConsistencyVerificationList_Export(CheckQuery inQuery, [FromServices] IRepository _commonDocumentRepository, [FromServices] IDictionaryService _dictionaryService, [FromServices] IRepository _trialRepository, [FromServices] IRepository _subjectVisitRepository) { - var svExpression = QCCommon.GetSubjectVisitFilter(checkQuery.VisitPlanArray); + var svExpression = QCCommon.GetSubjectVisitFilter(inQuery.VisitPlanArray); - var list = await _subjectVisitRepository.Where(x => x.TrialId == checkQuery.TrialId) + var query = _subjectVisitRepository.Where(x => x.TrialId == inQuery.TrialId) .Where(x => x.AuditState == AuditStateEnum.QCPassed) //一致性核查中的,或者还没一致性核查的 - .WhereIf(checkQuery.CheckState != null, t => t.CheckState == checkQuery.CheckState) - .WhereIf(checkQuery.TrialSiteId != null, t => t.TrialSiteId == checkQuery.TrialSiteId) - .WhereIf(!string.IsNullOrEmpty(checkQuery.SubjectInfo), t => t.Subject.Code.Contains(checkQuery.SubjectInfo)) - .WhereIf(checkQuery.VisitPlanArray != null && checkQuery.VisitPlanArray?.Length > 0, svExpression) + .WhereIf(inQuery.CheckState != null, t => t.CheckState == inQuery.CheckState) + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectInfo), t => t.Subject.Code.Contains(inQuery.SubjectInfo)) + .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) + //.WhereIf(!string.IsNullOrEmpty(checkQuery.VisitPlanInfo), checkQuery.VisitPlanInfo.Contains('.') ? t => t.InPlan == false : t => t.VisitNum == decimal.Parse(checkQuery.VisitPlanInfo)) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id))//CRC 过滤负责的site - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + .ProjectTo(_mapper.ConfigurationProvider); - list = list.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.VisitNum).ToList(); + var list = query.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.VisitNum).ToList(); - var exportInfo = (await _trialRepository.Where(t => t.Id == checkQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); + var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; @@ -810,44 +956,58 @@ namespace IRaCIS.Core.Application.Service.Common /// /// PM 重阅追踪 /// - /// + /// /// + /// /// /// /// [HttpPost] - public async Task GetReReadingTaskList_Export(VisitTaskQuery queryVisitTask, + public async Task GetReReadingTaskList_Export(VisitTaskQuery inQuery, [FromServices] IRepository _commonDocumentRepository, + [FromServices] IRepository _visitTaskReReadingRepository, [FromServices] IDictionaryService _dictionaryService, [FromServices] IRepository _trialRepository) { - var list = await _repository.Where(t => t.OriginalReReadingTask.TrialId == queryVisitTask.TrialId /*&& t.OriginalReReadingTask.IsAnalysisCreate == false*/) - .WhereIf(queryVisitTask.RootReReadingTaskId != null, t => t.RootReReadingTaskId == queryVisitTask.RootReReadingTaskId || t.OriginalReReadingTaskId == queryVisitTask.RootReReadingTaskId) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(queryVisitTask.TaskCode!) || t.RootReReadingTask.TaskCode.Contains(queryVisitTask.TaskCode!)) - .WhereIf(queryVisitTask.TrialSiteId != null, t => t.OriginalReReadingTask.Subject.TrialSiteId == queryVisitTask.TrialSiteId) - .WhereIf(queryVisitTask.TaskState != null, t => t.OriginalReReadingTask.TaskState == queryVisitTask.TaskState) - .WhereIf(queryVisitTask.ReReadingApplyState != null, t => t.OriginalReReadingTask.ReReadingApplyState == queryVisitTask.ReReadingApplyState) - .WhereIf(queryVisitTask.SubjectId != null, t => t.OriginalReReadingTask.SubjectId == queryVisitTask.SubjectId) - .WhereIf(queryVisitTask.IsUrgent != null, t => t.OriginalReReadingTask.IsUrgent == queryVisitTask.IsUrgent) - .WhereIf(queryVisitTask.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == queryVisitTask.DoctorUserId) - .WhereIf(queryVisitTask.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == queryVisitTask.ReadingTaskState) - .WhereIf(queryVisitTask.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == queryVisitTask.TaskAllocationState) - .WhereIf(queryVisitTask.TrialReadingCriterionId != null, t => t.OriginalReReadingTask.TrialReadingCriterionId == queryVisitTask.TrialReadingCriterionId) + var visitTaskQueryable = _visitTaskReReadingRepository + .Where(t => t.OriginalReReadingTask.TrialId == inQuery.TrialId /*&& t.OriginalReReadingTask.IsAnalysisCreate == false*/) + .WhereIf(inQuery.RootReReadingTaskId != null, t => t.RootReReadingTaskId == inQuery.RootReReadingTaskId || t.OriginalReReadingTaskId == inQuery.RootReReadingTaskId) + .WhereIf(!string.IsNullOrEmpty(inQuery.TaskCode), t => t.OriginalReReadingTask.TaskCode.Contains(inQuery.TaskCode!) || t.RootReReadingTask.TaskCode.Contains(inQuery.TaskCode!)) + .WhereIf(inQuery.TrialSiteId != null, t => t.OriginalReReadingTask.Subject.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.TaskState != null, t => t.OriginalReReadingTask.TaskState == inQuery.TaskState) + .WhereIf(inQuery.ReReadingApplyState != null, t => t.OriginalReReadingTask.ReReadingApplyState == inQuery.ReReadingApplyState) + .WhereIf(inQuery.RequestReReadingType != null, t => t.RequestReReadingType == inQuery.RequestReReadingType) + .WhereIf(inQuery.SubjectId != null, t => t.OriginalReReadingTask.SubjectId == inQuery.SubjectId) + .WhereIf(inQuery.IsUrgent != null, t => t.OriginalReReadingTask.IsUrgent == inQuery.IsUrgent) + .WhereIf(inQuery.DoctorUserId != null, t => t.OriginalReReadingTask.DoctorUserId == inQuery.DoctorUserId) + .WhereIf(inQuery.ArmEnum != null, t => t.OriginalReReadingTask.ArmEnum == inQuery.ArmEnum) + .WhereIf(inQuery.ReadingTaskState != null, t => t.OriginalReReadingTask.ReadingTaskState == inQuery.ReadingTaskState) + .WhereIf(inQuery.TaskAllocationState != null, t => t.OriginalReReadingTask.TaskAllocationState == inQuery.TaskAllocationState) + .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.OriginalReReadingTask.TrialReadingCriterionId == inQuery.TrialReadingCriterionId) + .WhereIf(inQuery.ReadingCategory != null, t => t.OriginalReReadingTask.ReadingCategory == inQuery.ReadingCategory) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(queryVisitTask.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(queryVisitTask.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate == false)) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(queryVisitTask.TaskName) || t.OriginalReReadingTask.TaskBlindName.Contains(queryVisitTask.TaskName)) - .WhereIf(!string.IsNullOrEmpty(queryVisitTask.SubjectCode), t => t.OriginalReReadingTask.Subject.Code.Contains(queryVisitTask.SubjectCode) || t.OriginalReReadingTask.BlindSubjectCode.Contains(queryVisitTask.SubjectCode)) - .WhereIf(queryVisitTask.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > queryVisitTask.BeginAllocateDate) - .WhereIf(queryVisitTask.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < queryVisitTask.EndAllocateDate!.Value.AddDays(1)) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + .WhereIf(!string.IsNullOrEmpty(inQuery.RequestReReadingReason), t => t.RequestReReadingReason.Contains(inQuery.RequestReReadingReason)) + + .WhereIf(inQuery.RequestReReadingResultEnum != null, t => t.RequestReReadingResultEnum == inQuery.RequestReReadingResultEnum) + + + .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.OriginalReReadingTask.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate) || (t.OriginalReReadingTask.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode!) && t.OriginalReReadingTask.IsAnalysisCreate == false)) + .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.OriginalReReadingTask.TaskName.Contains(inQuery.TaskName) || t.OriginalReReadingTask.TaskBlindName.Contains(inQuery.TaskName)) + .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => ((t.OriginalReReadingTask.Subject.Code.Contains(inQuery.SubjectCode) || t.OriginalReReadingTask.Subject.MedicalNo.Contains(inQuery.SubjectCode)) && t.OriginalReReadingTask.IsAnalysisCreate == false) || (t.OriginalReReadingTask.BlindSubjectCode.Contains(inQuery.SubjectCode) && t.OriginalReReadingTask.IsAnalysisCreate)) + .WhereIf(inQuery.BeginAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime > inQuery.BeginAllocateDate) + .WhereIf(inQuery.EndAllocateDate != null, t => t.OriginalReReadingTask.AllocateTime < inQuery.EndAllocateDate!.Value.AddDays(1)) + + .WhereIf(inQuery.BeginRequestReReadingTime != null, t => t.RequestReReadingTime >= inQuery.BeginRequestReReadingTime) + .WhereIf(inQuery.EndRequestReReadingTime != null, t => t.RequestReReadingTime <= inQuery.EndRequestReReadingTime!.Value.AddDays(1)) + .ProjectTo(_mapper.ConfigurationProvider); //var defalutSortArray = new string[] { nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.IsUrgent) + " desc", nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.SubjectId), nameof(ReReadingTaskView.OriginalReReadingTask) + "." + nameof(ReReadingTaskView.OriginalReReadingTask.VisitTaskNum) }; - list = list.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.VisitTaskNum).ToList(); + var list = visitTaskQueryable.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.VisitTaskNum).ToList(); - var exportInfo = (await _trialRepository.Where(t => t.Id == queryVisitTask.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); + var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list, _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; @@ -863,31 +1023,48 @@ namespace IRaCIS.Core.Application.Service.Common /// /// /// + /// /// /// /// [HttpPost] public async Task GetMedicalReviewTaskList_Export(TaskMedicalReviewQuery inQuery, [FromServices] IRepository _commonDocumentRepository, + [FromServices] IRepository _taskMedicalReviewRepository, [FromServices] IDictionaryService _dictionaryService, [FromServices] IRepository _trialRepository) { - var list = await _repository.Where(t => t.VisitTask.TrialId == inQuery.TrialId && t.MedicalManagerUserId!=null) + var taskMedicalReviewQueryable = _taskMedicalReviewRepository.Where(t => t.VisitTask.TrialId == inQuery.TrialId) + .WhereIf(inQuery.TrialSiteId != null, t => t.VisitTask.Subject.TrialSiteId == inQuery.TrialSiteId) .WhereIf(inQuery.SubjectId != null, t => t.VisitTask.SubjectId == inQuery.SubjectId) - .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.VisitTask.Subject.Code.Contains(inQuery.SubjectCode)) + .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectCode), t => t.VisitTask.Subject.Code.Contains(inQuery.SubjectCode) || t.VisitTask.Subject.MedicalNo.Contains(inQuery.SubjectCode)) .WhereIf(!string.IsNullOrEmpty(inQuery.TaskName), t => t.VisitTask.TaskName.Contains(inQuery.TaskName) || t.VisitTask.TaskBlindName.Contains(inQuery.TaskName)) .WhereIf(inQuery.IsUrgent != null, t => t.VisitTask.IsUrgent == inQuery.IsUrgent) .WhereIf(inQuery.DoctorUserId != null, t => t.VisitTask.DoctorUserId == inQuery.DoctorUserId) .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteCode), t => (t.VisitTask.BlindTrialSiteCode.Contains(inQuery.TrialSiteCode) && t.VisitTask.IsAnalysisCreate) || (t.VisitTask.Subject.TrialSite.TrialSiteCode.Contains(inQuery.TrialSiteCode) && t.VisitTask.IsAnalysisCreate == false)) .WhereIf(inQuery.ReadingCategory != null, t => t.VisitTask.ReadingCategory == inQuery.ReadingCategory) - .WhereIf(inQuery.ReadingTaskState != null, t => t.VisitTask.ReadingTaskState == inQuery.ReadingTaskState) + .WhereIf(inQuery.TaskState != null, t => t.VisitTask.TaskState == inQuery.TaskState) + .WhereIf(inQuery.ArmEnum != null, t => t.VisitTask.ArmEnum == inQuery.ArmEnum) + .WhereIf(inQuery.AuditState != null, t => t.AuditState == inQuery.AuditState) + .WhereIf(inQuery.MedicalManagerUserId != null, t => t.MedicalManagerUserId == inQuery.MedicalManagerUserId) + .WhereIf(inQuery.BeginSignTime != null, t => t.VisitTask.SignTime > inQuery.BeginSignTime) + .WhereIf(inQuery.EndSignTime != null, t => t.VisitTask.SignTime < inQuery.EndSignTime) + .WhereIf(inQuery.AuditAdviceEnum != null, t => t.AuditAdviceEnum == inQuery.AuditAdviceEnum) - .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.VisitTask.TrialReadingCriterionId == inQuery.TrialReadingCriterionId) - .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + .WhereIf(inQuery.DoctorUserIdeaEnum != null, t => t.DoctorUserIdeaEnum == inQuery.DoctorUserIdeaEnum) + .WhereIf(inQuery.TrialReadingCriterionId != null, t => t.VisitTask.TrialReadingCriterionId == inQuery.TrialReadingCriterionId) + .WhereIf(inQuery.IsInvalid != null, t => t.IsInvalid == inQuery.IsInvalid) + .WhereIf(inQuery.IsHaveQuestion != null, t => t.IsHaveQuestion == inQuery.IsHaveQuestion) - list = list.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.VisitTaskNum).ToList(); + .WhereIf(inQuery.BeginAllocateDate != null, t => t.AllocateTime >= inQuery.BeginAllocateDate) + .WhereIf(inQuery.EndAllocateDate != null, t => t.AllocateTime <= inQuery.EndAllocateDate) + .WhereIf(inQuery.BeginAuditSignTime != null, t => t.AuditSignTime >= inQuery.BeginAuditSignTime) + .WhereIf(inQuery.EndAuditSignTime != null, t => t.AuditSignTime <= inQuery.EndAuditSignTime) + .ProjectTo(_mapper.ConfigurationProvider); + + var list = taskMedicalReviewQueryable.OrderBy(t => t.TrialSiteCode).ThenBy(t => t.SubjectCode).ThenBy(t => t.VisitTaskNum).ToList(); var exportInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).IgnoreQueryFilters().ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync()).IfNullThrowException(); @@ -1326,7 +1503,7 @@ namespace IRaCIS.Core.Application.Service.Common //处理裁判标记 list = DealJudgeMark(criterion.ArbitrationRule, list); - exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list.Where(t=>t.ReadingCategory!=ReadingCategory.Global).ToList(), _userInfo.TimeZoneId); + exportInfo.List = ExportExcelConverterDate.ConvertToClientTimeInObject(list.Where(t => t.ReadingCategory != ReadingCategory.Global).ToList(), _userInfo.TimeZoneId); exportInfo.IsEn_US = _userInfo.IsEn_Us; exportInfo.ClientZoneId = _userInfo.TimeZoneId; diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index ca19ab0b9..1c32b6040 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -369,10 +369,10 @@ namespace IRaCIS.Core.Application.Services /// /// 获取确认列表情况 项目文档+系统文档+具体的人 /// - /// + /// /// [HttpPost] - public async Task<(PageOutput, object)> GetDocumentConfirmList(DocumentTrialUnionQuery querySystemDocument) + public async Task<(PageOutput, object)> GetDocumentConfirmList(DocumentTrialUnionQuery inQuery) { @@ -409,15 +409,15 @@ namespace IRaCIS.Core.Application.Services #endregion - var trialInfo = (await _repository.Where(t => t.Id == querySystemDocument.TrialId).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstNotNullAsync()); + var trialInfo = (await _repository.Where(t => t.Id == inQuery.TrialId).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstNotNullAsync()); - var trialDocQuery = from trialDocumentNeedConfirmedUserType in _repository.Where(t => t.TrialDocument.TrialId == querySystemDocument.TrialId) - join trialUser in _repository.Where(t => t.TrialId == querySystemDocument.TrialId) - .WhereIf(querySystemDocument.UserId != null, t => t.UserId == querySystemDocument.UserId) - .WhereIf(querySystemDocument.UserTypeId != null, t => t.User.UserTypeId == querySystemDocument.UserTypeId) + var trialDocQuery = from trialDocumentNeedConfirmedUserType in _repository.Where(t => t.TrialDocument.TrialId == inQuery.TrialId) + join trialUser in _repository.Where(t => t.TrialId == inQuery.TrialId) + .WhereIf(inQuery.UserId != null, t => t.UserId == inQuery.UserId) + .WhereIf(inQuery.UserTypeId != null, t => t.User.UserTypeId == inQuery.UserTypeId) on trialDocumentNeedConfirmedUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId - join confirm in _repository.Where(t => t.TrialDocument.TrialId == querySystemDocument.TrialId) on + join confirm in _repository.Where(t => t.TrialDocument.TrialId == inQuery.TrialId) on new { trialUser.UserId, TrialDocumentId = trialDocumentNeedConfirmedUserType.TrialDocumentId } equals new { UserId = confirm.ConfirmUserId, confirm.TrialDocumentId } into cc from confirm in cc.DefaultIfEmpty() select new UnionDocumentWithConfirmInfoView() @@ -451,8 +451,8 @@ namespace IRaCIS.Core.Application.Services var systemDocQuery = from needConfirmEdUserType in _repository.WhereIf(trialInfo.TrialFinishedTime != null, u => u.SystemDocument.CreateTime < trialInfo.TrialFinishedTime) - join trialUser in _repository.Where(t => t.TrialId == querySystemDocument.TrialId) - .WhereIf(querySystemDocument.UserId != null, t => t.UserId == querySystemDocument.UserId) + join trialUser in _repository.Where(t => t.TrialId == inQuery.TrialId) + .WhereIf(inQuery.UserId != null, t => t.UserId == inQuery.UserId) on needConfirmEdUserType.NeedConfirmUserTypeId equals trialUser.User.UserTypeId join confirm in _repository.GetQueryable() on new { ConfirmUserId = trialUser.UserId, SystemDocumentId = needConfirmEdUserType.SystemDocumentId } equals new { confirm.ConfirmUserId, confirm.SystemDocumentId } into cc from confirm in cc.DefaultIfEmpty() @@ -482,14 +482,14 @@ namespace IRaCIS.Core.Application.Services }; var unionQuery = trialDocQuery.Union(systemDocQuery) - .WhereIf(!string.IsNullOrEmpty(querySystemDocument.Name), t => t.Name.Contains(querySystemDocument.Name)) - .WhereIf(querySystemDocument.FileTypeId != null, t => t.FileTypeId == querySystemDocument.FileTypeId) - .WhereIf(querySystemDocument.IsConfirmed == true, t => t.ConfirmTime != null) - .WhereIf(querySystemDocument.IsConfirmed == false, t => t.ConfirmTime == null) - .WhereIf(querySystemDocument.IsDeleted != null, t => t.IsDeleted == querySystemDocument.IsDeleted) - .WhereIf(querySystemDocument.UserTypeId != null, t => t.UserTypeId == querySystemDocument.UserTypeId); + .WhereIf(!string.IsNullOrEmpty(inQuery.Name), t => t.Name.Contains(inQuery.Name)) + .WhereIf(inQuery.FileTypeId != null, t => t.FileTypeId == inQuery.FileTypeId) + .WhereIf(inQuery.IsConfirmed == true, t => t.ConfirmTime != null) + .WhereIf(inQuery.IsConfirmed == false, t => t.ConfirmTime == null) + .WhereIf(inQuery.IsDeleted != null, t => t.IsDeleted == inQuery.IsDeleted) + .WhereIf(inQuery.UserTypeId != null, t => t.UserTypeId == inQuery.UserTypeId); - var result = await unionQuery.ToPagedListAsync(querySystemDocument.PageIndex, querySystemDocument.PageSize, querySystemDocument.SortField, querySystemDocument.Asc); + var result = await unionQuery.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc); var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true) .Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.Id)) diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs index dbed0f7c8..cdd161e9b 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs @@ -483,21 +483,21 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc [HttpPost] - public async Task> GetDicomAndNoneDicomStudyMonitorList(StudyQuery studyQuery) + public async Task> GetDicomAndNoneDicomStudyMonitorList(StudyQuery inQuery) { - var svExpression = QCCommon.GetStudyMonitorSubjectVisitFilter(studyQuery.VisitPlanArray); - var StudyMonitorQuery = _repository.Where(t => t.TrialId == studyQuery.TrialId, ignoreQueryFilters: true) + var svExpression = QCCommon.GetStudyMonitorSubjectVisitFilter(inQuery.VisitPlanArray); + var StudyMonitorQuery = _repository.Where(t => t.TrialId == inQuery.TrialId, ignoreQueryFilters: true) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.Subject.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) //.WhereIf(!string.IsNullOrEmpty(studyQuery.VisitPlanInfo), studyQuery.VisitPlanInfo.Contains('.') ? t => t.SubjectVisit.VisitNum.ToString().Contains(".") : t => t.SubjectVisit.VisitNum == decimal.Parse(studyQuery.VisitPlanInfo)) - .WhereIf(studyQuery.VisitPlanArray != null && studyQuery.VisitPlanArray?.Length > 0, svExpression) - .WhereIf(!string.IsNullOrWhiteSpace(studyQuery.SubjectInfo), t => t.Subject.Code.Contains(studyQuery.SubjectInfo)) - .WhereIf(studyQuery.SubjectId != null, t => t.SubjectId == studyQuery.SubjectId) - .WhereIf(studyQuery.SubjectVisitId != null, t => t.SubjectId == studyQuery.SubjectVisitId) - .WhereIf(studyQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == studyQuery.TrialSiteId) - .WhereIf(studyQuery.IsDicom != null, t => t.IsDicom == studyQuery.IsDicom) - .WhereIf(!string.IsNullOrWhiteSpace(studyQuery.Uploader), t => t.Uploader.UserName.Contains(studyQuery.Uploader)) - .WhereIf(studyQuery.IsSuccess != null, t => t.IsSuccess == studyQuery.IsSuccess) - .WhereIf(!string.IsNullOrWhiteSpace(studyQuery.StudyCode), t => t.StudyCode.Contains(studyQuery.StudyCode)) + .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.SubjectInfo), t => t.Subject.Code.Contains(inQuery.SubjectInfo)) + .WhereIf(inQuery.SubjectId != null, t => t.SubjectId == inQuery.SubjectId) + .WhereIf(inQuery.SubjectVisitId != null, t => t.SubjectId == inQuery.SubjectVisitId) + .WhereIf(inQuery.TrialSiteId != null, t => t.Subject.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.IsDicom != null, t => t.IsDicom == inQuery.IsDicom) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Uploader), t => t.Uploader.UserName.Contains(inQuery.Uploader)) + .WhereIf(inQuery.IsSuccess != null, t => t.IsSuccess == inQuery.IsSuccess) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.StudyCode), t => t.StudyCode.Contains(inQuery.StudyCode)) .Select(t => new UnionStudyMonitorModel() { TrialId = t.TrialId, @@ -541,7 +541,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc }); - return await StudyMonitorQuery.ToPagedListAsync(studyQuery.PageIndex, studyQuery.PageSize, string.IsNullOrEmpty(studyQuery.SortField) ? "UploadTime" : studyQuery.SortField, studyQuery.Asc); + return await StudyMonitorQuery.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrEmpty(inQuery.SortField) ? "UploadTime" : inQuery.SortField, inQuery.Asc); diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index 3a4ba042c..7d9c33e72 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -7,6 +7,7 @@ using Newtonsoft.Json; using System.ComponentModel; using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; +using System.Web; namespace IRaCIS.Core.Application.Contracts { @@ -161,9 +162,61 @@ namespace IRaCIS.Core.Application.Contracts #region 导出模型 + + public class TrainingRecordExportDTO + { + public Guid Id { get; set; } + + public Guid FileTypeId { get; set; } + + public Guid UserTypeId { get; set; } + + public string FileType { get; set; } + + public string Name { get; set; } + + [DictionaryTranslateAttribute("IsSystemDoc")] + public bool IsSystemDoc { get; set; } + + [DictionaryTranslateAttribute("YesOrNo")] + public bool IsDeleted { get; set; } + + //上传时间 + public DateTime CreateTime { get; set; } + + [DictionaryTranslateAttribute("YesOrNo")] + public bool IsConfirmed { get; set; } + + public string RealName { get; set; } + + public string UserName { get; set; } + + public string UserTypeShortName { get; set; } + + + public DateTime? ConfirmTime { get; set; } + } + public class CRCVisitExportDTO { - public ChallengeStateEnum ChallengeState { get; set; } + //关闭 未关闭 + [DictionaryTranslateAttribute("CheckIsClosedEnum")] + public ChallengeStateEnum CheckIsClosedEnum { get; set; } + + //强行要分为两个字段 有无质疑 + [DictionaryTranslateAttribute("YesOrNo")] + public bool IsChallengeClosed => (int)CheckIsClosedEnum > 0; + + //临床数据收集 + + public string ClinicalDataCollect => $"{DicomStudyCount},{NoneDicomStudyCount}{(IsBaseLine? (ClinicalInformationTransmissionEnum>0 &&IsHaveClinicalData ? "w/" : "w/o") :"" )}"; + + public int? DicomStudyCount { get; set; } + public int? NoneDicomStudyCount { get; set; } + + public int ClinicalInformationTransmissionEnum { get; set; } + + public bool IsBaseLine { get; set; } [DictionaryTranslateAttribute("YesOrNo")] public bool IsUrgent { get; set; } @@ -197,12 +250,31 @@ namespace IRaCIS.Core.Application.Contracts public DateTime? ReviewAuditTime { get; set; } public DateTime? PreliminaryAuditTime { get; set; } + //审核通过时间 public DateTime? AuditTime => QCProcessEnum == TrialQCProcess.SingleAudit ? PreliminaryAuditTime : (QCProcessEnum == TrialQCProcess.DoubleAudit ? ReviewAuditTime : null); } + public class QCVisitExportDTO: CRCVisitExportDTO + { + //上传人 + public string SubmitUserRealName { get; set; } + + public string PreliminaryAuditUserName { get; set; } + + public string ReviewAuditUserName { get; set; } + + public string CurrentActionUserName { get; set; } + + + } + public class QCChanllengeExportDto { + //审核批次 + [DictionaryTranslateAttribute("CurrentQCType")] + public CurrentQC? CurrentQCEnum { get; set; } + [DictionaryTranslateAttribute("Subject_Visit_Status")] public SubjectStatus SubjectState { get; set; } @@ -654,7 +726,6 @@ namespace IRaCIS.Core.Application.Contracts public class ReadingTaskExportDto { - //public TaskAllocationState TaskAllocationState { get; set; } [DictionaryTranslateAttribute("Subject_Visit_Status")] public SubjectStatus SubjectStatus { get; set; } @@ -662,13 +733,14 @@ namespace IRaCIS.Core.Application.Contracts public DateTime? AllocateTime { get; set; } - //public bool IsPMSetBack { get; set; } public string TaskCode { get; set; } public string TaskName { get; set; } public string TaskBlindName { get; set; } + public string FinalTaskName => TaskName != TaskBlindName ? $"{TaskName}/{TaskBlindName}" : TaskName; + public decimal VisitTaskNum { get; set; } [DictionaryTranslateAttribute("ReadingCategory")] @@ -690,6 +762,8 @@ namespace IRaCIS.Core.Application.Contracts public String TrialSiteCode { get; set; } = String.Empty; public string SubjectCode { get; set; } = String.Empty; + public string MedicalNo { get; set; } + public string FinalSubjectCode { get; set; } public string TrialReadingCriterionName { get; set; } @@ -711,8 +785,7 @@ namespace IRaCIS.Core.Application.Contracts { - //public ReadingTaskExportDto ApplyTask { get; set; } - + public string? ReReadingNewTaskCode { get; set; } @@ -742,8 +815,7 @@ namespace IRaCIS.Core.Application.Contracts public class TaskMedicalReviewExportDto : ReadingTaskExportDto { - public string MedicalNo { get; set; } = string.Empty; - + public string QuestionContent { get; set; } [DictionaryTranslateAttribute("MedicalReviewAuditState")] public MedicalReviewAuditState AuditState { get; set; } @@ -755,7 +827,8 @@ namespace IRaCIS.Core.Application.Contracts [DictionaryTranslateAttribute("AuditAdvice")] public AuditAdvice AuditAdviceEnum { get; set; } - [DictionaryTranslateAttribute("YesOrNo")] + //审核结论 + [DictionaryTranslateAttribute("IsPass")] public bool IsHaveQuestion { get; set; } @@ -764,7 +837,9 @@ namespace IRaCIS.Core.Application.Contracts //public UserSimpleInfo MedicalManagerUser { get; set; } - //public string DoctorUserName { get; set; } + public string DoctorUserName { get; set; } + + public string MedicalManagerUserName { get; set; } /// diff --git a/IRaCIS.Core.Application/Service/QC/QCListService.cs b/IRaCIS.Core.Application/Service/QC/QCListService.cs index bd065b33e..657675744 100644 --- a/IRaCIS.Core.Application/Service/QC/QCListService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCListService.cs @@ -54,35 +54,35 @@ namespace IRaCIS.Core.Application.Image.QA /// /// CRC 访视上传列表 /// - /// + /// /// [HttpPost] - public async Task>> GetCRCVisitList(CRCVisitSearchDTO visitSearchDTO) + public async Task>> GetCRCVisitList(CRCVisitSearchDTO inQuery) { - var svExpression = QCCommon.GetSubjectVisitFilter(visitSearchDTO.VisitPlanArray); + var svExpression = QCCommon.GetSubjectVisitFilter(inQuery.VisitPlanArray); - var query = _subjectVisitRepository.Where(x => x.TrialId == visitSearchDTO.TrialId) + var query = _subjectVisitRepository.Where(x => x.TrialId == inQuery.TrialId) .Where(t => t.Subject.FinalSubjectVisitId != null ? t.VisitNum <= t.Subject.FinalSubjectVisit.VisitNum : true) - .WhereIf(visitSearchDTO.TrialSiteId != null, t => t.TrialSiteId == visitSearchDTO.TrialSiteId) - .WhereIf(visitSearchDTO.SubjectId != null, t => t.Subject.Id == visitSearchDTO.SubjectId) - .WhereIf(!string.IsNullOrEmpty(visitSearchDTO.SubjectInfo), t => t.Subject.Code.Contains(visitSearchDTO.SubjectInfo)) + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.SubjectId != null, t => t.Subject.Id == inQuery.SubjectId) + .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectInfo), t => t.Subject.Code.Contains(inQuery.SubjectInfo)) - .WhereIf(visitSearchDTO.VisitPlanArray != null && visitSearchDTO.VisitPlanArray?.Length > 0, svExpression) + .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) //.WhereIf(!string.IsNullOrEmpty(visitSearchDTO.VisitPlanInfo), visitSearchDTO.VisitPlanInfo.Contains('.') ? t => t.InPlan == false : t => t.VisitNum == decimal.Parse(visitSearchDTO.VisitPlanInfo)) - .WhereIf(visitSearchDTO.AuditStateArray != null && visitSearchDTO.AuditStateArray?.Length > 0, t => visitSearchDTO.AuditStateArray!.Contains(t.AuditState)) - .WhereIf(visitSearchDTO.SubmitState != null, t => t.SubmitState == visitSearchDTO.SubmitState) - .WhereIf(visitSearchDTO.ChallengeState != null, t => t.ChallengeState == visitSearchDTO.ChallengeState) - .WhereIf(visitSearchDTO.IsUrgent != null, t => t.IsUrgent == visitSearchDTO.IsUrgent) + .WhereIf(inQuery.AuditStateArray != null && inQuery.AuditStateArray?.Length > 0, t => inQuery.AuditStateArray!.Contains(t.AuditState)) + .WhereIf(inQuery.SubmitState != null, t => t.SubmitState == inQuery.SubmitState) + .WhereIf(inQuery.ChallengeState != null, t => t.ChallengeState == inQuery.ChallengeState) + .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) .ProjectTo(_mapper.ConfigurationProvider); var defalutSortArray = new string[] { nameof(SubjectVisit.IsUrgent) + " desc", nameof(SubjectVisit.SubjectId), nameof(SubjectVisit.VisitNum) }; - var pageList = await query.ToPagedListAsync(visitSearchDTO.PageIndex, visitSearchDTO.PageSize, visitSearchDTO.SortField, visitSearchDTO.Asc, string.IsNullOrWhiteSpace(visitSearchDTO.SortField), defalutSortArray); + var pageList = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); - var config = await _repository.Where(t => t.Id == visitSearchDTO.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); - config.IsHaveSubjectClinicalData = await _clinicalDataTrialSet.AnyAsync(x => x.TrialId == visitSearchDTO.TrialId && x.IsConfirm && (x.ClinicalDataLevel == ClinicalLevel.Subject ) && x.UploadRole == UploadRole.CRC); - config.IsHaveVisitClinicalData = await _clinicalDataTrialSet.AnyAsync(x => x.TrialId == visitSearchDTO.TrialId && x.IsConfirm && (x.ClinicalDataLevel == ClinicalLevel.SubjectVisit) && x.UploadRole == UploadRole.CRC); + var config = await _repository.Where(t => t.Id == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); + config.IsHaveSubjectClinicalData = await _clinicalDataTrialSet.AnyAsync(x => x.TrialId == inQuery.TrialId && x.IsConfirm && (x.ClinicalDataLevel == ClinicalLevel.Subject ) && x.UploadRole == UploadRole.CRC); + config.IsHaveVisitClinicalData = await _clinicalDataTrialSet.AnyAsync(x => x.TrialId == inQuery.TrialId && x.IsConfirm && (x.ClinicalDataLevel == ClinicalLevel.SubjectVisit) && x.UploadRole == UploadRole.CRC); return ResponseOutput.Ok (pageList, config); } @@ -103,7 +103,7 @@ namespace IRaCIS.Core.Application.Image.QA PageSize = 9999 }); - var pageList = list.Item1.CurrentPageData.ToList(); + var pageList = list.Data.CurrentPageData.ToList(); var data = pageList.Where(x=>x.Id==inDto.QCChallengeId||x.IsClosed==false).ToList(); @@ -144,38 +144,38 @@ namespace IRaCIS.Core.Application.Image.QA - /// - /// CRC 质疑列表 - /// - /// - /// - [HttpPost] - public async Task<(PageOutput, TrialSubjectAndSVConfig)> GetCRCChallengeList(ChallengeQuery challengeQuery) + /// + /// CRC 质疑列表 + /// + /// + /// + [HttpPost] + public async Task>> GetCRCChallengeList(ChallengeQuery inQuery) { - var svExpression = QCCommon.GetQCChallengeFilter(challengeQuery.VisitPlanArray); + var svExpression = QCCommon.GetQCChallengeFilter(inQuery.VisitPlanArray); - var query2 = _repository.Where(x => x.TrialId == challengeQuery.TrialId) + var query = _repository.Where(x => x.TrialId == inQuery.TrialId) //.WhereIf(challengeQuery.ChallengeState != null, t => t.SubjectVisit.ChallengeState == challengeQuery.ChallengeState) - .WhereIf(challengeQuery.ReuploadEnum != null, t => t.ReuploadEnum == challengeQuery.ReuploadEnum) - .WhereIf(challengeQuery.IsClosed != null, t => t.IsClosed == challengeQuery.IsClosed) - .WhereIf(challengeQuery.TrialSiteId != null, t => t.SubjectVisit.TrialSiteId == challengeQuery.TrialSiteId) - .WhereIf(challengeQuery.SubjectId != null, t => t.SubjectVisit.SubjectId == challengeQuery.SubjectId) - .WhereIf(challengeQuery.CreateUserId != null, t => t.CreateUserId == challengeQuery.CreateUserId) - .WhereIf(challengeQuery.SubjectCode != null, t => t.SubjectVisit.Subject.Code.Contains(challengeQuery.SubjectCode!)) - .WhereIf(challengeQuery.VisitPlanArray != null && challengeQuery.VisitPlanArray?.Length > 0, svExpression) + .WhereIf(inQuery.ReuploadEnum != null, t => t.ReuploadEnum == inQuery.ReuploadEnum) + .WhereIf(inQuery.IsClosed != null, t => t.IsClosed == inQuery.IsClosed) + .WhereIf(inQuery.TrialSiteId != null, t => t.SubjectVisit.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.SubjectId != null, t => t.SubjectVisit.SubjectId == inQuery.SubjectId) + .WhereIf(inQuery.CreateUserId != null, t => t.CreateUserId == inQuery.CreateUserId) + .WhereIf(inQuery.SubjectCode != null, t => t.SubjectVisit.Subject.Code.Contains(inQuery.SubjectCode!)) + .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) //.WhereIf(!string.IsNullOrEmpty(challengeQuery.VisitPlanInfo), challengeQuery.VisitPlanInfo.Contains('.') ? t => t.SubjectVisit.VisitNum.ToString().Contains(".") : t => t.SubjectVisit.VisitNum == decimal.Parse(challengeQuery.VisitPlanInfo)) - .WhereIf(challengeQuery.IsOverTime != null && challengeQuery.IsOverTime == true, t => t.IsClosed ? t.ClosedTime > t.DeadlineTime : DateTime.Now > t.DeadlineTime) - .WhereIf(challengeQuery.IsOverTime != null && challengeQuery.IsOverTime == false, t => t.IsClosed ? t.ClosedTime < t.DeadlineTime : DateTime.Now < t.DeadlineTime) - .WhereIf(challengeQuery.IsUrgent != null, t => t.SubjectVisit.IsUrgent == challengeQuery.IsUrgent) + .WhereIf(inQuery.IsOverTime != null && inQuery.IsOverTime == true, t => t.IsClosed ? t.ClosedTime > t.DeadlineTime : DateTime.Now > t.DeadlineTime) + .WhereIf(inQuery.IsOverTime != null && inQuery.IsOverTime == false, t => t.IsClosed ? t.ClosedTime < t.DeadlineTime : DateTime.Now < t.DeadlineTime) + .WhereIf(inQuery.IsUrgent != null, t => t.SubjectVisit.IsUrgent == inQuery.IsUrgent) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.SubjectVisit.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) .ProjectTo(_mapper.ConfigurationProvider); - var pageList = await query2.ToPagedListAsync(challengeQuery.PageIndex, challengeQuery.PageSize, challengeQuery.SortField, challengeQuery.Asc, string.IsNullOrWhiteSpace(challengeQuery.SortField), new string[] { "IsUrgent desc", "CreateTime asc" }); + var pageList = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), new string[] { "IsUrgent desc", "CreateTime asc" }); - var config = await _repository.Where(t => t.Id == challengeQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); - return (pageList, config); + var config = await _repository.Where(t => t.Id == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); + return ResponseOutput.Ok (pageList, config); } @@ -237,39 +237,39 @@ namespace IRaCIS.Core.Application.Image.QA return result.Data.CurrentPageData.Count > 0 ? result.Data.CurrentPageData[0] : null; } - /// - /// QC 访视列表 - /// - /// - /// - [HttpPost] - public async Task>> GetQCVisitList(QCVisitSearchDTO visitSearchDTO) + /// + /// QC 访视列表 + /// + /// + /// + [HttpPost] + public async Task>> GetQCVisitList(QCVisitSearchDTO inQuery) { - var svExpression = QCCommon.GetSubjectVisitFilter(visitSearchDTO.VisitPlanArray); - var query = _subjectVisitRepository.Where(x => x.TrialId == visitSearchDTO.TrialId) - .WhereIf(visitSearchDTO.VisitId != null, t => t.Id == visitSearchDTO.VisitId) - .WhereIf(visitSearchDTO.CurrentActionUserId != null, t => t.CurrentActionUserId == visitSearchDTO.CurrentActionUserId) - .WhereIf(visitSearchDTO.ChallengeState != null, t => t.ChallengeState == visitSearchDTO.ChallengeState) - .WhereIf(visitSearchDTO.TrialSiteId != null, t => t.TrialSiteId == visitSearchDTO.TrialSiteId) - .WhereIf(visitSearchDTO.SubjectId != null, t => t.Subject.Id == visitSearchDTO.SubjectId) - .WhereIf(!string.IsNullOrEmpty(visitSearchDTO.SubjectInfo), t => /*t.Subject.FirstName.Contains(subjectInfo) || t.Subject.LastName.Contains(subjectInfo) ||*/ t.Subject.Code.Contains(visitSearchDTO.SubjectInfo)) - .WhereIf(visitSearchDTO.VisitPlanArray != null && visitSearchDTO.VisitPlanArray?.Length > 0, svExpression) + var svExpression = QCCommon.GetSubjectVisitFilter(inQuery.VisitPlanArray); + var query = _subjectVisitRepository.Where(x => x.TrialId == inQuery.TrialId) + .WhereIf(inQuery.VisitId != null, t => t.Id == inQuery.VisitId) + .WhereIf(inQuery.CurrentActionUserId != null, t => t.CurrentActionUserId == inQuery.CurrentActionUserId) + .WhereIf(inQuery.ChallengeState != null, t => t.ChallengeState == inQuery.ChallengeState) + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(inQuery.SubjectId != null, t => t.Subject.Id == inQuery.SubjectId) + .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectInfo), t => /*t.Subject.FirstName.Contains(subjectInfo) || t.Subject.LastName.Contains(subjectInfo) ||*/ t.Subject.Code.Contains(inQuery.SubjectInfo)) + .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) //.WhereIf(!string.IsNullOrEmpty(visitSearchDTO.VisitPlanInfo), visitSearchDTO.VisitPlanInfo.Contains('.') ? t => t.VisitNum.ToString().Contains(".") : t => t.VisitNum == decimal.Parse(visitSearchDTO.VisitPlanInfo)) //.WhereIf(visitSearchDTO.AuditState != null, t => t.AuditState == visitSearchDTO.AuditState) - .WhereIf(visitSearchDTO.AuditStateArray != null && visitSearchDTO.AuditStateArray?.Length > 0, t => visitSearchDTO.AuditStateArray!.Contains(t.AuditState)) + .WhereIf(inQuery.AuditStateArray != null && inQuery.AuditStateArray?.Length > 0, t => inQuery.AuditStateArray!.Contains(t.AuditState)) - .WhereIf(visitSearchDTO.HandleUserId != null, t => t.PreliminaryAuditUserId == visitSearchDTO.HandleUserId || t.CurrentActionUserId == visitSearchDTO.HandleUserId - || t.ReviewAuditUserId == visitSearchDTO.HandleUserId - || t.QCChallengeList.Any(t => t.CreateUserId == visitSearchDTO.HandleUserId) - || t.QCChallengeDialogList.Any(t => t.CreateUserId == visitSearchDTO.HandleUserId)) - .WhereIf(visitSearchDTO.IsUrgent != null, t => t.IsUrgent == visitSearchDTO.IsUrgent) + .WhereIf(inQuery.HandleUserId != null, t => t.PreliminaryAuditUserId == inQuery.HandleUserId || t.CurrentActionUserId == inQuery.HandleUserId + || t.ReviewAuditUserId == inQuery.HandleUserId + || t.QCChallengeList.Any(t => t.CreateUserId == inQuery.HandleUserId) + || t.QCChallengeDialogList.Any(t => t.CreateUserId == inQuery.HandleUserId)) + .WhereIf(inQuery.IsUrgent != null, t => t.IsUrgent == inQuery.IsUrgent) .Where(t => t.SubmitState != SubmitStateEnum.None) - .WhereIf(visitSearchDTO.BeginAuditTime != null, t => t.Trial.QCProcessEnum==TrialQCProcess.SingleAudit? t.PreliminaryAuditTime>= visitSearchDTO.BeginAuditTime: - (t.Trial.QCProcessEnum == TrialQCProcess.DoubleAudit?t.ReviewAuditTime>= visitSearchDTO.BeginAuditTime:true)) + .WhereIf(inQuery.BeginAuditTime != null, t => t.Trial.QCProcessEnum==TrialQCProcess.SingleAudit? t.PreliminaryAuditTime>= inQuery.BeginAuditTime: + (t.Trial.QCProcessEnum == TrialQCProcess.DoubleAudit?t.ReviewAuditTime>= inQuery.BeginAuditTime:true)) - .WhereIf(visitSearchDTO.EndAuditTime != null, t => t.Trial.QCProcessEnum == TrialQCProcess.SingleAudit ? t.PreliminaryAuditTime <= visitSearchDTO.EndAuditTime : - (t.Trial.QCProcessEnum == TrialQCProcess.DoubleAudit ? t.ReviewAuditTime <= visitSearchDTO.EndAuditTime : true)) + .WhereIf(inQuery.EndAuditTime != null, t => t.Trial.QCProcessEnum == TrialQCProcess.SingleAudit ? t.PreliminaryAuditTime <= inQuery.EndAuditTime : + (t.Trial.QCProcessEnum == TrialQCProcess.DoubleAudit ? t.ReviewAuditTime <= inQuery.EndAuditTime : true)) //.WhereIf(visitSearchDTO.SubmitState != null, t => t.SubmitState == visitSearchDTO.SubmitState) //.WhereIf(visitSearchDTO.ChallengeState != null, t => t.ChallengeState == visitSearchDTO.ChallengeState) @@ -277,12 +277,12 @@ namespace IRaCIS.Core.Application.Image.QA var defalutSortArray = new string[] { nameof(QCVisitViewModel.IsUrgent) + " desc", nameof(QCVisitViewModel.SubjectId), nameof(QCVisitViewModel.VisitNum) }; //var defalutSortArray = new string[] { nameof(SubjectVisit.IsUrgent) + " desc", nameof(QCVisitViewModel.AuditState) +" asc" }; - var pageList = await query.ToPagedListAsync(visitSearchDTO.PageIndex, visitSearchDTO.PageSize, visitSearchDTO.SortField, visitSearchDTO.Asc, string.IsNullOrWhiteSpace(visitSearchDTO.SortField), defalutSortArray); + var pageList = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc, string.IsNullOrWhiteSpace(inQuery.SortField), defalutSortArray); - var config = await _repository.Where(t => t.Id == visitSearchDTO.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); + var config = await _repository.Where(t => t.Id == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); return ResponseOutput.Ok (pageList, config); @@ -295,26 +295,26 @@ namespace IRaCIS.Core.Application.Image.QA /// /// 获取一致性核查列表 CRC/PM 公用 /// - /// + /// /// [HttpPost] - public async Task<(PageOutput, TrialSubjectAndSVConfig)> GetConsistencyVerificationList(CheckQuery checkQuery) + public async Task<(PageOutput, TrialSubjectAndSVConfig)> GetConsistencyVerificationList(CheckQuery inQuery) { - var svExpression = QCCommon.GetSubjectVisitFilter(checkQuery.VisitPlanArray); + var svExpression = QCCommon.GetSubjectVisitFilter(inQuery.VisitPlanArray); - var query = _subjectVisitRepository.Where(x => x.TrialId == checkQuery.TrialId) + var query = _subjectVisitRepository.Where(x => x.TrialId == inQuery.TrialId) .Where(x => x.AuditState == AuditStateEnum.QCPassed) //一致性核查中的,或者还没一致性核查的 - .WhereIf(checkQuery.CheckState != null, t => t.CheckState == checkQuery.CheckState) - .WhereIf(checkQuery.TrialSiteId != null, t => t.TrialSiteId == checkQuery.TrialSiteId) - .WhereIf(!string.IsNullOrEmpty(checkQuery.SubjectInfo), t => t.Subject.Code.Contains(checkQuery.SubjectInfo)) - .WhereIf(checkQuery.VisitPlanArray != null && checkQuery.VisitPlanArray?.Length > 0, svExpression) + .WhereIf(inQuery.CheckState != null, t => t.CheckState == inQuery.CheckState) + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId) + .WhereIf(!string.IsNullOrEmpty(inQuery.SubjectInfo), t => t.Subject.Code.Contains(inQuery.SubjectInfo)) + .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) //.WhereIf(!string.IsNullOrEmpty(checkQuery.VisitPlanInfo), checkQuery.VisitPlanInfo.Contains('.') ? t => t.InPlan == false : t => t.VisitNum == decimal.Parse(checkQuery.VisitPlanInfo)) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id))//CRC 过滤负责的site .ProjectTo(_mapper.ConfigurationProvider); - var pageList = await query.ToPagedListAsync(checkQuery.PageIndex, checkQuery.PageSize, checkQuery.SortField, checkQuery.Asc); - var config = await _repository.Where(t => t.Id == checkQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); + var pageList = await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField, inQuery.Asc); + var config = await _repository.Where(t => t.Id == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); return (pageList, config); } diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index b5c088c66..2486bfae3 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -28,7 +28,18 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.IsHaveClinicalData, u => u.MapFrom(t => t.IsBaseLine ? t.PreviousHistoryList.Any() || t.PreviousOtherList.Any() || t.ReadingClinicalDataList.Any(x => x.ClinicalDataTrialSet.UploadRole == Domain.Share.UploadRole.CRC && x.ReadingClinicalDataPDFList.Count > 0) - || t.PreviousSurgeryList.Any() : false)); + || t.PreviousSurgeryList.Any() : false)) + + .ForMember(d => d.DicomStudyCount, u => u.MapFrom(t => t.StudyList.Count())) + .ForMember(d => d.NoneDicomStudyCount, u => u.MapFrom(t => t.NoneDicomStudyList.Count(t => t.NoneDicomFileList.Any()))); + + CreateMap().IncludeBase() + .ForMember(d => d.SubmitUserRealName, u => u.MapFrom(s => s.SubmitUser.FullName)) + + .ForMember(d => d.CurrentActionUserName, u => u.MapFrom(s => s.CurrentActionUser.UserName)) + .ForMember(d => d.PreliminaryAuditUserName, u => u.MapFrom(s => s.PreliminaryAuditUser.UserName)) + .ForMember(d => d.ReviewAuditUserName, u => u.MapFrom(s => s.ReviewAuditUser.UserName)); + @@ -41,7 +52,7 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.CreateUserName, u => u.MapFrom(s => s.CreateUser.UserName)) .ForMember(d => d.LatestReplyUserName, u => u.MapFrom(t => t.LatestReplyUser.UserName)) - .ForMember(d => d.DialogStr, u => u.MapFrom(t => string.Join(" | ", t.DialogList.OrderBy(t => t.CreateTime).Select(c => c.CreateUser.UserName + " " + c.CreateTime.ToString("yyyy-mm-dd hh:mm:ss") + " :" + c.TalkContent)))) + .ForMember(d => d.DialogStr, u => u.MapFrom(t => string.Join(" | ", t.DialogList.OrderBy(t => t.CreateTime).Select(c => c.CreateUser.UserName + " " + c.CreateTime.ToString("yyyy-MM-dd hh:mm:ss") + " :" + c.TalkContent)))) .ForMember(d => d.SubjectState, u => u.MapFrom(s => s.SubjectVisit.Subject.Status)); @@ -141,13 +152,16 @@ namespace IRaCIS.Core.Application.Service .ForMember(o => o.TrialReadingCriterionName, t => t.MapFrom(u => u.VisitTask.TrialReadingCriterion.CriterionName)) .ForMember(o => o.MedicalNo, t => t.MapFrom(u => u.VisitTask.Subject.MedicalNo)) - //.ForMember(o => o.DoctorUserName, t => t.MapFrom(u => u.VisitTask.DoctorUser.UserName)) - .ForMember(o => o.MedicalManagerUserName, t => t.MapFrom(u => u.MedicalManagerUser.UserName)); + .ForMember(o => o.DoctorUserName, t => t.MapFrom(u => u.VisitTask.DoctorUser.UserName)) + .ForMember(o => o.MedicalManagerUserName, t => t.MapFrom(u => u.MedicalManagerUser.UserName)) + .ForMember(o => o.QuestionContent, t => t.MapFrom(u=> string.Join('|', u.ReadingMedicalReviewDialogList.Where(t => t.IsHaveQuestion).Select(t=>t.Questioning))) ); CreateMap() .ForMember(o => o.TrialReadingCriterionName, t => t.MapFrom(u => u.TrialReadingCriterion.CriterionName)) .ForMember(o => o.TrialSiteCode, t => t.MapFrom(u => u.IsSelfAnalysis == true ? u.BlindTrialSiteCode : u.Subject.TrialSite.TrialSiteCode)) - .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.IsSelfAnalysis == true ? u.BlindSubjectCode : u.Subject.Code)); + .ForMember(o => o.SubjectCode, t => t.MapFrom(u => u.IsSelfAnalysis == true ? u.BlindSubjectCode : u.Subject.Code)) + + ; CreateMap() diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs index 0f56423cb..d9e1ace36 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectService.cs @@ -108,27 +108,27 @@ namespace IRaCIS.Application.Services } /// 分页获取受试者列表[New] - /// /// state:1-访视中,2-出组。0-全部 + /// /// state:1-访视中,2-出组。0-全部 [HttpPost] - public async Task>> GetSubjectList(SubjectQueryParam param) + public async Task>> GetSubjectList(SubjectQueryParam inQuery) { - var subjectQuery = _subjectRepository.Where(u => u.TrialId == param.TrialId) - .WhereIf(!string.IsNullOrWhiteSpace(param.Code), t => t.Code.Contains(param.Code)) - .WhereIf(!string.IsNullOrWhiteSpace(param.Name), t => t.ShortName.Contains(param.Name)) - .WhereIf(!string.IsNullOrWhiteSpace(param.Sex), t => t.Sex.Contains(param.Sex)) - .WhereIf(param.Status != null, t => t.Status == param.Status) + var subjectQuery = _subjectRepository.Where(u => u.TrialId == inQuery.TrialId) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Code), t => t.Code.Contains(inQuery.Code)) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Name), t => t.ShortName.Contains(inQuery.Name)) + .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Sex), t => t.Sex.Contains(inQuery.Sex)) + .WhereIf(inQuery.Status != null, t => t.Status == inQuery.Status) - .WhereIf(param.TrialSiteId != null, t => t.TrialSiteId == param.TrialSiteId) + .WhereIf(inQuery.TrialSiteId != null, t => t.TrialSiteId == inQuery.TrialSiteId) // CRC 只负责他管理site的受试者 .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) .ProjectTo(_mapper.ConfigurationProvider) - .WhereIf(param.IsMissingImages != null, t => t.IsMissingImages == param.IsMissingImages); + .WhereIf(inQuery.IsMissingImages != null, t => t.IsMissingImages == inQuery.IsMissingImages); - var pageList = await subjectQuery.ToPagedListAsync(param.PageIndex, param.PageSize, param.SortField == string.Empty ? "Code" : param.SortField, param.Asc); + var pageList = await subjectQuery.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, inQuery.SortField == string.Empty ? "Code" : inQuery.SortField, inQuery.Asc); - var trialConfig = await _repository.Where(t => t.Id == param.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); + var trialConfig = await _repository.Where(t => t.Id == inQuery.TrialId).ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync().IfNullThrowException(); return ResponseOutput.Ok(pageList, trialConfig); diff --git a/IRaCIS.Core.Domain/_Config/_StaticData.cs b/IRaCIS.Core.Domain/_Config/_StaticData.cs index ddcc620c9..fd2c73df6 100644 --- a/IRaCIS.Core.Domain/_Config/_StaticData.cs +++ b/IRaCIS.Core.Domain/_Config/_StaticData.cs @@ -208,6 +208,8 @@ public static class StaticData /// public static class Export { + public const string TrialTrainingRecordList_Export = "TrialTrainingRecordList_Export"; + public const string TrialSiteUserList_Export = "TrialSiteUserList_Export"; public const string TrialSiteUserSummary_Export = "TrialSiteUserSummary_Export"; @@ -216,6 +218,8 @@ public static class StaticData public const string TrialCRCUploadImageList_Export = "TrialCRCUploadImageList_Export"; + public const string TrialQCVisitImageList_Export = "TrialQCVisitImageList_Export"; + public const string TrialQCImageChanllengeList_Export = "TrialQCImageChanllengeList_Export"; public const string TrialSubjectList_Export = "TrialSubjectList_Export";