Class ClinicalTrialsAttributes

java.lang.Object
com.pixelmed.dicom.ClinicalTrialsAttributes

public abstract class ClinicalTrialsAttributes extends Object

An abstract class of static methods to support removing identifying attributes and adding Clinical Trials Patient, Study and Series Modules attributes.

UID attributes are handled specially, in that they may be kept, removed or remapped. Remapping means that any UID that is not standard (e.g., not a SOP Class, etc.) will be replaced consistently with another generated UID, such that when that UID is encountered again, the same replacement value will be used. The replacement mapping persists within the invocation of the JVM until it is explciitly flushed. A different JVM invocation will replace the UIDs with different values. Therefore, multiple instances that need to be remapped consistently must be cleaned within the same invocation.

Note that this map could grow quite large and consumes resources in memory, and hence in a server application should be flushed at appropriate intervals using the appropriate method.

  • Field Details

    • defaultValueForMissingNonZeroLengthStrings

      public static final String defaultValueForMissingNonZeroLengthStrings
      See Also:
    • defaultValueForMissingPossiblyZeroLengthStrings

      public static final String defaultValueForMissingPossiblyZeroLengthStrings
      See Also:
    • replacementForDeviceSerialNumber

      public static final String replacementForDeviceSerialNumber
      See Also:
    • replacementForDetectorID

      public static final String replacementForDetectorID
      See Also:
    • replacementForVerifyingObserverName

      public static final String replacementForVerifyingObserverName
      See Also:
    • replacementForVerifyingOrganization

      public static final String replacementForVerifyingOrganization
      See Also:
    • replacementForContainerIdentifier

      public static final String replacementForContainerIdentifier
      See Also:
    • replacementForSpecimenIdentifier

      public static final String replacementForSpecimenIdentifier
      See Also:
    • replacementForDescriptionOrLabel

      public static final String replacementForDescriptionOrLabel
      See Also:
    • replacementForTextInStructuredContent

      public static final String replacementForTextInStructuredContent
      See Also:
    • replacementForPersonNameInStructuredContent

      public static final String replacementForPersonNameInStructuredContent
      See Also:
    • replacementForDateTimeInStructuredContent

      public static final String replacementForDateTimeInStructuredContent
      See Also:
    • replacementForDateInStructuredContent

      public static final String replacementForDateInStructuredContent
      See Also:
    • replacementForTimeInStructuredContent

      public static final String replacementForTimeInStructuredContent
      See Also:
    • replacementForContentCreatorName

      public static final String replacementForContentCreatorName
      See Also:
    • replacementForAgeString

      public static final String replacementForAgeString
      See Also:
    • dictionary

      protected static final DicomDictionary dictionary
    • mapOfOriginalToReplacementUIDs

      protected static Map mapOfOriginalToReplacementUIDs
    • uidGenerator

      protected static UIDGenerator uidGenerator
  • Method Details

    • addType1LongStringAttribute

      protected static void addType1LongStringAttribute(AttributeList list, AttributeTag t, String value, SpecificCharacterSet specificCharacterSet) throws DicomException
      Throws:
      DicomException
    • addType2LongStringAttribute

      protected static void addType2LongStringAttribute(AttributeList list, AttributeTag t, String value, SpecificCharacterSet specificCharacterSet) throws DicomException
      Throws:
      DicomException
    • addType3ShortTextAttribute

      protected static void addType3ShortTextAttribute(AttributeList list, AttributeTag t, String value, SpecificCharacterSet specificCharacterSet) throws DicomException
      Throws:
      DicomException
    • addType3ShortStringAttribute

      protected static void addType3ShortStringAttribute(AttributeList list, AttributeTag t, String value, SpecificCharacterSet specificCharacterSet) throws DicomException
      Throws:
      DicomException
    • addType3LongStringAttribute

      protected static void addType3LongStringAttribute(AttributeList list, AttributeTag t, String value, SpecificCharacterSet specificCharacterSet) throws DicomException
      Throws:
      DicomException
    • addType3DateTimeAttribute

      protected static void addType3DateTimeAttribute(AttributeList list, AttributeTag t, String value) throws DicomException
      Throws:
      DicomException
    • addAgeDerivedFromBirthDateAndStudyRelatedDate

      public static void addAgeDerivedFromBirthDateAndStudyRelatedDate(AttributeList list)

      Add the Patient's Age derived from the Patient's Birth Date and study-related date.

      Does nothing if no value for Patient's Birth Date.

      Uses the Study, Series, Acquisition or Content Date in that order if present, else does nothing.

      Parameters:
      list - the list of attributes in which to find the dob and date and to which to add the age
    • addContributingEquipmentSequence

      public static void addContributingEquipmentSequence(AttributeList list, String manufacturer, String institutionName, String institutionalDepartmentName, String institutionAddress, String stationName, String manufacturerModelName, String deviceSerialNumber, String softwareVersion) throws DicomException

      Add the attributes of the Contributing Equipment Sequence to a list of attributes.

      Attributes are added if supplied string value are added if not null. May be zero length.

      Retains any existing items in Contributing Equipment Sequence.

      Uses ("109104","DCM","De-identifying Equipment") for the Purpose of Reference.

      Uses "Deidentified" for the Contribution Description.

      Uses the current date and time for the Contribution DateTime.

      Parameters:
      list - the list of attributes to which to add the Contributing Equipment Sequence
      manufacturer - the manufacturer
      institutionName - the institution name
      institutionalDepartmentName - the institution department name
      institutionAddress - the institution address
      stationName - the station name
      manufacturerModelName - the manufacturer model name
      deviceSerialNumber - the device serial number
      softwareVersion - the software version
      Throws:
      DicomException - if error in DICOM encoding
    • addContributingEquipmentSequence

      public static void addContributingEquipmentSequence(AttributeList list, boolean retainExistingItems, CodedSequenceItem purposeOfReferenceCodeSequence, String manufacturer, String institutionName, String institutionalDepartmentName, String institutionAddress, String stationName, String manufacturerModelName, String deviceSerialNumber, String softwareVersion, String contributionDescription) throws DicomException

      Add the attributes of the Contributing Equipment Sequence to a list of attributes.

      Attributes are added if supplied string value are added if not null. May be zero length.

      Parameters:
      list - the list of attributes to which to add the Contributing Equipment Sequence
      retainExistingItems - if true, retain any existing items in Contributing Equipment Sequence, otherwise remove them
      purposeOfReferenceCodeSequence - the purpose of reference
      manufacturer - the manufacturer
      institutionName - the institution name
      institutionalDepartmentName - the institution department name
      institutionAddress - the institution address
      stationName - the station name
      manufacturerModelName - the manufacturer model name
      deviceSerialNumber - the device serial number
      softwareVersion - the software version
      contributionDescription - the contribution description
      Throws:
      DicomException - if error in DICOM encoding
    • addContributingEquipmentSequence

      public static void addContributingEquipmentSequence(AttributeList list, boolean retainExistingItems, CodedSequenceItem purposeOfReferenceCodeSequence, String manufacturer, String institutionName, String institutionalDepartmentName, String institutionAddress, String stationName, String manufacturerModelName, String deviceSerialNumber, String softwareVersion, String contributionDescription, String contributionDateTime) throws DicomException

      Add the attributes of the Contributing Equipment Sequence to a list of attributes.

      Attributes are added if supplied string value are added if not null. May be zero length.

      Parameters:
      list - the list of attributes to which to add the Contributing Equipment Sequence
      retainExistingItems - if true, retain any existing items in Contributing Equipment Sequence, otherwise remove them
      purposeOfReferenceCodeSequence - the purpose of reference
      manufacturer - the manufacturer
      institutionName - the institution name
      institutionalDepartmentName - the institution department name
      institutionAddress - the institution address
      stationName - the station name
      manufacturerModelName - the manufacturer model name
      deviceSerialNumber - the device serial number
      softwareVersion - the software version
      contributionDescription - the contribution description
      contributionDateTime - the contribution datetime
      Throws:
      DicomException - if error in DICOM encoding
    • addContributingEquipmentSequence

      public static void addContributingEquipmentSequence(AttributeList list, boolean retainExistingItems, CodedSequenceItem purposeOfReferenceCodeSequence, String manufacturer, String institutionName, String institutionalDepartmentName, String institutionAddress, String stationName, String manufacturerModelName, String deviceSerialNumber, String softwareVersion, String contributionDescription, String contributionDateTime, String[] operatorNames, PersonIdentification[] operatorIdentifications) throws DicomException

      Add the attributes of the Contributing Equipment Sequence to a list of attributes.

      Attributes are added if supplied string value are added if not null. May be zero length.

      Parameters:
      list - the list of attributes to which to add the Contributing Equipment Sequence
      retainExistingItems - if true, retain any existing items in Contributing Equipment Sequence, otherwise remove them
      purposeOfReferenceCodeSequence - the purpose of reference
      manufacturer - the manufacturer
      institutionName - the institution name
      institutionalDepartmentName - the institution department name
      institutionAddress - the institution address
      stationName - the station name
      manufacturerModelName - the manufacturer model name
      deviceSerialNumber - the device serial number
      softwareVersion - the software version
      contributionDescription - the contribution description
      contributionDateTime - the contribution datetime
      operatorNames - an array of Strings of one or more operator's names, or null if not to be added
      operatorIdentifications - an array of PersonIdentification, or null if not to be added
      Throws:
      DicomException - if error in DICOM encoding
    • addContributingEquipmentSequence

      public static void addContributingEquipmentSequence(AttributeList list, boolean retainExistingItems, CodedSequenceItem purposeOfReferenceCodeSequence, String manufacturer, String institutionName, String institutionalDepartmentName, CodedSequenceItem institutionalDepartmentTypeCodeSequence, String institutionAddress, String stationName, String manufacturerModelName, String deviceSerialNumber, String softwareVersion, String contributionDescription, String contributionDateTime, String[] operatorNames, PersonIdentification[] operatorIdentifications) throws DicomException

      Add the attributes of the Contributing Equipment Sequence to a list of attributes.

      Attributes are added if supplied string value are added if not null. May be zero length.

      Parameters:
      list - the list of attributes to which to add the Contributing Equipment Sequence
      retainExistingItems - if true, retain any existing items in Contributing Equipment Sequence, otherwise remove them
      purposeOfReferenceCodeSequence - the purpose of reference
      manufacturer - the manufacturer
      institutionName - the institution name
      institutionalDepartmentName - the institution department name
      institutionalDepartmentTypeCodeSequence - the institution department type
      institutionAddress - the institution address
      stationName - the station name
      manufacturerModelName - the manufacturer model name
      deviceSerialNumber - the device serial number
      softwareVersion - the software version
      contributionDescription - the contribution description
      contributionDateTime - the contribution datetime
      operatorNames - an array of Strings of one or more operator's names, or null if not to be added
      operatorIdentifications - an array of PersonIdentification, or null if not to be added
      Throws:
      DicomException - if error in DICOM encoding
    • removeClinicalTrialsAttributes

      public static void removeClinicalTrialsAttributes(AttributeList list)

      Remove the attributes of the Clinical Trials Patient, Study and Series Modules, from a list of attributes.

      Parameters:
      list - the list of attributes from which to remove the attributes
    • addClinicalTrialsAttributes

      public static void addClinicalTrialsAttributes(AttributeList list, boolean replaceConventionalAttributes, String clinicalTrialSponsorName, String clinicalTrialProtocolID, String clinicalTrialProtocolName, String clinicalTrialSiteID, String clinicalTrialSiteName, String clinicalTrialSubjectID, String clinicalTrialSubjectReadingID, String clinicalTrialTimePointID, String clinicalTrialTimePointDescription, String clinicalTrialCoordinatingCenterName) throws DicomException

      Add the attributes of the Clinical Trials Patient, Study and Series Modules, to a list of attributes.

      Parameters:
      list - the list of attributes to which to add the attributes
      replaceConventionalAttributes - if true, use the supplied clinical trials attributes in place of the conventional ID attributes as well
      clinicalTrialSponsorName - the sponsor name
      clinicalTrialProtocolID - the protocol ID
      clinicalTrialProtocolName - the protocol name
      clinicalTrialSiteID - the site ID
      clinicalTrialSiteName - the site name
      clinicalTrialSubjectID - the subject ID
      clinicalTrialSubjectReadingID - the subject reading ID
      clinicalTrialTimePointID - the time point ID
      clinicalTrialTimePointDescription - the time point description
      clinicalTrialCoordinatingCenterName - the coordinating center name
      Throws:
      DicomException - if error in DICOM encoding
    • isSafePrivateAttribute

      public static boolean isSafePrivateAttribute(AttributeTag tag, AttributeList list)

      Is a private tag safe?

      Safe private attributes are all those that are known not to contain individually identifiable information.

      Private creators are always considered safe.

      Private transient UIDs are also considered "safe", since they can then be removed/remapped based in a subsequent step.

      Parameters:
      tag - the tag in question
      list - the list in which the tag is contained from which the private creator can be extracted
      Returns:
      true if safe
    • isSafePrivateAttribute

      public static boolean isSafePrivateAttribute(String creator, AttributeTag tag)

      Is a private tag safe?

      Safe private attributes are all those that are known not to contain individually identifiable informationR.

      Private creators are always considered safe, though there is no point in calling this method for private creator tags ... use AttributeTag.isPrivateCreator() instead.

      Private transient UIDs are also considered "safe", since they can then be removed/remapped based in a subsequent step.

      Parameters:
      creator - the private creator of the block containing the tag
      tag - the tag in question
      Returns:
      true if safe
    • isSafePrivateSequenceAttribute

      public static boolean isSafePrivateSequenceAttribute(String creator, AttributeTag tag)

      Is a private tag a safe sequence VR that needs to be read as SQ if UN.

      Parameters:
      creator - the private creator of the block containing the tag
      tag - the tag in question
      Returns:
      true if a safe SQ private tag
    • flushMapOfUIDs

      public static void flushMapOfUIDs()

      Flush (remove all entries in) the map of original UIDs to replacement UIDs.

    • getMapOfOriginalToReplacementUIDs

      public static Map<String,String> getMapOfOriginalToReplacementUIDs()

      Get the map of original UIDs to replacement UIDs.

    • remapUIDAttributes

      public static void remapUIDAttributes(AttributeList list) throws DicomException

      Remap UID attributes in a list of attributes, recursively iterating through nested sequences.

      Parameters:
      list - the list of attributes to be cleaned up
      Throws:
      DicomException - if error in DICOM encoding
    • removeUIDAttributes

      public static void removeUIDAttributes(AttributeList list) throws DicomException

      Remove UID attributes in a list of attributes, recursively iterating through nested sequences.

      Parameters:
      list - the list of attributes to be cleaned up
      Throws:
      DicomException - if error in DICOM encoding
    • removeOrRemapUIDAttributes

      protected static void removeOrRemapUIDAttributes(AttributeList list, int handleUIDs) throws DicomException

      Remove or remap UID attributes in a list of attributes, recursively iterating through nested sequences.

      Parameters:
      list - the list of attributes to be cleaned up
      handleUIDs - remove or remap the UIDs
      Throws:
      DicomException - if error in DICOM encoding
    • getTagOfTimeAttributeCorrespondingToDateAttribute

      public static AttributeTag getTagOfTimeAttributeCorrespondingToDateAttribute(AttributeTag dateTag)

      Get the Time Attribute corresponding to the Date Attribute.

      Parameters:
      dateTag -
      Returns:
      the AttributeTag of the corresponding Time Attribute, if any, otherwise null
    • isValidCandidateForEarliestDateTime

      protected static boolean isValidCandidateForEarliestDateTime(Date candidate)
    • findEarliestDateTime

      protected static Date findEarliestDateTime(AttributeList list, Date earliestSoFar, String dateToUseForUnaccompaniedTimes)

      Get the earliest patient event related date and time.

      Ignores equipment related dates like calibration, patient related dates like birth date, and non-patient instance related dates like effective and information issue.

      Parameters:
      list - the list of attributes from the top level data set
      earliestSoFar - for recursion
      dateToUseForUnaccompaniedTimes - the date to use for time attributes that don't have a date sibling
      Returns:
      the earliest date and time
    • findEarliestDateTime

      public static Date findEarliestDateTime(AttributeList list)

      Get the earliest patient event related date and time.

      Ignores equipment related dates like calibration, patient related dates like birth date, and non-patient instance related dates like effective and information issue.

      Parameters:
      list - the list of attributes from the top level data set
      Returns:
      the earliest date and time
    • getDateOffsetByEarliestMovedToEpoch

      public static Date getDateOffsetByEarliestMovedToEpoch(Date existingDate, Date epochForDateModification, Date earliest)

      Move the date and time by the offset from the earliest date to the epoch.

      Parameters:
      existingDate -
      epochForDateModification -
      earliest -
      Returns:
      the updated date and time
    • getDateToUseForUnaccompaniedTimes

      public static String getDateToUseForUnaccompaniedTimes(AttributeList list)

      Get the date to use for time attributes that don't have a date sibling and which may be nested in sequences.

      E.g., to use with RadiopharmaceuticalStartTime.

      Parameters:
      list - the list of attributes from the top level data set
      Returns:
      a date to use, or an empty string if none
    • removeOrRemapDateAndTimeAttributes

      protected static void removeOrRemapDateAndTimeAttributes(AttributeList list, int handleDates, Date epochForDateModification, Date earliest, String dateToUseForUnaccompaniedTimes) throws DicomException

      Remove or remap Date, Time and DateTime attributes (other than Patient Birth) in a list of attributes, recursively iterating through nested sequences.

      Parameters:
      list - the list of attributes to be cleaned up
      handleDates - keep, remove or modify dates and times
      epochForDateModification - used if handleDates is modify dates, otherwise null
      earliest - used to determine the offset from the epoch to remove from all dates and times - MUST be the earliest date and time else unaccompanied time attributes may cross midnight
      dateToUseForUnaccompaniedTimes - used for time attributes that don't have a date sibling and which may be nested in sequences, e.g., RadiopharmaceuticalStartTime
      Throws:
      DicomException - if error in DICOM encoding
    • removeStructuredContent

      protected static void removeStructuredContent(AttributeList list)
    • removeOrCleanStructuredContent

      protected static void removeOrCleanStructuredContent(AttributeList list, int handleStructuredContent, boolean keepDescriptors, boolean keepSeriesDescriptors, boolean keepProtocolName, boolean keepPatientCharacteristics, boolean keepDeviceIdentity, boolean keepInstitutionIdentity, int handleUIDs, int handleDates) throws DicomException

      Remove or clean structured content including the SR content tree (whether an SR object or not) in a list of attributes, recursively iterating through nested sequences.

      Parameters:
      list - the list of attributes to be cleaned up
      handleStructuredContent - keep, remove or modify structured content
      keepDescriptors - if true, keep the text description and comment attributes
      keepSeriesDescriptors - if true, keep the series description even if all other descriptors are removed
      keepProtocolName - if true, keep protocol name even if all other descriptors are removed
      keepPatientCharacteristics - if true, keep patient characteristics (such as might be needed for PET SUV calculations)
      keepDeviceIdentity - if true, keep device identity
      keepInstitutionIdentity - if true, keep institution identity
      handleUIDs - remove or remap the UIDs
      handleDates - keep, remove or modify dates and times
      Throws:
      DicomException - if error in DICOM encoding
    • removeOrNullIdentifyingAttributes

      public static void removeOrNullIdentifyingAttributes(AttributeList list, boolean keepUIDs, boolean keepDescriptors) throws DicomException

      De-identify a list of attributes.

      De-identifies attributes within nested sequences, other than Context Sequence.

      Handles UIDs as requested, including within nested sequences, including Context Sequence.

      Leaves dates and times alone (other than Patient Birth).

      Does not de-identify any specific content items in structured content, e.g., within Content Sequence.

      Also adds record that de-identification has been performed.

      Parameters:
      list - the list of attributes to be cleaned up
      keepUIDs - if true, keep the UIDs
      keepDescriptors - if true, keep the text description and comment attributes
      Throws:
      DicomException - if error in DICOM encoding
    • removeOrNullIdentifyingAttributes

      public static void removeOrNullIdentifyingAttributes(AttributeList list, boolean keepUIDs, boolean keepDescriptors, boolean keepPatientCharacteristics) throws DicomException

      De-identify a list of attributes.

      De-identifies attributes within nested sequences, other than Context Sequence.

      Handles UIDs as requested, including within nested sequences, including Context Sequence.

      Leaves dates and times alone (other than Patient Birth).

      Does not de-identify any specific content items in structured content, e.g., within Content Sequence.

      Also adds record that de-identification has been performed.

      Parameters:
      list - the list of attributes to be cleaned up
      keepUIDs - if true, keep the UIDs
      keepDescriptors - if true, keep the text description and comment attributes
      keepPatientCharacteristics - if true, keep patient characteristics (such as might be needed for PET SUV calculations)
      Throws:
      DicomException - if error in DICOM encoding
    • removeOrNullIdentifyingAttributes

      public static void removeOrNullIdentifyingAttributes(AttributeList list, int handleUIDs, boolean keepDescriptors, boolean keepPatientCharacteristics) throws DicomException

      De-identify a list of attributes.

      De-identifies attributes within nested sequences, other than Context Sequence.

      Handles UIDs as requested, including within nested sequences, including Context Sequence.

      Leaves dates and times alone (other than Patient Birth).

      Does not de-identify any specific content items in structured content, e.g., within Content Sequence.

      Also adds record that de-identification has been performed.

      Parameters:
      list - the list of attributes to be cleaned up
      handleUIDs - keep, remove or remap the UIDs
      keepDescriptors - if true, keep the text description and comment attributes
      keepPatientCharacteristics - if true, keep patient characteristics (such as might be needed for PET SUV calculations)
      Throws:
      DicomException - if error in DICOM encoding
    • removeOrNullIdentifyingAttributes

      public static void removeOrNullIdentifyingAttributes(AttributeList list, int handleUIDs, boolean keepDescriptors, boolean keepSeriesDescriptors, boolean keepPatientCharacteristics, boolean keepDeviceIdentity, boolean keepInstitutionIdentity) throws DicomException

      De-identify a list of attributes.

      De-identifies attributes within nested sequences, other than Context Sequence.

      Handles UIDs as requested, including within nested sequences, including Context Sequence.

      Leaves dates and times alone (other than Patient Birth).

      Does not de-identify any specific content items in structured content, e.g., within Content Sequence.

      Also adds record that de-identification has been performed.

      Parameters:
      list - the list of attributes to be cleaned up
      handleUIDs - keep, remove or remap the UIDs
      keepDescriptors - if true, keep the text description and comment attributes
      keepSeriesDescriptors - if true, keep the series description even if all other descriptors are removed
      keepPatientCharacteristics - if true, keep patient characteristics (such as might be needed for PET SUV calculations)
      keepDeviceIdentity - if true, keep device identity
      keepInstitutionIdentity - if true, keep institution identity
      Throws:
      DicomException - if error in DICOM encoding
    • removeOrNullIdentifyingAttributes

      public static void removeOrNullIdentifyingAttributes(AttributeList list, int handleUIDs, boolean keepDescriptors, boolean keepSeriesDescriptors, boolean keepPatientCharacteristics, boolean keepDeviceIdentity, boolean keepInstitutionIdentity, int handleDates, Date epochForDateModification, Date earliestDateInSet) throws DicomException

      De-identify a list of attributes.

      De-identifies attributes within nested sequences, other than Context Sequence.

      Handles UIDs as requested, including within nested sequences, including Context Sequence.

      Handles dates and times as requested (other than Patient Birth), including within nested sequences, including Context Sequence.

      Does not de-identify any specific content items in structured content, e.g., within Content Sequence.

      Also adds record that de-identification has been performed.

      Parameters:
      list - the list of attributes to be cleaned up
      handleUIDs - keep, remove or remap the UIDs
      keepDescriptors - if true, keep the text description and comment attributes
      keepSeriesDescriptors - if true, keep the series description even if all other descriptors are removed
      keepPatientCharacteristics - if true, keep patient characteristics (such as might be needed for PET SUV calculations)
      keepDeviceIdentity - if true, keep device identity
      keepInstitutionIdentity - if true, keep institution identity
      handleDates - keep, remove or modify dates and times
      epochForDateModification - the epoch to which to move the earliest date, used if handleDates is modify dates, otherwise null
      earliestDateInSet - the known earliest date to move to the specified epoch, used if handleDates is modify dates, otherwise null; if null, the earliest in the supplied list is used; MUST be the earliest date and time else unaccompanied time attributes may cross midnight
      Throws:
      DicomException - if error in DICOM encoding
    • removeOrNullIdentifyingAttributes

      public static void removeOrNullIdentifyingAttributes(AttributeList list, int handleUIDs, boolean keepDescriptors, boolean keepSeriesDescriptors, boolean keepProtocolName, boolean keepPatientCharacteristics, boolean keepDeviceIdentity, boolean keepInstitutionIdentity, int handleDates, Date epochForDateModification, Date earliestDateInSet) throws DicomException

      De-identify a list of attributes.

      De-identifies attributes within nested sequences.

      Handles UIDs as requested, including within nested sequences, including Content Sequence.

      Handles dates and times as requested (other than Patient Birth), including within nested sequences, including Content Sequence.

      Does not de-identify any specific content items in structured content, e.g., within Content Sequence.

      Also adds record that de-identification has been performed.

      Parameters:
      list - the list of attributes to be cleaned up
      handleUIDs - keep, remove or remap the UIDs
      keepDescriptors - if true, keep the text description and comment attributes
      keepSeriesDescriptors - if true, keep the series description even if all other descriptors are removed
      keepProtocolName - if true, keep protocol name even if all other descriptors are removed
      keepPatientCharacteristics - if true, keep patient characteristics (such as might be needed for PET SUV calculations)
      keepDeviceIdentity - if true, keep device identity
      keepInstitutionIdentity - if true, keep institution identity
      handleDates - keep, remove or modify dates and times
      epochForDateModification - the epoch to which to move the earliest date, used if handleDates is modify dates, otherwise null
      earliestDateInSet - the known earliest date to move to the specified epoch, used if handleDates is modify dates, otherwise null; if null, the earliest in the supplied list is used; MUST be the earliest date and time else unaccompanied time attributes may cross midnight
      Throws:
      DicomException - if error in DICOM encoding
    • removeOrNullIdentifyingAttributes

      public static void removeOrNullIdentifyingAttributes(AttributeList list, int handleUIDs, boolean keepDescriptors, boolean keepSeriesDescriptors, boolean keepProtocolName, boolean keepPatientCharacteristics, boolean keepDeviceIdentity, boolean keepInstitutionIdentity, int handleDates, Date epochForDateModification, Date earliestDateInSet, int handleStructuredContent) throws DicomException

      De-identify a list of attributes.

      De-identifies attributes within nested sequences.

      Handles UIDs as requested, including within nested sequences, including Content Sequence.

      Handles dates and times as requested (other than Patient Birth), including within nested sequences, including Content Sequence.

      Handles structured content as requested, including within nested sequences, including (and not just confined to) Content Sequence.

      Also adds record that de-identification has been performed.

      Parameters:
      list - the list of attributes to be cleaned up
      handleUIDs - keep, remove or remap the UIDs
      keepDescriptors - if true, keep the text description and comment attributes
      keepSeriesDescriptors - if true, keep the series description even if all other descriptors are removed
      keepProtocolName - if true, keep protocol name even if all other descriptors are removed
      keepPatientCharacteristics - if true, keep patient characteristics (such as might be needed for PET SUV calculations)
      keepDeviceIdentity - if true, keep device identity
      keepInstitutionIdentity - if true, keep institution identity
      handleDates - keep, remove or modify dates and times
      epochForDateModification - the epoch to which to move the earliest date, used if handleDates is modify dates, otherwise null
      earliestDateInSet - the known earliest date to move to the specified epoch, used if handleDates is modify dates, otherwise null; if null, the earliest in the supplied list is used; MUST be the earliest date and time else unaccompanied time attributes may cross midnight
      handleStructuredContent - keep, remove or modify structured content
      Throws:
      DicomException - if error in DICOM encoding
    • removeOrNullIdentifyingAttributes

      public static void removeOrNullIdentifyingAttributes(AttributeList list, int handleUIDs, boolean keepDescriptors, boolean keepSeriesDescriptors, boolean keepProtocolName, boolean keepPatientCharacteristics, boolean keepDeviceIdentity, boolean keepInstitutionIdentity, int handleDates, Date epochForDateModification, Date earliestDateInSet, int handleStructuredContent, boolean aggregateAgesOver89) throws DicomException

      De-identify a list of attributes.

      De-identifies attributes within nested sequences.

      Handles UIDs as requested, including within nested sequences, including Content Sequence.

      Handles dates and times as requested (other than Patient Birth), including within nested sequences, including Content Sequence.

      Can optionally group ages over 89 years into single age of 90 as per HIPAA PR ยง164.514(b)(2)(i)(C).

      Handles structured content as requested, including within nested sequences, including (and not just confined to) Content Sequence.

      Also adds record that de-identification has been performed.

      Parameters:
      list - the list of attributes to be cleaned up
      handleUIDs - keep, remove or remap the UIDs
      keepDescriptors - if true, keep the text description and comment attributes
      keepSeriesDescriptors - if true, keep the series description even if all other descriptors are removed
      keepProtocolName - if true, keep protocol name even if all other descriptors are removed
      keepPatientCharacteristics - if true, keep patient characteristics (such as might be needed for PET SUV calculations)
      keepDeviceIdentity - if true, keep device identity
      keepInstitutionIdentity - if true, keep institution identity
      handleDates - keep, remove or modify dates and times
      epochForDateModification - the epoch to which to move the earliest date, used if handleDates is modify dates, otherwise null
      earliestDateInSet - the known earliest date to move to the specified epoch, used if handleDates is modify dates, otherwise null; if null, the earliest in the supplied list is used; MUST be the earliest date and time else unaccompanied time attributes may cross midnight
      handleStructuredContent - keep, remove or modify structured content
      aggregateAgesOver89 - if true, and keepPatientCharacteristics true, combine patient ages over 89 years into single 90 year category
      Throws:
      DicomException - if error in DICOM encoding
    • removeOrNullIdentifyingAttributesRecursively

      protected static void removeOrNullIdentifyingAttributesRecursively(AttributeList list, int handleUIDs, boolean keepDescriptors, boolean keepSeriesDescriptors, boolean keepProtocolName, boolean keepPatientCharacteristics, boolean keepDeviceIdentity, boolean keepInstitutionIdentity, boolean aggregateAgesOver89) throws DicomException

      De-identify a list of attributes, recursively iterating through nested sequences.

      Does not process UIDs, but does remove sequences that would be invalidated by removing UIDs, e.g., Source Image Sequence and Referenced Image Sequence. If necessary caller should use removeOrRemapUIDAttributes().

      Does not process dates and times (other than Patient Birth). If necessary caller should use removeOrRemapDateAndTimeAttributes().

      Parameters:
      list - the list of attributes to be cleaned up
      handleUIDs - keep, remove or remap the UIDs
      keepDescriptors - if true, keep the text description and comment attributes
      keepSeriesDescriptors - if true, keep the series description even if all other descriptors are removed
      keepProtocolName - if true, keep protocol name even if all other descriptors are removed
      keepPatientCharacteristics - if true, keep patient characteristics (such as might be needed for PET SUV calculations)
      keepDeviceIdentity - if true, keep device identity
      keepInstitutionIdentity - if true, keep device identity
      aggregateAgesOver89 - if true, and keepPatientCharacteristics true, combine patient ages over 89 years into single 90 year category
      Throws:
      DicomException - if error in DICOM encoding
    • main

      public static void main(String[] arg)

      For testing.

      Read a DICOM object from the file specified on the command line, and remove identifying attributes, and add sample clinical trials attributes.

      Parameters:
      arg - two arguments, a DICOM input file and a DICOM output file