From: jpr Date: Wed, 9 Mar 2005 19:29:38 +0000 (+0000) Subject: Add Anonymize method (not yet fully checked) X-Git-Tag: Version1.2.bp~827 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=9eb68526a6b9dbcb217a679cd4764b1e4fa63c01;p=gdcm.git Add Anonymize method (not yet fully checked) --- diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index 3617ea1f..91458171 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -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; } diff --git a/src/gdcmDicomDir.h b/src/gdcmDicomDir.h index 656d949a..ea93005a 100644 --- a/src/gdcmDicomDir.h +++ b/src/gdcmDicomDir.h @@ -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 {