Mercurial > hg > orthanc
comparison OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp @ 4936:8422e4f99a18 more-tags
Handling RequestedTags in ExpandResource -> read parent main dicom tags if required. Not yet getting missing tags from file. Integration tests ok
author | Alain Mazy <am@osimis.io> |
---|---|
date | Fri, 11 Mar 2022 17:38:16 +0100 |
parents | 6eff25f70121 |
children | f2dcdbe05884 |
comparison
equal
deleted
inserted
replaced
4935:acd3f72e2a21 | 4936:8422e4f99a18 |
---|---|
26 #include "../../../OrthancFramework/Sources/Compression/GzipCompressor.h" | 26 #include "../../../OrthancFramework/Sources/Compression/GzipCompressor.h" |
27 #include "../../../OrthancFramework/Sources/Compression/ZipReader.h" | 27 #include "../../../OrthancFramework/Sources/Compression/ZipReader.h" |
28 #include "../../../OrthancFramework/Sources/Logging.h" | 28 #include "../../../OrthancFramework/Sources/Logging.h" |
29 #include "../../../OrthancFramework/Sources/MetricsRegistry.h" | 29 #include "../../../OrthancFramework/Sources/MetricsRegistry.h" |
30 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" | 30 #include "../../../OrthancFramework/Sources/SerializationToolbox.h" |
31 #include "../../../OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.h" | |
31 #include "../OrthancConfiguration.h" | 32 #include "../OrthancConfiguration.h" |
32 #include "../ServerContext.h" | 33 #include "../ServerContext.h" |
33 | 34 |
34 #include <boost/algorithm/string/predicate.hpp> | 35 #include <boost/algorithm/string/predicate.hpp> |
35 | 36 |
461 | 462 |
462 | 463 |
463 static const std::string GET_SIMPLIFY = "simplify"; | 464 static const std::string GET_SIMPLIFY = "simplify"; |
464 static const std::string GET_FULL = "full"; | 465 static const std::string GET_FULL = "full"; |
465 static const std::string GET_SHORT = "short"; | 466 static const std::string GET_SHORT = "short"; |
467 static const std::string GET_REQUESTED_TAGS = "requestedTags"; | |
466 | 468 |
467 static const std::string POST_SIMPLIFY = "Simplify"; | 469 static const std::string POST_SIMPLIFY = "Simplify"; |
468 static const std::string POST_FULL = "Full"; | 470 static const std::string POST_FULL = "Full"; |
469 static const std::string POST_SHORT = "Short"; | 471 static const std::string POST_SHORT = "Short"; |
472 static const std::string POST_REQUESTED_TAGS = "RequestedTags"; | |
470 | 473 |
471 static const std::string DOCUMENT_SIMPLIFY = | 474 static const std::string DOCUMENT_SIMPLIFY = |
472 "report the DICOM tags in human-readable format (using the symbolic name of the tags)"; | 475 "report the DICOM tags in human-readable format (using the symbolic name of the tags)"; |
473 | 476 |
474 static const std::string DOCUMENT_SHORT = | 477 static const std::string DOCUMENT_SHORT = |
523 { | 526 { |
524 return defaultFormat; | 527 return defaultFormat; |
525 } | 528 } |
526 } | 529 } |
527 | 530 |
528 | |
529 void OrthancRestApi::DocumentDicomFormat(RestApiGetCall& call, | 531 void OrthancRestApi::DocumentDicomFormat(RestApiGetCall& call, |
530 DicomToJsonFormat defaultFormat) | 532 DicomToJsonFormat defaultFormat) |
531 { | 533 { |
532 if (defaultFormat != DicomToJsonFormat_Human) | 534 if (defaultFormat != DicomToJsonFormat_Human) |
533 { | 535 { |
568 { | 570 { |
569 call.GetDocumentation().SetRequestField(POST_FULL, RestApiCallDocumentation::Type_Boolean, | 571 call.GetDocumentation().SetRequestField(POST_FULL, RestApiCallDocumentation::Type_Boolean, |
570 "If set to `true`, " + DOCUMENT_FULL, false); | 572 "If set to `true`, " + DOCUMENT_FULL, false); |
571 } | 573 } |
572 } | 574 } |
575 | |
576 void OrthancRestApi::GetRequestedTags(std::set<DicomTag>& requestedTags, | |
577 const RestApiGetCall& call) | |
578 { | |
579 requestedTags.clear(); | |
580 | |
581 if (call.HasArgument(GET_REQUESTED_TAGS)) | |
582 { | |
583 try | |
584 { | |
585 FromDcmtkBridge::ParseListOfTags(requestedTags, call.GetArgument("requestedTags", "")); | |
586 } | |
587 catch (OrthancException& ex) | |
588 { | |
589 throw OrthancException(ErrorCode_BadRequest, std::string("Invalid requestedTags argument: ") + ex.What() + " " + ex.GetDetails()); | |
590 } | |
591 } | |
592 | |
593 } | |
594 | |
595 void OrthancRestApi::DocumentRequestedTags(RestApiGetCall& call) | |
596 { | |
597 call.GetDocumentation().SetHttpGetArgument(GET_REQUESTED_TAGS, RestApiCallDocumentation::Type_String, | |
598 "If present, list the DICOM Tags you want to list in the response. This argument is a semi-column separated list " | |
599 "of DICOM Tags identifiers; e.g: 'requestedTags=0010,0010;PatientBirthDate'. " | |
600 "The tags requested tags are returned in the 'RequestedTags' field in the response. " | |
601 "Note that, if you are requesting tags that are not listed in the Main Dicom Tags stored in DB, building the response " | |
602 "might be slow since Orthanc will need to access the DICOM files. If not specified, Orthanc will return ", false); | |
603 } | |
604 | |
573 } | 605 } |