Skip to content

Commit 82a02e9

Browse files
marghe-molaromatt-grahamtbhallett
authored
Option to rescale to "effective capabilities" before switching to mode 2 (#1308)
* Rescale capabilities before switching in mode 2 to capture effective capabilities * Include test for rescaling of capabilities before mode switching * Create scenario file to test when rescaling to effective capabilities, for all scenarios considered * Create new scenario file to test a few scenarios with scaling to effective capabilities * Update src/tlo/methods/healthsystem.py Co-authored-by: Matt Graham <[email protected]> * Decorating scale_to_effective_capabilities and year_mode_switch methods as properties Co-authored-by: Matt Graham <[email protected]> * Call definition methods Co-authored-by: Matt Graham <[email protected]> * Prefix with underscore Co-authored-by: Matt Graham <[email protected]> * Avoid accessing attribute of another object prefixed with an underscore * Replace _frac_time_used_by_officer_type_and_level with _sum_of_daily_frac_time_used_by_officer_type_and_level * Cosmetic corrections to test * Remove commented-out line Co-authored-by: Tim Hallett <[email protected]> * Move scaling inside HealthSystem module * Fix to new HealthSystem function (outdated use of module to access) * Add scenario file * Removed outdated logic * Ensure only rescale if rescaling factor is > 1 and not infinity. Some of officers would have had 0 capability * Style fixes * Remove outdated lines * Style fixes * Remove reference to healthsystem module Co-authored-by: Matt Graham <[email protected]> * Remove reference to module under new design Co-authored-by: Matt Graham <[email protected]> * roll back incidental changes * roll back adding kwargs --------- Co-authored-by: Matt Graham <[email protected]> Co-authored-by: Tim Hallett <[email protected]>
1 parent 9c6b753 commit 82a02e9

6 files changed

+886
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:e2e47086a381ec30c0c4229278fe4567f01ca0f24b52808b542667ae50cb816f
3-
size 585
2+
oid sha256:e7e56da62d26488f05ec1a5a10f3790ec9416c029b040f1fed629f314a14816b
3+
size 622
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
"""This Scenario file run the model under different assumptions for HR capabilities expansion in order to estimate the
2+
impact that is achieved under each.
3+
4+
Run on the batch system using:
5+
```
6+
tlo batch-submit src/scripts/healthsystem/impact_of_policy/scenario_impact_of_const_capabilities_expansion.py
7+
```
8+
9+
or locally using:
10+
```
11+
tlo scenario-run src/scripts/healthsystem/impact_of_policy/scenario_impact_of_const_capabilities_expansion.py
12+
```
13+
14+
"""
15+
from pathlib import Path
16+
from typing import Dict
17+
18+
import pandas as pd
19+
20+
from tlo import Date, logging
21+
from tlo.analysis.utils import get_parameters_for_status_quo, mix_scenarios
22+
from tlo.methods.fullmodel import fullmodel
23+
from tlo.methods.scenario_switcher import ScenarioSwitcher
24+
from tlo.scenario import BaseScenario
25+
26+
27+
class ImpactOfHealthSystemMode(BaseScenario):
28+
def __init__(self):
29+
super().__init__()
30+
self.seed = 0
31+
self.start_date = Date(2010, 1, 1)
32+
self.end_date = self.start_date + pd.DateOffset(years=31)
33+
self.pop_size = 100_000
34+
self._scenarios = self._get_scenarios()
35+
self.number_of_draws = len(self._scenarios)
36+
self.runs_per_draw = 2
37+
38+
def log_configuration(self):
39+
return {
40+
'filename': 'effect_of_policy',
41+
'directory': Path('./outputs'), # <- (specified only for local running)
42+
'custom_levels': {
43+
'*': logging.WARNING,
44+
'tlo.methods.demography': logging.INFO,
45+
'tlo.methods.demography.detail': logging.WARNING,
46+
'tlo.methods.healthburden': logging.INFO,
47+
'tlo.methods.healthsystem.summary': logging.INFO,
48+
}
49+
}
50+
51+
def modules(self):
52+
return fullmodel(resourcefilepath=self.resources) + [ScenarioSwitcher(resourcefilepath=self.resources)]
53+
54+
def draw_parameters(self, draw_number, rng):
55+
if draw_number < self.number_of_draws:
56+
return list(self._scenarios.values())[draw_number]
57+
else:
58+
return
59+
60+
# case 1: gfHE = -0.030, factor = 1.01074
61+
# case 2: gfHE = -0.020, factor = 1.02116
62+
# case 3: gfHE = -0.015, factor = 1.02637
63+
# case 4: gfHE = 0.015, factor = 1.05763
64+
# case 5: gfHE = 0.020, factor = 1.06284
65+
# case 6: gfHE = 0.030, factor = 1.07326
66+
67+
def _get_scenarios(self) -> Dict[str, Dict]:
68+
"""Return the Dict with values for the parameters that are changed, keyed by a name for the scenario.
69+
"""
70+
return {
71+
"No growth":
72+
mix_scenarios(
73+
get_parameters_for_status_quo(),
74+
{
75+
"HealthSystem": {
76+
"yearly_HR_scaling_mode": "no_scaling",
77+
"year_mode_switch": 2019,
78+
"mode_appt_constraints_postSwitch": 2,
79+
"scale_to_effective_capabilities": True,
80+
"policy_name": "Naive",
81+
"tclose_overwrite": 1,
82+
"tclose_days_offset_overwrite": 7,
83+
"use_funded_or_actual_staffing": "actual",
84+
"year_cons_availability_switch": 2019,
85+
"cons_availability_postSwitch": "all",
86+
},
87+
}
88+
),
89+
90+
"GDP growth":
91+
mix_scenarios(
92+
get_parameters_for_status_quo(),
93+
{
94+
"HealthSystem": {
95+
"yearly_HR_scaling_mode": "GDP_growth",
96+
"year_mode_switch": 2019,
97+
"mode_appt_constraints_postSwitch": 2,
98+
"scale_to_effective_capabilities": True,
99+
"policy_name": "Naive",
100+
"tclose_overwrite": 1,
101+
"tclose_days_offset_overwrite": 7,
102+
"use_funded_or_actual_staffing": "actual",
103+
"year_cons_availability_switch": 2019,
104+
"cons_availability_postSwitch": "all",
105+
},
106+
}
107+
),
108+
109+
"GDP growth fHE growth case 1":
110+
mix_scenarios(
111+
get_parameters_for_status_quo(),
112+
{
113+
"HealthSystem": {
114+
"yearly_HR_scaling_mode": "GDP_growth_fHE_case1",
115+
"year_mode_switch": 2019,
116+
"mode_appt_constraints_postSwitch": 2,
117+
"scale_to_effective_capabilities": True,
118+
"policy_name": "Naive",
119+
"tclose_overwrite": 1,
120+
"tclose_days_offset_overwrite": 7,
121+
"use_funded_or_actual_staffing": "actual",
122+
"year_cons_availability_switch": 2019,
123+
"cons_availability_postSwitch": "all",
124+
},
125+
}
126+
),
127+
128+
"GDP growth fHE growth case 3":
129+
mix_scenarios(
130+
get_parameters_for_status_quo(),
131+
{
132+
"HealthSystem": {
133+
"yearly_HR_scaling_mode": "GDP_growth_fHE_case3",
134+
"year_mode_switch": 2019,
135+
"mode_appt_constraints_postSwitch": 2,
136+
"scale_to_effective_capabilities": True,
137+
"policy_name": "Naive",
138+
"tclose_overwrite": 1,
139+
"tclose_days_offset_overwrite": 7,
140+
"use_funded_or_actual_staffing": "actual",
141+
"year_cons_availability_switch": 2019,
142+
"cons_availability_postSwitch": "all",
143+
},
144+
}
145+
),
146+
147+
"GDP growth fHE growth case 4":
148+
mix_scenarios(
149+
get_parameters_for_status_quo(),
150+
{
151+
"HealthSystem": {
152+
"yearly_HR_scaling_mode": "GDP_growth_fHE_case4",
153+
"year_mode_switch": 2019,
154+
"mode_appt_constraints_postSwitch": 2,
155+
"scale_to_effective_capabilities": True,
156+
"policy_name": "Naive",
157+
"tclose_overwrite": 1,
158+
"tclose_days_offset_overwrite": 7,
159+
"use_funded_or_actual_staffing": "actual",
160+
"year_cons_availability_switch": 2019,
161+
"cons_availability_postSwitch": "all",
162+
},
163+
}
164+
),
165+
166+
"GDP growth fHE growth case 6":
167+
mix_scenarios(
168+
get_parameters_for_status_quo(),
169+
{
170+
"HealthSystem": {
171+
"yearly_HR_scaling_mode": "GDP_growth_fHE_case6",
172+
"year_mode_switch": 2019,
173+
"mode_appt_constraints_postSwitch": 2,
174+
"scale_to_effective_capabilities": True,
175+
"policy_name": "Naive",
176+
"tclose_overwrite": 1,
177+
"tclose_days_offset_overwrite": 7,
178+
"use_funded_or_actual_staffing": "actual",
179+
"year_cons_availability_switch": 2019,
180+
"cons_availability_postSwitch": "all",
181+
},
182+
}
183+
),
184+
185+
"GDP growth FL case 1 const i":
186+
mix_scenarios(
187+
get_parameters_for_status_quo(),
188+
{
189+
"HealthSystem": {
190+
"yearly_HR_scaling_mode": "GDP_growth_FL_case1_const_tot_i",
191+
"year_mode_switch": 2019,
192+
"mode_appt_constraints_postSwitch": 2,
193+
"scale_to_effective_capabilities": True,
194+
"policy_name": "Naive",
195+
"tclose_overwrite": 1,
196+
"tclose_days_offset_overwrite": 7,
197+
"use_funded_or_actual_staffing": "actual",
198+
"year_cons_availability_switch": 2019,
199+
"cons_availability_postSwitch": "all",
200+
},
201+
}
202+
),
203+
204+
"GDP growth FL case 2 const i":
205+
mix_scenarios(
206+
get_parameters_for_status_quo(),
207+
{
208+
"HealthSystem": {
209+
"yearly_HR_scaling_mode": "GDP_growth_FL_case2_const_tot_i",
210+
"year_mode_switch": 2019,
211+
"mode_appt_constraints_postSwitch": 2,
212+
"scale_to_effective_capabilities": True,
213+
"policy_name": "Naive",
214+
"tclose_overwrite": 1,
215+
"tclose_days_offset_overwrite": 7,
216+
"use_funded_or_actual_staffing": "actual",
217+
"year_cons_availability_switch": 2019,
218+
"cons_availability_postSwitch": "all",
219+
},
220+
}
221+
),
222+
223+
"GDP growth FL case 1 vary i":
224+
mix_scenarios(
225+
get_parameters_for_status_quo(),
226+
{
227+
"HealthSystem": {
228+
"yearly_HR_scaling_mode": "GDP_growth_FL_case1_vary_tot_i",
229+
"year_mode_switch": 2019,
230+
"mode_appt_constraints_postSwitch": 2,
231+
"scale_to_effective_capabilities": True,
232+
"policy_name": "Naive",
233+
"tclose_overwrite": 1,
234+
"tclose_days_offset_overwrite": 7,
235+
"use_funded_or_actual_staffing": "actual",
236+
"year_cons_availability_switch": 2019,
237+
"cons_availability_postSwitch": "all",
238+
},
239+
}
240+
),
241+
242+
"GDP growth FL case 2 vary i":
243+
mix_scenarios(
244+
get_parameters_for_status_quo(),
245+
{
246+
"HealthSystem": {
247+
"yearly_HR_scaling_mode": "GDP_growth_FL_case2_vary_tot_i",
248+
"year_mode_switch": 2019,
249+
"mode_appt_constraints_postSwitch": 2,
250+
"scale_to_effective_capabilities": True,
251+
"policy_name": "Naive",
252+
"tclose_overwrite": 1,
253+
"tclose_days_offset_overwrite": 7,
254+
"use_funded_or_actual_staffing": "actual",
255+
"year_cons_availability_switch": 2019,
256+
"cons_availability_postSwitch": "all",
257+
},
258+
}
259+
),
260+
}
261+
262+
if __name__ == '__main__':
263+
from tlo.cli import scenario_run
264+
265+
scenario_run([__file__])

0 commit comments

Comments
 (0)