import uuid


def generate_output_name(
    subject_id: str, instance: str, source: str = "ukb", data_type: str = "ecg"
) -> str:
    """Helper function to generate output names. Current implementation will
    return `BROAD_ML4H_mdrk_{source}_{data_type}_metadata_{id}_i{instance}_{hash}`.

    Examples:
        * BROAD_ML4H_mdrk_ukb_ecg_metadata_6025769_i2_cc96e96cbe03272703223adf
        * BROAD_ML4H_mdrk_muse_ecg_metadata_2331765_i0_545d840638e5fe00592ee64d.pq

    Args:
        subject_id (str): MUSE or UKB subject identifier. This could also be any random value for privacy.
        instance (str): UKB instance number. For MUSE this can be anything.
        source (str, optional): XML source: currently `ukb` or `muse` but no restrictions apply. Defaults to 'ukb'.
        data_type (str, optional): Modality associated with the XML. Defaults to 'ecg'.

    Returns:
        str: A prepared output string name.
    """
    return f"BROAD_ML4H_mdrk_{str(source)}_{data_type}_metadata_{str(subject_id)}_i{str(instance)}_{uuid.uuid4().hex}"