Skip to content

Commit 3ecadeb

Browse files
Retrieve annual capacity by cadre
1 parent 85823fa commit 3ecadeb

3 files changed

Lines changed: 28 additions & 17 deletions

File tree

src/scripts/lcoa_inputs_from_tlo_analyses/analysis_effect_of_treatment_ids.py

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ def apply(
172172
results['input_costs'] = input_costs
173173

174174
# Computing incremental costs
175+
# TODO Check with Sakshi if these are annual costs; as everything else is annual.
175176
if do_comparison:
176177
print("Computing incremental_scenario_cost...")
177178
start = perf_counter()
@@ -191,9 +192,6 @@ def apply(
191192

192193
incremental_scenario_cost_summarized = compute_summary_statistics(incremental_scenario_cost, 'median').iloc[0].unstack()
193194

194-
195-
196-
197195
# Get total population by year
198196
print("Extracting population data...")
199197
total_population_by_year = (
@@ -307,7 +305,7 @@ def apply(
307305
central_measure='median'
308306
).iloc[0].unstack()
309307
# Run-by-run incremental cost-effectiveness ratio calculation
310-
icers = incremental_scenario_cost.T /dalys_averted
308+
icers = incremental_scenario_cost.T / dalys_averted
311309
icers_summarized = compute_summary_statistics(icers.T, central_measure='median').iloc[0].unstack()
312310
dalys_averted = compute_summary_statistics(dalys_averted.T, central_measure='median').iloc[0].unstack()
313311

@@ -318,6 +316,7 @@ def apply(
318316
# From this we will extract the run-wise delta in capacity used relative to the Nothing scenario, for each cadre
319317
# and summarise. However since no HSIs are delivered in the Nothing scenario, the capacity used in that scenario is zero,
320318
# so the delta relative to Nothing is just the capacity used in each scenario.
319+
# TODO: Check if this should be scaled with population or used as is.
321320
annual_capacity_used_by_cadre_and_level = extract_results(
322321
results_folder,
323322
module='tlo.methods.healthsystem.summary',
@@ -326,25 +325,44 @@ def apply(
326325
do_scaling=True,
327326
autodiscover=True,
328327
)
329-
# Sum across all years and facility levels; so we get the *total* capacity used over the whole period
328+
# Sum across all facility levels and average across years; so we get the *average* annual capacity used over the whole period
330329
# TODO: Check with Sakshi if this is what we want.
331330
mask = annual_capacity_used_by_cadre_and_level.index.get_level_values(0).isin(range(2026, 2040))
332331
capacity_used_by_cadre = (
333-
annual_capacity_used_by_cadre_and_level[mask].groupby(['OfficerType']).
332+
annual_capacity_used_by_cadre_and_level[mask].groupby(['OfficerType', 'year']).
334333
sum().
334+
groupby(['OfficerType']).
335+
mean().
335336
pipe(set_param_names_as_column_index_level_0, param_names=param_names)
336337
)
337338

338339
capacity_used_by_cadre = (
339340
compute_summary_statistics(capacity_used_by_cadre, central_measure='median')
340341
)
341342

343+
# Get the total available caapacity by cadre needed for LCOA
344+
# resources/healthsystem/human_resources/actual/ResourceFile_Daily_Capabilities.csv
345+
daily_capacity_by_cadre_and_level = (
346+
pd.read_csv(resourcefilepath / "healthsystem" / "human_resources" / "actual" / "ResourceFile_Daily_Capabilities.csv")
347+
)
348+
# This gives the total minutes available per day by cadre and facility level.
349+
# Sum across levels to get cadre specific constraints, and multiply by 365 to get annual capacity
350+
annual_capacity_by_cadre = (
351+
daily_capacity_by_cadre_and_level.groupby('Officer_Category')['Total_Mins_Per_Day'].sum() * 365
352+
)
353+
354+
# Add consumables budget to this dictionary so that we have everything in one place
355+
# USD 225,602,946 (203136642 from donors + 22466304 from the government)
356+
# Ref Revision of Malawi’s Health Bene ts Package: A Critical Analysis of Policy Formulation and Implementation
357+
results['annual_consumables_budget'] = 225602946
358+
342359
results['dalys'] = dalys
343360
results['dalys_averted'] = dalys_averted if do_comparison else None
344361
results['pc_dalys_averted'] = pc_dalys_averted if do_comparison else None
345362
results['icers_summarized'] = icers_summarized if do_comparison else None
346363
results['incremental_scenario_cost'] = incremental_scenario_cost_summarized if do_comparison else None
347364
results['capacity_used_by_cadre'] = capacity_used_by_cadre
365+
results['annual_capacity_by_cadre'] = annual_capacity_by_cadre
348366

349367
return results
350368

src/scripts/lcoa_inputs_from_tlo_analyses/figures_effect_of_treatment_ids.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,25 @@
66
import pickle
77
import pandas as pd
88
import matplotlib.pyplot as plt
9-
from scripts.calibration_analyses.analysis_scripts import plot_legends
9+
1010
from scripts.lcoa_inputs_from_tlo_analyses.results_processing_utils import (
1111
get_parameter_names_from_scenario_file,
12-
get_periods_within_target_period,
1312
format_scenario_name,
14-
target_period,
1513
)
1614
from scripts.lcoa_inputs_from_tlo_analyses.fig_utils import (
1715
make_graph_file_name,
1816
do_barh_plot_with_ci,
19-
do_bar_plot_with_ci,
2017
plot_cadre_time_by_draw_stacked,
2118
plot_deaths_by_period_for_cause,
2219
plot_deaths_by_period_for_draw,
2320
plot_hsi_counts_by_period_for_draw,
2421
plot_population_by_year,
2522
)
26-
from tlo import Date
23+
2724

2825
# python src/scripts/lcoa_inputs_from_tlo_analyses/figures_effect_of_treatment_ids.py outputs/generated_outputs/2041-01-01_fullresults.pkl --output_folder=figs2
2926

30-
TARGET_PERIOD = (Date(2025, 1, 1), Date(2041, 1, 1))
27+
3128
PERIOD_LENGTH_YEARS_FOR_BAR_PLOTS = 1
3229

3330

@@ -73,7 +70,6 @@ def apply(results_files: list[Path], output_folder: Path, resourcefilepath: Path
7370
counts_of_hsi_in_implementation_period = counts_of_hsi_in_implementation_period.drop(['2010-2041'], level=1)
7471
capacity_used_by_cadre = primary_results.get("capacity_used_by_cadre")
7572

76-
7773
result_df_by_period = pd.DataFrame([
7874
{'treatment_id_included': draw, 'nonzero_hsis': treatment_id, 'period': period}
7975
for draw in counts_of_hsi_in_implementation_period.columns.get_level_values(0).unique()

src/scripts/lcoa_inputs_from_tlo_analyses/run_preaggregated_optimizer.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,7 @@ def _aggregate_hr_by_intervention(
8686
if "central" not in capacity_used_by_cadre.columns:
8787
raise ValueError("results['capacity_used_by_cadre'] must contain a 'central' column.")
8888

89-
if capacity_used_by_cadre.index.nlevels == 1:
90-
officer_types = capacity_used_by_cadre.index.astype(str).tolist()
91-
else:
92-
officer_types = capacity_used_by_cadre.index.get_level_values(0).astype(str).tolist()
89+
officer_types = capacity_used_by_cadre.index.get_level_values(0).astype(str).tolist()
9390

9491
mapping = _build_hr_mapping(officer_types)
9592
if not mapping:

0 commit comments

Comments
 (0)