diff OrthancFramework/Sources/DicomParsing/DicomModification.h @ 4685:693f049729ba

New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 08 Jun 2021 18:28:57 +0200
parents e3810750dc9d
children 45bce660ce3a
line wrap: on
line diff
--- a/OrthancFramework/Sources/DicomParsing/DicomModification.h	Tue Jun 08 14:42:09 2021 +0200
+++ b/OrthancFramework/Sources/DicomParsing/DicomModification.h	Tue Jun 08 18:28:57 2021 +0200
@@ -97,12 +97,40 @@
 
       bool Contains(const DicomTag& tag) const;
     };
+
+    class SequenceReplacement : public boost::noncopyable
+    {
+    private:
+      DicomPath    path_;
+      Json::Value  value_;
+
+    public:
+      SequenceReplacement(const DicomPath& path,
+                          const Json::Value& value) :
+        path_(path),
+        value_(value)
+      {
+      }
+
+      const DicomPath& GetPath() const
+      {
+        return path_;
+      }
+
+      const Json::Value& GetValue() const
+      {
+        return value_;
+      }
+    };
     
-    typedef std::set<DicomTag> SetOfTags;
-    typedef std::map<DicomTag, Json::Value*> Replacements;
+    typedef std::set<DicomTag>                SetOfTags;
+    typedef std::map<DicomTag, Json::Value*>  Replacements;
+    typedef std::list<DicomTagRange>          RemovedRanges;
+    typedef std::list<DicomPath>              ListOfPaths;
+    typedef std::list<SequenceReplacement*>   SequenceReplacements;
+
     typedef std::map< std::pair<ResourceType, std::string>, std::string>  UidMap;
-    typedef std::list<DicomTagRange>  RemovedRanges;
-
+    
     SetOfTags removals_;
     SetOfTags clearings_;
     Replacements replacements_;
@@ -122,8 +150,11 @@
     IDicomIdentifierGenerator* identifierGenerator_;
 
     // New in Orthanc 1.9.4
-    SetOfTags uids_;
-    RemovedRanges removedRanges_;
+    SetOfTags            uids_;
+    RemovedRanges        removedRanges_;
+    ListOfPaths          keepSequences_;         // Can *possibly* be a path whose prefix is empty
+    ListOfPaths          removeSequences_;       // Must *never* be a path whose prefix is empty
+    SequenceReplacements sequenceReplacements_;  // Must *never* be a path whose prefix is empty
 
     std::string MapDicomIdentifier(const std::string& original,
                                    ResourceType level);
@@ -139,7 +170,7 @@
 
     void ClearReplacements();
 
-    bool CancelReplacement(const DicomTag& tag);
+    void CancelReplacement(const DicomTag& tag);
 
     void ReplaceInternal(const DicomTag& tag,
                          const Json::Value& value);
@@ -214,5 +245,16 @@
     void SetPrivateCreator(const std::string& privateCreator);
 
     const std::string& GetPrivateCreator() const;
+
+    // New in Orthanc 1.9.4
+    void Keep(const DicomPath& path);
+
+    // New in Orthanc 1.9.4
+    void Remove(const DicomPath& path);
+
+    // New in Orthanc 1.9.4
+    void Replace(const DicomPath& path,
+                 const Json::Value& value,   // Encoded using UTF-8
+                 bool safeForAnonymization);
   };
 }