diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 058c044d3..bb7990b91 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -713,9 +713,15 @@ - + - 获取 项目 某个site的调研记录 + 获取 项目 site的调研记录 New + + + + + + 项目Site调研用户列表 所有site的调研用户 最新的调研表的记录的用户 new @@ -747,12 +753,6 @@ - - - 项目Site调研用户列表 所有site的调研用户 会有重复 - - - TrialSiteUserSurveyService diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs index 491c85e0c..e23ac4719 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteSurveyViewModel.cs @@ -68,8 +68,14 @@ namespace IRaCIS.Core.Application.Contracts public Guid TrialId { get; set; } public Guid? SiteId { get; set; } + public Guid? UserTypeId { get; set; } + public bool? IsGenerateAccount { get; set; } + public Guid? TrialRoleNameId { get; set; } + + public TrialSiteUserStateEnum? State { get; set; } + public string FormWriterKeyInfo { get; set; } = string.Empty; public string UserKeyInfo { get; set; } = string.Empty; @@ -232,13 +238,18 @@ namespace IRaCIS.Core.Application.Contracts public string RouteUrl { get; set; } = string.Empty; } - public class TrialSiteSurveyQueryDTO + public class TrialSiteSurveyQueryDTO : PageInput { - //public Guid? SiteId { get; set; } + [NotDefault] + public Guid TrialId { get; set; } - public string SiteName { get; set; } = String.Empty; - public string TrialSiteCode { get; set; } = String.Empty; - public string TrialSiteAliasName { get; set; } = String.Empty; + public Guid? SiteId { get; set; } + + public string UserKeyInfo { get; set; } = string.Empty; + + public TrialSiteSurveyEnum? State { get; set; } + + public bool? IsAbandon { get; set; } } public class CopyTrialSiteSurveyDTO diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs index 5106d1e72..5b6e67358 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/DTO/TrialSiteUserSurveyViewModel.cs @@ -84,7 +84,7 @@ namespace IRaCIS.Core.Application.Contracts public class TrialSiteUserSurveyAddOrEdit { public Guid? Id { get; set; } - public Guid TrialRoleNameId { get; set; } + public Guid TrialSiteSurveyId { get; set; } public Guid? UserTypeId { get; set; } public string FirstName { get; set; } = string.Empty; @@ -92,6 +92,7 @@ namespace IRaCIS.Core.Application.Contracts public string Phone { get; set; } = string.Empty; public string Email { get; set; } = string.Empty; public bool IsGenerateAccount { get; set; } + public Guid TrialRoleNameId { get; set; } public string OrganizationName { get; set; } = string.Empty; } diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteSurveyService.cs index 5d007c947..4026cd8ad 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/Interface/ITrialSiteSurveyService.cs @@ -14,7 +14,7 @@ namespace IRaCIS.Core.Application.Contracts Task AddOrUpdateTrialSiteSurvey(TrialSiteSurveyAddOrEdit addOrEditTrialSiteSurvey); Task DeleteTrialSiteSurvey(Guid trialSiteSurveyId); Task GetSiteSurveyInfo(Guid trialSiteSurveyId, Guid trialId); - Task> GetTrialSiteSurveyList(Guid trialId, TrialSiteSurveyQueryDTO trialSiteSurveyQueryDTO); + Task> GetTrialSiteSurveyList(TrialSiteSurveyQueryDTO surveyQueryDTO); Task GetTrialSurveyInitInfo(Guid trialId); Task SendVerifyCode(SiteSurveySendVerifyCode userInfo, [FromServices] IMailVerificationService _mailVerificationService); //Task TrialSurveyLock(Guid trialSiteSurveyId, bool isLock); diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index df7b0deff..503873396 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -29,7 +29,7 @@ namespace IRaCIS.Core.Application.Contracts private readonly IRepository _userRepository; private readonly IRepository _trialSiteRepository; - public TrialSiteSurveyService(IRepository trialSiteSurveyRepository, IRepository trialSiteUserSurveyRepository, IRepository userRepository,IRepository trialSiteRepository) + public TrialSiteSurveyService(IRepository trialSiteSurveyRepository, IRepository trialSiteUserSurveyRepository, IRepository userRepository, IRepository trialSiteRepository) { _trialSiteSurveyRepository = trialSiteSurveyRepository; _trialSiteUserSurveyRepository = trialSiteUserSurveyRepository; @@ -357,27 +357,72 @@ namespace IRaCIS.Core.Application.Contracts } - /// - /// 获取 项目 某个site的调研记录 + /// 获取 项目 site的调研记录 New /// /// - [HttpPost("{trialId:guid}")] - public async Task> GetTrialSiteSurveyList(Guid trialId, TrialSiteSurveyQueryDTO trialSiteSurveyQueryDTO) + [HttpPost] + public async Task> GetTrialSiteSurveyList(TrialSiteSurveyQueryDTO surveyQueryDTO) { - var trialSiteSurveyQueryable = _trialSiteSurveyRepository.Where(t => t.TrialId == trialId).IgnoreQueryFilters() - //.WhereIf(trialSiteSurveyQueryDTO.si != null, t => t.SiteId == siteId) - .WhereIf(!string.IsNullOrWhiteSpace(trialSiteSurveyQueryDTO.SiteName), t => t.Site.SiteName.Contains(trialSiteSurveyQueryDTO.SiteName)) - .WhereIf(!string.IsNullOrWhiteSpace(trialSiteSurveyQueryDTO.TrialSiteAliasName), t => t.TrialSite.TrialSiteAliasName.Contains(trialSiteSurveyQueryDTO.TrialSiteAliasName)) - .WhereIf(!string.IsNullOrWhiteSpace(trialSiteSurveyQueryDTO.TrialSiteCode), t => t.TrialSite.TrialSiteAliasName.Contains(trialSiteSurveyQueryDTO.TrialSiteCode)) - //.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM, t => t.State >= TrialSiteSurveyEnum.ToSubmit) - //.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM, t => t.State >= TrialSiteSurveyEnum.SPMApproved) - .ProjectTo(_mapper.ConfigurationProvider); + var trialSiteSurveyQueryable = _trialSiteSurveyRepository.Where(t => t.TrialId == surveyQueryDTO.TrialId).IgnoreQueryFilters() + .WhereIf(surveyQueryDTO.SiteId != null, t => t.SiteId == surveyQueryDTO.SiteId) + .WhereIf(surveyQueryDTO.IsAbandon != null, t => t.IsAbandon == surveyQueryDTO.IsAbandon) + .WhereIf(!string.IsNullOrWhiteSpace(surveyQueryDTO.UserKeyInfo), t => t.UserName.Contains(surveyQueryDTO.UserKeyInfo) || t.Phone.Contains(surveyQueryDTO.UserKeyInfo) || t.Email.Contains(surveyQueryDTO.UserKeyInfo)) + .WhereIf(surveyQueryDTO.State != null, t => t.State == surveyQueryDTO.State) + .ProjectTo(_mapper.ConfigurationProvider); - return await trialSiteSurveyQueryable.ToListAsync(); + return await trialSiteSurveyQueryable.ToPagedListAsync(surveyQueryDTO.PageIndex, surveyQueryDTO.PageSize, surveyQueryDTO.SortField, surveyQueryDTO.Asc); } + /// + /// 项目Site调研用户列表 所有site的调研用户 最新的调研表的记录的用户 new + /// + /// + public async Task> TrialSiteSurveyUserList(TrialSiteUserSurveyAllQuery queryParam) + { + + + var groupSelectIdQuery = + _trialSiteSurveyRepository.Where(t => t.TrialId == queryParam.TrialId && t.IsAbandon == false) + .WhereIf(queryParam.SiteId != null, t => t.SiteId == queryParam.SiteId) + .WhereIf(!string.IsNullOrEmpty(queryParam.FormWriterKeyInfo), t => (t.UserName).Contains(queryParam.FormWriterKeyInfo) || t.Email.Contains(queryParam.FormWriterKeyInfo) || t.Phone.Contains(queryParam.FormWriterKeyInfo)) + .GroupBy(t => t.SiteId) + .Select(g => g.OrderByDescending(u => u.CreateTime).Select(t => t.Id).First()); + + + var query = _trialSiteUserSurveyRepository + .Where(t => groupSelectIdQuery.Contains(t.TrialSiteSurveyId) ) + .WhereIf(queryParam.UserTypeId != null, t => t.UserTypeId == queryParam.UserTypeId) + .WhereIf(queryParam.IsGenerateAccount != null, t => t.IsGenerateAccount == queryParam.IsGenerateAccount) + .WhereIf(queryParam.TrialRoleNameId != null, t => t.TrialRoleNameId == queryParam.TrialRoleNameId) + .WhereIf(queryParam.State != null && queryParam.State != TrialSiteUserStateEnum.OverTime, t => t.InviteState == queryParam.State) + .WhereIf(queryParam.State != null && queryParam.State == TrialSiteUserStateEnum.OverTime, t => t.InviteState == TrialSiteUserStateEnum.HasSend && t.ExpireTime < DateTime.Now) + .WhereIf(!string.IsNullOrEmpty(queryParam.UserKeyInfo), t => (t.LastName + " / " + t.FirstName).Contains(queryParam.UserKeyInfo) || t.Email.Contains(queryParam.UserKeyInfo) || t.Phone.Contains(queryParam.UserKeyInfo)) + + .ProjectTo(_mapper.ConfigurationProvider); + + //var query = _trialSiteSurveyRepository.Where(t => t.TrialId == queryParam.TrialId && t.IsAbandon == false) + // .WhereIf(queryParam.SiteId != null, t => t.SiteId == queryParam.SiteId) + // .WhereIf(!string.IsNullOrEmpty(queryParam.FormWriterKeyInfo), t => (t.UserName).Contains(queryParam.FormWriterKeyInfo) || t.Email.Contains(queryParam.FormWriterKeyInfo) || t.Phone.Contains(queryParam.FormWriterKeyInfo)) + // .GroupBy(t => t.SiteId) + // .Select(g => g.OrderByDescending(u => u.CreateTime).FirstOrDefault()) + // .SelectMany(t => t.TrialSiteUserSurveyList) + //.WhereIf(queryParam.UserTypeId != null, t => t.UserTypeId == queryParam.UserTypeId) + //.WhereIf(queryParam.IsGenerateAccount != null, t => t.IsGenerateAccount == queryParam.IsGenerateAccount) + //.WhereIf(queryParam.TrialRoleNameId != null, t => t.TrialRoleNameId == queryParam.TrialRoleNameId) + //.WhereIf(queryParam.State != null && queryParam.State != TrialSiteUserStateEnum.OverTime, t => t.InviteState == queryParam.State) + //.WhereIf(queryParam.State != null && queryParam.State == TrialSiteUserStateEnum.OverTime, t => t.InviteState == TrialSiteUserStateEnum.HasSend && t.ExpireTime < DateTime.Now) + //.WhereIf(!string.IsNullOrEmpty(queryParam.UserKeyInfo), t => (t.LastName + " / " + t.FirstName).Contains(queryParam.UserKeyInfo) || t.Email.Contains(queryParam.UserKeyInfo) || t.Phone.Contains(queryParam.UserKeyInfo)) + //.ProjectTo(_mapper.ConfigurationProvider); + + return await query.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, queryParam.SortField, queryParam.Asc); + + + + + //return await query.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, queryParam.SortField, queryParam.Asc); + } @@ -439,9 +484,9 @@ namespace IRaCIS.Core.Application.Contracts { //PM 给SPM发 (初审人) - user = await _userRepository.FirstOrDefaultAsync(t => t.Id == survey.PreliminaryUserId); + user = await _userRepository.FirstOrDefaultAsync(t => t.Id == survey.PreliminaryUserId); - messageToSend.To.Add(new MailboxAddress(String.Empty, survey.PreliminaryUserId==null? survey.Email: user.EMail)); + messageToSend.To.Add(new MailboxAddress(String.Empty, survey.PreliminaryUserId == null ? survey.Email : user.EMail)); survey.State = TrialSiteSurveyEnum.CRCSubmitted; @@ -469,13 +514,13 @@ namespace IRaCIS.Core.Application.Contracts var trialInfo = await _repository.FirstOrDefaultAsync(t => t.Id == trialSiteSubmitBackCommand.TrialId); - var siteInfo = await _trialSiteRepository.FirstOrDefaultAsync(t => t.TrialId == trialSiteSubmitBackCommand.TrialId&& t.SiteId== survey.SiteId,true); + var siteInfo = await _trialSiteRepository.FirstOrDefaultAsync(t => t.TrialId == trialSiteSubmitBackCommand.TrialId && t.SiteId == survey.SiteId, true); builder.HtmlBody = @$"
- { (user==null? survey.UserName: user.LastName + "/ " + user.FirstName)}: + { (user == null ? survey.UserName : user.LastName + "/ " + user.FirstName)}:
您好, 您填写的中心调研表被驳回,详细信息如下: @@ -681,7 +726,7 @@ namespace IRaCIS.Core.Application.Contracts smtp.MessageSent += (sender, args) => { - _ = _trialSiteUserSurveyRepository.UpdateFromQueryAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, InviteState = TrialSiteUserStateEnum.HasSend, IsJoin=null,ConfirmTime=null,RejectReason=String.Empty, SystemUserId = sysUserInfo.Id, ExpireTime = DateTime.Now.AddDays(7) }).Result; + _ = _trialSiteUserSurveyRepository.UpdateFromQueryAsync(t => t.Id == item.Id, u => new TrialSiteUserSurvey() { IsGenerateSuccess = true, InviteState = TrialSiteUserStateEnum.HasSend, IsJoin = null, ConfirmTime = null, RejectReason = String.Empty, SystemUserId = sysUserInfo.Id, ExpireTime = DateTime.Now.AddDays(7) }).Result; }; @@ -742,7 +787,7 @@ namespace IRaCIS.Core.Application.Contracts else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.SPM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CPM) { - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.CRCSubmitted, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved, PreliminaryUserId = _userInfo.Id,PreliminaryTime=DateTime.Now }); + await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.CRCSubmitted, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.SPMApproved, PreliminaryUserId = _userInfo.Id, PreliminaryTime = DateTime.Now }); } else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.APM || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager) @@ -759,7 +804,7 @@ namespace IRaCIS.Core.Application.Contracts await SendInviteEmail(new InviteEmailCommand() { TrialId = trialId, RouteUrl = siteSurvyeSubmit.RouteUrl, UserList = needGenerateList }); - await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime=DateTime.Now}); + await _trialSiteSurveyRepository.UpdateFromQueryAsync(t => t.Id == trialSiteSurveyId && t.State == TrialSiteSurveyEnum.SPMApproved, u => new TrialSiteSurvey() { State = TrialSiteSurveyEnum.PMCreatedAndLock, ReviewerUserId = _userInfo.Id, ReviewerTime = DateTime.Now }); } @@ -767,21 +812,6 @@ namespace IRaCIS.Core.Application.Contracts } - /// - /// 项目Site调研用户列表 所有site的调研用户 会有重复 - /// - /// - public async Task> TrialSiteSurveyUserList(TrialSiteUserSurveyAllQuery queryParam) - { - var query = _trialSiteUserSurveyRepository.Where(t => t.TrialSiteSurvey.TrialId == queryParam.TrialId&&t.TrialSiteSurvey.IsAbandon==false) - .WhereIf(queryParam.SiteId!=null, t => t.TrialSiteSurvey.SiteId == queryParam.SiteId) - .WhereIf(! string.IsNullOrEmpty(queryParam.UserKeyInfo ), t => (t.LastName + " / " + t.FirstName).Contains(queryParam.UserKeyInfo)||t.Email.Contains(queryParam.UserKeyInfo) ||t.Phone.Contains(queryParam.UserKeyInfo)) - .WhereIf(!string.IsNullOrEmpty(queryParam.FormWriterKeyInfo), t => (t.TrialSiteSurvey.UserName).Contains(queryParam.FormWriterKeyInfo) || t.TrialSiteSurvey.Email.Contains(queryParam.FormWriterKeyInfo) || t.TrialSiteSurvey.Phone.Contains(queryParam.FormWriterKeyInfo)) - - .ProjectTo(_mapper.ConfigurationProvider); - - return await query.ToPagedListAsync(queryParam.PageIndex, queryParam.PageSize, queryParam.SortField, queryParam.Asc); - } diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index f96793546..e8c50a7ec 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -40,58 +40,13 @@ namespace IRaCIS.Core.Application.Services IsVerify=svCommand.IsFinalVisit }; - #region 废弃 - //var verifyExp2 = new EntityVerifyExp() - //{ - // verifyType = VerifyEnum.OnlyUpdate, - // VerifyExp = t => t.StudyList.Any(k => k.SubjectVisitId == svCommand.Id) && svCommand.SVSTDTC == null, - // VerifyMsg = "This visit is associated with the uploaded study images, and the visit start date is not allowed to be modified." - //}; - - //if (needDealEntity.SVSTDTC == null && needDealEntity.VisitExecuted == 1) - //{ - // return ResponseOutput.NotOk("VisitExecuted must have Start Date "); - //} - - - //if (needDealEntity.IsOutEnromentVisit) - //{ - // needDealEntity.VisitNum = _subjectVisitRepository.Where(t => t.SubjectId == svCommand.SubjectId).Max(t => t.VisitNum) + (decimal)0.1; - //} - - //没有EndOfVisit - //if (svCommand.IsFinalVisit) - //{ - // //if (svCommand.InPlan) - // //{ - // await _repository.UpdateFromQueryAsync(t => t.Id == svCommand.SubjectId, u => new Subject() { Status = SubjectStatus.EndOfVisit }); - // //} - // //else - // //{ - // // return ResponseOutput.NotOk("计划外访视不允许设置为最后一次访视"); - - // //} - //} - #endregion - svCommand.BlindName = "B" + ((int)(svCommand.VisitNum * 10)).ToString("D3"); var subject = (await _repository.FirstOrDefaultAsync(t => t.Id == svCommand.SubjectId)).IfNullThrowException(); - //不管是否 都是执行,只是失访的时候 设置Subject状态为失去访视 - //if (svCommand.IsLostVisit) - //{ - // svCommand.VisitExecuted = VisitExecutedEnum.Executed; - // subject.IsMissingImages = true; - - //} - //else - //{ - // svCommand.VisitExecuted = VisitExecutedEnum.Executed; - //} svCommand.VisitExecuted = svCommand.IsLostVisit ? VisitExecutedEnum.Executed : svCommand.VisitExecuted; @@ -141,6 +96,14 @@ namespace IRaCIS.Core.Application.Services await _subjectVisitRepository.UpdateFromQueryAsync(t => t.SubjectId == svCommand.SubjectId && t.VisitExecuted == VisitExecutedEnum.Unavailable, u => new SubjectVisit() { VisitExecuted = VisitExecutedEnum.UnExecuted }); } + if (svCommand.IsLostVisit && svCommand.Id == null) + { + if (await _subjectVisitRepository.AnyAsync(t => t.Id==svCommand.Id && t.SubmitState == SubmitStateEnum.ToSubmit)) + { + return ResponseOutput.NotOk("该受试者此访视有影像上传,不允许设置为失访"); + } + } + //更新受试者 首次给药日期 是否入组确认 if (svCommand.SubjectFirstGiveMedicineTime != null) { diff --git a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs index bba98c9e0..bef43ad72 100644 --- a/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs +++ b/IRaCIS.Core.Domain/SiteSurvey/TrialSiteUserSurvey.cs @@ -30,7 +30,7 @@ namespace IRaCIS.Core.Domain.Models public Guid? UserTypeId { get; set; } - public Guid? TrialRoleNameId { get; set; } + public Guid TrialRoleNameId { get; set; } public Dictionary TrialRoleName { get; set; }