changeset 519:1b2cdc855bd3

Parameter for PACS manufacturer, support for ClearCanvas
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 20 Aug 2013 13:39:42 +0200
parents b2b56b4e33b0
children 2c739f76d0bb
files OrthancServer/DicomProtocol/DicomUserConnection.cpp OrthancServer/DicomProtocol/DicomUserConnection.h OrthancServer/OrthancInitialization.cpp OrthancServer/OrthancInitialization.h OrthancServer/OrthancRestApi.cpp OrthancServer/ServerEnumerations.cpp OrthancServer/ServerEnumerations.h Resources/Configuration.json THANKS
diffstat 9 files changed, 103 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancServer/DicomProtocol/DicomUserConnection.cpp	Mon Aug 19 14:47:03 2013 +0200
+++ b/OrthancServer/DicomProtocol/DicomUserConnection.cpp	Tue Aug 20 13:39:42 2013 +0200
@@ -294,7 +294,20 @@
       break;
 
     case FindRootModel_Instance:
-      DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "INSTANCE");
+      if (manufacturer_ == ModalityManufacturer_ClearCanvas)
+      {
+        // This is a particular case for ClearCanvas, thanks to Peter Somlo <peter.somlo@gmail.com>.
+        // https://groups.google.com/d/msg/orthanc-users/j-6C3MAVwiw/iolB9hclom8J
+        // http://www.clearcanvas.ca/Home/Community/OldForums/tabid/526/aff/11/aft/14670/afv/topic/Default.aspx
+        printf("CLEAR CANVAS\n");
+        DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "IMAGE");
+      }
+      else
+      {
+        printf("GENERIC\n");
+        DU_putStringDOElement(dataset.get(), DcmTagKey(0x0008, 0x0052), "INSTANCE");
+      }
+
       sopClass = UID_FINDStudyRootQueryRetrieveInformationModel;
 
       // Accession number
@@ -453,6 +466,7 @@
     distantAet_ = "ANY-SCP";
     distantPort_ = 104;
     distantHost_ = "127.0.0.1";
+    manufacturer_ = ModalityManufacturer_Generic;
 
     pimpl_->net_ = NULL;
     pimpl_->params_ = NULL;
@@ -476,6 +490,12 @@
     distantAet_ = aet;
   }
 
+  void DicomUserConnection::SetDistantManufacturer(ModalityManufacturer manufacturer)
+  {
+    Close();
+    manufacturer_ = manufacturer;
+  }
+
 
   void DicomUserConnection::SetDistantHost(const std::string& host)
   {
--- a/OrthancServer/DicomProtocol/DicomUserConnection.h	Mon Aug 19 14:47:03 2013 +0200
+++ b/OrthancServer/DicomProtocol/DicomUserConnection.h	Tue Aug 20 13:39:42 2013 +0200
@@ -33,6 +33,7 @@
 #pragma once
 
 #include "DicomFindAnswers.h"
+#include "../ServerEnumerations.h"
 
 #include <stdint.h>
 #include <boost/shared_ptr.hpp>
@@ -59,6 +60,7 @@
     std::string distantAet_;
     std::string distantHost_;
     uint16_t distantPort_;
+    ModalityManufacturer manufacturer_;
 
     void CheckIsOpen() const;
 
@@ -106,6 +108,13 @@
       return distantPort_;
     }
 
+    void SetDistantManufacturer(ModalityManufacturer manufacturer);
+
+    ModalityManufacturer GetDistantManufacturer() const
+    {
+      return manufacturer_;
+    }
+
     void Open();
 
     void Close();
--- a/OrthancServer/OrthancInitialization.cpp	Mon Aug 19 14:47:03 2013 +0200
+++ b/OrthancServer/OrthancInitialization.cpp	Tue Aug 20 13:39:42 2013 +0200
@@ -230,7 +230,8 @@
   void GetDicomModality(const std::string& name,
                         std::string& aet,
                         std::string& address,
-                        int& port)
+                        int& port,
+                        ModalityManufacturer& manufacturer)
   {
     boost::mutex::scoped_lock lock(globalMutex_);
 
@@ -241,7 +242,8 @@
 
     const Json::Value& modalities = (*configuration_) ["DicomModalities"];
     if (modalities.type() != Json::objectValue ||
-        !modalities.isMember(name))
+        !modalities.isMember(name) ||
+        (modalities[name].size() != 3 && modalities[name].size() != 4))
     {
       throw OrthancException("");
     }
@@ -251,6 +253,15 @@
       aet = modalities[name].get(0u, "").asString();
       address = modalities[name].get(1u, "").asString();
       port = modalities[name].get(2u, "").asInt();
+
+      if (modalities[name].size() == 4)
+      {
+        manufacturer = StringToModalityManufacturer(modalities[name].get(3u, "").asString());
+      }
+      else
+      {
+        manufacturer = ModalityManufacturer_Generic;
+      }
     }
     catch (...)
     {
--- a/OrthancServer/OrthancInitialization.h	Mon Aug 19 14:47:03 2013 +0200
+++ b/OrthancServer/OrthancInitialization.h	Tue Aug 20 13:39:42 2013 +0200
@@ -37,6 +37,7 @@
 #include <json/json.h>
 #include <stdint.h>
 #include "../Core/HttpServer/MongooseServer.h"
+#include "ServerEnumerations.h"
 
 namespace Orthanc
 {
@@ -56,7 +57,8 @@
   void GetDicomModality(const std::string& name,
                         std::string& aet,
                         std::string& address,
-                        int& port);
+                        int& port,
+                        ModalityManufacturer& manufacturer);
 
   void GetOrthancPeer(const std::string& name,
                       std::string& url,
--- a/OrthancServer/OrthancRestApi.cpp	Mon Aug 19 14:47:03 2013 +0200
+++ b/OrthancServer/OrthancRestApi.cpp	Tue Aug 20 13:39:42 2013 +0200
@@ -76,11 +76,13 @@
   {
     std::string aet, address;
     int port;
-    GetDicomModality(name, aet, address, port);
+    ModalityManufacturer manufacturer;
+    GetDicomModality(name, aet, address, port, manufacturer);
     connection.SetLocalApplicationEntityTitle(GetGlobalStringParameter("DicomAet", "ORTHANC"));
     connection.SetDistantApplicationEntityTitle(aet);
     connection.SetDistantHost(address);
     connection.SetDistantPort(port);
+    connection.SetDistantManufacturer(manufacturer);
     connection.Open();
   }
 
--- a/OrthancServer/ServerEnumerations.cpp	Mon Aug 19 14:47:03 2013 +0200
+++ b/OrthancServer/ServerEnumerations.cpp	Tue Aug 20 13:39:42 2013 +0200
@@ -256,4 +256,39 @@
         throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
   }
+
+
+  const char* EnumerationToString(ModalityManufacturer manufacturer)
+  {
+    switch (manufacturer)
+    {
+      case ModalityManufacturer_Generic:
+        return "Generic";
+
+      case ModalityManufacturer_ClearCanvas:
+        return "ClearCanvas";
+      
+      default:
+        throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+  }
+
+
+  ModalityManufacturer StringToModalityManufacturer(const std::string& manufacturer)
+  {
+    if (manufacturer == "Generic")
+    {
+      return ModalityManufacturer_Generic;
+    }
+    else if (manufacturer == "ClearCanvas")
+    {
+      return ModalityManufacturer_ClearCanvas;
+    }
+    else
+    {
+      throw OrthancException(ErrorCode_ParameterOutOfRange);
+    }
+  }
+
+
 }
--- a/OrthancServer/ServerEnumerations.h	Mon Aug 19 14:47:03 2013 +0200
+++ b/OrthancServer/ServerEnumerations.h	Tue Aug 20 13:39:42 2013 +0200
@@ -51,6 +51,12 @@
     StoreStatus_FilteredOut     // Removed by NewInstanceFilter
   };
 
+  enum ModalityManufacturer
+  {
+    ModalityManufacturer_Generic,
+    ModalityManufacturer_ClearCanvas
+  };
+
 
   /**
    * WARNING: Do not change the explicit values in the enumerations
@@ -126,6 +132,10 @@
 
   const char* EnumerationToString(ChangeType type);
 
+  const char* EnumerationToString(ModalityManufacturer manufacturer);
+
+  ModalityManufacturer StringToModalityManufacturer(const std::string& manufacturer);
+
   ResourceType GetParentResourceType(ResourceType type);
 
   ResourceType GetChildResourceType(ResourceType type);
--- a/Resources/Configuration.json	Mon Aug 19 14:47:03 2013 +0200
+++ b/Resources/Configuration.json	Tue Aug 20 13:39:42 2013 +0200
@@ -96,6 +96,14 @@
      * command line "storescp 2000".
      **/
     // "sample" : [ "STORESCP", "localhost", 2000 ]
+
+    /**
+     * A fourth parameter is available to enable patches for a
+     * specific PACS manufacturer. The allowed values are currently
+     * "Generic" (default value) and "ClearCanvas". This parameter is
+     * case-sensitive.
+     **/
+    // "clearcanvas" : [ "CLEARCANVAS", "192.168.1.1", 104, "ClearCanvas" ]
   },
 
   // The list of the known Orthanc peers
--- a/THANKS	Mon Aug 19 14:47:03 2013 +0200
+++ b/THANKS	Tue Aug 20 13:39:42 2013 +0200
@@ -16,6 +16,7 @@
 * Will Ryder (will.ryder@sydney.edu.au), for improvements with the
   handling of series with temporal positions (fMRI and dynamic PET).
 * Ryan Walklin (ryanwalklin@gmail.com), for Mac OS X build.
+* Peter Somlo (peter.somlo@gmail.com), for ClearCanvas support.
 
 
 Artwork