Mercurial > hg > orthanc
comparison OrthancServer/OrthancMoveRequestHandler.cpp @ 1907:5011a597b6ce
Support of Move Originator Message ID (0000,1031) in C-Store responses driven by C-Move
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 Jan 2016 11:28:19 +0100 |
parents | b1291df2f780 |
children | 21fcfc428dc2 |
comparison
equal
deleted
inserted
replaced
1906:d7c1cb559431 | 1907:5011a597b6ce |
---|---|
50 ServerContext& context_; | 50 ServerContext& context_; |
51 const std::string& localAet_; | 51 const std::string& localAet_; |
52 std::vector<std::string> instances_; | 52 std::vector<std::string> instances_; |
53 size_t position_; | 53 size_t position_; |
54 RemoteModalityParameters remote_; | 54 RemoteModalityParameters remote_; |
55 uint16_t moveRequestID_; | |
55 | 56 |
56 public: | 57 public: |
57 OrthancMoveRequestIterator(ServerContext& context, | 58 OrthancMoveRequestIterator(ServerContext& context, |
58 const std::string& aet, | 59 const std::string& aet, |
59 const std::string& publicId) : | 60 const std::string& publicId, |
61 uint16_t moveRequestID) : | |
60 context_(context), | 62 context_(context), |
61 localAet_(context.GetDefaultLocalApplicationEntityTitle()), | 63 localAet_(context.GetDefaultLocalApplicationEntityTitle()), |
62 position_(0) | 64 position_(0), |
65 moveRequestID_(moveRequestID) | |
63 { | 66 { |
64 LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\""; | 67 LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\""; |
65 | 68 |
66 std::list<std::string> tmp; | 69 std::list<std::string> tmp; |
67 context_.GetIndex().GetChildInstances(tmp, publicId); | 70 context_.GetIndex().GetChildInstances(tmp, publicId); |
93 context_.ReadFile(dicom, id, FileContentType_Dicom); | 96 context_.ReadFile(dicom, id, FileContentType_Dicom); |
94 | 97 |
95 { | 98 { |
96 ReusableDicomUserConnection::Locker locker | 99 ReusableDicomUserConnection::Locker locker |
97 (context_.GetReusableDicomUserConnection(), localAet_, remote_); | 100 (context_.GetReusableDicomUserConnection(), localAet_, remote_); |
98 locker.GetConnection().Store(dicom); | 101 locker.GetConnection().Store(dicom, moveRequestID_); |
99 } | 102 } |
100 | 103 |
101 return Status_Success; | 104 return Status_Success; |
102 } | 105 } |
103 }; | 106 }; |
182 } | 185 } |
183 } | 186 } |
184 } | 187 } |
185 | 188 |
186 | 189 |
190 /** | |
191 * Retrieve the Message ID (0000,0110) for this C-MOVE request, if | |
192 * any. If present, this Message ID will be stored in the Move | |
193 * Originator Message ID (0000,1031) field of the C-MOVE response. | |
194 * http://dicom.nema.org/medical/dicom/current/output/html/part07.html#sect_9.3.1 | |
195 **/ | |
196 | |
197 static const DicomTag MESSAGE_ID(0x0000, 0x0110); | |
198 const DicomValue* messageIdTmp = input.TestAndGetValue(MESSAGE_ID); | |
199 | |
200 uint16_t messageId = 0; | |
201 | |
202 if (messageIdTmp != NULL && | |
203 !messageIdTmp->IsNull() && | |
204 !messageIdTmp->IsBinary()) | |
205 { | |
206 try | |
207 { | |
208 messageId = boost::lexical_cast<uint16_t>(messageIdTmp->GetContent()); | |
209 } | |
210 catch (boost::bad_lexical_cast&) | |
211 { | |
212 LOG(WARNING) << "Cannot convert the Message ID (\"" << messageIdTmp ->GetContent() | |
213 << "\") of an incoming C-MOVE request to an integer, assuming zero"; | |
214 } | |
215 } | |
216 | |
187 | 217 |
188 /** | 218 /** |
189 * Retrieve the query level. | 219 * Retrieve the query level. |
190 **/ | 220 **/ |
191 | 221 |
206 if (LookupIdentifier(publicId, ResourceType_Instance, input) || | 236 if (LookupIdentifier(publicId, ResourceType_Instance, input) || |
207 LookupIdentifier(publicId, ResourceType_Series, input) || | 237 LookupIdentifier(publicId, ResourceType_Series, input) || |
208 LookupIdentifier(publicId, ResourceType_Study, input) || | 238 LookupIdentifier(publicId, ResourceType_Study, input) || |
209 LookupIdentifier(publicId, ResourceType_Patient, input)) | 239 LookupIdentifier(publicId, ResourceType_Patient, input)) |
210 { | 240 { |
211 return new OrthancMoveRequestIterator(context_, targetAet, publicId); | 241 return new OrthancMoveRequestIterator(context_, targetAet, publicId, messageId); |
212 } | 242 } |
213 else | 243 else |
214 { | 244 { |
215 // No identifier is present in the request. | 245 // No identifier is present in the request. |
216 throw OrthancException(ErrorCode_BadRequest); | 246 throw OrthancException(ErrorCode_BadRequest); |
227 | 257 |
228 std::string publicId; | 258 std::string publicId; |
229 | 259 |
230 if (LookupIdentifier(publicId, level, input)) | 260 if (LookupIdentifier(publicId, level, input)) |
231 { | 261 { |
232 return new OrthancMoveRequestIterator(context_, targetAet, publicId); | 262 return new OrthancMoveRequestIterator(context_, targetAet, publicId, messageId); |
233 } | 263 } |
234 else | 264 else |
235 { | 265 { |
236 throw OrthancException(ErrorCode_BadRequest); | 266 throw OrthancException(ErrorCode_BadRequest); |
237 } | 267 } |