Mercurial > hg > orthanc
diff OrthancServer/OrthancRestApi/OrthancRestResources.cpp @ 1831:3ae2ff249675
"/instances/.../header" to get the meta information (header) of the DICOM instance
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 26 Nov 2015 18:53:00 +0100 |
parents | ac5b0b4e2434 |
children | 559956d5ceb2 |
line wrap: on
line diff
--- a/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Thu Nov 26 15:56:32 2015 +0100 +++ b/OrthancServer/OrthancRestApi/OrthancRestResources.cpp Thu Nov 26 18:53:00 2015 +0100 @@ -1275,6 +1275,34 @@ } + static void GetInstanceHeader(RestApiGetCall& call) + { + ServerContext& context = OrthancRestApi::GetContext(call); + + std::string publicId = call.GetUriComponent("id", ""); + bool simplify = call.HasArgument("simplify"); + + std::string dicomContent; + context.ReadFile(dicomContent, publicId, FileContentType_Dicom); + + ParsedDicomFile dicom(dicomContent); + + Json::Value header; + dicom.HeaderToJson(header, DicomToJsonFormat_Full); + + if (simplify) + { + Json::Value simplified; + Toolbox::SimplifyTags(simplified, header); + call.GetOutput().AnswerJson(simplified); + } + else + { + call.GetOutput().AnswerJson(header); + } + } + + void OrthancRestApi::RegisterResources() { Register("/instances", ListResources<ResourceType_Instance>); @@ -1323,6 +1351,7 @@ Register("/instances/{id}/image-uint16", GetImage<ImageExtractionMode_UInt16>); Register("/instances/{id}/image-int16", GetImage<ImageExtractionMode_Int16>); Register("/instances/{id}/matlab", GetMatlabImage); + Register("/instances/{id}/header", GetInstanceHeader); Register("/patients/{id}/protected", IsProtectedPatient); Register("/patients/{id}/protected", SetPatientProtection);