diff --git a/IRaCIS.Core.Application/Service/Visit/PatientService.cs b/IRaCIS.Core.Application/Service/Visit/PatientService.cs index bcc9681ee..066fa7c26 100644 --- a/IRaCIS.Core.Application/Service/Visit/PatientService.cs +++ b/IRaCIS.Core.Application/Service/Visit/PatientService.cs @@ -3303,6 +3303,18 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task GetDownloadPatientStudyInfo(PatientImageDownloadCommand inCommand) { + var isAdminOrOA = _userInfo.UserTypeEnumInt == (int)UserTypeEnum.Admin || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.OA || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.SuperAdmin; + + + 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 patientIdList = inCommand.PatientIdList.Distinct().ToList(); var studyIdList = inCommand.SCPStudyIdList.Distinct().ToList(); @@ -3316,6 +3328,7 @@ namespace IRaCIS.Application.Services { var list = _patientRepository.Where(t => patientIdList.Contains(t.Id)) .SelectMany(t => t.SCPStudyList.Where(t => studyIdList.Count > 0 ? studyIdList.Contains(t.Id) : true)) + .Where(t => isAdminOrOA ? true : t.HospitalGroupList.Any(c => currentUserHospitalGroupIdList.Contains(c.HospitalGroupId))) .SelectMany(t => t.InstanceList) .Select(t => new StudyDIRInfo() {