import logging


def get_pft_vals(key: str, rec: dict) -> tuple:
    """
    Takes a lung function test (eg TLco, etc) as key and returns an 4-tuple
    with measured, predicted, %predicted, SR 
    Fills tuple position with None if value doesn't exist
    Use get_spiro_vals() for measures with reversibility
    """
    if not key in rec:
        logging.error('Lung function, get_pft_vals() - no data found')
        return (None, None, None, None)

    measured = (rec[key]['Measured_pre'] if 'Measured_pre' in rec[key] else None)
    pred = (rec[key]['Predicted'] if 'Predicted' in rec[key] else None)
    percent = (rec[key]['Percent_pred_pre'] if 'Percent_pred_pre' in rec[key] else None)
    sr = (rec[key]['SR_pre'] if 'SR_pre' in rec[key] else None)

    return (measured, pred, percent, sr)