From 7c5f3323de95b5bee769fdfbc6cf97a13e016792 Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Thu, 1 Aug 2024 16:57:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=8B=E8=BD=BD=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ImageAndDoc/DTO/UnionStudyViewDodel.cs | 14 ++ .../ImageAndDoc/DownloadAndUploadService.cs | 142 +++++++++++++++--- 2 files changed, 135 insertions(+), 21 deletions(-) diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs index 6be7f1de5..24982f635 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DTO/UnionStudyViewDodel.cs @@ -214,6 +214,20 @@ namespace IRaCIS.Core.Application.Contracts public int FileCount { get; set; } } + + public class SubejctZipInfoQuery + { + public Guid? SubejctId { get; set; } + + public string? SubjectCode { get; set; } + + + public Guid? SubejectVisitId { get; set; } + + public Guid? TrialReadingCriterionId { get; set; } + + } + public class TaskArchiveStudyCommand { [NotDefault] diff --git a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs index 9f71bad89..acf4c3dd5 100644 --- a/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs +++ b/IRaCIS.Core.Application/Service/ImageAndDoc/DownloadAndUploadService.cs @@ -4,6 +4,7 @@ using IRaCIS.Core.Application.Contracts; using IRaCIS.Core.Application.Filter; using IRaCIS.Core.Application.Helper; using IRaCIS.Core.Application.Service.ImageAndDoc.DTO; +using IRaCIS.Core.Domain.Models; using IRaCIS.Core.Domain.Share; using IRaCIS.Core.Infrastructure; using IRaCIS.Core.Infrastructure.Extention; @@ -11,6 +12,7 @@ using MassTransit; using MathNet.Numerics; using Medallion.Threading; using Microsoft.AspNetCore.Mvc; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal; using Newtonsoft.Json; using System; using System.Collections.Generic; @@ -536,36 +538,134 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc - public async Task GetSubejectVisitPathInfo(Guid subjectVisitId) + /// + /// 受试者级别所有的影像 + /// 访视级别的影响 传递subjectVisitId + /// 标准Id是可选的 不同标准有些检查可能有过滤 + /// + /// + /// + /// + public async Task GetSubejectOrVisitZipInfo([FromServices] IRepository _subjectRepository, SubejctZipInfoQuery inQuery) { - var query = from sv in _subjectVisitRepository.Where(t => t.Id == subjectVisitId) + var isImageFilter = false; - select new - { - SubjectCode = sv.Subject.Code, - VisitName = sv.VisitName, - StudyList = sv.StudyList.Select(u => new + var criterionModalitys = string.Empty; + + if (inQuery.TrialReadingCriterionId != null) + { + var criterionInfo = await _repository.Where(t => t.Id == inQuery.TrialReadingCriterionId).Select(t => new { t.IsImageFilter, t.CriterionModalitys }).FirstOrDefaultAsync(); + + if (criterionInfo != null) + { + isImageFilter = criterionInfo.IsImageFilter; + criterionModalitys = criterionInfo.CriterionModalitys; + } + + } + + if (inQuery.SubejectVisitId != null) + { + var query = from sv in _subjectVisitRepository.Where(t => t.Id == inQuery.SubejectVisitId) + + + select new { - u.PatientId, - u.StudyTime, - u.StudyCode, - - SeriesList = u.SeriesList.Select(z => new + SubjectCode = sv.Subject.Code, + VisitName = sv.VisitName, + StudyList = sv.StudyList.AsQueryable().WhereIf(isImageFilter, t => ("|" + criterionModalitys + "|").Contains("|" + t.ModalityForEdit + "|")) + .Select(u => new { - z.Modality, + u.PatientId, + u.StudyTime, + u.StudyCode, - InstancePathList = z.DicomInstanceList.Select(k => new + SeriesList = u.SeriesList.Select(z => new { - k.Path + z.Modality, + + InstancePathList = z.DicomInstanceList.Select(k => new + { + k.Path + }) + }) + + }), + + NoneDicomStudyList = sv.NoneDicomStudyList.AsQueryable().WhereIf(isImageFilter, t => ("|" + criterionModalitys + "|").Contains("|" + t.Modality + "|")) + .Select(nd => new + { + nd.Modality, + nd.StudyCode, + nd.ImageDate, + + FileList = nd.NoneDicomFileList.Select(file => new + { + file.FileName, + file.Path, + file.FileType }) }) + }; - }) - }; + var result = query.ToList(); + + return ResponseOutput.Ok(result); + } + else if (inQuery.SubejctId != null) + { + var query = from sv in _subjectRepository.Where(t => t.Id == inQuery.SubejctId).SelectMany(t=>t.SubjectVisitList) + + + select new + { + SubjectCode = sv.Subject.Code, + VisitName = sv.VisitName, + StudyList = sv.StudyList.AsQueryable().WhereIf(isImageFilter, t => ("|" + criterionModalitys + "|").Contains("|" + t.ModalityForEdit + "|")) + .Select(u => new + { + u.PatientId, + u.StudyTime, + u.StudyCode, + + SeriesList = u.SeriesList.Select(z => new + { + z.Modality, + + InstancePathList = z.DicomInstanceList.Select(k => new + { + k.Path + }) + }) + + }), + + NoneDicomStudyList = sv.NoneDicomStudyList.AsQueryable().WhereIf(isImageFilter, t => ("|" + criterionModalitys + "|").Contains("|" + t.Modality + "|")) + .Select(nd => new + { + nd.Modality, + nd.StudyCode, + nd.ImageDate, + + FileList = nd.NoneDicomFileList.Select(file => new + { + file.FileName, + file.Path, + file.FileType + }) + }) + }; + + var result = query.ToList(); + + return ResponseOutput.Ok(result); + } + else + { + return ResponseOutput.NotOk("不允许 subjectId subjectId 都不传递"); + } - var info = query.FirstOrDefault(); - return ResponseOutput.Ok(info); } /// @@ -765,9 +865,9 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc foreach (var file in noneDicomStudy.FileList) { string destinationPath = Path.Combine(studyNoneDicomFolderPath, Path.GetFileName(file.FileName)); - + //下载到当前目录 - await _oSSService.DownLoadFromOSSAsync(HttpUtility.UrlDecode(file.Path) , destinationPath); + await _oSSService.DownLoadFromOSSAsync(HttpUtility.UrlDecode(file.Path), destinationPath); } }