annotate OrthancServer/DicomModification.h @ 2049:b89da14b3e8d

fix
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 27 Jun 2016 11:33:22 +0200
parents b1291df2f780
children 3b40ca7470cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
1900
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1698
diff changeset
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
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 *
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 * This program is free software: you can redistribute it and/or
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * modify it under the terms of the GNU General Public License as
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * published by the Free Software Foundation, either version 3 of the
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * License, or (at your option) any later version.
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 *
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * In addition, as a special exception, the copyright holders of this
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * program give permission to link the code of its release with the
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * that use the same license as the "OpenSSL" library), and distribute
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * the linked executables. You must obey the GNU General Public License
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * in all respects for all of the code used other than "OpenSSL". If you
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * modify file(s) with this exception, you may extend this exception to
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * your version of the file(s), but you are not obligated to do so. If
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * you do not wish to do so, delete this exception statement from your
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * version. If you delete this exception statement from all source files
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * in the program, then also delete it here.
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 *
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * This program is distributed in the hope that it will be useful, but
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * General Public License for more details.
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 *
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * You should have received a copy of the GNU General Public License
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 **/
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 #pragma once
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 788
diff changeset
35 #include "ParsedDicomFile.h"
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 namespace Orthanc
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
39 class DicomModification : public boost::noncopyable
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 /**
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 * Process:
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 * (1) Remove private tags
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 * (2) Remove tags specified by the user
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 * (3) Replace tags
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 **/
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 private:
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
49 typedef std::set<DicomTag> SetOfTags;
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
50 typedef std::map<DicomTag, Json::Value*> Replacements;
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
51 typedef std::map< std::pair<ResourceType, std::string>, std::string> UidMap;
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
53 SetOfTags removals_;
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 Replacements replacements_;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 bool removePrivateTags_;
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
56 ResourceType level_;
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 UidMap uidMap_;
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
58 SetOfTags privateTagsToKeep_;
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
59 bool allowManualIdentifiers_;
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 void MapDicomIdentifier(ParsedDicomFile& dicom,
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
62 ResourceType level);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
64 void MarkNotOrthancAnonymization();
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
65
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
66 void ClearReplacements();
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
67
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
68 void RemoveInternal(const DicomTag& tag);
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
69
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
70 void ReplaceInternal(const DicomTag& tag,
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
71 const Json::Value& value);
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
72
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 public:
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 DicomModification();
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
76 ~DicomModification();
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
77
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
78 void Keep(const DicomTag& tag);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 void Remove(const DicomTag& tag);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 bool IsRemoved(const DicomTag& tag) const;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 void Replace(const DicomTag& tag,
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
85 const Json::Value& value, // Encoded using UTF-8
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
86 bool safeForAnonymization = false);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 bool IsReplaced(const DicomTag& tag) const;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
90 const Json::Value& GetReplacement(const DicomTag& tag) const;
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
91
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
92 std::string GetReplacementAsString(const DicomTag& tag) const;
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 void SetRemovePrivateTags(bool removed);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 bool ArePrivateTagsRemoved() const
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 return removePrivateTags_;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
101 void SetLevel(ResourceType level);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
103 ResourceType GetLevel() const
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 return level_;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 void SetupAnonymization();
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 void Apply(ParsedDicomFile& toModify);
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
111
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
112 void SetAllowManualIdentifiers(bool check)
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
113 {
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
114 allowManualIdentifiers_ = check;
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
115 }
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
116
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
117 bool AreAllowManualIdentifiers() const
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
118 {
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
119 return allowManualIdentifiers_;
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
120 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 };
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 }