diff --git a/IRaCIS.Core.Application/Service/Visit/PatientService.cs b/IRaCIS.Core.Application/Service/Visit/PatientService.cs index ac3eceb09..e7945cfad 100644 --- a/IRaCIS.Core.Application/Service/Visit/PatientService.cs +++ b/IRaCIS.Core.Application/Service/Visit/PatientService.cs @@ -139,7 +139,7 @@ namespace IRaCIS.Application.Services { var exp = new EntityVerifyExp() { - VerifyExp = h => h.IsDefault.Equals(addOrEditHIRHospital.IsDefault), + VerifyExp = h => h.IsDefault.Equals(addOrEditHIRHospital.IsDefault) && addOrEditHIRHospital.IsDefault = true, //"默认医院只允许一个" VerifyMsg = _localizer["Patient_OnlyOneDefaultHospital"] @@ -662,7 +662,7 @@ namespace IRaCIS.Application.Services }; - var allHospitalGroupList = _hospitalGroupRepository.Where(t => t.IsEnable).Select(t => t.Name).ToList(); + var allHospitalGroupList = _hospitalGroupRepository.Where(t => t.IsEnable).Select(t => t.Name).ToList(); var pageList = await resultQuery.ToPagedListAsync(inQuery, nameof(PatientQueryView.PatientIdStr)); @@ -794,7 +794,7 @@ namespace IRaCIS.Application.Services var pageList = await query.ToPagedListAsync(inQuery, nameof(PatientStudySimpleView.StudyTime)); - var allHospitalGroupList= _hospitalGroupRepository.Where(t=>t.IsEnable).Select(t=> new HospitalGroupInfo() { Id = t.Id, Code = t.Code, Name = t.Name }).ToList(); + var allHospitalGroupList = _hospitalGroupRepository.Where(t => t.IsEnable).Select(t => new HospitalGroupInfo() { Id = t.Id, Code = t.Code, Name = t.Name }).ToList(); foreach (var item in pageList.CurrentPageData) { @@ -828,7 +828,10 @@ namespace IRaCIS.Application.Services { foreach (var hospitalGroupId in incommand.HospitalGroupIdList) { - await _SCPStudyHospitalGroupRepository.AddAsync(new SCPStudyHospitalGroup() { SCPStudyId = item, HospitalGroupId = hospitalGroupId }); + if (!_SCPStudyHospitalGroupRepository.Any(t => t.SCPStudyId == item && hospitalGroupId == t.HospitalGroupId)) + { + await _SCPStudyHospitalGroupRepository.AddAsync(new SCPStudyHospitalGroup() { SCPStudyId = item, HospitalGroupId = hospitalGroupId }); + } } @@ -844,7 +847,6 @@ namespace IRaCIS.Application.Services { await _SCPStudyHospitalGroupRepository.DeleteFromQueryAsync(t => t.HospitalGroupId == hospitalGroupId && t.SCPStudyId == item); - }