changeset 5294:e0e2aee4453e

Modality worklists plugin: allow searching on private tags (exact match only)
author Alain Mazy <am@osimis.io>
date Wed, 10 May 2023 12:52:35 +0200
parents ef6d4e794401
children 5053a10da5a2
files NEWS OrthancServer/Sources/Search/HierarchicalMatcher.cpp
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/NEWS	Wed May 10 11:54:59 2023 +0200
+++ b/NEWS	Wed May 10 12:52:35 2023 +0200
@@ -7,6 +7,7 @@
 * Fix decoding of YBR_FULL RLE images for which the "Planar Configuration" 
   tag (0028,0006) equals 1
 * Made Orthanc more resilient to common spelling errors in SpecificCharacterSet
+* Modality worklists plugin: allow searching on private tags (exact match only)
 * Upgraded dependencies for static builds:
   - boost 1.82.0
 
--- a/OrthancServer/Sources/Search/HierarchicalMatcher.cpp	Wed May 10 11:54:59 2023 +0200
+++ b/OrthancServer/Sources/Search/HierarchicalMatcher.cpp	Wed May 10 12:52:35 2023 +0200
@@ -248,6 +248,8 @@
   {
     std::unique_ptr<DcmDataset> target(new DcmDataset);
 
+    std::string currentPrivateCreator = "";
+
     for (std::set<DicomTag>::const_iterator it = flatTags_.begin();
          it != flatTags_.end(); ++it)
     {
@@ -257,13 +259,19 @@
       if (source.findAndGetElement(tag, element).good() &&
           element != NULL)
       {
-        if (it->IsPrivate())
+        if (tag.isPrivateReservation())
         {
-          throw OrthancException(ErrorCode_NotImplemented,
-                                 "Not applicable to private tags: " + it->Format());
+          OFString privateCreator;
+          element->getOFString(privateCreator, 0, false);
+          currentPrivateCreator = privateCreator.c_str();
         }
-        
-        std::unique_ptr<DcmElement> cloned(FromDcmtkBridge::CreateElementForTag(*it, "" /* no private creator */));
+        else if (!it->IsPrivate())
+        {
+          // reset the private creator as soon as we reach the end of the current private block
+          currentPrivateCreator = "";
+        }
+
+        std::unique_ptr<DcmElement> cloned(FromDcmtkBridge::CreateElementForTag(*it, currentPrivateCreator.c_str()));
         cloned->copyFrom(*element);
         target->insert(cloned.release());
       }