@@ -520,7 +520,68 @@ namespace IRaCIS.Core.Application.Contracts
|
||||
|
||||
}
|
||||
|
||||
#region 下载重新生成名字
|
||||
public class ImageDownloadDto
|
||||
{
|
||||
public Guid TrialId { get; set; }
|
||||
public Guid SubjectId { get; set; }
|
||||
public string SubjectCode { get; set; }
|
||||
public string TrialSiteCode { get; set; }
|
||||
public string VisitName { get; set; }
|
||||
|
||||
public string TaskBlindName { get; set; }
|
||||
|
||||
|
||||
public Guid VisitId { get; set; }
|
||||
|
||||
public List<DownloadDicomStudyDto> StudyList { get; set; }
|
||||
public List<DownloadNoneDicomStudyDto> NoneDicomStudyList { get; set; }
|
||||
}
|
||||
|
||||
public class DownloadDicomStudyDto
|
||||
{
|
||||
public string PatientId { get; set; }
|
||||
public DateTime? StudyTime { get; set; }
|
||||
public string StudyCode { get; set; }
|
||||
public string StudyInstanceUid { get; set; }
|
||||
public string StudyDIRPath { get; set; }
|
||||
|
||||
public List<DownloadDicomSeriesDto> SeriesList { get; set; }
|
||||
}
|
||||
|
||||
public class DownloadDicomSeriesDto
|
||||
{
|
||||
public string Modality { get; set; }
|
||||
|
||||
public List<DownloadDicomInstanceDto> InstanceList { get; set; }
|
||||
}
|
||||
|
||||
public class DownloadDicomInstanceDto
|
||||
{
|
||||
public Guid InstanceId { get; set; }
|
||||
public string FileName { get; set; }
|
||||
public string Path { get; set; }
|
||||
public long? FileSize { get; set; }
|
||||
}
|
||||
|
||||
public class DownloadNoneDicomStudyDto
|
||||
{
|
||||
public string Modality { get; set; }
|
||||
public string StudyCode { get; set; }
|
||||
public DateTime? ImageDate { get; set; }
|
||||
|
||||
public List<DownloadNoneDicomFileDto> FileList { get; set; } = new();
|
||||
}
|
||||
|
||||
public class DownloadNoneDicomFileDto
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string FileType { get; set; }
|
||||
public long? FileSize { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public class CRCUploadedStudyQuqry
|
||||
{
|
||||
|
||||
@@ -782,6 +782,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
var imageType = (isQueryDicom && isQueryNoneDicom) ? ImageType.DicomAndNoneDicom : (isQueryDicom ? ImageType.Dicom : ImageType.NoneDicom);
|
||||
|
||||
var dirDic = new Dictionary<string, string>();
|
||||
#region DIR处理导出文件名,并将对应关系上传到OSS里面存储
|
||||
|
||||
//有传输语法值的导出 才生成DIR
|
||||
@@ -831,9 +832,15 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
{
|
||||
var ossFolder = $"{pathInfo.TrialId}/Image/{pathInfo.SubjectId}/{pathInfo.VisitId}/{item.Key.StudyInstanceUid}";
|
||||
|
||||
await DicomDIRHelper.GenerateStudyDIRAndUploadAsync(item.ToList(), ossFolder, _oSSService);
|
||||
var (isSucess, dic) = await SafeBussinessHelper.RunAsync(async () => await DicomDIRHelper.GenerateStudyDIRAndUploadAsync(item.ToList(), ossFolder, _oSSService));
|
||||
|
||||
dirDic = dic;
|
||||
|
||||
if (isSucess)
|
||||
{
|
||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new DicomStudy() { StudyDIRPath = $"/{ossFolder}/DICOMDIR" });
|
||||
}
|
||||
|
||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new DicomStudy() { StudyDIRPath = $"/{ossFolder}/DICOMDIR" });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -843,7 +850,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
var query = from sv in _subjectVisitRepository.Where(t => t.Id == inQuery.SubjectVisitId)
|
||||
|
||||
|
||||
select new
|
||||
select new ImageDownloadDto()
|
||||
{
|
||||
TrialId = sv.TrialId,
|
||||
SubjectId = sv.SubjectId,
|
||||
@@ -854,48 +861,57 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
StudyList = sv.StudyList.Where(t => isQueryDicom ? inQuery.DicomStudyIdList.Contains(t.Id) : false)
|
||||
|
||||
.Select(u => new
|
||||
.Select(u => new DownloadDicomStudyDto()
|
||||
{
|
||||
u.PatientId,
|
||||
u.StudyTime,
|
||||
u.StudyCode,
|
||||
u.StudyInstanceUid,
|
||||
u.StudyDIRPath,
|
||||
PatientId = u.PatientId,
|
||||
StudyTime = u.StudyTime,
|
||||
StudyCode = u.StudyCode,
|
||||
StudyInstanceUid = u.StudyInstanceUid,
|
||||
StudyDIRPath = u.StudyDIRPath,
|
||||
|
||||
SeriesList = u.SeriesList.Select(z => new
|
||||
SeriesList = u.SeriesList.Select(z => new DownloadDicomSeriesDto()
|
||||
{
|
||||
z.Modality,
|
||||
Modality = z.Modality,
|
||||
|
||||
InstanceList = z.DicomInstanceList.Select(k => new
|
||||
InstanceList = z.DicomInstanceList.Select(k => new DownloadDicomInstanceDto()
|
||||
{
|
||||
k.Path,
|
||||
k.FileSize
|
||||
})
|
||||
})
|
||||
InstanceId = k.Id,
|
||||
FileName = string.Empty,
|
||||
Path = k.Path,
|
||||
FileSize = k.FileSize
|
||||
}).ToList()
|
||||
}).ToList()
|
||||
|
||||
}).ToList(),
|
||||
|
||||
NoneDicomStudyList = sv.NoneDicomStudyList.Where(t => isQueryNoneDicom ? inQuery.NoneDicomStudyIdList.Contains(t.Id) : false)
|
||||
|
||||
.Select(nd => new
|
||||
.Select(nd => new DownloadNoneDicomStudyDto()
|
||||
{
|
||||
nd.Modality,
|
||||
nd.StudyCode,
|
||||
nd.ImageDate,
|
||||
Modality = nd.Modality,
|
||||
StudyCode = nd.StudyCode,
|
||||
ImageDate = nd.ImageDate,
|
||||
|
||||
FileList = nd.NoneDicomFileList.Select(file => new
|
||||
FileList = nd.NoneDicomFileList.Select(file => new DownloadNoneDicomFileDto()
|
||||
{
|
||||
file.FileName,
|
||||
file.Path,
|
||||
file.FileType,
|
||||
file.FileSize,
|
||||
})
|
||||
FileName = file.FileName,
|
||||
Path = file.Path,
|
||||
FileType = file.FileType,
|
||||
FileSize = file.FileSize
|
||||
}).ToList()
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
var result = query.FirstOrDefault();
|
||||
|
||||
|
||||
foreach (var item in result.StudyList.SelectMany(t => t.SeriesList).SelectMany(t => t.InstanceList))
|
||||
{
|
||||
var key = item.InstanceId.ToString();
|
||||
if (dirDic.ContainsKey(key))
|
||||
{
|
||||
item.FileName = dirDic[key];
|
||||
}
|
||||
}
|
||||
|
||||
var preDownloadInfo = new TrialImageDownload()
|
||||
{
|
||||
@@ -1070,12 +1086,13 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
var trialSiteCode = _visitTaskRepository.Where(t => t.Id == taskIdList.FirstOrDefault()).Select(t => t.IsAnalysisCreate ? t.BlindTrialSiteCode : t.Subject.TrialSite.TrialSiteCode).FirstOrDefault() ?? string.Empty;
|
||||
|
||||
var dirDic = new Dictionary<string, string>();
|
||||
#region 在下载前先处理DIR文件
|
||||
|
||||
//有传输语法值的导出 才生成DIR
|
||||
if (_subjectVisitRepository.Any(t => t.SubjectId == inQuery.SubjectId && t.StudyList.SelectMany(t => t.InstanceList).Any(c => c.TransferSytaxUID != string.Empty)))
|
||||
{
|
||||
var list = _subjectRepository.Where(t => t.Id == inQuery.SubjectId).SelectMany(t => t.SubjectVisitList.Where(t => subjectVisitIdList.Contains(t.Id))).SelectMany(t => t.StudyList)
|
||||
var dirInfolist = _subjectRepository.Where(t => t.Id == inQuery.SubjectId).SelectMany(t => t.SubjectVisitList.Where(t => subjectVisitIdList.Contains(t.Id))).SelectMany(t => t.StudyList)
|
||||
.Where(t => isQueryDicom ? inQuery.DicomStudyIdList.Contains(t.Id) : false)
|
||||
.Where(t => info.IsImageFilter ? ("|" + info.CriterionModalitys + "|").Contains("|" + t.ModalityForEdit + "|") : true)
|
||||
.SelectMany(t => t.InstanceList.Where(t => t.IsReading && t.DicomSerie.IsReading))
|
||||
@@ -1117,15 +1134,21 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
|
||||
var pathInfo = await _subjectRepository.Where(t => t.Id == inQuery.SubjectId).Select(t => new { t.TrialId, SubjectId = t.Id }).FirstNotNullAsync();
|
||||
|
||||
foreach (var item in list.GroupBy(t => new { t.StudyInstanceUid, t.DicomStudyId }))
|
||||
foreach (var item in dirInfolist.GroupBy(t => new { t.StudyInstanceUid, t.DicomStudyId }))
|
||||
{
|
||||
var visitId = item.First().SubjectVisitId;
|
||||
|
||||
var ossFolder = $"{pathInfo.TrialId}/Image/{pathInfo.SubjectId}/{visitId}/{item.Key.StudyInstanceUid}";
|
||||
|
||||
await DicomDIRHelper.GenerateStudyDIRAndUploadAsync(item.ToList(), ossFolder, _oSSService);
|
||||
var (isSucess, dic) = await SafeBussinessHelper.RunAsync(async () => await DicomDIRHelper.GenerateStudyDIRAndUploadAsync(item.ToList(), ossFolder, _oSSService));
|
||||
|
||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new DicomStudy() { StudyDIRPath = $"/{ossFolder}/DICOMDIR" });
|
||||
dirDic = dic;
|
||||
|
||||
if (isSucess)
|
||||
{
|
||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Key.DicomStudyId, u => new DicomStudy() { StudyDIRPath = $"/{ossFolder}/DICOMDIR" });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1136,55 +1159,70 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
join visitTask in _visitTaskRepository.Where(t => taskIdList.Contains(t.Id))
|
||||
|
||||
on sv.Id equals visitTask.SourceSubjectVisitId
|
||||
select new
|
||||
select new ImageDownloadDto()
|
||||
{
|
||||
SubjectCode = inQuery.SubjectCode,
|
||||
VisitName = sv.VisitName,
|
||||
TaskBlindName = visitTask.TaskBlindName,
|
||||
StudyList = sv.StudyList.Where(t => isQueryDicom ? inQuery.DicomStudyIdList.Contains(t.Id) : false)
|
||||
.Where(t => info.IsImageFilter ? ("|" + info.CriterionModalitys + "|").Contains("|" + t.ModalityForEdit + "|") : true)
|
||||
.Select(u => new
|
||||
.Select(u => new DownloadDicomStudyDto()
|
||||
{
|
||||
u.PatientId,
|
||||
u.StudyTime,
|
||||
u.StudyCode,
|
||||
u.StudyDIRPath,
|
||||
PatientId = u.PatientId,
|
||||
StudyTime = u.StudyTime,
|
||||
StudyCode = u.StudyCode,
|
||||
StudyInstanceUid = u.StudyInstanceUid,
|
||||
StudyDIRPath = u.StudyDIRPath,
|
||||
|
||||
SeriesList = u.SeriesList.Where(t => t.IsReading).Select(z => new
|
||||
SeriesList = u.SeriesList.Where(t => t.IsReading).Select(z => new DownloadDicomSeriesDto()
|
||||
{
|
||||
z.Modality,
|
||||
Modality = z.Modality,
|
||||
|
||||
InstancePathList = z.DicomInstanceList.Where(t => t.IsReading).Select(k => new
|
||||
InstanceList = z.DicomInstanceList.Where(t => t.IsReading).Select(k => new DownloadDicomInstanceDto()
|
||||
{
|
||||
k.Path,
|
||||
k.FileSize
|
||||
})
|
||||
})
|
||||
|
||||
}),
|
||||
InstanceId = k.Id,
|
||||
FileName = string.Empty,
|
||||
Path = k.Path,
|
||||
FileSize = k.FileSize
|
||||
}).ToList()
|
||||
}).ToList()
|
||||
}).ToList(),
|
||||
|
||||
NoneDicomStudyList = sv.NoneDicomStudyList.Where(t => isQueryNoneDicom ? inQuery.NoneDicomStudyIdList.Contains(t.Id) : false)
|
||||
.Where(t => info.IsImageFilter ? ("|" + info.CriterionModalitys + "|").Contains("|" + t.Modality + "|") : true)
|
||||
.Where(t => t.IsReading)
|
||||
.Select(nd => new
|
||||
{
|
||||
nd.Modality,
|
||||
nd.StudyCode,
|
||||
nd.ImageDate,
|
||||
.Select(nd => new DownloadNoneDicomStudyDto()
|
||||
{
|
||||
Modality = nd.Modality,
|
||||
StudyCode = nd.StudyCode,
|
||||
ImageDate = nd.ImageDate,
|
||||
|
||||
FileList = nd.NoneDicomFileList.Where(t => t.IsReading).Select(file => new
|
||||
{
|
||||
file.FileName,
|
||||
file.Path,
|
||||
file.FileType,
|
||||
file.FileSize
|
||||
})
|
||||
})
|
||||
FileList = nd.NoneDicomFileList.Where(t => t.IsReading).Select(file => new DownloadNoneDicomFileDto()
|
||||
{
|
||||
FileName = file.FileName,
|
||||
Path = file.Path,
|
||||
FileType = file.FileType,
|
||||
FileSize = file.FileSize
|
||||
}).ToList()
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
|
||||
|
||||
var result = await query.ToListAsync();
|
||||
var list = await query.ToListAsync();
|
||||
|
||||
foreach (var result in list)
|
||||
{
|
||||
foreach (var item in result.StudyList.SelectMany(t => t.SeriesList).SelectMany(t => t.InstanceList))
|
||||
{
|
||||
var key = item.InstanceId.ToString();
|
||||
if (dirDic.ContainsKey(key))
|
||||
{
|
||||
item.FileName = dirDic[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1199,17 +1237,17 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||
DownloadStartTime = DateTime.Now,
|
||||
IsSuccess = false,
|
||||
ImageType = imageType,
|
||||
VisitName = string.Join(" | ", result.Select(t => t.VisitName).OrderBy(t => t).ToList()),
|
||||
NoneDicomStudyCount = result.Sum(t => t.NoneDicomStudyList.Count()),
|
||||
DicomStudyCount = result.Sum(t => t.StudyList.Count()),
|
||||
ImageCount = result.Sum(t => t.StudyList.Sum(s => s.SeriesList.Sum(s => s.InstancePathList.Count())) + t.NoneDicomStudyList.Sum(s => s.FileList.Count())),
|
||||
ImageSize = result.Sum(t => t.StudyList.Sum(t => t.SeriesList.Sum(s => s.InstancePathList.Sum(i => i.FileSize))) + t.NoneDicomStudyList.Sum(t => t.FileList.Sum(s => s.FileSize))
|
||||
VisitName = string.Join(" | ", list.Select(t => t.VisitName).OrderBy(t => t).ToList()),
|
||||
NoneDicomStudyCount = list.Sum(t => t.NoneDicomStudyList.Count()),
|
||||
DicomStudyCount = list.Sum(t => t.StudyList.Count()),
|
||||
ImageCount = list.Sum(t => t.StudyList.Sum(s => s.SeriesList.Sum(s => s.InstanceList.Count())) + t.NoneDicomStudyList.Sum(s => s.FileList.Count())),
|
||||
ImageSize = list.Sum(t => t.StudyList.Sum(t => t.SeriesList.Sum(s => s.InstanceList.Sum(i => i.FileSize))) + t.NoneDicomStudyList.Sum(t => t.FileList.Sum(s => s.FileSize))
|
||||
) ?? 0
|
||||
};
|
||||
|
||||
await _trialImageDownloadRepository.AddAsync(preDownloadInfo, true);
|
||||
|
||||
return ResponseOutput.Ok(result, new { PreDownloadId = preDownloadInfo.Id, info.IsReadingTaskViewInOrder });
|
||||
return ResponseOutput.Ok(list, new { PreDownloadId = preDownloadInfo.Id, info.IsReadingTaskViewInOrder });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user