Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
07b12f5
scenario file
PempheroM Nov 13, 2025
cb095e3
Merge branch 'master' into pemphero/nurses_scenario
thewati Nov 13, 2025
6617d49
changes_yearmode,hr scaling
PempheroM Nov 20, 2025
f586244
added default function
PempheroM Nov 21, 2025
94a9b35
reformat
PempheroM Nov 21, 2025
7f24781
Merge remote-tracking branch 'origin/pemphero/nurses_scenario' into p…
PempheroM Nov 21, 2025
ec05b17
remove unused input
PempheroM Nov 21, 2025
97c63a9
Merge branch 'master' into pemphero/nurses_scenario
PempheroM Nov 21, 2025
7994ed8
added files for improved and worse case scenarios
PempheroM Nov 27, 2025
9cb86db
Merge remote-tracking branch 'origin/pemphero/nurses_scenario' into p…
PempheroM Nov 27, 2025
40406ef
addressing comments
PempheroM Dec 8, 2025
6657544
.
thewati Dec 9, 2025
0a95a42
Merge remote-tracking branch 'origin/master'
thewati Dec 9, 2025
6e84902
Merge remote-tracking branch 'origin/master'
thewati Dec 28, 2025
f6cd794
Merge remote-tracking branch 'origin/master'
thewati Jan 12, 2026
660f2a0
Merge remote-tracking branch 'origin/master'
thewati Jan 19, 2026
74e7486
Merge remote-tracking branch 'origin/master'
thewati Jan 23, 2026
e3d3c41
Merge remote-tracking branch 'origin/master'
thewati Jan 27, 2026
992984a
Merge remote-tracking branch 'origin/master'
thewati Feb 3, 2026
7ef22f1
Merge branch 'master' into pemphero/nurses_scenario
thewati Feb 3, 2026
45174af
Merge remote-tracking branch 'origin/pemphero/nurses_scenario' into p…
thewati Feb 3, 2026
cc60285
setup analyses for qs
thewati Feb 3, 2026
95f4020
isort
thewati Feb 3, 2026
6d2ba99
change start and end years
thewati Feb 4, 2026
af3261e
Merge remote-tracking branch 'origin/master'
thewati Feb 4, 2026
55f31fd
Merge branch 'master' into pemphero/nurses_scenario
thewati Feb 4, 2026
b789b7a
Merge branch 'master' into pemphero/nurses_scenario
tbhallett Feb 5, 2026
9fa9a29
Merge branch 'master' into pemphero/nurses_scenario
tbhallett Feb 6, 2026
d5def29
TH suggestions
tbhallett Feb 6, 2026
beadfee
linting!
tbhallett Feb 6, 2026
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
Git LFS file not shown
Git LFS file not shown
167 changes: 167 additions & 0 deletions src/scripts/nurses_analyses/nurses_scenario_analyses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
"""
This scenario file sets up the scenarios for simulating the effects of nursing staffing levels.

Run on the batch system using:
```
tlo batch-submit src/scripts/nurses_analyses/nurses_scenario_analyses.py
```

or locally using:
```
tlo scenario-run src/scripts/nurses_analyses/nurses_scenario_analyses.py
```



"""

from pathlib import Path
from typing import Dict

from tlo import Date, logging
from tlo.analysis.utils import (
get_parameters_for_hrh_historical_scaling_and_rescaling_for_mode2,
get_root_path,
mix_scenarios,
)
from tlo.methods.fullmodel import fullmodel
from tlo.methods.scenario_switcher import ImprovedHealthSystemAndCareSeekingScenarioSwitcher
from tlo.scenario import BaseScenario


class StaffingScenario(BaseScenario):
def __init__(self):
super().__init__()
self.resources = get_root_path() / "resources"
self.seed = 0
self.start_date = Date(2010, 1, 1)
self.end_date = Date(2035, 1, 1)
self.pop_size = 200
self._scenarios = self._get_scenarios()
self.number_of_draws = len(self._scenarios)
self.runs_per_draw = 2

def log_configuration(self):
return {
'filename': 'nurses_scenario_outputs',
'directory': Path('./outputs'), # <- (specified only for local running)
'custom_levels': {
'*': logging.WARNING,
'tlo.methods.demography': logging.INFO,
'tlo.methods.demography.detail': logging.WARNING,
'tlo.methods.healthburden': logging.INFO,
'tlo.methods.healthsystem.summary': logging.INFO,
}
}

def modules(self):
return fullmodel() + [
ImprovedHealthSystemAndCareSeekingScenarioSwitcher()]

def draw_parameters(self, draw_number, rng):
if draw_number < self.number_of_draws:
return list(self._scenarios.values())[draw_number]

def draw_name(self, draw_number) -> str:
"""Store scenario name.
(This name can be retrieved by the plotting scripts to make the graphs be labelled nicely).
"""
if draw_number < self.number_of_draws:
return list(self._scenarios.keys())[draw_number]

@property
def _default_of_all_scenarios(self) -> Dict:
"""Base set of parameters is the standard historical scaling and transition into Mode 2."""
return get_parameters_for_hrh_historical_scaling_and_rescaling_for_mode2()

@property
def _default_of_all_max_healthsystem_scenarios(self) -> Dict:
"""Improved Health System Performance: the same as the default for scenarios, but increases health system
function and healthcare seeking behaviour in 2027"""
return mix_scenarios(
self._default_of_all_scenarios, # <-- start with the same default set of parameters (to avoid repeating them)
{
'ImprovedHealthSystemAndCareSeekingScenarioSwitcher': {
'max_healthcare_seeking': [False, True],
'max_healthsystem_function': [False, True],
'year_of_switch': 2027,
},
},
)

def _get_scenarios(self) -> Dict[str, Dict]:
"""Return the Dict with values for the parameters that are changed, keyed by a name for the scenario.
"""
return {
"Baseline Nurses / Default Healthsystem Function":
mix_scenarios(
self._default_of_all_scenarios,
{
"HealthSystem": {
'HR_scaling_by_level_and_officer_type_mode': "default",
"year_HR_scaling_by_level_and_officer_type": 2027,
},
},
),

"Fewer Nurses / Default Healthsystem Function":
mix_scenarios(
self._default_of_all_scenarios,
{
"HealthSystem": {
'HR_scaling_by_level_and_officer_type_mode': "custom_worse",
"year_HR_scaling_by_level_and_officer_type": 2027,
},
},
),

"More Nurses / Default Healthsystem Function":
mix_scenarios(
self._default_of_all_scenarios,
{
"HealthSystem": {
'HR_scaling_by_level_and_officer_type_mode': "improved_staffing",
"year_HR_scaling_by_level_and_officer_type": 2027,
},
},
),

"Baseline Nurses / Improved Healthsystem Function":
mix_scenarios(
self._default_of_all_max_healthsystem_scenarios,
{
"HealthSystem": {
'HR_scaling_by_level_and_officer_type_mode': "default",
"year_HR_scaling_by_level_and_officer_type": 2027,
},
},
),

"Fewer Nurses / Improved Healthsystem Function":
mix_scenarios(
self._default_of_all_max_healthsystem_scenarios,
{
"HealthSystem": {
'HR_scaling_by_level_and_officer_type_mode': "custom_worse",
"year_HR_scaling_by_level_and_officer_type": 2027,
},
},
),

"More Nurses / Improved Healthsystem Function":
mix_scenarios(
self._default_of_all_max_healthsystem_scenarios,
{
"HealthSystem": {
'HR_scaling_by_level_and_officer_type_mode': "improved_staffing",
"year_HR_scaling_by_level_and_officer_type": 2027,
},
},
),
}


if __name__ == '__main__':
from tlo.cli import scenario_run

scenario_run([__file__])
Loading