コード例 #1
0
def SI(cause: str) -> DiseaseModel:
    healthy = SusceptibleState(cause)
    infected = DiseaseState(cause)

    healthy.allow_self_transitions()
    healthy.add_transition(infected, source_data_type='rate')
    infected.allow_self_transitions()

    return DiseaseModel(cause, states=[healthy, infected])
コード例 #2
0
def NeonatalSWC_without_incidence(cause):
    with_condition_data_functions = {'birth_prevalence':
                                     lambda cause, builder: builder.data.load(f"cause.{cause}.birth_prevalence")}

    healthy = SusceptibleState(cause)
    with_condition = DiseaseState(cause, get_data_functions=with_condition_data_functions)

    healthy.allow_self_transitions()
    with_condition.allow_self_transitions()

    return DiseaseModel(cause, states=[healthy, with_condition])
コード例 #3
0
def SIS_fixed_duration(cause: str, duration: str) -> DiseaseModel:
    duration = pd.Timedelta(days=float(duration) // 1, hours=(float(duration) % 1) * 24.0)

    healthy = SusceptibleState(cause)
    infected = DiseaseState(cause, get_data_functions={'dwell_time': lambda _, __: duration})

    healthy.allow_self_transitions()
    healthy.add_transition(infected, source_data_type='rate')
    infected.add_transition(healthy)
    infected.allow_self_transitions()

    return DiseaseModel(cause, states=[healthy, infected])
コード例 #4
0
def NeonatalSIS(cause):
    with_condition_data_functions = {'birth_prevalence':
                                     lambda cause, builder: builder.data.load(f"cause.{cause}.birth_prevalence")}

    healthy = SusceptibleState(cause)
    with_condition = DiseaseState(cause, get_data_functions=with_condition_data_functions)

    healthy.allow_self_transitions()
    healthy.add_transition(with_condition, source_data_type='rate')
    with_condition.allow_self_transitions()
    with_condition.add_transition(healthy, source_data_type='rate')

    return DiseaseModel(cause, states=[healthy, with_condition])
コード例 #5
0
def Stroke(stroke_name):
    stroke_types = [
        'ischemic_stroke', 'subarachnoid_hemorrhage',
        'intracerebral_hemorrhage'
    ]
    if stroke_name not in stroke_types:
        raise ValueError(
            f'Stroke name must be one of {stroke_types}.  You supplied {stroke_name}'
        )

    susceptible = SusceptibleState(stroke_name)
    data_funcs = {'dwell_time': lambda *args: pd.Timedelta(days=28)}
    acute = DiseaseState(f'acute_{stroke_name}',
                         cause_type='sequela',
                         get_data_functions=data_funcs)
    #data_funcs = {'dwell_time': lambda *args: pd.Timedelta(days=365.25)}
    post = RelapseState(f'post_{stroke_name}', cause_type='sequela')

    susceptible.allow_self_transitions()
    data_funcs = {
        'incidence_rate':
        lambda _, builder: builder.data.load(
            f'cause.{stroke_name}.incidence_rate')
    }
    susceptible.add_transition(acute,
                               source_data_type='rate',
                               get_data_functions=data_funcs)
    acute.allow_self_transitions()
    acute.add_transition(post)
    post.allow_self_transitions()
    data_funcs = {
        'relapse_rate':
        lambda _, builder: builder.data.load(
            f'cause.{stroke_name}.incidence_rate')
    }
    post.add_transition(acute,
                        source_data_type='rate',
                        get_data_functions=data_funcs)
    #post.add_transition(susceptible, source_data_type='time')

    return DiseaseModel(stroke_name, states=[susceptible, acute, post])
コード例 #6
0
def IschemicHeartDisease():
    susceptible = SusceptibleState('ischemic_heart_disease')
    data_funcs = {'dwell_time': lambda *args: pd.Timedelta(days=28)}
    acute_mi = DiseaseState('acute_myocardial_infarction',
                            cause_type='sequela',
                            get_data_functions=data_funcs)
    #data_funcs = {'dwell_time': lambda *args: pd.Timedelta(days=365.25)}
    post_mi = RelapseState(
        'post_myocardial_infarction',
        cause_type='sequela',
    )

    susceptible.allow_self_transitions()
    data_funcs = {
        'incidence_rate':
        lambda _, builder: builder.data.load(
            'cause.ischemic_heart_disease.incidence_rate')
    }
    susceptible.add_transition(acute_mi,
                               source_data_type='rate',
                               get_data_functions=data_funcs)
    acute_mi.allow_self_transitions()
    acute_mi.add_transition(post_mi)
    post_mi.allow_self_transitions()
    data_funcs = {
        'relapse_rate':
        lambda _, builder: builder.data.load(
            'cause.ischemic_heart_disease.incidence_rate')
    }
    post_mi.add_transition(acute_mi,
                           source_data_type='rate',
                           get_data_functions=data_funcs)
    #post_mi.add_transition(susceptible, source_data_type='time')

    return DiseaseModel('ischemic_heart_disease',
                        states=[susceptible, acute_mi, post_mi])