]> Creatis software - gdcm.git/commitdiff
Add Anonymize method (not yet fully checked)
authorjpr <jpr>
Wed, 9 Mar 2005 19:29:38 +0000 (19:29 +0000)
committerjpr <jpr>
Wed, 9 Mar 2005 19:29:38 +0000 (19:29 +0000)
src/gdcmDicomDir.cxx
src/gdcmDicomDir.h

index 3617ea1faf17da0ef38c2471d46b7eb24982d27c..9145817176fed5f65f028c9f21af06b5c0dd2ffc 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/03/04 10:01:56 $
-  Version:   $Revision: 1.135 $
+  Date:      $Date: 2005/03/09 19:29:38 $
+  Version:   $Revision: 1.136 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -478,6 +478,44 @@ bool DicomDir::WriteDicomDir(std::string const &fileName)
    return true;
 }
 
+/**
+ * \brief    Anonymize a DICOMDIR
+ * @return true 
+ */
+bool DicomDir::AnonymizeDicomDir() 
+{
+   ValEntry *v;
+   // Something clever to be found to forge the Patient names
+   std::ostringstream s;
+   int i = 1;
+   for(ListDicomDirPatient::iterator cc = Patients.begin();
+                                     cc!= Patients.end();
+                                   ++cc)
+   {
+      s << i;
+      v = (*cc)->GetValEntry(0x0010, 0x0010) ; // Patient's Name
+      if (v)
+      {
+         v->SetValue(s.str());
+      }
+
+      v = (*cc)->GetValEntry(0x0010, 0x0020) ; // Patient ID
+      if (v)
+      {
+         v->SetValue(" ");
+      }
+
+      v = (*cc)->GetValEntry(0x0010, 0x0030) ; // Patient's BirthDate
+      if (v)
+      {
+         v->SetValue(" ");
+      }
+      s << "";
+      i++;
+   }
+   return true;
+}
 //-----------------------------------------------------------------------------
 // Protected
 /**
@@ -643,7 +681,7 @@ void DicomDir::CreateDicomDir()
       }
       else
       {
-         gdcmWarningMacro( "Not a ValEntry.");
+         gdcmWarningMacro( "(0004,1430) not a ValEntry ?!?");
          continue;
       }
 
index 656d949a3e768f59e977ed938e9733c251653fd3..ea93005a293eb66bd16c84b1738139ea9be69950 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDicomDir.h,v $
   Language:  C++
-  Date:      $Date: 2005/03/04 09:53:21 $
-  Version:   $Revision: 1.57 $
+  Date:      $Date: 2005/03/09 19:29:38 $
+  Version:   $Revision: 1.58 $
   
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -102,6 +102,8 @@ public:
    // Write
    bool WriteDicomDir(std::string const &fileName);
 
+   bool AnonymizeDicomDir();
+
    /// Types of the DicomDirObject within the DicomDir
    typedef enum
    {