Hybrid API - between full /tags retrieval and simplified form

Would it be possible to create an API call (or does one exist) where DICOM tags could be retrieved in human form (like with simplified-tags and simplify) but that tags unknown to Orthanc would be returned with their numeric descriptor instead of the human form “Unknown tag”?

My reason for asking is that the simplified-tags form is very useful when preparing JSON expressions to submit inside the Keep, Replace, and Remove parts of the /anonymize and /modify API calls. The format returned by simplified-tags IS the same as the format required for calls to anonymize and modify.

Except when a tag read by a call with simplified-tags is NOT in Orthanc’s dictionary. Then, the returned JSON annotates the human form as “Unknown tag”. This JSON can NOT then be used for subsequent anonymize and modify calls because Orthanc has no way to know what DICOM tag to convert “Unknown tag” into. Neither do I, for that matter, without calling the full “/tags” form myself and performing a one-to-one match between the returned JSON structures.

A common use case for me is to read an existing DICOM to retrieve tags in the process of modification and anonymization. Sometimes, I want to keep most of the information but update some parts of it, particularly when it comes to DICOM tag sequences. I can retrieve the current tags with “simplified-tags” form, update the parts in the JSON and resubmit via modify or anonymize to perform the update.

I could go the long route and use the standard “instance/{id}/tags” form. Then I would need to parse the more complicated JSON and construct the outgoing JSON myself - rather than simply updating a few parameters in the original incoming JSON.

“simplified-tags” nearly gets the job done except when unknown tags are encountered.

That’s why I wonder if a tag retrieval form could be added (or exists and I’m not seeing it in the API) which would return human readable descriptors for all known tags and numeric descriptors for unknown tags rather than “Unknown tag” as the descriptor.

If I have a chance, I’ll dig into the source and come up with a suggested diff. I don’t imagine it would require much code.

Thanks,
John.

Dear John,

Thanks for this suggestion.

We have just added this feature in the Orthanc mainline (it will be part of forthcoming Orthanc 1.4.0):
https://bitbucket.org/sjodogne/orthanc/commits/3603a2e145921d70affc273fa11d05d4041f4990

Just add “?short” to the URI. For instance, the following REST API call should now fulfill your requirement:

curl http://localhost:8042/instances/19816330-cb02e1cf-df3a8fe8-bf510623-ccefe9f5/tags?short

HTH,
Sébastien-

Great! Thanks a lot for the quick response. That will be useful.

John.