comparison OrthancServer/ResourceFinder.cpp @ 1677:a903d57d9f0c db-changes

adaptation of search with patient tags at study level
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 05 Oct 2015 16:40:14 +0200
parents f967bdf8534e
children 21d31da73374
comparison
equal deleted inserted replaced
1676:f079f3efe33b 1677:a903d57d9f0c
35 35
36 #include "../Core/Logging.h" 36 #include "../Core/Logging.h"
37 #include "FromDcmtkBridge.h" 37 #include "FromDcmtkBridge.h"
38 #include "ServerContext.h" 38 #include "ServerContext.h"
39 39
40 #include <boost/algorithm/string/predicate.hpp>
41
42 namespace Orthanc 40 namespace Orthanc
43 { 41 {
44 class ResourceFinder::CandidateResources 42 class ResourceFinder::CandidateResources
45 { 43 {
46 private: 44 private:
188 ListToSet(filtered_, resources); 186 ListToSet(filtered_, resources);
189 } 187 }
190 } 188 }
191 189
192 190
193 void RestrictMainDicomTags(const IQuery& query) 191 void RestrictMainDicomTags(const IQuery& query,
194 { 192 bool filterPatientTagsAtStudyLevel)
193 {
194 if (filterPatientTagsAtStudyLevel &&
195 level_ == ResourceType_Patient)
196 {
197 return;
198 }
199
195 if (!query.HasMainDicomTagsFilter(level_)) 200 if (!query.HasMainDicomTagsFilter(level_))
196 { 201 {
197 return; 202 return;
198 } 203 }
199 204
205 210
206 for (std::list<std::string>::const_iterator 211 for (std::list<std::string>::const_iterator
207 it = resources.begin(); it != resources.end(); ++it) 212 it = resources.begin(); it != resources.end(); ++it)
208 { 213 {
209 DicomMap mainTags; 214 DicomMap mainTags;
210 if (index_.GetMainDicomTags(mainTags, *it, level_)) 215 if (!index_.GetMainDicomTags(mainTags, *it, level_, level_) ||
211 { 216 !query.FilterMainDicomTags(*it, level_, mainTags))
212 if (query.FilterMainDicomTags(*it, level_, mainTags)) 217 {
218 continue;
219 }
220
221 if (filterPatientTagsAtStudyLevel &&
222 level_ == ResourceType_Study)
223 {
224 if (!index_.GetMainDicomTags(mainTags, *it, ResourceType_Study, ResourceType_Patient) ||
225 !query.FilterMainDicomTags(*it, ResourceType_Patient, mainTags))
213 { 226 {
214 filtered_.insert(*it); 227 continue;
215 } 228 }
216 } 229 }
230
231 filtered_.insert(*it);
217 } 232 }
218 } 233 }
219 }; 234 };
220 235
221 236
264 279
265 default: 280 default:
266 throw OrthancException(ErrorCode_InternalError); 281 throw OrthancException(ErrorCode_InternalError);
267 } 282 }
268 283
269 candidates.RestrictMainDicomTags(query); 284 if (query.GetLevel() == ResourceType_Patient)
285 {
286 candidates.RestrictMainDicomTags(query, false);
287 }
288 else
289 {
290 candidates.RestrictMainDicomTags(query, true);
291 }
270 } 292 }
271 293
272 294
273 295
274 static bool LookupOneInstance(std::string& result, 296 static bool LookupOneInstance(std::string& result,