def flatten_appointment_search(appointment_search):
    """
    Expects a messy list of appointment searches record from paginate_search().
    Unpacks nested results into one, long manageable list.
    """
    out_data = []
    for i in appointment_search:
        if len(i) == 1:
            if len(i[0]['items']) == 1:
                out_data.append(i[0]['items'][0])
            else:
                for n, x in enumerate(i[0]['items']):
                    out_data.append(i[0]['items'][n])
        elif len(i) > 1:
            for x in i:
                for n, y in enumerate(x['items']):
                    out_data.append(x['items'][n])
    return out_data
