def disease_propagate_case_status(case_id):
    """
        @todo: docstring
    """

    db = current.db
    s3db = current.s3db

    risk_status = ("SYMPTOMATIC", "SEVERE", "DECEASED", "RECOVERED")

    # Get the case
    ctable = s3db.disease_case
    query = (ctable.id == case_id) & \
            (ctable.deleted != True)
    case = db(query).select(ctable.id,
                            ctable.created_on,
                            ctable.disease_id,
                            ctable.illness_status,
                            ctable.symptom_debut,
                            ctable.diagnosis_status,
                            ctable.diagnosis_date,
                            limitby = (0, 1)).first()
    if case is None:
        return
    disease_id = case.disease_id

    # Try to establish a symptom debut
    symptom_debut = case.symptom_debut
    if not symptom_debut:
        # Get all monitoring entries for this case
        mtable = s3db.disease_case_monitoring
        query = (mtable.case_id == case_id) & \
                (mtable.illness_status.belongs(risk_status)) & \
                (mtable.deleted != True)
        monitoring = db(query).select(mtable.date,
                                      orderby = "disease_case_monitoring.date desc",
                                      limitby = (0, 1)).first()
        if monitoring:
            symptom_debut = monitoring.date
    if not symptom_debut and case.illness_status in risk_status:
        symptom_debut = case.created_on
    if not symptom_debut:
        # Case is not known to ever have shown any symptoms
        return

    if case.diagnosis_status == "CONFIRMED-NEG" and \
       case.diagnosis_date > symptom_debut:
        # Case has been declared CONFIRMED-NEG after symptom debut
        return

    # Establish risk period (=symptom debut minus trace period)
    dtable = s3db.disease_disease
    query = (dtable.id == disease_id) & \
            (dtable.deleted != True)
    disease = db(query).select(dtable.trace_period,
                               dtable.watch_period,
                               limitby = (0, 1)).first()
    if not disease:
        return
    trace_period = disease.trace_period
    if trace_period:
        risk_period_start = symptom_debut - datetime.timedelta(days = disease.trace_period)
    else:
        risk_period_start = symptom_debut

    # Get all high-risk exposures after risk_period_start
    etable = s3db.disease_exposure
    query = (etable.case_id == case_id) & \
            (etable.date >= risk_period_start) & \
            (etable.exposure_risk == "HIGH") & \
            (etable.deleted != True)
    exposures = db(query).select(etable.person_id)
    for exposure in exposures:
        disease_create_case(disease_id,
                            exposure.person_id,
                            monitoring_level = "OBSERVATION",
                            )
    return

# =============================================================================
dataset/ETHPy150Open sahana/eden/modules/s3db/disease.py/disease_propagate_case_status/original