diff Sphinx/source/plugins/python/lookup-dictionary.py @ 708:cd70d23f34bc

Lookup DICOM dictionary in Python scripts
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 11 Jun 2021 14:09:21 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sphinx/source/plugins/python/lookup-dictionary.py	Fri Jun 11 14:09:21 2021 +0200
@@ -0,0 +1,18 @@
+import json
+import orthanc
+
+# Create a dictionary mapping the numeric values in enumeration
+# "orthanc.ValueRepresentation" to the name of the corresponding VR
+VR_NAMES = {}
+for name in dir(orthanc.ValueRepresentation):
+    if not name.startswith('_'):
+        value = getattr(orthanc.ValueRepresentation, name)
+        VR_NAMES[value] = name
+
+entry = orthanc.LookupDictionary('PatientID')
+
+orthanc.LogWarning('Entry in the dictionary: %s' %
+                   json.dumps(entry, indent = 4, sort_keys = True))
+
+orthanc.LogWarning('Name of the value representation: %s' %
+                   VR_NAMES[entry['ValueRepresentation']])