修改项目参与人员判断

Uat_IRC_Net8
hang 2024-12-30 14:08:08 +08:00
parent 260be98cef
commit 14c62a8852
9 changed files with 80 additions and 77 deletions

View File

@ -52,7 +52,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
Expression<Func<VisitTask, bool>> comonTaskFilter = t => t.TrialId == trialId && t.TaskState == TaskState.Effect && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskAllocationState == TaskAllocationState.Allocated; Expression<Func<VisitTask, bool>> comonTaskFilter = t => t.TrialId == trialId && t.TaskState == TaskState.Effect && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskAllocationState == TaskAllocationState.Allocated;
var trialUserList = _trialUserRoleRepository.Where(t => t.TrialId == trialId).Select(t => new var trialUserList = _trialUserRoleRepository.Where(t => t.TrialId == trialId && t.TrialUser.JoinTime != null).Select(t => new
{ {
t.UserId, t.UserId,
t.UserRole.FullName, t.UserRole.FullName,
@ -69,7 +69,7 @@ namespace IRaCIS.Core.Application.MassTransit.Recurring
var userId = trialUser.UserId; var userId = trialUser.UserId;
var doctorCriterionList = await _trialReadingCriterionRepository.Where(t => t.IsSigned && t.IsConfirm && t.TrialId == trialId && t.Trial.TrialUserList.Any(t => t.UserId == userId)) var doctorCriterionList = await _trialReadingCriterionRepository.Where(t => t.IsSigned && t.IsConfirm && t.TrialId == trialId && t.Trial.TrialUserRoleList.Any(t => t.UserId == userId))
.Select(c => new .Select(c => new
{ {

View File

@ -1512,7 +1512,7 @@ public class VisitTaskService(IRepository<VisitTask> _visitTaskRepository,
var isSPMJoinReReadingApproval = _trialRepository.Any(t => t.Id == trialId && t.IsSPMJoinReReadingApproval); var isSPMJoinReReadingApproval = _trialRepository.Any(t => t.Id == trialId && t.IsSPMJoinReReadingApproval);
var hasSPMOrCPM = await _trialRepository.Where(t => t.Id == trialId).SelectMany(t => t.TrialUserList).AnyAsync(t => t.UserRole.UserTypeEnum == UserTypeEnum.SPM || t.UserRole.UserTypeEnum == UserTypeEnum.CPM); var hasSPMOrCPM = await _trialRepository.Where(t => t.Id == trialId).SelectMany(t => t.TrialIdentityUserList).AnyAsync(t => t.TrialUserRoleList.Any(t => t.UserRole.UserTypeEnum == UserTypeEnum.SPM || t.UserRole.UserTypeEnum == UserTypeEnum.CPM));
var isSPMjoin = isSPMJoinReReadingApproval && hasSPMOrCPM; var isSPMjoin = isSPMJoinReReadingApproval && hasSPMOrCPM;

View File

@ -223,9 +223,9 @@ namespace IRaCIS.Core.Application.Service.Common
.WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code))
.WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo)) .WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName))
.WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.IsDeleted == false) && t.IsDeleted == false)
.WhereIf(inQuery.CriterionType != null, o => o.TrialReadingCriterionList.Any(t => t.CriterionType == inQuery.CriterionType && t.IsSigned && t.IsConfirm)) .WhereIf(inQuery.CriterionType != null, o => o.TrialReadingCriterionList.Any(t => t.CriterionType == inQuery.CriterionType && t.IsSigned && t.IsConfirm))
.WhereIf(!string.IsNullOrEmpty(inQuery.PM_EMail), o => o.TrialUserList.Any(t => t.UserRole.IdentityUser.EMail.Contains(inQuery.PM_EMail) && (t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM))) .WhereIf(!string.IsNullOrEmpty(inQuery.PM_EMail), o => o.TrialUserRoleList.Any(t => t.UserRole.IdentityUser.EMail.Contains(inQuery.PM_EMail) && (t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM)))
.Select(t => new TrialToBeDoneDto() .Select(t => new TrialToBeDoneDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -286,7 +286,7 @@ namespace IRaCIS.Core.Application.Service.Common
IR_ReadingCriterionList = isIR ? t.TrialReadingCriterionList.Where(t => t.IsConfirm && t.IsSigned).OrderBy(t => t.CriterionName).Select(t => t.CriterionName).ToList() : null, IR_ReadingCriterionList = isIR ? t.TrialReadingCriterionList.Where(t => t.IsConfirm && t.IsSigned).OrderBy(t => t.CriterionName).Select(t => t.CriterionName).ToList() : null,
IR_PMEmailList = isIR ? t.TrialUserList.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM).OrderBy(t => t.UserRole.IdentityUser.EMail).Select(t => t.UserRole.IdentityUser.EMail).ToList() : null, IR_PMEmailList = isIR ? t.TrialUserRoleList.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM).OrderBy(t => t.UserRole.IdentityUser.EMail).Select(t => t.UserRole.IdentityUser.EMail).ToList() : null,
IR_TotalReadCount = isIR ? t.VisitTaskList.Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned).Count() : 0, IR_TotalReadCount = isIR ? t.VisitTaskList.Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned).Count() : 0,

View File

@ -321,7 +321,7 @@ namespace IRaCIS.Core.Application.Services
var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == inQuery.TrialId && t.Trial.TrialStatusStr != StaticData.TrialState.TrialStopped) var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true).Where(t => t.TrialId == inQuery.TrialId && t.Trial.TrialStatusStr != StaticData.TrialState.TrialStopped)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.UserRoleId && t.ConfirmTime != null) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.UserRoleId && t.ConfirmTime != null) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId))
.CountAsync(); .CountAsync();
@ -470,7 +470,7 @@ namespace IRaCIS.Core.Application.Services
var result = await unionQuery.ToPagedListAsync(inQuery); var result = await unionQuery.ToPagedListAsync(inQuery);
var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true) var needSignTrialDocCount = await _trialDocumentRepository.AsQueryable(true)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.UserRoleId) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .Where(t => t.IsDeleted == false && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.UserRoleId) && t.NeedConfirmedUserTypeList.Any(u => u.NeedConfirmUserTypeId == _userInfo.UserTypeId))
.CountAsync(); .CountAsync();
@ -837,7 +837,7 @@ namespace IRaCIS.Core.Application.Services
SignViewMinimumMinutes = t.SignViewMinimumMinutes, SignViewMinimumMinutes = t.SignViewMinimumMinutes,
DocumentConfirmedUserCount = t.TrialDocConfirmedUserList.Count(), DocumentConfirmedUserCount = t.TrialDocConfirmedUserList.Count(),
DocumentUserCount = t.Trial.TrialUserList.Count(cc => t.NeedConfirmedUserTypeList.Any(k => k.NeedConfirmUserTypeId == cc.UserRole.UserTypeId)) DocumentUserCount = t.Trial.TrialUserRoleList.Count(cc => t.NeedConfirmedUserTypeList.Any(k => k.NeedConfirmUserTypeId == cc.UserRole.UserTypeId))
}); });

View File

@ -438,7 +438,8 @@ namespace IRaCIS.Core.Application.Contracts
else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM) else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM)
{ {
var isTrialSPMJoin = await _trialRepository.AnyAsync(t => t.Id == trialSiteSubmitBackCommand.TrialId && t.IsSPMJoinSiteSurvey); var isTrialSPMJoin = await _trialRepository.AnyAsync(t => t.Id == trialSiteSubmitBackCommand.TrialId && t.IsSPMJoinSiteSurvey);
var hasSPMOrCPM = await _trialSiteSurveyRepository.AnyAsync(t => t.TrialId == trialSiteSubmitBackCommand.TrialId && t.Trial.TrialUserList.Any(u => u.UserRole.UserTypeEnum == UserTypeEnum.SPM || u.UserRole.UserTypeEnum == UserTypeEnum.CPM));
var hasSPMOrCPM = await _trialSiteSurveyRepository.AnyAsync(t => t.TrialId == trialSiteSubmitBackCommand.TrialId && t.Trial.TrialIdentityUserList.Any(u => u.TrialUserRoleList.Any(u => u.UserRole.UserTypeEnum == UserTypeEnum.SPM || u.UserRole.UserTypeEnum == UserTypeEnum.CPM)));
var isSPMjoin = isTrialSPMJoin && hasSPMOrCPM; var isSPMjoin = isTrialSPMJoin && hasSPMOrCPM;
@ -789,7 +790,7 @@ namespace IRaCIS.Core.Application.Contracts
if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator) if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.Undefined || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator)
{ {
var hasSPMOrCPM = await _trialSiteSurveyRepository.AnyAsync(t => t.TrialId == trialId && t.Trial.TrialUserList.Any(u => u.UserRole.UserTypeEnum == UserTypeEnum.SPM || u.UserRole.UserTypeEnum == UserTypeEnum.CPM)); var hasSPMOrCPM = await _trialSiteSurveyRepository.AnyAsync(t => t.TrialId == trialId && t.Trial.TrialIdentityUserList.Any(u => u.TrialUserRoleList.Any(u => u.UserRole.UserTypeEnum == UserTypeEnum.SPM || u.UserRole.UserTypeEnum == UserTypeEnum.CPM)));
var isTrialSPMJoin = await _trialRepository.AnyAsync(t => t.Id == trialId && t.IsSPMJoinSiteSurvey); var isTrialSPMJoin = await _trialRepository.AnyAsync(t => t.Id == trialId && t.IsSPMJoinSiteSurvey);

View File

@ -41,7 +41,7 @@ namespace IRaCIS.Core.Application.Service.Third_partyProject
.WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code))
.WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo)) .WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName))
.WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.IsDeleted == false) && t.IsDeleted == false)
.Select(t => new TrialListDTO_UltrasonicDicom() .Select(t => new TrialListDTO_UltrasonicDicom()
{ {
TrialId = t.Id, TrialId = t.Id,

View File

@ -39,7 +39,7 @@ namespace IRaCIS.Core.Application
{ {
return await _trialRepository return await _trialRepository
.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) .Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.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.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) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM, c => c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.CRCSubmitted).Count() > 0)
.ProjectTo<TrialSiteSurveyStat>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId }) .ProjectTo<TrialSiteSurveyStat>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId })
@ -70,7 +70,7 @@ namespace IRaCIS.Core.Application
else else
{ {
var trialDocStat = await _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var trialDocStat = await _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.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)) .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) .Count() > 0)
.ProjectTo<DocSignStat>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId, userTypeId = _userInfo.UserTypeId }) .ProjectTo<DocSignStat>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId, userTypeId = _userInfo.UserTypeId })
@ -101,7 +101,7 @@ namespace IRaCIS.Core.Application
var query = _trialRepository var query = _trialRepository
.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) .Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Select(t => new CheckToBeDoneDto() .Select(t => new CheckToBeDoneDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -122,11 +122,11 @@ namespace IRaCIS.Core.Application
var result = await query.ToPagedListAsync(inQuery, defalutSortArray); var result = await query.ToPagedListAsync(inQuery, defalutSortArray);
var totalToBeCheckedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var totalToBeCheckedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(u => u.CheckState == CheckStateEnum.ToCheck).CountAsync(); .Where(u => u.CheckState == CheckStateEnum.ToCheck).CountAsync();
var totalToBeRepliedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var totalToBeRepliedCount = await _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(u => u.CheckState == CheckStateEnum.CVIng && .Where(u => u.CheckState == CheckStateEnum.CVIng &&
u.CheckChallengeDialogList.OrderByDescending(t => t.CreateTime).First().UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).CountAsync(); u.CheckChallengeDialogList.OrderByDescending(t => t.CreateTime).First().UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).CountAsync();
@ -148,7 +148,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed) .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 }) .GroupBy(t => new { t.OriginalReReadingTask.Trial.ExperimentName, t.OriginalReReadingTask.Trial.ResearchProgramNo, t.OriginalReReadingTask.Trial.TrialCode, t.OriginalReReadingTask.TrialId })
.Select(g => new ReReadingApplyToBeDoneDto() .Select(g => new ReReadingApplyToBeDoneDto()
@ -169,7 +169,7 @@ namespace IRaCIS.Core.Application
var toBeApprovalCount = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeApprovalCount = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed).Count(); .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed).Count();
return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount });
@ -190,7 +190,7 @@ namespace IRaCIS.Core.Application
[FromServices] IRepository<Trial> _trialRepository) [FromServices] IRepository<Trial> _trialRepository)
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Select(t => new ReviewerSelectToBeDoneDto() .Select(t => new ReviewerSelectToBeDoneDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -208,7 +208,7 @@ namespace IRaCIS.Core.Application
var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync(); .Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync();
return ResponseOutput.Ok(result, new { ToBeApprovalCount = toBeApprovalCount }); ; return ResponseOutput.Ok(result, new { ToBeApprovalCount = toBeApprovalCount }); ;
@ -226,7 +226,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Select(t => new GetPMClinicalDataToBeDoneListOutDto() .Select(t => new GetPMClinicalDataToBeDoneListOutDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -246,7 +246,7 @@ namespace IRaCIS.Core.Application
var all = await _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var all = await _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Select(t => new GetPMClinicalDataToBeDoneListOutDto() .Select(t => new GetPMClinicalDataToBeDoneListOutDto()
{ {
@ -275,7 +275,7 @@ namespace IRaCIS.Core.Application
[FromServices] IRepository<Trial> _trialRepository) [FromServices] IRepository<Trial> _trialRepository)
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Select(t => new ReviewerSelectToBeDoneDto() .Select(t => new ReviewerSelectToBeDoneDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -294,7 +294,7 @@ namespace IRaCIS.Core.Application
var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeApprovalCount = await _enrollRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync(); .Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).CountAsync();
return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); ; return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); ;
@ -315,7 +315,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed) .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 }) .GroupBy(t => new { t.OriginalReReadingTask.Trial.ExperimentName, t.OriginalReReadingTask.Trial.ResearchProgramNo, t.OriginalReReadingTask.Trial.TrialCode, t.OriginalReReadingTask.TrialId })
.Select(g => new ReReadingApprovalToBeDoneDto() .Select(g => new ReReadingApprovalToBeDoneDto()
@ -336,7 +336,7 @@ namespace IRaCIS.Core.Application
var toBeApprovalCount = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeApprovalCount = _visitTaskReReadingRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed).Count(); .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed).Count();
return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount }); return ResponseOutput.Ok(result, new { TotalToBeApprovalCount = toBeApprovalCount });
@ -363,7 +363,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
//.Where(t => t.clinicalDataTrialSets.Any(t => t.ClinicalDataLevel == ClinicalLevel.Subject && t.IsConfirm)) //.Where(t => t.clinicalDataTrialSets.Any(t => t.ClinicalDataLevel == ClinicalLevel.Subject && t.IsConfirm))
.Select(t => new ImageClinicalDataToBeDoneDto() .Select(t => new ImageClinicalDataToBeDoneDto()
{ {
@ -405,7 +405,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
//.Where(t => t.clinicalDataTrialSets.Any(t => t.ClinicalDataLevel == ClinicalLevel.Subject && t.IsConfirm)) //.Where(t => t.clinicalDataTrialSets.Any(t => t.ClinicalDataLevel == ClinicalLevel.Subject && t.IsConfirm))
.Select(t => new ImageClinicalDataToBeDoneDto() .Select(t => new ImageClinicalDataToBeDoneDto()
{ {
@ -466,7 +466,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Select(t => new ImageQuestionToBeDoneDto() .Select(t => new ImageQuestionToBeDoneDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -491,7 +491,7 @@ namespace IRaCIS.Core.Application
var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId))
.SelectMany(c => c.QCChallengeList) .SelectMany(c => c.QCChallengeList)
.Where(u => u.IsClosed == false && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IQC).Count(); .Where(u => u.IsClosed == false && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IQC).Count();
@ -514,7 +514,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Select(t => new ImageCheckQuestionToBeDoneDto() .Select(t => new ImageCheckQuestionToBeDoneDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -537,7 +537,7 @@ namespace IRaCIS.Core.Application
var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId))
.Where(u => u.CheckState == CheckStateEnum.CVIng && u.CheckChallengeState == CheckChanllengeTypeEnum.PMWaitCRCReply).Count(); .Where(u => u.CheckState == CheckStateEnum.CVIng && u.CheckChallengeState == CheckChanllengeTypeEnum.PMWaitCRCReply).Count();
@ -560,7 +560,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Select(t => new ImageReUploadToBeDoneDto() .Select(t => new ImageReUploadToBeDoneDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -583,7 +583,7 @@ namespace IRaCIS.Core.Application
var result = await query.ToPagedListAsync(inQuery, defalutSortArray); var result = await query.ToPagedListAsync(inQuery, defalutSortArray);
var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(u => (u.SubmitState == SubmitStateEnum.ToSubmit && u.IsPMBackOrReReading) || (u.IsQCConfirmedReupload)).Count(); .Where(u => (u.SubmitState == SubmitStateEnum.ToSubmit && u.IsPMBackOrReReading) || (u.IsQCConfirmedReupload)).Count();
return ResponseOutput.Ok(result, new { TotalToBeReUploadCount = toBeDealedCount }); return ResponseOutput.Ok(result, new { TotalToBeReUploadCount = toBeDealedCount });
@ -607,7 +607,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId) && (t.IsUrgent || t.IsSubjectExpeditedView || t.IsEnrollementQualificationConfirm || t.IsPDProgressView)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId) && (t.IsUrgent || t.IsSubjectExpeditedView || t.IsEnrollementQualificationConfirm || t.IsPDProgressView))
.Select(t => new ImageSubmittedToBeDoneDto() .Select(t => new ImageSubmittedToBeDoneDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -633,7 +633,7 @@ namespace IRaCIS.Core.Application
var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId))
.Where(u => u.SubmitState == SubmitStateEnum.ToSubmit).Count(); .Where(u => u.SubmitState == SubmitStateEnum.ToSubmit).Count();
@ -663,7 +663,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.QCProcessEnum != TrialQCProcess.NotAudit) .Where(t => t.QCProcessEnum != TrialQCProcess.NotAudit)
.Select(t => new ImageQualityToBeDoneDto() .Select(t => new ImageQualityToBeDoneDto()
{ {
@ -693,12 +693,12 @@ namespace IRaCIS.Core.Application
var toBeClaimedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeClaimedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId) && t.SubmitState == SubmitStateEnum.Submitted && t.AuditState != AuditStateEnum.QCPassed && t.AuditState != AuditStateEnum.QCFailed) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId) && 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(); .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) var toBeReviwedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(u => u.CurrentActionUserId == _userInfo.UserRoleId).Count(); .Where(u => u.CurrentActionUserId == _userInfo.UserRoleId).Count();
@ -721,7 +721,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Select(t => new ImageQuestionToBeDoneDto() .Select(t => new ImageQuestionToBeDoneDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -742,7 +742,7 @@ namespace IRaCIS.Core.Application
var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeDealedCount = _subjectVisitRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.SelectMany(c => c.QCChallengeList) .SelectMany(c => c.QCChallengeList)
.Where(u => u.CreateUserId == _userInfo.UserRoleId && u.IsClosed == false && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).Count(); .Where(u => u.CreateUserId == _userInfo.UserRoleId && u.IsClosed == false && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).Count();
@ -775,7 +775,7 @@ namespace IRaCIS.Core.Application
{ {
var newQuery = _trialReadingCriterionRepository.Where(t => t.IsSigned && t.IsConfirm && t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) var newQuery = _trialReadingCriterionRepository.Where(t => t.IsSigned && t.IsConfirm && t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Select(c => new IRImageReadingToBeDoneDto() .Select(c => new IRImageReadingToBeDoneDto()
{ {
TrialId = c.TrialId, TrialId = c.TrialId,
@ -885,7 +885,7 @@ namespace IRaCIS.Core.Application
var result = await newQuery.ToPagedListAsync(inQuery, defalutSortArray); var result = await newQuery.ToPagedListAsync(inQuery, defalutSortArray);
var toBeDealedCount = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeDealedCount = _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.SelectMany(t => t.VisitTaskList) .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) .Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect && t.TrialReadingCriterion.IsSigned == true && t.TrialReadingCriterion.IsConfirm == true)
// 前序 不存在 未一致性核查未通过的 // 前序 不存在 未一致性核查未通过的
@ -913,7 +913,7 @@ namespace IRaCIS.Core.Application
{ {
var query = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.VisitTask.DoctorUserId == _userInfo.UserRoleId) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.VisitTask.DoctorUserId == _userInfo.UserRoleId)
.GroupBy(t => new .GroupBy(t => new
{ {
@ -957,7 +957,7 @@ namespace IRaCIS.Core.Application
var toBeDealedCount = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeDealedCount = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.IsClosedDialog == false && t.VisitTask.DoctorUserId == _userInfo.UserRoleId) .Where(t => t.IsClosedDialog == false && t.VisitTask.DoctorUserId == _userInfo.UserRoleId)
.Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.MIM) .Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.MIM)
//.Where(u => u.ReadingMedicalReviewDialogList.OrderByDescending(l => l.CreateTime).First().UserTypeEnumInt == (int)UserTypeEnum.MIM) //.Where(u => u.ReadingMedicalReviewDialogList.OrderByDescending(l => l.CreateTime).First().UserTypeEnumInt == (int)UserTypeEnum.MIM)
@ -990,7 +990,7 @@ namespace IRaCIS.Core.Application
#region 废弃不能对包含聚合或子查询的表达式执行聚合函数 #region 废弃不能对包含聚合或子查询的表达式执行聚合函数
var query = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var query = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId)
.GroupBy(t => new .GroupBy(t => new
{ {
@ -1028,7 +1028,7 @@ namespace IRaCIS.Core.Application
var toBeReplyedQuery = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var toBeReplyedQuery = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .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); .Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IndependentReviewer && u.AuditState == MedicalReviewAuditState.Auditing);
@ -1036,7 +1036,7 @@ namespace IRaCIS.Core.Application
var toBeReplyedCount = toBeReplyedQuery.Count(); var toBeReplyedCount = toBeReplyedQuery.Count();
var tobeReviewedCount = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing) var tobeReviewedCount = _taskMedicalReviewRepository.Where(t => t.Trial.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .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(); .Where(u => u.AuditState != MedicalReviewAuditState.HaveSigned && u.LatestReplyUser.UserTypeEnum != UserTypeEnum.IndependentReviewer).Count();
@ -1089,7 +1089,7 @@ namespace IRaCIS.Core.Application
if (!_userInfo.IsAdmin) if (!_userInfo.IsAdmin)
{ {
var list = await _trialRepository.Where(t => t.TrialStatusStr != StaticData.TrialState.TrialStopped) var list = await _trialRepository.Where(t => t.TrialStatusStr != StaticData.TrialState.TrialStopped)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.WhereIf(!_userInfo.IsAdmin, c => c.TrialDocumentList.Where(t => t.IsDeleted == false && t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _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) !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.UserRoleId && t.ConfirmTime != null)).Count() > 0)
.Select(t => t.Id).ToListAsync(); .Select(t => t.Id).ToListAsync();
@ -1115,7 +1115,7 @@ namespace IRaCIS.Core.Application
var isInternal = _userInfo.IsZhiZhun; var isInternal = _userInfo.IsZhiZhun;
var needSignTrialCount = await _trialRepository.Where(t => t.TrialStatusStr != StaticData.TrialState.TrialStopped) var needSignTrialCount = await _trialRepository.Where(t => t.TrialStatusStr != StaticData.TrialState.TrialStopped)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(c => c.TrialDocumentList.Where(t => t.IsDeleted == false && t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _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.UserRoleId && t.ConfirmTime != null)).Count() > 0).CountAsync(); && !t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.UserRoleId && t.ConfirmTime != null)).Count() > 0).CountAsync();
@ -1127,7 +1127,7 @@ namespace IRaCIS.Core.Application
.CountAsync(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId); .CountAsync(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId);
var signedTrialCount = await _trialDocumentRepository.AsQueryable(true) var signedTrialCount = await _trialDocumentRepository.AsQueryable(true)
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId)) .Where(t => t.NeedConfirmedUserTypeList.Any(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId))
.Where(t => t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.UserRoleId && t.ConfirmTime != null)).CountAsync(); .Where(t => t.TrialDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.UserRoleId && t.ConfirmTime != null)).CountAsync();
@ -1138,7 +1138,7 @@ namespace IRaCIS.Core.Application
var siteSurveyCount = await _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing) var siteSurveyCount = await _trialRepository.Where(t => t.TrialStatusStr == StaticData.TrialState.TrialOngoing)
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.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.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) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM, c => c.TrialSiteSurveyList.Where(t => t.State == TrialSiteSurveyEnum.CRCSubmitted).Count() > 0)
.CountAsync(); .CountAsync();
@ -1187,16 +1187,16 @@ namespace IRaCIS.Core.Application
PM_SiteSurveryCount = isPM ? siteSurveyCount : 0, PM_SiteSurveryCount = isPM ? siteSurveyCount : 0,
PM_CheckCount = isPM ? await _trialRepository PM_CheckCount = isPM ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(u => u.SubjectVisitList.Any(t => t.CheckState == CheckStateEnum.ToCheck || (t.CheckState == CheckStateEnum.CVIng && .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, t.CheckChallengeDialogList.OrderByDescending(t => t.CreateTime).First().UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator))).CountAsync() : 0,
PM_ReviewerSelectCount = isPM ? await _trialRepository PM_ReviewerSelectCount = isPM ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.InviteIntoGroup).Count() > 0).CountAsync() : 0, .Where(t => t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.InviteIntoGroup).Count() > 0).CountAsync() : 0,
PM_ReReadingApprovalCount = isPM ? await _visitTaskReReadingRepository PM_ReReadingApprovalCount = isPM ? await _visitTaskReReadingRepository
.Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.DocotorHaveApplyed)
.GroupBy(t => t.OriginalReReadingTask.TrialId) .GroupBy(t => t.OriginalReReadingTask.TrialId)
.Select(g => new ReReadingApplyToBeDoneDto() .Select(g => new ReReadingApplyToBeDoneDto()
@ -1207,7 +1207,7 @@ namespace IRaCIS.Core.Application
}).Where(x => x.ToBeApprovalCount > 0).CountAsync() : 0, }).Where(x => x.ToBeApprovalCount > 0).CountAsync() : 0,
PM_ClinicalDataCount = isPM ? await _trialRepository PM_ClinicalDataCount = isPM ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.ReadModuleList.Where(u => u.IsCRCConfirm && !u.IsPMConfirm).Count() > 0).CountAsync() : 0, .Where(t => t.ReadModuleList.Where(u => u.IsCRCConfirm && !u.IsPMConfirm).Count() > 0).CountAsync() : 0,
#endregion #endregion
@ -1215,34 +1215,34 @@ namespace IRaCIS.Core.Application
#region CRC #region CRC
CRC_ImageSubmitCount = isCRC ? await _trialRepository CRC_ImageSubmitCount = isCRC ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId) && (t.IsUrgent || t.IsSubjectExpeditedView || t.IsEnrollementQualificationConfirm || t.IsPDProgressView)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId) && (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, .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 CRC_ImageQuestionCount = isCRC ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.SubjectVisitList.Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)).SelectMany(c => c.QCChallengeList) .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, .Where(u => u.IsClosed == false && (u.LatestReplyUser.UserTypeEnum == UserTypeEnum.IQC || u.LatestReplyUserId == null)).Count() > 0).CountAsync() : 0,
CRC_CheckQuestionCount = isCRC ? await _trialRepository CRC_CheckQuestionCount = isCRC ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.SubjectVisitList.Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .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, .Where(u => u.CheckState == CheckStateEnum.CVIng && u.CheckChallengeState == CheckChanllengeTypeEnum.PMWaitCRCReply).Count() > 0).CountAsync() : 0,
CRC_ImageReUploadCount = isCRC ? await _trialRepository CRC_ImageReUploadCount = isCRC ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.SubjectVisitList .Where(t => t.SubjectVisitList
.Where(c => c.TrialSite.CRCUserList.Any(u => u.UserId == _userInfo.UserRoleId)) .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, .Where(u => (u.SubmitState == SubmitStateEnum.ToSubmit && u.IsPMBackOrReReading) || (u.IsQCConfirmedReupload)).Count() > 0).CountAsync() : 0,
CRC_ClinicalDataTobeDoneCount = isCRC ? await _trialRepository CRC_ClinicalDataTobeDoneCount = isCRC ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.ReadingClinicalDataList.Where(x => !x.IsSign && x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC).Count() > 0).CountAsync() : 0, .Where(t => t.ReadingClinicalDataList.Where(x => !x.IsSign && x.ClinicalDataTrialSet.UploadRole == UploadRole.CRC).Count() > 0).CountAsync() : 0,
CRC_ClinialDataTobeConfirmCount = isCRC ? await _trialRepository CRC_ClinialDataTobeConfirmCount = isCRC ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.ReadModuleList.Where(x => !x.IsCRCConfirm).Count() > 0).CountAsync() : 0, .Where(t => t.ReadModuleList.Where(x => !x.IsCRCConfirm).Count() > 0).CountAsync() : 0,
@ -1256,11 +1256,11 @@ namespace IRaCIS.Core.Application
SPM_SiteSurveryCount = isSPMOrCPM ? siteSurveyCount : 0, SPM_SiteSurveryCount = isSPMOrCPM ? siteSurveyCount : 0,
SPM_ReviewerApprovalCount = isSPMOrCPM ? await _trialRepository SPM_ReviewerApprovalCount = isSPMOrCPM ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).Count() > 0).CountAsync() : 0, .Where(t => t.EnrollList.Where(u => u.EnrollStatus == EnrollStatus.HasCommittedToCRO).Count() > 0).CountAsync() : 0,
SPM_ReReadingApprovalCount = isSPMOrCPM ? await _visitTaskReReadingRepository SPM_ReReadingApprovalCount = isSPMOrCPM ? await _visitTaskReReadingRepository
.Where(t => t.OriginalReReadingTask.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.OriginalReReadingTask.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed) .Where(t => t.OriginalReReadingTask.ReReadingApplyState == ReReadingApplyState.TrialGroupHaveApplyed)
.GroupBy(t => t.OriginalReReadingTask.TrialId) .GroupBy(t => t.OriginalReReadingTask.TrialId)
.Select(g => new ReReadingApplyToBeDoneDto() .Select(g => new ReReadingApplyToBeDoneDto()
@ -1277,7 +1277,7 @@ namespace IRaCIS.Core.Application
IQC_IamgeQCCount = isIQC ? await _trialRepository IQC_IamgeQCCount = isIQC ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.QCProcessEnum != TrialQCProcess.NotAudit) .Where(t => t.QCProcessEnum != TrialQCProcess.NotAudit)
.Select(t => new .Select(t => new
{ {
@ -1291,7 +1291,7 @@ namespace IRaCIS.Core.Application
}).Where(x => x.ToBeClaimedCount + x.ToBeReviewedCount > 0).CountAsync() : 0, }).Where(x => x.ToBeClaimedCount + x.ToBeReviewedCount > 0).CountAsync() : 0,
IQC_QCQuestionCount = isIQC ? await _trialRepository IQC_QCQuestionCount = isIQC ? await _trialRepository
.Where(t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.SubjectVisitList.SelectMany(c => c.QCChallengeList) .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, .Where(u => u.CreateUserId == _userInfo.UserRoleId && u.IsClosed == false && u.LatestReplyUser.UserTypeEnum == UserTypeEnum.ClinicalResearchCoordinator).Count() > 0).CountAsync() : 0,
@ -1315,7 +1315,7 @@ namespace IRaCIS.Core.Application
// .Where(y => y.IsFrontTaskNeedSignButNotSign == false && (y.IsNeedClinicalDataSign == false || y.IsClinicalDataSign == true)).Count()>0).CountAsync() : 0, // .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.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) await _trialReadingCriterionRepository.Where(t => t.IsSigned == true && t.IsConfirm == true && t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(c => c.VisitTaskList.Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.ReadingTaskState != ReadingTaskState.HaveSigned && t.TaskState == TaskState.Effect) .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)) .Where(t => !t.Subject.SubjectVisitList.Any(sv => sv.CheckState != CheckStateEnum.CVPassed && t.VisitTaskNum > sv.VisitNum))
@ -1328,7 +1328,7 @@ namespace IRaCIS.Core.Application
: 0, : 0,
IR_MedicalReviewCount = isIR ? await _taskMedicalReviewRepository.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) IR_MedicalReviewCount = isIR ? await _taskMedicalReviewRepository.Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.VisitTask.DoctorUserId == _userInfo.UserRoleId) .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 }) .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, .Where(g => g.Where(u => u.LatestReplyUser.UserTypeEnum == UserTypeEnum.MIM && u.AuditState == MedicalReviewAuditState.Auditing).Count() > 0).CountAsync() : 0,
@ -1339,7 +1339,7 @@ namespace IRaCIS.Core.Application
#region MIM #region MIM
MIM_MedicalReviewCount = isMIM ? await _taskMedicalReviewRepository MIM_MedicalReviewCount = isMIM ? await _taskMedicalReviewRepository
.Where(t => t.Trial.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .Where(t => t.Trial.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.Where(t => t.IsClosedDialog == false && t.VisitTask.TaskState == TaskState.Effect && t.IsInvalid == false && t.MedicalManagerUserId == _userInfo.UserRoleId) .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 }) .GroupBy(t => new { t.TrialId, t.VisitTask.TrialReadingCriterionId })
.Select(g => new .Select(g => new
@ -1379,9 +1379,9 @@ namespace IRaCIS.Core.Application
.WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code))
.WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo)) .WhereIf(!string.IsNullOrEmpty(inQuery.ResearchProgramNo), o => o.ResearchProgramNo.Contains(inQuery.ResearchProgramNo))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), o => o.ExperimentName.Contains(inQuery.ExperimentName))
.WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false) .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.IsDeleted == false) && t.IsDeleted == false)
.WhereIf(inQuery.CriterionType != null, o => o.TrialReadingCriterionList.Any(t => t.CriterionType == inQuery.CriterionType && t.IsSigned && t.IsConfirm)) .WhereIf(inQuery.CriterionType != null, o => o.TrialReadingCriterionList.Any(t => t.CriterionType == inQuery.CriterionType && t.IsSigned && t.IsConfirm))
.WhereIf(!string.IsNullOrEmpty(inQuery.PM_EMail), o => o.TrialUserList.Any(t => t.UserRole.IdentityUser.EMail.Contains(inQuery.PM_EMail) && (t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM))) .WhereIf(!string.IsNullOrEmpty(inQuery.PM_EMail), o => o.TrialIdentityUserList.Any(t => t.IdentityUser.EMail.Contains(inQuery.PM_EMail) ))
.Select(t => new TrialToBeDoneDto() .Select(t => new TrialToBeDoneDto()
{ {
TrialId = t.Id, TrialId = t.Id,
@ -1442,7 +1442,7 @@ namespace IRaCIS.Core.Application
IR_ReadingCriterionList = isIR ? t.TrialReadingCriterionList.Where(t => t.IsConfirm && t.IsSigned).OrderBy(t => t.CriterionName).Select(t => t.CriterionName).ToList() : null, IR_ReadingCriterionList = isIR ? t.TrialReadingCriterionList.Where(t => t.IsConfirm && t.IsSigned).OrderBy(t => t.CriterionName).Select(t => t.CriterionName).ToList() : null,
IR_PMEmailList = isIR ? t.TrialUserList.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM).OrderBy(t => t.UserRole.IdentityUser.EMail).Select(t => t.UserRole.IdentityUser.EMail).ToList() : null, IR_PMEmailList = isIR ? t.TrialUserRoleList.Where(t => t.UserRole.UserTypeEnum == UserTypeEnum.ProjectManager || t.UserRole.UserTypeEnum == UserTypeEnum.APM).OrderBy(t => t.UserRole.IdentityUser.EMail).Select(t => t.UserRole.IdentityUser.EMail).ToList() : null,
IR_TotalReadCount = isIR ? t.VisitTaskList.Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned).Count() : 0, IR_TotalReadCount = isIR ? t.VisitTaskList.Where(t => t.DoctorUserId == _userInfo.UserRoleId && t.TaskState == TaskState.Effect && t.ReadingTaskState == ReadingTaskState.HaveSigned).Count() : 0,

View File

@ -90,7 +90,6 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(multiModalityIdSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.Modality) == multiModalityIdSelectCount) .WhereIf(multiModalityIdSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.Modality) == multiModalityIdSelectCount)
.WhereIf(multiCriteriaSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.Criterion) == multiCriteriaSelectCount) .WhereIf(multiCriteriaSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.Criterion) == multiCriteriaSelectCount)
.WhereIf(multiReviewTypeSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.ReviewType) == multiReviewTypeSelectCount) .WhereIf(multiReviewTypeSelectCount > 0, t => t.TrialDicList.Count(t => t.KeyName == StaticData.ReviewType) == multiReviewTypeSelectCount)
.WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false) && t.IsDeleted == false)
.ProjectTo<TrialDetailDTO>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId, isEn_Us = _userInfo.IsEn_Us }); .ProjectTo<TrialDetailDTO>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId, isEn_Us = _userInfo.IsEn_Us });
return await query.ToPagedListAsync(inQuery); return await query.ToPagedListAsync(inQuery);
@ -102,7 +101,7 @@ namespace IRaCIS.Core.Application.Service
public async Task<List<TrialSelectDTO>> GetTrialSelect() public async Task<List<TrialSelectDTO>> GetTrialSelect()
{ {
return await _trialRepository.AsQueryable() return await _trialRepository.AsQueryable()
.WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId) && t.IsDeleted == false) .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OP, t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId) && t.IsDeleted == false)
.ProjectTo<TrialSelectDTO>(_mapper.ConfigurationProvider).ToListAsync(); .ProjectTo<TrialSelectDTO>(_mapper.ConfigurationProvider).ToListAsync();
} }
@ -629,7 +628,7 @@ namespace IRaCIS.Core.Application.Service
.WhereIf(inQuery.Expedited != null, o => o.Expedited == inQuery.Expedited) .WhereIf(inQuery.Expedited != null, o => o.Expedited == inQuery.Expedited)
.WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code)) .WhereIf(!string.IsNullOrEmpty(inQuery.Code), o => o.TrialCode.Contains(inQuery.Code))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Indication), o => o.Indication.Contains(inQuery.Indication)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.Indication), o => o.Indication.Contains(inQuery.Indication))
.WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialUserList.Any(t => t.UserId == _userInfo.UserRoleId)) .WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin, t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId))
.ProjectTo<TrialDetailDTO>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId, isEn_Us = _userInfo.IsEn_Us }); .ProjectTo<TrialDetailDTO>(_mapper.ConfigurationProvider, new { userTypeEnumInt = _userInfo.UserTypeEnumInt, userId = _userInfo.UserRoleId, isEn_Us = _userInfo.IsEn_Us });

View File

@ -38,7 +38,10 @@ public partial class Trial : BaseFullDeleteAuditEntity
[JsonIgnore] [JsonIgnore]
public List<Workload> WorkloadList { get; set; } = new List<Workload>(); public List<Workload> WorkloadList { get; set; } = new List<Workload>();
[JsonIgnore] [JsonIgnore]
public List<TrialUserRole> TrialUserList { get; set; } = new List<TrialUserRole>(); public List<TrialUserRole> TrialUserRoleList { get; set; } = new List<TrialUserRole>();
[JsonIgnore]
public List<TrialIdentityUser> TrialIdentityUserList { get; set; }
[JsonIgnore] [JsonIgnore]
public List<ReadingQuestionCriterionTrial> TrialReadingCriterionList { get; set; } = new List<ReadingQuestionCriterionTrial>(); public List<ReadingQuestionCriterionTrial> TrialReadingCriterionList { get; set; } = new List<ReadingQuestionCriterionTrial>();
[JsonIgnore] [JsonIgnore]