def get_dataset_name(tier, release_tag, deid_stage):
    """
    Helper function to create the output prod dataset name based on the given criteria
    This function should return a name for the final dataset only (not all steps along the way)
    The function returns a string in the form: [C|R]{release_tag}[_base|_clean]

    :param tier: controlled or registered tier intended for the output dataset
    :param release_tag: release tag for dataset in the format of YYYYQ#R#
    :param deid_stage: deid stage (deid, base or clean)
    :return: a string for the dataset name
    """

    tier = tier[0].upper()
    release_tag = release_tag.upper()
    deid_stage = f'_{deid_stage}' if deid_stage == 'base' else ''

    dataset_name = f"{tier}{release_tag}{deid_stage}"

    return dataset_name