DICOM RetrieveURL tag is empty in JSON output

211 views Asked by At

I am using a DicomDataSet to add tags and their values as below following:

....
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); 
....

when I make json per ds I don't see value for 00081190 like json in this link.

making json file snipped code:

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);

why vrvalue representation for RetrieveUrl(81190) tag is UN(unknown), the output is something like below:

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

There are 1 answers

0
Aria On BEST ANSWER

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.