#
# -=[[ [This file is best viewed with a monospaced font and tab-width 4 ]]]=-
#
# ABOUT EDITING THIS FILE
# The easiest way to edit AnonymizationConfiguration files - such as the one you are reading now - is to start the application and select 
# a config file to edit - or click new to create a new one from a template - and then drop one or more DICOM files you with to process 
# onto the application while holding the ⌥ (OPTION) key.
# You can then inspect the DICOM header, see which attributes will be anonymized and what data is in attributes that will not be anonymized. 
# You can add and remove attribute tags from the config file, and specify optional replacement values, without having the manually edit the file.
#
#
# FILE LOCATION
# The application will search for configuration files like this - and for AnonymizationLUT files (see below) - in the following locations (in this order):
#   0- Single config file named 'FixedAnonymizationConfiguration.txt' in the Config folder of the Application Bundle itself
#      \-> if present, no other configs will be accepted (allowing you to distribute a copy of the application with a single fixed configuration)
#
#   1- On the Desktop (configs you are editing or otherwise working on)
#   2- In ~/Library/Applications Support/DICOManonymizer (active configs for the current user on this computer - recommended location for your configs)
#   3- In /Library/Applications Support/DICOManonymizer (configs for all users on this computer)
#   4- In the Config folder of the Application Bundle itself (allowing you to distribute a copy of the application with one or more predefined configs)
#
#
# FILE FORMAT
# This file contains two sections: the Anonymization section and the Displayed-PHI filter section.
# The Displayed-PHI section maybe empty or absent. The Anonymization section may not be empty.
#
#
# ABOUT THE DISPLAYED-PHI SECTION
# The format of the Displayed-PHI section is simple:
#
# <group>:<element>[tab]<search_term>[optional_tab]<optional_2nd_search_term>[optional_tab]<and_so_on>
#
# Search terms are case-INsensitive and may contains spaces.
# As the <and_so_on> indicates, you can add multiple search terms for each tag in this section.
# Note the : (colon) between <group> and <element>. Do not use a comma, as the colon is used to identify this section.
#
# The purpose of this section is to allow the DELETION (or translocation) of DICOM files that may display PHI.
# Note that this is intended for files containing Radiation Dose Reports or Radiology Reports, etc.
# This is not intended to work for files such ultrasound images that may contain patient names and other PHI in the bitmap data itself.
#
#
# ABOUT THE ANONYMIZATION SECTION
# The format of the Anonymization section is equally simple:
#
# <group>,<element>[tab]<name>[one_or_more_tabs]<optional_new_value>
#
# Note that the <group> and <element> are required, the <name> is for personal reference.
# Note the , (comma) between <group> and <element>. Do not use a colon, as the comma is used to identify this section.
#
# The <optional_new_value> can be used as follows:
#
# a) blank or ....  -> the attribute is removed
#
# b) <LUT_XX>       -> will replace the attribute value based on a Look-Up Table (a LUT), eg: <LUT_MyTRIAL> will look for a file
#                      called AnonymizationLUT_MyTRIAL.txt and will look up the new value for the attribute there.
#                      See the example LUT file in the application bundle for how to format this file.
#                      Note that look up values are treated as string values.
#                      Note that anonymizing using a LUT takes much longer than anonymization alone because it requires all files to be parsed before writing
#                      Note that the current version of this application supports *one* attribute to be replaced by a LUT value.
#
# c) <AUTOLUT_XX>   -> Similar to b) but auto-generates an incremental value on the fly.
#                      The first value encountered for this attribute will be anonymized to Subject_0001, the second value Subject_0002, and so on.
#                      The thus created LUT will be written to this file.
#
# d) <AUTOLUT_R_XX> -> Similar to b) but auto-generates a unique, random value instead of an incrementing number
#
# e)                -> Instead of adding <AUTOLUT_XX> or <AUTOLUT_R_XX> (as described in c. and d.) to the patientID tag, you can also check 
#                      the "Auto-Pseudonymize using PID" checkbox when opening the app. In addition you can optionally specify this auto-LUT creation 
#                      to insert a Randomized number instead of an incremental number, by checking the 'Random' checkbox as well.
#
#                      ! Not all DICOM attributes can be used for creating a LUT !
#                      If Prepopulating a LUT from a set of DICOM files fails, please select a different DICOM attribute, preferably one that supports text strings.
#
# f) anything else  -> will replace the attribute's contents with 'anything else'.
#                      Note that if the attribute is not present in the source DICOM file it will be added.
#                      For sequence (nested) attributes, removing the attribute (by setting a blank, or .... value) is more often succesful, and thus safer, 
#                      than settting a replacement value.
#
#
# RECAP:
#
# To anonymize, you must:
#   - provide an AnonymizationConfiguration_<SomeNameForYourConfig>.txt file which details which attributes to anonymize.
#   -> you can generate this file by dropping DICOM files to anonymize onto the application while holding the ⌥ (OPTION) key as described above.
#
#
# To pseudonymize (=anonymize + replace a single attribute with a value from a Look Up Table, a "LUT"), you must:
# [easiest way]
#   - provide an AnonymizationConfiguration_<SomeNameForYourConfig>.txt file as described in the above paragraph.
#   - check the 'Auto-Pseudonymize using PID' checkbox and drop the DICOM files to process.
#   -> the application will then automatically prepopulate a Look Up Table with all the unique values of the PatientID attribute found in the
#      dropped DICOM files, and during subsequent anonymization automatically propagate anonymous replacement values to the correct files.
#
# [two alternatives:]
#
# To pseudonymize by replacing a single attribute with pseudonymous values from an existing Look Up Table, you must:
#   - provide an AnonymizationConfiguration_<SomeNameForYourConfig>.txt file
#       - in that file indicate one single attribute tag with <LUT_<SomeNameForYourTrialOrStudy>>
#         the value of which will be replaced by a value from a LUT
#         for example: <LUT_MyTrial>
#   - provide an AnonymizationLUT_<SomeNameForYourTrialOrStudy>.txt file, which enumerates
#         the replacement values for each original value of the LUT attribute
#         for example: AnonymizationLUT_MyTrial.txt to match the <LUT_MyTrial> attribute tag in your AnonymizationConfiguration file
#   - select this AnonymizationLUT file using the 'Use LUT' popup button before dropping your DICOM files
#
# To pseudonymize by replacing a single attribute with an auto-generated, incremental or random value, you must:
#   - provide an AnonymizationConfiguration_<SomeNameForYourConfig>.txt file
#       - in that file indicate one single attribute tag with <AUTOLUT_<SomeNameForYourTrialOrStudy>>
#         the value of which will be replaced by a value from a LUT
#         for example: <AUTOLUT_MyTrial>   to have the application create incremental pseudonymization values
#         for example: <AUTOLUT_R_MyTrial> to have the application create random pseudonymization values
#   -> you do NOT need to provide an AnonymizationLUT file -> it will be created for you.
#
# [variants:]
#
# To generate a pseudonymization Look Up Table *only*, without anonymizing your data and without actually writing LUT values to your data, you must:
#   - indicate a LUT attribute tag in your AnonymizationConfiguration file OR check the 'Auto-Pseudonymize using PID' checkbox
#   - check the 'Do not Anonymize - Prepopulate Table only' checkbox before dropping your DICOM files
#    -> the application will then prepopulate a LUT with all the unique values of the selected LUT attribute found in the dropped DICOM files 
#       but will not write the pseudonymous replacement values to the dropped DICOM files yet.
#    -> you can then edit the created LUT, for example replacing the automatically created replacement values with existing trial IDs.
#    -> after editing the files, check the 'Do not Anonymize - Propagate Table only' checkbox and drop the same DICOM files again to have
#       the application write the replacement values from your edited LUT to the correct DICOM files.
#
# To propagate the pseudonymization values from an existing Look Up Table *only*, without prepopulating the table, and without further anonymization, you must:
#   - indicate a LUT attribute tag in your AnonymizationConfiguration file OR check the 'Auto-Pseudonymize using PID' checkbox
#   - select the existing AnonymizationLUT file using the 'Use LUT' popup button 
#   - check the 'Do not Anonymize - Propagate Table only' checkbox before dropping your DICOM files
#   -> the application will then write the replacement values from the selected LUT to the correct DICOM files.
#
#
# To delete or remove files that may display PHI, you must:
#   - provide a Displayed-PHI filter section in your AnonymizationConfiguration file
#       - tags are identified as belonging to the Displayed-PHI section by the use of a colon (:) instead of a comma (,) to separate
#         the group-number and element-number parts of the tag (0010:0020 instead of 0010,0020)
#       - provide one or more search terms for each tag in that section (see below example)
#   -> the easiest way to add a Displayed-PHI section is to select a config file without such a section and then check
#      the 'Delete files with Displayed-PHI' checkbox -> the application will then offer to insert the default Displayed-PHI section
#      into the AnonymizationConfiguration file for you.
#   -> DICOM files that match the Displayed-PHI filter (by attribute tags and search terms for their value), are removed.
#      deleted (or moved if the 'Move' checkbox is checked).
#
#
# This file was created  by Wouter Veldhuis on  6 Aug 2012.
# This file was modified by Wouter Veldhuis on  4 Oct 2013.
# This file was modified by Wouter Veldhuis on 18 Sep 2017.
# This file was modified by Wouter Veldhuis on 25 Oct 2018.
# This file was modified by Wouter Veldhuis on 15 May 2019.
# This file was modified by Wouter Veldhuis on  4 Jan 2021.
# This file was modified by Wouter Veldhuis on  7 Feb 2021.
# This file was modified by Wouter Veldhuis on 10 Apr 2021.
# This file was modified by Wouter Veldhuis on  5 Jan 2022.
#
#
# Lines starting with # are considered to be comments
# You can comment out a tag to prevent the attribute from being anonymized
# !! Please make sure to use [tabs] to separate the fields in a row
# !! Please make sure there are no tabs after the last field in a row
#
# At the time of creation, the tags in the original file observe "Annex E ATTRIBUTE CONFIDENTIALITY PROFILES" of the DICOM standard
# Be aware that what is considered PHI may change in the future, and that HIPAA-compliance is your responsibility.
# That said:
#
# 1. BLINDLY ANONYMIZING *ALL* THE ATTRIBUTES IN THE 'Default FULL' CONFIG IS NOT RECOMMENDED, AND LIKELY NOT REQUIRED TO BE HIPAA-COMPLIANT
#    WHAT IS RECOMMENDED IS TO USE COMMON SENSE AND TO CHECK YOUR RESULTS: DID YOU ANONYMIZE WHAT NEEDED TO BE ANONYMIZED AND ARE THE
#    RESULTING FILES STILL COMPATIBLE WITH THEIR INTENDED USE AFTER ANONYMIZATION
#
# 2. IT IS ADVICED TO *NOT* PROVIDE REPLACEMENT VALUES FOR ANY TAG THAT IS A UID.
#    UID TAGS ARE ANONYMIZED BY CREATING A RANDOM REPLACEMENT VALUE.
#    THESE REPLACEMENT VALUES ARE KNOWN TO BE VALID FOR SOPINSTANCEUID, STUDYINSTANCEUID AND SERIESINSTANCEUID.
#    FOR OTHER UIDS THEY ARE NOT GUARANTEED TO BE FORMATTED 100% CORRECTLY BUT ARE LIKELY AT LEAST SOMEWHAT VALID AND STATISTICALLY UNLIKELY TO COLLIDE
#
# 3. IN GENERAL, REPLACEMENT VALUES SHOULD NOT EXCEED 64 CHARACTERS
#
#
# THE ABOVE MESSAGE *MAY NOT* BE REMOVED
#

#
# DISPLAYED-PHI FILTER SECTION
#
0008:0008	DOSE_INFO	EXAM PROTOCOL	CT_SOM5 PROT
0040:030E	Radiation	Dose	Report
0040:A043	Radiation	Dose	Report
0040:A730	Radiation	Dose	Report

#
# ANONYMIZATION SECTION
#
0008,0050	AccessionNumber									....
0008,0080	InstitutionName									....
0008,0081	InstitutionAddress								....
0008,0090	ReferringPhysiciansName							....
0008,0092	ReferringPhysician'sAddress						....
0008,0094	ReferringPhysiciansTelephoneNumbers				....
0008,1040	InstitutionalDepartmentName						....
0008,1048	PhysiciansofRecord								....
0008,1049	PhysiciansofRecordIdentificationSequence		....
0008,1050	PerformingPhysiciansName						....
0008,1060	NameofPhysiciansReadingStudy					....
0008,1070	OperatorsName									....
0008,1080	AdmittingDiagnosesDescription					....
0010,0010	PatientsName									Anonymous
0010,0030	PatientsBirthDate								19700101
0010,0020	PatientID									    <AUTOLUT_MyTrial>
0010,0032	PatientsBirthTime								....
0010,1000	OtherPatientIDs									....
0010,1001	OtherPatientNames								....
0010,1020	PatientsSize									....
0010,1030	PatientsWeight									....
0010,2160	EthnicGroup										....
0010,2180	Occupation										....
0010,21B0	AdditionalPatientHistory						....
0010,4000	PatientComments									....
0012,0010	ClinicalTrialSponsorName						....
0012,0020	ClinicalTrialProtocolID							....
0012,0021	ClinicalTrialProtocolName						....
0012,0030	ClinicalTrialSiteID								....
0012,0031	ClinicalTrialSiteName							....
0012,0040	ClinicalTrialSubjectID							....
0012,0042	ClinicalTrialSubjectReadingID					....
0012,0050	ClinicalTrialTimePointID						....
0012,0051	ClinicalTrialTimePointDescription				....
0012,0060	ClinicalTrialCoordinatingCenterName				....
0020,4000	ImageComments									....
0032,1032	RequestingPhysician								....
0032,1033	RequestingService								....
0040,0241	PerformedStationAETitle							....
0040,0244	PerformedProcedureStepStartDate					....
0040,0250	PerformedProcedureStepEndDate					....
0040,0254	PerformedProcedureStepDescription				....
0040,2400	ImagingServiceRequestComments					....
