changeset 816:908ca7847b9d

added incoming-cstore-filter.py
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Feb 2022 11:08:20 +0100
parents a56c4128c9a2
children 01fa632daae9
files Sphinx/source/plugins/python/incoming-cstore-filter.py Sphinx/source/plugins/python/received-instance-callback.py
diffstat 2 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Sphinx/source/plugins/python/incoming-cstore-filter.py	Wed Feb 23 11:08:20 2022 +0100
@@ -0,0 +1,15 @@
+import json
+import orthanc
+
+def Filter(receivedDicom):
+    # The list ofvalid status codes for DIMSE C-STORE can be found:
+    # https://dicom.nema.org/medical/Dicom/2021e/output/chtml/part04/sect_B.2.3.html
+
+    tags = json.loads(receivedDicom.GetInstanceSimplifiedJson())
+    if tags['PatientID'].startswith('001-'):
+        # Non-zero return value: The DICOM instance is discarded
+        return 0xA900  # DIMSE Failure: Data Set does not match SOP Class
+    else:
+        return 0  # Success: Accept the DICOM instance
+
+orthanc.RegisterIncomingCStoreInstanceFilter(Filter)
--- a/Sphinx/source/plugins/python/received-instance-callback.py	Wed Feb 23 09:26:51 2022 +0100
+++ b/Sphinx/source/plugins/python/received-instance-callback.py	Wed Feb 23 11:08:20 2022 +0100
@@ -14,7 +14,6 @@
         return memory_dataset.read()
 
 def ReceivedInstanceCallback(receivedDicom, origin):
-    orthanc.LogWarning('SOURCE: %d' % origin)
     if origin == orthanc.InstanceOrigin.REST_API:
         orthanc.LogWarning('DICOM instance received from the REST API')
     elif origin == orthanc.InstanceOrigin.DICOM_PROTOCOL: