Difficulty Modifying Private Tag Value

@jodogne @alainmazy
It seems an issue while modifying the value of a private tag using the Orthanc REST API.
I created a private tag using the Dictionary
“UserMetadata”: {
“AssignedDoctorEmail”: 1025
},

“UserContentType”: {
“AssignedDoctorEmail”: [1025, “text/plain”]
},

“Dictionary”: {
“9905,0010”: [“LO”, “PrivateCreatorForSMARDEX_AT_Medikalz”, 1, 1, “SMARDEX_AT_Medikalz”],
“9905,1025”: [“ST”, “AssignedDoctorEmail”, 1, 1, “SMARDEX_AT_Medikalz”]
},

“DefaultPrivateCreator”: “SMARDEX_AT_Medikalz”,

“ExtraMainDicomTags”: {
“Instance”: ,
“Series”: ,
“Study”: ,
“Patient”:
},

I managed to add a tag using this command
curl -X PUT http://localhost:8042/studies/58b54bac-e2f5e4c4-6329cd41-ac0844c3-3eee780e/metadata/AssignedDoctorEmail

I managed to see the tag added using the following command
curl -X GET http://localhost:8042/studies/58b54bac-e2f5e4c4-6329cd41-ac0844c3-3eee780e/metadata?expand
{
“AssignedDoctorEmail” : “”,
“LastUpdate” : “20240426T203725”,
“MainDicomTagsSignature” : “0008,0020;0008,0030;0008,0050;0008,0080;0008,0090;0008,1030;0020,000d;0020,0010;0032,1032;0032,1060”
}

I am trying to set the value of this private tag to be “mai@me.com” using modify command
curl http://localhost:8042/studies/58b54bac-e2f5e4c4-6329cd41-ac0844c3-3eee780e/modify -X POST -d ‘{“Replace” : {“AssignedDoctorEmail” : “mai@me.com”}, “PrivateCreator” : “SMARDEX_AT_Medikalz”}’

however it doesn’t work, the tag is not even exist in the modified study
curl -X GET http://localhost:8042/studies/f919950a-7e6b4388-24961662-0b4ed28d-adde9ac4/metadata?expand
{
“LastUpdate” : “20240429T212054”,
“MainDicomTagsSignature” : “0008,0020;0008,0030;0008,0050;0008,0080;0008,0090;0008,1030;0020,000d;0020,0010;0032,1032;0032,1060”,
“ModifiedFrom” : “58b54bac-e2f5e4c4-6329cd41-ac0844c3-3eee780e”
}

I tried the other way of using metadata
curl http://localhost:8042/studies/58b54bac-e2f5e4c4-6329cd41-ac0844c3-3eee780e/metadata -X PUT -d ‘{“AssignedDoctorEmail” : “mai@me.com”}’
However same result
curl -X GET http://localhost:8042/studies/58b54bac-e2f5e4c4-6329cd41-ac0844c3-3eee780e/metadata?expand
{
“AssignedDoctorEmail” : “”,
“LastUpdate” : “20240429T215826”,
“MainDicomTagsSignature” : “0008,0020;0008,0030;0008,0050;0008,0080;0008,0090;0008,1030;0020,000d;0020,0010;0032,1032;0032,1060”
}

Hi,

Do you actually want to attach a custom metadata or add a Private DICOM Tag ? These are 2 different notions.

To add a custom metadata, add this in your orthanc.json:

  "UserMetadata" : {
    "AssignedDoctorEmail": 1025
  },

Then, to add it:

curl -X PUT http://localhost:8042/studies/05a0713b-86294f41-9cb78acf-0c61f3c2-b14e9741/metadata/AssignedDoctorEmail -d "email@me.com"

And to retrieve it:

curl http://localhost:8042/studies/05a0713b-86294f41-9cb78acf-0c61f3c2-b14e9741/metadata/AssignedDoctorEmail

To add a Private DICOM Tag, add this in your orthanc.json (note that 9905 seems too high a value (I don’t know why) so I changed it to 7905:

    "Dictionary": {
      "7905,0010" : ["LO", "PrivateCreatorForSMARDEX_AT_Medikalz", 1, 1, "SMARDEX_AT_Medikalz"],
      "7905,1025" : [ "ST", "AssignedDoctorEmail", 1, 1, "SMARDEX_AT_Medikalz"]    },

And then, call this route (note that you must use the numeric tag ids and not their alias):

curl http://localhost:8042/studies/05a0713b-86294f41-9cb78acf-0c61f3c2-b14e9741/modify -d '{"PrivateCreator": "SMARDEX_AT_Medikalz", "Replace": {"PrivateCreatorForSMARDEX_AT_Medikalz": "SMARDEX_AT_Medikalz", "AssignedDoctorEmail": "email@me.com" }}'

And it now appears as:
image

HTH,

Alain.

It worked!
Thanks Alain.
You also provided great API, guys
I used the following LUA functions which are great
function SetMetadata(studyId, metadataName, metadataValue)
local payload = metadataValue
local UpdateMetadataUri = ‘/studies/’ … studyId … ‘/metadata/’ … metadataName
RestApiPut(UpdateMetadataUri, payload, true)
end

function GetMetadata(studyId, metadataName)
local studyGetUrl = ‘/studies/’ … studyId … ‘/metadata/’ … metadataName
return RestApiGet(studyGetUrl)
end