DIR 生成修改PatientId
parent
1514694e37
commit
3a06ecd66d
|
|
@ -1151,7 +1151,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
|
|
||||||
DicomStudyId = t.DicomStudy.Id,
|
DicomStudyId = t.DicomStudy.Id,
|
||||||
|
|
||||||
PatientId = info.TrialCode + "-" + t.DicomStudy.PatientId,
|
PatientId = info.TrialCode + "-" + t.DicomStudy.Subject.Code,
|
||||||
PatientName = t.DicomStudy.PatientName,
|
PatientName = t.DicomStudy.PatientName,
|
||||||
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
||||||
PatientSex = t.DicomStudy.PatientSex,
|
PatientSex = t.DicomStudy.PatientSex,
|
||||||
|
|
@ -1582,7 +1582,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
|
|
||||||
DicomStudyId = t.TaskStudy.Id,
|
DicomStudyId = t.TaskStudy.Id,
|
||||||
|
|
||||||
PatientId = info.TrialCode + "-" + t.TaskStudy.PatientId,
|
PatientId = info.TrialCode + "-" + t.TaskStudy.Subject.Code,
|
||||||
PatientName = t.TaskStudy.PatientName,
|
PatientName = t.TaskStudy.PatientName,
|
||||||
PatientBirthDate = t.TaskStudy.PatientBirthDate,
|
PatientBirthDate = t.TaskStudy.PatientBirthDate,
|
||||||
PatientSex = t.TaskStudy.PatientSex,
|
PatientSex = t.TaskStudy.PatientSex,
|
||||||
|
|
@ -2265,7 +2265,7 @@ namespace IRaCIS.Core.Application.Service.ImageAndDoc
|
||||||
|
|
||||||
DicomStudyId = t.DicomStudy.Id,
|
DicomStudyId = t.DicomStudy.Id,
|
||||||
|
|
||||||
PatientId = t.Trial.TrialCode + "-" + t.DicomStudy.PatientId,
|
PatientId = t.Trial.TrialCode + "-" + t.DicomStudy.Subject.Code,
|
||||||
PatientName = t.DicomStudy.PatientName,
|
PatientName = t.DicomStudy.PatientName,
|
||||||
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
PatientBirthDate = t.DicomStudy.PatientBirthDate,
|
||||||
PatientSex = t.DicomStudy.PatientSex,
|
PatientSex = t.DicomStudy.PatientSex,
|
||||||
|
|
|
||||||
|
|
@ -170,104 +170,121 @@ 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,
|
||||||
}).ToListAsync();
|
t.DicomStudy.PatientId,
|
||||||
|
t.DicomStudy.Id,
|
||||||
|
t.DicomStudy.StudyDIRPath
|
||||||
|
}).Distinct().ToListAsync();
|
||||||
|
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
{
|
{
|
||||||
Console.WriteLine(item.Path);
|
if (item.SubjectCode != item.PatientId)
|
||||||
|
|
||||||
await using var stream = await _IOSSService.GetStreamFromOSSAsync(item.Path);
|
|
||||||
|
|
||||||
var dicomFile = DicomFile.Open(stream, FileReadOption.ReadLargeOnDemand);
|
|
||||||
|
|
||||||
switch (item.SubjectCode)
|
|
||||||
{
|
{
|
||||||
case "04032":
|
await _dicomStudyRepository.BatchUpdateNoTrackingAsync(t => t.Id == item.Id, u => new DicomStudy() { PatientId = item.SubjectCode });
|
||||||
|
|
||||||
dicomFile.Dataset.AddOrUpdate(DicomTag.PatientID, $"{trialCode}-04032");
|
await _IOSSService.DeleteFromPrefix(item.StudyDIRPath.TrimStart("/"), true);
|
||||||
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,6 +13,9 @@ 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