Mercurial > hg > orthanc
annotate OrthancServer/Sources/ServerJobs/DicomMoveScuJob.cpp @ 5150:6ff13c95f62f
ThreadedSetOfInstancesJob: reduce cpu consumption of job main thread
author | Alain Mazy <am@osimis.io> |
---|---|
date | Mon, 30 Jan 2023 11:31:12 +0100 |
parents | afa427f65444 |
children | 0ea402b4d901 |
rev | line source |
---|---|
2867 | 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 |
2867 | 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 "DicomMoveScuJob.h" | |
24 | |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
25 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" |
4045 | 26 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" |
3095
beeeb6096f27
removing dependencies upon ServerContext
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3060
diff
changeset
|
27 #include "../ServerContext.h" |
2867 | 28 |
3303
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
29 static const char* const LOCAL_AET = "LocalAet"; |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
30 static const char* const QUERY = "Query"; |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
31 static const char* const QUERY_FORMAT = "QueryFormat"; // New in 1.9.5 |
3303
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
32 static const char* const REMOTE = "Remote"; |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
33 static const char* const TARGET_AET = "TargetAet"; |
3870
09798f2b985f
added a Timeout argument to every DICOM command + 'TargetAet' not mandatory anymore in /retrieve
Alain Mazy <alain@mazy.be>
parents:
3843
diff
changeset
|
34 static const char* const TIMEOUT = "Timeout"; |
3303
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
35 |
2867 | 36 namespace Orthanc |
37 { | |
38 class DicomMoveScuJob::Command : public SetOfCommandsJob::ICommand | |
39 { | |
40 private: | |
3712
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
41 DicomMoveScuJob& that_; |
2a170a8f1faf
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
42 std::unique_ptr<DicomMap> findAnswer_; |
2867 | 43 |
44 public: | |
45 Command(DicomMoveScuJob& that, | |
46 const DicomMap& findAnswer) : | |
47 that_(that), | |
48 findAnswer_(findAnswer.Clone()) | |
49 { | |
50 } | |
51 | |
3658
2d90dd30858c
providing job ID to the IJob::Step() methods
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3640
diff
changeset
|
52 virtual bool Execute(const std::string& jobId) ORTHANC_OVERRIDE |
2867 | 53 { |
54 that_.Retrieve(*findAnswer_); | |
55 return true; | |
56 } | |
57 | |
3763
5ff5d5a0fd28
adding missing ORTHANC_OVERRIDE
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3713
diff
changeset
|
58 virtual void Serialize(Json::Value& target) const ORTHANC_OVERRIDE |
2867 | 59 { |
60 findAnswer_->Serialize(target); | |
61 } | |
62 }; | |
63 | |
64 | |
65 class DicomMoveScuJob::Unserializer : | |
66 public SetOfCommandsJob::ICommandUnserializer | |
67 { | |
68 private: | |
69 DicomMoveScuJob& that_; | |
70 | |
71 public: | |
4205 | 72 explicit Unserializer(DicomMoveScuJob& that) : |
2867 | 73 that_(that) |
74 { | |
75 } | |
76 | |
4205 | 77 virtual ICommand* Unserialize(const Json::Value& source) const ORTHANC_OVERRIDE |
2867 | 78 { |
79 DicomMap findAnswer; | |
80 findAnswer.Unserialize(source); | |
81 return new Command(that_, findAnswer); | |
82 } | |
83 }; | |
84 | |
85 | |
86 void DicomMoveScuJob::Retrieve(const DicomMap& findAnswer) | |
87 { | |
88 if (connection_.get() == NULL) | |
89 { | |
3877
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
90 connection_.reset(new DicomControlUserConnection(parameters_)); |
2867 | 91 } |
92 | |
93 connection_->Move(targetAet_, findAnswer); | |
94 } | |
3303
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
95 |
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
96 |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
97 static void AddToQuery(DicomFindAnswers& query, |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
98 const DicomMap& item) |
3303
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
99 { |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
100 query.Add(item); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
101 |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
102 /** |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
103 * Compatibility with Orthanc <= 1.9.4: Remove the |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
104 * "SpecificCharacterSet" (0008,0005) tag that is automatically |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
105 * added if creating a ParsedDicomFile object from a DicomMap. |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
106 **/ |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
107 query.GetAnswer(query.GetSize() - 1).Remove(DICOM_TAG_SPECIFIC_CHARACTER_SET); |
3303
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
108 } |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
109 |
5025
afa427f65444
Added an Asynchronous mode to /modalities/../move
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
110 // this method is used to implement the retrieve part of a Q&R |
afa427f65444
Added an Asynchronous mode to /modalities/../move
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
111 // it keeps only the main dicom tags from the C-Find answer |
2867 | 112 void DicomMoveScuJob::AddFindAnswer(const DicomMap& answer) |
113 { | |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
114 DicomMap item; |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
115 item.CopyTagIfExists(answer, DICOM_TAG_QUERY_RETRIEVE_LEVEL); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
116 item.CopyTagIfExists(answer, DICOM_TAG_PATIENT_ID); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
117 item.CopyTagIfExists(answer, DICOM_TAG_STUDY_INSTANCE_UID); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
118 item.CopyTagIfExists(answer, DICOM_TAG_SERIES_INSTANCE_UID); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
119 item.CopyTagIfExists(answer, DICOM_TAG_SOP_INSTANCE_UID); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
120 item.CopyTagIfExists(answer, DICOM_TAG_ACCESSION_NUMBER); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
121 AddToQuery(query_, item); |
3303
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
122 |
2867 | 123 AddCommand(new Command(*this, answer)); |
124 } | |
125 | |
5025
afa427f65444
Added an Asynchronous mode to /modalities/../move
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
126 // this method is used to implement a C-Move |
afa427f65444
Added an Asynchronous mode to /modalities/../move
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
127 // it keeps all tags from the C-Move query |
afa427f65444
Added an Asynchronous mode to /modalities/../move
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
128 void DicomMoveScuJob::AddQuery(const DicomMap& query) |
afa427f65444
Added an Asynchronous mode to /modalities/../move
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
129 { |
afa427f65444
Added an Asynchronous mode to /modalities/../move
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
130 AddToQuery(query_, query); |
afa427f65444
Added an Asynchronous mode to /modalities/../move
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
131 AddCommand(new Command(*this, query)); |
afa427f65444
Added an Asynchronous mode to /modalities/../move
Alain Mazy <am@osimis.io>
parents:
4892
diff
changeset
|
132 } |
2867 | 133 |
134 void DicomMoveScuJob::AddFindAnswer(QueryRetrieveHandler& query, | |
135 size_t i) | |
136 { | |
137 DicomMap answer; | |
138 query.GetAnswer(answer, i); | |
139 AddFindAnswer(answer); | |
140 } | |
141 | |
142 | |
143 void DicomMoveScuJob::SetLocalAet(const std::string& aet) | |
144 { | |
145 if (IsStarted()) | |
146 { | |
147 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
148 } | |
149 else | |
150 { | |
3877
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
151 parameters_.SetLocalApplicationEntityTitle(aet); |
2867 | 152 } |
153 } | |
154 | |
155 | |
156 void DicomMoveScuJob::SetTargetAet(const std::string& aet) | |
157 { | |
158 if (IsStarted()) | |
159 { | |
160 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
161 } | |
162 else | |
163 { | |
164 targetAet_ = aet; | |
165 } | |
166 } | |
167 | |
168 | |
169 void DicomMoveScuJob::SetRemoteModality(const RemoteModalityParameters& remote) | |
170 { | |
171 if (IsStarted()) | |
172 { | |
173 throw OrthancException(ErrorCode_BadSequenceOfCalls); | |
174 } | |
175 else | |
176 { | |
3877
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
177 parameters_.SetRemoteModality(remote); |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
178 } |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
179 } |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
180 |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
181 |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
182 void DicomMoveScuJob::SetTimeout(uint32_t seconds) |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
183 { |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
184 if (IsStarted()) |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
185 { |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
186 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
187 } |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
188 else |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
189 { |
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
190 parameters_.SetTimeout(seconds); |
2867 | 191 } |
192 } | |
193 | |
194 | |
195 void DicomMoveScuJob::Stop(JobStopReason reason) | |
196 { | |
197 connection_.reset(); | |
198 } | |
199 | |
200 | |
4729
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
201 void DicomMoveScuJob::SetQueryFormat(DicomToJsonFormat format) |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
202 { |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
203 if (IsStarted()) |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
204 { |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
205 throw OrthancException(ErrorCode_BadSequenceOfCalls); |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
206 } |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
207 else |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
208 { |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
209 queryFormat_ = format; |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
210 } |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
211 } |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
212 |
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
213 |
2867 | 214 void DicomMoveScuJob::GetPublicContent(Json::Value& value) |
215 { | |
216 SetOfCommandsJob::GetPublicContent(value); | |
3877
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
217 |
4729
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
218 value[LOCAL_AET] = parameters_.GetLocalApplicationEntityTitle(); |
3877
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
219 value["RemoteAet"] = parameters_.GetRemoteModality().GetApplicationEntityTitle(); |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
220 |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
221 value[QUERY] = Json::objectValue; |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
222 query_.ToJson(value[QUERY], queryFormat_); |
2867 | 223 } |
224 | |
225 | |
226 DicomMoveScuJob::DicomMoveScuJob(ServerContext& context, | |
227 const Json::Value& serialized) : | |
228 SetOfCommandsJob(new Unserializer(*this), serialized), | |
3303
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
229 context_(context), |
4206 | 230 parameters_(DicomAssociationParameters::UnserializeJob(serialized)), |
231 targetAet_(SerializationToolbox::ReadString(serialized, TARGET_AET)), | |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
232 query_(true), |
4729
4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4437
diff
changeset
|
233 queryFormat_(DicomToJsonFormat_Short) |
2867 | 234 { |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
235 if (serialized.isMember(QUERY)) |
3303
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
236 { |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
237 const Json::Value& query = serialized[QUERY]; |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
238 if (query.type() == Json::arrayValue) |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
239 { |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
240 for (Json::Value::ArrayIndex i = 0; i < query.size(); i++) |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
241 { |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
242 DicomMap item; |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
243 FromDcmtkBridge::FromJson(item, query[i]); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
244 AddToQuery(query_, item); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
245 } |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
246 } |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
247 } |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
248 |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
249 if (serialized.isMember(QUERY_FORMAT)) |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
250 { |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
251 queryFormat_ = StringToDicomToJsonFormat(SerializationToolbox::ReadString(serialized, QUERY_FORMAT)); |
3303
a215182a0c2f
"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3095
diff
changeset
|
252 } |
2867 | 253 } |
254 | |
255 | |
256 bool DicomMoveScuJob::Serialize(Json::Value& target) | |
257 { | |
258 if (!SetOfCommandsJob::Serialize(target)) | |
259 { | |
260 return false; | |
261 } | |
262 else | |
263 { | |
3877
4b4f387c6bb8
making DicomMoveScuJob more consistent with DicomModalityStoreJob
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3875
diff
changeset
|
264 parameters_.SerializeJob(target); |
2867 | 265 target[TARGET_AET] = targetAet_; |
4730
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
266 |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
267 // "Short" is for compatibility with Orthanc <= 1.9.4 |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
268 target[QUERY] = Json::objectValue; |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
269 query_.ToJson(target[QUERY], DicomToJsonFormat_Short); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
270 |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
271 target[QUERY_FORMAT] = EnumerationToString(queryFormat_); |
7826ac059c31
Added Short/Simplify/Full options to format "/modalities/{id}/find-worklist" and "/queries/{id}/retrieve"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4729
diff
changeset
|
272 |
2867 | 273 return true; |
274 } | |
275 } | |
276 } |