|
PACS System 0.1.0
PACS DICOM system library
|
#include <anonymizer.h>

Public Member Functions | |
| anonymizer (anonymization_profile profile=anonymization_profile::basic) | |
| Construct with a specific profile. | |
| anonymizer (const anonymizer &other) | |
| Copy constructor. | |
| anonymizer (anonymizer &&other) noexcept | |
| Move constructor. | |
| auto | operator= (const anonymizer &other) -> anonymizer & |
| Copy assignment. | |
| auto | operator= (anonymizer &&other) noexcept -> anonymizer & |
| Move assignment. | |
| ~anonymizer ()=default | |
| Default destructor. | |
| auto | anonymize (core::dicom_dataset &dataset) -> kcenon::common::Result< anonymization_report > |
| Anonymize a DICOM dataset. | |
| auto | anonymize_with_mapping (core::dicom_dataset &dataset, uid_mapping &mapping) -> kcenon::common::Result< anonymization_report > |
| Anonymize with consistent UID mapping. | |
| auto | get_profile () const noexcept -> anonymization_profile |
| Get the current profile. | |
| void | set_profile (anonymization_profile profile) |
| Set a new profile. | |
| void | set_private_tag_action (private_tag_action action) |
| Set the action to take on private tags during anonymization. | |
| auto | get_private_tag_action () const noexcept -> private_tag_action |
| Get the current private tag action. | |
| void | add_tag_action (core::dicom_tag tag, tag_action_config config) |
| Add or override a tag action. | |
| void | add_tag_actions (const std::map< core::dicom_tag, tag_action_config > &actions) |
| Add multiple tag actions. | |
| auto | remove_tag_action (core::dicom_tag tag) -> bool |
| Remove a custom tag action (reverts to profile default) | |
| void | clear_custom_actions () |
| Clear all custom tag actions. | |
| auto | get_tag_action (core::dicom_tag tag) const -> tag_action_config |
| Get the effective action for a tag. | |
| void | set_date_offset (std::chrono::days offset) |
| Set date offset for longitudinal consistency. | |
| auto | get_date_offset () const noexcept -> std::optional< std::chrono::days > |
| Get the current date offset. | |
| void | clear_date_offset () |
| Clear the date offset (dates will be zeroed instead) | |
| auto | set_encryption_key (std::span< const std::uint8_t > key) -> kcenon::common::VoidResult |
| Set encryption key for encrypt actions. | |
| auto | has_encryption_key () const noexcept -> bool |
| Check if encryption is configured. | |
| void | set_hash_salt (std::string salt) |
| Set salt for hash operations. | |
| auto | get_hash_salt () const -> std::optional< std::string > |
| Get the current hash salt. | |
| void | set_detailed_reporting (bool enable) |
| Enable detailed action recording. | |
| auto | is_detailed_reporting () const noexcept -> bool |
| Check if detailed reporting is enabled. | |
Static Public Member Functions | |
| static auto | generate_random_date_offset (std::chrono::days min_days=std::chrono::days{-365}, std::chrono::days max_days=std::chrono::days{365}) -> std::chrono::days |
| Generate a random date offset. | |
| static auto | get_profile_actions (anonymization_profile profile) -> std::map< core::dicom_tag, tag_action_config > |
| Get tags to process for a given profile. | |
| static auto | get_hipaa_identifier_tags () -> std::vector< core::dicom_tag > |
| Get a list of HIPAA Safe Harbor identifier tags. | |
| static auto | get_gdpr_personal_data_tags () -> std::vector< core::dicom_tag > |
| Get a list of GDPR personal data tags. | |
Private Member Functions | |
| auto | apply_action (core::dicom_dataset &dataset, core::dicom_tag tag, const tag_action_config &config, uid_mapping *mapping) -> tag_action_record |
| auto | shift_date (std::string_view date_string) const -> std::string |
| auto | hash_value (std::string_view value) const -> std::string |
| auto | encrypt_value (std::string_view value) const -> kcenon::common::Result< std::string > |
| void | initialize_profile_actions () |
Private Attributes | |
| anonymization_profile | profile_ |
| Current anonymization profile. | |
| std::map< core::dicom_tag, tag_action_config > | custom_actions_ |
| Custom tag actions (override profile defaults) | |
| std::optional< std::chrono::days > | date_offset_ |
| Date offset for shifting. | |
| std::vector< std::uint8_t > | encryption_key_ |
| Encryption key (if set) | |
| std::optional< std::string > | hash_salt_ |
| Hash salt. | |
| private_tag_action | private_tag_action_ {private_tag_action::keep} |
| Action for private tags. | |
| bool | detailed_reporting_ {false} |
| Whether to include detailed action records in report. | |
Definition at line 89 of file anonymizer.h.
|
explicit |
Construct with a specific profile.
| profile | The anonymization profile to use |
Definition at line 34 of file anonymizer.cpp.
References initialize_profile_actions().

| kcenon::pacs::security::anonymizer::anonymizer | ( | const anonymizer & | other | ) |
Copy constructor.
Definition at line 39 of file anonymizer.cpp.
|
noexcept |
Move constructor.
Definition at line 48 of file anonymizer.cpp.
References kcenon::pacs::security::other.
|
default |
Default destructor.
| void kcenon::pacs::security::anonymizer::add_tag_action | ( | core::dicom_tag | tag, |
| tag_action_config | config ) |
Add or override a tag action.
Sets a custom action for a specific tag, overriding the profile default.
| tag | The DICOM tag |
| config | The action configuration |
Definition at line 211 of file anonymizer.cpp.
References custom_actions_.
| void kcenon::pacs::security::anonymizer::add_tag_actions | ( | const std::map< core::dicom_tag, tag_action_config > & | actions | ) |
Add multiple tag actions.
| actions | Map of tags to action configurations |
Definition at line 215 of file anonymizer.cpp.
References custom_actions_.
|
nodiscard |
Anonymize a DICOM dataset.
Applies the configured profile and any custom tag actions to de-identify the dataset. The dataset is modified in place.
| dataset | The dataset to anonymize (modified in place) |
Definition at line 83 of file anonymizer.cpp.
|
nodiscard |
Anonymize with consistent UID mapping.
Applies de-identification while maintaining consistent UID mappings across multiple datasets. This is essential for longitudinal studies and research linkage.
| dataset | The dataset to anonymize (modified in place) |
| mapping | UID mapping for consistent transformation |
Definition at line 89 of file anonymizer.cpp.
References kcenon::pacs::security::empty, kcenon::pacs::security::encrypt, kcenon::pacs::security::hash, kcenon::pacs::security::keep, kcenon::pacs::security::anonymization_report::profile_name, kcenon::pacs::security::remove, kcenon::pacs::security::remove_all, kcenon::pacs::security::remove_data, kcenon::pacs::security::remove_or_empty, kcenon::pacs::security::replace, kcenon::pacs::security::replace_uid, kcenon::pacs::security::report, kcenon::pacs::security::shift_date, and kcenon::pacs::security::to_string().

|
nodiscardprivate |
Definition at line 471 of file anonymizer.cpp.
References kcenon::pacs::security::empty, kcenon::pacs::security::encrypt, kcenon::pacs::security::uid_mapping::get_or_create(), kcenon::pacs::security::hash, kcenon::pacs::security::keep, kcenon::pacs::security::remove, kcenon::pacs::security::remove_or_empty, kcenon::pacs::security::replace, kcenon::pacs::security::replace_uid, and kcenon::pacs::security::shift_date.

| void kcenon::pacs::security::anonymizer::clear_custom_actions | ( | ) |
Clear all custom tag actions.
Definition at line 227 of file anonymizer.cpp.
References custom_actions_.
| void kcenon::pacs::security::anonymizer::clear_date_offset | ( | ) |
Clear the date offset (dates will be zeroed instead)
Definition at line 255 of file anonymizer.cpp.
References date_offset_.
|
nodiscardprivate |
Definition at line 676 of file anonymizer.cpp.
|
staticnodiscard |
Generate a random date offset.
Generates a random offset within the specified range.
| min_days | Minimum offset (days) |
| max_days | Maximum offset (days) |
Definition at line 259 of file anonymizer.cpp.
|
nodiscardnoexcept |
Get the current date offset.
Definition at line 250 of file anonymizer.cpp.
References date_offset_.
|
staticnodiscard |
Get a list of GDPR personal data tags.
Definition at line 448 of file anonymizer.cpp.
References kcenon::pacs::core::tags::patient_address, kcenon::pacs::core::tags::patient_age, kcenon::pacs::core::tags::patient_birth_date, kcenon::pacs::core::tags::patient_id, kcenon::pacs::core::tags::patient_name, kcenon::pacs::core::tags::patient_sex, kcenon::pacs::core::tags::patient_size, kcenon::pacs::core::tags::patient_weight, kcenon::pacs::core::tags::series_instance_uid, kcenon::pacs::core::tags::sop_instance_uid, and kcenon::pacs::core::tags::study_instance_uid.
|
nodiscard |
Get the current hash salt.
Definition at line 291 of file anonymizer.cpp.
References hash_salt_.
|
staticnodiscard |
Get a list of HIPAA Safe Harbor identifier tags.
Definition at line 444 of file anonymizer.cpp.
References kcenon::pacs::security::hipaa_identifiers::get_all_identifier_tags().

|
nodiscardnoexcept |
Get the current private tag action.
Definition at line 206 of file anonymizer.cpp.
References private_tag_action_.
|
nodiscardnoexcept |
Get the current profile.
Definition at line 193 of file anonymizer.cpp.
References profile_.
|
staticnodiscard |
Get tags to process for a given profile.
| profile | The anonymization profile |
Definition at line 303 of file anonymizer.cpp.
References kcenon::pacs::core::tags::accession_number, kcenon::pacs::core::tags::acquisition_date, kcenon::pacs::security::basic, kcenon::pacs::security::clean_descriptions, kcenon::pacs::security::clean_pixel, kcenon::pacs::core::tags::content_date, kcenon::pacs::core::tags::frame_of_reference_uid, kcenon::pacs::security::gdpr_compliant, kcenon::pacs::security::hipaa_safe_harbor, kcenon::pacs::core::tags::instance_creation_date, kcenon::pacs::core::tags::institution_address, kcenon::pacs::core::tags::institution_name, kcenon::pacs::security::tag_action_config::make_empty(), kcenon::pacs::security::tag_action_config::make_hash(), kcenon::pacs::security::tag_action_config::make_keep(), kcenon::pacs::security::tag_action_config::make_remove(), kcenon::pacs::security::tag_action_config::make_replace(), kcenon::pacs::core::tags::name_of_physicians_reading_study, kcenon::pacs::core::tags::operators_name, kcenon::pacs::core::tags::patient_address, kcenon::pacs::core::tags::patient_age, kcenon::pacs::core::tags::patient_birth_date, kcenon::pacs::core::tags::patient_comments, kcenon::pacs::core::tags::patient_id, kcenon::pacs::core::tags::patient_name, kcenon::pacs::core::tags::patient_sex, kcenon::pacs::core::tags::patient_size, kcenon::pacs::core::tags::patient_weight, kcenon::pacs::core::tags::performing_physician_name, kcenon::pacs::core::tags::referring_physician_name, kcenon::pacs::security::replace_uid, kcenon::pacs::security::retain_longitudinal, kcenon::pacs::security::retain_patient_characteristics, kcenon::pacs::core::tags::scheduled_performing_physician_name, kcenon::pacs::core::tags::series_date, kcenon::pacs::core::tags::series_description, kcenon::pacs::core::tags::series_instance_uid, kcenon::pacs::security::shift_date, kcenon::pacs::core::tags::sop_instance_uid, kcenon::pacs::core::tags::station_name, kcenon::pacs::core::tags::study_date, kcenon::pacs::core::tags::study_description, kcenon::pacs::core::tags::study_id, and kcenon::pacs::core::tags::study_instance_uid.

|
nodiscard |
Get the effective action for a tag.
Returns the custom action if set, otherwise the profile default.
| tag | The DICOM tag |
Definition at line 231 of file anonymizer.cpp.
References kcenon::pacs::security::tag_action_config::make_keep().

|
nodiscardnoexcept |
Check if encryption is configured.
Definition at line 283 of file anonymizer.cpp.
References encryption_key_.
|
nodiscardprivate |
Definition at line 632 of file anonymizer.cpp.
References kcenon::pacs::security::hash.
|
private |
Definition at line 780 of file anonymizer.cpp.
Referenced by anonymizer(), and set_profile().

|
nodiscardnoexcept |
Check if detailed reporting is enabled.
Definition at line 299 of file anonymizer.cpp.
References detailed_reporting_.
|
noexcept |
Move assignment.
Definition at line 70 of file anonymizer.cpp.
References kcenon::pacs::security::other.
| auto kcenon::pacs::security::anonymizer::operator= | ( | const anonymizer & | other | ) | -> anonymizer& |
Copy assignment.
Definition at line 57 of file anonymizer.cpp.
References kcenon::pacs::security::other.
| auto kcenon::pacs::security::anonymizer::remove_tag_action | ( | core::dicom_tag | tag | ) | -> bool |
Remove a custom tag action (reverts to profile default)
| tag | The tag to remove custom action for |
Definition at line 223 of file anonymizer.cpp.
| void kcenon::pacs::security::anonymizer::set_date_offset | ( | std::chrono::days | offset | ) |
Set date offset for longitudinal consistency.
All date/time values will be shifted by this offset, preserving temporal relationships while removing actual dates.
| offset | The number of days to shift (can be negative) |
Definition at line 246 of file anonymizer.cpp.
References date_offset_.
| void kcenon::pacs::security::anonymizer::set_detailed_reporting | ( | bool | enable | ) |
Enable detailed action recording.
When enabled, the anonymization report will include detailed records of each action performed.
| enable | true to enable detailed recording |
Definition at line 295 of file anonymizer.cpp.
References detailed_reporting_.
|
nodiscard |
Set encryption key for encrypt actions.
| key | The encryption key (must be 32 bytes for AES-256) |
Definition at line 272 of file anonymizer.cpp.
| void kcenon::pacs::security::anonymizer::set_hash_salt | ( | std::string | salt | ) |
Set salt for hash operations.
The salt is combined with values before hashing to prevent rainbow table attacks.
| salt | The salt value |
Definition at line 287 of file anonymizer.cpp.
References hash_salt_.
| void kcenon::pacs::security::anonymizer::set_private_tag_action | ( | private_tag_action | action | ) |
Set the action to take on private tags during anonymization.
DICOM PS3.15 Annex E recommends removing private data elements during de-identification, as they may contain PHI in vendor-specific formats that cannot be reliably inspected.
| action | The private tag action |
Definition at line 202 of file anonymizer.cpp.
References private_tag_action_.
| void kcenon::pacs::security::anonymizer::set_profile | ( | anonymization_profile | profile | ) |
Set a new profile.
Changes the anonymization profile. Custom tag actions are preserved.
| profile | The new profile to use |
Definition at line 197 of file anonymizer.cpp.
References initialize_profile_actions(), and profile_.

|
nodiscardprivate |
Definition at line 584 of file anonymizer.cpp.
|
private |
Custom tag actions (override profile defaults)
Definition at line 377 of file anonymizer.h.
Referenced by add_tag_action(), add_tag_actions(), and clear_custom_actions().
|
private |
Date offset for shifting.
Definition at line 380 of file anonymizer.h.
Referenced by clear_date_offset(), get_date_offset(), and set_date_offset().
|
private |
Whether to include detailed action records in report.
Definition at line 392 of file anonymizer.h.
Referenced by is_detailed_reporting(), and set_detailed_reporting().
|
private |
Encryption key (if set)
Definition at line 383 of file anonymizer.h.
Referenced by has_encryption_key().
|
private |
Hash salt.
Definition at line 386 of file anonymizer.h.
Referenced by get_hash_salt(), and set_hash_salt().
|
private |
Action for private tags.
Definition at line 389 of file anonymizer.h.
Referenced by get_private_tag_action(), and set_private_tag_action().
|
private |
Current anonymization profile.
Definition at line 374 of file anonymizer.h.
Referenced by get_profile(), and set_profile().