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