Actions on dates
This profile element applies a specific action to tags containing dates. These actions can only be applied to the following Value Representations: Age String (AS), Date (DA), Date Time (DT), and Time (TM).
Parameters
Required parameters
name: Description of the action appliedcodename: Must be set toaction.on.datesoption: The action to be applied (see options below)arguments: Additional parameters depending on the chosen option
Optional parameters
condition: Defines a condition to evaluate whether this profile element should be applied to the DICOM instancetags: List of tags the action should be applied to. If not specified, the action applies to all tags with AS, DA, DT, or TM Value RepresentationexcludedTags: List of tags that will be ignored by this action
Available Options
The option parameter can have one of the following values:
shift- Apply a fixed time shiftshift_range- Apply a random time shift within specified rangesshift_by_tag- Apply a shift based on values from another DICOM tagdate_format- Remove date precision (day and/or month)
Shift Option
The shift option applies a fixed shift to dates using the following required arguments:
seconds: Integer representing the number of seconds for the shift operationdays: Integer representing the number of days for the shift operation
Behavior by Value Representation:
- Age String (AS): Seconds and days are added to the existing value
- Date (DA), Date Time (DT), Time (TM): Seconds and days are subtracted from the existing value
Example
This example shifts all tags starting with 0010 that have AS, DA, DT, or TM Value Representation by 30 seconds and 10 days:
Shift Range Option
The shift_range option applies a random shift to dates within user-defined ranges.
Arguments
max_seconds(required): Upper bound for the number of seconds to shiftmax_days(required): Upper bound for the number of days to shiftmin_seconds(optional): Lower bound for the number of seconds to shift (defaults to 0)min_days(optional): Lower bound for the number of days to shift (defaults to 0)
The random operation is deterministic and reproducible based on the patient and project.
Example
This example shifts all tags starting with 0008,002 that have AS, DA, DT, or TM Value Representation randomly within a range of 0 to 60 seconds and 50 to 100 days:
Date Format Option
The date_format option removes date precision by deleting specific date components.
This action can only be applied to Date (DA) and Date Time (DT) Value Representations.
Arguments
remove: Specifies which date components to removeday: Removes the day information, replacing it with01month_day: Removes both month and day information, replacing them with01for each
Example: Remove Day
This example removes the day from all tags starting with 0008,003 that have DA or DT Value Representation:
For example, if the value contained in the tag is 20230512, the output value will be 20230501.
Shift By Tag Option
The shift_by_tag option applies a shift based on values contained in other DICOM tags.
Arguments
At least one of the following arguments must be specified:
seconds_tag: Tag containing the number of seconds for the shift operationdays_tag: Tag containing the number of days for the shift operation
Example
This example shifts all tags starting with 0010 that have AS, DA, DT, or TM Value Representation by the number of days stored in the private tag (0015,0011):
Complete Profile Example
This example demonstrates a complete de-identification profile that applies multiple date actions in sequence:
- Shift Range: Randomly shift tags matching
(0008,003X)and(0008,0012)(except(0008,0030)and(0008,0032)) by 0 to 60 seconds and 10 to 50 days - Date Format: Remove month and day from tags
(0008,0023)and(0008,0021) - Fixed Shift: Shift tags matching
(0010,XXXX)(except(0010,0010)) by 30 seconds and 10 days - Basic Profile: Apply the Basic DICOM Profile to all remaining tags