comparison OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp @ 5287:c04230962098 am-experimental

wip: 'dicomWeb' json format + 'include' get arguments
author Alain Mazy <am@osimis.io>
date Fri, 28 Apr 2023 10:42:27 +0200
parents 0ea402b4d901
children
comparison
equal deleted inserted replaced
5286:28f0e38e4082 5287:c04230962098
487 487
488 488
489 static const std::string GET_SIMPLIFY = "simplify"; 489 static const std::string GET_SIMPLIFY = "simplify";
490 static const std::string GET_FULL = "full"; 490 static const std::string GET_FULL = "full";
491 static const std::string GET_SHORT = "short"; 491 static const std::string GET_SHORT = "short";
492 static const std::string GET_DICOM_WEB = "dicomWeb";
492 static const std::string GET_REQUESTED_TAGS = "requestedTags"; 493 static const std::string GET_REQUESTED_TAGS = "requestedTags";
494 static const std::string GET_INCLUDE = "include";
493 495
494 static const std::string POST_SIMPLIFY = "Simplify"; 496 static const std::string POST_SIMPLIFY = "Simplify";
495 static const std::string POST_FULL = "Full"; 497 static const std::string POST_FULL = "Full";
496 static const std::string POST_SHORT = "Short"; 498 static const std::string POST_SHORT = "Short";
497 static const std::string POST_REQUESTED_TAGS = "RequestedTags"; 499 static const std::string POST_REQUESTED_TAGS = "RequestedTags";
504 506
505 static const std::string DOCUMENT_FULL = 507 static const std::string DOCUMENT_FULL =
506 "report the DICOM tags in full format (tags indexed by their hexadecimal " 508 "report the DICOM tags in full format (tags indexed by their hexadecimal "
507 "format, associated with their symbolic name and their value)"; 509 "format, associated with their symbolic name and their value)";
508 510
511 ExpandResourceFlags OrthancRestApi::GetResponseContent(const RestApiGetCall& call,
512 ExpandResourceFlags defaultContent)
513 {
514 if (call.HasArgument(GET_INCLUDE))
515 {
516 std::vector<std::string> includes;
517 Toolbox::TokenizeString(includes, call.GetArgument(GET_INCLUDE, ""), ',');
518
519 unsigned int result = static_cast<unsigned int>(ExpandResourceFlags_None);
520 for (size_t i = 0; i < includes.size(); ++i)
521 {
522 if (includes[i] == "MainDicomTags")
523 {
524 result |= static_cast<unsigned int>(ExpandResourceFlags_IncludeMainDicomTags);
525 }
526 else if (includes[i] == "RequestedTags")
527 {
528 result |= static_cast<unsigned int>(ExpandResourceFlags_IncludeRequestedTags);
529 }
530 else if (includes[i] == "Labels")
531 {
532 result |= static_cast<unsigned int>(ExpandResourceFlags_IncludeLabels);
533 }
534 else if (includes[i] == "Children")
535 {
536 result |= static_cast<unsigned int>(ExpandResourceFlags_IncludeChildren);
537 }
538 else if (includes[i] == "Metadata")
539 {
540 result |= static_cast<unsigned int>(ExpandResourceFlags_IncludeMetadata);
541 }
542 }
543
544 return static_cast<ExpandResourceFlags>(result);
545 }
546
547 return defaultContent;
548 }
549
509 550
510 DicomToJsonFormat OrthancRestApi::GetDicomFormat(const RestApiGetCall& call, 551 DicomToJsonFormat OrthancRestApi::GetDicomFormat(const RestApiGetCall& call,
511 DicomToJsonFormat defaultFormat) 552 DicomToJsonFormat defaultFormat)
512 { 553 {
513 if (call.HasArgument(GET_SIMPLIFY)) 554 if (call.HasArgument(GET_SIMPLIFY))
519 return DicomToJsonFormat_Short; 560 return DicomToJsonFormat_Short;
520 } 561 }
521 else if (call.HasArgument(GET_FULL)) 562 else if (call.HasArgument(GET_FULL))
522 { 563 {
523 return DicomToJsonFormat_Full; 564 return DicomToJsonFormat_Full;
565 }
566 else if (call.HasArgument(GET_DICOM_WEB))
567 {
568 return DicomToJsonFormat_DicomWeb;
524 } 569 }
525 else 570 else
526 { 571 {
527 return defaultFormat; 572 return defaultFormat;
528 } 573 }