changeset 665:41b3e5ccb291

fix for medInria
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 07 Nov 2013 16:25:28 +0100
parents 855adbdd75a6
children b8383ac0b227
files NEWS OrthancServer/DicomProtocol/IFindRequestHandler.h OrthancServer/Internals/CommandDispatcher.cpp OrthancServer/Internals/FindScp.cpp OrthancServer/Internals/FindScp.h OrthancServer/OrthancFindRequestHandler.cpp OrthancServer/OrthancFindRequestHandler.h OrthancServer/ServerEnumerations.cpp OrthancServer/ServerEnumerations.h Resources/Configuration.json
diffstat 10 files changed, 79 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed Nov 06 17:20:31 2013 +0100
+++ b/NEWS	Thu Nov 07 16:25:28 2013 +0100
@@ -2,6 +2,7 @@
 ===============================
 
 
+* Support of Query/Retrieve from medInria
 * Accept more transfer syntaxes for C-Store SCP and SCU (notably JPEG)
 * Create the meta-header when receiving files through C-Store SCP
 * Fixes and improvements thanks to the static analyzer cppcheck
--- a/OrthancServer/DicomProtocol/IFindRequestHandler.h	Wed Nov 06 17:20:31 2013 +0100
+++ b/OrthancServer/DicomProtocol/IFindRequestHandler.h	Thu Nov 07 16:25:28 2013 +0100
@@ -48,6 +48,7 @@
     }
 
     virtual void Handle(DicomFindAnswers& answers,
-                        const DicomMap& input) = 0;
+                        const DicomMap& input,
+                        const std::string& callingAETitle) = 0;
   };
 }
--- a/OrthancServer/Internals/CommandDispatcher.cpp	Wed Nov 06 17:20:31 2013 +0100
+++ b/OrthancServer/Internals/CommandDispatcher.cpp	Thu Nov 07 16:25:28 2013 +0100
@@ -238,6 +238,7 @@
       if (server.HasMoveRequestHandlerFactory())
       {
         knownAbstractSyntaxes.push_back(UID_MOVEStudyRootQueryRetrieveInformationModel);
+        knownAbstractSyntaxes.push_back(UID_MOVEPatientRootQueryRetrieveInformationModel);
       }
 
       cond = ASC_receiveAssociation(net, &assoc, 
@@ -266,13 +267,12 @@
 
       std::vector<const char*> transferSyntaxes;
 
-#if 0
       // This is the list of the transfer syntaxes that were supported up to Orthanc 0.7.1
       transferSyntaxes.push_back(UID_LittleEndianExplicitTransferSyntax);
       transferSyntaxes.push_back(UID_BigEndianExplicitTransferSyntax);
       transferSyntaxes.push_back(UID_LittleEndianImplicitTransferSyntax);
-#else
-      transferSyntaxes.push_back(UID_LittleEndianImplicitTransferSyntax); 
+
+      // New transfer syntaxes supported since Orthanc 0.7.2
       transferSyntaxes.push_back(UID_DeflatedExplicitVRLittleEndianTransferSyntax); 
       transferSyntaxes.push_back(UID_JPEGProcess1TransferSyntax);
       transferSyntaxes.push_back(UID_JPEGProcess2_4TransferSyntax);
@@ -303,7 +303,6 @@
       transferSyntaxes.push_back(UID_MPEG2MainProfileAtMainLevelTransferSyntax);
       transferSyntaxes.push_back(UID_MPEG2MainProfileAtHighLevelTransferSyntax);
       transferSyntaxes.push_back(UID_RLELosslessTransferSyntax);
-#endif
 
       /* accept the Verification SOP Class if presented */
       cond = ASC_acceptContextsWithPreferredTransferSyntaxes( assoc->params, &knownAbstractSyntaxes[0], knownAbstractSyntaxes.size(), &transferSyntaxes[0], transferSyntaxes.size());
@@ -580,7 +579,7 @@
               {
                 std::auto_ptr<IFindRequestHandler> handler
                   (server_.GetFindRequestHandlerFactory().ConstructFindRequestHandler());
-                cond = Internals::findScp(assoc_, &msg, presID, *handler);
+                cond = Internals::findScp(assoc_, &msg, presID, *handler, callingAETitle_);
               }
               break;
 
@@ -595,6 +594,8 @@
         // Bad status, which indicates the closing of the connection by
         // the peer or a network error
         finished = true;
+
+        LOG(ERROR) << cond.text();
       }
     
       if (finished)
--- a/OrthancServer/Internals/FindScp.cpp	Wed Nov 06 17:20:31 2013 +0100
+++ b/OrthancServer/Internals/FindScp.cpp	Thu Nov 07 16:25:28 2013 +0100
@@ -49,6 +49,7 @@
       DicomMap input_;
       DicomFindAnswers answers_;
       DcmDataset* lastRequest_;
+      const std::string* callingAETitle_;
     };
 
 
@@ -74,7 +75,7 @@
 
         try
         {
-          data.handler_->Handle(data.answers_, data.input_);
+          data.handler_->Handle(data.answers_, data.input_, *data.callingAETitle_);
         }
         catch (OrthancException& e)
         {
@@ -112,11 +113,13 @@
   OFCondition Internals::findScp(T_ASC_Association * assoc, 
                                  T_DIMSE_Message * msg, 
                                  T_ASC_PresentationContextID presID,
-                                 IFindRequestHandler& handler)
+                                 IFindRequestHandler& handler,
+                                 const std::string& callingAETitle)
   {
     FindScpData data;
     data.lastRequest_ = NULL;
     data.handler_ = &handler;
+    data.callingAETitle_ = &callingAETitle;
 
     OFCondition cond = DIMSE_findProvider(assoc, presID, &msg->msg.CFindRQ, 
                                           FindScpCallback, &data,
--- a/OrthancServer/Internals/FindScp.h	Wed Nov 06 17:20:31 2013 +0100
+++ b/OrthancServer/Internals/FindScp.h	Thu Nov 07 16:25:28 2013 +0100
@@ -43,6 +43,7 @@
     OFCondition findScp(T_ASC_Association * assoc, 
                         T_DIMSE_Message * msg, 
                         T_ASC_PresentationContextID presID,
-                        IFindRequestHandler& handler);
+                        IFindRequestHandler& handler,
+                        const std::string& callingAETitle);
   }
 }
--- a/OrthancServer/OrthancFindRequestHandler.cpp	Wed Nov 06 17:20:31 2013 +0100
+++ b/OrthancServer/OrthancFindRequestHandler.cpp	Thu Nov 07 16:25:28 2013 +0100
@@ -314,7 +314,8 @@
   static void LookupCandidateResources(/* out */ std::list<std::string>& resources,
                                        /* in */  ServerIndex& index,
                                        /* in */  ResourceType level,
-                                       /* in */  const DicomMap& query)
+                                       /* in */  const DicomMap& query,
+                                       /* in */  ModalityManufacturer manufacturer)
   {
     // TODO : Speed up using full querying against the MainDicomTags.
 
@@ -337,7 +338,22 @@
         break;
 
       case ResourceType_Instance:
-        done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SOP_INSTANCE_UID);
+        if (manufacturer == ModalityManufacturer_MedInria)
+        {
+          std::list<std::string> series;
+
+          if (LookupCandidateResourcesInternal(series, index, ResourceType_Series, query, DICOM_TAG_SERIES_INSTANCE_UID) &&
+              series.size() == 1)
+          {
+            index.GetChildInstances(resources, series.front());
+            done = true;
+          }          
+        }
+        else
+        {
+          done = LookupCandidateResourcesInternal(resources, index, level, query, DICOM_TAG_SOP_INSTANCE_UID);
+        }
+
         break;
 
       default:
@@ -359,9 +375,27 @@
 
 
   void OrthancFindRequestHandler::Handle(DicomFindAnswers& answers,
-                                         const DicomMap& input)
+                                         const DicomMap& input,
+                                         const std::string& callingAETitle)
   {
     /**
+     * Retrieve the manufacturer of this modality.
+     **/
+
+    ModalityManufacturer manufacturer;
+
+    {
+      std::string symbolicName, address;
+      int port;
+
+      if (!LookupDicomModalityUsingAETitle(callingAETitle, symbolicName, address, port, manufacturer))
+      {
+        throw OrthancException("Unknown modality");
+      }
+    }
+
+
+    /**
      * Retrieve the query level.
      **/
 
@@ -373,11 +407,19 @@
 
     ResourceType level = StringToResourceType(levelTmp->AsString().c_str());
 
-    if (level != ResourceType_Patient &&
-        level != ResourceType_Study &&
-        level != ResourceType_Series)
+    switch (manufacturer)
     {
-      throw OrthancException(ErrorCode_NotImplemented);
+      case ModalityManufacturer_MedInria:
+        // MedInria makes FIND requests at the instance level before starting MOVE
+        break;
+
+      default:
+        if (level != ResourceType_Patient &&
+            level != ResourceType_Study &&
+            level != ResourceType_Series)
+        {
+          throw OrthancException(ErrorCode_NotImplemented);
+        }
     }
 
 
@@ -389,7 +431,7 @@
      **/
 
     std::list<std::string>  resources;
-    LookupCandidateResources(resources, context_.GetIndex(), level, input);
+    LookupCandidateResources(resources, context_.GetIndex(), level, input, manufacturer);
 
 
     /**
--- a/OrthancServer/OrthancFindRequestHandler.h	Wed Nov 06 17:20:31 2013 +0100
+++ b/OrthancServer/OrthancFindRequestHandler.h	Thu Nov 07 16:25:28 2013 +0100
@@ -49,6 +49,7 @@
     }
 
     virtual void Handle(DicomFindAnswers& answers,
-                        const DicomMap& input);
+                        const DicomMap& input,
+                        const std::string& callingAETitle);
   };
 }
--- a/OrthancServer/ServerEnumerations.cpp	Wed Nov 06 17:20:31 2013 +0100
+++ b/OrthancServer/ServerEnumerations.cpp	Thu Nov 07 16:25:28 2013 +0100
@@ -248,6 +248,9 @@
       case ModalityManufacturer_ClearCanvas:
         return "ClearCanvas";
       
+      case ModalityManufacturer_MedInria:
+        return "MedInria";
+      
       default:
         throw OrthancException(ErrorCode_ParameterOutOfRange);
     }
@@ -296,6 +299,10 @@
     {
       return ModalityManufacturer_ClearCanvas;
     }
+    else if (manufacturer == "MedInria")
+    {
+      return ModalityManufacturer_MedInria;
+    }
     else
     {
       throw OrthancException(ErrorCode_ParameterOutOfRange);
--- a/OrthancServer/ServerEnumerations.h	Wed Nov 06 17:20:31 2013 +0100
+++ b/OrthancServer/ServerEnumerations.h	Thu Nov 07 16:25:28 2013 +0100
@@ -56,7 +56,8 @@
   enum ModalityManufacturer
   {
     ModalityManufacturer_Generic,
-    ModalityManufacturer_ClearCanvas
+    ModalityManufacturer_ClearCanvas,
+    ModalityManufacturer_MedInria
   };
 
   enum DicomRequestType
--- a/Resources/Configuration.json	Wed Nov 06 17:20:31 2013 +0100
+++ b/Resources/Configuration.json	Thu Nov 07 16:25:28 2013 +0100
@@ -100,8 +100,8 @@
     /**
      * 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.
+     * "Generic" (default value), "ClearCanvas" and "MedInria". This
+     * parameter is case-sensitive.
      **/
     // "clearcanvas" : [ "CLEARCANVAS", "192.168.1.1", 104, "ClearCanvas" ]
   },