comparison OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5607:a3732285f8b6 find-refactoring

added main DICOM tags to ResourceFinder
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 08 May 2024 12:58:16 +0200
parents 6e2dad336446
children 3d0aa94b44b3
comparison
equal deleted inserted replaced
5606:6e2dad336446 5607:a3732285f8b6
353 uint32_t expectedNumberOfInstances; 353 uint32_t expectedNumberOfInstances;
354 SeriesStatus status = GetSeriesStatus(expectedNumberOfInstances, resource); 354 SeriesStatus status = GetSeriesStatus(expectedNumberOfInstances, resource);
355 355
356 target["Status"] = EnumerationToString(status); 356 target["Status"] = EnumerationToString(status);
357 357
358 static const char* EXPECTED_NUMBER_OF_INSTANCES = "ExpectedNumberOfInstances";
359
358 if (status == SeriesStatus_Unknown) 360 if (status == SeriesStatus_Unknown)
359 { 361 {
360 target["ExpectedNumberOfInstances"] = Json::nullValue; 362 target[EXPECTED_NUMBER_OF_INSTANCES] = Json::nullValue;
361 } 363 }
362 else 364 else
363 { 365 {
364 target["ExpectedNumberOfInstances"] = expectedNumberOfInstances; 366 target[EXPECTED_NUMBER_OF_INSTANCES] = expectedNumberOfInstances;
365 } 367 }
366 368
367 break; 369 break;
368 } 370 }
369 371
378 else 380 else
379 { 381 {
380 throw OrthancException(ErrorCode_InternalError); 382 throw OrthancException(ErrorCode_InternalError);
381 } 383 }
382 384
385 static const char* INDEX_IN_SERIES = "IndexInSeries";
386
383 std::string s; 387 std::string s;
384 uint32_t index; 388 uint32_t index;
385 if (resource.LookupMetadata(s, ResourceType_Instance, MetadataType_Instance_IndexInSeries) && 389 if (resource.LookupMetadata(s, ResourceType_Instance, MetadataType_Instance_IndexInSeries) &&
386 SerializationToolbox::ParseUnsignedInteger32(index, s)) 390 SerializationToolbox::ParseUnsignedInteger32(index, s))
387 { 391 {
388 target["IndexInSeries"] = index; 392 target[INDEX_IN_SERIES] = index;
389 } 393 }
390 else 394 else
391 { 395 {
392 target["IndexInSeries"] = Json::nullValue; 396 target[INDEX_IN_SERIES] = Json::nullValue;
393 } 397 }
394 398
395 break; 399 break;
396 } 400 }
397 401
421 target["LastUpdate"] = s; 425 target["LastUpdate"] = s;
422 } 426 }
423 } 427 }
424 428
425 { 429 {
430 static const char* const MAIN_DICOM_TAGS = "MainDicomTags";
431 static const char* const PATIENT_MAIN_DICOM_TAGS = "PatientMainDicomTags";
432
426 // TODO-FIND : (expandFlags & ExpandResourceFlags_IncludeMainDicomTags) 433 // TODO-FIND : (expandFlags & ExpandResourceFlags_IncludeMainDicomTags)
434 DicomMap allMainDicomTags;
435 resource.GetMainDicomTags(allMainDicomTags, resource.GetLevel());
436
437 DicomMap levelMainDicomTags;
438 allMainDicomTags.ExtractResourceInformation(levelMainDicomTags, resource.GetLevel());
439
440 target[MAIN_DICOM_TAGS] = Json::objectValue;
441 FromDcmtkBridge::ToJson(target[MAIN_DICOM_TAGS], levelMainDicomTags, format_);
442
443 if (resource.GetLevel() == ResourceType_Study)
444 {
445 DicomMap patientMainDicomTags;
446 allMainDicomTags.ExtractPatientInformation(patientMainDicomTags);
447
448 target[PATIENT_MAIN_DICOM_TAGS] = Json::objectValue;
449 FromDcmtkBridge::ToJson(target[PATIENT_MAIN_DICOM_TAGS], patientMainDicomTags, format_);
450 }
451
452 /*
453 TODO-FIND
454
455 if (!requestedTags_.empty())
456 {
457 static const char* const REQUESTED_TAGS = "RequestedTags";
458
459 DicomMap tags;
460 resource.GetMainDicomTags().ExtractTags(tags, requestedTags);
461
462 target[REQUESTED_TAGS] = Json::objectValue;
463 FromDcmtkBridge::ToJson(target[REQUESTED_TAGS], tags, format);
464 }
465 */
427 } 466 }
428 467
429 { 468 {
430 Json::Value labels = Json::arrayValue; 469 Json::Value labels = Json::arrayValue;
431 470
522 { 561 {
523 for (size_t i = 0; i < response.GetSize(); i++) 562 for (size_t i = 0; i < response.GetSize(); i++)
524 { 563 {
525 Json::Value item; 564 Json::Value item;
526 Expand(item, response.GetResource(i), context.GetIndex()); 565 Expand(item, response.GetResource(i), context.GetIndex());
527
528 #if 0
529 target.append(item); 566 target.append(item);
530 #else
531 context.AppendFindResponse(target, request_, response.GetResource(i), format_,
532 requestedTags_, true /* allowStorageAccess */);
533 std::cout << "+++ Expected: " << target[target.size() - 1].toStyledString();
534 std::cout << "--- Actual: " << item.toStyledString();
535 #endif
536 } 567 }
537 } 568 }
538 else 569 else
539 { 570 {
540 for (size_t i = 0; i < response.GetSize(); i++) 571 for (size_t i = 0; i < response.GetSize(); i++)