changeset 923:55b945749bed mac

mainline -> mac integration
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 25 Feb 2014 17:24:08 +0100
parents a0a05f9dcd5a (current diff) b79eda29896d (diff)
children 8635d78ebb1d
files OrthancServer/DicomProtocol/DicomUserConnection.cpp
diffstat 13 files changed, 126 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomFormat/DicomMap.cpp	Mon Feb 24 17:41:17 2014 +0100
+++ b/Core/DicomFormat/DicomMap.cpp	Tue Feb 25 17:24:08 2014 +0100
@@ -199,7 +199,7 @@
     }
     else
     {
-      throw OrthancException("Inexistent tag");
+      throw OrthancException(ErrorCode_InexistentTag);
     }
   }
 
--- a/Core/Enumerations.h	Mon Feb 24 17:41:17 2014 +0100
+++ b/Core/Enumerations.h	Tue Feb 25 17:24:08 2014 +0100
@@ -67,7 +67,8 @@
     ErrorCode_UnknownResource,
     ErrorCode_IncompatibleDatabaseVersion,
     ErrorCode_FullStorage,
-    ErrorCode_CorruptedFile
+    ErrorCode_CorruptedFile,
+    ErrorCode_InexistentTag
   };
 
   /**
--- a/Core/OrthancException.cpp	Mon Feb 24 17:41:17 2014 +0100
+++ b/Core/OrthancException.cpp	Tue Feb 25 17:24:08 2014 +0100
@@ -108,6 +108,9 @@
       case ErrorCode_CorruptedFile:
         return "Corrupted file (inconsistent MD5 hash)";
 
+      case ErrorCode_InexistentTag:
+        return "Inexistent tag";
+
       case ErrorCode_Custom:
       default:
         return "???";
--- a/NEWS	Mon Feb 24 17:41:17 2014 +0100
+++ b/NEWS	Tue Feb 25 17:24:08 2014 +0100
@@ -1,6 +1,8 @@
 Pending changes in the mainline
 ===============================
 
+* Better logging about nonexistent tags
+* Dcm4Chee manufacturer
 
 
 Version 0.7.3 (2014/02/14)
--- a/OrthancServer/DicomProtocol/DicomUserConnection.cpp	Mon Feb 24 17:41:17 2014 +0100
+++ b/OrthancServer/DicomProtocol/DicomUserConnection.cpp	Tue Feb 25 17:24:08 2014 +0100
@@ -340,7 +340,8 @@
       break;
 
     case FindRootModel_Instance:
-      if (manufacturer_ == ModalityManufacturer_ClearCanvas)
+      if (manufacturer_ == ModalityManufacturer_ClearCanvas ||
+          manufacturer_ == ModalityManufacturer_Dcm4Chee)
       {
         // 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
--- a/OrthancServer/Internals/StoreScp.cpp	Mon Feb 24 17:41:17 2014 +0100
+++ b/OrthancServer/Internals/StoreScp.cpp	Tue Feb 25 17:24:08 2014 +0100
@@ -33,6 +33,7 @@
 #include "StoreScp.h"
 
 #include "../FromDcmtkBridge.h"
+#include "../ServerToolbox.h"
 #include "../ToDcmtkBridge.h"
 #include "../../Core/OrthancException.h"
 
@@ -57,7 +58,7 @@
       uint32_t messageID;
     };
 
-
+    
     static void
     storeScpCallback(
       void *callbackData,
@@ -155,7 +156,15 @@
               catch (OrthancException& e)
               {
                 rsp->DimseStatus = STATUS_STORE_Refused_OutOfResources;
-                LOG(ERROR) << "Exception while storing DICOM: " << e.What();
+
+                if (e.GetErrorCode() == ErrorCode_InexistentTag)
+                {
+                  LogMissingRequiredTag(summary);
+                }
+                else
+                {
+                  LOG(ERROR) << "Exception while storing DICOM: " << e.What();
+                }
               }
             }
           }
--- a/OrthancServer/ServerContext.cpp	Mon Feb 24 17:41:17 2014 +0100
+++ b/OrthancServer/ServerContext.cpp	Tue Feb 25 17:24:08 2014 +0100
@@ -238,19 +238,31 @@
     DicomMap dicomSummary;
     FromDcmtkBridge::Convert(dicomSummary, *dicomInstance.getDataset());
 
-    DicomInstanceHasher hasher(dicomSummary);
-    resultPublicId = hasher.HashInstance();
+    try
+    {
+      DicomInstanceHasher hasher(dicomSummary);
+      resultPublicId = hasher.HashInstance();
 
-    Json::Value dicomJson;
-    FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.getDataset());
+      Json::Value dicomJson;
+      FromDcmtkBridge::ToJson(dicomJson, *dicomInstance.getDataset());
       
-    StoreStatus status = StoreStatus_Failure;
-    if (dicomSize > 0)
+      StoreStatus status = StoreStatus_Failure;
+      if (dicomSize > 0)
+      {
+        status = Store(dicomBuffer, dicomSize, dicomSummary, dicomJson, "");
+      }   
+
+      return status;
+    }
+    catch (OrthancException& e)
     {
-      status = Store(dicomBuffer, dicomSize, dicomSummary, dicomJson, "");
-    }   
+      if (e.GetErrorCode() == ErrorCode_InexistentTag)
+      {
+        LogMissingRequiredTag(dicomSummary);
+      }
 
-    return status;
+      throw e;
+    }
   }
 
 
--- a/OrthancServer/ServerEnumerations.cpp	Mon Feb 24 17:41:17 2014 +0100
+++ b/OrthancServer/ServerEnumerations.cpp	Tue Feb 25 17:24:08 2014 +0100
@@ -282,6 +282,9 @@
       
       case ModalityManufacturer_MedInria:
         return "MedInria";
+
+      case ModalityManufacturer_Dcm4Chee:
+        return "Dcm4Chee";
       
       default:
         throw OrthancException(ErrorCode_ParameterOutOfRange);
@@ -335,6 +338,10 @@
     {
       return ModalityManufacturer_MedInria;
     }
+    else if (manufacturer == "Dcm4Chee")
+    {
+      return ModalityManufacturer_Dcm4Chee;
+    }
     else
     {
       throw OrthancException(ErrorCode_ParameterOutOfRange);
--- a/OrthancServer/ServerEnumerations.h	Mon Feb 24 17:41:17 2014 +0100
+++ b/OrthancServer/ServerEnumerations.h	Tue Feb 25 17:24:08 2014 +0100
@@ -57,7 +57,8 @@
   {
     ModalityManufacturer_Generic,
     ModalityManufacturer_ClearCanvas,
-    ModalityManufacturer_MedInria
+    ModalityManufacturer_MedInria,
+    ModalityManufacturer_Dcm4Chee
   };
 
   enum DicomRequestType
--- a/OrthancServer/ServerToolbox.cpp	Mon Feb 24 17:41:17 2014 +0100
+++ b/OrthancServer/ServerToolbox.cpp	Tue Feb 25 17:24:08 2014 +0100
@@ -35,6 +35,7 @@
 #include "../Core/OrthancException.h"
 
 #include <cassert>
+#include <glog/logging.h>
 
 namespace Orthanc
 {
@@ -82,4 +83,71 @@
       }
     }
   }
+
+
+  void LogMissingRequiredTag(const DicomMap& summary)
+  {
+    std::string s, t;
+
+    if (summary.HasTag(DICOM_TAG_PATIENT_ID))
+    {
+      if (t.size() > 0)
+        t += ", ";
+      t += "PatientID=" + summary.GetValue(DICOM_TAG_PATIENT_ID).AsString();
+    }
+    else
+    {
+      if (s.size() > 0)
+        s += ", ";
+      s += "PatientID";
+    }
+
+    if (summary.HasTag(DICOM_TAG_STUDY_INSTANCE_UID))
+    {
+      if (t.size() > 0)
+        t += ", ";
+      t += "StudyInstanceUID=" + summary.GetValue(DICOM_TAG_STUDY_INSTANCE_UID).AsString();
+    }
+    else
+    {
+      if (s.size() > 0)
+        s += ", ";
+      s += "StudyInstanceUID";
+    }
+
+    if (summary.HasTag(DICOM_TAG_SERIES_INSTANCE_UID))
+    {
+      if (t.size() > 0)
+        t += ", ";
+      t += "SeriesInstanceUID=" + summary.GetValue(DICOM_TAG_SERIES_INSTANCE_UID).AsString();
+    }
+    else
+    {
+      if (s.size() > 0)
+        s += ", ";
+      s += "SeriesInstanceUID";
+    }
+
+    if (summary.HasTag(DICOM_TAG_SOP_INSTANCE_UID))
+    {
+      if (t.size() > 0)
+        t += ", ";
+      t += "SOPInstanceUID=" + summary.GetValue(DICOM_TAG_SOP_INSTANCE_UID).AsString();
+    }
+    else
+    {
+      if (s.size() > 0)
+        s += ", ";
+      s += "SOPInstanceUID";
+    }
+
+    if (t.size() == 0)
+    {
+      LOG(ERROR) << "Store has failed because all the required tags (" << s << ") are missing (is it a DICOMDIR file?)";
+    }
+    else
+    {
+      LOG(ERROR) << "Store has failed because required tags (" << s << ") are missing for the following instance: " << t;
+    }
+  }
 }
--- a/OrthancServer/ServerToolbox.h	Mon Feb 24 17:41:17 2014 +0100
+++ b/OrthancServer/ServerToolbox.h	Tue Feb 25 17:24:08 2014 +0100
@@ -32,10 +32,14 @@
 
 #pragma once
 
+#include "../Core/DicomFormat/DicomMap.h"
+
 #include <json/json.h>
 
 namespace Orthanc
 {
   void SimplifyTags(Json::Value& target,
                     const Json::Value& source);
+
+  void LogMissingRequiredTag(const DicomMap& summary);
 }
--- a/OrthancServer/main.cpp	Mon Feb 24 17:41:17 2014 +0100
+++ b/OrthancServer/main.cpp	Tue Feb 25 17:24:08 2014 +0100
@@ -46,6 +46,7 @@
 #include "ServerContext.h"
 #include "OrthancFindRequestHandler.h"
 #include "OrthancMoveRequestHandler.h"
+#include "ServerToolbox.h"
 
 using namespace Orthanc;
 
--- a/Resources/Configuration.json	Mon Feb 24 17:41:17 2014 +0100
+++ b/Resources/Configuration.json	Tue Feb 25 17:24:08 2014 +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), "ClearCanvas" and "MedInria". This
-     * parameter is case-sensitive.
+     * "Generic" (default value), "ClearCanvas", "MedInria" and
+     * "Dcm4Chee". This parameter is case-sensitive.
      **/
     // "clearcanvas" : [ "CLEARCANVAS", "192.168.1.1", 104, "ClearCanvas" ]
   },