Automate replacing one DICOM tag with another


First, thank you very much for Orthanc!

Could someone give me hints how to achieve this...
I want to replace one DICOM tag in all patients stored in Orthanc with another DICOM tag. What would be the correct REST call/curl command? To be more precise... I have a lot of patients/studies in my database where the comments are wrongly stored in the "RETIRED_StudyComments" tag, and I want to copy the data from this tag to the "StudyDescription" tag. Is there a way to automate it?

Thank you very much for your help!


Here is a sample Python script that should meet your requirement:

import json
import sys

from RestToolbox import *

SOURCE = ‘RETIRED_StudyComments’
TARGET = ‘StudyDescription’

for study in DoGet(‘http://localhost:8042/studies’):
instance = DoGet(‘http://localhost:8042/studies/%s/instances’ % study)[0][‘ID’]
tags = DoGet(‘http://localhost:8042/instances/%s/tags?simplify’ % instance)
if SOURCE in tags:
print(‘Modifying study %s’ % study)
modified = DoPost(‘http://localhost:8042/studies/%s/modify’ % study,
{ ‘Replace’ : { TARGET : tags[SOURCE] },
‘Remove’ : [ SOURCE ]})
DoDelete(‘http://localhost:8042/studies/%s’ % study)

In a nutshell, this script loops over the studies stored by Orthanc. For each study, it selects one of its instance to read the content of the “RETIRED_StudyComments” tag. If this tag is present, the study is modified to put this value into “StudyDescription”. Note that the file “” is shipped with the source distribution of Orthanc.


Thank you so much for your very fast response! I'll try it with your script! Merry X-Mas!