diff OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp @ 5299:c9ea57d73603 am-experimental

New URI /instances/{id}/file-until-pixel-data
author Alain Mazy <am@osimis.io>
date Tue, 23 May 2023 17:38:26 +0200
parents c04230962098
children
line wrap: on
line diff
--- a/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Fri Apr 28 10:42:27 2023 +0200
+++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestResources.cpp	Tue May 23 17:38:26 2023 +0200
@@ -421,6 +421,30 @@
   }
 
 
+  static void GetInstanceFileUntiPixelData(RestApiGetCall& call)
+  {
+    if (call.IsDocumentation())
+    {
+      call.GetDocumentation()
+        .SetTag("Instances")
+        .SetSummary("Download DICOM Header (without the pixel data)")
+        .SetDescription("Download one DICOM instance header")
+        .SetUriArgument("id", "Orthanc identifier of the DICOM instance of interest")
+        .SetHttpHeader("Accept", "This HTTP header can be set to retrieve the DICOM instance in DICOMweb format")
+        .AddAnswerType(MimeType_Dicom, "The DICOM instance");
+      return;
+    }
+
+    ServerContext& context = OrthancRestApi::GetContext(call);
+
+    std::string publicId = call.GetUriComponent("id", "");
+
+    std::string buffer;
+    context.ReadDicomUntilPixelData(buffer, publicId);
+    call.GetOutput().AnswerBuffer(buffer, MimeType_Binary);
+  }
+
+
   static void ExportInstanceFile(RestApiPostCall& call)
   {
     if (call.IsDocumentation())
@@ -4011,6 +4035,7 @@
     Register("/studies/{id}/module-patient", GetModule<ResourceType_Study, DicomModule_Patient>);
 
     Register("/instances/{id}/file", GetInstanceFile);
+    Register("/instances/{id}/file-until-pixel-data", GetInstanceFileUntiPixelData);
     Register("/instances/{id}/export", ExportInstanceFile);
     Register("/instances/{id}/tags", GetInstanceTags);
     Register("/instances/{id}/simplified-tags", GetInstanceSimplifiedTags);