Bug 140 - Modifying private tags with REST API changes VR from LO to UN
Summary: Modifying private tags with REST API changes VR from LO to UN
Status: RESOLVED FIXED
Alias: None
Product: Orthanc
Classification: Unclassified
Component: Orthanc Core (show other bugs)
Version: unspecified
Hardware: All All
: --- minor
Assignee: Sébastien Jodogne
URL:
Depends on:
Blocks:
 
Reported: 2020-06-29 15:15 CEST by Sébastien Jodogne
Modified: 2020-06-29 15:27 CEST (History)
0 users

See Also:


Attachments
2583496647-orthanc-tags.jpg (135.87 KB, image/jpeg)
2020-06-29 15:15 CEST, Sébastien Jodogne
Details
3173254069-radiologic-dump.jpg (59.35 KB, image/jpeg)
2020-06-29 15:15 CEST, Sébastien Jodogne
Details
3565065530-modified-rest-api-dump.jpg (45.77 KB, image/jpeg)
2020-06-29 15:15 CEST, Sébastien Jodogne
Details
2363588212-modified-system-dcmtk-dump.jpg (45.35 KB, image/jpeg)
2020-06-29 15:15 CEST, Sébastien Jodogne
Details
radiologic-dic.json (907 bytes, text/plain)
2020-06-29 15:17 CEST, Sébastien Jodogne
Details
radiologic.dcm (1.09 KB, application/dicom)
2020-06-29 15:17 CEST, Sébastien Jodogne
Details
orthanc-trace-log.txt (13.45 KB, text/plain)
2020-06-29 15:17 CEST, Sébastien Jodogne
Details
modified-system-dcmtk.dcm (1.09 KB, application/dicom)
2020-06-29 15:17 CEST, Sébastien Jodogne
Details
modified-rest-api.dcm (1.10 KB, application/dicom)
2020-06-29 15:17 CEST, Sébastien Jodogne
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sébastien Jodogne 2020-06-29 15:15:32 CEST
[BitBucket user: Marco Barnig]
[BitBucket date: 2019-05-03.20:47:46]

**What steps will reproduce the problem?**   
Upload the attached DICOM file radiologic.dcm to Orthanc server.

By adding the attached radiologic-dic.json file to the Orthanc configuration the private tags are displayed as expected in the Orthanc tag panel.



![](2583496647-orthanc-tags.jpg)
An extract of a dump created with the dicom3tool dciodvfy is shown below:

![](3173254069-radiologic-dump.jpg)
Execute the curl command

```
curl http://<ip-adress:port>/instances/f1c8c9de-c1f0dd83-a1de5468-03def2fe-c24d3589/modify -X POST -d ‘{"Replace":{"RadioButton3":"aaabbbccc"}}’ > modified-rest-api.dcm
```

or

```
curl http://<ip-adress:port>/instances/f1c8c9de-c1f0dd83-a1de5468-03def2fe-c24d3589/modify -X POST -d ‘{"Replace":{"4321,1012":"aaabbbccc"}}’ > modified-rest-api.dcm
```

The related Orthanc log file is attached as orthanc-trace-log.txt.

**What is the expected output?**

A new DICOM file with value in tag \(4321,1013\) changed from _jklmnopq_ to _aaabbbccc_.

**What do you see instead?**  
A new DICOM file with VR of tag \(4321,1013\) changed from LO to UN.

An extract of a dump created with the dicom3tool dciodvfy is shown below:

![](3565065530-modified-rest-api-dump.jpg)
When modifying the series, study or patient instead of the instance with the REST API, the result is the same.

**What version of the product are you using? On what operating system?**  
Orthanc 1.5.6 in Docker Linux, natif in Windows 10 and natif in OS X 10.13.6. Same results in all systems.

**Temporary solution:**   
As a workaround I can use my own callback in a plugin to modify the files. Here is my code snippet:

```
{ 
  string myDcmtkCommand = "dcmtk-3.6.4/bin/dcmodify -m '(4321,1012)=aaabbbcc' /temp/radiologic.dcm";
  int resultDcmtk = system(myDcmtkCommand.c_str()); 
  ... 
  return OrthancPluginErrorCode_Success; 
}
```

An extract of a dump created with the dicom3tool dciodvfy is shown below:

![](2363588212-modified-system-dcmtk-dump.jpg)
Another workaround consist in using the modified files with VR = UN, because I can read the hexadecimal content and convert it to a string.

Both methods are not very elegant.

**What are references?**   
My contributions in the Orthanc Forum dated April 9, 2019 \( [Managing private tags is tricky](https://groups.google.com/forum/#!searchin/orthanc-users/mbarnig%7Csort:date/orthanc-users/p5S4YkHcTrc/h8PgZ2seAgAJ) \) and June 1, 2016 \( [Questions about private tags](https://groups.google.com/forum/#!msg/orthanc-users/v60O7x3uYF0/tiuOQTBuAgAJ) \).
Comment 1 Sébastien Jodogne 2020-06-29 15:15:34 CEST
Created attachment 11 [details]
2583496647-orthanc-tags.jpg
Comment 2 Sébastien Jodogne 2020-06-29 15:15:36 CEST
Created attachment 12 [details]
3173254069-radiologic-dump.jpg
Comment 3 Sébastien Jodogne 2020-06-29 15:15:38 CEST
Created attachment 13 [details]
3565065530-modified-rest-api-dump.jpg
Comment 4 Sébastien Jodogne 2020-06-29 15:15:40 CEST
Created attachment 14 [details]
2363588212-modified-system-dcmtk-dump.jpg
Comment 5 Sébastien Jodogne 2020-06-29 15:17:12 CEST
Created attachment 27 [details]
radiologic-dic.json
Comment 6 Sébastien Jodogne 2020-06-29 15:17:13 CEST
Created attachment 28 [details]
radiologic.dcm
Comment 7 Sébastien Jodogne 2020-06-29 15:17:14 CEST
Created attachment 29 [details]
orthanc-trace-log.txt
Comment 8 Sébastien Jodogne 2020-06-29 15:17:15 CEST
Created attachment 30 [details]
modified-system-dcmtk.dcm
Comment 9 Sébastien Jodogne 2020-06-29 15:17:16 CEST
Created attachment 31 [details]
modified-rest-api.dcm
Comment 10 Sébastien Jodogne 2020-06-29 15:25:21 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2019-05-06.13:24:29]

An integration test is available to reproduce the issue: https://hg.orthanc-server.com/orthanc-tests/changeset/9929e4af2b7a85dbd8812ef5f8927463ca777c11
Comment 11 Sébastien Jodogne 2020-06-29 15:26:59 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2020-02-25.20:44:16]

Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT

→ https://hg.orthanc-server.com/orthanc/changeset/4922bdd046dd
Comment 12 Sébastien Jodogne 2020-06-29 15:27:00 CEST
[BitBucket user: Sébastien Jodogne]
[BitBucket date: 2020-02-25.20:49:51]

The trick is first to define the private tag in the configuration file of Orthanc:

```
{ 
  [...]
  "Dictionary": {
    "4321,1012" : ["LO","RadioButton3",1,1,"RadioLogic"]
  }
}
```

Then, to provide the “PrivateCreator” argument \(introduced in forthcoming Orthanc 1.6.0\) while calling the REST API:

`curl <http://ip-adress:port/instances/f1c8c9de-c1f0dd83-a1de5468-03def2fe-c24d3589/modify> -X POST -d ‘{"Replace":{"RadioButton3":"aaabbbccc"},”PrivateCreator”:”RadioLogic”}’ > modified-rest-api.dcm`