Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates from paper analyses for HIV, TB and malaria #1273

Merged
merged 110 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
7590a5b
updates from paper analyses for HIV, TB and malaria
tdm32 Feb 9, 2024
22c10f0
remove unused import statements
tdm32 Feb 9, 2024
e8612a3
fix imports
tdm32 Feb 9, 2024
c6802c9
update filepath for malaria resource file
tdm32 Feb 9, 2024
8014f02
remove test_hiv_tb_scenarios.py
tdm32 Feb 9, 2024
63a364a
updated test_healthsystem.py: test_manipulation_of_service_availabili…
tdm32 Feb 13, 2024
b591b82
change ipt_coverage in TB logger as conflicts with existing parameter
tdm32 Feb 13, 2024
68b295e
updated ResourceFile_Improved_Healthsystem_And_Healthcare_Seeking.xls…
tdm32 Feb 13, 2024
7dbe7b5
remove test code
tdm32 Feb 13, 2024
09c9b26
remove test code
tdm32 Feb 13, 2024
3800748
Merge branch 'master' into tara_feb2024_updates_clean
tdm32 Feb 13, 2024
73f19da
delete tmp resourcefiles
tdm32 Feb 13, 2024
b81b2d6
malaria code use person_id consistently instead of individual_id
tdm32 Feb 13, 2024
df2b77e
use individual_id for demography.do_death()
tdm32 Feb 13, 2024
b2bd355
style change to avoid conflicts with master
tdm32 Feb 14, 2024
09b9b66
style change to avoid conflicts with master
tdm32 Feb 14, 2024
8a241e4
Merge branch 'master' into tara_feb2024_updates_clean
tdm32 Feb 14, 2024
758955e
fix conflicts with master
tdm32 Feb 14, 2024
f7ac7e2
fix conflicts with master
tdm32 Feb 14, 2024
c037a4d
Merge branch 'master' into tara_feb2024_updates_clean
tdm32 Feb 14, 2024
9690949
merge in master
tdm32 Feb 14, 2024
05c69ff
check property hv_date_last_ART correctly set
tdm32 Feb 15, 2024
3e3c0d4
Manually add PostnatalCare_Comprehensive to policy priorities
tdm32 Feb 16, 2024
cfd9166
edit fix
tdm32 Feb 16, 2024
3ff7bcb
add schisto high infection as conditional predictor for bladder cancer
tdm32 Feb 27, 2024
434147c
fix conditional predictor for active TB - should check presence of Ca…
tdm32 Feb 27, 2024
808c5ae
add 'ss' prefix to properties from schisto module referenced in bladd…
tdm32 Feb 27, 2024
218f4cf
edit praziquantel code in schisto.py to use value from CMST in place …
tdm32 Feb 27, 2024
f8ebee5
add parameter rr_depr_hiv for risk of depression with HIV infection
tdm32 Feb 27, 2024
904905d
tidy up linear models in depression, include conditional predictors f…
tdm32 Feb 27, 2024
79216db
move hv_inf into conditional predictor for depression in initial popu…
tdm32 Feb 27, 2024
ade9f57
convert lm for incident cancer (site_confined) to model with conditio…
tdm32 Feb 28, 2024
754a1bf
add parameter rr_site_confined_hiv to other_adult_cancers.py
tdm32 Feb 28, 2024
876c979
update other_adult_cancers write-up to include HIV as risk factor
tdm32 Feb 28, 2024
865aae0
update Depression.docx to include HIV as risk factor for depression
tdm32 Feb 28, 2024
5bb2560
edit HIV in depression to include only HIV cases not virally suppressed
tdm32 Feb 28, 2024
9cb1043
update other_adult_cancers.py linear model to include HIV as risk fac…
tdm32 Feb 28, 2024
1e316af
edit: HIV remains as risk factor for depression independent of treatm…
tdm32 Feb 28, 2024
85cec50
include HIV as risk factor for low grade dysplasia (oesophageal cance…
tdm32 Feb 28, 2024
6f45dc7
update linear model for low grade dysplasia to include HIV as conditi…
tdm32 Feb 28, 2024
2dbb98d
update OesophagealCancer.docx write-up to include HIV risk
tdm32 Feb 28, 2024
b6b5fdc
add condition hiv diagnosed for increased risk of depression
tdm32 Mar 4, 2024
a040823
remove hiv as risk factor for oesophageal cancer
tdm32 Mar 4, 2024
1eeff16
remove parameter for hiv as risk factor for oesophageal cancer
tdm32 Mar 4, 2024
78b73e5
update OesophagealCancer.docx to remove hiv as risk factor
tdm32 Mar 4, 2024
b899660
update value for weighted risk of other_adult_cancers with unsuppress…
tdm32 Mar 4, 2024
599580b
add rr_hiv to linear model. update ResourceFile_cmd_condition_onset.x…
tdm32 Mar 4, 2024
953502e
update resourcefiles for CMD include rr_hiv for all, no effect of maj…
tdm32 Mar 4, 2024
b57a503
add diabetes as risk for active TB and relapse. add params to Resourc…
tdm32 Mar 5, 2024
465b18b
add diabetes as risk factor for tb death
tdm32 Mar 5, 2024
d573211
add diabetes as risk factor for PLHIV with active TB and on TB treatment
tdm32 Mar 5, 2024
3734acb
add diabetes as risk factor for PLHIV with active TB and on TB treatment
tdm32 Mar 5, 2024
7e5f6a6
set up run to check calibration of deaths and disability
tdm32 Mar 5, 2024
b786256
add predictor high-intensity S. haematobium infection to risk of blad…
tdm32 Mar 6, 2024
956b09a
add predictor high-intensity S. haematobium infection to risk of HIV …
tdm32 Mar 6, 2024
e375927
fix indenting in HSI_Hiv_StartOrContinueTreatment
tdm32 Mar 7, 2024
272558f
add hv_date_treated abd hv_date_last_ART to baseline_art
tdm32 Mar 7, 2024
8602f03
convert linear model in CMD to include conditional predictors
tdm32 Mar 11, 2024
2f87289
delete resourcefile created in error
tdm32 Mar 11, 2024
c8d65f4
comment out path-specific changes to analysis_cause_of_death_and_disa…
tdm32 Mar 11, 2024
1574c3a
fix CMD error if Hiv not registered
tdm32 Mar 11, 2024
7b6e3d5
Merge branch 'master' into tara_hiv_ncd_feb2024
tdm32 Mar 11, 2024
f20b151
Merge branch 'master' into tara_hiv_ncd_feb2024
tdm32 Mar 11, 2024
3e982bf
Merge remote-tracking branch 'origin/tara_hiv_ncd_feb2024' into tara_…
tdm32 Mar 11, 2024
f0466bf
Merge branch 'master' into tara_feb2024_updates_clean
tdm32 Mar 12, 2024
9901edd
remove parameter rr_bcg_inf from tb.py
tdm32 Mar 19, 2024
62e5c04
Merge branch 'master' into tara_feb2024_updates_clean
tdm32 Mar 22, 2024
7e3e20f
edit comment in initialise_simulation
tdm32 Mar 22, 2024
7ec6efa
Merge branch 'tara_hiv_ncd_feb2024' into tara_feb2024_updates_clean
tdm32 Mar 22, 2024
922ac8e
fix parameter name error
tdm32 Mar 22, 2024
1b61aaf
update parameters
tdm32 Mar 22, 2024
3aa7b46
test runs
tdm32 Mar 22, 2024
604bd14
edit and fix flake8 errors
tdm32 Mar 22, 2024
629e2e0
fix failing test
tdm32 Mar 22, 2024
8bba11c
update ResourceFile_Improved_Healthsystem_And_Healthcare_Seeking.xlsx
tdm32 Mar 25, 2024
6543bd0
update ResourceFile_PriorityRanking_ALLPOLICIES.xlsx
tdm32 Mar 25, 2024
5edc77d
updated ResourceFile_Improved_Healthsystem_And_Healthcare_Seeking.xlsx
tdm32 Mar 25, 2024
a1f0da9
Merge branch 'master' into tara_feb2024_updates_clean
tdm32 Apr 22, 2024
b34d670
edit check for last ART when new dispensation occurs
tdm32 May 2, 2024
d56c3d8
update schisto risk on HIV to only include women
tdm32 May 13, 2024
ae988fb
Merge branch 'master' into tara_feb2024_updates_clean
tbhallett May 13, 2024
c40bec9
Update tests/test_healthsystem.py
tdm32 May 21, 2024
8a90ff7
address comments in PR
tdm32 May 21, 2024
9d32174
address comments in PR
tdm32 May 21, 2024
866e839
check changes in PR and rollback
tdm32 May 21, 2024
95b2781
check changes in PR and rollback
tdm32 May 21, 2024
b617058
fix failing tests
tdm32 May 22, 2024
6c96f85
merge in latest files from master
tdm32 May 22, 2024
feef07d
merge in latest files from master
tdm32 May 22, 2024
aa7eba4
Merge branch 'master' into tara_feb2024_updates_clean
tdm32 May 22, 2024
6e08709
baseline AIDS/death scheduling should happen for anyone on ART and no…
tdm32 May 22, 2024
4fa382c
Merge remote-tracking branch 'origin/tara_feb2024_updates_clean' into…
tdm32 May 22, 2024
03a33ac
fix failing tests in test_hiv.py
tdm32 May 22, 2024
2f96a67
check tests_hiv passing locally
tdm32 May 23, 2024
2260d4c
update enhanced_lifestyle.py due to failing test
tdm32 May 23, 2024
97027d7
remove json file committed accidentally
tbhallett May 24, 2024
a17bfbf
roll back incidental changes in test_healthsystem.py
tbhallett May 24, 2024
a27dfdc
roll back inicdental changes in malaria
tbhallett May 24, 2024
55543bb
roll back incidental changes in test_healthsystem.py
tbhallett May 24, 2024
932e33e
roll back incidental changes
tbhallett May 24, 2024
5fa5a4d
Update src/tlo/methods/hiv.py
tdm32 May 28, 2024
b3b3259
check the usage of '' versus ""
tdm32 May 28, 2024
c472f82
set VMMC HSI to level 1b otherwise consumables never available
tdm32 May 28, 2024
e250664
Merge branch 'master' into tara_feb2024_updates_clean
tdm32 May 29, 2024
b9984e6
Merge branch 'master' into tara_feb2024_updates_clean
tbhallett May 29, 2024
9979cab
check events using isinstance not string check (string could change)
tbhallett May 30, 2024
a301abf
linting
tbhallett May 30, 2024
dd56918
roll back incidental (formatting) changes in malaria.py
tbhallett May 30, 2024
e34c6de
reinstate checks to avoid division by zero
tbhallett May 30, 2024
e659225
isort
tbhallett May 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/write-ups/Depression.docx
Git LFS file not shown
4 changes: 2 additions & 2 deletions docs/write-ups/OesophagealCancer.docx
Git LFS file not shown
4 changes: 2 additions & 2 deletions docs/write-ups/OtherAdultCancer.docx
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/ResourceFile_Depression.xlsx
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/ResourceFile_HIV.xlsx
Git LFS file not shown
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/ResourceFile_Other_Adult_Cancers.xlsx
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/ResourceFile_TB.xlsx
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/cmd/ResourceFile_cmd_condition_death.xlsx
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/cmd/ResourceFile_cmd_condition_onset.xlsx
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/cmd/ResourceFile_cmd_condition_removal.xlsx
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/cmd/ResourceFile_cmd_condition_testing.xlsx
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/cmd/ResourceFile_cmd_events.xlsx
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/cmd/ResourceFile_cmd_events_death.xlsx
Git LFS file not shown
tbhallett marked this conversation as resolved.
Show resolved Hide resolved
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/malaria/ResourceFile_malaria.xlsx
Git LFS file not shown
4 changes: 2 additions & 2 deletions src/scripts/hiv/projections_jan2023/analysis_full_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

# %% Run the simulation
start_date = Date(2010, 1, 1)
end_date = Date(2020, 1, 1)
popsize = 5000
end_date = Date(2012, 1, 1)
popsize = 500
# scenario = 0

# set up the log config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@

# %% Run the simulation
start_date = Date(2010, 1, 1)
end_date = Date(2015, 1, 1)
popsize = 5000
end_date = Date(2014, 1, 1)
popsize = 1000

# scenario = 1

Expand Down
40 changes: 26 additions & 14 deletions src/tlo/methods/bladder_cancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def __init__(self, name=None, resourcefilepath=None):

INIT_DEPENDENCIES = {'Demography', 'Lifestyle', 'HealthSystem', 'SymptomManager'}

OPTIONAL_INIT_DEPENDENCIES = {'HealthBurden'}
OPTIONAL_INIT_DEPENDENCIES = {'HealthBurden', 'Schisto'}

METADATA = {
Metadata.DISEASE_MODULE,
Expand Down Expand Up @@ -242,17 +242,23 @@ def initialise_population(self, population):
# check parameters are sensible: probability of having any cancer stage cannot exceed 1.0
assert sum(p['init_prop_bladder_cancer_stage']) <= 1.0

lm_init_bc_status_any_stage = LinearModel(
LinearModelType.MULTIPLICATIVE,
sum(p['init_prop_bladder_cancer_stage']),
predictors = [
Predictor('li_tob').when(True, p['rp_bladder_cancer_tobacco']),
# todo: add line when schisto is merged
# Predictor('sh_infection_status').when('High-infection', p['rp_bladder_cancer_schisto_h']),
Predictor('age_years', conditions_are_mutually_exclusive=True)
.when('.between(30,49)', p['rp_bladder_cancer_age3049'])
.when('.between(50,69)', p['rp_bladder_cancer_age5069'])
.when('.between(70,120)', p['rp_bladder_cancer_agege70'])
.when('.between(0,14)', 0.0)
]

conditional_predictors = [
Predictor('ss_sh_infection_status').when('High-infection', p['rp_bladder_cancer_schisto_h']),
] if "Schisto" in self.sim.modules else []
tbhallett marked this conversation as resolved.
Show resolved Hide resolved

lm_init_bc_status_any_stage = LinearModel(
LinearModelType.MULTIPLICATIVE,
sum(p['init_prop_bladder_cancer_stage']),
*(predictors + conditional_predictors)
)

bc_status_any_stage = lm_init_bc_status_any_stage.predict(df.loc[df.is_alive], self.rng)
Expand Down Expand Up @@ -397,20 +403,26 @@ def initialise_simulation(self, sim):
p = self.parameters
lm = self.linear_models_for_progession_of_bc_status

lm['tis_t1'] = LinearModel(
LinearModelType.MULTIPLICATIVE,
p['r_tis_t1_bladder_cancer_none'],
# todo: add in when schisto is in
# Predictor('sh_infection_status').when('High-infection', p['rp_bladder_cancer_schisto_h']),
predictors = [
Predictor('age_years', conditions_are_mutually_exclusive=True)
.when('.between(30,49)', p['rp_bladder_cancer_age3049'])
.when('.between(50,69)', p['rp_bladder_cancer_age5069'])
.when('.between(70,120)', p['rp_bladder_cancer_agege70'])
.when('.between(0,14)', 0.0),
Predictor('li_tob').when(True, p['rr_tis_t1_bladder_cancer_none_tobacco']),
# todo: add in when schisto module in master
# Predictor('sh_').when(True, p['rr_tis_t1_bladder_cancer_none_ex_alc']),
Predictor('bc_status').when('none', 1.0).otherwise(0.0)
# todo:
# Predictor('tmp_').when(True, p['rr_tis_t1_bladder_cancer_none_ex_alc']),
tbhallett marked this conversation as resolved.
Show resolved Hide resolved
Predictor('bc_status').when('none', 1.0).otherwise(0.0),
]

conditional_predictors = [
Predictor('ss_sh_infection_status').when('High-infection', p['rp_bladder_cancer_schisto_h']),
] if "Schisto" in self.sim.modules else []
tbhallett marked this conversation as resolved.
Show resolved Hide resolved

lm["tis_t1"] = LinearModel(
LinearModelType.MULTIPLICATIVE,
p['r_tis_t1_bladder_cancer_none'],
*(predictors + conditional_predictors)
)

lm['t2p'] = LinearModel(
Expand Down
17 changes: 13 additions & 4 deletions src/tlo/methods/cardio_metabolic_disorders.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class CardioMetabolicDisorders(Module):

INIT_DEPENDENCIES = {'Demography', 'Lifestyle', 'HealthSystem', 'SymptomManager'}

OPTIONAL_INIT_DEPENDENCIES = {'HealthBurden'}
OPTIONAL_INIT_DEPENDENCIES = {'HealthBurden', 'Hiv'}

ADDITIONAL_DEPENDENCIES = {'Depression'}

Expand Down Expand Up @@ -598,9 +598,7 @@ def build_linear_model(self, condition, interval_between_polls, lm_type):
# LinearModel expects native python types - if it's numpy type, convert it
baseline_annual_probability = float(baseline_annual_probability)

linearmodel = LinearModel(
LinearModelType.MULTIPLICATIVE,
baseline_annual_probability,
predictors = [
Predictor('sex').when('M', p['rr_male']),
Predictor(
'age_years',
Expand Down Expand Up @@ -693,6 +691,17 @@ def build_linear_model(self, condition, interval_between_polls, lm_type):
'rr_chronic_ischemic_heart_disease_on_medication']),
Predictor('nc_ever_stroke_on_medication').when(True, p['rr_stroke_on_medication']),
Predictor('nc_ever_heart_attack_on_medication').when(True, p['rr_heart_attack_on_medication'])
]

conditional_predictors = [
Predictor().when('hv_inf & '
'(hv_art != "on_VL_suppressed")', p['rr_hiv']),
] if "Hiv" in self.sim.modules else []
tbhallett marked this conversation as resolved.
Show resolved Hide resolved

linearmodel = LinearModel(
LinearModelType.MULTIPLICATIVE,
baseline_annual_probability,
*(predictors + conditional_predictors)
)

return linearmodel
Expand Down
63 changes: 51 additions & 12 deletions src/tlo/methods/depression.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, name=None, resourcefilepath=None):
'Demography', 'Contraception', 'HealthSystem', 'Lifestyle', 'SymptomManager'
}

OPTIONAL_INIT_DEPENDENCIES = {'HealthBurden'}
OPTIONAL_INIT_DEPENDENCIES = {'HealthBurden', 'Hiv'}

# Declare Metadata
METADATA = {
Expand Down Expand Up @@ -145,6 +145,8 @@ def __init__(self, name=None, resourcefilepath=None):

'rr_depr_agege60': Parameter(Types.REAL, 'Relative rate of depression associated with age > 60'),

'rr_depr_hiv': Parameter(Types.REAL, 'Relative rate of depression associated with HIV infection'),

'depr_resolution_rates': Parameter(
Types.LIST,
'Risk of depression resolving in 3 months if no chronic conditions and no treatments.'
Expand Down Expand Up @@ -227,11 +229,13 @@ def read_parameters(self, data_folder):
)
p = self.parameters

# Build the Linear Models:
# Build the Linear Models

# ----- Initialisation of population -----
self.linearModels = dict()
self.linearModels['Depression_At_Population_Initialisation'] = LinearModel(
LinearModelType.MULTIPLICATIVE,
self.parameters['init_pr_depr_m_age1519_no_cc_wealth123'],

# risk of depression in initial population
predictors = [
Predictor('de_cc').when(True, p['init_rp_depr_cc']),
Predictor('li_wealth').when('.isin([4,5])', p['init_rp_depr_wealth45']),
Predictor().when('(sex=="F") & de_recently_pregnant', p['init_rp_depr_f_rec_preg']),
Expand All @@ -244,44 +248,63 @@ def read_parameters(self, data_folder):
.when('.between(0, 14)', 0)
.when('.between(15, 19)', 1.0)
.when('.between(20, 59)', p['init_rp_depr_age2059'])
.when('>= 60', p['init_rp_depr_agege60'])
.when('>= 60', p['init_rp_depr_agege60']),
]

conditional_predictors = [
Predictor().when(
'hv_inf & hv_diagnosed',
p["rr_depr_hiv"]),
] if "Hiv" in self.sim.modules else []
tbhallett marked this conversation as resolved.
Show resolved Hide resolved

self.linearModels["Depression_At_Population_Initialisation"] = LinearModel(
LinearModelType.MULTIPLICATIVE,
p['init_pr_depr_m_age1519_no_cc_wealth123'],
*(predictors + conditional_predictors)
)

# risk of ever having depression in initial population
self.linearModels['Depression_Ever_At_Population_Initialisation_Males'] = LinearModel.multiplicative(
Predictor('age_years').apply(
lambda x: (x if x > 15 else 0) * self.parameters['init_rp_ever_depr_per_year_older_m']
)
)

# risk of ever having depression in initial population (female)
self.linearModels['Depression_Ever_At_Population_Initialisation_Females'] = LinearModel.multiplicative(
Predictor('age_years').apply(lambda x: (x if x > 15 else 0) * p['init_rp_ever_depr_per_year_older_f'])
)

# risk of ever having diagnosed depression in initial population
self.linearModels['Depression_Ever_Diagnosed_At_Population_Initialisation'] = LinearModel.multiplicative(
Predictor('de_ever_depr').when(True, p['init_pr_ever_diagnosed_depression'])
.otherwise(0.0)
)

# risk of currently using anti-depressants in initial population
self.linearModels['Using_AntiDepressants_Initialisation'] = LinearModel.multiplicative(
Predictor('de_depr').when(True, p['init_pr_antidepr_curr_depr']),
Predictor().when('~de_depr & de_ever_diagnosed_depression', p['init_rp_antidepr_ever_depr_not_curr'])
)

# risk of ever having talking therapy in initial population
self.linearModels['Ever_Talking_Therapy_Initialisation'] = LinearModel(
LinearModelType.MULTIPLICATIVE,
p['init_pr_ever_talking_therapy_if_diagnosed'],
Predictor('de_ever_diagnosed_depression').when(False, 0)
)

# risk of ever having self-harmed in initial population
self.linearModels['Ever_Self_Harmed_Initialisation'] = LinearModel(
LinearModelType.MULTIPLICATIVE,
p['init_pr_ever_self_harmed_if_ever_depr'],
Predictor('de_ever_depr').when(False, 0)
)

self.linearModels['Risk_of_Depression_Onset_per3mo'] = LinearModel(
LinearModelType.MULTIPLICATIVE,
p['base_3m_prob_depr'],
# ----- Recurring events -----

# risk of depression every 3 months
predictors = [
Predictor('de_cc').when(True, p['rr_depr_cc']),
Predictor('age_years', conditions_are_mutually_exclusive=True)
.when('.between(0, 14)', 0)
Expand All @@ -291,26 +314,42 @@ def read_parameters(self, data_folder):
Predictor('sex').when('F', p['rr_depr_female']),
Predictor('de_recently_pregnant').when(True, p['rr_depr_pregnancy']),
Predictor('de_ever_depr').when(True, p['rr_depr_prev_epis']),
Predictor('de_on_antidepr').when(True, p['rr_depr_on_antidepr'])
Predictor('de_on_antidepr').when(True, p['rr_depr_on_antidepr']),
]

conditional_predictors = [
Predictor().when(
'hv_inf & hv_diagnosed',
p["rr_depr_hiv"]),
] if "Hiv" in self.sim.modules else []
tbhallett marked this conversation as resolved.
Show resolved Hide resolved

self.linearModels["Risk_of_Depression_Onset_per3mo"] = LinearModel(
LinearModelType.MULTIPLICATIVE,
p['base_3m_prob_depr'],
*(predictors + conditional_predictors)
)

# risk of depression resolution every 3 months
self.linearModels['Risk_of_Depression_Resolution_per3mo'] = LinearModel.multiplicative(
Predictor('de_intrinsic_3mo_risk_of_depr_resolution').apply(lambda x: x),
Predictor('de_cc').when(True, p['rr_resol_depr_cc']),
Predictor('de_on_antidepr').when(True, p['rr_resol_depr_on_antidepr']),
Predictor('de_ever_talk_ther').when(True, p['rr_resol_depr_current_talk_ther'])
)

# risk of stopping anti-depressants every 3 months
self.linearModels['Risk_of_Stopping_Antidepressants_per3mo'] = LinearModel.multiplicative(
Predictor('de_depr').when(True, p['prob_3m_default_antidepr'])
.when(False, p['prob_3m_stop_antidepr'])
)

# risk of self-harm every 3 months
self.linearModels['Risk_of_SelfHarm_per3mo'] = LinearModel(
LinearModelType.MULTIPLICATIVE,
p['prob_3m_selfharm_depr']
)

# risk of suicide every 3 months
self.linearModels['Risk_of_Suicide_per3mo'] = LinearModel(
LinearModelType.MULTIPLICATIVE,
p['prob_3m_suicide_depr_m'],
Expand Down Expand Up @@ -519,7 +558,7 @@ def _check_for_suspected_depression(
):
"""
Returns True if any signs of depression are present, otherwise False.

Raises an error if the treatment type cannot be identified.
"""
if treatment_id == "FirstAttendance_NonEmergency":
Expand Down Expand Up @@ -574,7 +613,7 @@ def do_when_suspected_depression(
"""
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
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.
Expand Down
Loading
Loading