首页 > 解决方案 > JSON 输出中的 DICOM RetrieveURL 标记为空

问题描述

我正在使用 aDicomDataSet添加标签及其值,如下所示:

....
var ds = new DicomDataSet();
ds.Initialize(DicomClassType.StudyRootQueryStudy, DicomDataSetInitializeFlags.None);
ds.InsertElementAndSetValue(DicomTag.QueryRetrieveLevel, "STUDY"); 
ds.InsertElementAndSetValue(DicomTag.SpecificCharacterSet, "ISO_IR192");  
ds.InsertElementAndSetValue(DicomTag.RetrieveURL,  "http://localhost/Service/api/wado-rs/studies/" + row.StudyInstanceUID); 
....

当我json按照这个链接ds制作时,我看不到00081190类似json的价值。

制作json文件截断代码:

string jsonFileNameOut = Path.Combine(@"C:\Study", $"{DateTime.Now.Ticks}.json"); 
// Save as JSON with no binary data 
// For the demo, keep the json output file size small by skipping the pixel data 
const DicomDataSetSaveJsonFlags jsonFlags = DicomDataSetSaveJsonFlags.IgnoreBinaryData |
                                            DicomDataSetSaveJsonFlags.TrimWhiteSpace;
ds.SaveJson(jsonFileNameOut, jsonFlags);

为什么RetrieveUrl( ) 标记的vr值表示是(未知),输出如下所示:81190UN

[{
  "00080005" : { 
   "vr" : "CS", 
   "Value" : [ 
     "ISO_IR 192"
   ] 
   },
  "00080052" : { 
   "vr" : "CS", 
   "Value" : [ 
     "STUDY"
   ] 
   },
  "00081190" : { 
   "vr" : "UN"
   }
  }]

标签: c#dicomleadtools-sdk

解决方案


I finally got the solution after reading many articles I decide post the solution here for those that don't know this like me.

So in DICOM protocol there are some private tags that vr(Value Representation) for them is UN by default after parsing to json or xml so they won't present in out put.

So we should make private tag to public and set vr manually for them like what I do below:

DicomElement dm = ds.InsertElement(null, false, DicomTag.RetrieveURL, DicomVRType.UT, false, 1);
if (dm != null)
{
    ds.FreeElementValue(dm); 
    ds.SetStringValue(dm, url, DicomCharacterSetType.UnicodeInUtf8);
}

the problem resolved by InsertElement and SetStringValue.


推荐阅读