changeset 3158:b6e7714c3fe6

Don't return tags whose group is below 0x0008 in C-FIND SCP
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 23 Jan 2019 14:23:10 +0100
parents 8a9eb767280c
children fc9a4a2dad63
files Core/DicomNetworking/DicomFindAnswers.cpp NEWS
diffstat 2 files changed, 30 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomNetworking/DicomFindAnswers.cpp	Wed Jan 23 09:32:59 2019 +0100
+++ b/Core/DicomNetworking/DicomFindAnswers.cpp	Wed Jan 23 14:23:10 2019 +0100
@@ -150,7 +150,35 @@
 
   DcmDataset* DicomFindAnswers::ExtractDcmDataset(size_t index) const
   {
-    return new DcmDataset(*GetAnswer(index).GetDcmtkObject().getDataset());
+    // As "DicomFindAnswers" stores its content using class
+    // "ParsedDicomFile" (that internally uses "DcmFileFormat" from
+    // DCMTK), the dataset can contain tags that are reserved if
+    // storing the media on the disk, notably tag
+    // "MediaStorageSOPClassUID" (0002,0002). In this function, we
+    // remove all those tags whose group is below 0x0008. The
+    // resulting data set is clean for emission in the C-FIND SCP.
+
+    // http://dicom.nema.org/medical/dicom/current/output/chtml/part04/sect_C.4.html#sect_C.4.1.1.3
+    // https://groups.google.com/d/msg/orthanc-users/D3kpPuX8yV0/_zgHOzkMEQAJ
+
+    DcmDataset& source = *GetAnswer(index).GetDcmtkObject().getDataset();
+
+    std::auto_ptr<DcmDataset> target(new DcmDataset);
+
+    for (unsigned long i = 0; i < source.card(); i++)
+    {
+      const DcmElement* element = source.getElement(i);
+      assert(element != NULL);
+
+      if (element != NULL &&
+          element->getTag().getGroup() >= 0x0008 &&
+          element->getTag().getElement() != 0x0000)
+      {
+        target->insert(dynamic_cast<DcmElement*>(element->clone()));
+      }
+    }
+    
+    return target.release();
   }
 
 
--- a/NEWS	Wed Jan 23 09:32:59 2019 +0100
+++ b/NEWS	Wed Jan 23 14:23:10 2019 +0100
@@ -3,6 +3,7 @@
 
 * Fix compatibility with DICOMweb plugin (allow multipart answers over HTTP Keep-Alive)
 * Fix issue #128 (Asynchronous C-MOVE: invalid number of remaining sub-operations)
+* Don't return tags whose group is below 0x0008 in C-FIND SCP
 
 
 Version 1.5.2 (2019-01-18)