changeset 2422:b340f0a9022c

New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 08 Oct 2017 11:46:56 +0200
parents d0fe5ec7eb05
children 5a7c5c541a1d
files Core/DicomParsing/DicomDirWriter.cpp Core/DicomParsing/DicomDirWriter.h NEWS OrthancServer/OrthancRestApi/OrthancRestArchive.cpp
diffstat 4 files changed, 58 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomParsing/DicomDirWriter.cpp	Sun Oct 08 11:13:56 2017 +0200
+++ b/Core/DicomParsing/DicomDirWriter.cpp	Sun Oct 08 11:46:56 2017 +0200
@@ -128,8 +128,9 @@
   class DicomDirWriter::PImpl
   {
   private:
-    std::string fileSetId_;
-    TemporaryFile file_;
+    std::string                fileSetId_;
+    bool                       extendedSopClass_;
+    TemporaryFile              file_;
     std::auto_ptr<DcmDicomDir> dir_;
 
     typedef std::pair<ResourceType, std::string>  IndexKey;
@@ -257,8 +258,26 @@
 
 
   public:
-    PImpl() : fileSetId_("ORTHANC_MEDIA")
+    PImpl() :
+      fileSetId_("ORTHANC_MEDIA"),
+      extendedSopClass_(false)
+    {
+    }
+
+    void EnableExtendedSopClass(bool enable)
     {
+      if (enable)
+      {
+        LOG(WARNING) << "Generating a DICOMDIR with type 3 attributes, "
+                     << "which leads to an Extended SOP Class";
+      }
+      
+      extendedSopClass_ = enable;
+    }
+
+    bool IsExtendedSopClass() const
+    {
+      return extendedSopClass_;
     }
 
     void FillPatient(DcmDirectoryRecord& record,
@@ -319,6 +338,14 @@
       CopyStringType1(record, dicom, encoding, DCM_SeriesInstanceUID);
       /* use type 1C instead of 1 in order to avoid unwanted overwriting */
       CopyStringType1C(record, dicom, encoding, DCM_SeriesNumber);
+
+      // Add extended (non-standard) type 3 tags, those are not generated by DCMTK
+      // http://dicom.nema.org/medical/Dicom/2016a/output/chtml/part02/sect_7.3.html
+      // https://groups.google.com/d/msg/orthanc-users/Y7LOvZMDeoc/9cp3kDgxAwAJ
+      if (extendedSopClass_)
+      {
+        CopyStringType3(record, dicom, encoding, DCM_SeriesDescription);
+      }
     }
 
     void FillInstance(DcmDirectoryRecord& record,
@@ -522,4 +549,16 @@
   {
     pimpl_->Read(target);
   }
+
+
+  void DicomDirWriter::EnableExtendedSopClass(bool enable)
+  {
+    pimpl_->EnableExtendedSopClass(enable);
+  }
+
+  
+  bool DicomDirWriter::IsExtendedSopClass() const
+  {
+    return pimpl_->IsExtendedSopClass();
+  }
 }
--- a/Core/DicomParsing/DicomDirWriter.h	Sun Oct 08 11:13:56 2017 +0200
+++ b/Core/DicomParsing/DicomDirWriter.h	Sun Oct 08 11:46:56 2017 +0200
@@ -57,6 +57,10 @@
              ParsedDicomFile& dicom);
 
     void Encode(std::string& target);
+
+    void EnableExtendedSopClass(bool enable);
+
+    bool IsExtendedSopClass() const;
   };
 
 }
--- a/NEWS	Sun Oct 08 11:13:56 2017 +0200
+++ b/NEWS	Sun Oct 08 11:46:56 2017 +0200
@@ -6,6 +6,7 @@
 
 * New URI: "/instances/.../frames/.../raw.gz" to compress raw frames using gzip
 * New argument "ignore-length" to force the inclusion of too long tags in JSON
+* New argument "/.../media?extended" to include additional type-3 tags in DICOMDIR
 
 Maintenance
 -----------
--- a/OrthancServer/OrthancRestApi/OrthancRestArchive.cpp	Sun Oct 08 11:13:56 2017 +0200
+++ b/OrthancServer/OrthancRestApi/OrthancRestArchive.cpp	Sun Oct 08 11:46:56 2017 +0200
@@ -625,7 +625,8 @@
       static void Apply(RestApiOutput& output,
                         ServerContext& context,
                         ArchiveIndex& archive,
-                        const std::string& filename)
+                        const std::string& filename,
+                        bool enableExtendedSopClass)
       {
         archive.Expand(context.GetIndex());
 
@@ -643,10 +644,12 @@
           writer.SetZip64(isZip64);
           writer.OpenDirectory("IMAGES");
 
-          // Create the DICOMDIR writer
-          DicomDirWriter dicomDir;
+          // Create a DICOMDIR writer
+          MediaWriterVisitor v(writer, context);
 
-          MediaWriterVisitor v(writer, context);
+          // Request type-3 arguments to be added to the DICOMDIR
+          v.dicomDir_.EnableExtendedSopClass(enableExtendedSopClass);
+
           archive.Apply(v);
 
           // Add the DICOMDIR
@@ -723,7 +726,8 @@
       MediaWriterVisitor::Apply(call.GetOutput(),
                                 OrthancRestApi::GetContext(call),
                                 archive,
-                                "Archive.zip");
+                                "Archive.zip",
+                                false);
     }
   }  
 
@@ -758,7 +762,8 @@
     MediaWriterVisitor::Apply(call.GetOutput(),
                               OrthancRestApi::GetContext(call),
                               archive,
-                              id + ".zip");
+                              id + ".zip",
+                              call.HasArgument("extended"));
   }