changeset 211:d7acfccc0d0b

documented RegisterFindCallback(), RegisterMoveCallback(), RegisterMoveCallback2(), and RegisterWorklistCallback()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 03 Jul 2024 14:21:01 +0200
parents 6ca37fcf0979
children 2db6c1f6417f
files CodeAnalysis/CustomFunctions.json CodeAnalysis/FunctionDocumentation.mustache Sources/Autogenerated/orthanc.pyi Sources/Autogenerated/sdk_GlobalFunctions.impl.h Sources/DicomScpCallbacks.cpp Sources/DicomScpCallbacks.h Sources/Plugin.cpp
diffstat 7 files changed, 198 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/CodeAnalysis/CustomFunctions.json	Wed Jul 03 13:38:56 2024 +0200
+++ b/CodeAnalysis/CustomFunctions.json	Wed Jul 03 14:21:01 2024 +0200
@@ -149,5 +149,117 @@
     ],
     "return_sdk_type" : "object",
     "return_sdk_class" : "OrthancPluginImage"
+  },
+
+  {
+    "comment" : "New in release 3.2",
+    "short_name" : "RegisterFindCallback",
+    "implementation" : "RegisterFindCallback",
+    "documentation" : {
+      "description" : [ "Register a callback to handle C-Find requests." ],
+      "args" : {
+        "callback" : "The callback function."
+      }
+    },
+    "args" : [
+      {
+        "sdk_name" : "callback",
+        "sdk_type" : "Callable",
+        "callable_type" : "FindCallback",
+        "callable_protocol_args" : "answers: FindAnswers, query: FindQuery, issuer_aet: str, called_aet: str",
+        "callable_protocol_return" : "None"
+      }
+    ],
+    "return_sdk_type" : "void"
+  },
+
+  {
+    "comment" : "New in release 3.2",
+    "short_name" : "RegisterMoveCallback",
+    "implementation" : "RegisterMoveCallback",
+    "documentation" : {
+      "description" : [ "Register a callback to handle C-Move requests (simple version, with 1 suboperation)." ],
+      "args" : {
+        "callback" : "The callback function."
+      }
+    },
+    "args" : [
+      {
+        "sdk_name" : "callback",
+        "sdk_type" : "Callable",
+        "callable_type" : "MoveCallback",
+        "callable_protocol_args" : "Level: str, PatientID: str, AccessionNumber: str, StudyInstanceUID: str, SeriesInstanceUID: str, SOPInstanceUID: str, OriginatorAET: str, SourceAET: str, TargetAET: str, OriginatorID: int",
+        "callable_protocol_return" : "None"
+      }
+    ],
+    "return_sdk_type" : "void"
+  },
+
+  {
+    "comment" : "New in release 3.2",
+    "short_name" : "RegisterMoveCallback2",
+    "implementation" : "RegisterMoveCallback2",
+    "documentation" : {
+      "description" : [ "Register a callback to handle C-Move requests (full version, with multiple suboperations)." ],
+      "args" : {
+        "callback" : "Main callback that creates the C-Move driver.",
+        "get_move_size" : "Callback to read the number of C-Move suboperations.",
+        "apply_move" : "Callback to apply one C-Move suboperation.",
+        "free_move" : "Callback to free the C-Move driver."
+      }
+    },
+    "args" : [
+      {
+        "sdk_name" : "callback",
+        "sdk_type" : "Callable",
+        "callable_type" : "MoveCallback2",
+        "callable_protocol_args" : "Level: str, PatientID: str, AccessionNumber: str, StudyInstanceUID: str, SeriesInstanceUID: str, SOPInstanceUID: str, OriginatorAET: str, SourceAET: str, TargetAET: str, OriginatorID: int",
+        "callable_protocol_return" : "object",  "comment" : "This is the newly created C-Move driver."
+      },
+      {
+        "sdk_name" : "get_move_size",
+        "sdk_type" : "Callable",
+        "callable_type" : "GetMoveSizeCallback",
+        "callable_protocol_args" : "driver: object",
+        "callable_protocol_return" : "int"
+      },
+      {
+        "sdk_name" : "apply_move",
+        "sdk_type" : "Callable",
+        "callable_type" : "ApplyMoveCallback",
+        "callable_protocol_args" : "driver: object",
+        "callable_protocol_return" : "None"
+      },
+      {
+        "sdk_name" : "free_move",
+        "sdk_type" : "Callable",
+        "callable_type" : "FreeMoveCallback",
+        "callable_protocol_args" : "driver: object",
+        "callable_protocol_return" : "None"
+      }
+    ],
+    "return_sdk_type" : "void"
+  },
+
+  {
+    "comment" : "New in release 3.2",
+    "short_name" : "RegisterWorklistCallback",
+    "implementation" : "RegisterWorklistCallback",
+    "documentation" : {
+      "description" : [ "Register a callback to handle modality worklists requests." ],
+      "args" : {
+        "callback" : "The callback function."
+      }
+    },
+    "args" : [
+      {
+        "sdk_name" : "callback",
+        "sdk_type" : "Callable",
+        "callable_type" : "WorklistCallback",
+        "callable_protocol_args" : "answers: WorklistAnswers, query: WorklistQuery, issuer_aet: str, called_aet: str",
+        "callable_protocol_return" : "None"
+      }
+    ],
+    "return_sdk_type" : "void"
   }
 ]
--- a/CodeAnalysis/FunctionDocumentation.mustache	Wed Jul 03 13:38:56 2024 +0200
+++ b/CodeAnalysis/FunctionDocumentation.mustache	Wed Jul 03 14:21:01 2024 +0200
@@ -1,6 +1,6 @@
 {{#args}}{{#callable_protocol_return}}
 class {{callable_type}}(typing.Protocol):
-    def __call__(self, {{callable_protocol_args}}) -> {{callable_protocol_return}}:
+    def __call__(self{{#callable_protocol_args}}, {{callable_protocol_args}}{{/callable_protocol_args}}) -> {{callable_protocol_return}}:
         ...
 {{/callable_protocol_return}}{{/args}}
 {{#documentation.short_description}}
--- a/Sources/Autogenerated/orthanc.pyi	Wed Jul 03 13:38:56 2024 +0200
+++ b/Sources/Autogenerated/orthanc.pyi	Wed Jul 03 14:21:01 2024 +0200
@@ -2186,6 +2186,20 @@
     """
     ...
 
+class FindCallback(typing.Protocol):
+    def __call__(self, answers: FindAnswers, query: FindQuery, issuer_aet: str, called_aet: str) -> None:
+        ...
+
+# Register a callback to handle C-Find requests
+def RegisterFindCallback(callback: FindCallback) -> None:
+    """
+    Register a callback to handle C-Find requests.
+
+    Args:
+      callback (FindCallback): The callback function.
+    """
+    ...
+
 class IncomingHttpRequestFilter(typing.Protocol):
     def __call__(self, uri: str, method: HttpMethod, ip: str, headers: dict, get: dict) -> bool:
         ...
@@ -2200,6 +2214,49 @@
     """
     ...
 
+class MoveCallback(typing.Protocol):
+    def __call__(self, Level: str, PatientID: str, AccessionNumber: str, StudyInstanceUID: str, SeriesInstanceUID: str, SOPInstanceUID: str, OriginatorAET: str, SourceAET: str, TargetAET: str, OriginatorID: int) -> None:
+        ...
+
+# Register a callback to handle C-Move requests (simple version, with 1 suboperation)
+def RegisterMoveCallback(callback: MoveCallback) -> None:
+    """
+    Register a callback to handle C-Move requests (simple version, with 1 suboperation).
+
+    Args:
+      callback (MoveCallback): The callback function.
+    """
+    ...
+
+class MoveCallback2(typing.Protocol):
+    def __call__(self, Level: str, PatientID: str, AccessionNumber: str, StudyInstanceUID: str, SeriesInstanceUID: str, SOPInstanceUID: str, OriginatorAET: str, SourceAET: str, TargetAET: str, OriginatorID: int) -> object:
+        ...
+
+class GetMoveSizeCallback(typing.Protocol):
+    def __call__(self, driver: object) -> int:
+        ...
+
+class ApplyMoveCallback(typing.Protocol):
+    def __call__(self, driver: object) -> None:
+        ...
+
+class FreeMoveCallback(typing.Protocol):
+    def __call__(self, driver: object) -> None:
+        ...
+
+# Register a callback to handle C-Move requests (full version, with multiple suboperations)
+def RegisterMoveCallback2(callback: MoveCallback2, get_move_size: GetMoveSizeCallback, apply_move: ApplyMoveCallback, free_move: FreeMoveCallback) -> None:
+    """
+    Register a callback to handle C-Move requests (full version, with multiple suboperations).
+
+    Args:
+      callback (MoveCallback2): Main callback that creates the C-Move driver.
+      get_move_size (GetMoveSizeCallback): Callback to read the number of C-Move suboperations.
+      apply_move (ApplyMoveCallback): Callback to apply one C-Move suboperation.
+      free_move (FreeMoveCallback): Callback to free the C-Move driver.
+    """
+    ...
+
 class OnChangeCallback(typing.Protocol):
     def __call__(self, change_type: ChangeType, resource_type: ResourceType, resource_id: str) -> None:
         ...
@@ -2243,6 +2300,20 @@
     """
     ...
 
+class WorklistCallback(typing.Protocol):
+    def __call__(self, answers: WorklistAnswers, query: WorklistQuery, issuer_aet: str, called_aet: str) -> None:
+        ...
+
+# Register a callback to handle modality worklists requests
+def RegisterWorklistCallback(callback: WorklistCallback) -> None:
+    """
+    Register a callback to handle modality worklists requests.
+
+    Args:
+      callback (WorklistCallback): The callback function.
+    """
+    ...
+
 
 class DicomInstance:
     """
--- a/Sources/Autogenerated/sdk_GlobalFunctions.impl.h	Wed Jul 03 13:38:56 2024 +0200
+++ b/Sources/Autogenerated/sdk_GlobalFunctions.impl.h	Wed Jul 03 14:21:01 2024 +0200
@@ -25,10 +25,14 @@
 // Forward declaration of the custom global functions
 extern PyObject *CreateImageFromBuffer(PyObject* module, PyObject *args);
 extern PyObject *LookupDictionary(PyObject* module, PyObject *args);
+extern PyObject *RegisterFindCallback(PyObject* module, PyObject *args);
 extern PyObject *RegisterIncomingHttpRequestFilter(PyObject* module, PyObject *args);
+extern PyObject *RegisterMoveCallback(PyObject* module, PyObject *args);
+extern PyObject *RegisterMoveCallback2(PyObject* module, PyObject *args);
 extern PyObject *RegisterOnChangeCallback(PyObject* module, PyObject *args);
 extern PyObject *RegisterOnStoredInstanceCallback(PyObject* module, PyObject *args);
 extern PyObject *RegisterRestCallback(PyObject* module, PyObject *args);
+extern PyObject *RegisterWorklistCallback(PyObject* module, PyObject *args);
 // End of forward declarations
 
 
@@ -2026,14 +2030,22 @@
     "Implemented in C++ function CreateImageFromBuffer()" },
   { "LookupDictionary", LookupDictionary, METH_VARARGS,
     "Implemented in C++ function LookupDictionary()" },
+  { "RegisterFindCallback", RegisterFindCallback, METH_VARARGS,
+    "Implemented in C++ function RegisterFindCallback()" },
   { "RegisterIncomingHttpRequestFilter", RegisterIncomingHttpRequestFilter, METH_VARARGS,
     "Implemented in C++ function RegisterIncomingHttpRequestFilter()" },
+  { "RegisterMoveCallback", RegisterMoveCallback, METH_VARARGS,
+    "Implemented in C++ function RegisterMoveCallback()" },
+  { "RegisterMoveCallback2", RegisterMoveCallback2, METH_VARARGS,
+    "Implemented in C++ function RegisterMoveCallback2()" },
   { "RegisterOnChangeCallback", RegisterOnChangeCallback, METH_VARARGS,
     "Implemented in C++ function RegisterOnChangeCallback()" },
   { "RegisterOnStoredInstanceCallback", RegisterOnStoredInstanceCallback, METH_VARARGS,
     "Implemented in C++ function RegisterOnStoredInstanceCallback()" },
   { "RegisterRestCallback", RegisterRestCallback, METH_VARARGS,
     "Implemented in C++ function RegisterRestCallback()" },
+  { "RegisterWorklistCallback", RegisterWorklistCallback, METH_VARARGS,
+    "Implemented in C++ function RegisterWorklistCallback()" },
   { NULL, NULL }
 };
 
--- a/Sources/DicomScpCallbacks.cpp	Wed Jul 03 13:38:56 2024 +0200
+++ b/Sources/DicomScpCallbacks.cpp	Wed Jul 03 14:21:01 2024 +0200
@@ -21,6 +21,8 @@
 
 #include "DicomScpCallbacks.h"
 
+#include "PythonHeaderWrapper.h"
+
 #include "../Resources/Orthanc/Plugins/OrthancPluginCppWrapper.h"
 #include "Autogenerated/sdk.h"
 #include "ICallbackRegistration.h"
--- a/Sources/DicomScpCallbacks.h	Wed Jul 03 13:38:56 2024 +0200
+++ b/Sources/DicomScpCallbacks.h	Wed Jul 03 14:21:01 2024 +0200
@@ -21,14 +21,4 @@
 
 #pragma once
 
-#include "PythonHeaderWrapper.h"
-
-PyObject* RegisterFindCallback(PyObject* module, PyObject* args);
-
-PyObject* RegisterMoveCallback(PyObject* module, PyObject* args);
-
-PyObject* RegisterMoveCallback2(PyObject* module, PyObject* args);
-
-PyObject* RegisterWorklistCallback(PyObject* module, PyObject* args);
-
 void FinalizeDicomScpCallbacks();
--- a/Sources/Plugin.cpp	Wed Jul 03 13:38:56 2024 +0200
+++ b/Sources/Plugin.cpp	Wed Jul 03 14:21:01 2024 +0200
@@ -279,31 +279,6 @@
 
   
   /**
-   * New in release 3.2
-   **/
-  
-  {
-    PyMethodDef f = { "RegisterFindCallback", RegisterFindCallback, METH_VARARGS, "" };
-    functions.push_back(f);
-  }
-  
-  {
-    PyMethodDef f = { "RegisterMoveCallback", RegisterMoveCallback, METH_VARARGS, "" };
-    functions.push_back(f);
-  }
-
-  {
-    PyMethodDef f = { "RegisterMoveCallback2", RegisterMoveCallback2, METH_VARARGS, "" };
-    functions.push_back(f);
-  }
-
-  {
-    PyMethodDef f = { "RegisterWorklistCallback", RegisterWorklistCallback, METH_VARARGS, "" };
-    functions.push_back(f);
-  }
-  
-  
-  /**
    * New in release 3.3
    **/