diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml index 909f16392..c8db7aee2 100644 --- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml +++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml @@ -12924,7 +12924,7 @@ 项目外部人员 录入流程相关 - + 项目外部人员 录入流程相关 @@ -15539,7 +15539,7 @@ TrialSiteSurveyService - + TrialSiteSurveyService diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index c195e4511..dc21c1622 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -7,6 +7,7 @@ using IRaCIS.Core.Infrastructure; using MailKit; using Medallion.Threading; using Microsoft.AspNetCore.Hosting; +using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Options; using MimeKit; @@ -485,14 +486,6 @@ namespace IRaCIS.Core.Application.Service await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, null); - //创建账号 和创建角色 一条,更新的时候才记录更新角色 - if (!sysUserInfo.IsFirstAdd) - { - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = userId, OptType = UserOptType.UpdateUserRole }, true); - - } - - } //Site调研 用户加入项目 @@ -553,13 +546,6 @@ namespace IRaCIS.Core.Application.Service await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig); - //创建账号 和创建角色 一条,更新的时候才记录更新角色 - if (!sysUserInfo.IsFirstAdd) - { - await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = userId, OptType = UserOptType.UpdateUserRole }, true); - - } - } @@ -574,6 +560,9 @@ namespace IRaCIS.Core.Application.Service var userType = await _userTypeRepository.FirstAsync(t => t.UserTypeEnum == UserTypeEnum.IndependentReviewer); + //需要创建新的账户 + var isNeedCreateNewUser = false; + var @lock = _distributedLockProvider.CreateLock($"UserCode"); using (await @lock.AcquireAsync()) @@ -583,6 +572,7 @@ namespace IRaCIS.Core.Application.Service if (!isDoctorHaveAccount) { + isNeedCreateNewUser = true; var saveItem = new IdentityUser() { FirstName = doctor.FirstName, LastName = doctor.LastName, EMail = doctor.EMail }; @@ -685,10 +675,9 @@ namespace IRaCIS.Core.Application.Service await SendEmailHelper.SendEmailAsync(messageToSend, _systemEmailConfig, null); //创建账号 和创建角色 一条,更新的时候才记录更新角色 - if (!sysUserInfo.IsFirstAdd) + if (isNeedCreateNewUser == false) { await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = sysUserInfo.Id, OptType = UserOptType.UpdateUserRole }, true); - } diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs index 1e76770b7..f82a373c9 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/NoneDicomStudyService.cs @@ -28,7 +28,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpGet] - public async Task> GetNoneDicomStudyList( + public async Task> > GetNoneDicomStudyList( [FromQuery, NotDefault] Guid subjectVisitId, [FromQuery] Guid? nonedicomStudyId, [FromQuery] bool isFilterZip, @@ -54,7 +54,10 @@ namespace IRaCIS.Core.Application.Contracts } - return await noneDicomStudyQueryable.ToListAsync(); + var list = await noneDicomStudyQueryable.ToListAsync(); + + var config = await _subjectVisitRepository.Where(t => t.Id == subjectVisitId).Select(t => new { t.Trial.ImageFormatList, t.Trial.StudyNameList ,t.Trial.IsShowStudyName}).FirstOrDefaultAsync(); + return ResponseOutput.Ok(list, config) ; } diff --git a/IRaCIS.Core.Application/Service/QC/DTO/NoneDicomStudyViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/NoneDicomStudyViewModel.cs index 2ef4f593c..daed12f4d 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/NoneDicomStudyViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/NoneDicomStudyViewModel.cs @@ -14,6 +14,7 @@ namespace IRaCIS.Core.Application.Contracts public int FileCount { get; set; } + public List NoneDicomStudyFileList { get; set; } = new List(); @@ -54,6 +55,7 @@ namespace IRaCIS.Core.Application.Contracts public int Code { get; set; } + public string StudyName { get; set; } public string VideoName { get; set; } = string.Empty; diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QARecordViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QARecordViewModel.cs index 72c906f67..5a8b5f93c 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QARecordViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QARecordViewModel.cs @@ -18,6 +18,8 @@ namespace IRaCIS.Core.Application.Contracts.DTO public int Type { get; set; } + public string StudyName { get; set; } = String.Empty; + public string Modality { get; set; } = String.Empty; public string BodyPart { get; set; } = String.Empty; @@ -353,8 +355,13 @@ namespace IRaCIS.Core.Application.Contracts.DTO public int? NotClosedChallengeCount { get; set; } + public List StudyNameList { get; set; } + public List ImageFormatList { get; set; } + + public bool IsShowStudyName { get; set; } = false; + } public class QAStudyInfoDTO { @@ -389,6 +396,8 @@ namespace IRaCIS.Core.Application.Contracts.DTO public string BodyPartForEdit { get; set; } = String.Empty; + public string StudyName { get; set; } = string.Empty; + public string ModalityForEdit { get; set; } = string.Empty; public bool IsHaveUploadFailed { get; set; } diff --git a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs index 7b21a2efb..7020f74d1 100644 --- a/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs +++ b/IRaCIS.Core.Application/Service/QC/DTO/QCListViewModel.cs @@ -161,6 +161,13 @@ namespace IRaCIS.Core.Application.Contracts [Comment("阅片任务产生之前 采集影像")] public CollectImagesType CollectImagesEnum { get; set; } + public List StudyNameList { get; set; } + + + public List ImageFormatList { get; set; } + + public bool IsShowStudyName { get; set; } = false; + } diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index bf12c9a31..c630017c6 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -762,6 +762,8 @@ namespace IRaCIS.Core.Application.Image.QA study.BodyPartForEdit = updateModalityCommand.BodyPart; study.ModalityForEdit = updateModalityCommand.Modality; + study.StudyName = updateModalityCommand.StudyName; + await _dicomSeriesRepository.BatchUpdateNoTrackingAsync(t => t.StudyId == studyId, r => new DicomSeries() { BodyPartForEdit = updateModalityCommand.BodyPart }); } diff --git a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs index d7b29f3e1..7b6d5cb23 100644 --- a/IRaCIS.Core.Application/Service/QC/_MapConfig.cs +++ b/IRaCIS.Core.Application/Service/QC/_MapConfig.cs @@ -588,7 +588,10 @@ namespace IRaCIS.Core.Application.Service .ForMember(d => d.SubjectFirstGiveMedicineTime, u => u.MapFrom(s => s.Subject.FirstGiveMedicineTime)) .ForMember(d => d.SiteName, u => u.MapFrom(s => s.TrialSite.TrialSiteName)) .ForMember(d => d.TotalChallengeCount, u => u.MapFrom(s => s.QCChallengeList.Count())) - .ForMember(d => d.NotClosedChallengeCount, u => u.MapFrom(s => s.QCChallengeList.Count(c => c.IsClosed == false))); + .ForMember(d => d.NotClosedChallengeCount, u => u.MapFrom(s => s.QCChallengeList.Count(c => c.IsClosed == false))) + .ForMember(d => d.IsShowStudyName, u => u.MapFrom(s => s.Trial.IsShowStudyName)) + .ForMember(d => d.StudyNameList, u => u.MapFrom(s => s.Trial.StudyNameList)) + .ForMember(d => d.ImageFormatList, u => u.MapFrom(s => s.Trial.ImageFormatList)); CreateMap(MemberList.None); diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index fe1dd8fde..7fb3fcec1 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -54,6 +54,7 @@ namespace IRaCIS.Core.Application.Contracts ITokenService _tokenService, IRepository _userTypeRepository, IMailVerificationService _mailVerificationService, + IRepository _userLogRepository, IOptionsMonitor systemEmailConfig, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ITrialSiteSurveyService { private readonly SystemEmailSendConfig _systemEmailConfig = systemEmailConfig.CurrentValue; @@ -672,7 +673,7 @@ namespace IRaCIS.Core.Application.Contracts TrialSiteSurveyId = currentEntity!.Id, Token = _tokenService.GetToken(new UserTokenInfo() { - IdentityUserId=Guid.NewGuid(), + IdentityUserId = Guid.NewGuid(), UserRoleId = Guid.NewGuid(), UserName = "SiteSurvey", UserTypeEnum = UserTypeEnum.Undefined, @@ -871,6 +872,8 @@ namespace IRaCIS.Core.Application.Contracts #region 人员生成 + //需要创建新的账户 + var isNeedCreateNewUser = existSysUser == null; if (existSysUser != null) { @@ -949,11 +952,12 @@ namespace IRaCIS.Core.Application.Contracts } + + #endregion await _identityUserRepository.SaveChangesAsync(); - var identityUserId = existSysUser.Id; #region 项目加入 @@ -1048,12 +1052,18 @@ namespace IRaCIS.Core.Application.Contracts if (isNeedSendEmail) { + //创建账号 和创建角色 一条,更新的时候才记录更新角色 + if (isNeedCreateNewUser == false) + { + await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.UpdateUserRole }); + } var dbUserType = _userTypeRepository.Where(t => userTypeIdList.Contains(t.Id)).ToList(); var usertyps = string.Join(',', dbUserType.Select(t => t.UserTypeName)); await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, identityUserId, usertyps, baseUrl, routeUrl); + } var userJoinIdList = item.Select(t => t.Id).ToList(); @@ -1104,6 +1114,9 @@ namespace IRaCIS.Core.Application.Contracts var existSysUser = await _identityUserRepository.Where(t => t.EMail == userEmail, true).Include(t => t.UserRoleList).FirstOrDefaultAsync(); + //需要创建新的账户 + var isNeedCreateNewUser = existSysUser == null; + if (existSysUser != null) { @@ -1288,9 +1301,17 @@ namespace IRaCIS.Core.Application.Contracts if (isNeedSendEmail) { + //创建账号 和创建角色 一条,更新的时候才记录更新角色 + if (isNeedCreateNewUser == false) + { + await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.UpdateUserRole }); + } + var dbUserType = _userTypeRepository.Where(t => userTypeIdList.Contains(t.Id)).ToList(); var usertyps = string.Join(',', dbUserType.Select(t => t.UserTypeName)); await _mailVerificationService.SiteSurveyUserJoinEmail(trialId, identityUserId, usertyps, baseUrl, routeUrl); + + } await _trialSiteUserRoleRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs index 04e6c7e6b..f9c1fa014 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialConfigDTO.cs @@ -69,6 +69,19 @@ namespace IRaCIS.Core.Application.Contracts public List ModalityList { get; set; } = new List(); + /// + /// 是否显示检查名称 + /// + public bool IsShowStudyName { get; set; } = false; + + /// + /// 检查名称列表 + /// + public List StudyNameList { get; set; } + + + + public List TrialObjectNameList { get; set; } @@ -94,6 +107,10 @@ namespace IRaCIS.Core.Application.Contracts public Guid TrialId { get; set; } + /// + /// 图像格式 + /// + public List ImageFormatList { get; set; } = new List(); /// /// 临床信息传输 1:系统录入2:系统录入+PDF 0:无 @@ -1040,7 +1057,7 @@ namespace IRaCIS.Core.Application.Contracts [Comment("SPM 参与重阅审批")] public bool IsSPMJoinReReadingApproval { get; set; } - + public List ImageFormatList { get; set; } public List TrialCriterionIds { get; set; } = new List(); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs index 31d253d81..922c7d4fc 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialExternalUserService.cs @@ -31,6 +31,7 @@ namespace IRaCIS.Core.Application.Service IRepository _trialIdentityUserRepository, IRepository _trialRepository, IRepository _userTypeRepository, + IRepository _userLogRepository, IMailVerificationService _mailVerificationService, IDistributedLockProvider _distributedLockProvider, IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer) : BaseService, ITrialExternalUserService { @@ -215,8 +216,13 @@ namespace IRaCIS.Core.Application.Service //var identityUserId = item.Key; + + var existSysUser = await _identityUserRepository.Where(t => t.EMail == userEmail, true).Include(t => t.UserRoleList).FirstOrDefaultAsync(); + //需要创建新的账户 + var isNeedCreateNewUser = existSysUser == null; + if (existSysUser != null) { @@ -294,7 +300,7 @@ namespace IRaCIS.Core.Application.Service var newAddUser = await _identityUserRepository.AddAsync(generateUser); - + existSysUser = newAddUser; @@ -390,6 +396,12 @@ namespace IRaCIS.Core.Application.Service await _trialExternalUseRepository.BatchUpdateNoTrackingAsync(t => externalIdList.Contains(t.Id), u => new TrialExternalUser() { IsJoin = true }); + //创建账号 和创建角色 一条,更新的时候才记录更新角色 + if (isNeedCreateNewUser == false) + { + await _userLogRepository.AddAsync(new UserLog() { IP = _userInfo.IP, ActionIdentityUserId = _userInfo.IdentityUserId, ActionUserName = _userInfo.UserName, TargetIdentityUserId = identityUserId, OptType = UserOptType.UpdateUserRole }, true); + } + } diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index 8558b55bf..6df2e9bf2 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -154,6 +154,72 @@ namespace IRaCIS.Core.Application.Service return ResponseOutput.Ok(); } + /// + /// 项目退出历史数据维护 + /// + /// + /// + /// + [AllowAnonymous] + public async Task OldTrialDeleteUser([FromServices] IRepository _trialIdentityUserRepository, [FromServices] IRepository _trialUserRoleReposiotry) + { + _userInfo.IsNotNeedInspection = true; + + + if (_trialUserRoleReposiotry.Any(t => t.TrialUserId == Guid.Empty)) + { + var list = _trialUserRoleReposiotry.Where(t => t.IsDeleted == true && t.TrialUserId == Guid.Empty, false, true).Select(t => new { t.TrialId, t.UserRole.IdentityUserId, t.UserId, t.JoinTime, t.RemoveTime, t.DeletedTime, t.DeleteUserId, t.CreateUserId }).ToList(); + + + foreach (var item in list.GroupBy(t => new { t.IdentityUserId, t.TrialId })) + { + + var id = NewId.NextSequentialGuid(); + + var userRoleList = item.ToList(); + + var userIdList = item.Select(t => t.UserId).ToList(); + + var first = userRoleList.OrderByDescending(t => t.RemoveTime).FirstOrDefault(); + + + //判断在项目中是否存在 + + var find = _trialIdentityUserRepository.Where(t => t.IdentityUserId == first.IdentityUserId && t.TrialId == first.TrialId).FirstOrDefault(); + + if (find == null) + { + await _trialIdentityUserRepository.AddAsync(new TrialIdentityUser() + { + Id = id, + IdentityUserId = item.Key.IdentityUserId, + TrialId = item.Key.TrialId, + RemoveTime = first.RemoveTime, + IsDeleted = true, + DeletedTime = first.DeletedTime, + DeleteUserId = first.DeleteUserId, + + }); + + + await _trialUserRoleReposiotry.BatchUpdateNoTrackingAsync(t => t.TrialId == item.Key.TrialId && userIdList.Contains(t.UserId), u => new TrialUserRole() { TrialUserId = id, UpdateTime = (DateTime)first.DeletedTime }); + } + else + { + await _trialUserRoleReposiotry.BatchUpdateNoTrackingAsync(t => t.TrialId == item.Key.TrialId && userIdList.Contains(t.UserId), u => new TrialUserRole() { TrialUserId = find.Id, UpdateTime = (DateTime)first.DeletedTime }); + } + + + + } + + await _trialIdentityUserRepository.SaveChangesAsync(); + } + + + + return ResponseOutput.Ok(); + } /// /// 用户多账号,初次维护数据 diff --git a/IRaCIS.Core.Domain/Image/DicomStudy.cs b/IRaCIS.Core.Domain/Image/DicomStudy.cs index ee9228614..06e648cac 100644 --- a/IRaCIS.Core.Domain/Image/DicomStudy.cs +++ b/IRaCIS.Core.Domain/Image/DicomStudy.cs @@ -43,6 +43,11 @@ public class DicomStudy : BaseFullDeleteAuditEntity, IEntitySeqId public int Code { get; set; } + /// + /// 检查名称 + /// + public string StudyName { get; set; } = string.Empty; + public string Description { get; set; } = null!; public int InstanceCount { get; set; } diff --git a/IRaCIS.Core.Domain/Image/NoneDicomStudy.cs b/IRaCIS.Core.Domain/Image/NoneDicomStudy.cs index 7696dca02..df6f5bb2e 100644 --- a/IRaCIS.Core.Domain/Image/NoneDicomStudy.cs +++ b/IRaCIS.Core.Domain/Image/NoneDicomStudy.cs @@ -19,6 +19,11 @@ public class NoneDicomStudy : BaseFullAuditEntity #endregion public string StudyCode { get; set; } = string.Empty; + /// + /// 检查名称 + /// + public string StudyName { get; set; } = string.Empty; + public int FileCount { get; set; } public int Code { get; set; } diff --git a/IRaCIS.Core.Domain/Trial/Trial.cs b/IRaCIS.Core.Domain/Trial/Trial.cs index f32bcb561..c1687b161 100644 --- a/IRaCIS.Core.Domain/Trial/Trial.cs +++ b/IRaCIS.Core.Domain/Trial/Trial.cs @@ -170,7 +170,7 @@ public partial class Trial : BaseFullDeleteAuditEntity [Comment("阅片方式")] public int ReadingMode { get; set; } = 1; - public int ChangeDefalutDays { get; set; } = 5; + public int ChangeDefalutDays { get; set; } = 7; [Comment("跨项目复制")] public bool IsImageReplicationAcrossTrial { get; set; } = false; @@ -240,6 +240,25 @@ public partial class Trial : BaseFullDeleteAuditEntity public string VitrualSiteCode { get; set; } = string.Empty; + #region 检查相关新加字段 + + /// + /// 是否显示检查名称 + /// + public bool IsShowStudyName { get; set; } = false; + + /// + /// 检查名称列表 + /// + public List StudyNameList { get; set; } + + /// + /// 图像格式 + /// + [StringLength(2000)] + public List ImageFormatList { get; set; } = new List() {"jpg","jpeg","png","bmp","pdf","zip" }; + #endregion + #region 邮件配置 [Comment("发件箱账号")] public string EmailFromEmail { get; set; } = string.Empty; @@ -290,6 +309,29 @@ public enum CollectImagesType NoneDicom = 2 } +/// +/// 检查名称 +/// + +[ComplexType] +public class StudyName +{ + /// + /// 是否选中 + /// + public bool IsChoose { get; set; } + + /// + /// 名称 + /// + public string Name { get; set; } + + /// + /// 英文名称 + /// + public string EnName { get; set; } +} + [ComplexType] public class TrialObjectNameConfig { diff --git a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs index 9f9142c6a..e77133622 100644 --- a/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs +++ b/IRaCIS.Core.Infra.EFCore/Context/IRaCISDBContext.cs @@ -84,6 +84,11 @@ public class IRaCISDBContext : DbContext { ownedNavigationBuilder.ToJson(); }); + + entity.OwnsMany(x => x.StudyNameList, ownedNavigationBuilder => + { + ownedNavigationBuilder.ToJson(); + }); }); #region pgsql codefirst 配置 暂时屏蔽