changeset 303:c76a35a85c69

ready for anonymization
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 18 Dec 2012 19:01:01 +0100
parents 238134081136
children 4eea080e6e7a
files Core/DicomFormat/DicomTag.h OrthancServer/FromDcmtkBridge.cpp OrthancServer/OrthancRestApi.cpp
diffstat 3 files changed, 29 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/Core/DicomFormat/DicomTag.h	Tue Dec 18 17:29:30 2012 +0100
+++ b/Core/DicomFormat/DicomTag.h	Tue Dec 18 19:01:01 2012 +0100
@@ -100,4 +100,9 @@
   static const DicomTag DICOM_TAG_IMAGES_IN_ACQUISITION(0x0020, 0x1002);
 
   static const DicomTag DICOM_TAG_PATIENT_NAME(0x0010, 0x0010);
+
+  // The following is used for "modify" operations
+  static const DicomTag DICOM_TAG_SOP_CLASS_UID(0x0008, 0x0016);
+  static const DicomTag DICOM_TAG_MEDIA_STORAGE_SOP_CLASS_UID(0x0002, 0x0002);
+  static const DicomTag DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID(0x0002, 0x0003);
 }
--- a/OrthancServer/FromDcmtkBridge.cpp	Tue Dec 18 17:29:30 2012 +0100
+++ b/OrthancServer/FromDcmtkBridge.cpp	Tue Dec 18 19:01:01 2012 +0100
@@ -616,6 +616,21 @@
     {
       FillElementWithString(*element, tag, value);
     }
+
+
+    /**
+     * dcmodify will automatically correct 'Media Storage SOP Class
+     * UID' and 'Media Storage SOP Instance UID' in the metaheader, if
+     * you make changes to the related tags in the dataset ('SOP Class
+     * UID' and 'SOP Instance UID') via insert or modify mode
+     * options. You can disable this behaviour by using the -nmu
+     * option.
+     **/
+    if (tag == DICOM_TAG_SOP_CLASS_UID)
+      ReplaceInternal(DICOM_TAG_MEDIA_STORAGE_SOP_CLASS_UID, value, true);
+
+    if (tag == DICOM_TAG_SOP_INSTANCE_UID)
+      ReplaceInternal(DICOM_TAG_MEDIA_STORAGE_SOP_INSTANCE_UID, value, true);
   }
 
     
--- a/OrthancServer/OrthancRestApi.cpp	Tue Dec 18 17:29:30 2012 +0100
+++ b/OrthancServer/OrthancRestApi.cpp	Tue Dec 18 19:01:01 2012 +0100
@@ -882,8 +882,16 @@
     
     std::auto_ptr<ParsedDicomFile> modified(dicom.Clone());
 
+    std::string studyUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Study);
+    std::string seriesUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Series);
+    std::string instanceUid = FromDcmtkBridge::GenerateUniqueIdentifier(DicomRootLevel_Instance);
+
+    modified->Replace(DICOM_TAG_SOP_INSTANCE_UID, instanceUid);
+    modified->Replace(DICOM_TAG_SERIES_INSTANCE_UID, seriesUid);
+    modified->Replace(DICOM_TAG_STUDY_INSTANCE_UID, studyUid);
+
     modified->InsertOrReplace(DicomTag(0x0010,0x0010), "0.42");
-    modified->Remove(DicomTag(0x0010,0x0020));
+    //modified->Remove(DicomTag(0x0010,0x0020));
     /*modified->Insert(DicomTag(0x0018,0x9082), "0.42");
       modified->Replace(DicomTag(0x0010,0x0010), "Hello");*/
     modified->Answer(call.GetOutput());