comparison OrthancServer/ServerToolbox.cpp @ 1709:2ad22b2970a2 db-changes

SearchableStudies
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 13 Oct 2015 17:48:30 +0200
parents 0bbcfd9695e5
children 5ebd6cbb3da8
comparison
equal deleted inserted replaced
1708:275780da54ae 1709:2ad22b2970a2
305 case ResourceType_Patient: 305 case ResourceType_Patient:
306 Toolbox::SetMainDicomTags(database, resource, ResourceType_Patient, dicomSummary, true); 306 Toolbox::SetMainDicomTags(database, resource, ResourceType_Patient, dicomSummary, true);
307 break; 307 break;
308 308
309 case ResourceType_Study: 309 case ResourceType_Study:
310 {
310 Toolbox::SetMainDicomTags(database, resource, ResourceType_Study, dicomSummary, true); 311 Toolbox::SetMainDicomTags(database, resource, ResourceType_Study, dicomSummary, true);
311 312
312 // Duplicate the patient tags at the study level (new in Orthanc 0.9.5 - db v6) 313 // Duplicate the patient tags at the study level (new in Orthanc 0.9.5 - db v6)
313 Toolbox::SetMainDicomTags(database, resource, ResourceType_Patient, dicomSummary, false); 314 Toolbox::SetMainDicomTags(database, resource, ResourceType_Patient, dicomSummary, false);
315
316 DicomMap module;
317 Toolbox::ExtractModule(module, dicomSummary, DicomModule_Patient, true /* normalize */);
318 Toolbox::ExtractModule(module, dicomSummary, DicomModule_Study, true /* normalize */);
319 database.StoreStudyModule(resource, module);
320
314 break; 321 break;
322 }
315 323
316 case ResourceType_Series: 324 case ResourceType_Series:
317 Toolbox::SetMainDicomTags(database, resource, ResourceType_Series, dicomSummary, true); 325 Toolbox::SetMainDicomTags(database, resource, ResourceType_Series, dicomSummary, true);
318 break; 326 break;
319 327
324 default: 332 default:
325 throw OrthancException(ErrorCode_InternalError); 333 throw OrthancException(ErrorCode_InternalError);
326 } 334 }
327 } 335 }
328 } 336 }
337
338
339 void ExtractModule(DicomMap& result, // WARNING: Will not be cleared!
340 const DicomMap& summary,
341 DicomModule module,
342 bool normalize)
343 {
344 typedef std::set<DicomTag> ModuleTags;
345 ModuleTags moduleTags;
346 DicomTag::AddTagsForModule(moduleTags, module);
347
348 for (ModuleTags::const_iterator tag = moduleTags.begin(); tag != moduleTags.end(); ++tag)
349 {
350 const DicomValue* value = summary.TestAndGetValue(*tag);
351 if (value != NULL &&
352 !value->IsNull())
353 {
354 std::string t = value->AsString();
355
356 if (normalize)
357 {
358 t = StripSpaces(ConvertToAscii(t));
359 ToUpperCase(t);
360 }
361
362 result.SetValue(*tag, t);
363 }
364 }
365 }
329 } 366 }
330 } 367 }