diff --git a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs index e39cfc363..309a69f63 100644 --- a/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs +++ b/IRaCIS.Core.API/Controllers/UploadDownLoadController.cs @@ -492,7 +492,7 @@ namespace IRaCIS.Core.API.Controllers studyMonitor.IP = _userInfo.IP; studyMonitor.IsSuccess = true; - await _repository.SaveChangesAsync(); + await _noneDicomStudyRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Application/Helper/CacheHelper.cs b/IRaCIS.Core.Application/Helper/CacheHelper.cs index 8198049df..87248465a 100644 --- a/IRaCIS.Core.Application/Helper/CacheHelper.cs +++ b/IRaCIS.Core.Application/Helper/CacheHelper.cs @@ -42,9 +42,9 @@ namespace IRaCIS.Core.Application.Helper return statusStr; } - public static async Task> GetSystemAnonymizationListAsync(IRepository _repository) + public static async Task> GetSystemAnonymizationListAsync(IRepository _systemAnonymizationRepository) { - var list = await _repository.Where(t => t.IsEnable).ToListAsync(); + var list = await _systemAnonymizationRepository.Where(t => t.IsEnable).ToListAsync(); return list; } diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs index facd2ed87..83d1bb3cf 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskService.cs @@ -48,6 +48,10 @@ namespace IRaCIS.Core.Application.Service.Allocation IRepository _dicomInstanceRepository, IRepository _dicomSeriesRepository, IRepository _subjectCanceDoctorRepository, + IRepository _readingTaskQuestionMarkRepository, + IRepository _readingTableAnswerRowInfoRepository, + IRepository _readingCustomTagRepository, + IRepository _taskInfluenceRepository, IRepository _trialQCQuestionAnswerRepository, IRepository _subjectCriteriaEvaluationVisitStudyFilterRepository) : BaseService, IVisitTaskService { @@ -1561,7 +1565,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { if (await _visitTaskRepository.AnyAsync(t => t.IsAnalysisCreate && t.SubjectId == subjectId)) { - await _repository.UpdatePartialFromQueryAsync(t => t.Id == subjectId, u => new Subject() { IsReReadingOrBackInfluenceAnalysis = true }); + await _subjectRepository.UpdatePartialFromQueryAsync(t => t.Id == subjectId, u => new Subject() { IsReReadingOrBackInfluenceAnalysis = true }); } @@ -2156,7 +2160,7 @@ namespace IRaCIS.Core.Application.Service.Allocation { //自定义 - var readingCustomTagList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + var readingCustomTagList = _readingCustomTagRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); foreach (var item in readingCustomTagList) { @@ -2164,10 +2168,10 @@ namespace IRaCIS.Core.Application.Service.Allocation item.VisitTaskId = newTask.Id; } - _ = _repository.AddRangeAsync(readingCustomTagList).Result; + _ = _readingCustomTagRepository.AddRangeAsync(readingCustomTagList).Result; - var readingTaskQuestionMarkList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); + var readingTaskQuestionMarkList = _readingTaskQuestionMarkRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); foreach (var item in readingTaskQuestionMarkList) { @@ -2175,7 +2179,7 @@ namespace IRaCIS.Core.Application.Service.Allocation item.VisitTaskId = newTask.Id; } - _ = _repository.AddRangeAsync(readingTaskQuestionMarkList).Result; + _ = _readingTaskQuestionMarkRepository.AddRangeAsync(readingTaskQuestionMarkList).Result; var readingTaskQuestionAnswerList = _readingTaskQuestionAnswerRepository.Where(t => t.VisitTaskId == origenalTask.Id).ToList(); @@ -2184,12 +2188,12 @@ namespace IRaCIS.Core.Application.Service.Allocation item.Id = Guid.Empty; item.VisitTaskId = newTask.Id; } - _ = _repository.AddRangeAsync(readingTaskQuestionAnswerList).Result; + _ = _readingTaskQuestionAnswerRepository.AddRangeAsync(readingTaskQuestionAnswerList).Result; //ReadingTableAnswerRowInfo ReadingTableQuestionAnswer 一起加 - var readingTableAnswerRowInfoList = _repository.Where(t => t.VisitTaskId == origenalTask.Id).Include(t => t.LesionAnswerList).ToList(); + var readingTableAnswerRowInfoList = _readingTableAnswerRowInfoRepository.Where(t => t.VisitTaskId == origenalTask.Id).Include(t => t.LesionAnswerList).ToList(); foreach (var item in readingTableAnswerRowInfoList) { @@ -2212,7 +2216,7 @@ namespace IRaCIS.Core.Application.Service.Allocation } } - _ = _repository.AddRangeAsync(readingTableAnswerRowInfoList).Result; + _ = _readingTableAnswerRowInfoRepository.AddRangeAsync(readingTableAnswerRowInfoList).Result; @@ -2876,7 +2880,7 @@ namespace IRaCIS.Core.Application.Service.Allocation /// public async Task> GetInfluencedTaskList(Guid taskId) { - var list = await _repository.Where(t => t.OriginalTaskId == taskId)/*.Select(t => t.InfluenceTask)*/.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + var list = await _taskInfluenceRepository.Where(t => t.OriginalTaskId == taskId)/*.Select(t => t.InfluenceTask)*/.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); return list; } diff --git a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs index 9b0689521..c206ca82e 100644 --- a/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs +++ b/IRaCIS.Core.Application/Service/Common/ExcelExportService.cs @@ -35,9 +35,12 @@ namespace IRaCIS.Core.Application.Service.Common IRepository _systemDocNeedConfirmedUserTypeRepository, IRepository _dicomStudyRepository, IRepository _qcChallengeRepository, + IRepository _readModuleRepository, IRepository _noneDicomStudyRepository, + IRepository _studyMonitorRepository, IRepository _commonDocumentRepository, IRepository _systemDocConfirmedUserRepository, + IRepository _trialDocNeedConfirmedUserTypeRepository, IRepository _trialDocConfirmedUserRepository, IRepository _subjectRepository) : BaseService { @@ -347,7 +350,7 @@ namespace IRaCIS.Core.Application.Service.Common { var trialInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstNotNullAsync()); - var trialDocQuery = from trialDocumentNeedConfirmedUserType in _repository.Where(t => t.TrialDocument.TrialId == inQuery.TrialId) + var trialDocQuery = from trialDocumentNeedConfirmedUserType in _trialDocNeedConfirmedUserTypeRepository.Where(t => t.TrialDocument.TrialId == inQuery.TrialId) join trialUser in _trialUserRepository.Where(t => t.TrialId == inQuery.TrialId) .WhereIf(inQuery.UserId != null, t => t.UserId == inQuery.UserId) .WhereIf(inQuery.UserTypeId != null, t => t.User.UserTypeId == inQuery.UserTypeId) @@ -808,7 +811,7 @@ namespace IRaCIS.Core.Application.Service.Common { var svExpression = QCCommon.GetStudyMonitorSubjectVisitFilter(inQuery.VisitPlanArray); - var StudyMonitorQuery = _repository.Where(t => t.TrialId == inQuery.TrialId, ignoreQueryFilters: true) + var StudyMonitorQuery = _studyMonitorRepository.Where(t => t.TrialId == inQuery.TrialId, ignoreQueryFilters: true) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.Subject.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) //.WhereIf(!string.IsNullOrEmpty(studyQuery.VisitPlanInfo), studyQuery.VisitPlanInfo.Contains('.') ? t => t.SubjectVisit.VisitNum.ToString().Contains(".") : t => t.SubjectVisit.VisitNum == decimal.Parse(studyQuery.VisitPlanInfo)) .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) @@ -889,7 +892,7 @@ namespace IRaCIS.Core.Application.Service.Common [FromServices] IRepository _trialRepository) { - var list = await _repository.Where(u => u.TrialId == param.TrialId) + var list = await _readModuleRepository.Where(u => u.TrialId == param.TrialId) .ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); diff --git a/IRaCIS.Core.Application/Service/Common/MailService.cs b/IRaCIS.Core.Application/Service/Common/MailService.cs index 4d37789c0..c9b05b161 100644 --- a/IRaCIS.Core.Application/Service/Common/MailService.cs +++ b/IRaCIS.Core.Application/Service/Common/MailService.cs @@ -57,7 +57,9 @@ namespace IRaCIS.Application.Services IRepository _verificationCodeRepository, IRepository _systemBasicDatarepository, IRepository _visitTaskRepository, + IRepository _trialSiteRepository, IRepository _userRepository, + IRepository _userFeedBackRepository, ITokenService _tokenService, IRepository _subjectVisitRepository, IRepository _trialRepository, @@ -356,7 +358,7 @@ namespace IRaCIS.Application.Services var trialInfo = await _trialRepository.FirstOrDefaultAsync(t => t.Id == trialSiteSurvey.TrialId); - var siteInfo = await _repository.FirstOrDefaultAsync(t => t.TrialId == trialSiteSurvey.TrialId && t.Id == trialSiteSurvey.TrialSiteId, true); + var siteInfo = await _trialSiteRepository.FirstOrDefaultAsync(t => t.TrialId == trialSiteSurvey.TrialId && t.Id == trialSiteSurvey.TrialSiteId, true); var companyName = _userInfo.IsEn_Us ? _systemEmailConfig.CompanyShortName : _systemEmailConfig.CompanyShortNameCN; @@ -721,7 +723,7 @@ namespace IRaCIS.Application.Services public async Task UserFeedBackMail(Guid feedBackId) { - var feedBack = await _repository.Where(t => t.Id == feedBackId).Include(t => t.CreateUser).ThenInclude(t => t.UserTypeRole).FirstNotNullAsync(); + var feedBack = await _userFeedBackRepository.Where(t => t.Id == feedBackId).Include(t => t.CreateUser).ThenInclude(t => t.UserTypeRole).FirstNotNullAsync(); var messageToSend = new MimeMessage(); //发件地址 diff --git a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs index e9fd44333..598a16889 100644 --- a/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/AttachmentService.cs @@ -159,8 +159,8 @@ namespace IRaCIS.Application.Services var newAttachment = attachments.Where(t => t.Id == Guid.Empty); - await _repository.AddRangeAsync(newAttachment); - await _repository.SaveChangesAsync(); + await _attachmentrepository.AddRangeAsync(newAttachment); + await _attachmentrepository.SaveChangesAsync(); //_doctorAttachmentRepository.AddRange(newAttachment); //_doctorAttachmentRepository.SaveChanges(); @@ -185,7 +185,7 @@ namespace IRaCIS.Application.Services } await _attachmentrepository.AddAsync(newAttachment); - var success = await _repository.SaveChangesAsync(); + var success = await _attachmentrepository.SaveChangesAsync(); return ResponseOutput.Result(success, attachment); } @@ -214,15 +214,14 @@ namespace IRaCIS.Application.Services [HttpPost("{doctorId:guid}/{attachmentId:guid}/{language}")] public async Task SetOfficial(Guid doctorId, Guid attachmentId, int language) { - var resumeList = await _attachmentrepository.Where(t => t.DoctorId == doctorId && t.Type == "Resume" && t.Language == language).ToListAsync(); + var resumeList = await _attachmentrepository.Where(t => t.DoctorId == doctorId && t.Type == "Resume" && t.Language == language,true).ToListAsync(); foreach (var item in resumeList) { if (item.Id == attachmentId) item.IsOfficial = true; else item.IsOfficial = false; - await _repository.UpdateAsync(item); } - return ResponseOutput.Result(await _repository.SaveChangesAsync()); + return ResponseOutput.Result(await _attachmentrepository.SaveChangesAsync()); } /// diff --git a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs index 9ac5f36f1..50cdd9746 100644 --- a/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/DoctorService.cs @@ -16,6 +16,7 @@ namespace IRaCIS.Application.Services IRepository _attachmentRepository, IRepository _doctorCriterionFileRepository, IRepository _trialRepository, + IRepository _vacationRepository, IRepository _trialExtRepository ) : BaseService, IDoctorService { @@ -72,7 +73,7 @@ namespace IRaCIS.Application.Services //await _repository.AddAsync(new UserDoctor() { DoctorId = doctor.Id, UserId = _userInfo.Id }); //_userDoctorRepository.Add(new UserDoctor() { DoctorId = doctor.Id, UserId = _userInfo.Id }); - var success = await _repository.SaveChangesAsync(); + var success = await _doctorDictionaryRepository.SaveChangesAsync(); return ResponseOutput.Result(success, _mapper.Map(doctor)); } @@ -103,11 +104,11 @@ namespace IRaCIS.Application.Services //重新插入新的 Title记录 updateModel.TitleIds.ForEach(titleId => adddata.Add(new DoctorDictionary() { DoctorId = updateModel.Id.Value, KeyName = StaticData.Title, DictionaryId = titleId })); - await _repository.AddRangeAsync(adddata); + await _doctorDictionaryRepository.AddRangeAsync(adddata); _mapper.Map(basicInfoModel, doctor); - var success = await _repository.SaveChangesAsync(); + var success = await _doctorDictionaryRepository.SaveChangesAsync(); return ResponseOutput.Result(success, basicInfoModel); @@ -296,7 +297,7 @@ namespace IRaCIS.Application.Services #endregion - var entity = await _repository.InsertOrUpdateAsync(doctorWorkInfoModel, true); + var entity = await _doctorRepository.InsertOrUpdateAsync(doctorWorkInfoModel, true); return ResponseOutput.Ok(); @@ -389,11 +390,11 @@ namespace IRaCIS.Application.Services DictionaryId = subspecialityId })); - await _repository.AddRangeAsync(adddata); + await _doctorDictionaryRepository.AddRangeAsync(adddata); _mapper.Map(specialtyUpdateModel, doctor); - var success = await _repository.SaveChangesAsync(); + var success = await _doctorDictionaryRepository.SaveChangesAsync(); return ResponseOutput.Result(success); @@ -519,7 +520,7 @@ namespace IRaCIS.Application.Services var doctor = (await _doctorRepository .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(t => t.Id == doctorId)).IfNullThrowException(); - doctor.InHoliday = (await _repository.CountAsync(x => x.DoctorId == doctorId && x.EndDate <= appDateTimeNow && x.StartDate <= appDateTimeNow)) > 0; + doctor.InHoliday = (await _vacationRepository.CountAsync(x => x.DoctorId == doctorId && x.EndDate <= appDateTimeNow && x.StartDate <= appDateTimeNow)) > 0; return doctor; } diff --git a/IRaCIS.Core.Application/Service/Doctor/EducationService.cs b/IRaCIS.Core.Application/Service/Doctor/EducationService.cs index a72dccbcd..5f12ce29d 100644 --- a/IRaCIS.Core.Application/Service/Doctor/EducationService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/EducationService.cs @@ -59,7 +59,7 @@ namespace IRaCIS.Application.Services break; } await _educationRepository.AddAsync(doctorEducationInfo); - var success = await _repository.SaveChangesAsync(); + var success = await _educationRepository.SaveChangesAsync(); return ResponseOutput.Result(success, doctorEducationInfo.Id.ToString()); } @@ -72,7 +72,7 @@ namespace IRaCIS.Application.Services _mapper.Map(educationInfoViewModel, needUpdate); - var success = await _repository.SaveChangesAsync(); + var success = await _educationRepository.SaveChangesAsync(); return ResponseOutput.Ok(success); @@ -114,7 +114,7 @@ namespace IRaCIS.Application.Services //} #endregion - var entity = await _repository.InsertOrUpdateAsync(postgraduateViewModel, true); + var entity = await _postgraduateRepository.InsertOrUpdateAsync(postgraduateViewModel, true); return ResponseOutput.Ok(entity.Id); } /// diff --git a/IRaCIS.Core.Application/Service/Doctor/ResearchPublicationService.cs b/IRaCIS.Core.Application/Service/Doctor/ResearchPublicationService.cs index b7cf597f7..97a0f2ef4 100644 --- a/IRaCIS.Core.Application/Service/Doctor/ResearchPublicationService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/ResearchPublicationService.cs @@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc; namespace IRaCIS.Application.Services { [ApiExplorerSettings(GroupName = "Reviewer")] - public class ResearchPublicationService(IRepository researchPublicationRepository) : BaseService, IResearchPublicationService + public class ResearchPublicationService(IRepository _researchPublicationRepository) : BaseService, IResearchPublicationService { @@ -17,7 +17,7 @@ namespace IRaCIS.Application.Services [HttpGet("{doctorId:guid}")] public async Task GetResearchPublication(Guid doctorId) { - var doctorScientificResearchInfo = await researchPublicationRepository.Where(o => o.DoctorId == doctorId) + var doctorScientificResearchInfo = await _researchPublicationRepository.Where(o => o.DoctorId == doctorId) .ProjectTo(_mapper.ConfigurationProvider).FirstOrDefaultAsync(); return doctorScientificResearchInfo!; @@ -28,7 +28,7 @@ namespace IRaCIS.Application.Services public async Task AddOrUpdateResearchPublication(ResearchPublicationDTO param) { - var entity = await _repository.InsertOrUpdateAsync(param, true); + var entity = await _researchPublicationRepository.InsertOrUpdateAsync(param, true); return ResponseOutput.Ok(entity.Id); } diff --git a/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs b/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs index 6591d0663..6fd328a0b 100644 --- a/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/TrialExperienceService.cs @@ -82,17 +82,15 @@ namespace IRaCIS.Application.Services await _trialExperienceCriteriaRepository.AddRangeAsync(criteriaList); - var success = await _repository.SaveChangesAsync(); + var success = await _trialExperienceCriteriaRepository.SaveChangesAsync(); return ResponseOutput.Result(success, trialExperience.Id); } else { - var needUpdate = await _trialExperienceRepository.FirstOrDefaultAsync(t => t.Id == trialExperienceViewModel.Id); + var needUpdate = trialExperienceViewModel; - if (needUpdate == null) return Null404NotFound(needUpdate); - _mapper.Map(trialExperienceViewModel, needUpdate); - await _repository.UpdateAsync(needUpdate); + await _trialExperienceRepository.UpdateFromDTOAsync(trialExperienceViewModel); await _trialExperienceCriteriaRepository.BatchDeleteNoTrackingAsync(t => t.TrialExperienceId == needUpdate.Id); @@ -102,13 +100,13 @@ namespace IRaCIS.Application.Services { DoctorId = trialExperienceViewModel.DoctorId, EvaluationCriteriaId = t, - TrialExperienceId = needUpdate.Id + TrialExperienceId = needUpdate.Id.Value })); - await _repository.AddRangeAsync(criteriaList); + await _trialExperienceCriteriaRepository.AddRangeAsync(criteriaList); - var success = await _repository.SaveChangesAsync(); + var success = await _trialExperienceCriteriaRepository.SaveChangesAsync(); return ResponseOutput.Result(success, trialExperienceViewModel.Id); } } diff --git a/IRaCIS.Core.Application/Service/Doctor/VacationService.cs b/IRaCIS.Core.Application/Service/Doctor/VacationService.cs index 1cb5489ab..dff6bd463 100644 --- a/IRaCIS.Core.Application/Service/Doctor/VacationService.cs +++ b/IRaCIS.Core.Application/Service/Doctor/VacationService.cs @@ -23,7 +23,7 @@ namespace IRaCIS.Application.Services { var result = await _vacationRepository.AddAsync(_mapper.Map(param)); - var success = await _repository.SaveChangesAsync(); + var success = await _vacationRepository.SaveChangesAsync(); return ResponseOutput.Result(success, result.Id); diff --git a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs index a1f2d1e69..8e13c0287 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialDocumentService.cs @@ -26,6 +26,7 @@ namespace IRaCIS.Core.Application.Services ISystemDocumentService _systemDocumentService, IRepository _systemDocConfirmedUserRepository, IRepository _systemDocNeedConfirmedUserTypeRepository, + IRepository _trialDocNeedConfirmedUserTypeRepository, IRepository _systemDocumentRepository, IRepository _trialUserRepository, IRepository _trialDocConfirmedUserRepository, @@ -223,7 +224,7 @@ namespace IRaCIS.Core.Application.Services var trialInfo = await ( _trialRepository.Where(t => t.Id == inQuery.TrialId, ignoreQueryFilters: true).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstNotNullAsync()); //系统文档查询 - var systemDocumentQueryable = from needConfirmedUserType in _repository.Where(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId) + var systemDocumentQueryable = from needConfirmedUserType in _systemDocNeedConfirmedUserTypeRepository.Where(t => t.NeedConfirmUserTypeId == _userInfo.UserTypeId) //.Where(u => u.UserTypeRole.UserList.SelectMany(cc => cc.UserTrials.Where(t => t.TrialId == querySystemDocument.TrialId)).Any(e => e.Trial.TrialFinishedTime < u.SystemDocument.CreateTime)) .WhereIf(trialInfo.TrialFinishedTime != null, u => u.SystemDocument.CreateTime < trialInfo.TrialFinishedTime) .WhereIf(!_userInfo.IsAdmin, t => t.SystemDocument.IsDeleted == false || (t.SystemDocument.IsDeleted == true && t.SystemDocument.SystemDocConfirmedUserList.Any(t => t.ConfirmUserId == _userInfo.Id))) @@ -394,7 +395,7 @@ namespace IRaCIS.Core.Application.Services var trialInfo = (await _trialRepository.Where(t => t.Id == inQuery.TrialId).Select(t => new { t.TrialFinishedTime, t.TrialStatusStr }).FirstNotNullAsync()); - var trialDocQuery = from trialDocumentNeedConfirmedUserType in _repository.Where(t => t.TrialDocument.TrialId == inQuery.TrialId) + var trialDocQuery = from trialDocumentNeedConfirmedUserType in _trialDocNeedConfirmedUserTypeRepository.Where(t => t.TrialDocument.TrialId == inQuery.TrialId) join trialUser in _trialUserRepository.Where(t => t.TrialId == inQuery.TrialId) .WhereIf(inQuery.UserId != null, t => t.UserId == inQuery.UserId) .WhereIf(inQuery.UserTypeId != null, t => t.User.UserTypeId == inQuery.UserTypeId) @@ -639,7 +640,7 @@ namespace IRaCIS.Core.Application.Services } - success = await _repository.SaveChangesAsync(); + success = await _systemDocConfirmedUserRepository.SaveChangesAsync(); return ResponseOutput.Ok(success); } @@ -653,7 +654,7 @@ namespace IRaCIS.Core.Application.Services } - var success = await _repository.SaveChangesAsync(); + var success = await _systemDocConfirmedUserRepository.SaveChangesAsync(); return ResponseOutput.Ok(success); } @@ -667,7 +668,7 @@ namespace IRaCIS.Core.Application.Services await _trialDocConfirmedUserRepository.AddAsync(new TrialDocConfirmedUser() { TrialDocumentId = documentId, ConfirmUserId = _userInfo.Id, SignFirstViewTime = DateTime.Now }); } - var success = await _repository.SaveChangesAsync(); + var success = await _trialDocConfirmedUserRepository.SaveChangesAsync(); return ResponseOutput.Ok(success); } diff --git a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs index 785697baa..dd74124a9 100644 --- a/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs +++ b/IRaCIS.Core.Application/Service/Document/TrialEmailNoticeConfigService.cs @@ -40,10 +40,13 @@ namespace IRaCIS.Core.Application.Service IRepository _emailNoticeConfigRepository, IRepository _trialRepository, IRepository _taskMedicalReviewRepository, + IRepository _readingGlobalTaskInfoRepository, IRepository _visitTaskRepository, IRepository _trialUserRepository, IRepository _trialEmailNoticeUserRepository, IRepository _subjectRepository, + IRepository _readModuleRepository, + IRepository _readingTableQuestionAnswerRepository, IRepository _subjectVisitRepository, IRepository _readingTaskQuestionAnswerRepository, IRepository _readingQuestionCriterionTrialRepository, @@ -311,7 +314,7 @@ namespace IRaCIS.Core.Application.Service //入组确认 根据每个标准配置的是否自动发送,发送邮件与否 if (businessScenarioEnum == EmailBusinessScenario.EnrollConfirmed) { - if (await _repository.Where().AnyAsync(x => x.VisitTaskId == visitTaskId && x.Answer == TargetState.Exist.GetEnumInt() && + if (await _readingTableQuestionAnswerRepository.Where().AnyAsync(x => x.VisitTaskId == visitTaskId && x.Answer == TargetState.Exist.GetEnumInt() && x.ReadingTableQuestionTrial.QuestionMark == QuestionMark.State && x.ReadingQuestionTrial.LesionType == LesionType.TargetLesion)) { answer = "是"; @@ -490,7 +493,7 @@ namespace IRaCIS.Core.Application.Service // if (taskInfo.ReadingCategory == ReadingCategory.Visit) // { // //存在阅片期 那么就是截止访视 - // if (await _repository.Where(t => t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && t.SubjectVisitId == taskInfo.SourceSubjectVisitId && t.ReadingSetType == ReadingSetType.ImageReading).AnyAsync()) + // if (await _readModuleRepository.Where(t => t.TrialReadingCriterionId == taskInfo.TrialReadingCriterionId && t.SubjectVisitId == taskInfo.SourceSubjectVisitId && t.ReadingSetType == ReadingSetType.ImageReading).AnyAsync()) // { // isNeedSend = false; // } @@ -905,7 +908,7 @@ namespace IRaCIS.Core.Application.Service //仲裁在阅片期上 else if (trialReadingCriterionConfig.ArbitrationRule == ArbitrationRule.Reading) { - var existReadModule = await _repository.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == currentLatestPdVisitId && t.ReadingSetType == ReadingSetType.ImageReading) + var existReadModule = await _readModuleRepository.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == currentLatestPdVisitId && t.ReadingSetType == ReadingSetType.ImageReading) .FirstOrDefaultAsync(); if (existReadModule == null) @@ -978,7 +981,7 @@ namespace IRaCIS.Core.Application.Service // { // //存在阅片期 那么就是截止访视 - // var existReadModule = await _repository.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == currentLatestPdVisitId && t.ReadingSetType == ReadingSetType.ImageReading) + // var existReadModule = await _readModuleRepository.Where(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectVisitId == currentLatestPdVisitId && t.ReadingSetType == ReadingSetType.ImageReading) // .FirstOrDefaultAsync(); // if (existReadModule != null) // { @@ -1081,7 +1084,7 @@ namespace IRaCIS.Core.Application.Service } else if (readingCategory == ReadingCategory.Global) { - var questionAnsewer = await _repository.Where(t => t.GlobalTaskId == visitTaskId && t.TrialReadingQuestion.QuestionType == QuestionType.Tumor).OrderByDescending(c => c.VisitTask.VisitTaskNum).FirstNotNullAsync(); + var questionAnsewer = await _readingGlobalTaskInfoRepository.Where(t => t.GlobalTaskId == visitTaskId && t.TrialReadingQuestion.QuestionType == QuestionType.Tumor).OrderByDescending(c => c.VisitTask.VisitTaskNum).FirstNotNullAsync(); answer = questionAnsewer.Answer; @@ -1129,7 +1132,7 @@ namespace IRaCIS.Core.Application.Service } else if (readingCategory == ReadingCategory.Global) { - var questionAnsewer = await _repository.Where(t => t.TaskId == visitTaskId && t.TrialReadingQuestion.QuestionType == QuestionType.SiteVisitForTumorEvaluation).FirstNotNullAsync(); + var questionAnsewer = await _readingGlobalTaskInfoRepository.Where(t => t.TaskId == visitTaskId && t.TrialReadingQuestion.QuestionType == QuestionType.SiteVisitForTumorEvaluation).FirstNotNullAsync(); answer = questionAnsewer.Answer; } @@ -1395,7 +1398,7 @@ namespace IRaCIS.Core.Application.Service trialEmailNoticeUsers.Add(new TrialEmailNoticeUser() { EmailUserType = EmailUserType.Copy, UserType = item, TrialEmailNoticeConfigId = id }); } - await _repository.AddRangeAsync(trialEmailNoticeUsers); + await _trialEmailNoticeUserRepository.AddRangeAsync(trialEmailNoticeUsers); foreach (var userid in addOrEditTrialEmailNoticeConfig.BlackUserIdList) { diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs index be6ce45cc..3f2c31f05 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DicomArchiveService.cs @@ -22,6 +22,7 @@ namespace IRaCIS.Core.Application.Services IRepository _seriesRepository, IRepository _instanceRepository, IRepository _dictionaryRepository, + IRepository _systemAnonymizationRepository, IDistributedLockProvider _distributedLockProvider) : BaseService, IDicomArchiveService { @@ -59,7 +60,7 @@ namespace IRaCIS.Core.Application.Services } - var anonymizeList = await _fusionCache.GetOrSetAsync(CacheKeys.SystemAnonymization, _ => CacheHelper.GetSystemAnonymizationListAsync(_repository), TimeSpan.FromDays(7)); + var anonymizeList = await _fusionCache.GetOrSetAsync(CacheKeys.SystemAnonymization, _ => CacheHelper.GetSystemAnonymizationListAsync(_systemAnonymizationRepository), TimeSpan.FromDays(7)); var fixedFiledList = anonymizeList.Where(t => t.IsFixed).ToList(); var ircFiledList = anonymizeList.Where(t => t.IsFixed == false).ToList(); diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs index 484a08e17..58a9b9415 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs @@ -292,7 +292,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc using (await @lock.AcquireAsync()) { //查询数据库获取最大的Code 没有记录则为0 - var dbStudyCodeIntMax = _repository.Where(s => s.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max(); + var dbStudyCodeIntMax = _taskStudyRepository.Where(s => s.TrialId == trialId).Select(t => t.Code).DefaultIfEmpty().Max(); //获取缓存中的值 并发的时候,需要记录,已被占用的值 这样其他线程在此占用的最大的值上递增 var cacheMaxCodeInt = await _fusionCache.GetOrDefaultAsync(CacheKeys.TrialStudyMaxCode(trialId)); @@ -371,7 +371,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc var studyId = IdentifierHelper.CreateGuid(incommand.Study.StudyInstanceUid, incommand.TrialId.ToString(), findOriginStudy.VisitTaskId.ToString()); - var study = await _repository.FirstOrDefaultAsync(t => t.Id == studyId); + var study = await _taskStudyRepository.FirstOrDefaultAsync(t => t.Id == studyId); //重传的时候也要赋值检查Id studyMonitor.StudyId = study.Id; @@ -390,7 +390,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc { var seriesId = IdentifierHelper.CreateGuid(seriesItem.StudyInstanceUid, seriesItem.SeriesInstanceUid, trialId.ToString(), findOriginStudy.VisitTaskId.ToString()); - TaskSeries dicomSeries = await _repository.FirstOrDefaultAsync(t => t.Id == seriesId); + TaskSeries dicomSeries = await _taskSeriesRepository.FirstOrDefaultAsync(t => t.Id == seriesId); //判断重复 if (dicomSeries == null) @@ -444,7 +444,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc using (await @lock2.AcquireAsync()) { - await _repository.SaveChangesAsync(); + await _taskStudyRepository.SaveChangesAsync(); } } catch (Exception ex) diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs index d52abbdbc..47ecb65c6 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/StudyService.cs @@ -14,7 +14,6 @@ using Microsoft.AspNetCore.Http; using Newtonsoft.Json; using System.Threading; using Medallion.Threading; -using System.Reactive.Subjects; using DocumentFormat.OpenXml.Drawing.Diagrams; using IRaCIS.Core.Application.Service.ImageAndDoc.DTO; using ZiggyCreatures.Caching.Fusion; @@ -31,7 +30,9 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc IRepository _trialRepository, IRepository _visitTaskRepository, IRepository _dicomStudyRepository, + IRepository _subjectRepository, IRepository _studyMonitorRepository, + IRepository _systemAnonymizationRepository, IRepository _noneDicomStudyRepository, IDistributedLockProvider _distributedLockProvider) : BaseService, IStudyService { @@ -460,7 +461,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc public async Task> GetDicomAndNoneDicomStudyMonitorList(StudyQuery inQuery) { var svExpression = QCCommon.GetStudyMonitorSubjectVisitFilter(inQuery.VisitPlanArray); - var StudyMonitorQuery = _repository.Where(t => t.TrialId == inQuery.TrialId, ignoreQueryFilters: true) + var StudyMonitorQuery = _studyMonitorRepository.Where(t => t.TrialId == inQuery.TrialId, ignoreQueryFilters: true) .WhereIf(_userInfo.UserTypeEnumInt == (int)UserTypeEnum.ClinicalResearchCoordinator || _userInfo.UserTypeEnumInt == (int)UserTypeEnum.CRA, t => t.Subject.TrialSite.CRCUserList.Any(t => t.UserId == _userInfo.Id)) //.WhereIf(!string.IsNullOrEmpty(studyQuery.VisitPlanInfo), studyQuery.VisitPlanInfo.Contains('.') ? t => t.SubjectVisit.VisitNum.ToString().Contains(".") : t => t.SubjectVisit.VisitNum == decimal.Parse(studyQuery.VisitPlanInfo)) .WhereIf(inQuery.VisitPlanArray != null && inQuery.VisitPlanArray?.Length > 0, svExpression) @@ -711,7 +712,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc - var systemAnonymizationList = _repository.Where(t => t.IsEnable).ToList(); + var systemAnonymizationList = _systemAnonymizationRepository.Where(t => t.IsEnable).ToList(); return ResponseOutput.Ok>(resultList, new { @@ -772,7 +773,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc // 写入dicom 固定的信息,以及组织路径的信息 以及匿名化的信息 var otherData = GetSaveToDicomInfo(verifyInfo.SubjectVisitId); - var anonymizeList = _fusionCache.GetOrSetAsync(CacheKeys.SystemAnonymization, _ => CacheHelper.GetSystemAnonymizationListAsync(_repository), TimeSpan.FromDays(7)).Result; + var anonymizeList = _fusionCache.GetOrSetAsync(CacheKeys.SystemAnonymization, _ => CacheHelper.GetSystemAnonymizationListAsync(_systemAnonymizationRepository), TimeSpan.FromDays(7)).Result; return ResponseOutput.Ok>(result, new { @@ -801,7 +802,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc return result; } - if (_repository.Where(t => t.Id == SubjectId).Select(t => t.Status).FirstOrDefault() == SubjectStatus.EndOfVisit) + if (_subjectRepository.Where(t => t.Id == SubjectId).Select(t => t.Status).FirstOrDefault() == SubjectStatus.EndOfVisit) { result.AllowUpload = false; diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs index 601d5884a..9307cadc8 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/SystemAnonymizationService.cs @@ -14,7 +14,7 @@ namespace IRaCIS.Core.Application.Service /// SystemAnonymizationService /// [ApiExplorerSettings(GroupName = "Image")] - public class SystemAnonymizationService(IRepository systemAnonymizationRepository) : BaseService, ISystemAnonymizationService + public class SystemAnonymizationService(IRepository _systemAnonymizationRepository) : BaseService, ISystemAnonymizationService { @@ -22,7 +22,7 @@ namespace IRaCIS.Core.Application.Service public async Task> GetSystemAnonymizationList(SystemAnonymizationQuery inQuery) { - var systemAnonymizationQueryable = systemAnonymizationRepository + var systemAnonymizationQueryable = _systemAnonymizationRepository .WhereIf(!string.IsNullOrEmpty(inQuery.Group), t => t.Group.Contains(inQuery.Group)) .WhereIf(!string.IsNullOrEmpty(inQuery.Element), t => t.Element.Contains(inQuery.Element)) .WhereIf(inQuery.IsAdd != null, t => t.IsAdd == inQuery.IsAdd) @@ -36,7 +36,7 @@ namespace IRaCIS.Core.Application.Service public async Task AddOrUpdateSystemAnonymization(SystemAnonymizationAddOrEdit addOrEditSystemAnonymization) { - var entity = await _repository.InsertOrUpdateAsync(addOrEditSystemAnonymization, true); + var entity = await _systemAnonymizationRepository.InsertOrUpdateAsync(addOrEditSystemAnonymization, true); return ResponseOutput.Ok(entity.Id.ToString()); @@ -47,7 +47,7 @@ namespace IRaCIS.Core.Application.Service [HttpDelete("{systemAnonymizationId:guid}")] public async Task DeleteSystemAnonymization(Guid systemAnonymizationId) { - var success = await systemAnonymizationRepository.BatchDeleteNoTrackingAsync(t => t.Id == systemAnonymizationId); + var success = await _systemAnonymizationRepository.BatchDeleteNoTrackingAsync(t => t.Id == systemAnonymizationId); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs b/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs index 0ef5a9930..d84811f9f 100644 --- a/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/FrontAuditConfigService.cs @@ -1066,8 +1066,8 @@ namespace IRaCIS.Core.Application.Service await _repository.UpdateRange(neewupdate); - await _repository.AddRangeAsync(list); - await _repository.SaveChangesAsync(); + await _frontAuditConfigRepository.AddRangeAsync(list); + await _frontAuditConfigRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index 2e09c4465..0ee0e60e5 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -260,7 +260,7 @@ namespace IRaCIS.Core.Application.Service.Inspection /// 验证用户签名信息 /// public async Task VerifySignatureAsync(SignDTO signDTO) { - var user = await _repository.FirstOrDefaultAsync(u => u.UserName == signDTO.UserName && u.Password == signDTO.PassWord); + var user = await _userRepository.FirstOrDefaultAsync(u => u.UserName == signDTO.UserName && u.Password == signDTO.PassWord); if (user == null) { throw new BusinessValidationFailedException(_localizer["User_CheckNameOrPw"]); @@ -279,7 +279,7 @@ namespace IRaCIS.Core.Application.Service.Inspection { var add = await _trialSignRepository.AddAsync(_mapper.Map(signDTO)); - var success = await _repository.SaveChangesAsync(); + var success = await _trialSignRepository.SaveChangesAsync(); return add.Id; diff --git a/IRaCIS.Core.Application/Service/Institution/SiteService.cs b/IRaCIS.Core.Application/Service/Institution/SiteService.cs index 46083fb42..cc20b12b8 100644 --- a/IRaCIS.Core.Application/Service/Institution/SiteService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SiteService.cs @@ -47,7 +47,7 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task> GetTrialSiteList(TrialSiteInQuery inQuery) { - var query = _repository.Where(t => t.SiteId == null) + var query = _trialSiteRepository.Where(t => t.SiteId == null) .WhereIf(!string.IsNullOrEmpty(inQuery.TrialSiteName), t => t.TrialSiteName.Contains(inQuery.TrialSiteName) || t.TrialSiteAliasName.Contains(inQuery.TrialSiteName)) .WhereIf(!string.IsNullOrEmpty(inQuery.TrialCode), t => t.Trial.TrialCode.Contains(inQuery.TrialCode)) .Select(t => new TrialSiteAddView() diff --git a/IRaCIS.Core.Application/Service/Management/MenuService.cs b/IRaCIS.Core.Application/Service/Management/MenuService.cs index 866c77b7a..65bb7a1f1 100644 --- a/IRaCIS.Core.Application/Service/Management/MenuService.cs +++ b/IRaCIS.Core.Application/Service/Management/MenuService.cs @@ -7,7 +7,7 @@ namespace IRaCIS.Application.Services { [ApiExplorerSettings(GroupName = "Management")] public class MenuService( - IRepository menuRepository, + IRepository _menuRepository, IRepository _userTypeMenuRepository) : BaseService, IMenuService { @@ -26,7 +26,7 @@ namespace IRaCIS.Application.Services VerifyMsg = _localizer["Menu_ParentDupChild"] }; - var menu = await _repository.InsertOrUpdateAsync(menuAddOrUpdateModel, true, exp); + var menu = await _menuRepository.InsertOrUpdateAsync(menuAddOrUpdateModel, true, exp); return ResponseOutput.Ok(menu.Id.ToString()); @@ -85,13 +85,13 @@ namespace IRaCIS.Application.Services [HttpDelete("{menuId:guid}")] public async Task DeleteMenu(Guid menuId) { - if (await menuRepository.AnyAsync(t => t.ParentId == menuId)) + if (await _menuRepository.AnyAsync(t => t.ParentId == menuId)) { //---该节点存在子节点,请在删除子节点后,再删除该节点。 return ResponseOutput.NotOk(_localizer["Menu_ChildExist"]); } - var success =await menuRepository.BatchDeleteNoTrackingAsync(u => u.Id == menuId); + var success =await _menuRepository.BatchDeleteNoTrackingAsync(u => u.Id == menuId); return ResponseOutput.Result(success); } @@ -104,7 +104,7 @@ namespace IRaCIS.Application.Services [HttpGet] public async Task> GetMenuTree() { - var allMenuList = (await menuRepository.ProjectTo(_mapper.ConfigurationProvider).ToListAsync()).IfNullThrowException(); + var allMenuList = (await _menuRepository.ProjectTo(_mapper.ConfigurationProvider).ToListAsync()).IfNullThrowException(); var list = allMenuList.ToTree((root, child) => child.ParentId == Guid.Empty, (root, child) => child.ParentId == root.MenuId, @@ -125,7 +125,7 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task> GetMenuList(MenuQueyDTO menuQueyDTO) { - return await menuRepository + return await _menuRepository .WhereIf(menuQueyDTO.ParentId != null, t => t.ParentId == menuQueyDTO.ParentId) .WhereIf(menuQueyDTO.IsEnable != null, t => t.IsEnable == menuQueyDTO.IsEnable) .WhereIf(menuQueyDTO.IsCache != null, t => t.IsCache == menuQueyDTO.IsCache) @@ -146,7 +146,7 @@ namespace IRaCIS.Application.Services [HttpGet("{userTypeId:guid}")] public async Task> GetUserTypeMenuTree(Guid userTypeId) { - var menuFunctionlist = (await menuRepository + var menuFunctionlist = (await _menuRepository .ProjectTo(_mapper.ConfigurationProvider, new { userTypeId = userTypeId }).ToListAsync()).IfNullThrowException(); @@ -189,7 +189,7 @@ namespace IRaCIS.Application.Services .Where(t => t.UserTypeId == _userInfo.UserTypeId && t.Menu.MenuType == "F") .Select(t => t.Menu.PermissionStr).ToListAsync(); - //var str = await _repository.Where(t => t.Id == _userInfo.UserTypeId).Select(t => t.PermissionStr).FirstOrDefaultAsync(); + //var str = await _userTypeRepository.Where(t => t.Id == _userInfo.UserTypeId).Select(t => t.PermissionStr).FirstOrDefaultAsync(); list.Add(_userInfo.PermissionStr); diff --git a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs index 0d3f1ac5f..189191b3c 100644 --- a/IRaCIS.Core.Application/Service/Management/UserTypeService.cs +++ b/IRaCIS.Core.Application/Service/Management/UserTypeService.cs @@ -14,7 +14,7 @@ namespace IRaCIS.Core.Application.Contracts /// UserTypeRoleService /// [ApiExplorerSettings(GroupName = "Management")] - public class UserTypeRoleService(IRepository _userTypeRepository) : BaseService, IUserTypeService + public class UserTypeRoleService(IRepository _userTypeRepository, IRepository _userRepository) : BaseService, IUserTypeService { [HttpPost] @@ -71,7 +71,7 @@ namespace IRaCIS.Core.Application.Contracts await _userTypeRepository.EntityVerifyAsync(entity.Id, verifyExp1); } - var success = await _repository.SaveChangesAsync(); + var success = await _userTypeRepository.SaveChangesAsync(); return ResponseOutput.Ok( entity.Id.ToString()); @@ -81,7 +81,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpDelete("{userTypeId:guid}")] public async Task DeleteUserTypeRole(Guid userTypeId) { - if ( await _repository.AnyAsync(t => t.UserTypeId == userTypeId)) + if ( await _userRepository.AnyAsync(t => t.UserTypeId == userTypeId)) { //---该用户类型中已存在用户,不能删除 return ResponseOutput.NotOk(_localizer["UserType_InUse"]); diff --git a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs index e5baa7e12..63a74b56f 100644 --- a/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs +++ b/IRaCIS.Core.Application/Service/QC/NoneDicomStudyService.cs @@ -143,7 +143,7 @@ namespace IRaCIS.Core.Application.Contracts [HttpGet("{subjectVisitId:guid}")] public async Task> GetVisitNoneDicomStudyFileList(Guid subjectVisitId) { - return await _repository.Where(t => t.NoneDicomStudy.SubjectVisitId == subjectVisitId) + return await _noneDicomStudyFileRepository.Where(t => t.NoneDicomStudy.SubjectVisitId == subjectVisitId) .ProjectTo(_mapper.ConfigurationProvider, new { token = _userInfo.UserToken }).ToListAsync(); } diff --git a/IRaCIS.Core.Application/Service/QC/QCCommon.cs b/IRaCIS.Core.Application/Service/QC/QCCommon.cs index 45feef04e..6378bde70 100644 --- a/IRaCIS.Core.Application/Service/QC/QCCommon.cs +++ b/IRaCIS.Core.Application/Service/QC/QCCommon.cs @@ -39,17 +39,17 @@ namespace IRaCIS.Core.Application.Service if (_userInfo.UserTypeEnumInt == (int)UserTypeEnum.IQC) { - await VerifyIsCanQCAsync(_repository, _userInfo, null, subjectVisitId); + await VerifyIsCanQCAsync(_subjectVisitRepository, _userInfo, null, subjectVisitId); } } - public async Task VerifyIsCanQCAsync(IRepository _repository, IUserInfo _userInfo, SubjectVisit? subjectVisit = null, Guid? subjectVisitId = null) + public async Task VerifyIsCanQCAsync(IRepository _subjectVisitRepository, IUserInfo _userInfo, SubjectVisit? subjectVisit = null, Guid? subjectVisitId = null) { if (subjectVisitId != null) { - subjectVisit = (await _repository.FirstOrDefaultAsync(t => t.Id == subjectVisitId)).IfNullThrowException(); + subjectVisit = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == subjectVisitId)).IfNullThrowException(); } if (subjectVisit!.CurrentActionUserId != _userInfo.Id) { diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index 78e811ce9..d2e56bddc 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -116,7 +116,7 @@ namespace IRaCIS.Core.Application.Image.QA else { - await _repository.UpdateFromDTOAsync(qaQuestionCommand, true); + await _qcChallengeRepository.UpdateFromDTOAsync(qaQuestionCommand, true); return ResponseOutput.Ok(); @@ -191,7 +191,7 @@ namespace IRaCIS.Core.Application.Image.QA public async Task DeleteQCChallenge(Guid qcChallengeId) { - if (await _repository.AnyAsync(t => t.QCChallengeId == qcChallengeId)) + if (await _qCChallengeDialogrepository.AnyAsync(t => t.QCChallengeId == qcChallengeId)) { //---当前QC质疑已经回复。 ResponseOutput.NotOk(_localizer["QCOperation_QuestionReplied"]); @@ -203,7 +203,7 @@ namespace IRaCIS.Core.Application.Image.QA await _qcChallengeRepository.DeleteAsync(qaRecord); - var success1 = await _repository.SaveChangesAsync(); + var success1 = await _qcChallengeRepository.SaveChangesAsync(); return ResponseOutput.Result(success1 /*|| success2 || success3*/); } @@ -224,7 +224,7 @@ namespace IRaCIS.Core.Application.Image.QA qaReply.UserTypeEnum = (UserTypeEnum)_userInfo.UserTypeEnumInt; - var dbQCChallenge = (await _repository.FirstOrDefaultAsync(t => t.Id == qaDialogCommand.QCChallengeId)).IfNullThrowException(); + var dbQCChallenge = (await _qcChallengeRepository.FirstOrDefaultAsync(t => t.Id == qaDialogCommand.QCChallengeId)).IfNullThrowException(); dbQCChallenge.LatestMsgTime = DateTime.Now; @@ -232,7 +232,7 @@ namespace IRaCIS.Core.Application.Image.QA dbQCChallenge.LatestReplyUserId = _userInfo.Id; - var success = await _repository.SaveChangesAsync(); + var success = await _qCChallengeDialogrepository.SaveChangesAsync(); return ResponseOutput.Result(success, qaReply); @@ -279,7 +279,7 @@ namespace IRaCIS.Core.Application.Image.QA throw new BusinessValidationFailedException(_localizer["QCOperation_NoPermissionReply"]); } - var success = await _repository.SaveChangesAsync(); + var success = await _subjectVisitRepository.SaveChangesAsync(); return ResponseOutput.Result(success, qaReply.Id); } @@ -314,7 +314,7 @@ namespace IRaCIS.Core.Application.Image.QA UserTypeEnum = (UserTypeEnum)_userInfo.UserTypeEnumInt, }); - await _repository.SaveChangesAsync(); + await _subjectVisitRepository.SaveChangesAsync(); return ResponseOutput.Ok(sv); } @@ -575,7 +575,7 @@ namespace IRaCIS.Core.Application.Image.QA - return ResponseOutput.Ok(await _repository.SaveChangesAsync()); + return ResponseOutput.Ok(await _trialQCQuestionAnswerRepository.SaveChangesAsync()); } else { @@ -583,9 +583,9 @@ namespace IRaCIS.Core.Application.Image.QA addlist.ForEach(t => { t.TrialId = trialId; t.SubjectVisitId = subjectVisitId; t.CurrentQCEnum = currentQCType; t.QCProcessEnum = trialQCProcess; }); - await _repository.AddRangeAsync(addlist); + await _trialQCQuestionAnswerRepository.AddRangeAsync(addlist); - return ResponseOutput.Result(await _repository.SaveChangesAsync()); + return ResponseOutput.Result(await _trialQCQuestionAnswerRepository.SaveChangesAsync()); } @@ -661,7 +661,7 @@ namespace IRaCIS.Core.Application.Image.QA study.IsDeleted = study.SeriesCount == 0; } - return ResponseOutput.Ok(await _repository.SaveChangesAsync()); + return ResponseOutput.Ok(await _dicomStudyRepository.SaveChangesAsync()); } /// @@ -693,7 +693,7 @@ namespace IRaCIS.Core.Application.Image.QA { var studyId = updateModalityCommand.Id; - var study = (await _repository.FirstOrDefaultAsync(t => t.Id == studyId)).IfNullThrowException(); + var study = (await _dicomStudyRepository.FirstOrDefaultAsync(t => t.Id == studyId)).IfNullThrowException(); study.BodyPartForEdit = updateModalityCommand.BodyPart; @@ -706,7 +706,7 @@ namespace IRaCIS.Core.Application.Image.QA { var seriesId = updateModalityCommand.Id; - var series = (await _repository.FirstOrDefaultAsync(t => t.Id == seriesId)).IfNullThrowException(); + var series = (await _dicomSeriesRepository.FirstOrDefaultAsync(t => t.Id == seriesId)).IfNullThrowException(); series.BodyPartForEdit = updateModalityCommand.BodyPart; } @@ -715,7 +715,7 @@ namespace IRaCIS.Core.Application.Image.QA } - await _repository.SaveChangesAsync(); + await _subjectVisitRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } @@ -730,7 +730,7 @@ namespace IRaCIS.Core.Application.Image.QA { await VerifyIsCanQCAsync(null, subjectVisitId); - if (await _repository.AnyAsync(t => t.SubjectVisitId == subjectVisitId && t.IsClosed == false)) + if (await _qcChallengeRepository.AnyAsync(t => t.SubjectVisitId == subjectVisitId && t.IsClosed == false)) { //---当前访视有质疑未关闭,不允许该操作 return ResponseOutput.NotOk(_localizer["QCOperation_UnresolvedQCQuery"]); @@ -804,11 +804,11 @@ namespace IRaCIS.Core.Application.Image.QA var subjectId=waitDeleteStudyList.Select(t=>t.SubjectId).FirstOrDefault(); - var patientList = _repository.Where(t => t.SubjectId == subjectId).Select(t => t.Id).ToList(); + var patientList = _scpPatientRepository.Where(t => t.SubjectId == subjectId).Select(t => t.Id).ToList(); foreach (var patientId in patientList) { - if (_repository.Where(t=>t.Id== patientId).Any(t => t.SCPStudyList.Count() == t.SCPStudyList.Where(t => t.SubjectVisitId == null).Count())) + if (_scpPatientRepository.Where(t=>t.Id== patientId).Any(t => t.SCPStudyList.Count() == t.SCPStudyList.Where(t => t.SubjectVisitId == null).Count())) { await _scpPatientRepository.BatchUpdateNoTrackingAsync(t => t.Id == patientId, u => new SCPPatient() { SubjectId = null }); } @@ -1295,7 +1295,7 @@ namespace IRaCIS.Core.Application.Image.QA } //获取确认的临床数据配置 - var clinicalDataConfirmList = _repository.Where(t => t.TrialId == trialId && t.IsConfirm).ToList(); + var clinicalDataConfirmList = _clinicalDataTrialSetRepository.Where(t => t.TrialId == trialId && t.IsConfirm).ToList(); // 别人未提交的 foreach (var dbSubjectVisit in dbSubjectVisitList) @@ -1496,7 +1496,7 @@ namespace IRaCIS.Core.Application.Image.QA - var success = await _repository.SaveChangesAsync(); + var success = await _subjectVisitRepository.SaveChangesAsync(); return ResponseOutput.Ok(success); @@ -1528,7 +1528,7 @@ namespace IRaCIS.Core.Application.Image.QA if (auditState == AuditStateEnum.QCPassed) { //判断质疑是否都关闭了 - if (await _repository.AnyAsync(t => t.SubjectVisitId == subjectVisitId && t.IsClosed == false)) + if (await _qcChallengeRepository.AnyAsync(t => t.SubjectVisitId == subjectVisitId && t.IsClosed == false)) { //---当前访视有影像质控质疑未关闭,不能进行此操作。 return ResponseOutput.NotOk(_localizer["QCOperation_QCNotClosed"]); @@ -1727,7 +1727,7 @@ namespace IRaCIS.Core.Application.Image.QA dbSubjectVisit.CurrentActionUserId = null; dbSubjectVisit.CurrentActionUserExpireTime = null; - await _repository.SaveChangesAsync(); + await _subjectVisitRepository.SaveChangesAsync(); return ResponseOutput.Result(true); @@ -1753,7 +1753,7 @@ namespace IRaCIS.Core.Application.Image.QA var sv = (await _subjectVisitRepository.FirstOrDefaultAsync(t => t.Id == subjectVisitId)).IfNullThrowException(); sv.IsUrgent = setOrCancel; - var success = await _repository.SaveChangesAsync(); + var success = await _subjectVisitRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } @@ -1837,7 +1837,7 @@ namespace IRaCIS.Core.Application.Image.QA }); //双审 并且是2QC 那么需要回退到1QC 讲1QC数据清除 - if (trialConfig.QCProcessEnum == TrialQCProcess.DoubleAudit && await _repository.AnyAsync(t => t.Id == qcChallengeId && t.SubjectVisit.AuditState == AuditStateEnum.InSecondaryQC)) + if (trialConfig.QCProcessEnum == TrialQCProcess.DoubleAudit && await _qcChallengeRepository.AnyAsync(t => t.Id == qcChallengeId && t.SubjectVisit.AuditState == AuditStateEnum.InSecondaryQC)) { @@ -1872,7 +1872,7 @@ namespace IRaCIS.Core.Application.Image.QA } - var success = await _repository.SaveChangesAsync(); + var success = await _qcChallengeRepository.SaveChangesAsync(); return ResponseOutput.Result(success); diff --git a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs index 42979d9ec..43be232ff 100644 --- a/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs +++ b/IRaCIS.Core.Application/Service/QC/TrialQCQuestionService.cs @@ -254,7 +254,7 @@ namespace IRaCIS.Core.Application.Contracts await _trialQcQuestionRepository.AddRangeAsync(childList); - var success = await _repository.SaveChangesAsync(); + var success = await _trialQcQuestionRepository.SaveChangesAsync(); return ResponseOutput.Result(success); } diff --git a/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalDataSetService.cs b/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalDataSetService.cs index b89c5f43f..f99104d8e 100644 --- a/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalDataSetService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ClinicalData/ClinicalDataSetService.cs @@ -232,7 +232,7 @@ namespace IRaCIS.Application.Services { await _trialClinicalDataSetCriterionRepository.DeleteFromQueryAsync(t => t.TrialClinicalDataSetId == entity.Id); - await _repository.AddRangeAsync(entity.TrialClinicalDataSetCriteriaList); + await _trialClinicalDataSetCriterionRepository.AddRangeAsync(entity.TrialClinicalDataSetCriteriaList); } diff --git a/IRaCIS.Core.Application/Service/Reading/ClinicalData/ReadingClinicalDataService.cs b/IRaCIS.Core.Application/Service/Reading/ClinicalData/ReadingClinicalDataService.cs index a0b47be22..945c150ba 100644 --- a/IRaCIS.Core.Application/Service/Reading/ClinicalData/ReadingClinicalDataService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ClinicalData/ReadingClinicalDataService.cs @@ -356,7 +356,7 @@ namespace IRaCIS.Application.Services if (await _clinicalDataTrialSetRepository.AnyAsync(t => t.Id == data.ClinicalDataTrialSetId && t.UploadRole == UploadRole.PM && (t.ClinicalDataLevel == ClinicalLevel.Subject || t.ClinicalDataLevel == ClinicalLevel.SubjectVisit))) { - var needDealTrialReadingCriterionIdList = _repository.Where(t => t.Id == data.ClinicalDataTrialSetId) + var needDealTrialReadingCriterionIdList = _clinicalDataTrialSetRepository.Where(t => t.Id == data.ClinicalDataTrialSetId) .SelectMany(t => t.TrialClinicalDataSetCriteriaList) .Select(u => u.TrialReadingCriterionId).Distinct().ToList(); @@ -402,7 +402,7 @@ namespace IRaCIS.Application.Services // if (await _clinicalDataTrialSetRepository.AnyAsync(t => t.Id == data.ClinicalDataTrialSetId && t.UploadRole == UploadRole.PM && t.ClinicalDataLevel == ClinicalLevel.Subject)) // { - // var needDealTrialReadingCriterionIdList = _repository.Where(t => t.Id == data.ClinicalDataTrialSetId) + // var needDealTrialReadingCriterionIdList = _clinicalDataTrialSetRepository.Where(t => t.Id == data.ClinicalDataTrialSetId) // .SelectMany(t => t.TrialClinicalDataSetCriteriaList) // .Select(u => u.TrialReadingCriterionId).Distinct().ToList(); diff --git a/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs b/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs index f30de3f84..4cc96de78 100644 --- a/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs +++ b/IRaCIS.Core.Application/Service/Reading/ReadingPeriod/ReadModuleService.cs @@ -28,6 +28,7 @@ namespace IRaCIS.Application.Services IRepository _readingQuestionCriterionTrialRepository, IRepository _dicomInstanceRepository, IRepository _noneDicomStudyFileRepository, + IRepository _readingClinicalDataRepository, IRepository _readingPeriodSetRepository, IRepository _readModuleRepository) : BaseService { @@ -454,7 +455,7 @@ namespace IRaCIS.Application.Services var readModule = await _readModuleRepository.Where(x => x.Id == readModuleId).FirstNotNullAsync(); - if(await _repository.Where(t => t.ReadingId == readModuleId).AnyAsync(t => t.ReadingClinicalDataState == ReadingClinicalDataStatus.HaveSigned)) + if(await _readingClinicalDataRepository.Where(t => t.ReadingId == readModuleId).AnyAsync(t => t.ReadingClinicalDataState == ReadingClinicalDataStatus.HaveSigned)) { //---临床资料已签名,不允许删除 return ResponseOutput.NotOk(_localizer["ReadModule_SignedDataCannotDelete"]); diff --git a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs index 4d7b7cf0f..b8159abca 100644 --- a/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs +++ b/IRaCIS.Core.Application/Service/SiteSurvey/TrialSiteSurveyService.cs @@ -37,11 +37,13 @@ namespace IRaCIS.Core.Application.Contracts IRepository _userRepository, IRepository _trialRepository, IRepository _trialSiteRepository, + IRepository _doctorRepository, IRepository _verificationCodeRepository, IRepository _trialUserRepository, IRepository _trialSiteUserRepository, IDistributedLockProvider _distributedLockProvider, ITokenService _tokenService, + IRepository _userTypeRepository, IMailVerificationService _mailVerificationService, IOptionsMonitor systemEmailConfig) : BaseService, ITrialSiteSurveyService { @@ -105,7 +107,7 @@ namespace IRaCIS.Core.Application.Contracts //删除验证码历史记录 await _verificationCodeRepository.BatchDeleteNoTrackingAsync(t => t.Id == verificationRecord.Id); - var dockerInfo = await _repository.Where(t => t.EMail == inDto.EmailOrPhone || t.Phone == inDto.EmailOrPhone).FirstOrDefaultAsync(); + var dockerInfo = await _doctorRepository.Where(t => t.EMail == inDto.EmailOrPhone || t.Phone == inDto.EmailOrPhone).FirstOrDefaultAsync(); if (dockerInfo != null) { @@ -167,7 +169,7 @@ namespace IRaCIS.Core.Application.Contracts #region 20230804 修改调研表逻辑 - var verifyRecord = await _repository.FirstOrDefaultAsync(t => (t.EmailOrPhone == userInfo.EmailOrPhone) && t.Code == userInfo.verificationCode && t.CodeType == userInfo.verificationType); + var verifyRecord = await _verificationCodeRepository.FirstOrDefaultAsync(t => (t.EmailOrPhone == userInfo.EmailOrPhone) && t.Code == userInfo.verificationCode && t.CodeType == userInfo.verificationType); //检查数据库是否存在该验证码 if (verifyRecord == null) { @@ -630,7 +632,7 @@ namespace IRaCIS.Core.Application.Contracts survey.IsDeleted = true; - await _repository.SaveChangesAsync(); + await _trialSiteSurveyRepository.SaveChangesAsync(); return ResponseOutput.Ok(); @@ -779,7 +781,7 @@ namespace IRaCIS.Core.Application.Contracts saveItem.UserName = saveItem.UserCode; - saveItem.UserTypeEnum = _repository.Where(t => t.Id == saveItem.UserTypeId).Select(t => t.UserTypeEnum).First(); + saveItem.UserTypeEnum = _userTypeRepository.Where(t => t.Id == saveItem.UserTypeId).Select(t => t.UserTypeEnum).First(); var newUser = _userRepository.AddAsync(saveItem).Result; @@ -890,7 +892,7 @@ namespace IRaCIS.Core.Application.Contracts }); - await _repository.SaveChangesAsync(); + await _trialSiteUserRepository.SaveChangesAsync(); } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs index 2d6a4f3dc..a401e036a 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialConfigService.cs @@ -40,6 +40,7 @@ namespace IRaCIS.Core.Application IRepository _clinicalDataTrialSetRepository, IRepository _readingCriterionPageRepository, IOrganInfoService _iOrganInfoService, + IRepository _trialBodyPartRepository, IRepository _readingCriterionDictionaryRepository, IRepository _readingTrialCriterionDictionaryRepository, IReadingQuestionService iReadingQuestionService, @@ -50,6 +51,7 @@ namespace IRaCIS.Core.Application IRepository _systemBasicDataRepository, IRepository _subjectVisitRepository, IRepository _enrollRepository, + IRepository _trialStateChangeRepository, IRepository _readingTableQuestionTrialRepository) : BaseService, ITrialConfigService { @@ -909,7 +911,7 @@ namespace IRaCIS.Core.Application //await _readingQuestionCriterionTrialRepository.BatchUpdateNoTrackingAsync(t => t.TrialId == trialConfig.TrialId && t.IsSigned == false, u => new ReadingQuestionCriterionTrial() { CriterionModalitys = trialConfig.Modalitys }); - return ResponseOutput.Ok(await _repository.SaveChangesAsync()); + return ResponseOutput.Ok(await _trialRepository.SaveChangesAsync()); } @@ -1052,7 +1054,7 @@ namespace IRaCIS.Core.Application //}); ; - var result = await _repository.SaveChangesAsync(); + var result = await _trialRepository.SaveChangesAsync(); if (trialConfig.IsTrialProcessConfirmed) { @@ -1101,7 +1103,7 @@ namespace IRaCIS.Core.Application trialInfo.UpdateTime = DateTime.Now; - return ResponseOutput.Ok(await _repository.SaveChangesAsync()); + return ResponseOutput.Ok(await _trialRepository.SaveChangesAsync()); } /// @@ -1192,7 +1194,7 @@ namespace IRaCIS.Core.Application await _fusionCache.SetAsync(CacheKeys.Trial(trial.Id.ToString()), trialStatusStr, TimeSpan.FromDays(7)); - await _repository.SaveChangesAsync(); + await _trialRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } @@ -1206,7 +1208,7 @@ namespace IRaCIS.Core.Application [HttpGet("{trialId:guid}")] public async Task> GetTrialStateChangeList(Guid trialId) { - return await _repository.Where(t => t.TrialId == trialId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + return await _trialStateChangeRepository.Where(t => t.TrialId == trialId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); } @@ -1298,7 +1300,7 @@ namespace IRaCIS.Core.Application public async Task AddOrUpdateTrialBodyPart(AddOrUpdateTrialBodyPartCommand incommand) { - var codeList = await _repository.Where(t => t.TrialId == incommand.TrialId) + var codeList = await _trialBodyPartRepository.Where(t => t.TrialId == incommand.TrialId) .WhereIf(incommand.Id != null, t => t.Id != incommand.Id) .Select(t => t.Code).ToListAsync(); @@ -1322,7 +1324,7 @@ namespace IRaCIS.Core.Application VerifyMsg = _localizer["TrialBodyPart_DupName"] }; - var cro = await _repository.InsertOrUpdateAsync(incommand, true, exp); + var cro = await _trialBodyPartRepository.InsertOrUpdateAsync(incommand, true, exp); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs index 54470350d..7bc62b5bd 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialMaintenanceService.cs @@ -171,7 +171,7 @@ namespace IRaCIS.Application.Services } - var success = await _repository.SaveChangesAsync(); + var success = await _trialUseRepository.SaveChangesAsync(); return ResponseOutput.Result(success); } @@ -205,7 +205,7 @@ namespace IRaCIS.Application.Services _mapper.Map(updateTrialUserCommand, trialUser); - await _repository.SaveChangesAsync(); + await _trialUseRepository.SaveChangesAsync(); return ResponseOutput.Ok(); @@ -239,7 +239,7 @@ namespace IRaCIS.Application.Services await _trialUseRepository.BatchUpdateNoTrackingAsync(t => t.Id == id, u => new TrialUser() { IsDeleted = isDelete, RemoveTime = isDelete ? DateTime.Now : null }); - await _repository.SaveChangesAsync(); + await _trialUseRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs index 7c6ac366c..761cb5462 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialService.cs @@ -32,6 +32,7 @@ namespace IRaCIS.Application.Services IRepository _visitStageRepository, IRepository _trialPaymentPriceRepository, IRepository _trialDictionaryRepository, + IRepository _trialBodyPartRepository, IOptionsMonitor _verifyConfig) : BaseService, ITrialService { @@ -222,7 +223,7 @@ namespace IRaCIS.Application.Services await _visitStageRepository.AddAsync(new VisitStage { TrialId = trial.Id, VisitNum = 1, BlindName = "B" + 10.ToString("D3"), VisitDay = 30, VisitName = "Visit 1", VisitWindowLeft = -5, VisitWindowRight = 5 }); - var success = await _repository.SaveChangesAsync(); + var success = await _trialRepository.SaveChangesAsync(); //维护CRO Sponsor await DealSponsorAndCROAsync(trial); @@ -238,7 +239,7 @@ namespace IRaCIS.Application.Services } - await _repository.AddRangeAsync(needAddBodyPartList, true); + await _trialBodyPartRepository.AddRangeAsync(needAddBodyPartList, true); await _fusionCache.SetAsync(CacheKeys.Trial(trial.Id.ToString()), StaticData.TrialState.TrialInitializing, TimeSpan.FromDays(7)); @@ -286,7 +287,7 @@ namespace IRaCIS.Application.Services trial.DeclarationTypes = $"|{string.Join('|', updateModel.DeclarationTypeEnumList.Select(x => ((int)x).ToString()).ToList())}|"; trial.AttendedReviewerTypes = $"|{string.Join('|', updateModel.AttendedReviewerTypeEnumList.Select(x => ((int)x).ToString()).ToList())}|"; - var success = await _repository.SaveChangesAsync(); + var success = await _trialRepository.SaveChangesAsync(); //维护CRO Sponsor await DealSponsorAndCROAsync(trial); diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs index 41fc1c5ab..66f63f1f2 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/TrialSiteService.cs @@ -133,7 +133,7 @@ namespace IRaCIS.Core.Application.Services await _trialSiteRepository.AddRangeAsync(addArray); - return ResponseOutput.Result(await _repository.SaveChangesAsync()); + return ResponseOutput.Result(await _trialSiteRepository.SaveChangesAsync()); } @@ -309,9 +309,9 @@ namespace IRaCIS.Core.Application.Services return ResponseOutput.NotOk(_localizer["TrialSite_CannotDeleteAssociatedSubject"]); } - await _repository.DeleteAsync(relation); + await _trialSiteRepository.DeleteAsync(relation); - return ResponseOutput.Result(await _repository.SaveChangesAsync()); + return ResponseOutput.Result(await _trialSiteUserRepository.SaveChangesAsync()); } diff --git a/IRaCIS.Core.Application/Service/Visit/PatientService.cs b/IRaCIS.Core.Application/Service/Visit/PatientService.cs index ff9d85f72..d69f2a4d0 100644 --- a/IRaCIS.Core.Application/Service/Visit/PatientService.cs +++ b/IRaCIS.Core.Application/Service/Visit/PatientService.cs @@ -55,6 +55,7 @@ namespace IRaCIS.Application.Services IRepository _dictionaryRepository, IRepository _dicomStudyRepository, IRepository _scpPatientRepository, + IRepository _scpImageUploadRepository, IDistributedLockProvider _distributedLockProvider) : BaseService { @@ -106,7 +107,7 @@ namespace IRaCIS.Application.Services [HttpPost] public async Task>> GetSCPImageUploadList(SCPImageUploadQuery inQuery) { - var query = _repository.Where(t => t.TrialId == inQuery.TrialId) + var query = _scpImageUploadRepository.Where(t => t.TrialId == inQuery.TrialId) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.CalledAE), t => t.CalledAE.Contains(inQuery.CalledAE)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.CallingAEIP), t => t.CallingAEIP.Contains(inQuery.CallingAEIP)) .WhereIf(!string.IsNullOrWhiteSpace(inQuery.CallingAE), t => t.CallingAE.Contains(inQuery.CallingAE)) @@ -578,7 +579,6 @@ namespace IRaCIS.Application.Services } } - await _repository.SaveChangesAsync(); await _scpPatientRepository.BatchUpdateNoTrackingAsync(t => t.Id == scpStudy.PatientId, u => new SCPPatient() { SubjectId = subjectId }); await _scpStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == scpStudyId, u => new SCPStudy() { SubjectVisitId = subjectVisitId }); } @@ -588,7 +588,7 @@ namespace IRaCIS.Application.Services - await _repository.SaveChangesAsync(); + await _scpStudyRepository.SaveChangesAsync(); return ResponseOutput.Ok(); diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index dc58f47d8..8672695b0 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -31,6 +31,7 @@ namespace IRaCIS.Core.Application.Services IRepository _noneDicomStudyFileRepository, IRepository _subjectRepository, IRepository _dicomInstanceRepository, + IRepository _taskStudyRepository, IServiceProvider _serviceProvider, IRepository _dicomSeriesRepository, IRepository _trialReadingCriterionRepository @@ -185,7 +186,7 @@ namespace IRaCIS.Core.Application.Services //[Authorize(Policy = IRaCISPolicy.CRC)] public async Task DeleteSV(Guid id) { - if (await _repository.AnyAsync(t => t.SubjectVisitId == id)) + if (await _dicomStudyRepository.AnyAsync(t => t.SubjectVisitId == id)) { //---当前访视已经有影像上传,不允许删除。 return ResponseOutput.NotOk(_localizer["Visit_UploadedNoDelete"]); @@ -449,7 +450,7 @@ namespace IRaCIS.Core.Application.Services if (taskInfo.TaskStudyCount > 0) { - var taskStudyList = await _repository.Where(t => t.TrialId == indto.TrialId && t.VisitTaskId == indto.VisitTaskId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); + var taskStudyList = await _taskStudyRepository.Where(t => t.TrialId == indto.TrialId && t.VisitTaskId == indto.VisitTaskId).ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); foreach (var study in taskStudyList) { diff --git a/IRaCIS.Core.Application/TestService.cs b/IRaCIS.Core.Application/TestService.cs index 8eb6f2bce..089c33355 100644 --- a/IRaCIS.Core.Application/TestService.cs +++ b/IRaCIS.Core.Application/TestService.cs @@ -41,12 +41,15 @@ namespace IRaCIS.Application.Services IRepository _systemDocumentRepository, IRepository _trialClinicalDataSetCriterionRepository, IRepository _dicomInstanceRepository, + IRepository _internationalizationRepository, IRepository _systemDocConfirmedUserRepository, IRepository _dicomStudyRepository, + IRepository _clinicalDataTrialSetRepository, IRepository _readingQuestionCriterionTrialRepository, IRepository _visitTaskRepository, IRepository _dicomSeriesRepository, IRepository _userRepository, + IRepository _trialBodyPartRepository, IDistributedLockProvider _distributedLockProvider, ILogger _logger) : BaseService { @@ -79,7 +82,7 @@ namespace IRaCIS.Application.Services await _readingConsistentClinicalDataRepository.BatchDeleteNoTrackingAsync(t => consistentSubjectIdList.Contains(t.SubjectId)); - await _repository.SaveChangesAsync(); + await _readingConsistentClinicalDataRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } @@ -175,11 +178,11 @@ namespace IRaCIS.Application.Services foreach (var row in rows) { - await _repository.InsertOrUpdateAsync(row); + await _internationalizationRepository.InsertOrUpdateAsync(row); } - await _repository.SaveChangesAsync(); + await _internationalizationRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } @@ -188,7 +191,6 @@ namespace IRaCIS.Application.Services public async Task Get() { - await _repository.Where(t => t.SubjectId == Guid.Empty).Include(t => t.ReadingClinicalDataPDFList).ExecuteDeleteAsync(); // Generate RSA keys var keyPair = RSAHelper.GenerateRSAKeyPair(2048); @@ -436,10 +438,10 @@ namespace IRaCIS.Application.Services tempList.ForEach(t => t.TrialId = trialId); - await _repository.AddRangeAsync(tempList); + await _trialBodyPartRepository.AddRangeAsync(tempList); } - await _repository.SaveChangesAsync(); + await _dicRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } @@ -451,7 +453,7 @@ namespace IRaCIS.Application.Services [AllowAnonymous] public async Task ModifyClinicalDataTable() { - var needAddList = _repository.Where(t => t.CriterionEnumListStr != String.Empty && t.TrialClinicalDataSetCriteriaList.Count() == 0).ToList(); + var needAddList = _clinicalDataTrialSetRepository.Where(t => t.CriterionEnumListStr != String.Empty && t.TrialClinicalDataSetCriteriaList.Count() == 0).ToList(); //遍历项目 @@ -478,7 +480,7 @@ namespace IRaCIS.Application.Services } } } - await _repository.SaveChangesAsync(); + await _trialClinicalDataSetCriterionRepository.SaveChangesAsync(); return ResponseOutput.Ok(); } @@ -553,7 +555,7 @@ namespace IRaCIS.Application.Services Console.WriteLine($"Error: {ex.Message}"); } - await _repository.SaveChangesAsync(); + await _dicomStudyRepository.SaveChangesAsync(); }