Mercurial > hg > orthanc
changeset 2623:bd6e0b70e915 jobs
integration mainline->jobs
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 May 2018 14:28:25 +0200 |
parents | 83ac5a05ce84 (current diff) 3603a2e14592 (diff) |
children | 714dcddeb65f |
files | NEWS Plugins/Include/orthanc/OrthancCPlugin.h |
diffstat | 3 files changed, 68 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Tue May 22 17:37:16 2018 +0200 +++ b/NEWS Wed May 23 14:28:25 2018 +0200 @@ -15,11 +15,19 @@ -------- * "/jobs/..." to manage the jobs from the REST API -* ".../tags" URI was returning only the first value of DicomTags containing - multiple numerical value. It now returns all values in a string separated - by \\ (i.e.: "1\\2\\3"). Note that, for data already in Orthanc, you'll need - to reconstruct the data by sending a POST request to the ".../reconstruct" URI. - This change triggered an update of ORTHANC_API_VERSION from 1.0 to 1.1 +* New option "?short" to list DICOM tags using their hexadecimal ID in: + - "/instances/.../tags?short" + - "/instances/.../header?short" + - "/{patients|studies|series}/.../instances-tags?short" + - "/{patients|studies|series}/.../shared-tags?short" + - "/{patients|studies|series|instances}/.../module?short" + - "/studies/.../module-patient?short" +* "/instances/.../tags" URI was returning only the first value of + DicomTags containing multiple numerical value. It now returns all + values in a string separated by \\ (i.e.: "1\\2\\3"). Note that, + for data already in Orthanc, you'll need to reconstruct the data by + sending a POST request to the ".../reconstruct" URI. This change + triggered an update of ORTHANC_API_VERSION from 1.0 to 1.1 Maintenance -----------
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Tue May 22 17:37:16 2018 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Wed May 23 14:28:25 2018 +0200 @@ -50,12 +50,12 @@ { static void AnswerDicomAsJson(RestApiCall& call, const Json::Value& dicom, - bool simplify) + DicomToJsonFormat mode) { - if (simplify) + if (mode != DicomToJsonFormat_Full) { Json::Value simplified; - ServerToolbox::SimplifyTags(simplified, dicom, DicomToJsonFormat_Human); + ServerToolbox::SimplifyTags(simplified, dicom, mode); call.GetOutput().AnswerJson(simplified); } else @@ -65,6 +65,30 @@ } + static DicomToJsonFormat GetDicomFormat(const RestApiGetCall& call) + { + if (call.HasArgument("simplify")) + { + return DicomToJsonFormat_Human; + } + else if (call.HasArgument("short")) + { + return DicomToJsonFormat_Short; + } + else + { + return DicomToJsonFormat_Full; + } + } + + + static void AnswerDicomAsJson(RestApiGetCall& call, + const Json::Value& dicom) + { + AnswerDicomAsJson(call, dicom, GetDicomFormat(call)); + } + + static void ParseSetOfTags(std::set<DicomTag>& target, const RestApiGetCall& call, const std::string& argument) @@ -236,7 +260,7 @@ } - template <bool simplify> + template <DicomToJsonFormat format> static void GetInstanceTags(RestApiGetCall& call) { ServerContext& context = OrthancRestApi::GetContext(call); @@ -246,18 +270,18 @@ std::set<DicomTag> ignoreTagLength; ParseSetOfTags(ignoreTagLength, call, "ignore-length"); - if (simplify || + if (format != DicomToJsonFormat_Full || !ignoreTagLength.empty()) { Json::Value full; context.ReadDicomAsJson(full, publicId, ignoreTagLength); - AnswerDicomAsJson(call, full, simplify); + AnswerDicomAsJson(call, full, format); } else { // This path allows to avoid the JSON decoding if no - // simplification is asked, or if no "ignore-length" argument is - // present + // simplification is asked, and if no "ignore-length" argument + // is present std::string full; context.ReadDicomAsJson(full, publicId); call.GetOutput().AnswerBuffer(full, "application/json"); @@ -267,15 +291,22 @@ static void GetInstanceTagsBis(RestApiGetCall& call) { - bool simplify = call.HasArgument("simplify"); - - if (simplify) + switch (GetDicomFormat(call)) { - GetInstanceTags<true>(call); - } - else - { - GetInstanceTags<false>(call); + case DicomToJsonFormat_Human: + GetInstanceTags<DicomToJsonFormat_Human>(call); + break; + + case DicomToJsonFormat_Short: + GetInstanceTags<DicomToJsonFormat_Short>(call); + break; + + case DicomToJsonFormat_Full: + GetInstanceTags<DicomToJsonFormat_Full>(call); + break; + + default: + throw OrthancException(ErrorCode_InternalError); } } @@ -1044,13 +1075,12 @@ { ServerContext& context = OrthancRestApi::GetContext(call); std::string publicId = call.GetUriComponent("id", ""); - bool simplify = call.HasArgument("simplify"); Json::Value sharedTags; if (ExtractSharedTags(sharedTags, context, publicId)) { // Success: Send the value of the shared tags - AnswerDicomAsJson(call, sharedTags, simplify); + AnswerDicomAsJson(call, sharedTags); } } @@ -1071,7 +1101,6 @@ ServerContext& context = OrthancRestApi::GetContext(call); std::string publicId = call.GetUriComponent("id", ""); - bool simplify = call.HasArgument("simplify"); std::set<DicomTag> ignoreTagLength; ParseSetOfTags(ignoreTagLength, call, "ignore-length"); @@ -1111,7 +1140,7 @@ } } - AnswerDicomAsJson(call, result, simplify); + AnswerDicomAsJson(call, result); } @@ -1306,7 +1335,7 @@ { ServerContext& context = OrthancRestApi::GetContext(call); std::string publicId = call.GetUriComponent("id", ""); - bool simplify = call.HasArgument("simplify"); + DicomToJsonFormat format = GetDicomFormat(call); std::set<DicomTag> ignoreTagLength; ParseSetOfTags(ignoreTagLength, call, "ignore-length"); @@ -1325,10 +1354,10 @@ Json::Value full; context.ReadDicomAsJson(full, *it, ignoreTagLength); - if (simplify) + if (format != DicomToJsonFormat_Full) { Json::Value simplified; - ServerToolbox::SimplifyTags(simplified, full, DicomToJsonFormat_Human); + ServerToolbox::SimplifyTags(simplified, full, format); result[*it] = simplified; } else @@ -1409,7 +1438,6 @@ ServerContext& context = OrthancRestApi::GetContext(call); std::string publicId = call.GetUriComponent("id", ""); - bool simplify = call.HasArgument("simplify"); std::string dicomContent; context.ReadDicom(dicomContent, publicId); @@ -1422,7 +1450,7 @@ Json::Value header; dicom.HeaderToJson(header, DicomToJsonFormat_Full); - AnswerDicomAsJson(call, header, simplify); + AnswerDicomAsJson(call, header); } @@ -1495,7 +1523,7 @@ Register("/instances/{id}/file", GetInstanceFile); Register("/instances/{id}/export", ExportInstanceFile); Register("/instances/{id}/tags", GetInstanceTagsBis); - Register("/instances/{id}/simplified-tags", GetInstanceTags<true>); + Register("/instances/{id}/simplified-tags", GetInstanceTags<DicomToJsonFormat_Human>); Register("/instances/{id}/frames", ListFrames); Register("/instances/{id}/frames/{frame}/preview", GetImage<ImageExtractionMode_Preview>);
--- a/Plugins/Include/orthanc/OrthancCPlugin.h Tue May 22 17:37:16 2018 +0200 +++ b/Plugins/Include/orthanc/OrthancCPlugin.h Wed May 23 14:28:25 2018 +0200 @@ -54,7 +54,7 @@ * @defgroup Callbacks Callbacks * @brief Functions to register and manage callbacks by the plugins. * - * @defgroup DicomCallbaks DicomCallbaks + * @defgroup DicomCallbacks DicomCallbacks * @brief Functions to register and manage DICOM callbacks (worklists, C-Find, C-MOVE). * * @defgroup Orthanc Orthanc