Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestModalities.cpp @ 4740:c1d6ce00be3f openssl-3.x
integration mainline->openssl-3.x
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 06 Jul 2021 08:40:43 +0200 |
parents | b11900508dc0 3709565bee7f |
children | 2e71a08eea15 |
comparison
equal
deleted
inserted
replaced
4739:8cc9137b5c2e | 4740:c1d6ce00be3f |
---|---|
377 DicomControlUserConnection connection(GetAssociationParameters(call)); | 377 DicomControlUserConnection connection(GetAssociationParameters(call)); |
378 FindPatient(answers, connection, fields); | 378 FindPatient(answers, connection, fields); |
379 } | 379 } |
380 | 380 |
381 Json::Value result; | 381 Json::Value result; |
382 answers.ToJson(result, true); | 382 answers.ToJson(result, DicomToJsonFormat_Human); |
383 call.GetOutput().AnswerJson(result); | 383 call.GetOutput().AnswerJson(result); |
384 } | 384 } |
385 | 385 |
386 static void DicomFindStudy(RestApiPostCall& call) | 386 static void DicomFindStudy(RestApiPostCall& call) |
387 { | 387 { |
420 DicomControlUserConnection connection(GetAssociationParameters(call)); | 420 DicomControlUserConnection connection(GetAssociationParameters(call)); |
421 FindStudy(answers, connection, fields); | 421 FindStudy(answers, connection, fields); |
422 } | 422 } |
423 | 423 |
424 Json::Value result; | 424 Json::Value result; |
425 answers.ToJson(result, true); | 425 answers.ToJson(result, DicomToJsonFormat_Human); |
426 call.GetOutput().AnswerJson(result); | 426 call.GetOutput().AnswerJson(result); |
427 } | 427 } |
428 | 428 |
429 static void DicomFindSeries(RestApiPostCall& call) | 429 static void DicomFindSeries(RestApiPostCall& call) |
430 { | 430 { |
464 DicomControlUserConnection connection(GetAssociationParameters(call)); | 464 DicomControlUserConnection connection(GetAssociationParameters(call)); |
465 FindSeries(answers, connection, fields); | 465 FindSeries(answers, connection, fields); |
466 } | 466 } |
467 | 467 |
468 Json::Value result; | 468 Json::Value result; |
469 answers.ToJson(result, true); | 469 answers.ToJson(result, DicomToJsonFormat_Human); |
470 call.GetOutput().AnswerJson(result); | 470 call.GetOutput().AnswerJson(result); |
471 } | 471 } |
472 | 472 |
473 static void DicomFindInstance(RestApiPostCall& call) | 473 static void DicomFindInstance(RestApiPostCall& call) |
474 { | 474 { |
509 DicomControlUserConnection connection(GetAssociationParameters(call)); | 509 DicomControlUserConnection connection(GetAssociationParameters(call)); |
510 FindInstance(answers, connection, fields); | 510 FindInstance(answers, connection, fields); |
511 } | 511 } |
512 | 512 |
513 Json::Value result; | 513 Json::Value result; |
514 answers.ToJson(result, true); | 514 answers.ToJson(result, DicomToJsonFormat_Human); |
515 call.GetOutput().AnswerJson(result); | 515 call.GetOutput().AnswerJson(result); |
516 } | 516 } |
517 | 517 |
518 | 518 |
519 static void CopyTagIfExists(DicomMap& target, | 519 static void CopyTagIfExists(DicomMap& target, |
563 // Loop over the found patients | 563 // Loop over the found patients |
564 Json::Value result = Json::arrayValue; | 564 Json::Value result = Json::arrayValue; |
565 for (size_t i = 0; i < patients.GetSize(); i++) | 565 for (size_t i = 0; i < patients.GetSize(); i++) |
566 { | 566 { |
567 Json::Value patient; | 567 Json::Value patient; |
568 patients.ToJson(patient, i, true); | 568 patients.ToJson(patient, i, DicomToJsonFormat_Human); |
569 | 569 |
570 DicomMap::SetupFindStudyTemplate(m); | 570 DicomMap::SetupFindStudyTemplate(m); |
571 if (!MergeQueryAndTemplate(m, call)) | 571 if (!MergeQueryAndTemplate(m, call)) |
572 { | 572 { |
573 return; | 573 return; |
582 | 582 |
583 // Loop over the found studies | 583 // Loop over the found studies |
584 for (size_t j = 0; j < studies.GetSize(); j++) | 584 for (size_t j = 0; j < studies.GetSize(); j++) |
585 { | 585 { |
586 Json::Value study; | 586 Json::Value study; |
587 studies.ToJson(study, j, true); | 587 studies.ToJson(study, j, DicomToJsonFormat_Human); |
588 | 588 |
589 DicomMap::SetupFindSeriesTemplate(m); | 589 DicomMap::SetupFindSeriesTemplate(m); |
590 if (!MergeQueryAndTemplate(m, call)) | 590 if (!MergeQueryAndTemplate(m, call)) |
591 { | 591 { |
592 return; | 592 return; |
601 // Loop over the found series | 601 // Loop over the found series |
602 study["Series"] = Json::arrayValue; | 602 study["Series"] = Json::arrayValue; |
603 for (size_t k = 0; k < series.GetSize(); k++) | 603 for (size_t k = 0; k < series.GetSize(); k++) |
604 { | 604 { |
605 Json::Value series2; | 605 Json::Value series2; |
606 series.ToJson(series2, k, true); | 606 series.ToJson(series2, k, DicomToJsonFormat_Human); |
607 study["Series"].append(series2); | 607 study["Series"].append(series2); |
608 } | 608 } |
609 | 609 |
610 patient["Studies"].append(study); | 610 patient["Studies"].append(study); |
611 } | 611 } |
922 targetAet = context.GetDefaultLocalApplicationEntityTitle(); | 922 targetAet = context.GetDefaultLocalApplicationEntityTitle(); |
923 } | 923 } |
924 } | 924 } |
925 | 925 |
926 std::unique_ptr<DicomMoveScuJob> job(new DicomMoveScuJob(context)); | 926 std::unique_ptr<DicomMoveScuJob> job(new DicomMoveScuJob(context)); |
927 job->SetQueryFormat(OrthancRestApi::GetDicomFormat(body, DicomToJsonFormat_Short)); | |
927 | 928 |
928 { | 929 { |
929 QueryAccessor query(call); | 930 QueryAccessor query(call); |
930 job->SetTargetAet(targetAet); | 931 job->SetTargetAet(targetAet); |
931 job->SetLocalAet(query.GetHandler().GetLocalAet()); | 932 job->SetLocalAet(query.GetHandler().GetLocalAet()); |
965 | 966 |
966 | 967 |
967 static void DocumentRetrieveShared(RestApiPostCall& call) | 968 static void DocumentRetrieveShared(RestApiPostCall& call) |
968 { | 969 { |
969 OrthancRestApi::DocumentSubmitCommandsJob(call); | 970 OrthancRestApi::DocumentSubmitCommandsJob(call); |
971 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Short); | |
972 | |
970 call.GetDocumentation() | 973 call.GetDocumentation() |
971 .SetTag("Networking") | 974 .SetTag("Networking") |
972 .SetUriArgument("id", "Identifier of the query of interest") | 975 .SetUriArgument("id", "Identifier of the query of interest") |
973 .SetRequestField(KEY_TARGET_AET, RestApiCallDocumentation::Type_String, | 976 .SetRequestField(KEY_TARGET_AET, RestApiCallDocumentation::Type_String, |
974 "AET of the target modality. By default, the AET of Orthanc is used, as defined in the " | 977 "AET of the target modality. By default, the AET of Orthanc is used, as defined in the " |
1509 | 1512 |
1510 static void DicomMove(RestApiPostCall& call) | 1513 static void DicomMove(RestApiPostCall& call) |
1511 { | 1514 { |
1512 if (call.IsDocumentation()) | 1515 if (call.IsDocumentation()) |
1513 { | 1516 { |
1514 OrthancRestApi::DocumentSubmitCommandsJob(call); | |
1515 call.GetDocumentation() | 1517 call.GetDocumentation() |
1516 .SetTag("Networking") | 1518 .SetTag("Networking") |
1517 .SetSummary("Trigger C-MOVE SCU") | 1519 .SetSummary("Trigger C-MOVE SCU") |
1518 .SetDescription("Start a C-MOVE SCU command as a job, in order to drive the execution of a sequence of " | 1520 .SetDescription("Start a C-MOVE SCU command as a job, in order to drive the execution of a sequence of " |
1519 "C-STORE commands by some remote DICOM modality whose identifier is provided in the URL: " | 1521 "C-STORE commands by some remote DICOM modality whose identifier is provided in the URL: " |
1558 | 1560 |
1559 const RemoteModalityParameters source = | 1561 const RemoteModalityParameters source = |
1560 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); | 1562 MyGetModalityUsingSymbolicName(call.GetUriComponent("id", "")); |
1561 | 1563 |
1562 DicomAssociationParameters params(localAet, source); | 1564 DicomAssociationParameters params(localAet, source); |
1563 InjectAssociationTimeout(params, request); | 1565 InjectAssociationTimeout(params, request); // Handles KEY_TIMEOUT |
1564 | 1566 |
1565 DicomControlUserConnection connection(params); | 1567 DicomControlUserConnection connection(params); |
1566 | 1568 |
1567 for (Json::Value::ArrayIndex i = 0; i < request[KEY_RESOURCES].size(); i++) | 1569 for (Json::Value::ArrayIndex i = 0; i < request[KEY_RESOURCES].size(); i++) |
1568 { | 1570 { |
2126 | 2128 |
2127 static void DicomFindWorklist(RestApiPostCall& call) | 2129 static void DicomFindWorklist(RestApiPostCall& call) |
2128 { | 2130 { |
2129 if (call.IsDocumentation()) | 2131 if (call.IsDocumentation()) |
2130 { | 2132 { |
2133 OrthancRestApi::DocumentDicomFormat(call, DicomToJsonFormat_Human); | |
2134 | |
2131 call.GetDocumentation() | 2135 call.GetDocumentation() |
2132 .SetTag("Networking") | 2136 .SetTag("Networking") |
2133 .SetSummary("C-FIND SCU for worklist") | 2137 .SetSummary("C-FIND SCU for worklist") |
2134 .SetDescription("Trigger C-FIND SCU command against the remote worklists of the DICOM modality " | 2138 .SetDescription("Trigger C-FIND SCU command against the remote worklists of the DICOM modality " |
2135 "whose identifier is provided in URL") | 2139 "whose identifier is provided in URL") |
2136 .SetUriArgument("id", "Identifier of the modality of interest") | 2140 .SetUriArgument("id", "Identifier of the modality of interest") |
2137 .AddRequestType(MimeType_Json, "Associative array containing the query on the values of the DICOM tags") | 2141 .SetRequestField(KEY_QUERY, RestApiCallDocumentation::Type_JsonObject, |
2142 "Associative array containing the filter on the values of the DICOM tags", true) | |
2138 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching worklists"); | 2143 .AddAnswerType(MimeType_Json, "JSON array describing the DICOM tags of the matching worklists"); |
2139 return; | 2144 return; |
2140 } | 2145 } |
2141 | 2146 |
2142 Json::Value json; | 2147 Json::Value json; |
2143 if (call.ParseJsonRequest(json)) | 2148 if (call.ParseJsonRequest(json)) |
2144 { | 2149 { |
2145 std::unique_ptr<ParsedDicomFile> query | 2150 std::unique_ptr<ParsedDicomFile> query; |
2146 (ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(0), | 2151 DicomToJsonFormat format; |
2147 "" /* no private creator */)); | 2152 |
2153 if (json.isMember(KEY_QUERY)) | |
2154 { | |
2155 // New in Orthanc 1.9.5 | |
2156 query.reset(ParsedDicomFile::CreateFromJson(json[KEY_QUERY], static_cast<DicomFromJsonFlags>(0), | |
2157 "" /* no private creator */)); | |
2158 format = OrthancRestApi::GetDicomFormat(json, DicomToJsonFormat_Human); | |
2159 } | |
2160 else | |
2161 { | |
2162 // Compatibility with Orthanc <= 1.9.4 | |
2163 query.reset(ParsedDicomFile::CreateFromJson(json, static_cast<DicomFromJsonFlags>(0), | |
2164 "" /* no private creator */)); | |
2165 format = DicomToJsonFormat_Human; | |
2166 } | |
2148 | 2167 |
2149 DicomFindAnswers answers(true); | 2168 DicomFindAnswers answers(true); |
2150 | 2169 |
2151 { | 2170 { |
2152 DicomControlUserConnection connection(GetAssociationParameters(call, json)); | 2171 DicomControlUserConnection connection(GetAssociationParameters(call, json)); |
2153 connection.FindWorklist(answers, *query); | 2172 connection.FindWorklist(answers, *query); |
2154 } | 2173 } |
2155 | 2174 |
2156 Json::Value result; | 2175 Json::Value result; |
2157 answers.ToJson(result, true); | 2176 answers.ToJson(result, format); |
2158 call.GetOutput().AnswerJson(result); | 2177 call.GetOutput().AnswerJson(result); |
2159 } | 2178 } |
2160 else | 2179 else |
2161 { | 2180 { |
2162 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object"); | 2181 throw OrthancException(ErrorCode_BadFileFormat, "Must provide a JSON object"); |