GDCM: gdcmAnonymizer.h Source File

GDCM 3.0.25

gdcmAnonymizer.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: GDCM (Grassroots DICOM). A DICOM library
4
5 Copyright (c) 2006-2011 Mathieu Malaterre
6 All rights reserved.
7 See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html for details.
8
9 This software is distributed WITHOUT ANY WARRANTY; without even
10 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 PURPOSE. See the above copyright notice for more information.
12
13=========================================================================*/
14#ifndef GDCMANONYMIZER_H
15#define GDCMANONYMIZER_H
16
17#include "gdcmFile.h"
18#include "gdcmSubject.h"
19#include "gdcmEvent.h"
20#include "gdcmSmartPointer.h"
21
22#include <map>
23
24namespace gdcm
25{
26class TagPath;
27class IOD;
28class CryptographicMessageSyntax;
29
77 class GDCM_EXPORT Anonymizer : public Subject
78{
79public:
80 Anonymizer():F(new File),CMS(nullptr) {}
81 ~Anonymizer() override;
82
84 bool Empty( Tag const &t );
85
90 bool Empty( PrivateTag const &pt );
91
93 bool Clear( Tag const &t );
94 bool Clear( PrivateTag const &pt );
95
97 bool Remove( Tag const &t );
98
104 bool Remove( PrivateTag const &pt );
105
108 bool Replace( Tag const &t, const char *value );
109 bool Replace( PrivateTag const &t, const char *value );
110
113 bool Replace( Tag const &t, const char *value, VL const & vl );
114 bool Replace( PrivateTag const &t, const char *value, VL const & vl );
115
117 bool RemovePrivateTags();
118
120 bool RemoveGroupLength();
121
123 bool RemoveRetired();
124
126 void SetFile(const File& f) { F = f; }
127 //const File &GetFile() const { return *F; }
128 File &GetFile() { return *F; }
129
134 bool BasicApplicationLevelConfidentialityProfile(bool deidentify = true);
135
137 void SetCryptographicMessageSyntax( CryptographicMessageSyntax *cms );
138 const CryptographicMessageSyntax *GetCryptographicMessageSyntax() const;
139
141 static SmartPointer<Anonymizer> New() { return new Anonymizer; }
142
144 static std::vector<Tag> GetBasicApplicationLevelConfidentialityProfileAttributes();
145
148 static void ClearInternalUIDs();
149
150protected:
151 // Internal function used to either empty a tag or set it's value to a dummy value (Type 1 vs Type 2)
152 bool BALCPProtect(DataSet &ds, Tag const & tag, const IOD &iod);
153 bool CanEmptyTag(Tag const &tag, const IOD &iod) const;
154 void RecurseDataSet( DataSet & ds );
155
156private:
157 bool BasicApplicationLevelConfidentialityProfile1();
158 bool BasicApplicationLevelConfidentialityProfile2();
159 bool CheckIfSequenceContainsAttributeToAnonymize(File const &file, SequenceOfItems* sqi) const;
160
161private:
162 // I would prefer to have a smart pointer to DataSet but DataSet does not derive from Object...
163 SmartPointer<File> F;
164 CryptographicMessageSyntax *CMS;
165
166 typedef std::pair< Tag, std::string > TagValueKey;
167 typedef std::map< TagValueKey, std::string > DummyMapNonUIDTags;
168 typedef std::map< std::string, std::string > DummyMapUIDTags;
169 static DummyMapNonUIDTags dummyMapNonUIDTags;
170 static DummyMapUIDTags dummyMapUIDTags;
171};
172
178
179} // end namespace gdcm
180
181#endif //GDCMANONYMIZER_H
gdcm::Anonymizer::RemoveRetired
bool RemoveRetired()
Main function that loop over all elements and remove retired element.
gdcm::Anonymizer::Remove
bool Remove(Tag const &t)
remove a tag (even a SQ can be removed)
gdcm::Anonymizer::RemovePrivateTags
bool RemovePrivateTags()
Main function that loop over all elements and remove private tags.
gdcm::Anonymizer::Empty
bool Empty(PrivateTag const &pt)
gdcm::Anonymizer::SetFile
void SetFile(const File &f)
Set/Get File.
Definition gdcmAnonymizer.h:126
gdcm::Anonymizer::RecurseDataSet
void RecurseDataSet(DataSet &ds)
gdcm::Anonymizer::Empty
bool Empty(Tag const &t)
Make Tag t empty (if not found tag will be created)
gdcm::Anonymizer::GetFile
File & GetFile()
Definition gdcmAnonymizer.h:128
gdcm::Anonymizer::Anonymizer
Anonymizer()
Definition gdcmAnonymizer.h:80
gdcm::Anonymizer::Clear
bool Clear(PrivateTag const &pt)
gdcm::Anonymizer::SetCryptographicMessageSyntax
void SetCryptographicMessageSyntax(CryptographicMessageSyntax *cms)
Set/Get CMS key that will be used to encrypt the dataset within BasicApplicationLevelConfidentialityP...
gdcm::Anonymizer::ClearInternalUIDs
static void ClearInternalUIDs()
gdcm::Anonymizer::BasicApplicationLevelConfidentialityProfile
bool BasicApplicationLevelConfidentialityProfile(bool deidentify=true)
gdcm::Anonymizer::BALCPProtect
bool BALCPProtect(DataSet &ds, Tag const &tag, const IOD &iod)
gdcm::Anonymizer::~Anonymizer
~Anonymizer() override
gdcm::Anonymizer::Replace
bool Replace(Tag const &t, const char *value)
gdcm::Anonymizer::Replace
bool Replace(PrivateTag const &t, const char *value, VL const &vl)
gdcm::Anonymizer::GetBasicApplicationLevelConfidentialityProfileAttributes
static std::vector< Tag > GetBasicApplicationLevelConfidentialityProfileAttributes()
Return the list of Tag that will be considered when anonymizing a DICOM file.
gdcm::Anonymizer::Replace
bool Replace(Tag const &t, const char *value, VL const &vl)
gdcm::Anonymizer::CanEmptyTag
bool CanEmptyTag(Tag const &tag, const IOD &iod) const
gdcm::Anonymizer::Replace
bool Replace(PrivateTag const &t, const char *value)
gdcm::Anonymizer::New
static SmartPointer< Anonymizer > New()
for wrapped language: instantiate a reference counted object
Definition gdcmAnonymizer.h:141
gdcm::Anonymizer::Clear
bool Clear(Tag const &t)
Identical to 'Empty' except no action is done when tag is not present.
gdcm::Anonymizer::Remove
bool Remove(PrivateTag const &pt)
gdcm::Anonymizer::GetCryptographicMessageSyntax
const CryptographicMessageSyntax * GetCryptographicMessageSyntax() const
gdcm::Anonymizer::RemoveGroupLength
bool RemoveGroupLength()
Main function that loop over all elements and remove group length.
gdcm::CryptographicMessageSyntax
Definition gdcmCryptographicMessageSyntax.h:23
gdcm::DataSet
Class to represent a Data Set (which contains Data Elements)
Definition gdcmDataSet.h:56
gdcm::File
a DICOM File
Definition gdcmFile.h:34
gdcm::IOD
Class for representing a IOD.
Definition gdcmIOD.h:35
gdcm::PrivateTag
Class to represent a Private DICOM Data Element (Attribute) Tag (Group, Element, Owner)
Definition gdcmPrivateTag.h:39
gdcm::SequenceOfItems
Class to represent a Sequence Of Items.
Definition gdcmSequenceOfItems.h:40
gdcm::SmartPointer
Class for Smart Pointer.
Definition gdcmSmartPointer.h:40
gdcm::Subject::Subject
Subject()
gdcm::TagPath
class to handle a path of tag.
Definition gdcmTagPath.h:31
gdcm::Tag
Class to represent a DICOM Data Element (Attribute) Tag (Group, Element).
Definition gdcmTag.h:39
gdcm::VL
Value Length.
Definition gdcmVL.h:30
gdcmEvent.h
gdcmFile.h
gdcmSmartPointer.h
gdcmSubject.h
GDCM_EXPORT
#define GDCM_EXPORT
Definition gdcmWin32.h:34
gdcm
Definition gdcmASN1.h:21