annotate OrthancFramework/Sources/DicomParsing/DicomModification.cpp @ 4734:b51c08bd5c38

added ITagVisitor::Action_Remove
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 05 Jul 2021 16:12:10 +0200
parents dd6274412ff4
children 979ae3ea3381
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: 1818
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
4437
d9473bd5ed43 upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4313
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * 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: 4044
diff changeset
8 * 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: 4044
diff changeset
9 * 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: 4044
diff changeset
10 * the License, or (at your option) any later version.
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * 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: 4044
diff changeset
15 * Lesser General Public License for more details.
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
4119
bf7b9edf6b81 re-licensing the OrthancFramework to LGPL, in order to license Stone of Orthanc under LGPL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
17 * 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: 4044
diff changeset
18 * 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: 4044
diff changeset
19 * <http://www.gnu.org/licenses/>.
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2323
diff changeset
23 #include "../PrecompiledHeaders.h"
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 #include "DicomModification.h"
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
26 #include "../Compatibility.h"
2382
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2323
diff changeset
27 #include "../Logging.h"
7284093111b0 big reorganization to cleanly separate framework vs. server
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2323
diff changeset
28 #include "../OrthancException.h"
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
29 #include "../SerializationToolbox.h"
790
331eaf9d9d69 ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 789
diff changeset
30 #include "FromDcmtkBridge.h"
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
31 #include "ITagVisitor.h"
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
33 #include <memory> // For std::unique_ptr
795
d466b3606aca refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 790
diff changeset
34
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
35
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
36 static const std::string ORTHANC_DEIDENTIFICATION_METHOD_2008 =
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
37 "Orthanc " ORTHANC_VERSION " - PS 3.15-2008 Table E.1-1";
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
38
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
39 static const std::string ORTHANC_DEIDENTIFICATION_METHOD_2017c =
2314
c54c9523adf8 add basic profile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2313
diff changeset
40 "Orthanc " ORTHANC_VERSION " - PS 3.15-2017c Table E.1-1 Basic Profile";
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
41
4677
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
42 static const std::string ORTHANC_DEIDENTIFICATION_METHOD_2021b =
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
43 "Orthanc " ORTHANC_VERSION " - PS 3.15-2021b Table E.1-1 Basic Profile";
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
44
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 namespace Orthanc
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 {
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
47 DicomModification::DicomTagRange::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
48 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
49 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
50 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
51 groupFrom_(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
52 groupTo_(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
53 elementFrom_(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
54 elementTo_(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
55 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
56 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
57
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
58
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
59 bool DicomModification::DicomTagRange::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
60 {
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 return (tag.GetGroup() >= 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
62 tag.GetGroup() <= 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
63 tag.GetElement() >= 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
64 tag.GetElement() <= 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
65 }
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
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
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
68 class DicomModification::RelationshipsVisitor : public ITagVisitor
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
69 {
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
70 private:
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
71 DicomModification& that_;
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
72
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
73 // This method is only applicable to first-level tags
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
74 bool IsManuallyModified(const DicomTag& tag) const
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
75 {
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
76 return (that_.IsCleared(tag) ||
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
77 that_.IsRemoved(tag) ||
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
78 that_.IsReplaced(tag));
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
79 }
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
80
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
81 public:
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4139
diff changeset
82 explicit RelationshipsVisitor(DicomModification& that) :
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4139
diff changeset
83 that_(that)
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
84 {
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
85 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
86
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
87 virtual Action VisitNotSupported(const std::vector<DicomTag>& parentTags,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
88 const std::vector<size_t>& parentIndexes,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
89 const DicomTag& tag,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
90 ValueRepresentation vr) ORTHANC_OVERRIDE
3195
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3194
diff changeset
91 {
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
92 return Action_None;
3195
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3194
diff changeset
93 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3194
diff changeset
94
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
95 virtual Action VisitEmptySequence(const std::vector<DicomTag>& parentTags,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
96 const std::vector<size_t>& parentIndexes,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
97 const DicomTag& tag) ORTHANC_OVERRIDE
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
98 {
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
99 return Action_None;
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
100 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
101
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
102 virtual Action VisitBinary(const std::vector<DicomTag>& parentTags,
3194
47ef29168698 support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
103 const std::vector<size_t>& parentIndexes,
47ef29168698 support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
104 const DicomTag& tag,
47ef29168698 support of value multiplicity in ITagVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
105 ValueRepresentation vr,
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
106 const void* data,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
107 size_t size) ORTHANC_OVERRIDE
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
108 {
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
109 return Action_None;
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
110 }
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
111
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
112 virtual Action VisitIntegers(const std::vector<DicomTag>& parentTags,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
113 const std::vector<size_t>& parentIndexes,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
114 const DicomTag& tag,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
115 ValueRepresentation vr,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
116 const std::vector<int64_t>& values) ORTHANC_OVERRIDE
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
117 {
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
118 return Action_None;
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
119 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
120
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
121 virtual Action VisitDoubles(const std::vector<DicomTag>& parentTags,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
122 const std::vector<size_t>& parentIndexes,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
123 const DicomTag& tag,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
124 ValueRepresentation vr,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
125 const std::vector<double>& value) ORTHANC_OVERRIDE
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
126 {
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
127 return Action_None;
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
128 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
129
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
130 virtual Action VisitAttributes(const std::vector<DicomTag>& parentTags,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
131 const std::vector<size_t>& parentIndexes,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
132 const DicomTag& tag,
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
133 const std::vector<DicomTag>& value) ORTHANC_OVERRIDE
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
134 {
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
135 return Action_None;
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
136 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
137
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
138 virtual Action VisitString(std::string& newValue,
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
139 const std::vector<DicomTag>& parentTags,
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
140 const std::vector<size_t>& parentIndexes,
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
141 const DicomTag& tag,
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
142 ValueRepresentation vr,
4734
b51c08bd5c38 added ITagVisitor::Action_Remove
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4696
diff changeset
143 const std::string& value) ORTHANC_OVERRIDE
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
144 {
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
145 /**
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
146 * Note that all the tags in "uids_" have the VR UI (unique
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
147 * identifier), and are considered as strings.
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
148 *
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
149 * Also, the tags "SOP Instance UID", "Series Instance UID" and
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
150 * "Study Instance UID" are *never* included in "uids_", as they
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
151 * are separately handed by "MapDicomTags()".
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
152 **/
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
153
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
154 assert(that_.uids_.find(DICOM_TAG_STUDY_INSTANCE_UID) == that_.uids_.end());
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
155 assert(that_.uids_.find(DICOM_TAG_SERIES_INSTANCE_UID) == that_.uids_.end());
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
156 assert(that_.uids_.find(DICOM_TAG_SOP_INSTANCE_UID) == that_.uids_.end());
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
157
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
158 if (parentTags.empty())
2521
6db878376018 support anonymization of CurrentRequestedProcedureEvidenceSequence
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2520
diff changeset
159 {
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
160 // We are on a first-level tag
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
161 if (that_.uids_.find(tag) != that_.uids_.end() &&
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
162 !IsManuallyModified(tag))
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
163 {
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
164 if (tag == DICOM_TAG_PATIENT_ID ||
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
165 tag == DICOM_TAG_PATIENT_NAME)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
166 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
167 assert(vr == ValueRepresentation_LongString ||
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
168 vr == ValueRepresentation_PersonName);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
169 newValue = that_.MapDicomIdentifier(value, ResourceType_Patient);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
170 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
171 else
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
172 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
173 // This is a first-level UID tag that must be anonymized
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
174 assert(vr == ValueRepresentation_UniqueIdentifier ||
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
175 vr == ValueRepresentation_NotSupported /* for older versions of DCMTK */);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
176 newValue = that_.MapDicomIdentifier(value, ResourceType_Instance);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
177 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
178
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
179 return Action_Replace;
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
180 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
181 else
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
182 {
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
183 return Action_None;
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
184 }
3344
90b4a5001c24 Anonymization: Preserve hierarchical relationships in (0008,1115) [] (0020,000e)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3195
diff changeset
185 }
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
186 else
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
187 {
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
188 // We are within a sequence
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
189
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
190 if (!that_.keepSequences_.empty())
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
191 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
192 // New in Orthanc 1.9.4 - Solves issue LSD-629
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
193 DicomPath path(parentTags, parentIndexes, tag);
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
194
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
195 for (ListOfPaths::const_iterator it = that_.keepSequences_.begin();
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
196 it != that_.keepSequences_.end(); ++it)
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
197 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
198 if (DicomPath::IsMatch(*it, path))
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
199 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
200 return Action_None;
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
201 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
202 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
203 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
204
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
205 if (tag == DICOM_TAG_STUDY_INSTANCE_UID)
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
206 {
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
207 newValue = that_.MapDicomIdentifier(value, ResourceType_Study);
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
208 return Action_Replace;
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
209 }
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
210 else if (tag == DICOM_TAG_SERIES_INSTANCE_UID)
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
211 {
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
212 newValue = that_.MapDicomIdentifier(value, ResourceType_Series);
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
213 return Action_Replace;
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
214 }
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
215 else if (tag == DICOM_TAG_SOP_INSTANCE_UID)
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
216 {
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
217 newValue = that_.MapDicomIdentifier(value, ResourceType_Instance);
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
218 return Action_Replace;
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
219 }
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
220 else if (that_.uids_.find(tag) != that_.uids_.end())
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
221 {
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
222 if (tag == DICOM_TAG_PATIENT_ID ||
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
223 tag == DICOM_TAG_PATIENT_NAME)
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
224 {
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
225 newValue = that_.MapDicomIdentifier(value, ResourceType_Patient);
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
226 }
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
227 else
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
228 {
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
229 assert(vr == ValueRepresentation_UniqueIdentifier ||
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
230 vr == ValueRepresentation_NotSupported /* for older versions of DCMTK */);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
231
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
232 if (parentTags.size() == 2 &&
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
233 parentTags[0] == DICOM_TAG_REFERENCED_FRAME_OF_REFERENCE_SEQUENCE &&
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
234 parentTags[1] == DICOM_TAG_RT_REFERENCED_STUDY_SEQUENCE &&
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
235 tag == DICOM_TAG_REFERENCED_SOP_INSTANCE_UID)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
236 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
237 /**
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
238 * In RT-STRUCT, this ReferencedSOPInstanceUID is actually
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
239 * referencing a StudyInstanceUID !! (observed in many
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
240 * data sets including:
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
241 * https://wiki.cancerimagingarchive.net/display/Public/Lung+CT+Segmentation+Challenge+2017)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
242 * Tested in "test_anonymize_relationships_5". Introduced
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
243 * in: https://hg.orthanc-server.com/orthanc/rev/3513
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
244 **/
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
245 newValue = that_.MapDicomIdentifier(value, ResourceType_Study);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
246 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
247 else
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
248 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
249 newValue = that_.MapDicomIdentifier(value, ResourceType_Instance);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
250 }
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
251 }
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
252
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
253 return Action_Replace;
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
254 }
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
255 else
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
256 {
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
257 return Action_None;
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
258 }
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
259 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
260 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
261
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
262 void RemoveRelationships(ParsedDicomFile& dicom) const
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
263 {
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
264 for (SetOfTags::const_iterator it = that_.uids_.begin(); it != that_.uids_.end(); ++it)
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
265 {
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
266 assert(*it != DICOM_TAG_STUDY_INSTANCE_UID &&
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
267 *it != DICOM_TAG_SERIES_INSTANCE_UID &&
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
268 *it != DICOM_TAG_SOP_INSTANCE_UID);
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
269
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
270 if (!IsManuallyModified(*it))
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
271 {
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
272 dicom.Remove(*it);
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
273 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
274 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
275
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
276 // The only two sequences with to the "X/Z/U*" rule in the
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
277 // basic profile. They were already present in Orthanc 1.9.3.
4684
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
278 if (!IsManuallyModified(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE))
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
279 {
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
280 dicom.Remove(DICOM_TAG_REFERENCED_IMAGE_SEQUENCE);
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
281 }
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
282
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
283 if (!IsManuallyModified(DICOM_TAG_SOURCE_IMAGE_SEQUENCE))
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
284 {
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
285 dicom.Remove(DICOM_TAG_SOURCE_IMAGE_SEQUENCE);
e3810750dc9d simplified DicomModification::RelationshipsVisitor
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4678
diff changeset
286 }
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
287 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
288 };
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
289
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
290
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
291 void DicomModification::CancelReplacement(const DicomTag& tag)
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
292 {
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
293 Replacements::iterator it = replacements_.find(tag);
2323
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2321
diff changeset
294
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
295 if (it != replacements_.end())
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
296 {
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
297 assert(it->second != NULL);
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
298 delete it->second;
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
299 replacements_.erase(it);
2323
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2321
diff changeset
300 }
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
301 }
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
302
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
303
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
304 void DicomModification::ReplaceInternal(const DicomTag& tag,
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
305 const Json::Value& value)
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
306 {
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
307 Replacements::iterator it = replacements_.find(tag);
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
308
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
309 if (it != replacements_.end())
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
310 {
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
311 assert(it->second != NULL);
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
312 delete it->second;
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
313 it->second = NULL; // In the case of an exception during the clone
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
314 it->second = new Json::Value(value); // Clone
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
315 }
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
316 else
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
317 {
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
318 replacements_[tag] = new Json::Value(value); // Clone
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
319 }
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
320 }
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
321
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
322
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
323 void DicomModification::ClearReplacements()
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
324 {
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
325 for (Replacements::iterator it = replacements_.begin();
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
326 it != replacements_.end(); ++it)
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
327 {
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
328 assert(it->second != NULL);
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
329 delete it->second;
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
330 }
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
331
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
332 replacements_.clear();
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
333
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
334 for (SequenceReplacements::iterator it = sequenceReplacements_.begin();
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
335 it != sequenceReplacements_.end(); ++it)
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
336 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
337 assert(*it != NULL);
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
338 assert((*it)->GetPath().GetPrefixLength() > 0);
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
339 delete *it;
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
340 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
341
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
342 sequenceReplacements_.clear();
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
343 }
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
344
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
345
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
346 void DicomModification::MarkNotOrthancAnonymization()
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
347 {
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
348 Replacements::iterator it = replacements_.find(DICOM_TAG_DEIDENTIFICATION_METHOD);
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
349
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
350 if (it != replacements_.end())
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
351 {
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
352 assert(it->second != NULL);
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
353
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
354 if (it->second->asString() == ORTHANC_DEIDENTIFICATION_METHOD_2008 ||
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
355 it->second->asString() == ORTHANC_DEIDENTIFICATION_METHOD_2017c ||
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
356 it->second->asString() == ORTHANC_DEIDENTIFICATION_METHOD_2021b)
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
357 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
358 delete it->second;
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
359 replacements_.erase(it);
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
360 }
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
361 }
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
362 }
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
363
3513
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
364 void DicomModification::RegisterMappedDicomIdentifier(const std::string& original,
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
365 const std::string& mapped,
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
366 ResourceType level)
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
367 {
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
368 UidMap::const_iterator previous = uidMap_.find(std::make_pair(level, original));
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
369
3513
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
370 if (previous == uidMap_.end())
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
371 {
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
372 uidMap_.insert(std::make_pair(std::make_pair(level, original), mapped));
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
373 }
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
374 }
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
375
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
376 std::string DicomModification::MapDicomIdentifier(const std::string& original,
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
377 ResourceType level)
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
378 {
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
379 const std::string stripped = Toolbox::StripSpaces(original);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
380
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
381 std::string mapped;
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
382
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
383 UidMap::const_iterator previous = uidMap_.find(std::make_pair(level, stripped));
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
384
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
385 if (previous == uidMap_.end())
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
386 {
2535
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
387 if (identifierGenerator_ == NULL)
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
388 {
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
389 mapped = FromDcmtkBridge::GenerateUniqueIdentifier(level);
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
390 }
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
391 else
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
392 {
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
393 if (!identifierGenerator_->Apply(mapped, stripped, level, currentSource_))
2535
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
394 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
395 throw OrthancException(ErrorCode_InternalError,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
396 "Unable to generate an anonymized ID");
2535
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
397 }
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
398 }
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
399
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
400 uidMap_.insert(std::make_pair(std::make_pair(level, stripped), mapped));
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
401 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
402 else
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
403 {
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
404 mapped = previous->second;
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
405 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
406
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
407 return mapped;
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
408 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
409
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
410
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
411 void DicomModification::MapDicomTags(ParsedDicomFile& dicom,
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
412 ResourceType level)
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
413 {
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3709
diff changeset
414 std::unique_ptr<DicomTag> tag;
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
415
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
416 switch (level)
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
417 {
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
418 case ResourceType_Study:
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
419 tag.reset(new DicomTag(DICOM_TAG_STUDY_INSTANCE_UID));
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
420 break;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
421
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
422 case ResourceType_Series:
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
423 tag.reset(new DicomTag(DICOM_TAG_SERIES_INSTANCE_UID));
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
424 break;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
425
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
426 case ResourceType_Instance:
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
427 tag.reset(new DicomTag(DICOM_TAG_SOP_INSTANCE_UID));
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
428 break;
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
429
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
430 default:
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
431 throw OrthancException(ErrorCode_InternalError);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
432 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
433
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
434 std::string original;
4273
0034f855c023 tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
435 if (!const_cast<const ParsedDicomFile&>(dicom).GetTagValue(original, *tag))
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
436 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
437 original = "";
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
438 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
439
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
440 std::string mapped = MapDicomIdentifier(original, level);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
441
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
442 dicom.Replace(*tag, mapped,
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
443 false /* don't try and decode data URI scheme for UIDs */,
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
444 DicomReplaceMode_InsertIfAbsent, privateCreator_);
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
445 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
446
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
447
2194
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
448 DicomModification::DicomModification() :
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
449 removePrivateTags_(false),
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
450 level_(ResourceType_Instance),
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
451 allowManualIdentifiers_(true),
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
452 keepStudyInstanceUid_(false),
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
453 keepSeriesInstanceUid_(false),
3860
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
454 keepSopInstanceUid_(false),
2535
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
455 updateReferencedRelationships_(true),
2721
062776ab4a21 fix issue #94
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
456 isAnonymization_(false),
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
457 //privateCreator_("PrivateCreator"),
2535
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
458 identifierGenerator_(NULL)
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
459 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
460 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
461
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
462 DicomModification::~DicomModification()
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
463 {
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
464 ClearReplacements();
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
465 }
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
466
787
ac18946afa74 refactoring of anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 786
diff changeset
467 void DicomModification::Keep(const DicomTag& tag)
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
468 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
469 removals_.erase(tag);
2310
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
470 clearings_.erase(tag);
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
471 uids_.erase(tag);
2323
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2321
diff changeset
472
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
473 CancelReplacement(tag);
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 916
diff changeset
474
2194
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
475 if (tag == DICOM_TAG_STUDY_INSTANCE_UID)
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
476 {
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
477 keepStudyInstanceUid_ = true;
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
478 }
2321
65ffba10cace warning message in DicomModification::Keep()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2314
diff changeset
479 else if (tag == DICOM_TAG_SERIES_INSTANCE_UID)
2194
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
480 {
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
481 keepSeriesInstanceUid_ = true;
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
482 }
3860
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
483 else if (tag == DICOM_TAG_SOP_INSTANCE_UID)
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
484 {
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
485 keepSopInstanceUid_ = true;
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
486 }
2321
65ffba10cace warning message in DicomModification::Keep()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2314
diff changeset
487 else if (tag.IsPrivate())
65ffba10cace warning message in DicomModification::Keep()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2314
diff changeset
488 {
65ffba10cace warning message in DicomModification::Keep()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2314
diff changeset
489 privateTagsToKeep_.insert(tag);
65ffba10cace warning message in DicomModification::Keep()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2314
diff changeset
490 }
2194
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
491
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
492 MarkNotOrthancAnonymization();
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
493 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
494
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
495 void DicomModification::Remove(const DicomTag& tag)
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
496 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 removals_.insert(tag);
2310
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
498 clearings_.erase(tag);
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
499 uids_.erase(tag);
2323
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2321
diff changeset
500 CancelReplacement(tag);
2310
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
501 privateTagsToKeep_.erase(tag);
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
502
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
503 MarkNotOrthancAnonymization();
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
504 }
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
505
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
506 void DicomModification::Clear(const DicomTag& tag)
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
507 {
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
508 removals_.erase(tag);
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
509 clearings_.insert(tag);
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
510 uids_.erase(tag);
2323
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2321
diff changeset
511 CancelReplacement(tag);
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 916
diff changeset
512 privateTagsToKeep_.erase(tag);
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
513
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
514 MarkNotOrthancAnonymization();
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
515 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
516
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
517 bool DicomModification::IsRemoved(const DicomTag& tag) const
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
518 {
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
519 if (removals_.find(tag) != removals_.end())
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
520 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
521 return true;
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
522 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
523 else
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
524 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
525 for (RemovedRanges::const_iterator it = removedRanges_.begin();
4690
13efc0967cea cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4688
diff changeset
526 it != removedRanges_.end(); ++it)
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
527 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
528 if (it->Contains(tag))
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
529 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
530 return true;
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
531 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
532 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
533
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
534 return false;
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
535 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
536 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
537
2310
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
538 bool DicomModification::IsCleared(const DicomTag& tag) const
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
539 {
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
540 return clearings_.find(tag) != clearings_.end();
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
541 }
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
542
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
543 void DicomModification::Replace(const DicomTag& tag,
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
544 const Json::Value& value,
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
545 bool safeForAnonymization)
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
546 {
2310
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
547 clearings_.erase(tag);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
548 removals_.erase(tag);
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
549 uids_.erase(tag);
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 916
diff changeset
550 privateTagsToKeep_.erase(tag);
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
551 ReplaceInternal(tag, value);
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
552
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
553 if (!safeForAnonymization)
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
554 {
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
555 MarkNotOrthancAnonymization();
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
556 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
557 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
558
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
559
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
560 bool DicomModification::IsReplaced(const DicomTag& tag) const
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
561 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
562 return replacements_.find(tag) != replacements_.end();
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
563 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
564
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
565 const Json::Value& DicomModification::GetReplacement(const DicomTag& tag) const
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
566 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
567 Replacements::const_iterator it = replacements_.find(tag);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
568
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
569 if (it == replacements_.end())
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
570 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
571 throw OrthancException(ErrorCode_InexistentItem);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
572 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573 else
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
574 {
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
575 assert(it->second != NULL);
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
576 return *it->second;
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
577 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
578 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
579
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
580
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
581 std::string DicomModification::GetReplacementAsString(const DicomTag& tag) const
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
582 {
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
583 const Json::Value& json = GetReplacement(tag);
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
584
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
585 if (json.type() != Json::stringValue)
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
586 {
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
587 throw OrthancException(ErrorCode_BadParameterType);
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
588 }
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
589 else
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
590 {
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
591 return json.asString();
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
592 }
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
593 }
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
594
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
595
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
596 void DicomModification::SetRemovePrivateTags(bool removed)
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
597 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
598 removePrivateTags_ = removed;
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
599
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
600 if (!removed)
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
601 {
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
602 MarkNotOrthancAnonymization();
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
603 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
604 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
605
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
606 bool DicomModification::ArePrivateTagsRemoved() const
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
607 {
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
608 return removePrivateTags_;
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
609 }
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
610
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
611 void DicomModification::SetLevel(ResourceType level)
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
612 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
613 uidMap_.clear();
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
614 level_ = level;
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
615
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
616 if (level != ResourceType_Patient)
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
617 {
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
618 MarkNotOrthancAnonymization();
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
619 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
620 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
621
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
622 ResourceType DicomModification::GetLevel() const
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
623 {
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
624 return level_;
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
625 }
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
626
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
627
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
628 static void SetupUidsFromOrthancInternal(std::set<DicomTag>& uids,
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
629 std::set<DicomTag>& removals,
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
630 const DicomTag& tag)
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
631 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
632 uids.insert(tag);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
633 removals.erase(tag); // Necessary if unserializing a job from 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
634 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
635
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
636
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
637 void DicomModification::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
638 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
639 /**
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
640 * Values below come from the hardcoded UID of Orthanc 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
641 * in DicomModification::RelationshipsVisitor::VisitString() and
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
642 * DicomModification::RelationshipsVisitor::RemoveRelationships()
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
643 * https://hg.orthanc-server.com/orthanc/file/Orthanc-1.9.3/OrthancFramework/Sources/DicomParsing/DicomModification.cpp#l117
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
644 **/
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
645 uids_.clear();
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
646
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
647 // (*) "PatientID" and "PatientName" are handled as UIDs since Orthanc 1.9.4
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
648 uids_.insert(DICOM_TAG_PATIENT_ID);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
649 uids_.insert(DICOM_TAG_PATIENT_NAME);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
650
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
651 SetupUidsFromOrthancInternal(uids_, removals_, DicomTag(0x0008, 0x0014)); // Instance Creator UID <= from SetupAnonymization2008()
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
652 SetupUidsFromOrthancInternal(uids_, removals_, DicomTag(0x0008, 0x1155)); // Referenced SOP Instance UID <= from VisitString() + RemoveRelationships()
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
653 SetupUidsFromOrthancInternal(uids_, removals_, DicomTag(0x0020, 0x0052)); // Frame of Reference UID <= from VisitString() + RemoveRelationships()
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
654 SetupUidsFromOrthancInternal(uids_, removals_, DicomTag(0x0020, 0x0200)); // Synchronization Frame of Reference UID <= from SetupAnonymization2008()
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
655 SetupUidsFromOrthancInternal(uids_, removals_, DicomTag(0x0040, 0xa124)); // UID <= from SetupAnonymization2008()
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
656 SetupUidsFromOrthancInternal(uids_, removals_, DicomTag(0x0088, 0x0140)); // Storage Media File-set UID <= from SetupAnonymization2008()
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
657 SetupUidsFromOrthancInternal(uids_, removals_, DicomTag(0x3006, 0x0024)); // Referenced Frame of Reference UID <= from VisitString() + RemoveRelationships()
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
658 SetupUidsFromOrthancInternal(uids_, removals_, DicomTag(0x3006, 0x00c2)); // Related Frame of Reference UID <= from VisitString() + RemoveRelationships()
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
659 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
660
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
661
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
662 void DicomModification::SetupAnonymization2008()
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
663 {
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
664 // This is Table E.1-1 from PS 3.15-2008 - DICOM Part 15: Security and System Management Profiles
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
665 // https://raw.githubusercontent.com/jodogne/dicom-specification/master/2008/08_15pu.pdf
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
666
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
667 SetupUidsFromOrthanc_1_9_3();
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
668
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
669 //uids_.insert(DicomTag(0x0008, 0x0014)); // Instance Creator UID => set in SetupUidsFromOrthanc_1_9_3()
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
670 //removals_.insert(DicomTag(0x0008, 0x0018)); // SOP Instance UID => set in Apply()
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
671 removals_.insert(DicomTag(0x0008, 0x0050)); // Accession Number
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
672 removals_.insert(DicomTag(0x0008, 0x0080)); // Institution Name
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
673 removals_.insert(DicomTag(0x0008, 0x0081)); // Institution Address
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
674 removals_.insert(DicomTag(0x0008, 0x0090)); // Referring Physician's Name
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
675 removals_.insert(DicomTag(0x0008, 0x0092)); // Referring Physician's Address
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
676 removals_.insert(DicomTag(0x0008, 0x0094)); // Referring Physician's Telephone Numbers
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
677 removals_.insert(DicomTag(0x0008, 0x1010)); // Station Name
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
678 removals_.insert(DicomTag(0x0008, 0x1030)); // Study Description
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
679 removals_.insert(DicomTag(0x0008, 0x103e)); // Series Description
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
680 removals_.insert(DicomTag(0x0008, 0x1040)); // Institutional Department Name
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
681 removals_.insert(DicomTag(0x0008, 0x1048)); // Physician(s) of Record
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
682 removals_.insert(DicomTag(0x0008, 0x1050)); // Performing Physicians' Name
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
683 removals_.insert(DicomTag(0x0008, 0x1060)); // Name of Physician(s) Reading Study
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
684 removals_.insert(DicomTag(0x0008, 0x1070)); // Operators' Name
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
685 removals_.insert(DicomTag(0x0008, 0x1080)); // Admitting Diagnoses Description
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
686 //uids_.insert(DicomTag(0x0008, 0x1155)); // Referenced SOP Instance UID => set in SetupUidsFromOrthanc_1_9_3()
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
687 removals_.insert(DicomTag(0x0008, 0x2111)); // Derivation Description
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
688 //removals_.insert(DicomTag(0x0010, 0x0010)); // Patient's Name => cf. below (*)
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
689 //removals_.insert(DicomTag(0x0010, 0x0020)); // Patient ID => cf. below (*)
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
690 removals_.insert(DicomTag(0x0010, 0x0030)); // Patient's Birth Date
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
691 removals_.insert(DicomTag(0x0010, 0x0032)); // Patient's Birth Time
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
692 removals_.insert(DicomTag(0x0010, 0x0040)); // Patient's Sex
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
693 removals_.insert(DicomTag(0x0010, 0x1000)); // Other Patient Ids
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
694 removals_.insert(DicomTag(0x0010, 0x1001)); // Other Patient Names
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
695 removals_.insert(DicomTag(0x0010, 0x1010)); // Patient's Age
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
696 removals_.insert(DicomTag(0x0010, 0x1020)); // Patient's Size
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
697 removals_.insert(DicomTag(0x0010, 0x1030)); // Patient's Weight
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
698 removals_.insert(DicomTag(0x0010, 0x1090)); // Medical Record Locator
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
699 removals_.insert(DicomTag(0x0010, 0x2160)); // Ethnic Group
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
700 removals_.insert(DicomTag(0x0010, 0x2180)); // Occupation
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
701 removals_.insert(DicomTag(0x0010, 0x21b0)); // Additional Patient's History
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
702 removals_.insert(DicomTag(0x0010, 0x4000)); // Patient Comments
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
703 removals_.insert(DicomTag(0x0018, 0x1000)); // Device Serial Number
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
704 removals_.insert(DicomTag(0x0018, 0x1030)); // Protocol Name
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
705 //removals_.insert(DicomTag(0x0020, 0x000d)); // Study Instance UID => set in Apply()
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
706 //removals_.insert(DicomTag(0x0020, 0x000e)); // Series Instance UID => set in Apply()
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
707 removals_.insert(DicomTag(0x0020, 0x0010)); // Study ID
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
708 //uids_.insert(DicomTag(0x0020, 0x0052)); // Frame of Reference UID => set in 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
709 //uids_.insert(DicomTag(0x0020, 0x0200)); // Synchronization Frame of Reference UID => set in SetupUidsFromOrthanc_1_9_3()
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
710 removals_.insert(DicomTag(0x0020, 0x4000)); // Image Comments
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
711 removals_.insert(DicomTag(0x0040, 0x0275)); // Request Attributes Sequence
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
712 //uids_.insert(DicomTag(0x0040, 0xa124)); // UID => set in SetupUidsFromOrthanc_1_9_3()
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
713 removals_.insert(DicomTag(0x0040, 0xa730)); // Content Sequence
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
714 //uids_.insert(DicomTag(0x0088, 0x0140)); // Storage Media File-set UID => set in 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
715 //uids_.insert(DicomTag(0x3006, 0x0024)); // Referenced Frame of Reference UID => set in 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
716 //uids_.insert(DicomTag(0x3006, 0x00c2)); // Related Frame of Reference UID => set in SetupUidsFromOrthanc_1_9_3()
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
717
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
718 // Some more removals (from the experience of DICOM files at the CHU of Liege)
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
719 removals_.insert(DicomTag(0x0010, 0x1040)); // Patient's Address
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
720 removals_.insert(DicomTag(0x0032, 0x1032)); // Requesting Physician
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
721 removals_.insert(DicomTag(0x0010, 0x2154)); // PatientTelephoneNumbers
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
722 removals_.insert(DicomTag(0x0010, 0x2000)); // Medical Alerts
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
723
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
724 // Set the DeidentificationMethod tag
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
725 ReplaceInternal(DICOM_TAG_DEIDENTIFICATION_METHOD, ORTHANC_DEIDENTIFICATION_METHOD_2008);
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
726 }
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
727
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
728
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
729 void DicomModification::SetupAnonymization2017c()
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
730 {
2313
d19e716b79fa switch to anonymization according to DICOM 2017c
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2311
diff changeset
731 /**
d19e716b79fa switch to anonymization according to DICOM 2017c
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2311
diff changeset
732 * This is Table E.1-1 from PS 3.15-2017c (DICOM Part 15: Security
d19e716b79fa switch to anonymization according to DICOM 2017c
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2311
diff changeset
733 * and System Management Profiles), "basic profile" column. It was
4675
7e4d1f2b3a8f GenerateAnonymizationProfile.py can read from URL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
734 * generated automatically by calling:
7e4d1f2b3a8f GenerateAnonymizationProfile.py can read from URL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
735 * "../../../OrthancServer/Resources/GenerateAnonymizationProfile.py
7e4d1f2b3a8f GenerateAnonymizationProfile.py can read from URL
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
736 * https://raw.githubusercontent.com/jodogne/dicom-specification/master/2017c/part15.xml"
2313
d19e716b79fa switch to anonymization according to DICOM 2017c
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2311
diff changeset
737 **/
d19e716b79fa switch to anonymization according to DICOM 2017c
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2311
diff changeset
738
4676
caf963ee3de9 DicomModification_Anonymization2017c.impl.h
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4675
diff changeset
739 #include "DicomModification_Anonymization2017c.impl.h"
2313
d19e716b79fa switch to anonymization according to DICOM 2017c
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2311
diff changeset
740
d19e716b79fa switch to anonymization according to DICOM 2017c
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2311
diff changeset
741 // Set the DeidentificationMethod tag
d19e716b79fa switch to anonymization according to DICOM 2017c
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2311
diff changeset
742 ReplaceInternal(DICOM_TAG_DEIDENTIFICATION_METHOD, ORTHANC_DEIDENTIFICATION_METHOD_2017c);
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
743 }
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
744
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
745
4677
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
746 void DicomModification::SetupAnonymization2021b()
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
747 {
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
748 /**
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
749 * This is Table E.1-1 from PS 3.15-2021b (DICOM Part 15: Security
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
750 * and System Management Profiles), "basic profile" column. It was
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
751 * generated automatically by calling:
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
752 * "../../../OrthancServer/Resources/GenerateAnonymizationProfile.py
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
753 * https://raw.githubusercontent.com/jodogne/dicom-specification/master/2021b/part15.xml"
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
754 *
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
755 * http://dicom.nema.org/medical/dicom/2021b/output/chtml/part15/chapter_E.html#table_E.1-1a
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
756 * http://dicom.nema.org/medical/dicom/2021b/output/chtml/part15/chapter_E.html#table_E.1-1
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
757 **/
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
758
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
759 #include "DicomModification_Anonymization2021b.impl.h"
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
760
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
761 // Set the DeidentificationMethod tag
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
762 ReplaceInternal(DICOM_TAG_DEIDENTIFICATION_METHOD, ORTHANC_DEIDENTIFICATION_METHOD_2021b);
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
763 }
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
764
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
765
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
766 void DicomModification::SetupAnonymization(DicomVersion version)
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
767 {
2721
062776ab4a21 fix issue #94
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
768 isAnonymization_ = true;
062776ab4a21 fix issue #94
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
769
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
770 removals_.clear();
2310
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
771 clearings_.clear();
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
772 removedRanges_.clear();
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
773 uids_.clear();
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
774 ClearReplacements();
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
775 removePrivateTags_ = true;
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
776 level_ = ResourceType_Patient;
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
777 uidMap_.clear();
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
778 privateTagsToKeep_.clear();
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
779 keepSequences_.clear();
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
780 removeSequences_.clear();
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
781
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
782 switch (version)
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
783 {
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
784 case DicomVersion_2008:
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
785 SetupAnonymization2008();
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
786 break;
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
787
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
788 case DicomVersion_2017c:
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
789 SetupAnonymization2017c();
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
790 break;
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
791
4677
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
792 case DicomVersion_2021b:
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
793 SetupAnonymization2021b();
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
794 break;
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
795
2309
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
796 default:
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
797 throw OrthancException(ErrorCode_ParameterOutOfRange);
4dc313b9a20a Argument "DicomVersion" in URIs "/{...}/{...}/anonymization"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2277
diff changeset
798 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
799
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
800 // Set the PatientIdentityRemoved tag
1698
d78b87f93bcf DicomModification use Json::Value
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1695
diff changeset
801 ReplaceInternal(DicomTag(0x0012, 0x0062), "YES");
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
802
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
803 // (*) Choose a random patient name and ID
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
804 uids_.insert(DICOM_TAG_PATIENT_ID);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
805 uids_.insert(DICOM_TAG_PATIENT_NAME);
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
806
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
807 // Sanity check
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
808 for (SetOfTags::const_iterator it = uids_.begin(); it != uids_.end(); ++it)
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
809 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
810 ValueRepresentation vr = FromDcmtkBridge::LookupValueRepresentation(*it);
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
811 if (*it == DICOM_TAG_PATIENT_ID)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
812 {
4696
dd6274412ff4 new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
813 if (vr != ValueRepresentation_LongString &&
dd6274412ff4 new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
814 vr != ValueRepresentation_NotSupported /* if no dictionary loaded */)
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
815 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
816 throw OrthancException(ErrorCode_InternalError);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
817 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
818 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
819 else if (*it == DICOM_TAG_PATIENT_NAME)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
820 {
4696
dd6274412ff4 new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
821 if (vr != ValueRepresentation_PersonName &&
dd6274412ff4 new configuration option "ExternalDictionaries" to load external DICOM dictionaries
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4693
diff changeset
822 vr != ValueRepresentation_NotSupported /* if no dictionary loaded */)
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
823 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
824 throw OrthancException(ErrorCode_InternalError);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
825 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
826 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
827 else if (vr != ValueRepresentation_UniqueIdentifier &&
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
828 vr != ValueRepresentation_NotSupported /* for older versions of DCMTK */)
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
829 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
830 throw OrthancException(ErrorCode_InternalError);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
831 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
832 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
833 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
834
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
835 void DicomModification::Apply(ParsedDicomFile& toModify)
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
836 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
837 // Check the request
788
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
838 assert(ResourceType_Patient + 1 == ResourceType_Study &&
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
839 ResourceType_Study + 1 == ResourceType_Series &&
7ebe4bf87196 refactoring
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 787
diff changeset
840 ResourceType_Series + 1 == ResourceType_Instance);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
841
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
842 if (IsRemoved(DICOM_TAG_PATIENT_ID) ||
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
843 IsRemoved(DICOM_TAG_STUDY_INSTANCE_UID) ||
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
844 IsRemoved(DICOM_TAG_SERIES_INSTANCE_UID) ||
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
845 IsRemoved(DICOM_TAG_SOP_INSTANCE_UID))
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
846 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
847 throw OrthancException(ErrorCode_BadRequest);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
848 }
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
849
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
850
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
851 // Sanity checks at the patient level
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
852 bool isReplacedPatientId = (IsReplaced(DICOM_TAG_PATIENT_ID) ||
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
853 uids_.find(DICOM_TAG_PATIENT_ID) != uids_.end());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
854
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
855 if (level_ == ResourceType_Patient && !isReplacedPatientId)
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
856 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
857 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
858 "When modifying a patient, her PatientID is required to be modified");
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
859 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
860
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
861 if (!allowManualIdentifiers_)
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
862 {
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
863 if (level_ == ResourceType_Patient && IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID))
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
864 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
865 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
866 "When modifying a patient, the StudyInstanceUID cannot be manually modified");
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
867 }
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
868
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
869 if (level_ == ResourceType_Patient && IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID))
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
870 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
871 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
872 "When modifying a patient, the SeriesInstanceUID cannot be manually modified");
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
873 }
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
874
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
875 if (level_ == ResourceType_Patient && IsReplaced(DICOM_TAG_SOP_INSTANCE_UID))
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
876 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
877 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
878 "When modifying a patient, the SopInstanceUID cannot be manually modified");
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
879 }
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
880 }
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
881
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
882
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
883 // Sanity checks at the study level
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
884 if (level_ == ResourceType_Study && isReplacedPatientId)
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
885 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
886 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
887 "When modifying a study, the parent PatientID cannot be manually modified");
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
888 }
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
889
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
890 if (!allowManualIdentifiers_)
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
891 {
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
892 if (level_ == ResourceType_Study && IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID))
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
893 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
894 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
895 "When modifying a study, the SeriesInstanceUID cannot be manually modified");
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
896 }
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
897
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
898 if (level_ == ResourceType_Study && IsReplaced(DICOM_TAG_SOP_INSTANCE_UID))
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
899 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
900 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
901 "When modifying a study, the SopInstanceUID cannot be manually modified");
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
902 }
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
903 }
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
904
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
905
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
906 // Sanity checks at the series level
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
907 if (level_ == ResourceType_Series && isReplacedPatientId)
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
908 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
909 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
910 "When modifying a series, the parent PatientID cannot be manually modified");
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
911 }
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
912
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
913 if (level_ == ResourceType_Series && IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID))
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
914 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
915 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
916 "When modifying a series, the parent StudyInstanceUID cannot be manually modified");
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
917 }
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
918
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
919 if (!allowManualIdentifiers_)
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
920 {
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
921 if (level_ == ResourceType_Series && IsReplaced(DICOM_TAG_SOP_INSTANCE_UID))
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
922 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
923 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
924 "When modifying a series, the SopInstanceUID cannot be manually modified");
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
925 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
926 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
927
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
928
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
929 // Sanity checks at the instance level
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
930 if (level_ == ResourceType_Instance && isReplacedPatientId)
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
931 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
932 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
933 "When modifying an instance, the parent PatientID cannot be manually modified");
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
934 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
935
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
936 if (level_ == ResourceType_Instance && IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID))
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
937 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
938 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
939 "When modifying an instance, the parent StudyInstanceUID cannot be manually modified");
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
940 }
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
941
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
942 if (level_ == ResourceType_Instance && IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID))
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
943 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
944 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
945 "When modifying an instance, the parent SeriesInstanceUID cannot be manually modified");
1160
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
946 }
80671157d051 generalization of create-dicom
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 991
diff changeset
947
2535
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
948 // (0) Create a summary of the source file, if a custom generator
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
949 // is provided
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
950 if (identifierGenerator_ != NULL)
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
951 {
4139
a4f28efdfccf "maxTagLength" must be explicitly given to ParsedDicomFile::ExtractDicomSummary()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4119
diff changeset
952 toModify.ExtractDicomSummary(currentSource_, ORTHANC_MAXIMUM_TAG_LENGTH);
2535
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
953 }
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
954
3513
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
955 // (1) Make sure the relationships are updated with the ids that we force too
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
956 // i.e: an RT-STRUCT is referencing its own StudyInstanceUID
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
957 if (isAnonymization_ && updateReferencedRelationships_)
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
958 {
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
959 if (IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID))
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
960 {
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
961 std::string original;
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
962 std::string replacement = GetReplacementAsString(DICOM_TAG_STUDY_INSTANCE_UID);
4273
0034f855c023 tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
963 const_cast<const ParsedDicomFile&>(toModify).GetTagValue(original, DICOM_TAG_STUDY_INSTANCE_UID);
3513
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
964 RegisterMappedDicomIdentifier(original, replacement, ResourceType_Study);
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
965 }
2535
d3476d90dcb7 DicomModification::SetDicomIdentifierGenerator()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2521
diff changeset
966
3513
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
967 if (IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID))
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
968 {
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
969 std::string original;
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
970 std::string replacement = GetReplacementAsString(DICOM_TAG_SERIES_INSTANCE_UID);
4273
0034f855c023 tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
971 const_cast<const ParsedDicomFile&>(toModify).GetTagValue(original, DICOM_TAG_SERIES_INSTANCE_UID);
3513
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
972 RegisterMappedDicomIdentifier(original, replacement, ResourceType_Series);
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
973 }
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
974
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
975 if (IsReplaced(DICOM_TAG_SOP_INSTANCE_UID))
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
976 {
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
977 std::string original;
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
978 std::string replacement = GetReplacementAsString(DICOM_TAG_SOP_INSTANCE_UID);
4273
0034f855c023 tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
979 const_cast<const ParsedDicomFile&>(toModify).GetTagValue(original, DICOM_TAG_SOP_INSTANCE_UID);
3513
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
980 RegisterMappedDicomIdentifier(original, replacement, ResourceType_Instance);
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
981 }
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
982 }
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
983
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
984
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
985 // (2) Remove the private tags, if need be
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
986 if (removePrivateTags_)
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
987 {
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 916
diff changeset
988 toModify.RemovePrivateTags(privateTagsToKeep_);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
989 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
990
3513
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
991 // (3) Clear the tags specified by the user
2310
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
992 for (SetOfTags::const_iterator it = clearings_.begin();
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
993 it != clearings_.end(); ++it)
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
994 {
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
995 toModify.Clear(*it, true /* only clear if the tag exists in the original file */);
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
996 }
b7fba68747f6 DicomModification::Clear()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2309
diff changeset
997
3513
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
998 // (4) Remove the tags specified by the user
991
2f76b92addd4 keep private tags during anonymization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 916
diff changeset
999 for (SetOfTags::const_iterator it = removals_.begin();
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1000 it != removals_.end(); ++it)
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1001 {
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1002 toModify.Remove(*it);
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1003 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1004
3513
7db879b014ff Fix lost relationships between CT and RT-STRUCT during anonymization
amazy
parents: 3344
diff changeset
1005 // (5) Replace the tags
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1006 for (Replacements::const_iterator it = replacements_.begin();
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1007 it != replacements_.end(); ++it)
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1008 {
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1009 assert(it->second != NULL);
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
1010 toModify.Replace(it->first, *it->second, true /* decode data URI scheme */,
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
1011 DicomReplaceMode_InsertIfAbsent, privateCreator_);
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1012 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1013
4691
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1014 // (6) Update the DICOM identifiers
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
1015 if (level_ <= ResourceType_Study &&
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
1016 !IsReplaced(DICOM_TAG_STUDY_INSTANCE_UID))
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1017 {
2194
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1018 if (keepStudyInstanceUid_)
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1019 {
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1020 LOG(WARNING) << "Modifying a study while keeping its original StudyInstanceUID: This should be avoided!";
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1021 }
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1022 else
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1023 {
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1024 MapDicomTags(toModify, ResourceType_Study);
2194
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1025 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1026 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1027
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
1028 if (level_ <= ResourceType_Series &&
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
1029 !IsReplaced(DICOM_TAG_SERIES_INSTANCE_UID))
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1030 {
2194
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1031 if (keepSeriesInstanceUid_)
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1032 {
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1033 LOG(WARNING) << "Modifying a series while keeping its original SeriesInstanceUID: This should be avoided!";
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1034 }
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1035 else
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1036 {
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1037 MapDicomTags(toModify, ResourceType_Series);
2194
3b40ca7470cc "Keep" option for modifications to keep original DICOM identifiers (advanced feature)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1982
diff changeset
1038 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1039 }
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1040
1279
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
1041 if (level_ <= ResourceType_Instance && // Always true
7f3a65e84d4b More flexible /modify and /anonymize for single instance
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1160
diff changeset
1042 !IsReplaced(DICOM_TAG_SOP_INSTANCE_UID))
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1043 {
3860
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
1044 if (keepSopInstanceUid_)
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
1045 {
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
1046 LOG(WARNING) << "Modifying an instance while keeping its original SOPInstanceUID: This should be avoided!";
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
1047 }
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
1048 else
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
1049 {
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
1050 MapDicomTags(toModify, ResourceType_Instance);
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
1051 }
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1052 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1053
4691
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1054 // (7) Update the "referenced" relationships in the case of an anonymization
2721
062776ab4a21 fix issue #94
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
1055 if (isAnonymization_)
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1056 {
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1057 RelationshipsVisitor visitor(*this);
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1058
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1059 if (updateReferencedRelationships_)
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1060 {
4273
0034f855c023 tuning log categories from command-line, and binary compat with orthanc framework 1.7.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4268
diff changeset
1061 const_cast<const ParsedDicomFile&>(toModify).Apply(visitor);
2506
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1062 }
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1063 else
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1064 {
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1065 visitor.RemoveRelationships(toModify);
51b91ead6c38 Preservation of UID relationships while anonymizing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2447
diff changeset
1066 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1067 }
4691
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1068
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1069 // (8) New in Orthanc 1.9.4: Apply modifications to subsequences
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1070 for (ListOfPaths::const_iterator it = removeSequences_.begin();
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1071 it != removeSequences_.end(); ++it)
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1072 {
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1073 assert(it->GetPrefixLength() > 0);
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1074 toModify.RemovePath(*it);
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1075 }
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1076
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1077 for (SequenceReplacements::const_iterator it = sequenceReplacements_.begin();
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1078 it != sequenceReplacements_.end(); ++it)
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1079 {
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1080 assert(*it != NULL);
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1081 assert((*it)->GetPath().GetPrefixLength() > 0);
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1082 toModify.ReplacePath((*it)->GetPath(), (*it)->GetValue(), true /* decode data URI scheme */,
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1083 DicomReplaceMode_InsertIfAbsent, privateCreator_);
a08ef46c95a1 applying modifications to subsequences after all the other modifications
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4690
diff changeset
1084 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1085 }
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1086
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1087 void DicomModification::SetAllowManualIdentifiers(bool check)
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1088 {
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1089 allowManualIdentifiers_ = check;
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1090 }
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1091
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1092 bool DicomModification::AreAllowManualIdentifiers() const
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1093 {
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1094 return allowManualIdentifiers_;
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1095 }
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1096
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1097
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1098 static bool IsDatabaseKey(const DicomTag& tag)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1099 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1100 return (tag == DICOM_TAG_PATIENT_ID ||
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1101 tag == DICOM_TAG_STUDY_INSTANCE_UID ||
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1102 tag == DICOM_TAG_SERIES_INSTANCE_UID ||
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1103 tag == DICOM_TAG_SOP_INSTANCE_UID);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1104 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1105
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1106
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1107 static void ParseListOfTags(DicomModification& target,
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1108 const Json::Value& query,
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1109 DicomModification::TagOperation operation,
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1110 bool force)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1111 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1112 if (!query.isArray())
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1113 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1114 throw OrthancException(ErrorCode_BadRequest);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1115 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1116
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1117 for (Json::Value::ArrayIndex i = 0; i < query.size(); i++)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1118 {
2844
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2721
diff changeset
1119 if (query[i].type() != Json::stringValue)
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2721
diff changeset
1120 {
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2721
diff changeset
1121 throw OrthancException(ErrorCode_BadRequest);
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2721
diff changeset
1122 }
99863d6245b2 New URI: "/studies/.../split" to split a study
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2721
diff changeset
1123
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1124 std::string name = query[i].asString();
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1125
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1126 const DicomPath path(DicomPath::Parse(name));
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1127
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1128 if (path.GetPrefixLength() == 0 &&
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1129 !force &&
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1130 IsDatabaseKey(path.GetFinalTag()))
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1131 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1132 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1133 "Marking tag \"" + name + "\" as to be " +
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1134 (operation == DicomModification::TagOperation_Keep ? "kept" : "removed") +
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1135 " requires the \"Force\" option to be set to true");
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1136 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1137
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1138 switch (operation)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1139 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1140 case DicomModification::TagOperation_Keep:
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1141 target.Keep(path);
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1142 LOG(TRACE) << "Keep: " << name << " = " << path.Format();
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1143 break;
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1144
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1145 case DicomModification::TagOperation_Remove:
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1146 target.Remove(path);
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1147 LOG(TRACE) << "Remove: " << name << " = " << path.Format();
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1148 break;
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1149
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1150 default:
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1151 throw OrthancException(ErrorCode_InternalError);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1152 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1153 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1154 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1155
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1156
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1157 static void ParseReplacements(DicomModification& target,
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1158 const Json::Value& replacements,
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1159 bool force)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1160 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1161 if (!replacements.isObject())
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1162 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1163 throw OrthancException(ErrorCode_BadRequest);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1164 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1165
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1166 Json::Value::Members members = replacements.getMemberNames();
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1167 for (size_t i = 0; i < members.size(); i++)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1168 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1169 const std::string& name = members[i];
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1170 const Json::Value& value = replacements[name];
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1171
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1172 const DicomPath path(DicomPath::Parse(name));
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1173
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1174 if (path.GetPrefixLength() == 0 &&
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1175 !force &&
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1176 IsDatabaseKey(path.GetFinalTag()))
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1177 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1178 throw OrthancException(ErrorCode_BadRequest,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1179 "Marking tag \"" + name + "\" as to be replaced " +
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1180 "requires the \"Force\" option to be set to true");
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1181 }
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1182
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1183 target.Replace(path, value, false /* not safe for anonymization */);
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1184
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1185 LOG(TRACE) << "Replace: " << name << " = " << path.Format()
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1186 << " by: " << value.toStyledString();
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1187 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1188 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1189
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1190
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1191 static bool GetBooleanValue(const std::string& member,
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1192 const Json::Value& json,
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1193 bool defaultValue)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1194 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1195 if (!json.isMember(member))
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1196 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1197 return defaultValue;
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1198 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1199 else if (json[member].type() == Json::booleanValue)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1200 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1201 return json[member].asBool();
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1202 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1203 else
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1204 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1205 throw OrthancException(ErrorCode_BadFileFormat,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1206 "Member \"" + member + "\" should be a Boolean value");
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1207 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1208 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1209
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1210
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1211 void DicomModification::ParseModifyRequest(const Json::Value& request)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1212 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1213 if (!request.isObject())
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1214 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1215 throw OrthancException(ErrorCode_BadFileFormat);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1216 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1217
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1218 bool force = GetBooleanValue("Force", request, false);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1219
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1220 if (GetBooleanValue("RemovePrivateTags", request, false))
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1221 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1222 SetRemovePrivateTags(true);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1223 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1224
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1225 if (request.isMember("Remove"))
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1226 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1227 ParseListOfTags(*this, request["Remove"], TagOperation_Remove, force);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1228 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1229
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1230 if (request.isMember("Replace"))
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1231 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1232 ParseReplacements(*this, request["Replace"], force);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1233 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1234
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1235 // The "Keep" operation only makes sense for the tags
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1236 // StudyInstanceUID, SeriesInstanceUID and SOPInstanceUID. Avoid
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1237 // this feature as much as possible, as this breaks the DICOM
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1238 // model of the real world, except if you know exactly what
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1239 // you're doing!
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1240 if (request.isMember("Keep"))
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1241 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1242 ParseListOfTags(*this, request["Keep"], TagOperation_Keep, force);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1243 }
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
1244
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
1245 // New in Orthanc 1.6.0
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
1246 if (request.isMember("PrivateCreator"))
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
1247 {
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
1248 privateCreator_ = SerializationToolbox::ReadString(request, "PrivateCreator");
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
1249 }
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1250 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1251
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1252
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
1253 void DicomModification::ParseAnonymizationRequest(bool& patientNameOverridden,
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1254 const Json::Value& request)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1255 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1256 if (!request.isObject())
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1257 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1258 throw OrthancException(ErrorCode_BadFileFormat);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1259 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1260
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1261 bool force = GetBooleanValue("Force", request, false);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1262
4677
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
1263 // DicomVersion version = DicomVersion_2008; // For Orthanc <= 1.2.0
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
1264 // DicomVersion version = DicomVersion_2017c; // For Orthanc between 1.3.0 and 1.9.3
521e39b3f2c0 Fix issue #146 (Update Anonyization to 2019c) - was actually updated to 2021b
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4676
diff changeset
1265 DicomVersion version = DicomVersion_2021b; // For Orthanc >= 1.9.4
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1266 if (request.isMember("DicomVersion"))
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1267 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1268 if (request["DicomVersion"].type() != Json::stringValue)
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1269 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1270 throw OrthancException(ErrorCode_BadFileFormat);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1271 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1272 else
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1273 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1274 version = StringToDicomVersion(request["DicomVersion"].asString());
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1275 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1276 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1277
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1278 SetupAnonymization(version);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1279
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1280 if (GetBooleanValue("KeepPrivateTags", request, false))
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1281 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1282 SetRemovePrivateTags(false);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1283 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1284
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1285 if (request.isMember("Remove"))
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1286 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1287 ParseListOfTags(*this, request["Remove"], TagOperation_Remove, force);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1288 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1289
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1290 if (request.isMember("Replace"))
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1291 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1292 ParseReplacements(*this, request["Replace"], force);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1293 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1294
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1295 if (request.isMember("Keep"))
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1296 {
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1297 ParseListOfTags(*this, request["Keep"], TagOperation_Keep, force);
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1298 }
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1299
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
1300 patientNameOverridden = (uids_.find(DICOM_TAG_PATIENT_NAME) == uids_.end());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4691
diff changeset
1301
3709
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1302 // New in Orthanc 1.6.0
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1303 if (request.isMember("PrivateCreator"))
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1304 {
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1305 privateCreator_ = SerializationToolbox::ReadString(request, "PrivateCreator");
1f4910999fe7 Fix issue #168 (Plugins can't read private tags from the configuration file)
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3691
diff changeset
1306 }
2519
2e6b7862ccf2 ParseAnonymizationRequest/ParseModifyRequest now in DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2506
diff changeset
1307 }
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2535
diff changeset
1308
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1309 void DicomModification::SetDicomIdentifierGenerator(DicomModification::IDicomIdentifierGenerator &generator)
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1310 {
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1311 identifierGenerator_ = &generator;
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1312 }
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1313
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1314
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1315
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1316
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1317 static const char* REMOVE_PRIVATE_TAGS = "RemovePrivateTags";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1318 static const char* LEVEL = "Level";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1319 static const char* ALLOW_MANUAL_IDENTIFIERS = "AllowManualIdentifiers";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1320 static const char* KEEP_STUDY_INSTANCE_UID = "KeepStudyInstanceUID";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1321 static const char* KEEP_SERIES_INSTANCE_UID = "KeepSeriesInstanceUID";
3860
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
1322 static const char* KEEP_SOP_INSTANCE_UID = "KeepSOPInstanceUID";
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1323 static const char* UPDATE_REFERENCED_RELATIONSHIPS = "UpdateReferencedRelationships";
2721
062776ab4a21 fix issue #94
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
1324 static const char* IS_ANONYMIZATION = "IsAnonymization";
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1325 static const char* REMOVALS = "Removals";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1326 static const char* CLEARINGS = "Clearings";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1327 static const char* PRIVATE_TAGS_TO_KEEP = "PrivateTagsToKeep";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1328 static const char* REPLACEMENTS = "Replacements";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1329 static const char* MAP_PATIENTS = "MapPatients";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1330 static const char* MAP_STUDIES = "MapStudies";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1331 static const char* MAP_SERIES = "MapSeries";
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1332 static const char* MAP_INSTANCES = "MapInstances";
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1333 static const char* PRIVATE_CREATOR = "PrivateCreator"; // New in Orthanc 1.6.0
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1334 static const char* UIDS = "Uids"; // New in Orthanc 1.9.4
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1335 static const char* REMOVED_RANGES = "RemovedRanges"; // New in Orthanc 1.9.4
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1336 static const char* KEEP_SEQUENCES = "KeepSequences"; // New in Orthanc 1.9.4
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1337 static const char* REMOVE_SEQUENCES = "RemoveSequences"; // New in Orthanc 1.9.4
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1338 static const char* SEQUENCE_REPLACEMENTS = "SequenceReplacements"; // New in Orthanc 1.9.4
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2535
diff changeset
1339
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2535
diff changeset
1340 void DicomModification::Serialize(Json::Value& value) const
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2535
diff changeset
1341 {
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1342 if (identifierGenerator_ != NULL)
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1343 {
2954
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1344 throw OrthancException(ErrorCode_InternalError,
d924f9bb61cc taking advantage of details in OrthancException
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2844
diff changeset
1345 "Cannot serialize a DicomModification with a custom identifier generator");
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1346 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1347
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1348 value = Json::objectValue;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1349 value[REMOVE_PRIVATE_TAGS] = removePrivateTags_;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1350 value[LEVEL] = EnumerationToString(level_);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1351 value[ALLOW_MANUAL_IDENTIFIERS] = allowManualIdentifiers_;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1352 value[KEEP_STUDY_INSTANCE_UID] = keepStudyInstanceUid_;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1353 value[KEEP_SERIES_INSTANCE_UID] = keepSeriesInstanceUid_;
3860
9ccbbd55bc23 allow Keeping the SOPInstanceUID in /instances/../modify
Alain Mazy <alain@mazy.be>
parents: 3712
diff changeset
1354 value[KEEP_SOP_INSTANCE_UID] = keepSopInstanceUid_;
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1355 value[UPDATE_REFERENCED_RELATIONSHIPS] = updateReferencedRelationships_;
2721
062776ab4a21 fix issue #94
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
1356 value[IS_ANONYMIZATION] = isAnonymization_;
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
1357 value[PRIVATE_CREATOR] = privateCreator_;
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1358
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1359 SerializationToolbox::WriteSetOfTags(value, removals_, REMOVALS);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1360 SerializationToolbox::WriteSetOfTags(value, clearings_, CLEARINGS);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1361 SerializationToolbox::WriteSetOfTags(value, privateTagsToKeep_, PRIVATE_TAGS_TO_KEEP);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1362
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1363 Json::Value& tmp = value[REPLACEMENTS];
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1364
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1365 tmp = Json::objectValue;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1366
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1367 for (Replacements::const_iterator it = replacements_.begin();
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1368 it != replacements_.end(); ++it)
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1369 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1370 assert(it->second != NULL);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1371 tmp[it->first.Format()] = *it->second;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1372 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1373
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1374 Json::Value& mapPatients = value[MAP_PATIENTS];
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1375 Json::Value& mapStudies = value[MAP_STUDIES];
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1376 Json::Value& mapSeries = value[MAP_SERIES];
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1377 Json::Value& mapInstances = value[MAP_INSTANCES];
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1378
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1379 mapPatients = Json::objectValue;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1380 mapStudies = Json::objectValue;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1381 mapSeries = Json::objectValue;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1382 mapInstances = Json::objectValue;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1383
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1384 for (UidMap::const_iterator it = uidMap_.begin(); it != uidMap_.end(); ++it)
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1385 {
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4139
diff changeset
1386 Json::Value* tmp2 = NULL;
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1387
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1388 switch (it->first.first)
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1389 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1390 case ResourceType_Patient:
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4139
diff changeset
1391 tmp2 = &mapPatients;
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1392 break;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1393
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1394 case ResourceType_Study:
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4139
diff changeset
1395 tmp2 = &mapStudies;
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1396 break;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1397
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1398 case ResourceType_Series:
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4139
diff changeset
1399 tmp2 = &mapSeries;
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1400 break;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1401
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1402 case ResourceType_Instance:
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4139
diff changeset
1403 tmp2 = &mapInstances;
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1404 break;
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1405
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1406 default:
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1407 throw OrthancException(ErrorCode_InternalError);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1408 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1409
4200
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4139
diff changeset
1410 assert(tmp2 != NULL);
7112a8af0b63 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4139
diff changeset
1411 (*tmp2) [it->first.second] = it->second;
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1412 }
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
1413
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1414 // New in Orthanc 1.9.4
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1415 SerializationToolbox::WriteSetOfTags(value, uids_, UIDS);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1416
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1417 // New in Orthanc 1.9.4
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1418 Json::Value ranges = Json::arrayValue;
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1419
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1420 for (RemovedRanges::const_iterator it = removedRanges_.begin(); it != removedRanges_.end(); ++it)
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1421 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1422 Json::Value item = Json::arrayValue;
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1423 item.append(it->GetGroupFrom());
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1424 item.append(it->GetGroupTo());
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1425 item.append(it->GetElementFrom());
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1426 item.append(it->GetElementTo());
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1427 ranges.append(item);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1428 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1429
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1430 value[REMOVED_RANGES] = ranges;
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1431
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1432 // New in Orthanc 1.9.4
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1433 Json::Value lst = Json::arrayValue;
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1434 for (ListOfPaths::const_iterator it = keepSequences_.begin(); it != keepSequences_.end(); ++it)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1435 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1436 lst.append(it->Format());
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1437 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1438
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1439 value[KEEP_SEQUENCES] = lst;
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1440
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1441 // New in Orthanc 1.9.4
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1442 lst = Json::arrayValue;
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1443 for (ListOfPaths::const_iterator it = removeSequences_.begin(); it != removeSequences_.end(); ++it)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1444 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1445 assert(it->GetPrefixLength() > 0);
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1446 lst.append(it->Format());
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1447 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1448
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1449 value[REMOVE_SEQUENCES] = lst;
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1450
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1451 // New in Orthanc 1.9.4
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1452 lst = Json::objectValue;
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1453 for (SequenceReplacements::const_iterator it = sequenceReplacements_.begin(); it != sequenceReplacements_.end(); ++it)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1454 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1455 assert(*it != NULL);
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1456 assert((*it)->GetPath().GetPrefixLength() > 0);
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1457 lst[(*it)->GetPath().Format()] = (*it)->GetValue();
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1458 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1459
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1460 value[SEQUENCE_REPLACEMENTS] = lst;
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1461 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1462
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1463 void DicomModification::UnserializeUidMap(ResourceType level,
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1464 const Json::Value& serialized,
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1465 const char* field)
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1466 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1467 if (!serialized.isMember(field) ||
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1468 serialized[field].type() != Json::objectValue)
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1469 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1470 throw OrthancException(ErrorCode_BadFileFormat);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1471 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1472
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1473 Json::Value::Members names = serialized[field].getMemberNames();
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1474
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1475 for (Json::Value::Members::const_iterator it = names.begin(); it != names.end(); ++it)
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1476 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1477 const Json::Value& value = serialized[field][*it];
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1478
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1479 if (value.type() != Json::stringValue)
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1480 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1481 throw OrthancException(ErrorCode_BadFileFormat);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1482 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1483 else
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1484 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1485 uidMap_[std::make_pair(level, *it)] = value.asString();
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1486 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1487 }
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
1488 }
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
1489
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
1490
2666
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
1491 DicomModification::DicomModification(const Json::Value& serialized) :
2540ac79ab6c SequenceOfOperationsJob serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2662
diff changeset
1492 identifierGenerator_(NULL)
2655
c196d76cb8fa serialization
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2616
diff changeset
1493 {
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1494 removePrivateTags_ = SerializationToolbox::ReadBoolean(serialized, REMOVE_PRIVATE_TAGS);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1495 level_ = StringToResourceType(SerializationToolbox::ReadString(serialized, LEVEL).c_str());
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1496 allowManualIdentifiers_ = SerializationToolbox::ReadBoolean(serialized, ALLOW_MANUAL_IDENTIFIERS);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1497 keepStudyInstanceUid_ = SerializationToolbox::ReadBoolean(serialized, KEEP_STUDY_INSTANCE_UID);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1498 keepSeriesInstanceUid_ = SerializationToolbox::ReadBoolean(serialized, KEEP_SERIES_INSTANCE_UID);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1499 updateReferencedRelationships_ = SerializationToolbox::ReadBoolean
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1500 (serialized, UPDATE_REFERENCED_RELATIONSHIPS);
2721
062776ab4a21 fix issue #94
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2666
diff changeset
1501 isAnonymization_ = SerializationToolbox::ReadBoolean(serialized, IS_ANONYMIZATION);
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1502
4688
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1503 if (serialized.isMember(KEEP_SOP_INSTANCE_UID))
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1504 {
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1505 keepSopInstanceUid_ = SerializationToolbox::ReadBoolean(serialized, KEEP_SOP_INSTANCE_UID);
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1506 }
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1507 else
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1508 {
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1509 /**
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1510 * Compatibility with jobs serialized using Orthanc between
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1511 * 1.5.0 and 1.6.1. This compatibility was broken between 1.7.0
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1512 * and 1.9.3: Indeed, an exception was thrown in "ReadBoolean()"
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1513 * if "KEEP_SOP_INSTANCE_UID" was absent, because of changeset:
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1514 * https://hg.orthanc-server.com/orthanc/rev/3860
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1515 **/
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1516 keepSopInstanceUid_ = false;
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1517 }
177ad026d219 backward compatibility with old DicomModification serialization from Orthanc <= 1.6.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4687
diff changeset
1518
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
1519 if (serialized.isMember(PRIVATE_CREATOR))
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
1520 {
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
1521 privateCreator_ = SerializationToolbox::ReadString(serialized, PRIVATE_CREATOR);
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
1522 }
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
1523
2662
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1524 SerializationToolbox::ReadSetOfTags(removals_, serialized, REMOVALS);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1525 SerializationToolbox::ReadSetOfTags(clearings_, serialized, CLEARINGS);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1526 SerializationToolbox::ReadSetOfTags(privateTagsToKeep_, serialized, PRIVATE_TAGS_TO_KEEP);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1527
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1528 if (!serialized.isMember(REPLACEMENTS) ||
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1529 serialized[REPLACEMENTS].type() != Json::objectValue)
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1530 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1531 throw OrthancException(ErrorCode_BadFileFormat);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1532 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1533
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1534 Json::Value::Members names = serialized[REPLACEMENTS].getMemberNames();
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1535
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1536 for (Json::Value::Members::const_iterator it = names.begin(); it != names.end(); ++it)
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1537 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1538 DicomTag tag(0, 0);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1539 if (!DicomTag::ParseHexadecimal(tag, it->c_str()))
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1540 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1541 throw OrthancException(ErrorCode_BadFileFormat);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1542 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1543 else
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1544 {
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1545 const Json::Value& value = serialized[REPLACEMENTS][*it];
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1546 replacements_.insert(std::make_pair(tag, new Json::Value(value)));
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1547 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1548 }
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1549
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1550 UnserializeUidMap(ResourceType_Patient, serialized, MAP_PATIENTS);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1551 UnserializeUidMap(ResourceType_Study, serialized, MAP_STUDIES);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1552 UnserializeUidMap(ResourceType_Series, serialized, MAP_SERIES);
47d812308d63 serialization of DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2655
diff changeset
1553 UnserializeUidMap(ResourceType_Instance, serialized, MAP_INSTANCES);
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
1554
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1555 // New in Orthanc 1.9.4
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1556 if (serialized.isMember(UIDS)) // Backward compatibility with Orthanc <= 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
1557 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1558 SerializationToolbox::ReadSetOfTags(uids_, serialized, UIDS);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1559 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1560 else
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1561 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1562 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
1563 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1564
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1565 // New in Orthanc 1.9.4
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1566 removedRanges_.clear();
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1567 if (serialized.isMember(REMOVED_RANGES)) // Backward compatibility with Orthanc <= 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
1568 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1569 const Json::Value& ranges = serialized[REMOVED_RANGES];
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1570
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1571 if (ranges.type() != Json::arrayValue)
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1572 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1573 throw OrthancException(ErrorCode_BadFileFormat);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1574 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1575 else
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1576 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1577 for (Json::Value::ArrayIndex i = 0; i < ranges.size(); i++)
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1578 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1579 if (ranges[i].type() != Json::arrayValue ||
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1580 ranges[i].size() != 4 ||
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1581 !ranges[i][0].isUInt() ||
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1582 !ranges[i][1].isUInt() ||
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1583 !ranges[i][2].isUInt() ||
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1584 !ranges[i][3].isUInt())
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1585 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1586 throw OrthancException(ErrorCode_BadFileFormat);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1587 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1588 else
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1589 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1590 Json::LargestUInt groupFrom = ranges[i][0].asUInt();
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1591 Json::LargestUInt groupTo = ranges[i][1].asUInt();
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1592 Json::LargestUInt elementFrom = ranges[i][2].asUInt();
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1593 Json::LargestUInt elementTo = ranges[i][3].asUInt();
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1594
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1595 if (groupFrom > 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
1596 elementFrom > 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
1597 groupTo > 0xffffu ||
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1598 elementTo > 0xffffu)
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1599 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1600 throw OrthancException(ErrorCode_BadFileFormat);
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1601 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1602 else
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1603 {
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1604 removedRanges_.push_back(DicomTagRange(groupFrom, groupTo, elementFrom, 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
1605 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1606 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1607 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1608 }
2e850edf03d6 Full support for the anonymization of subsequences containing tags whose VR is UI
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4677
diff changeset
1609 }
4687
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1610
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1611 // New in Orthanc 1.9.4
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1612 if (serialized.isMember(KEEP_SEQUENCES))
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1613 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1614 const Json::Value& keep = serialized[KEEP_SEQUENCES];
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1615
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1616 if (keep.type() != Json::arrayValue)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1617 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1618 throw OrthancException(ErrorCode_BadFileFormat);
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1619 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1620 else
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1621 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1622 for (Json::Value::ArrayIndex i = 0; i < keep.size(); i++)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1623 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1624 if (keep[i].type() != Json::stringValue)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1625 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1626 throw OrthancException(ErrorCode_BadFileFormat);
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1627 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1628 else
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1629 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1630 keepSequences_.push_back(DicomPath::Parse(keep[i].asString()));
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1631 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1632 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1633 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1634 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1635
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1636 // New in Orthanc 1.9.4
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1637 if (serialized.isMember(REMOVE_SEQUENCES))
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1638 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1639 const Json::Value& remove = serialized[REMOVE_SEQUENCES];
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1640
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1641 if (remove.type() != Json::arrayValue)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1642 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1643 throw OrthancException(ErrorCode_BadFileFormat);
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1644 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1645 else
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1646 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1647 for (Json::Value::ArrayIndex i = 0; i < remove.size(); i++)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1648 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1649 if (remove[i].type() != Json::stringValue)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1650 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1651 throw OrthancException(ErrorCode_BadFileFormat);
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1652 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1653 else
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1654 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1655 removeSequences_.push_back(DicomPath::Parse(remove[i].asString()));
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1656 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1657 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1658 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1659 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1660
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1661 // New in Orthanc 1.9.4
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1662 if (serialized.isMember(SEQUENCE_REPLACEMENTS))
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1663 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1664 const Json::Value& replace = serialized[SEQUENCE_REPLACEMENTS];
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1665
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1666 if (replace.type() != Json::objectValue)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1667 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1668 throw OrthancException(ErrorCode_BadFileFormat);
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1669 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1670 else
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1671 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1672 Json::Value::Members members = replace.getMemberNames();
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1673 for (size_t i = 0; i < members.size(); i++)
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1674 {
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1675 sequenceReplacements_.push_back(
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1676 new SequenceReplacement(DicomPath::Parse(members[i]), replace[members[i]]));
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1677 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1678 }
fcd2dc7c8f31 "Replace", "Keep" and "Remove" in "/modify" and "/anonymize" accept paths to subsequences
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4685
diff changeset
1679 }
2616
2f3007bf0708 event queues in Lua, serialization of sequence of operations
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2535
diff changeset
1680 }
4297
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1681
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1682
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1683 void DicomModification::SetPrivateCreator(const std::string &privateCreator)
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1684 {
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1685 privateCreator_ = privateCreator;
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1686 }
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1687
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1688 const std::string &DicomModification::GetPrivateCreator() const
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1689 {
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1690 return privateCreator_;
785a2713323e abi continued
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4273
diff changeset
1691 }
4685
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1692
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1693
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1694 void DicomModification::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
1695 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1696 if (path.GetPrefixLength() == 0)
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1697 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1698 Keep(path.GetFinalTag());
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1699 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1700
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1701 keepSequences_.push_back(path);
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1702 MarkNotOrthancAnonymization();
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1703 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1704
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1705
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1706 void DicomModification::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
1707 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1708 if (path.GetPrefixLength() == 0)
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1709 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1710 Remove(path.GetFinalTag());
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1711 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1712 else
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1713 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1714 removeSequences_.push_back(path);
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1715 MarkNotOrthancAnonymization();
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1716 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1717 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1718
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1719
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1720 void DicomModification::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
1721 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
1722 bool safeForAnonymization)
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1723 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1724 if (path.GetPrefixLength() == 0)
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1725 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1726 Replace(path.GetFinalTag(), value, safeForAnonymization);
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1727 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1728 else
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1729 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1730 sequenceReplacements_.push_back(new SequenceReplacement(path, value));
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1731
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1732 if (!safeForAnonymization)
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1733 {
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1734 MarkNotOrthancAnonymization();
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1735 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1736 }
693f049729ba New versions of Keep(), Remove() and Replace() in DicomModification that use DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4684
diff changeset
1737 }
786
b6d6b65142e8 DicomModification
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1738 }