def dvr_case_status_filter_opts(closed=None):

    table = current.s3db.dvr_case_status
    query = (table.deleted != True)
    if closed is not None:
        if closed:
            query &= (table.is_closed == True)
        else:
            query &= ((table.is_closed == False) | (table.is_closed == None))
    rows = current.db(query).select(table.id,
                                    table.name,
                                    orderby = "workflow_position",
                                    )

    if not rows:
        return {}

    T = current.T
    return OrderedDict((row.id, T(row.name)) for row in rows)

# =============================================================================
Get filter options for case status, ordered by workflow position
dataset/ETHPy150Open sahana/eden/modules/s3db/dvr.py/dvr_case_status_filter_opts