annotate OrthancServer/Sources/ServerJobs/ResourceModificationJob.cpp @ 4870:43e613a7756b

upgrade to year 2022
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 11 Jan 2022 11:15:42 +0100
parents 7053502fbf97
children 6eff25f70121
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
4870
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
5 * Copyright (C) 2017-2022 Osimis S.A., Belgium
43e613a7756b upgrade to year 2022
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4831
diff changeset
6 * Copyright (C) 2021-2022 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * This program is free software: you can redistribute it and/or
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * modify it under the terms of the GNU General Public License as
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * published by the Free Software Foundation, either version 3 of the
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 * License, or (at your option) any later version.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * In addition, as a special exception, the copyright holders of this
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * program give permission to link the code of its release with the
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * OpenSSL project's "OpenSSL" library (or with modified versions of it
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * that use the same license as the "OpenSSL" library), and distribute
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * the linked executables. You must obey the GNU General Public License
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * in all respects for all of the code used other than "OpenSSL". If you
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * modify file(s) with this exception, you may extend this exception to
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * your version of the file(s), but you are not obligated to do so. If
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * you do not wish to do so, delete this exception statement from your
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * version. If you delete this exception statement from all source files
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 * in the program, then also delete it here.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * This program is distributed in the hope that it will be useful, but
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * WITHOUT ANY WARRANTY; without even the implied warranty of
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 * General Public License for more details.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 *
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * You should have received a copy of the GNU General Public License
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 * along with this program. If not, see <http://www.gnu.org/licenses/>.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 #include "../PrecompiledHeadersServer.h"
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 #include "ResourceModificationJob.h"
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
4045
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
38 #include "../../../OrthancFramework/Sources/Logging.h"
05b8fd21089c fix path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
39 #include "../../../OrthancFramework/Sources/SerializationToolbox.h"
3095
beeeb6096f27 removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
40 #include "../ServerContext.h"
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
42 #include <dcmtk/dcmdata/dcfilefo.h>
3948
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
43 #include <dcmtk/dcmdata/dcdeftag.h>
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
44 #include <cassert>
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
45
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 namespace Orthanc
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
48 static void FormatResource(Json::Value& target,
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
49 ResourceType level,
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
50 const std::string& id)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
51 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
52 target["Type"] = EnumerationToString(level);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
53 target["ID"] = id;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
54 target["Path"] = GetBasePath(level, id);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
55 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
56
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
57 class ResourceModificationJob::SingleOutput : public IOutput
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
59 private:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
60 ResourceType level_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
61 bool isFirst_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
62 std::string id_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
63 std::string patientId_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
64
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
65 public:
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
66 explicit SingleOutput(ResourceType level) :
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
67 level_(level),
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
68 isFirst_(true)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
69 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
70 if (level_ != ResourceType_Patient &&
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
71 level_ != ResourceType_Study &&
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
72 level_ != ResourceType_Series)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
73 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
74 throw OrthancException(ErrorCode_ParameterOutOfRange);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
75 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
76 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
77
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
78 virtual void Update(DicomInstanceHasher& hasher) ORTHANC_OVERRIDE
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
79 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
80 if (isFirst_)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
81 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
82 switch (level_)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
83 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
84 case ResourceType_Series:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
85 id_ = hasher.HashSeries();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
86 break;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
87
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
88 case ResourceType_Study:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
89 id_ = hasher.HashStudy();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
90 break;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
91
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
92 case ResourceType_Patient:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
93 id_ = hasher.HashPatient();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
94 break;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
95
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
96 default:
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
97 throw OrthancException(ErrorCode_InternalError);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
98 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
99
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
100 patientId_ = hasher.HashPatient();
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
101 isFirst_ = false;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
102 }
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
103 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
105 virtual void Format(Json::Value& target) const ORTHANC_OVERRIDE
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
106 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
107 assert(target.type() == Json::objectValue);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
109 if (!isFirst_)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 {
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
111 FormatResource(target, level_, id_);
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
112 target["PatientID"] = patientId_;
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
113 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
116 virtual bool IsSingleResource() const ORTHANC_OVERRIDE
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117 {
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
118 return true;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
119 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
120
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
121 ResourceType GetLevel() const
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
122 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
123 return level_;
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 }
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
125 };
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
126
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
127
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
128 class ResourceModificationJob::MultipleOutputs : public IOutput
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
129 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
130 private:
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
131 static void FormatResources(Json::Value& target,
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
132 ResourceType level,
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
133 const std::set<std::string>& resources)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
134 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
135 assert(target.type() == Json::arrayValue);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
136
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
137 for (std::set<std::string>::const_iterator
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
138 it = resources.begin(); it != resources.end(); ++it)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
139 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
140 Json::Value item = Json::objectValue;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
141 FormatResource(item, level, *it);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
142 target.append(item);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
143 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
144 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
145
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
146 std::set<std::string> instances_;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
147 std::set<std::string> series_;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
148 std::set<std::string> studies_;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
149 std::set<std::string> patients_;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
150
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
151 public:
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
152 virtual void Update(DicomInstanceHasher& hasher) ORTHANC_OVERRIDE
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
153 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
154 instances_.insert(hasher.HashInstance());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
155 series_.insert(hasher.HashSeries());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
156 studies_.insert(hasher.HashStudy());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
157 patients_.insert(hasher.HashPatient());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
158 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
159
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
160 virtual void Format(Json::Value& target) const ORTHANC_OVERRIDE
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
161 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
162 assert(target.type() == Json::objectValue);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
163 Json::Value resources = Json::arrayValue;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
164 FormatResources(resources, ResourceType_Instance, instances_);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
165 FormatResources(resources, ResourceType_Series, series_);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
166 FormatResources(resources, ResourceType_Study, studies_);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
167 FormatResources(resources, ResourceType_Patient, patients_);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
168 target["Resources"] = resources;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
169 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
170
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
171 virtual bool IsSingleResource() const ORTHANC_OVERRIDE
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
172 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
173 return false;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
174 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
175 };
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
176
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 bool ResourceModificationJob::HandleInstance(const std::string& instance)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 {
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
181 if (modification_.get() == NULL ||
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
182 output_.get() == NULL)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
184 throw OrthancException(ErrorCode_BadSequenceOfCalls,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
185 "No modification was provided for this job");
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 LOG(INFO) << "Modifying instance in a job: " << instance;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
191
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
192 /**
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
193 * Retrieve the original instance from the DICOM cache.
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
194 **/
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
195
3712
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
196 std::unique_ptr<DicomInstanceHasher> originalHasher;
2a170a8f1faf replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3640
diff changeset
197 std::unique_ptr<ParsedDicomFile> modified;
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 try
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200 {
3942
5b882ad2ffd0 "/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
201 ServerContext::DicomCacheLocker locker(GetContext(), instance);
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
202 ParsedDicomFile& original = locker.GetDicom();
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
203
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
204 originalHasher.reset(new DicomInstanceHasher(original.GetHasher()));
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
205 modified.reset(original.Clone(true));
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206 }
3430
4c45e018bd3d improved logging
Alain Mazy <alain@mazy.be>
parents: 3095
diff changeset
207 catch (OrthancException& e)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 {
3430
4c45e018bd3d improved logging
Alain Mazy <alain@mazy.be>
parents: 3095
diff changeset
209 LOG(WARNING) << "An error occurred while executing a Modification job on instance " << instance << ": " << e.GetDetails();
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210 return false;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 * Compute the resulting DICOM instance.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 modification_->Apply(*modified);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219
3948
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
220 const std::string modifiedUid = IDicomTranscoder::GetSopInstanceUid(modified->GetDcmtkObject());
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
221
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
222 if (transcode_)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
223 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
224 std::set<DicomTransferSyntax> syntaxes;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
225 syntaxes.insert(transferSyntax_);
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
226
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
227 IDicomTranscoder::DicomImage source;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
228 source.AcquireParsed(*modified); // "modified" is invalid below this point
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
229
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
230 IDicomTranscoder::DicomImage transcoded;
3951
5fe8c6d3212e removed useless information "hasSopInstanceUidChanged"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3948
diff changeset
231 if (GetContext().Transcode(transcoded, source, syntaxes, true))
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
232 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
233 modified.reset(transcoded.ReleaseAsParsedDicomFile());
3948
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
234
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
235 // Fix the SOP instance UID in order the preserve the
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
236 // references between instance UIDs in the DICOM hierarchy
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
237 // (the UID might have changed in the case of lossy transcoding)
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
238 if (modified.get() == NULL ||
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
239 modified->GetDcmtkObject().getDataset() == NULL ||
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
240 !modified->GetDcmtkObject().getDataset()->putAndInsertString(
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
241 DCM_SOPInstanceUID, modifiedUid.c_str(), OFTrue /* replace */).good())
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
242 {
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
243 throw OrthancException(ErrorCode_InternalError);
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
244 }
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
245 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
246 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
247 {
3945
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
248 LOG(WARNING) << "Cannot transcode instance, keeping original transfer syntax: " << instance;
0b3256c3ee14 simplified IDicomTranscoder
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3943
diff changeset
249 modified.reset(source.ReleaseAsParsedDicomFile());
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
250 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
251 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
252
3948
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
253 assert(modifiedUid == IDicomTranscoder::GetSopInstanceUid(modified->GetDcmtkObject()));
3d2fc1b5cc8c ResourceModificationJob: Fix the SOP instance UID to preserve references
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3945
diff changeset
254
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
255 std::unique_ptr<DicomInstanceToStore> toStore(DicomInstanceToStore::CreateFromParsedDicomFile(*modified));
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
256 toStore->SetOrigin(origin_);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 * Prepare the metadata information to associate with the
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 * resulting DICOM instance (AnonymizedFrom/ModifiedFrom).
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 DicomInstanceHasher modifiedHasher = modified->GetHasher();
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 MetadataType metadataType = (isAnonymization_ ?
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 MetadataType_AnonymizedFrom :
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 MetadataType_ModifiedFrom);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
270 if (originalHasher->HashSeries() != modifiedHasher.HashSeries())
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 {
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
272 toStore->AddMetadata(ResourceType_Series, metadataType, originalHasher->HashSeries());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
275 if (originalHasher->HashStudy() != modifiedHasher.HashStudy())
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276 {
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
277 toStore->AddMetadata(ResourceType_Study, metadataType, originalHasher->HashStudy());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
280 if (originalHasher->HashPatient() != modifiedHasher.HashPatient())
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 {
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
282 toStore->AddMetadata(ResourceType_Patient, metadataType, originalHasher->HashPatient());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284
2825
8aa6aef11b70 New configuration option "OverwriteInstances" to choose how duplicate SOPInstanceUID are handled
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2664
diff changeset
285 assert(instance == originalHasher->HashInstance());
4508
8f9090b137f1 Optimization in C-STORE SCP by avoiding an unnecessary DICOM parsing
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4437
diff changeset
286 toStore->AddMetadata(ResourceType_Instance, metadataType, instance);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289 /**
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 * Store the resulting DICOM instance into the Orthanc store.
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 **/
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 std::string modifiedInstance;
4796
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4693
diff changeset
294 ServerContext::StoreResult result = GetContext().Store(modifiedInstance, *toStore, StoreInstanceMode_Default);
94616af363ec added ReceivedCStoreInstanceFilter lua callback + OrthancPluginRegisterIncomingCStoreInstanceFilter in sdk
Alain Mazy <am@osimis.io>
parents: 4693
diff changeset
295 if (result.GetStatus() != StoreStatus_Success)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296 {
2955
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
297 throw OrthancException(ErrorCode_CannotStoreInstance,
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2868
diff changeset
298 "Error while storing a modified instance " + instance);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300
3938
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
301 /**
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
302 * The assertion below will fail if automated transcoding to a
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
303 * lossy transfer syntax is enabled in the Orthanc core, and if
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
304 * the source instance is not in this transfer syntax.
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
305 **/
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3814
diff changeset
306 // assert(modifiedInstance == modifiedHasher.HashInstance());
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
308 output_->Update(modifiedHasher);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 return true;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312
2842
ff0ed5ea9e4e trailing step in SetOfInstancesJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2825
diff changeset
313
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
314 ResourceModificationJob::ResourceModificationJob(ServerContext& context) :
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
315 CleaningInstancesJob(context, true /* by default, keep source */),
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
316 isAnonymization_(false),
4206
171af1567473 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4205
diff changeset
317 transcode_(false),
171af1567473 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4205
diff changeset
318 transferSyntax_(DicomTransferSyntax_LittleEndianExplicit) // dummy initialization
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
319 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
320 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
321
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
322
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
323 void ResourceModificationJob::SetSingleResourceModification(DicomModification* modification,
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
324 ResourceType outputLevel,
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
325 bool isAnonymization)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
326 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
327 if (modification == NULL)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
328 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
329 throw OrthancException(ErrorCode_NullPointer);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
330 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
331 else if (IsStarted())
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
332 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
333 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
334 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
335 else
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
336 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
337 modification_.reset(modification);
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
338 output_.reset(new SingleOutput(outputLevel));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
339 isAnonymization_ = isAnonymization;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
340 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
341 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
342
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
343
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
344 void ResourceModificationJob::SetMultipleResourcesModification(DicomModification* modification,
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
345 bool isAnonymization)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
346 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
347 if (modification == NULL)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
348 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
349 throw OrthancException(ErrorCode_NullPointer);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
350 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
351 else if (IsStarted())
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
352 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
353 throw OrthancException(ErrorCode_BadSequenceOfCalls);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
354 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
355 else
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
356 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
357 modification_.reset(modification);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
358 output_.reset(new MultipleOutputs);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
359 isAnonymization_ = isAnonymization;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
360 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
361 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
362
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
363
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
364 void ResourceModificationJob::SetOrigin(const DicomInstanceOrigin& origin)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
365 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
366 if (IsStarted())
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
367 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
368 throw OrthancException(ErrorCode_BadSequenceOfCalls);
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
369 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
370 else
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
371 {
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
372 origin_ = origin;
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
373 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
374 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
375
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
376
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
377 void ResourceModificationJob::SetOrigin(const RestApiCall& call)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
378 {
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
379 SetOrigin(DicomInstanceOrigin::FromRest(call));
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
380 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
381
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
382
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
383 const DicomModification& ResourceModificationJob::GetModification() const
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
384 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
385 if (modification_.get() == NULL)
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
386 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
387 throw OrthancException(ErrorCode_BadSequenceOfCalls);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
388 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
389 else
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
390 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
391 return *modification_;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
392 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
393 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
394
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
395
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
396 DicomTransferSyntax ResourceModificationJob::GetTransferSyntax() const
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
397 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
398 if (transcode_)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
399 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
400 return transferSyntax_;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
401 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
402 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
403 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
404 throw OrthancException(ErrorCode_BadSequenceOfCalls);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
405 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
406 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
407
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
408
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
409 void ResourceModificationJob::SetTranscode(DicomTransferSyntax syntax)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
410 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
411 if (IsStarted())
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
412 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
413 throw OrthancException(ErrorCode_BadSequenceOfCalls);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
414 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
415 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
416 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
417 transcode_ = true;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
418 transferSyntax_ = syntax;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
419 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
420 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
421
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
422
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
423 void ResourceModificationJob::SetTranscode(const std::string& transferSyntaxUid)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
424 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
425 DicomTransferSyntax s;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
426 if (LookupTransferSyntax(s, transferSyntaxUid))
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
427 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
428 SetTranscode(s);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
429 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
430 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
431 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
432 throw OrthancException(ErrorCode_BadFileFormat,
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
433 "Unknown transfer syntax UID: " + transferSyntaxUid);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
434 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
435 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
436
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
437
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
438 void ResourceModificationJob::ClearTranscode()
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
439 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
440 if (IsStarted())
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
441 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
442 throw OrthancException(ErrorCode_BadSequenceOfCalls);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
443 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
444 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
445 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
446 transcode_ = false;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
447 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
448 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
449
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
450
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
451 bool ResourceModificationJob::IsSingleResourceModification() const
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
452 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
453 if (modification_.get() == NULL)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
454 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
455 assert(output_.get() == NULL);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
456 throw OrthancException(ErrorCode_BadSequenceOfCalls);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
457 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
458 else
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
459 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
460 assert(output_.get() != NULL);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
461 return output_->IsSingleResource();
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
462 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
463 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
464
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
465
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
466 ResourceType ResourceModificationJob::GetOutputLevel() const
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
467 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
468 if (IsSingleResourceModification())
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
469 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
470 assert(modification_.get() != NULL &&
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
471 output_.get() != NULL);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
472 return dynamic_cast<const SingleOutput&>(*output_).GetLevel();
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
473 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
474 else
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
475 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
476 // Not applicable if multiple resources
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
477 throw OrthancException(ErrorCode_BadSequenceOfCalls);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
478 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
479 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
480
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
481
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
482 void ResourceModificationJob::GetPublicContent(Json::Value& value)
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
483 {
3942
5b882ad2ffd0 "/{patients|studies|series}/.../modify": New option "KeepSource"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3938
diff changeset
484 CleaningInstancesJob::GetPublicContent(value);
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
485
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
486 value["IsAnonymization"] = isAnonymization_;
2868
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
487
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
488 if (output_.get() != NULL)
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
489 {
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
490 output_->Format(value);
abce036683cd sharing code within OrthancRestAnonymizeModify
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2842
diff changeset
491 }
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
492
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
493 if (transcode_)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
494 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
495 value["Transcode"] = GetTransferSyntaxUid(transferSyntax_);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
496 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
497 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
498
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
499
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
500 static const char* MODIFICATION = "Modification";
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
501 static const char* ORIGIN = "Origin";
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
502 static const char* IS_ANONYMIZATION = "IsAnonymization";
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
503 static const char* TRANSCODE = "Transcode";
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
504 static const char* OUTPUT_LEVEL = "OutputLevel";
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
505 static const char* IS_SINGLE_RESOURCE = "IsSingleResource";
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
506
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
507
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
508 ResourceModificationJob::ResourceModificationJob(ServerContext& context,
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
509 const Json::Value& serialized) :
4223
3d6f14a05db1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4206
diff changeset
510 CleaningInstancesJob(context, serialized, true /* by default, keep source */),
3d6f14a05db1 cppcheck
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4206
diff changeset
511 transferSyntax_(DicomTransferSyntax_LittleEndianExplicit) // dummy initialization
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
512 {
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
513 assert(serialized.type() == Json::objectValue);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
514
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
515 origin_ = DicomInstanceOrigin(serialized[ORIGIN]);
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
516
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
517 if (serialized.isMember(TRANSCODE))
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
518 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
519 SetTranscode(SerializationToolbox::ReadString(serialized, TRANSCODE));
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
520 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
521 else
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
522 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
523 transcode_ = false;
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
524 }
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
525
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
526 bool isSingleResource;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
527 if (serialized.isMember(IS_SINGLE_RESOURCE))
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
528 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
529 isSingleResource = SerializationToolbox::ReadBoolean(serialized, IS_SINGLE_RESOURCE);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
530 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
531 else
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
532 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
533 isSingleResource = true; // Backward compatibility with Orthanc <= 1.9.3
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
534 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
535
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
536 bool isAnonymization = SerializationToolbox::ReadBoolean(serialized, IS_ANONYMIZATION);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
537 std::unique_ptr<DicomModification> modification(new DicomModification(serialized[MODIFICATION]));
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
538
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
539 if (isSingleResource)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
540 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
541 ResourceType outputLevel;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
542
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
543 if (serialized.isMember(OUTPUT_LEVEL))
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
544 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
545 // New in Orthanc 1.9.4. This fixes an *incorrect* behavior in
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
546 // Orthanc <= 1.9.3, in which "outputLevel" would be set to
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
547 // "modification->GetLevel()"
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
548 outputLevel = StringToResourceType(SerializationToolbox::ReadString(serialized, OUTPUT_LEVEL).c_str());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
549 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
550 else
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
551 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
552 // Use the buggy convention from Orthanc <= 1.9.3 (which is
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
553 // the only thing we have at hand)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
554 outputLevel = modification->GetLevel();
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
555
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
556 if (outputLevel == ResourceType_Instance)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
557 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
558 // This should never happen, but as "SingleOutput" doesn't
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
559 // support instance-level anonymization, don't take any risk
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
560 // and choose an arbitrary output level
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
561 outputLevel = ResourceType_Patient;
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
562 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
563 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
564
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
565 SetSingleResourceModification(modification.release(), outputLevel, isAnonymization);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
566 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
567 else
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
568 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
569 // New in Orthanc 1.9.4
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
570 SetMultipleResourcesModification(modification.release(), isAnonymization);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
571 }
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
572 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
573
2663
228e2783ce83 some jobs might not be serializable
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2648
diff changeset
574 bool ResourceModificationJob::Serialize(Json::Value& value)
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
575 {
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
576 if (modification_.get() == NULL)
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
577 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
578 throw OrthancException(ErrorCode_BadSequenceOfCalls);
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
579 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
580 else if (!CleaningInstancesJob::Serialize(value))
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
581 {
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
582 return false;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
583 }
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
584 else
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
585 {
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
586 assert(value.type() == Json::objectValue);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
587
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
588 value[IS_ANONYMIZATION] = isAnonymization_;
3943
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
589
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
590 if (transcode_)
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
591 {
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
592 value[TRANSCODE] = GetTransferSyntaxUid(transferSyntax_);
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
593 }
b26d25d3c1c7 "/{patients|studies|series}/.../modify": New option "Transcode"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3942
diff changeset
594
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
595 origin_.Serialize(value[ORIGIN]);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
596
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
597 Json::Value tmp;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
598 modification_->Serialize(tmp);
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
599 value[MODIFICATION] = tmp;
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
600
4693
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
601 // New in Orthanc 1.9.4
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
602 value[IS_SINGLE_RESOURCE] = IsSingleResourceModification();
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
603 if (IsSingleResourceModification())
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
604 {
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
605 value[OUTPUT_LEVEL] = EnumerationToString(GetOutputLevel());
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
606 }
45bce660ce3a added routes for bulk anonymization/modification
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4508
diff changeset
607
2664
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
608 return true;
a21b244efb37 serialization of DicomModalityStoreJob, OrthancPeerStoreJob and ResourceModificationJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2663
diff changeset
609 }
2642
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
610 }
ccc470091ea6 reorganization
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
611 }