From 5246c10e32891fd72dc51a10e95c2ac5ce5f7fce Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Mon, 22 Jul 2024 15:41:16 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=A3=80=E6=9F=A5=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E3=80=81=E6=B7=BB=E5=8A=A0=E3=80=81=E7=BB=B4=E6=8A=A4?= =?UTF-8?q?=E7=BB=91=E5=AE=9A=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Service/QC/QCOperationService.cs | 39 ++++++++++++++----- .../Service/Visit/PatientService.cs | 21 +++++----- IRaCIS.Core.Domain/Image/SCPStudy.cs | 1 + 3 files changed, 42 insertions(+), 19 deletions(-) diff --git a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs index bd00eef1f..d67743443 100644 --- a/IRaCIS.Core.Application/Service/QC/QCOperationService.cs +++ b/IRaCIS.Core.Application/Service/QC/QCOperationService.cs @@ -17,6 +17,7 @@ using IRaCIS.Core.Application.ViewModel; using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Application.Service; using Medallion.Threading; +using DocumentFormat.OpenXml.Office2010.Excel; namespace IRaCIS.Core.Application.Image.QA { @@ -802,28 +803,46 @@ namespace IRaCIS.Core.Application.Image.QA var succeess2 = await _repository.BatchDeleteAsync(t => t.StudyId == id); var success3 = await _dicomSeriesrepository.BatchDeleteNoTrackingAsync(t => t.StudyId == id); + await _repository.BatchUpdateAsync(t => t.Id == id,u=>new SCPStudy() { SubjectVisitId=null}); + + + //var success3 = await _dicomSeriesrepository.DeleteFromQueryAsync(t => t.StudyId == id, true); //var success4 = await _repository.BatchDeleteAsync(t => t.StudyId == id); //删除 物理文件 - var instancePathList = await _repository.Where(t => t.StudyId == id) - .Select(t => t.Path).ToListAsync(); + //var instancePathList = await _repository.Where(t => t.StudyId == id) + // .Select(t => t.Path).ToListAsync(); - instancePathList.ForEach(path => - { + //instancePathList.ForEach(path => + //{ - var physicalPath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, path); + // var physicalPath = FileStoreHelper.GetPhysicalFilePath(_hostEnvironment, path); - if (System.IO.File.Exists(physicalPath)) - { - File.Delete(physicalPath); - } - }); + // if (System.IO.File.Exists(physicalPath)) + // { + // File.Delete(physicalPath); + // } + //}); } + var subjectId=waitDeleteStudyList.Select(t=>t.SubjectId).FirstOrDefault(); + + var patientList = _repository.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())) + { + await _repository.BatchUpdateAsync(t => t.Id == patientId, u => new SCPPatient() { SubjectId = null }); + } + } + + + await _subjectVisitRepository.SaveChangesAsync(); diff --git a/IRaCIS.Core.Application/Service/Visit/PatientService.cs b/IRaCIS.Core.Application/Service/Visit/PatientService.cs index f0f6f684a..da2f95207 100644 --- a/IRaCIS.Core.Application/Service/Visit/PatientService.cs +++ b/IRaCIS.Core.Application/Service/Visit/PatientService.cs @@ -192,7 +192,7 @@ namespace IRaCIS.Application.Services SCPStudyId = scpStudy.Id, SeriesCount = scpStudy.SeriesCount, StudyTime = scpStudy.StudyTime, - + @@ -229,7 +229,7 @@ namespace IRaCIS.Application.Services public async Task> GetDicomModalityList(Guid trialId) { - var list = await _scpStudyRepository.Where(t => t.TrialId == trialId).SelectMany(t => t.SeriesList).Select(t=>t.Modality).Distinct().ToListAsync(); + var list = await _scpStudyRepository.Where(t => t.TrialId == trialId).SelectMany(t => t.SeriesList).Select(t => t.Modality).Distinct().ToListAsync(); return list; } @@ -265,10 +265,10 @@ namespace IRaCIS.Application.Services SCPStudyId = scpStudy.Id, SeriesCount = scpStudy.SeriesCount, StudyTime = scpStudy.StudyTime, - BodyPartExamined=scpStudy.BodyPartExamined, - AccessionNumber=scpStudy.AccessionNumber, + BodyPartExamined = scpStudy.BodyPartExamined, + AccessionNumber = scpStudy.AccessionNumber, - PatientBirthDate=scpStudy.PatientBirthDate, + PatientBirthDate = scpStudy.PatientBirthDate, PatientAge = scpStudy.PatientAge, PatientIdStr = scpStudy.PatientIdStr, PatientName = scpStudy.PatientName, @@ -311,12 +311,12 @@ namespace IRaCIS.Application.Services foreach (var scpStudyId in inCommand.SCPStudyIdList) { - var find = _scpStudyRepository.Where(t => t.Id == scpStudyId).Include(t => t.SeriesList).Include(t => t.InstanceList).FirstOrDefault(); + var find = _scpStudyRepository.Where(t => t.Id == scpStudyId).Select(t => new { SCPStudy = t, t.SeriesList, t.InstanceList }).FirstOrDefault(); if (find != null) { - var newStuty = _mapper.Map(find); + var newStuty = _mapper.Map(find.SCPStudy); await _repository.AddAsync(newStuty); @@ -345,8 +345,6 @@ namespace IRaCIS.Application.Services foreach (var instance in newInstanceList) { - - instance.SeqId = Guid.Empty; instance.TrialId = trialId; instance.SubjectId = subjectId; @@ -358,6 +356,10 @@ namespace IRaCIS.Application.Services currentNextCodeInt++; + await _repository.BatchUpdateAsync(t => t.Id == find.SCPStudy.PatientId, u => new SCPPatient() { SubjectId = subjectId }); + await _repository.BatchUpdateAsync(t => t.Id == scpStudyId, u => new SCPStudy() { SubjectVisitId = subjectVisitId }); + + } @@ -367,6 +369,7 @@ namespace IRaCIS.Application.Services await _repository.SaveChangesAsync(); + return ResponseOutput.Ok(); } diff --git a/IRaCIS.Core.Domain/Image/SCPStudy.cs b/IRaCIS.Core.Domain/Image/SCPStudy.cs index 4af3686cd..2fff33c5f 100644 --- a/IRaCIS.Core.Domain/Image/SCPStudy.cs +++ b/IRaCIS.Core.Domain/Image/SCPStudy.cs @@ -99,5 +99,6 @@ namespace IRaCIS.Core.Domain.Models [JsonIgnore] public TrialSite TrialSite { get; set; } + } }