changeset 6972:317326336ac6

fix sequence handling in C-Find answers
author Alain Mazy <am@orthanc.team>
date Wed, 01 Jul 2026 16:40:42 +0200
parents c60dae105872
children 534f52a5dba0
files NEWS OrthancServer/Sources/OrthancFindRequestHandler.cpp
diffstat 2 files changed, 15 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Jun 29 16:00:46 2026 +0200
+++ b/NEWS	Wed Jul 01 16:40:42 2026 +0200
@@ -19,6 +19,11 @@
   - StoreKeyValue(storeId, key, value)
   - value = GetKeyValue(storeId, key)
   - DeleteKeyValue(storeId, key)
+* C-Find SCP: When Orthanc was requested a sequence in a C-Find, Orthanc was actually not returning 
+  any sequences in the C-Find answer if the matched resource did contain the requested sequence and
+  was returning an empty sequence if the matched resource did not contain the requestes sequence.
+  Orthanc now returns the full sequence content when the matched resource contains the requested sequence.
+
 
 REST API
 --------
--- a/OrthancServer/Sources/OrthancFindRequestHandler.cpp	Mon Jun 29 16:00:46 2026 +0200
+++ b/OrthancServer/Sources/OrthancFindRequestHandler.cpp	Wed Jul 01 16:40:42 2026 +0200
@@ -41,25 +41,22 @@
 
 namespace Orthanc
 {
+
   static void CopySequence(ParsedDicomFile& dicom,
                            const DicomTag& tag,
-                           const Json::Value& source,
+                           const Json::Value& sequenceContent,
                            const std::string& defaultPrivateCreator,
                            const std::map<uint16_t, std::string>& privateCreators)
   {
-    if (source.type() == Json::objectValue &&
-        source.isMember("Type") &&
-        source.isMember("Value") &&
-        source["Type"].asString() == "Sequence" &&
-        source["Value"].type() == Json::arrayValue)
+    if (sequenceContent.isArray())
     {
-      Json::Value content = Json::arrayValue;
+      Json::Value simplifiedContent = Json::arrayValue;
 
-      for (Json::Value::ArrayIndex i = 0; i < source["Value"].size(); i++)
+      for (Json::Value::ArrayIndex i = 0; i < sequenceContent.size(); i++)
       {
         Json::Value item;
-        Toolbox::SimplifyDicomAsJson(item, source["Value"][i], DicomToJsonFormat_Short);
-        content.append(item);
+        Toolbox::SimplifyDicomAsJson(item, sequenceContent[i], DicomToJsonFormat_Short);
+        simplifiedContent.append(item);
       }
 
       if (tag.IsPrivate())
@@ -68,16 +65,16 @@
 
         if (found != privateCreators.end())
         {
-          dicom.Replace(tag, content, false, DicomReplaceMode_InsertIfAbsent, found->second.c_str());
+          dicom.Replace(tag, simplifiedContent, false, DicomReplaceMode_InsertIfAbsent, found->second.c_str());
         }
         else
         {
-          dicom.Replace(tag, content, false, DicomReplaceMode_InsertIfAbsent, defaultPrivateCreator);
+          dicom.Replace(tag, simplifiedContent, false, DicomReplaceMode_InsertIfAbsent, defaultPrivateCreator);
         }
       }
       else
       {
-        dicom.Replace(tag, content, false, DicomReplaceMode_InsertIfAbsent, "" /* no private creator */);
+        dicom.Replace(tag, simplifiedContent, false, DicomReplaceMode_InsertIfAbsent, "" /* no private creator */);
       }
     }
   }