Compare commits
No commits in common. "e6b3c662e28477b809a8fb999b56d9cc8ad9cc60" and "71217999005ce72bde50f21463aefcb8622bf952" have entirely different histories.
e6b3c662e2
...
7121799900
|
|
@ -1151,7 +1151,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
|
|
||||||
DicomStudyId = t.DicomStudy.Id,
|
DicomStudyId = t.DicomStudy.Id,
|
||||||
|
|
||||||
PatientId = info.TrialCode + "-" + t.DicomStudy.Subject.Code,
|
PatientId = info.TrialCode + "-" + t.DicomStudy.PatientId,
|
||||||
PatientName = t.DicomStudy.PatientName,
|
PatientName = t.DicomStudy.PatientName,
|
||||||
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
||||||
PatientSex = t.DicomStudy.PatientSex,
|
PatientSex = t.DicomStudy.PatientSex,
|
||||||
|
|
@ -1585,7 +1585,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
|
|
||||||
DicomStudyId = t.TaskStudy.Id,
|
DicomStudyId = t.TaskStudy.Id,
|
||||||
|
|
||||||
PatientId = info.TrialCode + "-" + t.TaskStudy.Subject.Code,
|
PatientId = info.TrialCode + "-" + t.TaskStudy.PatientId,
|
||||||
PatientName = t.TaskStudy.PatientName,
|
PatientName = t.TaskStudy.PatientName,
|
||||||
PatientBirthDate = t.TaskStudy.PatientBirthDate,
|
PatientBirthDate = t.TaskStudy.PatientBirthDate,
|
||||||
PatientSex = t.TaskStudy.PatientSex,
|
PatientSex = t.TaskStudy.PatientSex,
|
||||||
|
|
@ -2270,7 +2270,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
|
|
||||||
DicomStudyId = t.DicomStudy.Id,
|
DicomStudyId = t.DicomStudy.Id,
|
||||||
|
|
||||||
PatientId = t.Trial.TrialCode + "-" + t.DicomStudy.Subject.Code,
|
PatientId = t.Trial.TrialCode + "-" + t.DicomStudy.PatientId,
|
||||||
PatientName = t.DicomStudy.PatientName,
|
PatientName = t.DicomStudy.PatientName,
|
||||||
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
||||||
PatientSex = t.DicomStudy.PatientSex,
|
PatientSex = t.DicomStudy.PatientSex,
|
||||||
|
|
|
||||||
|
|
@ -243,121 +243,104 @@ namespace IRaCIS.Core.Application.Service
|
||||||
.Select(t => new
|
.Select(t => new
|
||||||
{
|
{
|
||||||
SubjectCode = t.DicomStudy.Subject.Code,
|
SubjectCode = t.DicomStudy.Subject.Code,
|
||||||
//t.DicomStudy.ModalityForEdit,
|
t.DicomStudy.ModalityForEdit,
|
||||||
//t.Path,
|
t.Path,
|
||||||
//t.FileSize,
|
t.FileSize
|
||||||
t.DicomStudy.PatientId,
|
}).ToListAsync();
|
||||||
t.DicomStudy.Id,
|
|
||||||
t.DicomStudy.StudyDIRPath
|
|
||||||
}).Distinct().ToListAsync();
|
|
||||||
|
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
if (item.SubjectCode != item.PatientId)
|
Console.WriteLine(item.Path);
|
||||||
|
|
||||||
|
await using var stream = await _IOSSService.GetStreamFromOSSAsync(item.Path);
|
||||||
|
|
||||||
|
var dicomFile = DicomFile.Open(stream, FileReadOption.ReadLargeOnDemand);
|
||||||
|
|
||||||
|
switch (item.SubjectCode)
|
||||||
{
|
{
|
||||||
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new DicomStudy() { PatientId = item.SubjectCode });
|
case "04032":
|
||||||
|
|
||||||
await _IOSSService.DeleteFromPrefix(item.StudyDIRPath.TrimStart("/"), true);
|
dicomFile.Dataset.AddOrUpdate(DicomTag.PatientID, $"{trialCode}-04032");
|
||||||
}
|
dicomFile.Dataset.AddOrUpdate(DicomTag.ClinicalTrialSubjectID, "04032");
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "12004":
|
||||||
|
dicomFile.Dataset.AddOrUpdate(DicomTag.PatientID, $"{trialCode}-12004");
|
||||||
|
dicomFile.Dataset.AddOrUpdate(DicomTag.ClinicalTrialSubjectID, "12004");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "04004":
|
||||||
|
dicomFile.Dataset.AddOrUpdate(DicomTag.PatientID, $"{trialCode}-04004");
|
||||||
|
dicomFile.Dataset.AddOrUpdate(DicomTag.ClinicalTrialSubjectID, "04004");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "04005":
|
||||||
|
dicomFile.Dataset.AddOrUpdate(DicomTag.PatientID, $"{trialCode}-04005");
|
||||||
|
dicomFile.Dataset.AddOrUpdate(DicomTag.ClinicalTrialSubjectID, "04005");
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//获取原始目录 和文件名
|
||||||
|
var folder = item.Path.Substring(0, item.Path.LastIndexOf('/')).TrimStart('/');
|
||||||
|
var fileName = Path.GetFileName(item.Path);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//if (isUploadOss == false)
|
||||||
|
//{
|
||||||
|
// // 本地完整路径
|
||||||
|
// var localPath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
|
||||||
|
|
||||||
|
// // 写入文件
|
||||||
|
// await using var fileStream = File.Create(localPath);
|
||||||
|
// await output.CopyToAsync(fileStream);
|
||||||
|
|
||||||
|
// // 可选:确保写入完成再关闭
|
||||||
|
// await fileStream.FlushAsync();
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
if (isUploadOss == true)
|
||||||
|
{
|
||||||
|
//4 保存到一个 MemoryStream
|
||||||
|
await using var output = new MemoryStream();
|
||||||
|
dicomFile.Save(output);
|
||||||
|
output.Position = 0;
|
||||||
|
|
||||||
|
|
||||||
|
await _IOSSService.UploadToOSSAsync(output, folder, fileName, false);
|
||||||
|
|
||||||
|
//var pipe = new System.IO.Pipelines.Pipe();
|
||||||
|
|
||||||
|
//// 写入端:fo-dicom
|
||||||
|
//_ = Task.Run(async () =>
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// await using var writer = pipe.Writer.AsStream();
|
||||||
|
// dicomFile.Save(writer); // 直接写 Pipe
|
||||||
|
// await pipe.Writer.CompleteAsync();
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// await pipe.Writer.CompleteAsync(ex);
|
||||||
|
// }
|
||||||
|
//});
|
||||||
|
|
||||||
|
////await _IOSSService.UploadToOSSAsync(pipe.Reader.AsStream(), folder, fileName, false);
|
||||||
|
|
||||||
|
await _IOSSService.DeleteFromPrefix(item.Path.TrimStart("/"), true);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return ResponseOutput.Ok();
|
return ResponseOutput.Ok();
|
||||||
|
|
||||||
//foreach (var item in list)
|
|
||||||
//{
|
|
||||||
// Console.WriteLine(item.Path);
|
|
||||||
|
|
||||||
// await using var stream = await _IOSSService.GetStreamFromOSSAsync(item.Path);
|
|
||||||
|
|
||||||
// var dicomFile = DicomFile.Open(stream, FileReadOption.ReadLargeOnDemand);
|
|
||||||
|
|
||||||
// switch (item.SubjectCode)
|
|
||||||
// {
|
|
||||||
// case "04032":
|
|
||||||
|
|
||||||
// dicomFile.Dataset.AddOrUpdate(DicomTag.PatientID, $"{trialCode}-04032");
|
|
||||||
// dicomFile.Dataset.AddOrUpdate(DicomTag.ClinicalTrialSubjectID, "04032");
|
|
||||||
|
|
||||||
// break;
|
|
||||||
// case "12004":
|
|
||||||
// dicomFile.Dataset.AddOrUpdate(DicomTag.PatientID, $"{trialCode}-12004");
|
|
||||||
// dicomFile.Dataset.AddOrUpdate(DicomTag.ClinicalTrialSubjectID, "12004");
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case "04004":
|
|
||||||
// dicomFile.Dataset.AddOrUpdate(DicomTag.PatientID, $"{trialCode}-04004");
|
|
||||||
// dicomFile.Dataset.AddOrUpdate(DicomTag.ClinicalTrialSubjectID, "04004");
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case "04005":
|
|
||||||
// dicomFile.Dataset.AddOrUpdate(DicomTag.PatientID, $"{trialCode}-04005");
|
|
||||||
// dicomFile.Dataset.AddOrUpdate(DicomTag.ClinicalTrialSubjectID, "04005");
|
|
||||||
// break;
|
|
||||||
|
|
||||||
|
|
||||||
// default:
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //获取原始目录 和文件名
|
|
||||||
// var folder = item.Path.Substring(0, item.Path.LastIndexOf('/')).TrimStart('/');
|
|
||||||
// var fileName = Path.GetFileName(item.Path);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// //if (isUploadOss == false)
|
|
||||||
// //{
|
|
||||||
// // // 本地完整路径
|
|
||||||
// // var localPath = Path.Combine(Directory.GetCurrentDirectory(), fileName);
|
|
||||||
|
|
||||||
// // // 写入文件
|
|
||||||
// // await using var fileStream = File.Create(localPath);
|
|
||||||
// // await output.CopyToAsync(fileStream);
|
|
||||||
|
|
||||||
// // // 可选:确保写入完成再关闭
|
|
||||||
// // await fileStream.FlushAsync();
|
|
||||||
// //}
|
|
||||||
// //else
|
|
||||||
// if (isUploadOss == true)
|
|
||||||
// {
|
|
||||||
// //4 保存到一个 MemoryStream
|
|
||||||
// await using var output = new MemoryStream();
|
|
||||||
// dicomFile.Save(output);
|
|
||||||
// output.Position = 0;
|
|
||||||
|
|
||||||
|
|
||||||
// await _IOSSService.UploadToOSSAsync(output, folder, fileName, false);
|
|
||||||
|
|
||||||
// //var pipe = new System.IO.Pipelines.Pipe();
|
|
||||||
|
|
||||||
// //// 写入端:fo-dicom
|
|
||||||
// //_ = Task.Run(async () =>
|
|
||||||
// //{
|
|
||||||
// // try
|
|
||||||
// // {
|
|
||||||
// // await using var writer = pipe.Writer.AsStream();
|
|
||||||
// // dicomFile.Save(writer); // 直接写 Pipe
|
|
||||||
// // await pipe.Writer.CompleteAsync();
|
|
||||||
// // }
|
|
||||||
// // catch (Exception ex)
|
|
||||||
// // {
|
|
||||||
// // await pipe.Writer.CompleteAsync(ex);
|
|
||||||
// // }
|
|
||||||
// //});
|
|
||||||
|
|
||||||
// ////await _IOSSService.UploadToOSSAsync(pipe.Reader.AsStream(), folder, fileName, false);
|
|
||||||
|
|
||||||
// await _IOSSService.DeleteFromPrefix(item.Path.TrimStart("/"), true);
|
|
||||||
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
//return ResponseOutput.Ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@ public class TaskInstance : BaseFullAuditEntity, IEntitySeqId
|
||||||
[ForeignKey("StudyId")]
|
[ForeignKey("StudyId")]
|
||||||
public TaskStudy TaskStudy { get; set; }
|
public TaskStudy TaskStudy { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
|
||||||
[ForeignKey("SubjectId")]
|
|
||||||
public Subject Subject { get; set; }
|
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
[ForeignKey("SubjectVisitId")]
|
[ForeignKey("SubjectVisitId")]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue