comparison OrthancServer/OrthancRestApi/OrthancRestModalities.cpp @ 2948:d2e548e643af

New options to URI "/queries/.../answers": "?expand" and "?limit"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 29 Nov 2018 20:36:31 +0100
parents f395460af74d
children bbfd95a0c429
comparison
equal deleted inserted replaced
2947:11f8d72f366f 2948:d2e548e643af
496 } 496 }
497 497
498 498
499 static void ListQueryAnswers(RestApiGetCall& call) 499 static void ListQueryAnswers(RestApiGetCall& call)
500 { 500 {
501 const bool expand = call.HasArgument("expand");
502 const bool simplify = call.HasArgument("simplify");
503
501 QueryAccessor query(call); 504 QueryAccessor query(call);
502 size_t count = query.GetHandler().GetAnswersCount(); 505 size_t count = query.GetHandler().GetAnswersCount();
503 506
504 Json::Value result = Json::arrayValue; 507 Json::Value result = Json::arrayValue;
505 for (size_t i = 0; i < count; i++) 508 for (size_t i = 0; i < count; i++)
506 { 509 {
507 result.append(boost::lexical_cast<std::string>(i)); 510 if (expand)
511 {
512 // New in Orthanc 1.4.3
513 DicomMap value;
514 query.GetHandler().GetAnswer(value, i);
515
516 Json::Value json = Json::objectValue;
517 FromDcmtkBridge::ToJson(json, value, simplify);
518
519 result.append(json);
520 }
521 else
522 {
523 result.append(boost::lexical_cast<std::string>(i));
524 }
508 } 525 }
509 526
510 call.GetOutput().AnswerJson(result); 527 call.GetOutput().AnswerJson(result);
511 } 528 }
512 529