'Update the illness status of the case from last monitoring entry'

@staticmethod
def monitoring_onaccept(form):

    formvars = form.vars
    try:
        record_id = formvars.id
    except AttributeError:
        return
    db = current.db
    s3db = current.s3db
    ctable = s3db.disease_case
    mtable = s3db.disease_case_monitoring
    case_id = None
    if ('case_id' not in formvars):
        query = (mtable.id == record_id)
        row = db(query).select(mtable.case_id, limitby=(0, 1)).first()
        if row:
            case_id = row.case_id
    else:
        case_id = formvars.case_id
    if (not case_id):
        return
    query = ((mtable.case_id == case_id) & (mtable.illness_status != None))
    row = db(query).select(mtable.illness_status, orderby='disease_case_monitoring.date    desc', limitby=(0, 1)).first()
    if row:
        db((ctable.id == case_id)).update(illness_status=row.illness_status)
        disease_propagate_case_status(case_id)
    return
