changeset 2189:c4b3259c8bce

New metadata automatically computed at the instance level: "TransferSyntax"
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 29 Nov 2016 16:07:14 +0100
parents 7cfc2e0383b3
children 3b9ee145f149
files Core/DicomFormat/DicomTag.h NEWS OrthancServer/DicomInstanceToStore.cpp OrthancServer/DicomInstanceToStore.h OrthancServer/ServerEnumerations.cpp OrthancServer/ServerEnumerations.h OrthancServer/ServerIndex.cpp
diffstat 7 files changed, 37 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomFormat/DicomTag.h	Tue Nov 29 15:39:46 2016 +0100
+++ b/Core/DicomFormat/DicomTag.h	Tue Nov 29 16:07:14 2016 +0100
@@ -100,6 +100,7 @@
   static const DicomTag DICOM_TAG_SERIES_INSTANCE_UID(0x0020, 0x000e);
   static const DicomTag DICOM_TAG_STUDY_INSTANCE_UID(0x0020, 0x000d);
   static const DicomTag DICOM_TAG_PIXEL_DATA(0x7fe0, 0x0010);
+  static const DicomTag DICOM_TAG_TRANSFER_SYNTAX_UID(0x0002, 0x0010);
 
   static const DicomTag DICOM_TAG_IMAGE_INDEX(0x0054, 0x1330);
   static const DicomTag DICOM_TAG_INSTANCE_NUMBER(0x0020, 0x0013);
--- a/NEWS	Tue Nov 29 15:39:46 2016 +0100
+++ b/NEWS	Tue Nov 29 16:07:14 2016 +0100
@@ -6,6 +6,7 @@
 
 * Handling of private tags/creators in the "Dictionary" configuration option
 * New configuration options: "LoadPrivateDictionary", "DicomScuTimeout" and "DicomScpTimeout"
+* New metadata automatically computed at the instance level: "TransferSyntax"
 
 REST API
 --------
--- a/OrthancServer/DicomInstanceToStore.cpp	Tue Nov 29 15:39:46 2016 +0100
+++ b/OrthancServer/DicomInstanceToStore.cpp	Tue Nov 29 16:07:14 2016 +0100
@@ -38,6 +38,7 @@
 #include "../Core/Logging.h"
 
 #include <dcmtk/dcmdata/dcfilefo.h>
+#include <dcmtk/dcmdata/dcdeftag.h>
 
 
 namespace Orthanc
@@ -270,4 +271,25 @@
       return "";
     }
   }
+
+
+  bool DicomInstanceToStore::LookupTransferSyntax(std::string& result)
+  {
+    ComputeMissingInformation();
+
+    DicomMap header;
+    if (DicomMap::ParseDicomMetaInformation(header, GetBufferData(), GetBufferSize()))
+    {
+      const DicomValue* value = header.TestAndGetValue(DICOM_TAG_TRANSFER_SYNTAX_UID);
+      if (value != NULL &&
+          !value->IsBinary() &&
+          !value->IsNull())
+      {
+        result = Toolbox::StripSpaces(value->GetContent());
+        return true;
+      }
+    }
+
+    return false;
+  }
 }
--- a/OrthancServer/DicomInstanceToStore.h	Tue Nov 29 15:39:46 2016 +0100
+++ b/OrthancServer/DicomInstanceToStore.h	Tue Nov 29 16:07:14 2016 +0100
@@ -221,5 +221,7 @@
     const Json::Value& GetJson();
 
     void GetOriginInformation(Json::Value& result) const;
+
+    bool LookupTransferSyntax(std::string& result);
   };
 }
--- a/OrthancServer/ServerEnumerations.cpp	Tue Nov 29 15:39:46 2016 +0100
+++ b/OrthancServer/ServerEnumerations.cpp	Tue Nov 29 16:07:14 2016 +0100
@@ -64,6 +64,7 @@
     dictMetadataType_.Add(MetadataType_AnonymizedFrom, "AnonymizedFrom");
     dictMetadataType_.Add(MetadataType_LastUpdate, "LastUpdate");
     dictMetadataType_.Add(MetadataType_Instance_Origin, "Origin");
+    dictMetadataType_.Add(MetadataType_Instance_TransferSyntax, "TransferSyntax");
 
     dictContentType_.Add(FileContentType_Dicom, "dicom");
     dictContentType_.Add(FileContentType_DicomAsJson, "dicom-as-json");
--- a/OrthancServer/ServerEnumerations.h	Tue Nov 29 15:39:46 2016 +0100
+++ b/OrthancServer/ServerEnumerations.h	Tue Nov 29 16:07:14 2016 +0100
@@ -157,7 +157,8 @@
     MetadataType_ModifiedFrom = 5,
     MetadataType_AnonymizedFrom = 6,
     MetadataType_LastUpdate = 7,
-    MetadataType_Instance_Origin = 8,   // New in Orthanc 0.9.5
+    MetadataType_Instance_Origin = 8,          // New in Orthanc 0.9.5
+    MetadataType_Instance_TransferSyntax = 9,  // New in Orthanc 1.2.0
 
     // Make sure that the value "65535" can be stored into this enumeration
     MetadataType_StartUser = 1024,
--- a/OrthancServer/ServerIndex.cpp	Tue Nov 29 15:39:46 2016 +0100
+++ b/OrthancServer/ServerIndex.cpp	Tue Nov 29 16:07:14 2016 +0100
@@ -775,10 +775,15 @@
       // reflecting these additions into the input metadata map
       SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_ReceptionDate, now);
       SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_RemoteAet, instanceToStore.GetRemoteAet());
-
+      SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_Origin, 
+                          EnumerationToString(instanceToStore.GetRequestOrigin()));
+        
       {
-        std::string s = EnumerationToString(instanceToStore.GetRequestOrigin());
-        SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_Origin, s);
+        std::string s;
+        if (instanceToStore.LookupTransferSyntax(s))
+        {
+          SetInstanceMetadata(instanceMetadata, instance, MetadataType_Instance_TransferSyntax, s);
+        }
       }
 
       const DicomValue* value;