Mercurial > hg > orthanc
comparison OrthancServer/OrthancFindRequestHandler.cpp @ 611:9924aec1d694 find-move-scp
filtering on modalities
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 Oct 2013 13:12:18 +0200 |
parents | 5ba825b87b21 |
children | fdd5f7f9c4d7 |
comparison
equal
deleted
inserted
replaced
610:5ba825b87b21 | 611:9924aec1d694 |
---|---|
74 | 74 |
75 | 75 |
76 static bool ApplyListConstraint(const std::string& value, | 76 static bool ApplyListConstraint(const std::string& value, |
77 const std::string& constraint) | 77 const std::string& constraint) |
78 { | 78 { |
79 std::cout << value << std::endl; | |
80 | |
81 std::string v1 = ToLowerCase(value); | 79 std::string v1 = ToLowerCase(value); |
82 | 80 |
83 std::vector<std::string> items; | 81 std::vector<std::string> items; |
84 Toolbox::TokenizeString(items, constraint, '\\'); | 82 Toolbox::TokenizeString(items, constraint, '\\'); |
85 | 83 |
161 { | 159 { |
162 for (size_t i = 0; i < query.GetSize(); i++) | 160 for (size_t i = 0; i < query.GetSize(); i++) |
163 { | 161 { |
164 if (query.GetElement(i).GetValue().IsNull() || | 162 if (query.GetElement(i).GetValue().IsNull() || |
165 query.GetElement(i).GetTag() == DICOM_TAG_QUERY_RETRIEVE_LEVEL || | 163 query.GetElement(i).GetTag() == DICOM_TAG_QUERY_RETRIEVE_LEVEL || |
166 query.GetElement(i).GetTag() == DICOM_TAG_SPECIFIC_CHARACTER_SET) | 164 query.GetElement(i).GetTag() == DICOM_TAG_SPECIFIC_CHARACTER_SET || |
165 query.GetElement(i).GetTag() == DICOM_TAG_MODALITIES_IN_STUDY) | |
167 { | 166 { |
168 continue; | 167 continue; |
169 } | 168 } |
170 | 169 |
171 std::string tag = query.GetElement(i).GetTag().Format(); | 170 std::string tag = query.GetElement(i).GetTag().Format(); |
172 std::string value; | 171 std::string value; |
173 if (resource.isMember(tag)) | 172 if (resource.isMember(tag)) |
174 { | 173 { |
175 value = resource.get(tag, Json::arrayValue).get("Value", "").asString(); | 174 value = resource.get(tag, Json::arrayValue).get("Value", "").asString(); |
176 } | 175 } |
177 | |
178 std::cout << tag << " " << value << std::endl; | |
179 | 176 |
180 if (!Matches(value, query.GetElement(i).GetValue().AsString())) | 177 if (!Matches(value, query.GetElement(i).GetValue().AsString())) |
181 { | 178 { |
182 return false; | 179 return false; |
183 } | 180 } |
243 | 240 |
244 Json::Value resources; | 241 Json::Value resources; |
245 context_.GetIndex().GetAllUuids(resources, level); | 242 context_.GetIndex().GetAllUuids(resources, level); |
246 assert(resources.type() == Json::arrayValue); | 243 assert(resources.type() == Json::arrayValue); |
247 | 244 |
248 | |
249 // TODO : Speed up using MainDicomTags (to avoid looping over ALL | 245 // TODO : Speed up using MainDicomTags (to avoid looping over ALL |
250 // the resources and reading the JSON file for each of them) | 246 // the resources and reading the JSON file for each of them) |
247 | |
248 | |
249 | |
250 /** | |
251 * Apply filtering on modalities for studies, if asked (this is an | |
252 * extension to standard DICOM) | |
253 * http://www.medicalconnections.co.uk/kb/Filtering_on_and_Retrieving_the_Modality_in_a_C_FIND | |
254 **/ | |
255 | |
256 if (level == ResourceType_Study && | |
257 input.HasTag(DICOM_TAG_MODALITIES_IN_STUDY)) | |
258 { | |
259 const DicomValue& v = input.GetValue(DICOM_TAG_MODALITIES_IN_STUDY); | |
260 if (!v.IsNull()) | |
261 { | |
262 // Move the allowed modalities into a "std::set" | |
263 std::vector<std::string> tmp; | |
264 Toolbox::TokenizeString(tmp, v.AsString(), '\\'); | |
265 | |
266 std::set<std::string> modalities; | |
267 for (size_t i = 0; i < tmp.size(); i++) | |
268 { | |
269 modalities.insert(tmp[i]); | |
270 } | |
271 | |
272 // Loop over the studies | |
273 Json::Value studies = resources; | |
274 resources = Json::arrayValue; | |
275 | |
276 for (Json::Value::ArrayIndex i = 0; i < studies.size(); i++) | |
277 { | |
278 // We are considering a single study. Check whether one of | |
279 // its child series matches one of the modalities. | |
280 Json::Value study; | |
281 if (context_.GetIndex().LookupResource(study, studies[i].asString(), ResourceType_Study)) | |
282 { | |
283 // Loop over the series of the considered study. | |
284 for (Json::Value::ArrayIndex j = 0; j < study["Series"].size(); j++) // (*) | |
285 { | |
286 Json::Value series; | |
287 if (context_.GetIndex().LookupResource(series, study["Series"][j].asString(), ResourceType_Series)) | |
288 { | |
289 // Get the modality of this series | |
290 if (series["MainDicomTags"].isMember("Modality")) | |
291 { | |
292 std::string modality = series["MainDicomTags"]["Modality"].asString(); | |
293 if (modalities.find(modality) != modalities.end()) | |
294 { | |
295 // This series of the considered study matches one | |
296 // of the required modalities. Take the study into | |
297 // consideration for future filtering. | |
298 resources.append(studies[i]); | |
299 | |
300 // We have finished considering this study. Break the study loop at (*). | |
301 break; | |
302 } | |
303 } | |
304 } | |
305 } | |
306 } | |
307 } | |
308 } | |
309 } | |
251 | 310 |
252 | 311 |
253 /** | 312 /** |
254 * Loop over all the resources for this query level. | 313 * Loop over all the resources for this query level. |
255 **/ | 314 **/ |
271 } | 330 } |
272 } | 331 } |
273 } | 332 } |
274 catch (OrthancException&) | 333 catch (OrthancException&) |
275 { | 334 { |
276 // This resource has been deleted during the find request | 335 // This resource has probably been deleted during the find request |
277 } | 336 } |
278 } | 337 } |
279 } | 338 } |
280 } | 339 } |