# HG changeset patch # User Sebastien Jodogne # Date 1561197698 -7200 # Node ID 9257352fbcf9f433a3e683240aa98a4930657260 # Parent 487fca2fa5e29791e1c269330c55d6ad1958d747 Retrieve Rendered Transaction for frames, fixes issue #6 diff -r 487fca2fa5e2 -r 9257352fbcf9 NEWS --- a/NEWS Sat Jun 22 11:17:30 2019 +0200 +++ b/NEWS Sat Jun 22 12:01:38 2019 +0200 @@ -12,7 +12,7 @@ * Handling of the HTTP header "Forwarded" for WADO-RS * New URI: /dicom-web/servers/.../qido * New URI: /dicom-web/servers/.../delete -* Basic implementation of WADO-RS "Retrieve rendered instance" +* First implementation of WADO-RS "Retrieve Rendered Transaction" Version 0.6 (2019-02-27) diff -r 487fca2fa5e2 -r 9257352fbcf9 Plugin/Plugin.cpp --- a/Plugin/Plugin.cpp Sat Jun 22 11:17:30 2019 +0200 +++ b/Plugin/Plugin.cpp Sat Jun 22 12:01:38 2019 +0200 @@ -32,6 +32,8 @@ #include +#include + bool RequestHasKey(const OrthancPluginHttpRequest* request, const char* key) { @@ -386,9 +388,10 @@ -void RetrieveInstanceRendered(OrthancPluginRestOutput* output, - const char* url, - const OrthancPluginHttpRequest* request) + +static void AnswerFrameRendered(OrthancPluginRestOutput* output, + int frame, + const OrthancPluginHttpRequest* request) { OrthancPluginContext* context = OrthancPlugins::GetGlobalContext(); @@ -398,16 +401,41 @@ } else { - Orthanc::MimeType mime = Orthanc::MimeType_Jpeg; - - std::string publicId; - if (LocateInstance(output, publicId, request)) + std::string instanceId; + if (LocateInstance(output, instanceId, request)) { + Orthanc::MimeType mime = Orthanc::MimeType_Jpeg; // This is the default in DICOMweb + + for (uint32_t i = 0; i < request->headersCount; i++) + { + if (boost::iequals(request->headersKeys[i], "Accept") && + !boost::iequals(request->headersValues[i], "*/*")) + { + try + { + // TODO - Support conversion to GIF + + mime = Orthanc::StringToMimeType(request->headersValues[i]); + if (mime != Orthanc::MimeType_Png && + mime != Orthanc::MimeType_Jpeg) + { + throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); + } + } + catch (Orthanc::OrthancException&) + { + LOG(ERROR) << "Unsupported MIME type in WADO-RS rendered frame: " << request->headersValues[i]; + throw; + } + } + } + std::map headers; headers["Accept"] = Orthanc::EnumerationToString(mime); - + OrthancPlugins::MemoryBuffer buffer; - if (buffer.RestApiGet("/instances/" + publicId + "/preview", headers, false)) + if (buffer.RestApiGet("/instances/" + instanceId + "/frames/" + + boost::lexical_cast(frame) + "/preview", headers, false)) { OrthancPluginAnswerBuffer(context, output, buffer.GetData(), buffer.GetSize(), Orthanc::EnumerationToString(mime)); @@ -417,6 +445,25 @@ } +void RetrieveInstanceRendered(OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request) +{ + AnswerFrameRendered(output, 0, request); +} + + +void RetrieveFrameRendered(OrthancPluginRestOutput* output, + const char* url, + const OrthancPluginHttpRequest* request) +{ + assert(request->groupsCount == 4); + const char* frame = request->groups[3]; + + AnswerFrameRendered(output, boost::lexical_cast(frame), request); +} + + @@ -562,6 +609,7 @@ OrthancPlugins::RegisterRestCallback(root + "info", true); OrthancPlugins::RegisterRestCallback(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/rendered", true); + OrthancPlugins::RegisterRestCallback(root + "studies/([^/]*)/series/([^/]*)/instances/([^/]*)/frames/([^/]*)/rendered", true); // Extend the default Orthanc Explorer with custom JavaScript for STOW client diff -r 487fca2fa5e2 -r 9257352fbcf9 Status.txt --- a/Status.txt Sat Jun 22 11:17:30 2019 +0200 +++ b/Status.txt Sat Jun 22 12:01:38 2019 +0200 @@ -1,4 +1,4 @@ -Reference: http://medical.nema.org/medical/dicom/current/output/html/part18.html +Reference: http://dicom.nema.org/MEDICAL/dicom/2019a/output/html/part18.html @@ -86,7 +86,19 @@ 6.5.8 WADO-RS / RetrieveRenderedTransaction =========================================== -Not supported yet. +http://dicom.nema.org/MEDICAL/dicom/2019a/output/chtml/part18/sect_6.5.8.html + +Supported +--------- + +* Single-frame and multi-frame retrieval +* JPEG and PNG output + +Not supported +------------- + +* GIF output +* None of the "Retrieve Rendered Query Parameters" (table 6.5.8-2)