tlo.methods.depression module
This is the Depression Module.
- class Depression(name=None, resourcefilepath=None)[source]
Bases:
tlo.core.Module
,tlo.methods.hsi_generic_first_appts.GenericFirstAppointmentsMixin
PARAMETERS:
Item
Type
Description
init_pr_depr_m_age1519_no_cc_wealth123
REAL
Initial probability of being depressed in male age1519 with no chronic condition with wealth level 1 or 2 or 3
init_rp_depr_f_not_rec_preg
REAL
Initial relative prevalence of being depressed in females not recently pregnant
init_rp_depr_f_rec_preg
REAL
Initial relative prevalence of being depressed in females recently pregnant
init_rp_depr_age2059
REAL
Initial relative prevalence of being depressed in 20-59 year olds vs 15-19
init_rp_depr_agege60
REAL
Initial relative prevalence of being depressed in 60+ year olds vs 15-19
init_rp_depr_cc
REAL
Initial relative prevalence of being depressed in people with chronic condition
init_rp_depr_wealth45
REAL
Initial relative prevalence of being depressed in people with wealth level 4 or 5 vs 1 or 2 or 3
init_rp_ever_depr_per_year_older_m
REAL
Initial relative prevalence ever depression per year older in men
init_rp_ever_depr_per_year_older_f
REAL
Initial relative prevalence ever depression per year older in women
init_pr_ever_talking_therapy_if_diagnosed
REAL
Initial probability of ever having had talking therapy if ever diagnosed with depression
init_pr_antidepr_curr_depr
REAL
Initial probability of being on antidepressants if currently depressed
init_rp_antidepr_ever_depr_not_curr
REAL
Initial relative prevalence of being on antidepressants if ever depressed but not currently
init_pr_ever_diagnosed_depression
REAL
Initial probability of having ever been diagnosed with depression, amongst people with ever depression and not on antidepressants
init_pr_ever_self_harmed_if_ever_depr
REAL
Initial probability of having ever self harmed if ever depressed
base_3m_prob_depr
REAL
Probability of onset of depression in a 3 month period if male, wealth 1 2 or 3, no chronic condition and never previously depressed
rr_depr_wealth45
REAL
Relative rate of depression when in wealth level 4 or 5 vs 1 or 2 or 3
rr_depr_cc
REAL
Relative rate of depression if has any chronic disease
rr_depr_pregnancy
REAL
Relative rate of depression when pregnant or recently pregnant
rr_depr_female
REAL
Relative rate of depression for females vs males
rr_depr_prev_epis
REAL
Relative rate of depression associated with previous depression vs never previously depressed
rr_depr_on_antidepr
REAL
Relative rate of depression episode if on antidepressants
rr_depr_age1519
REAL
Relative rate of depression associated with 15-20 year olds
rr_depr_agege60
REAL
Relative rate of depression associated with age > 60
rr_depr_hiv
REAL
Relative rate of depression associated with HIV infection
depr_resolution_rates
LIST
Risk of depression resolving in 3 months if no chronic conditions and no treatments.Each individual is equally likely to be assigned each of these risks
rr_resol_depr_cc
REAL
Relative rate of resolving depression if has any chronic disease
rr_resol_depr_on_antidepr
REAL
Relative rate of resolving depression if on antidepressants
rr_resol_depr_current_talk_ther
REAL
Relative rate of resolving depression if has ever had talking therapy vs has never had talking therapy
prob_3m_stop_antidepr
REAL
Probability per 3 months of stopping antidepressants when not currently depressed.
prob_3m_default_antidepr
REAL
Probability per 3 months of stopping antidepressants when still depressed.
prob_3m_suicide_depr_m
REAL
Probability per 3 months of suicide in currently depressed men
rr_suicide_depr_f
REAL
Relative risk of suicide in women compared with men
prob_3m_selfharm_depr
REAL
Probability per 3 months of non-fatal self harm in those currently depressed
sensitivity_of_assessment_of_depression
REAL
The sensitivity of the clinical assessment in detecting the true current status of depression
pr_assessed_for_depression_in_generic_appt_level1
REAL
Probability that a person is assessed for depression during a non-emergency generic appointmentlevel 1
anti_depressant_medication_item_code
INT
The item code used for one month of anti-depressant treatment
pr_assessed_for_depression_for_perinatal_female
REAL
Probability that a perinatal female is assessed for depression during antenatal or postnatal services
PROPERTIES:
Item
Type
Description
de_depr
BOOL
whether this person is currently depressed
de_ever_depr
BOOL
whether this person has ever experienced depression
de_date_init_most_rec_depr
DATE
date this person last initiated a depression episode
de_date_depr_resolved
DATE
date this person resolved last episode of depression
de_intrinsic_3mo_risk_of_depr_resolution
REAL
the risk per 3 mo of an episode of depression being resolved in absence of any treatment
de_ever_diagnosed_depression
BOOL
whether ever diagnosed with depression
de_on_antidepr
BOOL
is currently on anti-depressants
de_ever_talk_ther
BOOL
whether this person has ever had a session of talking therapy
de_ever_non_fatal_self_harm_event
BOOL
ever had a non-fatal self harm event
de_cc
BOOL
whether this person has chronic condition
de_recently_pregnant
BOOL
whether this person is female and is either currently pregnant or had a last pregnancy less than one year ago
Class attributes:
CAUSES_OF_DEATH : {‘Suicide’: <tlo.methods.causes.Cause object at 0x12a59c4d0>}
CAUSES_OF_DISABILITY : {‘SevereDepression’: <tlo.methods.causes.Cause object at 0x12a59cfd0>}
INIT_DEPENDENCIES : {‘HealthSystem’, ‘Demography’, ‘SymptomManager’, ‘Lifestyle’, ‘Contraception’}
METADATA : {<Metadata.DISEASE_MODULE: 1>, <Metadata.USES_HEALTHBURDEN: 4>, <Metadata.USES_HEALTHSYSTEM: 3>, <Metadata.USES_SYMPTOMMANAGER: 2>}
OPTIONAL_INIT_DEPENDENCIES : {‘HealthBurden’, ‘Hiv’}
Functions (defined or overridden in class Depression):
- __init__(name=None, resourcefilepath=None)[source]
Construct a new disease module ready to be included in a simulation.
Initialises an empty parameters dictionary and module-specific random number generator.
- Parameters:
name – the name to use for this module. Defaults to the concrete subclass’ name.
- read_parameters(data_folder)[source]
read parameters, register disease module with healthsystem and register symptoms
- apply_linear_model(lm, df)[source]
Helper function will apply the linear model (lm) on the dataframe (df) to get a probability of some event happening to each individual. It then returns a series with same index with bools indicating the outcome based on the toss of the biased coin. :param lm: The linear model :param df: The dataframe :return: Series with same index containing outcomes (bool)
- initialise_population(population)[source]
Set our property values for the initial population.
Must be implemented by subclasses.
This method is called by the simulation when creating the initial population, and is responsible for assigning initial values, for every individual, of those properties ‘owned’ by this module, i.e. those declared in its PROPERTIES dictionary.
TODO: We probably need to declare somehow which properties we ‘read’ here, so the simulation knows what order to initialise modules in!
- Parameters:
population – the population of individuals
- initialise_simulation(sim)[source]
Launch the main polling event and the logging event. Schedule the refill prescriptions for those on antidepressants. Register the assessment of depression with the DxManager.
- on_birth(mother_id, child_id)[source]
Initialise our properties for a newborn individual – they will not have depression or any history of it. :param mother_id: the mother for this child :param child_id: the new child
- on_hsi_alert(person_id, treatment_id)[source]
Nothing happens if this module is alerted to a person attending an HSI
- report_daly_values()[source]
Report DALYs based status in the previous month. A DALY weight is attached to a status of depression for as long as the depression lasted in the previous month.
- _check_for_suspected_depression(symptoms: List[str], treatment_id: str, has_even_been_diagnosed: bool)[source]
Returns True if any signs of depression are present, otherwise False.
Raises an error if the treatment type cannot be identified.
- do_on_presentation_to_care(person_id: int, hsi_event: HSI_Event)[source]
This member function is called when a person is in an HSI, and there may need to be screening for depression.
- do_when_suspected_depression(person_id: int, individual_properties: dict | IndividualProperties, schedule_hsi_event: HSIEventScheduler, diagnosis_function: DiagnosisFunction | None = None, hsi_event: HSI_Event | None = None) None [source]
This is called by any HSI event when depression is suspected or otherwise investigated.
At least one of the diagnosis_function or hsi_event arguments must be provided; if both are provided, the hsi_event argument is ignored. - If the hsi_event argument is provided, that event is used to access the diagnosis manager and run diagnosis tests. - If the diagnosis_function is passed in directly, it is assumed to be a Callable method that runs diagnosis tests.
- Parameters:
person_id – Patient’s row index in the population DataFrame.
individual_properties – Indexable object to write individual property updates to.
schedule_hsi_event – Function to schedule subsequent HSI events.
diagnosis_function – A function capable of running diagnosis checks on the population.
hsi_event – The HSI_Event that triggered this call.
- do_at_generic_first_appt(individual_properties: IndividualProperties, **kwargs) None [source]
Actions to take during a non-emergency generic health system interaction (HSI).
Derived classes should overwrite this method so that they are compatible with the
HealthSystem
module, and can schedule HSI events when a individual presents symptoms indicative of the corresponding illness or condition.When overwriting, arguments that are not required can be left out of the definition. If done so, the method must take a
**kwargs
input to avoid errors when looping over all disease modules and running their generic HSI methods.HSI events should be scheduled by the
Module
subclass implementing this method using theschedule_hsi_event
argument.Implementations of this method should not make any updates to the population dataframe directly - if the target individuals properties need to be updated this should be performed by updating the
individual_properties
argument.- Parameters:
person_id – Row index (ID) of the individual target of the HSI event in the population dataframe.
individual_properties – Properties of individual target as provided in the population dataframe. Updates to individual properties may be written to this object.
symptoms – List of symptoms the patient is experiencing.
schedule_hsi_event – A function that can schedule subsequent HSI events.
diagnosis_function – A function that can run diagnosis tests based on the patient’s symptoms.
consumables_checker – A function that can query the health system to check for available consumables.
facility_level – The level of the facility that the patient presented at.
treatment_id – The treatment id of the HSI event triggering the generic appointment.
- do_at_generic_first_appt_emergency(person_id: int, individual_properties: IndividualProperties, symptoms: List[str], schedule_hsi_event: HSIEventScheduler, diagnosis_function: DiagnosisFunction, treatment_id: str, **kwargs) None [source]
Actions to take during an emergency generic health system interaction (HSI).
Call signature is identical to the
do_at_generic_first_appt()
method.Derived classes should overwrite this method so that they are compatible with the :py:class`~.HealthSystem` module, and can schedule HSI events when a individual presents symptoms indicative of the corresponding illness or condition.
- class DepressionPollingEvent(module)[source]
The regular event that actually changes individuals’ depression status. It occurs every 3 months and this cannot be changed. The onset and resolution of depression events occurs at the polling event and synchronously for all persons. Individual level events (HSI, self-harm/suicide events) may occur at other times.
Bases:
tlo.events.RegularEvent
,tlo.events.Event
,tlo.events.PopulationScopeEventMixin
Class attributes:
__annotations__ : {}
Functions (defined or overridden in class DepressionPollingEvent):
- class DepressionSelfHarmEvent(module, person_id)[source]
This is a Self-Harm event. It has been scheduled to occur by the DepressionPollingEvent. It imposes the Injuries_From_Self_Harm symptom, which will lead to emergency care being sought
Bases:
tlo.events.Event
,tlo.events.IndividualScopeEventMixin
Functions (defined or overridden in class DepressionSelfHarmEvent):
- __init__(module, person_id)[source]
Create a new event.
Note that just creating an event does not schedule it to happen; that must be done by calling Simulation.schedule_event.
- Parameters:
module – the module that created this event. All subclasses of Event take this as the first argument in their constructor, but may also take further keyword arguments.
priority – a keyword-argument to set the priority (see Priority enum)
- class DepressionSuicideEvent(module, person_id)[source]
This is a Suicide event. It has been scheduled to occur by the DepressionPollingEvent. It causes the immediate death of the person.
Bases:
tlo.events.Event
,tlo.events.IndividualScopeEventMixin
Functions (defined or overridden in class DepressionSuicideEvent):
- __init__(module, person_id)[source]
Create a new event.
Note that just creating an event does not schedule it to happen; that must be done by calling Simulation.schedule_event.
- Parameters:
module – the module that created this event. All subclasses of Event take this as the first argument in their constructor, but may also take further keyword arguments.
priority – a keyword-argument to set the priority (see Priority enum)
- class DepressionLoggingEvent(module)[source]
This is the LoggingEvent for Depression. It runs every 3 months and gives: * population summaries for statuses for Depression at that time. * counts of events of self-harm and suicide that have occurred in the 3 months prior
Bases:
tlo.events.RegularEvent
,tlo.events.Event
,tlo.events.PopulationScopeEventMixin
Class attributes:
__annotations__ : {}
Functions (defined or overridden in class DepressionLoggingEvent):
- class HSI_Depression_TalkingTherapy(module, person_id)[source]
This is a Health System Interaction Event in which a person receives a session of talking therapy. It is one of a course of 5 sessions (at months 0, 6, 12, 18, 24). If one of these HSI does not happen then no further sessions occur. Sessions after the first have no direct effect, as the only property affected is reflects ever having had one session of talking therapy.
Bases:
tlo.methods.hsi_event.HSI_Event
,tlo.events.IndividualScopeEventMixin
Class attributes:
__annotations__ : {}
Functions (defined or overridden in class HSI_Depression_TalkingTherapy):
- __init__(module, person_id)[source]
Create a new event.
Note that just creating an event does not schedule it to happen; that must be done by calling Simulation.schedule_event.
- Parameters:
module – the module that created this event. All subclasses of Event take this as the first argument in their constructor, but may also take further keyword arguments.
- class HSI_Depression_Start_Antidepressant(module, person_id)[source]
This is a Health System Interaction Event in which a person is started on anti-depressants. The facility_level is modified as a input parameter.
Bases:
tlo.methods.hsi_event.HSI_Event
,tlo.events.IndividualScopeEventMixin
Class attributes:
__annotations__ : {}
Functions (defined or overridden in class HSI_Depression_Start_Antidepressant):
- __init__(module, person_id)[source]
Create a new event.
Note that just creating an event does not schedule it to happen; that must be done by calling Simulation.schedule_event.
- Parameters:
module – the module that created this event. All subclasses of Event take this as the first argument in their constructor, but may also take further keyword arguments.
- class HSI_Depression_Refill_Antidepressant(module, person_id)[source]
This is a Health System Interaction Event in which a person seeks a refill prescription of anti-depressants. The next refill of anti-depressants is also scheduled. If the person is flagged as not being on antidepressants, then the event does nothing and returns a blank footprint. If it does not run, then person ceases to be on anti-depressants and no further refill HSI are scheduled.
Bases:
tlo.methods.hsi_event.HSI_Event
,tlo.events.IndividualScopeEventMixin
Class attributes:
__annotations__ : {}
Functions (defined or overridden in class HSI_Depression_Refill_Antidepressant):
- __init__(module, person_id)[source]
Create a new event.
Note that just creating an event does not schedule it to happen; that must be done by calling Simulation.schedule_event.
- Parameters:
module – the module that created this event. All subclasses of Event take this as the first argument in their constructor, but may also take further keyword arguments.