diff --git a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs index 4bb4af74d..976ebf9d4 100644 --- a/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs +++ b/IRaCIS.Core.Application/Service/Allocation/VisitTaskHelpeService.cs @@ -40,8 +40,8 @@ namespace IRaCIS.Core.Application.Service private readonly IRepository _readingTaskQuestionAnswerRepository; private readonly IRepository _readingTableAnswerRowInfoRepository; private readonly IRepository _readingTableQuestionAnswerRepository; - private readonly IRepository _readingOncologyTaskInfoRepository; - private readonly IRepository _readingTableQuestionTrialRepository; + private readonly IRepository _readingOncologyTaskInfoRepository; + private readonly IRepository _readingTableQuestionTrialRepository; private readonly IRepository _readingQuestionTrialRepository; private readonly IMapper _mapper; private readonly IUserInfo _userInfo; @@ -61,8 +61,8 @@ namespace IRaCIS.Core.Application.Service IRepository readingTaskQuestionAnswerRepository, IRepository readingTableAnswerRowInfoRepository, IRepository readingTableQuestionAnswerRepository, - IRepository ReadingOncologyTaskInfoRepository, - IRepository readingTableQuestionTrialRepository, + IRepository ReadingOncologyTaskInfoRepository, + IRepository readingTableQuestionTrialRepository, IRepository readingQuestionTrialRepository, IRepository readingJudgeInfoRepository, IRepository taskAllocationRuleRepository, IMapper mapper, IUserInfo userInfo, IRepository visitTaskReReadingRepository, @@ -78,8 +78,8 @@ namespace IRaCIS.Core.Application.Service this._readingTaskQuestionAnswerRepository = readingTaskQuestionAnswerRepository; this._readingTableAnswerRowInfoRepository = readingTableAnswerRowInfoRepository; this._readingTableQuestionAnswerRepository = readingTableQuestionAnswerRepository; - _readingOncologyTaskInfoRepository = ReadingOncologyTaskInfoRepository; - this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository; + _readingOncologyTaskInfoRepository = ReadingOncologyTaskInfoRepository; + this._readingTableQuestionTrialRepository = readingTableQuestionTrialRepository; this._readingQuestionTrialRepository = readingQuestionTrialRepository; _provider = provider; _subjectVisitRepository = subjectVisitRepository; @@ -464,11 +464,11 @@ namespace IRaCIS.Core.Application.Service .Where(t => t.TrialId == trialId && t.IsSign && t.ReadingClinicalDataState == ReadingClinicalDataStatus.HaveSigned && t.ReadingId == readingId && t.ClinicalDataTrialSet.UploadRole == UploadRole.PM).Count(); - var readModule = _readModuleRepository.Where(t => t.Id == readingId).FirstOrDefault(); + var readModule = _readModuleRepository.Where(t => t.Id == readingId).FirstOrDefault(); //CRC 阅片期自定义结构化录入是否签名 bool crcReadModuleSign = true; - + //访视 if (readingCategory == ReadingCategory.Visit) @@ -509,7 +509,7 @@ namespace IRaCIS.Core.Application.Service // 肿瘤学 else if (readingCategory == ReadingCategory.Oncology) { - needSignCount= trialClinicalDataSetList.Where(t => t.TrialClinicalDataSetCriteriaList.Any(c => c.TrialReadingCriterionId == trialReadingCriterionId) && t.ClinicalDataLevel == ClinicalLevel.OncologyRead && t.UploadRole == UploadRole.PM).Count(); + needSignCount = trialClinicalDataSetList.Where(t => t.TrialClinicalDataSetCriteriaList.Any(c => c.TrialReadingCriterionId == trialReadingCriterionId) && t.ClinicalDataLevel == ClinicalLevel.OncologyRead && t.UploadRole == UploadRole.PM).Count(); if (readModule != null) { // 不存在需要CRC上传的临床数据 或者 PM已确认 @@ -527,7 +527,7 @@ namespace IRaCIS.Core.Application.Service } //可能仅仅CRC 基线 没有PM - if (needSignCount == haveSignedCount && crcReadModuleSign ) + if (needSignCount == haveSignedCount && crcReadModuleSign) { isClinicalDataSign = true; @@ -669,21 +669,22 @@ namespace IRaCIS.Core.Application.Service var isFrontTaskNeedSignButNotSign = await _visitTaskRepository.AnyAsync(t => t.TrialReadingCriterionId == trialReadingCriterionId && t.SubjectId == subjectVisit.SubjectId && t.TaskState == TaskState.Effect && t.VisitTaskNum < subjectVisit.VisitNum && t.IsNeedClinicalDataSign == true && t.IsClinicalDataSign == false); - if (visitNumList.IndexOf(subjectVisit.VisitNum) == 0) + if (trialReadingCriterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder) { - blindTaskName = visitBlindConfig.BlindBaseLineName; - } - else - { - if (trialReadingCriterionConfig.IsReadingTaskViewInOrder == ReadingOrder.InOrder) + if (visitNumList.IndexOf(subjectVisit.VisitNum) == 0) { - blindTaskName = visitBlindConfig.BlindFollowUpPrefix + " " + visitNumList.IndexOf(subjectVisit.VisitNum); + blindTaskName = visitBlindConfig.BlindBaseLineName; } else { - blindTaskName = visitBlindConfig.BlindFollowUpPrefix; + blindTaskName = visitBlindConfig.BlindFollowUpPrefix + " " + visitNumList.IndexOf(subjectVisit.VisitNum); + } } + else + { + blindTaskName = visitBlindConfig.BlindFollowUpPrefix; + } //每个访视 根据项目配置生成任务 双审生成两个 @@ -1076,7 +1077,7 @@ namespace IRaCIS.Core.Application.Service TrialReadingCriterionId = trialReadingCriterionConfig.TrialReadingCriterionId, IsNeedClinicalDataSign = isNeedClinicalDataSign, IsClinicalDataSign = isClinicalDataSign, - IsFrontTaskNeedSignButNotSign= isFrontTaskNeedSignButNotSign + IsFrontTaskNeedSignButNotSign = isFrontTaskNeedSignButNotSign }); @@ -1610,12 +1611,12 @@ namespace IRaCIS.Core.Application.Service var oncologySubjectUser = await _subjectUserRepository.Where(x => x.SubjectId == item.SubjectId && x.ArmEnum == Arm.TumorArm && x.IsConfirmed && x.TrialReadingCriterionId == originalTaskInfo.TrialReadingCriterionId).FirstOrDefaultAsync(); item.VisitNum = await _readModuleRepository.Where(x => x.Id == item.ReadModuleId).Select(x => x.SubjectVisit.VisitNum).FirstOrDefaultAsync(); - var id= NewId.NextGuid(); + var id = NewId.NextGuid(); - var singleTask = await _visitTaskRepository.AddAsync(new VisitTask() + var singleTask = await _visitTaskRepository.AddAsync(new VisitTask() { - Id= id, - TrialId = trialId, + Id = id, + TrialId = trialId, SubjectId = item.SubjectId, IsUrgent = originalTaskInfo.IsUrgent, TaskName = item.ReadingName, @@ -1649,20 +1650,20 @@ namespace IRaCIS.Core.Application.Service // 生成肿瘤学需要 肿瘤学阅片结果中基线,统一显示为NA // 找到基线任务ID var baseLineTaskId = await _visitTaskRepository.Where(x => x.TaskState == TaskState.Effect - && x.ArmEnum == originalTaskInfo.ArmEnum && x.VisitTaskNum == 0 - && x.SubjectId== originalTaskInfo.SubjectId - && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.TrialReadingCriterionId == originalTaskInfo.TrialReadingCriterionId).Select(x => x.Id).FirstNotNullAsync(); + && x.ArmEnum == originalTaskInfo.ArmEnum && x.VisitTaskNum == 0 + && x.SubjectId == originalTaskInfo.SubjectId + && x.ReadingTaskState == ReadingTaskState.HaveSigned && x.TrialReadingCriterionId == originalTaskInfo.TrialReadingCriterionId).Select(x => x.Id).FirstNotNullAsync(); await _readingOncologyTaskInfoRepository.AddAsync(new ReadingOncologyTaskInfo() { EvaluationResult = "-1", - EvaluationReason=string.Empty, + EvaluationReason = string.Empty, OncologyTaskId = id, VisitTaskId = baseLineTaskId, SubjectId = originalTaskInfo.SubjectId, TrialId = originalTaskInfo.TrialId }); - _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30)); + _provider.Set($"{trialId}_{StaticData.CacheKey.TaskMaxCode}", currentMaxCodeInt, TimeSpan.FromMinutes(30)); } break; } diff --git a/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs b/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs index 794f4efa5..e900e5c59 100644 --- a/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs +++ b/IRaCIS.Core.Application/Service/Institution/DTO/SiteModel.cs @@ -5,7 +5,7 @@ namespace IRaCIS.Application.Contracts { public class SiteDTO: SiteCommand { - + public DateTime CreateTime { get; set; } } public class SiteCommand @@ -29,6 +29,8 @@ namespace IRaCIS.Application.Contracts public string DirectorPhone { get; set; } = string.Empty; public string ContactName { get; set; } = string.Empty; public string ContactPhone { get; set; } = string.Empty; + + public Guid? TrialSiteId { get; set; } } public class SiteSelectionDTO @@ -44,6 +46,24 @@ namespace IRaCIS.Application.Contracts public string Country { get; set; } = String.Empty; } + + public class TrialSiteInQuery:PageInput + { + public string? TrialSiteName { get; set; } + + public string? TrialCode { get; set; } + } + + public class TrialSiteAddView + { + public Guid TrialSiteId { get; set; } + public string TrialCode { get; set; } + + public string TrialSiteName { get; set; } + + public string TrialSiteAliasName { get; set; } = String.Empty; + } + public class SiteSelectDTO : SiteDTO { public string HospitalName { get; set; } = String.Empty; diff --git a/IRaCIS.Core.Application/Service/Institution/SiteService.cs b/IRaCIS.Core.Application/Service/Institution/SiteService.cs index f8cce2a48..72e901cc3 100644 --- a/IRaCIS.Core.Application/Service/Institution/SiteService.cs +++ b/IRaCIS.Core.Application/Service/Institution/SiteService.cs @@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Mvc; using IRaCIS.Core.Domain.Share; using Medallion.Threading; using IRaCIS.Core.Domain.Models; +using System.Security.Policy; +using Site = IRaCIS.Core.Domain.Models.Site; namespace IRaCIS.Application.Services { @@ -21,7 +23,7 @@ namespace IRaCIS.Application.Services _siteRepository = siteRepository; _trialSiteUserRepository = trialSiteUserRepository; _distributedLockProvider = distributedLockProvider; - _hospitalRepository= hospitalRepository; + _hospitalRepository = hospitalRepository; } /// 分页获取研究中心列表 @@ -35,7 +37,7 @@ namespace IRaCIS.Application.Services .WhereIf(!string.IsNullOrWhiteSpace(searchModel.City), t => t.City.Contains(searchModel.City)) .WhereIf(!string.IsNullOrWhiteSpace(searchModel.Country), t => t.Country.Contains(searchModel.Country)) .WhereIf(!string.IsNullOrWhiteSpace(searchModel.Province), t => t.Province.Contains(searchModel.Province)) - .ProjectTo(_mapper.ConfigurationProvider, new { isEn_Us = _userInfo.IsEn_Us }); + .ProjectTo(_mapper.ConfigurationProvider, new { isEn_Us = _userInfo.IsEn_Us }); return await siteQueryable.ToPagedListAsync(searchModel.PageIndex, searchModel.PageSize, string.IsNullOrWhiteSpace(searchModel.SortField) ? "SiteName" : searchModel.SortField, searchModel.Asc); @@ -48,6 +50,22 @@ namespace IRaCIS.Application.Services return await _siteRepository.ProjectTo(_mapper.ConfigurationProvider).ToListAsync(); } + [HttpPost] + public async Task> GetTrialSiteList(TrialSiteInQuery inQuery) + { + var query = _repository.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() + { + TrialCode = t.Trial.TrialCode, + TrialSiteAliasName = t.TrialSiteAliasName, + TrialSiteId = t.Id, + TrialSiteName = t.TrialSiteName + }); + + return await query.ToPagedListAsync(inQuery.PageIndex, inQuery.PageSize, string.IsNullOrWhiteSpace(inQuery.SortField) ? nameof(TrialSiteAddView.TrialCode) : inQuery.SortField, inQuery.Asc); + } /// 添加研究中心 @@ -56,7 +74,7 @@ namespace IRaCIS.Application.Services var exp = new EntityVerifyExp() { - VerifyExp = h => h.SiteName.Equals(siteCommand.SiteName) || h.SiteCode.Equals(siteCommand.SiteCode), + VerifyExp = h => h.SiteName.Equals(siteCommand.SiteName) || h.SiteNameCN.Equals(siteCommand.SiteNameCN), //---已经存在同名的中心,请确认。 VerifyMsg = _localizer["Site_DupName"] }; @@ -82,15 +100,22 @@ namespace IRaCIS.Application.Services } //手动绑 - if(siteCommand.HospitalId != null) + if (siteCommand.HospitalId != null) { await _hospitalRepository.BatchUpdateNoTrackingAsync(t => t.Id == siteCommand.HospitalId, u => new Hospital() { SiteId = site.Id }); } + if (siteCommand.TrialSiteId != null) + { + await _repository.BatchUpdateAsync(t => t.Id == siteCommand.TrialSiteId, u => new TrialSite() { SiteId = site.Id }); + } + return ResponseOutput.Ok(site.Id.ToString()); } + + } /// 删除研究中心 diff --git a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialSiteViewModel.cs b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialSiteViewModel.cs index 7006e529e..ec296769e 100644 --- a/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialSiteViewModel.cs +++ b/IRaCIS.Core.Application/Service/TrialSiteUser/DTO/TrialSiteViewModel.cs @@ -19,7 +19,6 @@ namespace IRaCIS.Core.Application.Contracts.DTO public string UserKeyInfo { get; set; } = String.Empty; - } public class SiteCRCExportQueryDTO diff --git a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs index 37793e6d0..45d106551 100644 --- a/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs +++ b/IRaCIS.Core.Application/Service/Visit/SubjectVisitService.cs @@ -555,8 +555,7 @@ namespace IRaCIS.Core.Application.Services item.Description = "Key Series"; - var modalityList = await _repository.Where(s => thisSeriesIdIds.Contains(s.Id)).OrderBy(s => s.SeriesNumber). - ThenBy(s => s.SeriesTime).Select(x => x.Modality).Distinct().ToListAsync(); ; + var modalityList = await _repository.Where(s => thisSeriesIdIds.Contains(s.Id)).OrderBy(s => s.SeriesNumber).ThenBy(s => s.SeriesTime).Select(x => x.Modality).Distinct().ToListAsync(); ; item.Modality = string.Join(",", modalityList); thisVisitTaskStudy.SeriesList.Add(item); thisVisitTaskStudy.SeriesCount = thisVisitTaskStudy.SeriesList.Count; @@ -604,8 +603,7 @@ namespace IRaCIS.Core.Application.Services foreach (var t in studyList) { - t.SeriesList = seriesLists.Where(s => s.StudyId == t.StudyId).OrderBy(s => s.SeriesNumber). - ThenBy(s => s.SeriesTime).ToList(); + t.SeriesList = seriesLists.Where(s => s.StudyId == t.StudyId).OrderBy(s => s.SeriesNumber).ThenBy(s => s.SeriesTime).ToList(); t.SeriesList.ForEach(series => { diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 668549658..8c0bc8bf0 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -1634,7 +1634,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common var type = GetEntityAuditOpt(item); var entity = item.Entity as TrialSite; - if (entity.Site == null) + if (entity.Site == null && entity.SiteId!=null) { entity.Site = await _dbContext.Site.Where(x => x.Id == entity.SiteId).FirstOrDefaultAsync(); } @@ -1650,9 +1650,7 @@ namespace IRaCIS.Core.Infra.EFCore.Common SiteCode = entity.TrialSiteCode, //Site 没记录稽查 必须查询存 - SiteName = entity.Site.SiteName, - City = entity.Site.City, - Country = entity.Site.Country, + SiteName = entity.TrialSiteName }); }