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