Mercurial > hg > orthanc
comparison OrthancServer/OrthancMoveRequestHandler.cpp @ 1721:3bcb01028107 db-changes
removed another flavor of ServerIndex::LookupIdentifier
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 20 Oct 2015 10:39:21 +0200 |
parents | 3309878b3e16 |
children | 7e0b5e413c7c |
comparison
equal
deleted
inserted
replaced
1720:88b74d8512be | 1721:3bcb01028107 |
---|---|
103 }; | 103 }; |
104 } | 104 } |
105 | 105 |
106 | 106 |
107 bool OrthancMoveRequestHandler::LookupIdentifier(std::string& publicId, | 107 bool OrthancMoveRequestHandler::LookupIdentifier(std::string& publicId, |
108 DicomTag tag, | 108 ResourceType level, |
109 const DicomMap& input) | 109 const DicomMap& input) |
110 { | 110 { |
111 DicomTag tag = GetIdentifierTag(level); | |
112 | |
111 if (!input.HasTag(tag)) | 113 if (!input.HasTag(tag)) |
112 { | 114 { |
113 return false; | 115 return false; |
114 } | 116 } |
115 | 117 |
116 std::string value = input.GetValue(tag).AsString(); | 118 std::string value = input.GetValue(tag).AsString(); |
117 | 119 |
118 std::list<std::string> ids; | 120 std::list<std::string> ids; |
119 context_.GetIndex().LookupIdentifier(ids, tag, value); | 121 context_.GetIndex().LookupIdentifier(ids, tag, value, level); |
120 | 122 |
121 if (ids.size() != 1) | 123 if (ids.size() != 1) |
122 { | 124 { |
123 return false; | 125 return false; |
124 } | 126 } |
154 | 156 |
155 /** | 157 /** |
156 * Retrieve the query level. | 158 * Retrieve the query level. |
157 **/ | 159 **/ |
158 | 160 |
159 ResourceType level; | |
160 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL); | 161 const DicomValue* levelTmp = input.TestAndGetValue(DICOM_TAG_QUERY_RETRIEVE_LEVEL); |
161 | 162 |
162 if (levelTmp != NULL) | 163 if (levelTmp == NULL) |
163 { | |
164 level = StringToResourceType(levelTmp->AsString().c_str()); | |
165 } | |
166 else | |
167 { | 164 { |
168 // The query level is not present in the C-Move request, which | 165 // The query level is not present in the C-Move request, which |
169 // does not follow the DICOM standard. This is for instance the | 166 // does not follow the DICOM standard. This is for instance the |
170 // behavior of Tudor DICOM. Try and automatically deduce the | 167 // behavior of Tudor DICOM. Try and automatically deduce the |
171 // query level: Start from the instance level, going up to the | 168 // query level: Start from the instance level, going up to the |
172 // patient level until a valid DICOM identifier is found. | 169 // patient level until a valid DICOM identifier is found. |
173 | 170 |
174 std::string publicId; | 171 std::string publicId; |
175 | 172 |
176 if (LookupIdentifier(publicId, DICOM_TAG_SOP_INSTANCE_UID, input) || | 173 if (LookupIdentifier(publicId, ResourceType_Instance, input) || |
177 LookupIdentifier(publicId, DICOM_TAG_SERIES_INSTANCE_UID, input) || | 174 LookupIdentifier(publicId, ResourceType_Series, input) || |
178 LookupIdentifier(publicId, DICOM_TAG_STUDY_INSTANCE_UID, input) || | 175 LookupIdentifier(publicId, ResourceType_Study, input) || |
179 LookupIdentifier(publicId, DICOM_TAG_PATIENT_ID, input)) | 176 LookupIdentifier(publicId, ResourceType_Patient, input)) |
180 { | 177 { |
181 return new OrthancMoveRequestIterator(context_, targetAet, publicId); | 178 return new OrthancMoveRequestIterator(context_, targetAet, publicId); |
182 } | 179 } |
183 else | 180 else |
184 { | 181 { |
185 // No identifier is present in the request. | 182 // No identifier is present in the request. |
186 throw OrthancException(ErrorCode_BadRequest); | 183 throw OrthancException(ErrorCode_BadRequest); |
187 } | 184 } |
188 } | 185 } |
189 | 186 |
187 assert(levelTmp != NULL); | |
188 ResourceType level = StringToResourceType(levelTmp->AsString().c_str()); | |
190 | 189 |
191 | 190 |
192 /** | 191 /** |
193 * Lookup for the resource to be sent. | 192 * Lookup for the resource to be sent. |
194 **/ | 193 **/ |
195 | 194 |
196 bool ok; | |
197 std::string publicId; | 195 std::string publicId; |
198 | 196 |
199 switch (level) | 197 if (LookupIdentifier(publicId, level, input)) |
200 { | 198 { |
201 case ResourceType_Patient: | 199 return new OrthancMoveRequestIterator(context_, targetAet, publicId); |
202 ok = LookupIdentifier(publicId, DICOM_TAG_PATIENT_ID, input); | 200 } |
203 break; | 201 else |
204 | |
205 case ResourceType_Study: | |
206 ok = LookupIdentifier(publicId, DICOM_TAG_STUDY_INSTANCE_UID, input); | |
207 break; | |
208 | |
209 case ResourceType_Series: | |
210 ok = LookupIdentifier(publicId, DICOM_TAG_SERIES_INSTANCE_UID, input); | |
211 break; | |
212 | |
213 case ResourceType_Instance: | |
214 ok = LookupIdentifier(publicId, DICOM_TAG_SOP_INSTANCE_UID, input); | |
215 break; | |
216 | |
217 default: | |
218 ok = false; | |
219 } | |
220 | |
221 if (!ok) | |
222 { | 202 { |
223 throw OrthancException(ErrorCode_BadRequest); | 203 throw OrthancException(ErrorCode_BadRequest); |
224 } | 204 } |
225 | |
226 return new OrthancMoveRequestIterator(context_, targetAet, publicId); | |
227 } | 205 } |
228 } | 206 } |