def disease_upgrade_monitoring(case_id, level, case=None):
    """
        @todo: docstring
    """

    if level not in MONITORING_UPGRADE:
        return False
    else:
        previous_levels = MONITORING_UPGRADE[level]

    if case is None or case not in "monitoring_level":
        ctable = current.s3db.disease_case
        query = (ctable.id == case_id) & \
                (ctable.monitoring_level.belongs(previous_levels)) & \
                (ctable.deleted != True)

        case = current.db(query).select(ctable.id,
                                        limitby = (0, 1)).first()
    elif case.monitoring_level not in previous_levels:
        return
    if case:
        case.update_record(monitoring_level = level)
    return True

# =============================================================================
dataset/ETHPy150Open sahana/eden/modules/s3db/disease.py/disease_upgrade_monitoring/swapped operands of `not in`