changeset 5855:aeb9f63923b1 find-refactoring

ignore tags from meta header in RequestedTags
author Alain Mazy <am@orthanc.team>
date Mon, 04 Nov 2024 20:00:42 +0100
parents 65f8c6dfba50
children d1dea8ad74a6
files NEWS OrthancFramework/Sources/DicomFormat/DicomMap.cpp OrthancFramework/Sources/DicomFormat/DicomMap.h OrthancServer/Resources/Configuration.json OrthancServer/Sources/OrthancConfiguration.cpp OrthancServer/Sources/ResourceFinder.cpp OrthancServer/Sources/ServerEnumerations.h
diffstat 7 files changed, 50 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Mon Nov 04 17:51:46 2024 +0100
+++ b/NEWS	Mon Nov 04 20:00:42 2024 +0100
@@ -73,6 +73,7 @@
   - W003_DecoderFailure
   - W004_NoMainDicomTagsSignature
   - W005_RequestingTagFromLowerResourceLevel
+  - W006_RequestingTagFromMetaHeader
 * New default MainDicomTags are now stored in DB.  Note that, in order to store these values
   for resources that were ingested in Orthanc before this release, you would have to run
   the Housekeeper plugin or call /reconstruct on every resources
--- a/OrthancFramework/Sources/DicomFormat/DicomMap.cpp	Mon Nov 04 17:51:46 2024 +0100
+++ b/OrthancFramework/Sources/DicomFormat/DicomMap.cpp	Mon Nov 04 20:00:42 2024 +0100
@@ -800,6 +800,17 @@
     return false;
   }
 
+  bool DicomMap::HasMetaInformationTags(const std::set<DicomTag>& tags)
+  {
+    for (std::set<DicomTag>::const_iterator it = tags.begin(); it != tags.end(); ++it)
+    {
+      if (it->GetGroup() == 0x0002)
+      {
+        return true;
+      }
+    }
+    return false;
+  }
 
   void DicomMap::GetMainDicomTags(std::set<DicomTag>& target,
                                   ResourceType level)
--- a/OrthancFramework/Sources/DicomFormat/DicomMap.h	Mon Nov 04 17:51:46 2024 +0100
+++ b/OrthancFramework/Sources/DicomFormat/DicomMap.h	Mon Nov 04 20:00:42 2024 +0100
@@ -146,6 +146,8 @@
 
     static bool HasComputedTags(const std::set<DicomTag>& tags);
 
+    static bool HasMetaInformationTags(const std::set<DicomTag>& tags);
+
     static void GetMainDicomTags(std::set<DicomTag>& target,
                                  ResourceType level);
 
--- a/OrthancServer/Resources/Configuration.json	Mon Nov 04 17:51:46 2024 +0100
+++ b/OrthancServer/Resources/Configuration.json	Mon Nov 04 20:00:42 2024 +0100
@@ -1004,7 +1004,12 @@
     // from a lower resource level; e.g. when requesting "StudyDescription" at
     // Patient level.
     // (new in Orthanc 1.12.5)
-    "W005_RequestingTagFromLowerResourceLevel": true
+    "W005_RequestingTagFromLowerResourceLevel": true,
+
+    // Display a warning when a user performs a find request and requests a tag
+    // from the DICOM Meta Header.
+    // (new in Orthanc 1.12.5)
+    "W006_RequestingTagFromMetaHeader": true
   },
 
   // Configure Orthanc in read only mode.
--- a/OrthancServer/Sources/OrthancConfiguration.cpp	Mon Nov 04 17:51:46 2024 +0100
+++ b/OrthancServer/Sources/OrthancConfiguration.cpp	Mon Nov 04 20:00:42 2024 +0100
@@ -1169,6 +1169,10 @@
         {
           warning = Warnings_005_RequestingTagFromLowerResourceLevel;
         }
+        else if (name == "W006_RequestingTagFromMetaHeader")
+        {
+          warning = Warnings_006_RequestingTagFromMetaHeader;
+        }
         else
         {
           throw OrthancException(ErrorCode_BadFileFormat, name + " is not recognized as a valid warning name");
--- a/OrthancServer/Sources/ResourceFinder.cpp	Mon Nov 04 17:51:46 2024 +0100
+++ b/OrthancServer/Sources/ResourceFinder.cpp	Mon Nov 04 20:00:42 2024 +0100
@@ -1022,11 +1022,13 @@
 
     bool isWarning002Enabled = false;
     bool isWarning004Enabled = false;
+    bool isWarning006Enabled = false;
 
     {
       OrthancConfiguration::ReaderLock lock;
       isWarning002Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_002_InconsistentDicomTagsInDb);
       isWarning004Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_004_NoMainDicomTagsSignature);
+      isWarning006Enabled = lock.GetConfiguration().IsWarningEnabled(Warnings_006_RequestingTagFromMetaHeader);
     }
 
     FindResponse response;
@@ -1084,6 +1086,28 @@
         InjectRequestedTags(outRequestedTags, remainingRequestedTags, resource, ResourceType_Series);
         InjectRequestedTags(outRequestedTags, remainingRequestedTags, resource, ResourceType_Instance);
 
+        if (DicomMap::HasMetaInformationTags(remainingRequestedTags)) // we are not able to retrieve meta information in RequestedTags
+        {
+          std::set<DicomTag> metaTagsToRemove;
+          for (std::set<DicomTag>::const_iterator it = remainingRequestedTags.begin(); it != remainingRequestedTags.end(); ++it)
+          {
+            if (it->GetGroup() == 0x0002)
+            {
+              metaTagsToRemove.insert(*it);
+            }
+          }
+
+          if (isWarning006Enabled)
+          {
+            std::string joinedMetaTags;
+            FromDcmtkBridge::FormatListOfTags(joinedMetaTags, metaTagsToRemove);
+            LOG(WARNING) << "W006: Unable to include tags from the Meta Header in 'RequestedTags'.  Skipping them: " << joinedMetaTags;
+          }
+
+          Toolbox::RemoveSets(remainingRequestedTags, metaTagsToRemove);
+        }
+
+
         if (!remainingRequestedTags.empty() && 
             !DicomMap::HasOnlyComputedTags(remainingRequestedTags)) // if the only remaining tags are computed tags, it is worthless to read them from disk
         {
--- a/OrthancServer/Sources/ServerEnumerations.h	Mon Nov 04 17:51:46 2024 +0100
+++ b/OrthancServer/Sources/ServerEnumerations.h	Mon Nov 04 20:00:42 2024 +0100
@@ -253,7 +253,8 @@
     Warnings_002_InconsistentDicomTagsInDb,
     Warnings_003_DecoderFailure,              // new in Orthanc 1.12.5
     Warnings_004_NoMainDicomTagsSignature,    // new in Orthanc 1.12.5
-    Warnings_005_RequestingTagFromLowerResourceLevel    // new in Orthanc 1.12.5
+    Warnings_005_RequestingTagFromLowerResourceLevel,    // new in Orthanc 1.12.5
+    Warnings_006_RequestingTagFromMetaHeader    // new in Orthanc 1.12.5
   };