Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp @ 4729:4e2247df6327
Added "Short" and "Full" options in /modalities/id/find-worklist
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Jun 2021 10:41:35 +0200 |
parents | 88d16656b8b5 |
children | 7826ac059c31 |
comparison
equal
deleted
inserted
replaced
4728:b5ca12bfce8c | 4729:4e2247df6327 |
---|---|
389 DicomControlUserConnection connection(GetAssociationParameters(call)); | 389 DicomControlUserConnection connection(GetAssociationParameters(call)); |
390 FindPatient(answers, connection, fields); | 390 FindPatient(answers, connection, fields); |
391 } | 391 } |
392 | 392 |
393 Json::Value result; | 393 Json::Value result; |
394 answers.ToJson(result, true); | 394 answers.ToJson(result, DicomToJsonFormat_Human); |
395 call.GetOutput().AnswerJson(result); | 395 call.GetOutput().AnswerJson(result); |
396 } | 396 } |
397 | 397 |
398 static void DicomFindStudy(RestApiPostCall& call) | 398 static void DicomFindStudy(RestApiPostCall& call) |
399 { | 399 { |
432 DicomControlUserConnection connection(GetAssociationParameters(call)); | 432 DicomControlUserConnection connection(GetAssociationParameters(call)); |
433 FindStudy(answers, connection, fields); | 433 FindStudy(answers, connection, fields); |
434 } | 434 } |
435 | 435 |
436 Json::Value result; | 436 Json::Value result; |
437 answers.ToJson(result, true); | 437 answers.ToJson(result, DicomToJsonFormat_Human); |
438 call.GetOutput().AnswerJson(result); | 438 call.GetOutput().AnswerJson(result); |
439 } | 439 } |
440 | 440 |
441 static void DicomFindSeries(RestApiPostCall& call) | 441 static void DicomFindSeries(RestApiPostCall& call) |
442 { | 442 { |
476 DicomControlUserConnection connection(GetAssociationParameters(call)); | 476 DicomControlUserConnection connection(GetAssociationParameters(call)); |
477 FindSeries(answers, connection, fields); | 477 FindSeries(answers, connection, fields); |
478 } | 478 } |
479 | 479 |
480 Json::Value result; | 480 Json::Value result; |
481 answers.ToJson(result, true); | 481 answers.ToJson(result, DicomToJsonFormat_Human); |
482 call.GetOutput().AnswerJson(result); | 482 call.GetOutput().AnswerJson(result); |
483 } | 483 } |
484 | 484 |
485 static void DicomFindInstance(RestApiPostCall& call) | 485 static void DicomFindInstance(RestApiPostCall& call) |
486 { | 486 { |
521 DicomControlUserConnection connection(GetAssociationParameters(call)); | 521 DicomControlUserConnection connection(GetAssociationParameters(call)); |
522 FindInstance(answers, connection, fields); | 522 FindInstance(answers, connection, fields); |
523 } | 523 } |
524 | 524 |
525 Json::Value result; | 525 Json::Value result; |
526 answers.ToJson(result, true); | 526 answers.ToJson(result, DicomToJsonFormat_Human); |
527 call.GetOutput().AnswerJson(result); | 527 call.GetOutput().AnswerJson(result); |
528 } | 528 } |
529 | 529 |
530 | 530 |
531 static void CopyTagIfExists(DicomMap& target, | 531 static void CopyTagIfExists(DicomMap& target, |
575 // Loop over the found patients | 575 // Loop over the found patients |
576 Json::Value result = Json::arrayValue; | 576 Json::Value result = Json::arrayValue; |
577 for (size_t i = 0; i < patients.GetSize(); i++) | 577 for (size_t i = 0; i < patients.GetSize(); i++) |
578 { | 578 { |
579 Json::Value patient; | 579 Json::Value patient; |
580 patients.ToJson(patient, i, true); | 580 patients.ToJson(patient, i, DicomToJsonFormat_Human); |
581 | 581 |
582 DicomMap::SetupFindStudyTemplate(m); | 582 DicomMap::SetupFindStudyTemplate(m); |
583 if (!MergeQueryAndTemplate(m, call)) | 583 if (!MergeQueryAndTemplate(m, call)) |
584 { | 584 { |
585 return; | 585 return; |
594 | 594 |
595 // Loop over the found studies | 595 // Loop over the found studies |
596 for (size_t j = 0; j < studies.GetSize(); j++) | 596 for (size_t j = 0; j < studies.GetSize(); j++) |
597 { | 597 { |
598 Json::Value study; | 598 Json::Value study; |
599 studies.ToJson(study, j, true); | 599 studies.ToJson(study, j, DicomToJsonFormat_Human); |
600 | 600 |
601 DicomMap::SetupFindSeriesTemplate(m); | 601 DicomMap::SetupFindSeriesTemplate(m); |
602 if (!MergeQueryAndTemplate(m, call)) | 602 if (!MergeQueryAndTemplate(m, call)) |
603 { | 603 { |
604 return; | 604 return; |
613 // Loop over the found series | 613 // Loop over the found series |
614 study["Series"] = Json::arrayValue; | 614 study["Series"] = Json::arrayValue; |
615 for (size_t k = 0; k < series.GetSize(); k++) | 615 for (size_t k = 0; k < series.GetSize(); k++) |
616 { | 616 { |
617 Json::Value series2; | 617 Json::Value series2; |
618 series.ToJson(series2, k, true); | 618 series.ToJson(series2, k, DicomToJsonFormat_Human); |
619 study["Series"].append(series2); | 619 study["Series"].append(series2); |
620 } | 620 } |
621 | 621 |
622 patient["Studies"].append(study); | 622 patient["Studies"].append(study); |
623 } | 623 } |
2138 | 2138 |
2139 static void DicomFindWorklist(RestApiPostCall& call) | 2139 static void DicomFindWorklist(RestApiPostCall& call) |
2140 { | 2140 { |
2141 if (call.IsDocumentation()) | 2141 if (call.IsDocumentation()) |
2142 { | 2142 { |
2143 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human); | |
2144 | |
2143 call.GetDocumentation() | 2145 call.GetDocumentation() |
2144 .SetTag("Networking") | 2146 .SetTag("Networking") |
2145 .SetSummary("C-FIND SCU for worklist") | 2147 .SetSummary("C-FIND SCU for worklist") |
2146 .SetDescription("Trigger C-FIND SCU command against the remote worklists of the DICOM modality " | 2148 .SetDescription("Trigger C-FIND SCU command against the remote worklists of the DICOM modality " |
2147 "whose identifier is provided in URL") | 2149 "whose identifier is provided in URL") |
2148 .SetUriArgument("id", "Identifier of the modality of interest") | 2150 .SetUriArgument("id", "Identifier of the modality of interest") |
2149 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags") | 2151 .SetRequestField(KEY_QUERY, RestApiCallDocumentation::Type_JsonObject, |
2152 "Associative array containing the filter on the values of the DICOM tags", true) | |
2150 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching worklists"); | 2153 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching worklists"); |
2151 return; | 2154 return; |
2152 } | 2155 } |
2153 | 2156 |
2154 Json::Value json; | 2157 Json::Value json; |
2155 if (call.ParseJsonRequest(json)) | 2158 if (call.ParseJsonRequest(json)) |
2156 { | 2159 { |
2157 std::unique_ptr<ParsedDicomFile> query | 2160 std::unique_ptr<ParsedDicomFile> query; |
2158 (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(0), | 2161 DicomToJsonFormat format; |
2159 "" /* no private creator */)); | 2162 |
2163 if (json.isMember(KEY_QUERY)) | |
2164 { | |
2165 // New in Orthanc 1.9.5 | |
2166 query.reset(ParsedDicomFile::CreateFromJson(json[KEY_QUERY], static_cast<DicomFromJsonFlags>(0), | |
2167 "" /* no private creator */)); | |
2168 format = OrthancRestApi::GetDicomFormat(json, DicomToJsonFormat_Human); | |
2169 } | |
2170 else | |
2171 { | |
2172 // Compatibility with Orthanc <= 1.9.4 | |
2173 query.reset(ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(0), | |
2174 "" /* no private creator */)); | |
2175 format = DicomToJsonFormat_Human; | |
2176 } | |
2160 | 2177 |
2161 DicomFindAnswers answers(true); | 2178 DicomFindAnswers answers(true); |
2162 | 2179 |
2163 { | 2180 { |
2164 DicomControlUserConnection connection(GetAssociationParameters(call, json)); | 2181 DicomControlUserConnection connection(GetAssociationParameters(call, json)); |
2165 connection.FindWorklist(answers, *query); | 2182 connection.FindWorklist(answers, *query); |
2166 } | 2183 } |
2167 | 2184 |
2168 Json::Value result; | 2185 Json::Value result; |
2169 answers.ToJson(result, true); | 2186 answers.ToJson(result, format); |
2170 call.GetOutput().AnswerJson(result); | 2187 call.GetOutput().AnswerJson(result); |
2171 } | 2188 } |
2172 else | 2189 else |
2173 { | 2190 { |
2174 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object"); | 2191 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object"); |