def anonymize_dcm(dcm)
      # Extract the data element parents to investigate:
      parents = element_parents(dcm)
      parents.each do |parent|
        # Anonymize the desired tags:
        @tags.each_index do |j|
          if parent.exists?(@tags[j])
            element = parent[@tags[j]]
            if element.is_a?(Element)
              if @blank
                value = ''
              elsif @enumeration
                old_value = element.value
                # Only launch enumeration logic if there is an actual value to the data element:
                if old_value
                  value = enumerated_value(old_value, j)
                else
                  value = ''
                end
              else
                # Use the value that has been set for this tag:
                value = @values[j]
              end
              element.value = value
            end
          end
        end
        # Delete elements marked for deletion:
        @delete.each_key do |tag|
          parent.delete(tag) if parent.exists?(tag)
        end
      end
      # General DICOM object manipulation:
      # Add a Patient Identity Removed attribute (as per
      # DICOM PS 3.15, Annex E, E.1.1 De-Identifier, point 6):
      dcm.add(Element.new('0012,0062', 'YES'))
      # Add a De-Identification Method Code Sequence Item:
      dcm.add(Sequence.new('0012,0064')) unless dcm.exists?('0012,0064')
      i = dcm['0012,0064'].add_item
      i.add(Element.new('0012,0063', 'De-identified by the ruby-dicom Anonymizer'))
      # FIXME: At some point we should add a set of de-indentification method codes, as per
      #   DICOM PS 3.16 CID 7050 which corresponds to the settings chosen for the anonymizer.
      # Delete the old File Meta Information group (as per
      # DICOM PS 3.15, Annex E, E.1.1 De-Identifier, point 7):
      dcm.delete_group('0002')
      # Handle UIDs if requested:
      replace_uids(parents) if @uid
      # Delete private tags if indicated:
      dcm.delete_private if @delete_private
    end
def anonymize_dcm(dcm)
      # Extract the data element parents to investigate:
      parents = element_parents(dcm)
      parents.each do |parent|
        # Anonymize the desired tags:
        @tags.each_index do |j|
          if parent.exists?(@tags[j])
            element = parent[@tags[j]]
            if element.is_a?(Element)
              if @blank
                value = ''
              elsif @enumeration
                old_value = element.value
                # Only launch enumeration logic if there is an actual value to the data element:
                if old_value
                  value = enumerated_value(old_value, j)
                else
                  value = ''
                end
              else
                # Use the value that has been set for this tag:
                value = @values[j]
              end
              element.value = value
            end
          end
        end
        # Delete elements marked for deletion:
        @delete.each_key do |tag|
          parent.delete(tag) if parent.exists?(tag)
        end
      end
      # General DICOM object manipulation:
      # Add a Patient Identity Removed attribute (as per
      # DICOM PS 3.15, Annex E, E.1.1 De-Identifier, point 6):
      dcm.add(Element.new('0012,0062', 'YES'))
      # Add a De-Identification Method Code Sequence Item:
      dcm.add(Sequence.new('0012,0064')) unless dcm.exists?('0012,0064')
      i = dcm['0012,0064'].add_item
      i.add(Element.new('0012,0063', 'De-identified by the ruby-dicom Anonymizer'))
      # FIXME: At some point we should add a set of de-indentification method codes, as per
      #   DICOM PS 3.16 CID 7050 which corresponds to the settings chosen for the anonymizer.
      # Delete the old File Meta Information group (as per
      # DICOM PS 3.15, Annex E, E.1.1 De-Identifier, point 7):
      dcm.delete_group('0002')
      # Handle UIDs if requested:
      replace_uids(parents) if @uid
      # Delete private tags if indicated:
      dcm.delete_private if @delete_private
    end
Performs anonymization on a DICOM object.

 @param [DObject] dcm a DICOM object