Skip to content

Commit c9e65ca

Browse files
tbhalletttdm32marghe-molaro
authored
Updates to HTM Swtiching Method to Fix Issue #1411 (#1413)
* updates from paper analyses for HIV, TB and malaria * remove unused import statements * fix imports * update filepath for malaria resource file * remove test_hiv_tb_scenarios.py * updated test_healthsystem.py: test_manipulation_of_service_availability as small population size over 7 days will not schedule VMMC through HIV module. Remove HIV_Prevention_Circumcision in assert statement for HIV services delivered in one week * change ipt_coverage in TB logger as conflicts with existing parameter * updated ResourceFile_Improved_Healthsystem_And_Healthcare_Seeking.xlsx with updated NTP2019 TB data * remove test code * remove test code * delete tmp resourcefiles * malaria code use person_id consistently instead of individual_id * use individual_id for demography.do_death() * style change to avoid conflicts with master * style change to avoid conflicts with master * fix conflicts with master * fix conflicts with master * merge in master * check property hv_date_last_ART correctly set * Manually add PostnatalCare_Comprehensive to policy priorities * edit fix * add schisto high infection as conditional predictor for bladder cancer * fix conditional predictor for active TB - should check presence of CardioMetabolicDisorders * add 'ss' prefix to properties from schisto module referenced in bladder_cancer.py * edit praziquantel code in schisto.py to use value from CMST in place of donated * add parameter rr_depr_hiv for risk of depression with HIV infection * tidy up linear models in depression, include conditional predictors for hiv infection and add comments * move hv_inf into conditional predictor for depression in initial population * convert lm for incident cancer (site_confined) to model with conditional predictors. Include HIV as risk factor. * add parameter rr_site_confined_hiv to other_adult_cancers.py * update other_adult_cancers write-up to include HIV as risk factor * update Depression.docx to include HIV as risk factor for depression * edit HIV in depression to include only HIV cases not virally suppressed * update other_adult_cancers.py linear model to include HIV as risk factor only if not virally suppressed * edit: HIV remains as risk factor for depression independent of treatment status * include HIV as risk factor for low grade dysplasia (oesophageal cancer). Update ResourceFile_Oesophageal_Cancer.xlsx * update linear model for low grade dysplasia to include HIV as conditional risk factor * update OesophagealCancer.docx write-up to include HIV risk * add condition hiv diagnosed for increased risk of depression * remove hiv as risk factor for oesophageal cancer * remove parameter for hiv as risk factor for oesophageal cancer * update OesophagealCancer.docx to remove hiv as risk factor * update value for weighted risk of other_adult_cancers with unsuppressed HIV * add rr_hiv to linear model. update ResourceFile_cmd_condition_onset.xlsx with rr_hiv, leave value=1.0 if no effect of hiv * update resourcefiles for CMD include rr_hiv for all, no effect of majority of processes * refactoring: * put the helper function for switching scenario into same file a ScenarioSwitcher class * put tests for class and helper function together (next step will be to rename and mock-up extended functionality) * add diabetes as risk for active TB and relapse. add params to ResourceFile_TB.xlsx replace linearmodels dict which was accidentally removed in depression.py * add diabetes as risk factor for tb death * add diabetes as risk factor for PLHIV with active TB and on TB treatment * add diabetes as risk factor for PLHIV with active TB and on TB treatment * set up run to check calibration of deaths and disability * add predictor high-intensity S. haematobium infection to risk of bladder cancer in initial population * add predictor high-intensity S. haematobium infection to risk of HIV acquisition * fix indenting in HSI_Hiv_StartOrContinueTreatment * add hv_date_treated abd hv_date_last_ART to baseline_art * convert linear model in CMD to include conditional predictors * delete resourcefile created in error * comment out path-specific changes to analysis_cause_of_death_and_disability_calibrations.py * fix CMD error if Hiv not registered * initial sketch of structure * tidy-up and fix tests * commments * remove parameter rr_bcg_inf from tb.py * edit comment in initialise_simulation * fix parameter name error * update parameters * test runs * edit and fix flake8 errors * fix failing test * update ResourceFile_Improved_Healthsystem_And_Healthcare_Seeking.xlsx * update ResourceFile_PriorityRanking_ALLPOLICIES.xlsx * updated ResourceFile_Improved_Healthsystem_And_Healthcare_Seeking.xlsx * scenario file * starting work on the scenario file * design and HR scenarios * scenario for HRH * roll back changes to ScenarioSwitcher * Revert "roll back changes to ScenarioSwitcher" This reverts commit 49d14e7. * sketch out of prposed changed for scenario_switcher * sketch out of prposed changed for scenario_switcher * sketch out of prposed changed for scenario_switcher * sketch out of prposed changed for scenario_switcher * sketch out of prposed changed for scenario_switcher * Add ResourceFile_Consumables_Item_Designations.csv * create special scenarios for consumables availability based on the designation of the consumable item * comment and fix imports * draft of scenario file * linting * increase length of scenarios and reduce reps * rename * correct error in specifiction of dynamic scaling scenario * remove trailing commas that casts return as tuple * Initially only consider baseline and perfect healthcare seeking scenarios, to get upper limit on RAM requirements * Submit remaining scenarios * direct to self.module (rather than self) * edit check for last ART when new dispensation occurs * update schisto risk on HIV to only include women * add scale-up parameter for htm programs add event to hiv module to switch parameters include new keywords in hiv module for scale-up separately for hiv, tb and malaria add new sheet in ResourceFile_HIV.xlsx containing new scale-up parameter values * add catch for malaria rdt_testing_rates post-2024 * malaria parameters scale-up included * restore `scenario_comparison_of_horizontal_and_vertical_programs` (removing comments used to select certain scenarios to be run). * first draft of figures * set up test for HTM scenario scale-up * add tests for HTM scale-up * check resourcefiles updated * check the usage of '' versus "" * reset to single quotes to match PR #1273 * remove unneeded resource files * remove unneeded resource files * edit filepaths * isort for imports * edit ResourceFile_Improved_Healthsystem_And_Healthcare_Seeking.xlsx to remove 2024 missing value in malaria Rate_rdt_testing * fix filename for test_HTMscaleup.py * update scenario file * update scenario file * include "scale_to_effective_capabilities": True * linting * linting * reduce number of draws * set scaleup parameters separately in each module use parameters to select scaleup instead of module arguments update resourcefiles * set scaleup parameters separately in each module use parameters to select scaleup instead of module arguments update resourcefiles * update resourcefiles * update resourcefiles * set up script to test scenarios - scale-up of HTM programs * test runs * add scenario switch to malaria.py * cherry-pick inadvertently updated files and revert * isort fixes * Delete resources/~$ResourceFile_HIV.xlsx * Delete resources/~$ResourceFile_TB.xlsx * Delete resources/malaria/~$ResourceFile_malaria.xlsx * fix failing tests * rollback changes to calibration_analyses/scenarios/long_run_all_diseases.py * fix error in filename * revert timedelta format to 'M' * add todos * merge in master * set up test runs for scale-up * edit scenario start date * change parameter scaleup_start_date to an integer value used in DateOffset, as timestamp is not json serializable for analysis runs * change scale-up event scheduling to use new DateOffset parameter * test runs * set up test runs * set up test runs * fix failing tests * Update tests/test_HTMscaleup.py Co-authored-by: Tim Hallett <[email protected]> * address comments on PR review * isort fixes * isort fixes * change np.timedelta in enhanced_lifestyle.py back to original * remove json file * call it 'htm_scenario_analysis' rather than just 'scenario_analysis' * update comment * roll back change in test_tb.py * remove .py extension for clarity * roll back incidental change * linting and editing string for clarity * roll back incidental changes * defaults for healthsystem ok -- no need to step through each option * remove inadvertent duplication in code * remove comment * use dict for ease of accessing * parameter to be the YEAR (int) of the change to fit with the convention used in other modules (instead of years since the beginning of the simulation) * remove comment * refactor module method for clarity * refactor to prevent same name being used for events specific to different modules * specify year for scale-up in analysis file * rename; add note; remove comments for HTM scenarios * refacotring * rename scenario class for hss elements * new scenario for combinations of vertical and horizontal programs * minor refactor * update docstring * renaming * add @Property decorator * plot DALYS averted relative to Baseline - broken down by major cause (HIV, TB, MALARIA) * remove unused parameter prob_start_art_after_hiv_test * set up test runs * update linear models for tb and malaria after changing parameters * set up test runs * set up test runs * remove unused parameter from ResourceFile_HIV.xlsx * remove annual_testing_rate_children as not used * add scale-up parameter probability_of_being_retained_on_art_every_3_months, increase to 1 * set cons_availability to all and set off larger runs * test runs * change spec. of runs to be smaller pop size and fewer runs * roll back changes that are not related to this PR * delete file added by accident * roll back change (I think this is mistake) * refactor * remove clause `if p["do_scale_up"]` as not neccessary * make "_build_linear_models" function, called from initialise_population and update_parameter_for_program_scaleup --------- Co-authored-by: tdm32 <[email protected]> Co-authored-by: Tara <[email protected]> Co-authored-by: Margherita Molaro <[email protected]>
1 parent 625b4d9 commit c9e65ca

File tree

7 files changed

+112
-102
lines changed

7 files changed

+112
-102
lines changed

resources/ResourceFile_HIV.xlsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:913d736db7717519270d61824a8855cbfd4d6e61a73b7ce51e2c3b7915b011ff
3-
size 161597
2+
oid sha256:f57142efaf515d74f8290238ce1abad7b99871f9195623112892b3bb535bf634
3+
size 161721

src/scripts/hiv/projections_jan2023/analysis_logged_deviance.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434

3535
# %% Run the simulation
3636
start_date = Date(2010, 1, 1)
37-
end_date = Date(2014, 1, 1)
38-
popsize = 1000
37+
end_date = Date(2022, 1, 1)
38+
popsize = 5000
3939

4040
# scenario = 1
4141

@@ -87,8 +87,8 @@
8787
)
8888

8989
# set the scenario
90-
# sim.modules["Hiv"].parameters["beta"] = 0.129671
91-
# sim.modules["Tb"].parameters["scaling_factor_WHO"] = 1.5
90+
sim.modules["Hiv"].parameters["do_scaleup"] = True
91+
sim.modules["Hiv"].parameters["scaleup_start_year"] = 2019
9292
# sim.modules["Tb"].parameters["scenario"] = scenario
9393
# sim.modules["Tb"].parameters["scenario_start_date"] = Date(2010, 1, 1)
9494
# sim.modules["Tb"].parameters["scenario_SI"] = "z"

src/scripts/htm_scenario_analyses/analysis_htm_scaleup.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def __init__(self):
5151
super().__init__()
5252
self.seed = 0
5353
self.start_date = Date(2010, 1, 1)
54-
self.end_date = Date(2020, 1, 1)
55-
self.pop_size = 75_000
56-
self.number_of_draws = 5
54+
self.end_date = Date(2025, 1, 1)
55+
self.pop_size = 5_000
56+
self.number_of_draws = 2
5757
self.runs_per_draw = 1
5858

5959
def log_configuration(self):
@@ -86,7 +86,7 @@ def modules(self):
8686
]
8787

8888
def draw_parameters(self, draw_number, rng):
89-
scaleup_start_year = 2012
89+
scaleup_start_year = 2019
9090

9191
return {
9292
'Hiv': {

src/scripts/htm_scenario_analyses/scenario_plots.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
datestamp = datetime.date.today().strftime("__%Y_%m_%d")
2424

2525
outputspath = Path("./outputs")
26+
# outputspath = Path("./outputs/[email protected]")
2627

2728

2829
# 0) Find results_folder associated with a given batch_file (and get most recent [-1])
@@ -32,7 +33,7 @@
3233
make_graph_file_name = lambda stub: results_folder / f"{stub}.png" # noqa: E731
3334

3435
# look at one log (so can decide what to extract)
35-
log = load_pickled_dataframes(results_folder)
36+
log = load_pickled_dataframes(results_folder, draw=1)
3637

3738
# get basic information about the results
3839
info = get_scenario_info(results_folder)
@@ -55,14 +56,14 @@ def get_num_deaths_by_cause_label(_df):
5556
.size()
5657

5758

58-
TARGET_PERIOD = (Date(2015, 1, 1), Date(2020, 1, 1))
59+
TARGET_PERIOD = (Date(2020, 1, 1), Date(2025, 1, 1))
5960

6061
num_deaths_by_cause_label = extract_results(
6162
results_folder,
6263
module='tlo.methods.demography',
6364
key='death',
6465
custom_generate_series=get_num_deaths_by_cause_label,
65-
do_scaling=True
66+
do_scaling=False
6667
)
6768

6869

@@ -103,9 +104,9 @@ def summarise_deaths_for_one_cause(results_folder, label):
103104
tb_deaths = summarise_deaths_for_one_cause(results_folder, 'TB (non-AIDS)')
104105
malaria_deaths = summarise_deaths_for_one_cause(results_folder, 'Malaria')
105106

106-
draw_labels = ['No scale-up', 'HIV, scale-up', 'TB scale-up', 'Malaria scale-up']
107+
draw_labels = ['No scale-up', 'HIV, scale-up', 'TB scale-up', 'Malaria scale-up', 'HTM scale-up']
107108

108-
colors = sns.color_palette("Set1", 4) # Blue, Orange, Green, Red
109+
colors = sns.color_palette("Set1", 5) # Blue, Orange, Green, Red
109110

110111

111112
# Create subplots
@@ -116,19 +117,19 @@ def summarise_deaths_for_one_cause(results_folder, label):
116117
axs[0].plot(aids_deaths.index, aids_deaths[col], label=draw_labels[i], color=colors[i])
117118
axs[0].set_title('HIV/AIDS')
118119
axs[0].legend()
119-
axs[0].axvline(x=2015, color='gray', linestyle='--')
120+
axs[0].axvline(x=2019, color='gray', linestyle='--')
120121

121122
# Plot for df2
122123
for i, col in enumerate(tb_deaths.columns):
123124
axs[1].plot(tb_deaths.index, tb_deaths[col], color=colors[i])
124125
axs[1].set_title('TB')
125-
axs[1].axvline(x=2015, color='gray', linestyle='--')
126+
axs[1].axvline(x=2019, color='gray', linestyle='--')
126127

127128
# Plot for df3
128129
for i, col in enumerate(malaria_deaths.columns):
129130
axs[2].plot(malaria_deaths.index, malaria_deaths[col], color=colors[i])
130131
axs[2].set_title('Malaria')
131-
axs[2].axvline(x=2015, color='gray', linestyle='--')
132+
axs[2].axvline(x=2019, color='gray', linestyle='--')
132133

133134
for ax in axs:
134135
ax.set_xlabel('Years')

src/tlo/methods/hiv.py

+31-29
Original file line numberDiff line numberDiff line change
@@ -472,10 +472,13 @@ def read_parameters(self, data_folder):
472472
)
473473

474474
def pre_initialise_population(self):
475-
"""
476-
* Establish the Linear Models
477-
*
478-
"""
475+
"""Do things required before the population is created
476+
* Build the LinearModels"""
477+
self._build_linear_models()
478+
479+
def _build_linear_models(self):
480+
"""Establish the Linear Models"""
481+
479482
p = self.parameters
480483

481484
# ---- LINEAR MODELS -----
@@ -1099,42 +1102,41 @@ def initialise_simulation(self, sim):
10991102
)
11001103

11011104
def update_parameters_for_program_scaleup(self):
1102-
11031105
p = self.parameters
11041106
scaled_params = p["scaleup_parameters"]
11051107

1106-
if p["do_scaleup"]:
1108+
# scale-up HIV program
1109+
# reduce risk of HIV - applies to whole adult population
1110+
p["beta"] = p["beta"] * scaled_params["reduction_in_hiv_beta"]
11071111

1108-
# scale-up HIV program
1109-
# reduce risk of HIV - applies to whole adult population
1110-
p["beta"] = p["beta"] * scaled_params["reduction_in_hiv_beta"]
1112+
# increase PrEP coverage for FSW after HIV test
1113+
p["prob_prep_for_fsw_after_hiv_test"] = scaled_params["prob_prep_for_fsw_after_hiv_test"]
11111114

1112-
# increase PrEP coverage for FSW after HIV test
1113-
p["prob_prep_for_fsw_after_hiv_test"] = scaled_params["prob_prep_for_fsw_after_hiv_test"]
1115+
# prep poll for AGYW - target to the highest risk
1116+
# increase retention to 75% for FSW and AGYW
1117+
p["prob_prep_for_agyw"] = scaled_params["prob_prep_for_agyw"]
1118+
p["probability_of_being_retained_on_prep_every_3_months"] = scaled_params["probability_of_being_retained_on_prep_every_3_months"]
11141119

1115-
# prep poll for AGYW - target to the highest risk
1116-
# increase retention to 75% for FSW and AGYW
1117-
p["prob_prep_for_agyw"] = scaled_params["prob_prep_for_agyw"]
1118-
p["probability_of_being_retained_on_prep_every_3_months"] = scaled_params["probability_of_being_retained_on_prep_every_3_months"]
1120+
# perfect retention on ART
1121+
p["probability_of_being_retained_on_art_every_3_months"] = scaled_params["probability_of_being_retained_on_art_every_3_months"]
11191122

1120-
# increase probability of VMMC after hiv test
1121-
p["prob_circ_after_hiv_test"] = scaled_params["prob_circ_after_hiv_test"]
1123+
# increase probability of VMMC after hiv test
1124+
p["prob_circ_after_hiv_test"] = scaled_params["prob_circ_after_hiv_test"]
11221125

1123-
# increase testing/diagnosis rates, default 2020 0.03/0.25 -> 93% dx
1124-
p["hiv_testing_rates"]["annual_testing_rate_children"] = scaled_params["annual_testing_rate_children"]
1125-
p["hiv_testing_rates"]["annual_testing_rate_adults"] = scaled_params["annual_testing_rate_adults"]
1126+
# increase testing/diagnosis rates, default 2020 0.03/0.25 -> 93% dx
1127+
p["hiv_testing_rates"]["annual_testing_rate_adults"] = scaled_params["annual_testing_rate_adults"]
11261128

1127-
# ANC testing - value for mothers and infants testing
1128-
p["prob_hiv_test_at_anc_or_delivery"] = scaled_params["prob_hiv_test_at_anc_or_delivery"]
1129-
p["prob_hiv_test_for_newborn_infant"] = scaled_params["prob_hiv_test_for_newborn_infant"]
1129+
# ANC testing - value for mothers and infants testing
1130+
p["prob_hiv_test_at_anc_or_delivery"] = scaled_params["prob_hiv_test_at_anc_or_delivery"]
1131+
p["prob_hiv_test_for_newborn_infant"] = scaled_params["prob_hiv_test_for_newborn_infant"]
11301132

1131-
# prob ART start if dx, this is already 95% at 2020
1132-
p["prob_start_art_after_hiv_test"] = scaled_params["prob_start_art_after_hiv_test"]
1133+
# viral suppression rates
1134+
# adults already at 95% by 2020
1135+
# change all column values
1136+
p["prob_start_art_or_vs"]["virally_suppressed_on_art"] = scaled_params["virally_suppressed_on_art"]
11331137

1134-
# viral suppression rates
1135-
# adults already at 95% by 2020
1136-
# change all column values
1137-
p["prob_start_art_or_vs"]["virally_suppressed_on_art"] = scaled_params["virally_suppressed_on_art"]
1138+
# update exising linear models to use new scaled-up paramters
1139+
self._build_linear_models()
11381140

11391141
def on_birth(self, mother_id, child_id):
11401142
"""

src/tlo/methods/malaria.py

+39-36
Original file line numberDiff line numberDiff line change
@@ -327,13 +327,16 @@ def read_parameters(self, data_folder):
327327
)
328328

329329
def pre_initialise_population(self):
330-
"""
331-
* Establish the Linear Models
330+
"""Do things required before the population is created
331+
* Build the LinearModels"""
332+
self._build_linear_models()
333+
334+
def _build_linear_models(self):
335+
"""Establish the Linear Models
332336
333337
if HIV is registered, the conditional predictors will apply
334338
otherwise only IPTp will affect risk of clinical/severe malaria
335339
"""
336-
337340
p = self.parameters
338341

339342
# ---- LINEAR MODELS -----
@@ -656,52 +659,52 @@ def initialise_simulation(self, sim):
656659
)
657660

658661
def update_parameters_for_program_scaleup(self):
659-
660662
p = self.parameters
661663
scaled_params = p["scaleup_parameters"]
662664

663-
if p["do_scaleup"]:
665+
# scale-up malaria program
666+
# increase testing
667+
# prob_malaria_case_tests=0.4 default
668+
p["prob_malaria_case_tests"] = scaled_params["prob_malaria_case_tests"]
664669

665-
# scale-up malaria program
666-
# increase testing
667-
# prob_malaria_case_tests=0.4 default
668-
p["prob_malaria_case_tests"] = scaled_params["prob_malaria_case_tests"]
670+
# gen pop testing rates
671+
# annual Rate_rdt_testing=0.64 at 2023
672+
p["rdt_testing_rates"]["Rate_rdt_testing"] = scaled_params["rdt_testing_rates"]
669673

670-
# gen pop testing rates
671-
# annual Rate_rdt_testing=0.64 at 2023
672-
p["rdt_testing_rates"]["Rate_rdt_testing"] = scaled_params["rdt_testing_rates"]
674+
# treatment reaches XX
675+
# no default between testing and treatment, governed by tx availability
673676

674-
# treatment reaches XX
675-
# no default between testing and treatment, governed by tx availability
677+
# coverage IPTp reaches XX
678+
# given during ANC visits and MalariaIPTp Event which selects ALL eligible women
676679

677-
# coverage IPTp reaches XX
678-
# given during ANC visits and MalariaIPTp Event which selects ALL eligible women
680+
# treatment success reaches 1 - default is currently 1 also
681+
p["prob_of_treatment_success"] = scaled_params["prob_of_treatment_success"]
679682

680-
# treatment success reaches 1 - default is currently 1 also
681-
p["prob_of_treatment_success"] = scaled_params["prob_of_treatment_success"]
683+
# bednet and ITN coverage
684+
# set IRS for 4 high-risk districts
685+
# lookup table created in malaria read_parameters
686+
# produces self.itn_irs called by malaria poll to draw incidence
687+
# need to overwrite this
688+
highrisk_distr_num = p["highrisk_districts"]["district_num"]
682689

683-
# bednet and ITN coverage
684-
# set IRS for 4 high-risk districts
685-
# lookup table created in malaria read_parameters
686-
# produces self.itn_irs called by malaria poll to draw incidence
687-
# need to overwrite this
688-
highrisk_distr_num = p["highrisk_districts"]["district_num"]
690+
# Find indices where District_Num is in highrisk_distr_num
691+
mask = self.itn_irs['irs_rate'].index.get_level_values('District_Num').isin(
692+
highrisk_distr_num)
689693

690-
# Find indices where District_Num is in highrisk_distr_num
691-
mask = self.itn_irs['irs_rate'].index.get_level_values('District_Num').isin(
692-
highrisk_distr_num)
694+
# IRS values can be 0 or 0.8 - no other value in lookup table
695+
self.itn_irs['irs_rate'].loc[mask] = scaled_params["irs_district"]
693696

694-
# IRS values can be 0 or 0.8 - no other value in lookup table
695-
self.itn_irs['irs_rate'].loc[mask] = scaled_params["irs_district"]
697+
# set ITN for all districts
698+
# Set these values to 0.7 - this is the max value possible in lookup table
699+
# equivalent to 0.7 of all pop sleeping under bednet
700+
# household coverage could be 100%, but not everyone in household sleeping under bednet
701+
self.itn_irs['itn_rate'] = scaled_params["itn_district"]
696702

697-
# set ITN for all districts
698-
# Set these values to 0.7 - this is the max value possible in lookup table
699-
# equivalent to 0.7 of all pop sleeping under bednet
700-
# household coverage could be 100%, but not everyone in household sleeping under bednet
701-
self.itn_irs['itn_rate'] = scaled_params["itn_district"]
703+
# itn rates for 2019 onwards
704+
p["itn"] = scaled_params["itn"]
702705

703-
# itn rates for 2019 onwards
704-
p["itn"] = scaled_params["itn"]
706+
# update exising linear models to use new scaled-up parameters
707+
self._build_linear_models()
705708

706709
def on_birth(self, mother_id, child_id):
707710
df = self.sim.population.props

src/tlo/methods/tb.py

+23-19
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,13 @@ def read_parameters(self, data_folder):
470470
)
471471

472472
def pre_initialise_population(self):
473-
"""
474-
* Establish the Linear Models
475-
"""
473+
"""Do things required before the population is created
474+
* Build the LinearModels"""
475+
self._build_linear_models()
476+
477+
def _build_linear_models(self):
478+
"""Establish the Linear Models"""
479+
476480
p = self.parameters
477481

478482
# risk of active tb
@@ -885,29 +889,29 @@ def initialise_simulation(self, sim):
885889
)
886890

887891
def update_parameters_for_program_scaleup(self):
888-
889892
p = self.parameters
890893
scaled_params = p["scaleup_parameters"]
891894

892-
if p["do_scaleup"]:
895+
# scale-up TB program
896+
# use NTP treatment rates
897+
p["rate_testing_active_tb"]["treatment_coverage"] = scaled_params["tb_treatment_coverage"]
893898

894-
# scale-up TB program
895-
# use NTP treatment rates
896-
p["rate_testing_active_tb"]["treatment_coverage"] = scaled_params["tb_treatment_coverage"]
899+
# increase tb treatment success rates
900+
p["prob_tx_success_ds"] = scaled_params["tb_prob_tx_success_ds"]
901+
p["prob_tx_success_mdr"] = scaled_params["tb_prob_tx_success_mdr"]
902+
p["prob_tx_success_0_4"] = scaled_params["tb_prob_tx_success_0_4"]
903+
p["prob_tx_success_5_14"] = scaled_params["tb_prob_tx_success_5_14"]
897904

898-
# increase tb treatment success rates
899-
p["prob_tx_success_ds"] = scaled_params["tb_prob_tx_success_ds"]
900-
p["prob_tx_success_mdr"] = scaled_params["tb_prob_tx_success_mdr"]
901-
p["prob_tx_success_0_4"] = scaled_params["tb_prob_tx_success_0_4"]
902-
p["prob_tx_success_5_14"] = scaled_params["tb_prob_tx_success_5_14"]
905+
# change first-line testing for TB to xpert
906+
p["first_line_test"] = scaled_params["first_line_test"]
907+
p["second_line_test"] = scaled_params["second_line_test"]
903908

904-
# change first-line testing for TB to xpert
905-
p["first_line_test"] = scaled_params["first_line_test"]
906-
p["second_line_test"] = scaled_params["second_line_test"]
909+
# increase coverage of IPT
910+
p["ipt_coverage"]["coverage_plhiv"] = scaled_params["ipt_coverage_plhiv"]
911+
p["ipt_coverage"]["coverage_paediatric"] = scaled_params["ipt_coverage_paediatric"]
907912

908-
# increase coverage of IPT
909-
p["ipt_coverage"]["coverage_plhiv"] = scaled_params["ipt_coverage_plhiv"]
910-
p["ipt_coverage"]["coverage_paediatric"] = scaled_params["ipt_coverage_paediatric"]
913+
# update exising linear models to use new scaled-up paramters
914+
self._build_linear_models()
911915

912916
def on_birth(self, mother_id, child_id):
913917
"""Initialise properties for a newborn individual

0 commit comments

Comments
 (0)