diff --git a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs index ecb6ae1c4..a5c2db85d 100644 --- a/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs +++ b/IRaCIS.Core.Application/Service/Inspection/InspectionService.cs @@ -79,14 +79,12 @@ namespace IRaCIS.Core.Application.Service.Inspection from lefttrialSign in trialSigntemp.DefaultIfEmpty() - join leftfrontAuditConfig in _repository.GetQueryable().Where(x=>x.ConfigType=="M"&&x.Identification!=null) on new - { - data.Identification - } equals new - { - leftfrontAuditConfig.Identification, + join leftfrontAuditConfig in _repository.GetQueryable().Where(x=>x.ConfigType=="M"&&x.Identification!=null) on + data.Identification.ToLower() + equals + leftfrontAuditConfig.Identification.ToLower() - } + diff --git a/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs b/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs index 9581152de..bd4dc587e 100644 --- a/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs +++ b/IRaCIS.Core.Application/Triggers/SubjectVisitTrigger.cs @@ -7,7 +7,7 @@ namespace IRaCIS.Core.Application.Triggers /// /// 处理 访视 1、提交状态 2、执行状态 3、最早最晚 拍片日期 /// - public class SubjectVisitTrigger : IAfterSaveTrigger, IAfterSaveTrigger + public class SubjectVisitTrigger : IAfterSaveTrigger, IAfterSaveTrigger, IAfterSaveTrigger { private readonly IRepository _subjectVisitRepository; @@ -60,6 +60,19 @@ namespace IRaCIS.Core.Application.Triggers } + public async Task AfterSave(ITriggerContext context, CancellationToken cancellationToken) + { + var subjectVisitId =await _subjectVisitRepository._dbContext.NoneDicomStudy.Where(x=>x.Id== context.Entity.NoneDicomStudyId).Select(x=>x.SubjectVisitId).FirstOrDefaultAsync(); + + + if (context.ChangeType == ChangeType.Deleted) + { + + await UpdateSubjectVisitSubmitStateAsync(subjectVisitId); + } + + } + /// 处理提交状态 public async Task UpdateSubjectVisitSubmitStateAsync(Guid subjectVisitId) diff --git a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs index 63a467795..bde268bab 100644 --- a/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs +++ b/IRaCIS.Core.Infra.EFCore/Common/AuditingData.cs @@ -128,6 +128,96 @@ namespace IRaCIS.Core.Infra.EFCore.Common FinalSubjectVisitName = FinalSubjectVisitName, }); } + + + // 检查 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy))) + { + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + + + }); + } + + + // 序列 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomSeries))) + { + var entity = item.Entity as DicomSeries; + if (entity.DicomStudy == null) + { + entity.DicomStudy = await _dbContext.DicomStudys.AsNoTracking().FirstOrDefaultAsync(x => x.Id == entity.StudyId); + } + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }, new + { + StudyCode = entity.DicomStudy?.StudyCode, + Modalities = entity.DicomStudy?.Modalities, + + }); + } + + // 非Dicom + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudy))) + { + var entity = item.Entity as NoneDicomStudy; + var filecount = await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.Id).CountAsync(); + switch (GetRequestUrl().ToLower()) + { + case "nonedicomstudy/addorupdatenonedicomstudy": + type = _userInfo.UserTypeShortName + "/" + type; + break; + } + + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + }, new + { + FileCount = filecount, + }); + } + + // 非Dicom文件 + foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile))) + { + var entity = item.Entity as NoneDicomStudyFile; + var noneDicomStudy = entity.NoneDicomStudy; + if (noneDicomStudy == null) + { + noneDicomStudy = await _dbContext.NoneDicomStudy.FirstOrDefaultAsync(x => x.Id == entity.NoneDicomStudyId); + } + noneDicomStudy = noneDicomStudy ?? new NoneDicomStudy(); + var fileCount = 0; + if (type == "Add") + { + fileCount = _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.NoneDicomStudyId).Count() + 1; + } else if (type == "Deleted") + { + fileCount = _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.NoneDicomStudyId).Count() - 1; + } + await InsertInspection(item, type, x => new DataInspection() + { + GeneralId = x.Id, + TrialId = noneDicomStudy.TrialId, + SubjectId = noneDicomStudy.SubjectId, + SiteId= noneDicomStudy.SiteId, + SubjectVisitId = noneDicomStudy.SubjectVisitId, + + },new { + StudyCode = noneDicomStudy.StudyCode, + Modality= noneDicomStudy.Modality, + BodyPart= noneDicomStudy.BodyPart, + FileCount= fileCount, + ImageDate= noneDicomStudy.ImageDate, + UpNum= 1,// 每次上传或下载一个 + }); + } + // 访视 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(SubjectVisit))) { @@ -151,15 +241,11 @@ namespace IRaCIS.Core.Infra.EFCore.Common break; } - - var subjectCode = entity.Subject?.Code; - await InsertInspection(item, type, x => new DataInspection() { SubjectCode= subjectCode, SubjectId=x.SubjectId, - SubjectVisitId = x.Id, SubjectVisitName=x.VisitName, BlindName=x.BlindName, @@ -170,9 +256,20 @@ namespace IRaCIS.Core.Infra.EFCore.Common // 既往手术史 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousSurgery))) { + var entity = item.Entity as PreviousSurgery; + var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync(); + subjectvisit = subjectvisit ?? new SubjectVisit(); await InsertInspection(item, type, x => new DataInspection() { GeneralId = x.Id, + SiteId = subjectvisit.SiteId, + SubjectVisitName = subjectvisit.VisitName, + TrialId = subjectvisit.TrialId, + SubjectId = subjectvisit.SubjectId, + + }, new + { + Type = "既往手术史" }); } @@ -180,94 +277,41 @@ namespace IRaCIS.Core.Infra.EFCore.Common // 既往放疗史 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousHistory))) { + var entity = item.Entity as PreviousHistory; + var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync(); + subjectvisit = subjectvisit ?? new SubjectVisit(); await InsertInspection(item, type, x => new DataInspection() { GeneralId = x.Id, + SiteId = subjectvisit.SiteId, + SubjectVisitName = subjectvisit.VisitName, + TrialId = subjectvisit.TrialId, + SubjectId = subjectvisit.SubjectId, + }, new + { + Type = "既往放疗史" }); } // 其他治疗史 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(PreviousOther))) { - + var entity = item.Entity as PreviousOther; + var subjectvisit = await _dbContext.SubjectVisit.Where(x => x.Id == entity.SubjectVisitId).FirstOrDefaultAsync(); + subjectvisit = subjectvisit ?? new SubjectVisit(); await InsertInspection(item, type, x => new DataInspection() { GeneralId = x.Id, - }); - } - - // 检查 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomStudy))) - { - await InsertInspection(item, type, x => new DataInspection() - { - GeneralId = x.Id, - - - }); - } - - - // 序列 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(DicomSeries))) - { - var entity = item.Entity as DicomSeries; - if (entity.DicomStudy == null) - { - entity.DicomStudy =await _dbContext.DicomStudys.AsNoTracking().FirstOrDefaultAsync(x=>x.Id== entity.StudyId); - } - await InsertInspection(item, type, x => new DataInspection() - { - GeneralId = x.Id, + SiteId = subjectvisit.SiteId, + SubjectVisitName = subjectvisit.VisitName, + TrialId = subjectvisit.TrialId, + SubjectId = subjectvisit.SubjectId, }, new { - StudyCode = entity.DicomStudy?.StudyCode, - Modalities = entity.DicomStudy?.Modalities, - + Type = "其他治疗史" }); } - // 非Dicom - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudy))) - { - var entity = item.Entity as NoneDicomStudy; - var filecount =await _dbContext.NoneDicomStudyFile.Where(x => x.NoneDicomStudyId == entity.Id).CountAsync(); - switch (GetRequestUrl().ToLower()) - { - case "nonedicomstudy/addorupdatenonedicomstudy": - type = _userInfo.UserTypeShortName + "/" + type; - break; - } - - await InsertInspection(item, type, x => new DataInspection() - { - GeneralId = x.Id, - },new { - FileCount= filecount, - }); - } - - // 非Dicom文件 - foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(NoneDicomStudyFile))) - { - var entity = item.Entity as NoneDicomStudyFile; - var noneDicomStudy = entity.NoneDicomStudy; - if (noneDicomStudy == null) - { - noneDicomStudy = await _dbContext.NoneDicomStudy.FirstOrDefaultAsync(x => x.Id == entity.NoneDicomStudyId); - } - noneDicomStudy = noneDicomStudy ?? new NoneDicomStudy(); - await InsertInspection(item, type, x => new DataInspection() - { - GeneralId = x.Id, - TrialId= noneDicomStudy.TrialId, - SubjectId=noneDicomStudy.SubjectId, - SubjectVisitId=noneDicomStudy.SubjectVisitId, - }); - } - - - //质疑 foreach (var item in entitys.Where(x => x.Entity.GetType() == typeof(QCChallenge))) {