def get_term(value, level, goal_type, shape):
    """Get treatment plan utility term value.

    Parameters
    ----------
    value : float
        Clinical goal value.
    level : float
        Clinical goal AcceptanceLevel.
    goal_type : str
        Clinical goal type (e.g., 'MaxDose')
    shape : {'linear', 'linear_quadratic'}
        Shape of treatment plan utility term.

    Returns
    -------
    float
        Treatment plan utility term value.

    """
    if shape not in ('linear', 'linear_quadratic'):
        raise ValueError(f'Invalid shape: {shape}')
    diff = 100*(value - level)/level
    if shape == 'linear':
        return -diff if 'Max' in goal_type else diff
    if 'Max' in goal_type:
        return -diff if value <= level else -(diff + 1)*diff
    return diff if value >= level else -(diff - 1)*diff