From 758e0aedcb05ef11e45913af62bb48e6bfbc0cbf Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 9 Sep 2025 14:41:04 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE=E7=BB=91?= =?UTF-8?q?=E5=AE=9A=E6=A3=80=E6=9F=A5=E8=AF=BE=E9=A2=98=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IRaCIS.Core.Application/Service/Visit/PatientService.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/IRaCIS.Core.Application/Service/Visit/PatientService.cs b/IRaCIS.Core.Application/Service/Visit/PatientService.cs index 4eeeca0f9..f66f885dd 100644 --- a/IRaCIS.Core.Application/Service/Visit/PatientService.cs +++ b/IRaCIS.Core.Application/Service/Visit/PatientService.cs @@ -1378,9 +1378,12 @@ namespace IRaCIS.Application.Services [TrialGlobalLimit("AfterStopCannNotOpt")] public async Task AutoBindingPatientStudyVisit(AutoBindingPatientStudyVisitCommand inCommand) { + var trialHospitalGroupId = await _trialRepository.Where(t => t.Id == inCommand.TrialId).Select(t => t.HospitalGroupId).FirstOrDefaultAsync(); + //找到已绑定患者,但是没绑定检查的 新来的检查->现在换成未提交的 //var query = from scpStudy in _studyRepository.Where(t => !t.SCPStudySubjectVisitList.Any(t => t.TrialId == inCommand.TrialId)) var query = from scpStudy in _studyRepository.Where(t => !t.SCPStudySubjectVisitList.Any(t => t.TrialId == inCommand.TrialId && t.SubjectVisit.SubmitState == SubmitStateEnum.Submitted)) + .Where(t => t.HospitalGroupList.Any(t => t.HospitalGroupId == trialHospitalGroupId)) join subjectPatient in _subjectPatientRepository.Where(t => t.Subject.TrialId == inCommand.TrialId) on scpStudy.PatientId equals subjectPatient.PatientId select new @@ -1543,8 +1546,11 @@ namespace IRaCIS.Application.Services // 预处理4: 处理需要绑定的检查 //获取 该受试者绑定患者已存在的检查,考虑要生成多少个访视,去除已提交的检查 + var trialHospitalGroupId = await _trialRepository.Where(t => t.Id == inCommand.TrialId).Select(t => t.HospitalGroupId).FirstOrDefaultAsync(); + var studyList = await _studyRepository.Where(t => inCommand.PatientIdList.Contains(t.PatientId) && !t.SCPStudySubjectVisitList.Any(t => t.SubjectId == subjectId && t.SubjectVisit.SubmitState == SubmitStateEnum.Submitted)) + .Where(t => t.HospitalGroupList.Any(t => t.HospitalGroupId == trialHospitalGroupId)) .WhereIf(maxStudyTime != null, t => t.StudyTime > maxStudyTime) .Select(t => new AuToBindingStudyInfo { SCPStudyId = t.Id, StudyTime = t.StudyTime }).OrderBy(t => t.StudyTime).Distinct().ToListAsync(); @@ -1606,8 +1612,11 @@ namespace IRaCIS.Application.Services // 预处理4: 处理需要绑定的检查 //获取 该受试者绑定患者已存在的检查,考虑要生成多少个访视,去除已提交的检查 + var trialHospitalGroupId = await _trialRepository.Where(t => t.Id == inCommand.TrialId).Select(t => t.HospitalGroupId).FirstOrDefaultAsync(); + var studyList = await _studyRepository.Where(t => dbPatientIdList.Contains(t.PatientId) && !t.SCPStudySubjectVisitList.Any(t => t.SubjectId == subjectId && t.SubjectVisit.SubmitState == SubmitStateEnum.Submitted)) + .Where(t => t.HospitalGroupList.Any(t => t.HospitalGroupId == trialHospitalGroupId)) .WhereIf(maxStudyTime != null, t => t.StudyTime > maxStudyTime) .Select(t => new AuToBindingStudyInfo { SCPStudyId = t.Id, StudyTime = t.StudyTime }).OrderBy(t => t.StudyTime).Distinct().ToListAsync();