def replace_by(value, VR, action, default_name='John Doe', default_date=
    '18000101', default_datetime='180001010000.000000', default_time=
    '0000.000000', default_text='anon', default_code='ANON', default_age=
    '000M', default_decimal='0.0', default_integer='0', default_uid='000.000.0'
    ):
    """ Replace a 'value' depending of the input 'action' and the value
    representation 'VR'.

    The following action codes are:

    * D - replace with a non zero length value that may be a dummy value and
      consistent with the VR
    * Z - replace with a zero length value, or a non-zero length value that
      may be a dummy value and consistent with the VR
    * X - remove
    * K - keep (unchanged for non-sequence attributes, cleaned for sequences)
    * C - clean, that is replace with values of similar meaning known not to
      contain identifying information and consistent with the VR
    * U - replace with a non-zero length UID that is internally consistent
      within a set of Instances
    * Z/D - Z unless D is required to maintain IOD conformance (Type 2 versus
      Type 1)
    * X/Z - X unless Z is required to maintain IOD conformance (Type 3 versus
      Type 2)
    * X/D - X unless D is required to maintain IOD conformance (Type 3 versus
      Type 1)
    * X/Z/D - X unless Z or D is required to maintain IOD conformance (Type 3
      versus Type 2 versus Type 1)
    * X/Z/U* - X unless Z or replacement of contained instance UIDs (U) is
      required to maintain IOD conformance (Type 3 versus Type 2 versus Type 1
      sequences containing UID references)

    We use here the PS 3.6 convention.
    """
    if action in ['X', 'X/Z', 'X/D', 'X/Z/D', 'X/Z/U*']:
        return None
    elif action in ['U', 'D', 'Z', 'Z/D']:
        if VR == 'DA':
            return default_date
        elif VR == 'AS':
            return default_age
        elif VR == 'DS':
            return default_decimal
        elif VR == 'DT':
            return default_datetime
        elif VR == 'TM':
            return default_time
        elif VR == 'FL':
            return float(eval(default_decimal))
        elif VR == 'FD':
            return float(eval(default_decimal))
        elif VR in ['IS']:
            return default_integer
        elif VR in ['UL', 'US', 'SS', 'SL']:
            return eval(default_integer)
        elif VR == 'PN':
            return default_name
        elif VR == 'UI':
            return default_uid
        elif VR == 'CS':
            return default_code
        elif VR in ['LO', 'LT', 'ST', 'SH']:
            return default_text
        elif VR in ['OB', 'OW']:
            return default_integer
        else:
            raise Exception(
                "VR '{0}' is not yet supported. Current value is '{1}'.".
                format(VR, value))
    else:
        raise Exception("Action '{0}' is not yet supported.".format(action))
