Mercurial > hg > orthanc
annotate OrthancFramework/Sources/DicomParsing/DicomModification.h @ 5137:15109c3f0f7d
added sanity checks in DicomModificationJob + automatically reconstruct resources at the end of a DicomModificationJob
author | Alain Mazy <am@osimis.io> |
---|---|
date | Wed, 18 Jan 2023 17:58:51 +0100 |
parents | f2dcdbe05884 |
children | 023569e7155b |
rev | line source |
---|---|
4297 | 1 /** |
786 | 2 * Orthanc - A Lightweight, RESTful DICOM Store |
1900 | 3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
1288
6e7e5ed91c2d
upgrade to year 2015
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
4870
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium |
43e613a7756b
upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4831
diff
changeset
|
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
786 | 7 * |
8 * This program is free software: you can redistribute it and/or | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
9 * modify it under the terms of the GNU Lesser General Public License |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
10 * as published by the Free Software Foundation, either version 3 of |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
11 * the License, or (at your option) any later version. |
786 | 12 * |
13 * This program is distributed in the hope that it will be useful, but | |
14 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
16 * Lesser General Public License for more details. |
786 | 17 * |
4119
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
18 * You should have received a copy of the GNU Lesser General Public |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
19 * License along with this program. If not, see |
bf7b9edf6b81
re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4063
diff
changeset
|
20 * <http://www.gnu.org/licenses/>. |
786 | 21 **/ |
22 | |
23 | |
24 #pragma once | |
25 | |
790 | 26 #include "ParsedDicomFile.h" |
5130
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
27 #include <boost/thread/recursive_mutex.hpp> |
786 | 28 |
4680
898e8ac8c453
fix build of wsi and stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4678
diff
changeset
|
29 #include <list> |
898e8ac8c453
fix build of wsi and stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4678
diff
changeset
|
30 |
898e8ac8c453
fix build of wsi and stone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4678
diff
changeset
|
31 |
786 | 32 namespace Orthanc |
33 { | |
4063
e00f3d089991
shared library of orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4044
diff
changeset
|
34 class ORTHANC_PUBLIC DicomModification : public boost::noncopyable |
786 | 35 { |
36 /** | |
37 * Process: | |
38 * (1) Remove private tags | |
39 * (2) Remove tags specified by the user | |
40 * (3) Replace tags | |
41 **/ | |
42 | |
2519
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2506
diff
changeset
|
43 public: |
2535
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
44 class IDicomIdentifierGenerator : public boost::noncopyable |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
45 { |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
46 public: |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
47 virtual ~IDicomIdentifierGenerator() |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
48 { |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
49 } |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
50 |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
51 virtual bool Apply(std::string& target, |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
52 const std::string& sourceIdentifier, |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
53 ResourceType level, |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
54 const DicomMap& sourceDicom) = 0; |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
55 }; |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
56 |
786 | 57 private: |
2506
51b91ead6c38
Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
58 class RelationshipsVisitor; |
51b91ead6c38
Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
59 |
4678
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
60 class DicomTagRange |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
61 { |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
62 private: |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
63 uint16_t groupFrom_; |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
64 uint16_t groupTo_; |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
65 uint16_t elementFrom_; |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
66 uint16_t elementTo_; |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
67 |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
68 public: |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
69 DicomTagRange(uint16_t groupFrom, |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
70 uint16_t groupTo, |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
71 uint16_t elementFrom, |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
72 uint16_t elementTo); |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
73 |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
74 uint16_t GetGroupFrom() const |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
75 { |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
76 return groupFrom_; |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
77 } |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
78 |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
79 uint16_t GetGroupTo() const |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
80 { |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
81 return groupTo_; |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
82 } |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
83 |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
84 uint16_t GetElementFrom() const |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
85 { |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
86 return elementFrom_; |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
87 } |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
88 |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
89 uint16_t GetElementTo() const |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
90 { |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
91 return elementTo_; |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
92 } |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
93 |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
94 bool Contains(const DicomTag& tag) const; |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
95 }; |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
96 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
97 class SequenceReplacement : public boost::noncopyable |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
98 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
99 private: |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
100 DicomPath path_; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
101 Json::Value value_; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
102 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
103 public: |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
104 SequenceReplacement(const DicomPath& path, |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
105 const Json::Value& value) : |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
106 path_(path), |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
107 value_(value) |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
108 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
109 } |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
110 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
111 const DicomPath& GetPath() const |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
112 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
113 return path_; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
114 } |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
115 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
116 const Json::Value& GetValue() const |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
117 { |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
118 return value_; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
119 } |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
120 }; |
4678
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
121 |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
122 typedef std::set<DicomTag> SetOfTags; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
123 typedef std::map<DicomTag, Json::Value*> Replacements; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
124 typedef std::list<DicomTagRange> RemovedRanges; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
125 typedef std::list<DicomPath> ListOfPaths; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
126 typedef std::list<SequenceReplacement*> SequenceReplacements; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
127 |
788 | 128 typedef std::map< std::pair<ResourceType, std::string>, std::string> UidMap; |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
129 |
5130
f2dcdbe05884
ResourceModification jobs can now use multiple threads
Alain Mazy <am@osimis.io>
parents:
5122
diff
changeset
|
130 mutable boost::recursive_mutex uidMapMutex_; |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
790
diff
changeset
|
131 SetOfTags removals_; |
2310
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
132 SetOfTags clearings_; |
5137
15109c3f0f7d
added sanity checks in DicomModificationJob + automatically reconstruct resources at the end of a DicomModificationJob
Alain Mazy <am@osimis.io>
parents:
5130
diff
changeset
|
133 SetOfTags keep_; |
786 | 134 Replacements replacements_; |
135 bool removePrivateTags_; | |
788 | 136 ResourceType level_; |
786 | 137 UidMap uidMap_; |
991
2f76b92addd4
keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
790
diff
changeset
|
138 SetOfTags privateTagsToKeep_; |
5122
8638522eeda1
revert changeset df4a90a65af9 that removes features used elsewhere, and protect by Force the change of UIDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5087
diff
changeset
|
139 bool allowManualIdentifiers_; |
2194
3b40ca7470cc
"Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
140 bool keepStudyInstanceUid_; |
3b40ca7470cc
"Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1900
diff
changeset
|
141 bool keepSeriesInstanceUid_; |
3860
9ccbbd55bc23
allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents:
3709
diff
changeset
|
142 bool keepSopInstanceUid_; |
2506
51b91ead6c38
Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
143 bool updateReferencedRelationships_; |
2721 | 144 bool isAnonymization_; |
2535
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
145 DicomMap currentSource_; |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
146 std::string privateCreator_; |
2535
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
147 |
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
148 IDicomIdentifierGenerator* identifierGenerator_; |
786 | 149 |
4684
e3810750dc9d
simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4680
diff
changeset
|
150 // New in Orthanc 1.9.4 |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
151 SetOfTags uids_; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
152 RemovedRanges removedRanges_; |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
153 ListOfPaths keepSequences_; // Can *possibly* be a path whose prefix is empty |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
154 ListOfPaths removeSequences_; // Must *never* be a path whose prefix is empty |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
155 SequenceReplacements sequenceReplacements_; // Must *never* be a path whose prefix is empty |
4684
e3810750dc9d
simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4680
diff
changeset
|
156 |
2506
51b91ead6c38
Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
157 std::string MapDicomIdentifier(const std::string& original, |
51b91ead6c38
Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
158 ResourceType level); |
51b91ead6c38
Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
159 |
3513
7db879b014ff
Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents:
3060
diff
changeset
|
160 void RegisterMappedDicomIdentifier(const std::string& original, |
7db879b014ff
Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents:
3060
diff
changeset
|
161 const std::string& mapped, |
7db879b014ff
Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents:
3060
diff
changeset
|
162 ResourceType level); |
7db879b014ff
Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents:
3060
diff
changeset
|
163 |
2506
51b91ead6c38
Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
164 void MapDicomTags(ParsedDicomFile& dicom, |
51b91ead6c38
Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2447
diff
changeset
|
165 ResourceType level); |
786 | 166 |
1279
7f3a65e84d4b
More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
167 void MarkNotOrthancAnonymization(); |
7f3a65e84d4b
More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
168 |
1698
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
169 void ClearReplacements(); |
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
170 |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
171 void CancelReplacement(const DicomTag& tag); |
1698
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
172 |
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
173 void ReplaceInternal(const DicomTag& tag, |
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
174 const Json::Value& value); |
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
175 |
4678
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
176 void SetupUidsFromOrthanc_1_9_3(); |
2e850edf03d6
Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4677
diff
changeset
|
177 |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
178 void SetupAnonymization2008(); |
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
179 |
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
180 void SetupAnonymization2017c(); |
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
181 |
4677
521e39b3f2c0
Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
182 void SetupAnonymization2021b(); |
521e39b3f2c0
Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
183 |
2662
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
184 void UnserializeUidMap(ResourceType level, |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
185 const Json::Value& serialized, |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
186 const char* field); |
47d812308d63
serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2655
diff
changeset
|
187 |
786 | 188 public: |
189 DicomModification(); | |
190 | |
4200 | 191 explicit DicomModification(const Json::Value& serialized); |
2655 | 192 |
1698
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
193 ~DicomModification(); |
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
194 |
787
ac18946afa74
refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
786
diff
changeset
|
195 void Keep(const DicomTag& tag); |
786 | 196 |
197 void Remove(const DicomTag& tag); | |
198 | |
2310
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
199 // Replace the DICOM tag as a NULL/empty value (e.g. for anonymization) |
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
200 void Clear(const DicomTag& tag); |
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
201 |
786 | 202 bool IsRemoved(const DicomTag& tag) const; |
203 | |
2310
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
204 bool IsCleared(const DicomTag& tag) const; |
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
205 |
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
206 // "safeForAnonymization" tells Orthanc that this replacement does |
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
207 // not break the anonymization process it implements (for internal use only) |
786 | 208 void Replace(const DicomTag& tag, |
1698
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
209 const Json::Value& value, // Encoded using UTF-8 |
2310
b7fba68747f6
DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2309
diff
changeset
|
210 bool safeForAnonymization); |
786 | 211 |
212 bool IsReplaced(const DicomTag& tag) const; | |
213 | |
5137
15109c3f0f7d
added sanity checks in DicomModificationJob + automatically reconstruct resources at the end of a DicomModificationJob
Alain Mazy <am@osimis.io>
parents:
5130
diff
changeset
|
214 void GetReplacedTags(std::set<DicomTag>& target) const; |
15109c3f0f7d
added sanity checks in DicomModificationJob + automatically reconstruct resources at the end of a DicomModificationJob
Alain Mazy <am@osimis.io>
parents:
5130
diff
changeset
|
215 |
1698
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
216 const Json::Value& GetReplacement(const DicomTag& tag) const; |
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
217 |
d78b87f93bcf
DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1695
diff
changeset
|
218 std::string GetReplacementAsString(const DicomTag& tag) const; |
786 | 219 |
5137
15109c3f0f7d
added sanity checks in DicomModificationJob + automatically reconstruct resources at the end of a DicomModificationJob
Alain Mazy <am@osimis.io>
parents:
5130
diff
changeset
|
220 bool IsKept(const DicomTag& tag) const; |
15109c3f0f7d
added sanity checks in DicomModificationJob + automatically reconstruct resources at the end of a DicomModificationJob
Alain Mazy <am@osimis.io>
parents:
5130
diff
changeset
|
221 |
786 | 222 void SetRemovePrivateTags(bool removed); |
223 | |
4297 | 224 bool ArePrivateTagsRemoved() const; |
786 | 225 |
788 | 226 void SetLevel(ResourceType level); |
786 | 227 |
4297 | 228 ResourceType GetLevel() const; |
786 | 229 |
2309
4dc313b9a20a
Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2244
diff
changeset
|
230 void SetupAnonymization(DicomVersion version); |
786 | 231 |
232 void Apply(ParsedDicomFile& toModify); | |
1279
7f3a65e84d4b
More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
991
diff
changeset
|
233 |
5122
8638522eeda1
revert changeset df4a90a65af9 that removes features used elsewhere, and protect by Force the change of UIDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5087
diff
changeset
|
234 void SetAllowManualIdentifiers(bool check); |
8638522eeda1
revert changeset df4a90a65af9 that removes features used elsewhere, and protect by Force the change of UIDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5087
diff
changeset
|
235 |
8638522eeda1
revert changeset df4a90a65af9 that removes features used elsewhere, and protect by Force the change of UIDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5087
diff
changeset
|
236 bool AreAllowManualIdentifiers() const; |
8638522eeda1
revert changeset df4a90a65af9 that removes features used elsewhere, and protect by Force the change of UIDs
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5087
diff
changeset
|
237 |
2519
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2506
diff
changeset
|
238 void ParseModifyRequest(const Json::Value& request); |
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2506
diff
changeset
|
239 |
4693
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4685
diff
changeset
|
240 // "patientNameOverridden" is set to "true" iff. the PatientName |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4685
diff
changeset
|
241 // (0010,0010) tag is manually replaced, removed, cleared or kept |
45bce660ce3a
added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4685
diff
changeset
|
242 void ParseAnonymizationRequest(bool& patientNameOverridden /* out */, |
2519
2e6b7862ccf2
ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2506
diff
changeset
|
243 const Json::Value& request); |
2535
d3476d90dcb7
DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2519
diff
changeset
|
244 |
4297 | 245 void SetDicomIdentifierGenerator(IDicomIdentifierGenerator& generator); |
2616
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2535
diff
changeset
|
246 |
2f3007bf0708
event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2535
diff
changeset
|
247 void Serialize(Json::Value& value) const; |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
248 |
4297 | 249 void SetPrivateCreator(const std::string& privateCreator); |
3691
4922bdd046dd
Fix issue #140 (Modifying private tags with REST API changes VR from LO to UN) - DANGEROUS COMMIT
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
250 |
4297 | 251 const std::string& GetPrivateCreator() const; |
4685
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
252 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
253 // New in Orthanc 1.9.4 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
254 void Keep(const DicomPath& path); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
255 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
256 // New in Orthanc 1.9.4 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
257 void Remove(const DicomPath& path); |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
258 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
259 // New in Orthanc 1.9.4 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
260 void Replace(const DicomPath& path, |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
261 const Json::Value& value, // Encoded using UTF-8 |
693f049729ba
New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4684
diff
changeset
|
262 bool safeForAnonymization); |
4789
51ec061516c9
Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
263 |
51ec061516c9
Fix handling of option "DeidentifyLogs", notably for tags (0010,0010) and (0010,0020)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4737
diff
changeset
|
264 bool IsAlteredTag(const DicomTag& tag) const; |
786 | 265 }; |
266 } |