comparison OrthancServer/ServerJobs/DicomMoveScuJob.cpp @ 3303:a215182a0c2f

"DicomMoveScu" jobs provide the associated C-FIND answer in their "Query" public field
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 24 Feb 2019 10:03:02 +0100
parents beeeb6096f27
children 94f4a18a79cc
comparison
equal deleted inserted replaced
3302:8ed445e94486 3303:a215182a0c2f
34 #include "DicomMoveScuJob.h" 34 #include "DicomMoveScuJob.h"
35 35
36 #include "../../Core/SerializationToolbox.h" 36 #include "../../Core/SerializationToolbox.h"
37 #include "../ServerContext.h" 37 #include "../ServerContext.h"
38 38
39 static const char* const LOCAL_AET = "LocalAet";
40 static const char* const TARGET_AET = "TargetAet";
41 static const char* const REMOTE = "Remote";
42 static const char* const QUERY = "Query";
43
39 namespace Orthanc 44 namespace Orthanc
40 { 45 {
41 class DicomMoveScuJob::Command : public SetOfCommandsJob::ICommand 46 class DicomMoveScuJob::Command : public SetOfCommandsJob::ICommand
42 { 47 {
43 private: 48 private:
95 connection_->Open(); 100 connection_->Open();
96 } 101 }
97 102
98 connection_->Move(targetAet_, findAnswer); 103 connection_->Move(targetAet_, findAnswer);
99 } 104 }
105
106
107 static void AddTagIfString(Json::Value& target,
108 const DicomMap& answer,
109 const DicomTag& tag)
110 {
111 const DicomValue* value = answer.TestAndGetValue(tag);
112 if (value != NULL &&
113 !value->IsNull() &&
114 !value->IsBinary())
115 {
116 target[tag.Format()] = value->GetContent();
117 }
118 }
119
120
121 void DicomMoveScuJob::AddFindAnswer(const DicomMap& answer)
122 {
123 assert(query_.type() == Json::arrayValue);
124
125 // Copy the identifiers tags, if they exist
126 Json::Value item = Json::objectValue;
127 AddTagIfString(item, answer, DICOM_TAG_QUERY_RETRIEVE_LEVEL);
128 AddTagIfString(item, answer, DICOM_TAG_PATIENT_ID);
129 AddTagIfString(item, answer, DICOM_TAG_STUDY_INSTANCE_UID);
130 AddTagIfString(item, answer, DICOM_TAG_SERIES_INSTANCE_UID);
131 AddTagIfString(item, answer, DICOM_TAG_SOP_INSTANCE_UID);
132 AddTagIfString(item, answer, DICOM_TAG_ACCESSION_NUMBER);
133 query_.append(item);
100 134
101
102 void DicomMoveScuJob::AddFindAnswer(const DicomMap& answer)
103 {
104 AddCommand(new Command(*this, answer)); 135 AddCommand(new Command(*this, answer));
105 } 136 }
106 137
107 138
108 void DicomMoveScuJob::AddFindAnswer(QueryRetrieveHandler& query, 139 void DicomMoveScuJob::AddFindAnswer(QueryRetrieveHandler& query,
163 { 194 {
164 SetOfCommandsJob::GetPublicContent(value); 195 SetOfCommandsJob::GetPublicContent(value);
165 196
166 value["LocalAet"] = localAet_; 197 value["LocalAet"] = localAet_;
167 value["RemoteAet"] = remote_.GetApplicationEntityTitle(); 198 value["RemoteAet"] = remote_.GetApplicationEntityTitle();
168 } 199 value["Query"] = query_;
169 200 }
170 201
171 static const char* LOCAL_AET = "LocalAet";
172 static const char* TARGET_AET = "TargetAet";
173 static const char* REMOTE = "Remote";
174 202
175 DicomMoveScuJob::DicomMoveScuJob(ServerContext& context, 203 DicomMoveScuJob::DicomMoveScuJob(ServerContext& context,
176 const Json::Value& serialized) : 204 const Json::Value& serialized) :
177 SetOfCommandsJob(new Unserializer(*this), serialized), 205 SetOfCommandsJob(new Unserializer(*this), serialized),
178 context_(context) 206 context_(context),
207 query_(Json::arrayValue)
179 { 208 {
180 localAet_ = SerializationToolbox::ReadString(serialized, LOCAL_AET); 209 localAet_ = SerializationToolbox::ReadString(serialized, LOCAL_AET);
181 targetAet_ = SerializationToolbox::ReadString(serialized, TARGET_AET); 210 targetAet_ = SerializationToolbox::ReadString(serialized, TARGET_AET);
182 remote_ = RemoteModalityParameters(serialized[REMOTE]); 211 remote_ = RemoteModalityParameters(serialized[REMOTE]);
212
213 if (serialized.isMember(QUERY) &&
214 serialized[QUERY].type() == Json::arrayValue)
215 {
216 query_ = serialized[QUERY];
217 }
183 } 218 }
184 219
185 220
186 bool DicomMoveScuJob::Serialize(Json::Value& target) 221 bool DicomMoveScuJob::Serialize(Json::Value& target)
187 { 222 {
191 } 226 }
192 else 227 else
193 { 228 {
194 target[LOCAL_AET] = localAet_; 229 target[LOCAL_AET] = localAet_;
195 target[TARGET_AET] = targetAet_; 230 target[TARGET_AET] = targetAet_;
231 target[QUERY] = query_;
196 remote_.Serialize(target[REMOTE], true /* force advanced format */); 232 remote_.Serialize(target[REMOTE], true /* force advanced format */);
197 return true; 233 return true;
198 } 234 }
199 } 235 }
200 } 236 }