changeset 1069:a91b4900f06a

plugin lookup using accession number
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 28 Jul 2014 11:49:16 +0200
parents f54a9c6fea5d
children 67a6031f09ae
files Plugins/Engine/PluginsHttpHandler.cpp Plugins/Engine/PluginsHttpHandler.h Plugins/OrthancCPlugin/OrthancCPlugin.h
diffstat 3 files changed, 70 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/Plugins/Engine/PluginsHttpHandler.cpp	Mon Jul 28 11:34:01 2014 +0200
+++ b/Plugins/Engine/PluginsHttpHandler.cpp	Mon Jul 28 11:49:16 2014 +0200
@@ -552,29 +552,46 @@
   }
 
 
-  void PluginsHttpHandler::LookupResource(ResourceType level,
+  void PluginsHttpHandler::LookupResource(_OrthancPluginService service,
                                           const void* parameters)
   {
     const _OrthancPluginLookupResource& p = 
       *reinterpret_cast<const _OrthancPluginLookupResource*>(parameters);
 
+    /**
+     * The enumeration below only uses the tags that are indexed in
+     * the Orthanc database. It reflects the
+     * "CandidateResources::ApplyFilter()" method of the
+     * "OrthancFindRequestHandler" class.
+     **/
+
     DicomTag tag(0, 0);
-    switch (level)
+    ResourceType level;
+    switch (service)
     {
-      case ResourceType_Patient:
+      case _OrthancPluginService_LookupPatient:
         tag = DICOM_TAG_PATIENT_ID;
+        level = ResourceType_Patient;
         break;
 
-      case ResourceType_Study:
+      case _OrthancPluginService_LookupStudy:
         tag = DICOM_TAG_STUDY_INSTANCE_UID;
+        level = ResourceType_Study;
         break;
 
-      case ResourceType_Series:
-        tag = DICOM_TAG_SERIES_INSTANCE_UID;
+      case _OrthancPluginService_LookupStudyWithAccessionNumber:
+        tag = DICOM_TAG_ACCESSION_NUMBER;
+        level = ResourceType_Study;
         break;
 
-      case ResourceType_Instance:
+      case _OrthancPluginService_LookupSeries:
+        tag = DICOM_TAG_SERIES_INSTANCE_UID;
+        level = ResourceType_Series;
+        break;
+
+      case _OrthancPluginService_LookupInstance:
         tag = DICOM_TAG_SOP_INSTANCE_UID;
+        level = ResourceType_Instance;
         break;
 
       default:
@@ -769,19 +786,11 @@
         return true;
 
       case _OrthancPluginService_LookupPatient:
-        LookupResource(ResourceType_Patient, parameters);
-        return true;
-
       case _OrthancPluginService_LookupStudy:
-        LookupResource(ResourceType_Study, parameters);
-        return true;
-
+      case _OrthancPluginService_LookupStudyWithAccessionNumber:
       case _OrthancPluginService_LookupSeries:
-        LookupResource(ResourceType_Series, parameters);
-        return true;
-
       case _OrthancPluginService_LookupInstance:
-        LookupResource(ResourceType_Instance, parameters);
+        LookupResource(service, parameters);
         return true;
 
       case _OrthancPluginService_GetInstanceRemoteAet:
--- a/Plugins/Engine/PluginsHttpHandler.h	Mon Jul 28 11:34:01 2014 +0200
+++ b/Plugins/Engine/PluginsHttpHandler.h	Mon Jul 28 11:49:16 2014 +0200
@@ -68,7 +68,7 @@
 
     void RestApiDelete(const void* parameters);
 
-    void LookupResource(ResourceType level,
+    void LookupResource(_OrthancPluginService service,
                         const void* parameters);
 
     void SendHttpStatusCode(const void* parameters);
--- a/Plugins/OrthancCPlugin/OrthancCPlugin.h	Mon Jul 28 11:34:01 2014 +0200
+++ b/Plugins/OrthancCPlugin/OrthancCPlugin.h	Mon Jul 28 11:49:16 2014 +0200
@@ -260,6 +260,7 @@
     _OrthancPluginService_LookupStudy = 3006,
     _OrthancPluginService_LookupSeries = 3007,
     _OrthancPluginService_LookupInstance = 3008,
+    _OrthancPluginService_LookupStudyWithAccessionNumber = 3009,
 
     /* Access to DICOM instances */
     _OrthancPluginService_GetInstanceRemoteAet = 4000,
@@ -872,6 +873,8 @@
    * @brief Look for a patient.
    *
    * Look for a patient stored in Orthanc, using its Patient ID tag (0x0010, 0x0020).
+   * This function uses the database index to run as fast as possible (it does not loop
+   * over all the stored patients).
    * 
    * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
    * @param patientID The Patient ID of interest.
@@ -904,6 +907,8 @@
    * @brief Look for a study.
    *
    * Look for a study stored in Orthanc, using its Study Instance UID tag (0x0020, 0x000d).
+   * This function uses the database index to run as fast as possible (it does not loop
+   * over all the stored studies).
    * 
    * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
    * @param studyUID The Study Instance UID of interest.
@@ -933,9 +938,45 @@
 
 
   /**
+   * @brief Look for a study, using the accession number.
+   *
+   * Look for a study stored in Orthanc, using its Accession Number tag (0x0008, 0x0050).
+   * This function uses the database index to run as fast as possible (it does not loop
+   * over all the stored studies).
+   * 
+   * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
+   * @param accessionNumber The Accession Number of interest.
+   * @return The NULL value if the study is non-existent, or a string containing the 
+   * Orthanc ID of the study. This string must be freed by OrthancPluginFreeString().
+   **/
+  ORTHANC_PLUGIN_INLINE char* OrthancPluginLookupStudyWithAccessionNumber(
+    OrthancPluginContext*  context,
+    const char*            accessionNumber)
+  {
+    char* result;
+
+    _OrthancPluginLookupResource params;
+    params.result = &result;
+    params.identifier = accessionNumber;
+
+    if (context->InvokeService(context, _OrthancPluginService_LookupStudyWithAccessionNumber, &params))
+    {
+      /* Error */
+      return NULL;
+    }
+    else
+    {
+      return result;
+    }
+  }
+
+
+  /**
    * @brief Look for a series.
    *
    * Look for a series stored in Orthanc, using its Series Instance UID tag (0x0020, 0x000e).
+   * This function uses the database index to run as fast as possible (it does not loop
+   * over all the stored series).
    * 
    * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
    * @param seriesUID The Series Instance UID of interest.
@@ -968,6 +1009,8 @@
    * @brief Look for an instance.
    *
    * Look for an instance stored in Orthanc, using its SOP Instance UID tag (0x0008, 0x0018).
+   * This function uses the database index to run as fast as possible (it does not loop
+   * over all the stored instances).
    * 
    * @param context The Orthanc plugin context, as received by OrthancPluginInitialize().
    * @param sopInstanceUID The SOP Instance UID of interest.