changeset 1231:703fcd797186

Support of Tudor DICOM in Query/Retrieve
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 28 Nov 2014 12:39:22 +0100
parents 4f1ac0f2c39c
children f1c01451a8ee
files NEWS OrthancServer/OrthancMoveRequestHandler.cpp
diffstat 2 files changed, 31 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Thu Nov 27 19:57:49 2014 +0000
+++ b/NEWS	Fri Nov 28 12:39:22 2014 +0100
@@ -2,6 +2,7 @@
 ===============================
 
 * Instances without PatientID are now allowed
+* Support of Tudor DICOM in Query/Retrieve
 
 
 Version 0.8.5 (2014/11/04)
--- a/OrthancServer/OrthancMoveRequestHandler.cpp	Thu Nov 27 19:57:49 2014 +0000
+++ b/OrthancServer/OrthancMoveRequestHandler.cpp	Fri Nov 28 12:39:22 2014 +0100
@@ -102,8 +102,8 @@
 
 
   bool OrthancMoveRequestHandler::LookupIdentifier(std::string& publicId,
-                                                 DicomTag tag,
-                                                 const DicomMap& input)
+                                                   DicomTag tag,
+                                                   const DicomMap& input)
   {
     if (!input.HasTag(tag))
     {
@@ -132,18 +132,42 @@
   {
     LOG(WARNING) << "Move-SCU request received for AET \"" << aet << "\"";
 
-
     /**
      * Retrieve the query level.
      **/
 
+    ResourceType level;
     const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL);
-    if (levelTmp == NULL) 
+
+    if (levelTmp != NULL) 
+    {
+      level = StringToResourceType(levelTmp->AsString().c_str());
+    }
+    else
     {
-      throw OrthancException(ErrorCode_BadRequest);
+      // The query level is not present in the C-Move request, which
+      // does not follow the DICOM standard. This is for instance the
+      // behavior of Tudor DICOM. Try and automatically deduce the
+      // query level: Start from the instance level, going up to the
+      // patient level until a valid DICOM identifier is found.
+
+      std::string publicId;
+
+      if (LookupIdentifier(publicId, DICOM_TAG_SOP_INSTANCE_UID, input) ||
+          LookupIdentifier(publicId, DICOM_TAG_SERIES_INSTANCE_UID, input) ||
+          LookupIdentifier(publicId, DICOM_TAG_STUDY_INSTANCE_UID, input) ||
+          LookupIdentifier(publicId, DICOM_TAG_PATIENT_ID, input))
+      {
+        return new OrthancMoveRequestIterator(context_, aet, publicId);
+      }
+      else
+      {
+        // No identifier is present in the request.
+        throw OrthancException(ErrorCode_BadRequest);
+      }
     }
 
-    ResourceType level = StringToResourceType(levelTmp->AsString().c_str());
+
 
     /**
      * Lookup for the resource to be sent.