From f80ac02562658e7249a61ff5c6dc6d98b2d98c73 Mon Sep 17 00:00:00 2001
From: hang <872297557@qq.com>
Date: Tue, 9 Sep 2025 18:00:03 +0800
Subject: [PATCH] =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E8=AF=BE=E9=A2=98=E7=BB=84?=
=?UTF-8?q?=E5=90=AF=E7=94=A8=E7=A6=81=E7=94=A8=EF=BC=8C=E7=B3=BB=E7=BB=9F?=
=?UTF-8?q?=E8=AF=BE=E9=A2=98=E7=BB=84=E5=90=AF=E7=94=A8=E7=A6=81=E7=94=A8?=
=?UTF-8?q?=E5=AE=9E=E6=97=B6=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../IRaCIS.Core.Application.xml | 2 +-
.../Service/Management/UserService.cs | 10 ++-
.../Service/TrialSiteUser/TrialService.cs | 16 +++-
.../Service/Visit/HospitalGroupService.cs | 16 +++-
.../Service/Visit/PatientService.cs | 86 ++++++++++++++++---
5 files changed, 109 insertions(+), 21 deletions(-)
diff --git a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
index c40bcead0..61d9936e1 100644
--- a/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
+++ b/IRaCIS.Core.Application/IRaCIS.Core.Application.xml
@@ -18607,7 +18607,7 @@
-
+
获取 检查列表
diff --git a/IRaCIS.Core.Application/Service/Management/UserService.cs b/IRaCIS.Core.Application/Service/Management/UserService.cs
index 70199c8e7..35b0f99ed 100644
--- a/IRaCIS.Core.Application/Service/Management/UserService.cs
+++ b/IRaCIS.Core.Application/Service/Management/UserService.cs
@@ -461,7 +461,13 @@ namespace IRaCIS.Core.Application.Service
public async Task> GetUserList(UserListQueryDTO inQuery)
{
- var isGAGroupAdmin = _userInfo.HospitalGroupAdminIdList.Any();
+ var currentUserHospitalGroupList = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList)
+ .Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable).Select(t => new { t.HospitalGroupId, t.IsManager }).ToList();
+
+ var hospitalGroupAdminIdList = currentUserHospitalGroupList.Where(t => t.IsManager).Select(t => t.HospitalGroupId).ToList();
+ var hospitalGroupIdList = currentUserHospitalGroupList.Select(t => t.HospitalGroupId).ToList();
+
+ var isGAGroupAdmin = hospitalGroupAdminIdList.Any();
var userQueryable = _identityUserRepository.Where(x => x.UserRoleList.Any(x => x.UserTypeEnum != UserTypeEnum.SuperAdmin))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.UserName), t => t.UserName.Contains(inQuery.UserName))
@@ -486,7 +492,7 @@ namespace IRaCIS.Core.Application.Service
//GA 只能看有该课题组的用户,并且不是admin oa
.WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.GA, t => !t.UserRoleList.Any(t => t.UserTypeEnum == UserTypeEnum.Admin || t.UserTypeEnum == UserTypeEnum.SuperAdmin || t.UserTypeEnum == UserTypeEnum.OA)
- && t.IdentityUserHospitalGroupList.Any(t => isGAGroupAdmin ? _userInfo.HospitalGroupAdminIdList.Contains(t.HospitalGroupId) : false))
+ && t.IdentityUserHospitalGroupList.Any(t => isGAGroupAdmin ? hospitalGroupAdminIdList.Contains(t.HospitalGroupId) : false))
.ProjectTo(_mapper.ConfigurationProvider);
return await userQueryable.ToPagedListAsync(inQuery);
diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs
index a305467a8..827288e03 100644
--- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs
+++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs
@@ -17,6 +17,7 @@ namespace IRaCIS.Core.Application.Service
public class TrialService(IRepository _trialRepository,
IRepository _trialIdentityUserRepository,
+ IRepository _identityUserRepository,
IRepository _croRepository,
IRepository _enrollDetailRepository,
IRepository _dictionaryRepository,
@@ -28,7 +29,7 @@ namespace IRaCIS.Core.Application.Service
IRepository _trialPaymentPriceRepository,
IRepository _trialDictionaryRepository,
IRepository _trialBodyPartRepository,
- IOptionsMonitor _verifyConfig,
+ IOptionsMonitor _verifyConfig,
IMapper _mapper, IUserInfo _userInfo, IStringLocalizer _localizer, IFusionCache _fusionCache) : BaseService, ITrialService
{
@@ -102,6 +103,13 @@ namespace IRaCIS.Core.Application.Service
//过滤废除的项目
public async Task> GetTrialSelect()
{
+ var currentUserHospitalGroupList = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList)
+ .Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable).Select(t => new { t.HospitalGroupId, t.IsManager }).ToList();
+
+ var hospitalGroupAdminIdList = currentUserHospitalGroupList.Where(t => t.IsManager).Select(t => t.HospitalGroupId).ToList();
+ var hospitalGroupIdList = currentUserHospitalGroupList.Select(t => t.HospitalGroupId).ToList();
+
+
// SuperAdmin Admin OP OA
List sap = new List() { (int)UserTypeEnum.SuperAdmin, (int)UserTypeEnum.Admin, (int)UserTypeEnum.OP, (int)UserTypeEnum.OA };
@@ -136,8 +144,8 @@ namespace IRaCIS.Core.Application.Service
&& t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId && t.IsDeleted == false))
&& t.IsDeleted == false)
- // ga
- .WhereIf(ga.Contains(_userInfo.UserTypeEnumInt), t => _userInfo.HospitalGroupIdList.Contains(t.HospitalGroupId)&& trialState.Contains(t.TrialStatusStr))
+ // ga
+ .WhereIf(ga.Contains(_userInfo.UserTypeEnumInt) && hospitalGroupAdminIdList.Any(), t => hospitalGroupAdminIdList.Contains(t.HospitalGroupId) && trialState.Contains(t.TrialStatusStr))
// QA EA
.WhereIf(qAEq.Contains(_userInfo.UserTypeEnumInt), t => t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId && t.IsDeleted == false
@@ -680,7 +688,7 @@ namespace IRaCIS.Core.Application.Service
///
[HttpPost("{trialId:guid}/{status:int}")]
- [TrialGlobalLimit( "AfterStopCannNotOpt" )]
+ [TrialGlobalLimit("AfterStopCannNotOpt")]
public async Task UpdateEnrollStatus(Guid trialId, EnrollStatus status)
{
await _enrollDetailRepository.AddAsync(new EnrollDetail()
diff --git a/IRaCIS.Core.Application/Service/Visit/HospitalGroupService.cs b/IRaCIS.Core.Application/Service/Visit/HospitalGroupService.cs
index 7eee0cd4e..4f565abe6 100644
--- a/IRaCIS.Core.Application/Service/Visit/HospitalGroupService.cs
+++ b/IRaCIS.Core.Application/Service/Visit/HospitalGroupService.cs
@@ -43,14 +43,26 @@ public class HospitalGroupService(IRepository _hospitalGroupRepos
public async Task> GetHospitalGroupList(HospitalGroupQuery inQuery)
{
+ var currentUserHospitalGroupIdList = new List();
+
+ if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager)
+ {
+ currentUserHospitalGroupIdList = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList)
+ .Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable).Select(t => t.HospitalGroupId).ToList();
+ }
+ else if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.GA)
+ {
+ currentUserHospitalGroupIdList = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList)
+ .Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable && t.IsManager).Select(t => t.HospitalGroupId).ToList();
+ }
+
var hospitalGroupQueryable = _hospitalGroupRepository.Where(t => t.IsEnable == true)//都是查询启用的
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Code), t => t.Code.Contains(inQuery.Code))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Name), t => t.Name.Contains(inQuery.Name))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.Affiliation), t => t.Affiliation.Contains(inQuery.Affiliation))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ContactPhone), t => t.ContactPhone.Contains(inQuery.ContactPhone))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ContactName), t => t.ContactName.Contains(inQuery.ContactName))
- .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager, t => _userInfo.HospitalGroupIdList.Contains(t.Id))
- .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.GA, t => _userInfo.HospitalGroupAdminIdList.Contains(t.Id))
+ .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ProjectManager || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.GA, t => currentUserHospitalGroupIdList.Contains(t.Id))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.CallingAE), t => t.CallingAE.Contains(inQuery.CallingAE))
//.WhereIf(inQuery.IsEnable != null, t => t.IsEnable == inQuery.IsEnable)
.ProjectTo(_mapper.ConfigurationProvider);
diff --git a/IRaCIS.Core.Application/Service/Visit/PatientService.cs b/IRaCIS.Core.Application/Service/Visit/PatientService.cs
index 51f0055be..ce21ba603 100644
--- a/IRaCIS.Core.Application/Service/Visit/PatientService.cs
+++ b/IRaCIS.Core.Application/Service/Visit/PatientService.cs
@@ -51,6 +51,7 @@ namespace IRaCIS.Application.Services
[ApiExplorerSettings(GroupName = "HIR")]
public class PatientService(IRepository _studySubjectVisitRepository,
IRepository _trialIdentityUserRepository,
+ IRepository _identityUserRepository,
IRepository _subjectPatientRepository, IRepository _SCPStudyHospitalGroupRepository,
IRepository _trialRepository,
IRepository _cmoveStudyRepository,
@@ -201,6 +202,14 @@ namespace IRaCIS.Application.Services
{
var hospitalInfo = await _fusionCache.GetOrSetAsync(CacheKeys.Hospital, _ => CacheHelper.GetHospitalCode(_hIRHospitalRepository), TimeSpan.FromDays(7));
+
+ var currentUserHospitalGroupList = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList)
+ .Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable).Select(t => new { t.HospitalGroupId, t.IsManager }).ToList();
+
+ var hospitalGroupAdminIdList = currentUserHospitalGroupList.Where(t => t.IsManager).Select(t => t.HospitalGroupId).ToList();
+ var hospitalGroupIdList = currentUserHospitalGroupList.Select(t => t.HospitalGroupId).ToList();
+
+
var trialQuery = _trialRepository
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ResearchProgramNo), t => t.ResearchProgramNo.Contains(inQuery.ResearchProgramNo))
.WhereIf(!string.IsNullOrWhiteSpace(inQuery.ExperimentName), t => t.ExperimentName.Contains(inQuery.ExperimentName))
@@ -211,10 +220,10 @@ namespace IRaCIS.Application.Services
//过滤医院,切换会有问题
.Where(t => t.HospitalId == hospitalInfo.Id)
//GA 要过滤课题组
- .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.GA && _userInfo.HospitalGroupAdminIdList.Any(), t => _userInfo.HospitalGroupAdminIdList.Contains(t.HospitalGroupId))
+ .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.GA && hospitalGroupAdminIdList.Any(), t => hospitalGroupAdminIdList.Contains(t.HospitalGroupId))
.WhereIf(_userInfo.UserTypeEnumInt != (int)UserTypeEnum.SuperAdmin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.Admin && _userInfo.UserTypeEnumInt != (int)UserTypeEnum.OA
- && !(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.GA && _userInfo.HospitalGroupAdminIdList.Any())
- , t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId) && t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId) && _userInfo.HospitalGroupIdList.Contains(t.HospitalGroupId))
+ && !(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.GA && hospitalGroupAdminIdList.Any())
+ , t => t.TrialUserRoleList.Any(t => t.UserId == _userInfo.UserRoleId) && t.TrialIdentityUserList.Any(t => t.IdentityUserId == _userInfo.IdentityUserId) && hospitalGroupIdList.Contains(t.HospitalGroupId))
.ProjectTo(_mapper.ConfigurationProvider);
@@ -624,7 +633,14 @@ namespace IRaCIS.Application.Services
var isAdminOrOA = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.Admin || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.OA || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin;
- var currentUserHospitalGroupIdList = _userInfo.HospitalGroupList.Select(t => t.Id).ToList();
+
+ var currentUserHospitalGroupIdList = new List();
+
+ if (!isAdminOrOA)
+ {
+ currentUserHospitalGroupIdList = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList)
+ .Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable).Select(t => t.HospitalGroupId).ToList();
+ }
#region new ok
var query = _patientRepository.Where(t => isAdminOrOA ? true : t.SCPStudyList.Any(c => c.HospitalGroupList.Any(c => currentUserHospitalGroupIdList.Contains(c.HospitalGroupId))))
@@ -689,7 +705,14 @@ namespace IRaCIS.Application.Services
}
else
{
- item.CurrentUserHospitalGroupList = _userInfo.HospitalGroupList.Select(t => t.Name).ToList();
+
+ var list = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList).Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable == true)
+ .Select(t => t.HospitalGroup.Name).ToList();
+
+
+ item.CurrentUserHospitalGroupList = list;
+
+ //item.CurrentUserHospitalGroupList = _userInfo.HospitalGroupList.Select(t => t.Name).ToList();
}
}
@@ -778,7 +801,13 @@ namespace IRaCIS.Application.Services
{
var isAdminOrOA = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.Admin || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.OA || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin;
- var currentUserHospitalGroupIdList = _userInfo.HospitalGroupList.Select(t => t.Id).ToList();
+ var currentUserHospitalGroupIdList = new List();
+
+ if (!isAdminOrOA)
+ {
+ currentUserHospitalGroupIdList = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList)
+ .Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable).Select(t => t.HospitalGroupId).ToList();
+ }
var query = from scpStudy in _studyRepository.Where(t => t.PatientId == inQuery.PatientId)
.Where(t => isAdminOrOA ? true : t.HospitalGroupList.Any(c => currentUserHospitalGroupIdList.Contains(c.HospitalGroupId)))
@@ -819,7 +848,13 @@ namespace IRaCIS.Application.Services
}
else
{
- item.CurrentUserHospitalGroupList = _userInfo.HospitalGroupList.Select(t => new HospitalGroupInfo() { Id = t.Id, Code = t.Code, Name = t.Name, IsManager = t.IsManager }).ToList();
+ var list = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList).Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable == true)
+ .Select(t => new HospitalGroupInfo() { Code = t.HospitalGroup.Code, Id = t.Id, Name = t.HospitalGroup.Name, IsManager = t.IsManager }).ToList();
+
+ item.CurrentUserHospitalGroupList = list;
+
+
+ //item.CurrentUserHospitalGroupList = _userInfo.HospitalGroupList.Select(t => new HospitalGroupInfo() { Id = t.Id, Code = t.Code, Name = t.Name, IsManager = t.IsManager }).ToList();
}
}
@@ -941,6 +976,7 @@ namespace IRaCIS.Application.Services
[HttpDelete]
public async Task DeletePatientStudy(Guid patiendId, Guid scpStudyId,
[FromServices] IRepository _SeriesRepository,
+ [FromServices] IRepository _identityUserRepository,
[FromServices] IRepository _instanceRepository,
[FromServices] IRepository _scpStudyHospitalGroupRepository)
{
@@ -950,18 +986,38 @@ namespace IRaCIS.Application.Services
var isAdminOrOAOrGA = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.Admin || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.OA
|| _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.GA;
+
+ var currentPMHospitalGroupIdList = _identityUserRepository.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList)
+ .Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable == true).Select(t => t.HospitalGroupId).ToList();
+
// abc 课题组,人属于AB 课题组,删除仅仅删除这个标签 直接返回
- if (!isAdminOrOAOrGA && existList.Count > _userInfo.HospitalGroupList.Count)
+ if (!isAdminOrOAOrGA && existList.Count >= currentPMHospitalGroupIdList.Count)
{
+ //同课题组其他项目绑定了,那么这个绑定关系也不能删除
+
+
+ //这个检查 已经在该人所属课题组的项目,进行了绑定访视,(不管是不是当前PM的项目) 那么就不允许删除课题组关系和影像
+ if (_studySubjectVisitRepository.Any(t => t.SCPStudyId == scpStudyId && currentPMHospitalGroupIdList.Contains(t.Subject.Trial.HospitalGroupId)))
+ {
+ return ResponseOutput.NotOk(_localizer["Patient_SCPStudyVisitBindedSubmit"]);
+ }
+
+ //这个检查 已经在该人所属课题组的项目,没有进行绑定访视 那么就允许删除课题组关系
+ if (!_studySubjectVisitRepository.Any(t => t.SCPStudyId == scpStudyId && currentPMHospitalGroupIdList.Contains(t.Subject.Trial.HospitalGroupId)))
+ {
+
+ await _scpStudyHospitalGroupRepository.BatchDeleteNoTrackingAsync(t => t.SCPStudyId == scpStudyId && currentPMHospitalGroupIdList.Contains(t.HospitalGroupId));
+ return ResponseOutput.Ok();
+
+ }
- await _scpStudyHospitalGroupRepository.BatchDeleteNoTrackingAsync(t => t.SCPStudyId == scpStudyId && _userInfo.HospitalGroupIdList.Contains(t.HospitalGroupId));
- return ResponseOutput.Ok();
}
+ //不属于任何项目,那么删除所有影像和绑定关系
- if (_studySubjectVisitRepository.Any(t => t.SCPStudyId == scpStudyId && t.StudyId != null))
+ if (_studySubjectVisitRepository.Any(t => t.SCPStudyId == scpStudyId))
{
//"该检查已绑定某项目下受试者访视(不一定是你所创建的项目)并已提交生成任务,不允许删除该检查"
return ResponseOutput.NotOk(_localizer["Patient_SCPStudyVisitBindedSubmit"]);
@@ -3316,6 +3372,7 @@ namespace IRaCIS.Application.Services
[HttpPost]
public async Task>> GetCFindStudyList(SCUQuery inQuery,
[FromServices] IRepository _dicomAEReposiotry,
+ [FromServices] IRepository _identityUserReposiotry,
[FromServices] ILogger _logger)
{
@@ -3561,7 +3618,12 @@ namespace IRaCIS.Application.Services
}
else
{
- item.CurrentUserHospitalGroupList = _userInfo.HospitalGroupList.Select(t => new HospitalGroupInfo() { Code = t.Code, Id = t.Id, Name = t.Name, IsManager = t.IsManager }).ToList();
+ var list = _identityUserReposiotry.Where(t => t.Id == _userInfo.IdentityUserId).SelectMany(t => t.IdentityUserHospitalGroupList).Where(t => t.IsDisabled == false && t.HospitalGroup.IsEnable == true)
+ .Select(t => new HospitalGroupInfo() { Code = t.HospitalGroup.Code, Id = t.Id, Name = t.HospitalGroup.Name, IsManager = t.IsManager }).ToList();
+
+ item.CurrentUserHospitalGroupList = list;
+
+ //item.CurrentUserHospitalGroupList = _userInfo.HospitalGroupList.Select(t => new HospitalGroupInfo() { Code = t.Code, Id = t.Id, Name = t.Name, IsManager = t.IsManager }).ToList();
}
}