# gdcm::Anonymizer Class Reference

Anonymizer This class is a multi purpose anonymizer. It can work in 2 mode:

- Full (irreversible) anonymizer (aka dumb mode)
- reversible de-identifier/re-identifier (aka smart mode). This implements the Basic Application Level Confidentiality Profile, DICOM PS 3.15-2009.

More...

`#include <gdcmAnonymizer.h>`

Inheritance diagram for gdcm::Anonymizer:
[legend]
Collaboration diagram for gdcm::Anonymizer:
[legend]

List of all members.

## Public Member Functions

| Anonymizer ()
| ~Anonymizer ()
bool | BasicApplicationLevelConfidentialityProfile (bool deidentify=true)
bool | Empty (Tag const &t)
const CryptographicMessageSyntax * | GetCryptographicMessageSyntax () const
File & | GetFile ()
bool | Remove (Tag const &t)
| remove a tag (even a SQ can be removed)
bool | RemoveGroupLength ()
| Main function that loop over all elements and remove group length.
bool | RemovePrivateTags ()
| Main function that loop over all elements and remove private tags.
bool | RemoveRetired ()
| Main function that loop over all elements and remove retired element.
bool | Replace (Tag const &t, const char *value, VL const &vl)
bool | Replace (Tag const &t, const char *value)
void | SetCryptographicMessageSyntax (CryptographicMessageSyntax *cms)
| Set/Get CMS key that will be used to encrypt the dataset within BasicApplicationLevelConfidentialityProfile.
void | SetFile (const File &f)
| Set/Get File.

## Static Public Member Functions

static std::vector< Tag > | GetBasicApplicationLevelConfidentialityProfileAttributes ()
| Return the list of Tag that will be considered when anonymizing a DICOM file.
static SmartPointer< Anonymizer > | New ()
| for wrapped language: instantiate a reference counted object

## Protected Member Functions

bool | BALCPProtect (DataSet &ds, Tag const &tag, const IOD &iod)
bool | CanEmptyTag (Tag const &tag, const IOD &iod) const
void | RecurseDataSet (DataSet &ds)

## Detailed Description

Anonymizer This class is a multi purpose anonymizer. It can work in 2 mode:

- Full (irreversible) anonymizer (aka dumb mode)
- reversible de-identifier/re-identifier (aka smart mode). This implements the Basic Application Level Confidentiality Profile, DICOM PS 3.15-2009.

1. dumb mode This is a dumb anonymizer implementation. All it allows user is simple operation such as:

Tag based functions:

- complete removal of DICOM attribute (Remove)
- make a tag empty, ie make it's length 0 (Empty)
- replace with another string-based value (Replace)

DataSet based functions:

- Remove all group length attribute from a DICOM dataset (Group Length element are deprecated, DICOM 2008)
- Remove all private attributes
- Remove all retired attributes

All function calls actually execute the user specified request. Previous implementation were calling a general Anonymize function but traversing a std::set is O(n) operation, while a simple user specified request is O(log(n)) operation. So 'm' user interaction is O(m*log(n)) which is < O(n) complexity.

2. smart mode this mode implements the Basic Application Level Confidentiality Profile (DICOM PS 3.15-2008) In this case, it is extremely important to use the same gdcm::Anonymizer class when anonymizing a FileSet. Once the gdcm::Anonymizer is destroyed its memory of known (already processed) UIDs will be lost. which will make the anonymizer behaves incorrectly for attributes such as Series UID Study UID where user want some consistency. When attribute is Type 1 / Type 1C, a dummy generator will take in the existing value and produce a dummy value (a sha1 representation). sha1 algorithm is considered to be cryptographically strong (compared to md5sum) so that we meet the following two conditions:

- Produce the same dummy value for the same input value
- do not provide an easy way to retrieve the original value from the sha1 generated value

This class implement the Subject/Observer pattern trigger the following event:

- AnonymizeEvent
- IterationEvent
- StartEvent
- EndEvent

See also:
  CryptographicMessageSyntax

Examples:

  ClinicalTrialAnnotate.cxx, and EncapsulateFileInRawData.cxx.

## Constructor & Destructor Documentation

gdcm::Anonymizer::Anonymizer | ( |  | ) | `[inline]`

gdcm::Anonymizer::~Anonymizer | ( |  | ) |

## Member Function Documentation

bool gdcm::Anonymizer::BALCPProtect | ( | DataSet & | ds,
|  | Tag const & | tag,
|  | const IOD & | iod
| ) |  | `[protected]`

bool gdcm::Anonymizer::BasicApplicationLevelConfidentialityProfile | ( | bool | deidentify = `true` | ) |

PS 3.15 / E.1.1 De-Identifier An Application may claim conformance to the Basic Application Level Confidentiality Profile as a deidentifier if it protects all Attributes that might be used by unauthorized entities to identify the patient. NOT THREAD SAFE

bool gdcm::Anonymizer::CanEmptyTag | ( | Tag const & | tag,
|  | const IOD & | iod
| ) |  | const`[protected]`

bool gdcm::Anonymizer::Empty | ( | Tag const & | t | ) |

Make Tag t empty (if not found tag will be created) Warning: does not handle SQ element

static std::vector<Tag> gdcm::Anonymizer::GetBasicApplicationLevelConfidentialityProfileAttributes | ( |  | ) | `[static]`

Return the list of Tag that will be considered when anonymizing a DICOM file.

Examples:
  GenFakeIdentifyFile.cxx, and TraverseModules.cxx.

const CryptographicMessageSyntax* gdcm::Anonymizer::GetCryptographicMessageSyntax | ( |  | ) | const

File& gdcm::Anonymizer::GetFile | ( |  | ) | `[inline]`

static SmartPointer<Anonymizer> gdcm::Anonymizer::New | ( |  | ) | `[inline, static]`

for wrapped language: instantiate a reference counted object

void gdcm::Anonymizer::RecurseDataSet | ( | DataSet & | ds | ) | `[protected]`

bool gdcm::Anonymizer::Remove | ( | Tag const & | t | ) |

remove a tag (even a SQ can be removed)

bool gdcm::Anonymizer::RemoveGroupLength | ( |  | ) |

Main function that loop over all elements and remove group length.

Examples:
  ClinicalTrialAnnotate.cxx.

bool gdcm::Anonymizer::RemovePrivateTags | ( |  | ) |

Main function that loop over all elements and remove private tags.

Examples:
  ClinicalTrialAnnotate.cxx.

bool gdcm::Anonymizer::RemoveRetired | ( |  | ) |

Main function that loop over all elements and remove retired element.

bool gdcm::Anonymizer::Replace | ( | Tag const & | t,
|  | const char * | value,
|  | VL const & | vl
| ) |  |

when the value contains \0, it is a good idea to specify the length. This function is required when dealing with VRBINARY tag

bool gdcm::Anonymizer::Replace | ( | Tag const & | t,
|  | const char * | value
| ) |  |

Replace tag with another value, if tag is not found it will be created: WARNING: this function can only execute if tag is a VRASCII

Examples:
  ClinicalTrialAnnotate.cxx, and EncapsulateFileInRawData.cxx.

void gdcm::Anonymizer::SetCryptographicMessageSyntax | ( | CryptographicMessageSyntax * | cms | ) |

Set/Get CMS key that will be used to encrypt the dataset within BasicApplicationLevelConfidentialityProfile.

void gdcm::Anonymizer::SetFile | ( | const File & | f | ) | `[inline]`

Set/Get File.

Examples:
  ClinicalTrialAnnotate.cxx, and EncapsulateFileInRawData.cxx.

The documentation for this class was generated from the following file:

- gdcmAnonymizer.h