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

The Impact of Past Improvements in HRH: The Historical Analysis #1414

Open
wants to merge 46 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
fa47520
initial investigation of data
tbhallett Jul 5, 2024
52bf483
small edits to figuees
tbhallett Jul 5, 2024
5785e84
small edits to figuees
tbhallett Jul 5, 2024
6312efd
construct scenario - figure, scenario file and update rhe resource file
tbhallett Jul 8, 2024
1c2639a
update comment
tbhallett Jul 8, 2024
abf2056
hardcode year
tbhallett Jul 8, 2024
cf0e3f8
update figure
tbhallett Jul 8, 2024
44adabf
first draft of graph
tbhallett Jul 10, 2024
7d49506
graph with breakdown by cause
tbhallett Jul 14, 2024
33453fc
graph with breakdown by cause
tbhallett Jul 14, 2024
3fcfb3a
Merge branch 'refs/heads/master' into hallett/historical-impact-of-gr…
tbhallett Aug 6, 2024
548bc1d
update dropbox path to use OneDrive instead
tbhallett Aug 6, 2024
1e1bbfe
update analysis script
tbhallett Aug 6, 2024
4ac04a5
update scenario specification
tbhallett Aug 6, 2024
8e24fb9
increase numnber of runs
tbhallett Aug 6, 2024
c8af1bc
add table_2_relative_frequency_of_cons_use
tbhallett Aug 7, 2024
6f6b6a3
update graph
tbhallett Aug 7, 2024
e700cc6
elaborate script so that ResourceFile is written to with the scenario…
tbhallett Aug 7, 2024
d845954
elaborate script so that ResourceFile is written to with the scenario…
tbhallett Aug 7, 2024
8faae8f
save new version of RF
tbhallett Aug 7, 2024
9944e71
update comment
tbhallett Aug 7, 2024
7ca3eb1
modify scenario
tbhallett Aug 7, 2024
8443945
modify scenario
tbhallett Aug 7, 2024
c074a65
modify scenario
tbhallett Aug 7, 2024
7d2cee7
extend date per
tbhallett Aug 7, 2024
d4f5e12
adjust scaling
tbhallett Aug 12, 2024
36a4a07
update HR scale-up analysis and create graphs
tbhallett Aug 13, 2024
3bdccba
update HR scale-up analysis and create graphs
tbhallett Aug 13, 2024
3f72e4f
updates to scenario definition
tbhallett Aug 14, 2024
36feac7
updates to scenario definition
tbhallett Aug 14, 2024
ff9b7ef
make small run
tbhallett Aug 14, 2024
b77d6cd
update scenario definition
tbhallett Aug 15, 2024
fdb988c
update analysis script to use latets data
tbhallett Aug 16, 2024
2b4d38d
tweaking to graphs
tbhallett Aug 16, 2024
ad1e6af
final tweaks to plots and adding comments
tbhallett Aug 17, 2024
2391598
linting isort
tbhallett Aug 17, 2024
5af40ec
linting
tbhallett Aug 17, 2024
3a7ed3f
linting
tbhallett Aug 17, 2024
b194621
isort change
tbhallett Aug 17, 2024
65cf98d
plot table giving breakdown of causes
tbhallett Aug 22, 2024
b55cbed
add look at breakdown of other causes
tbhallett Aug 22, 2024
8fd885e
add print-out
tbhallett Aug 22, 2024
f66fa98
use logger stacked by age and time rather than the wealth logger (mak…
tbhallett Aug 22, 2024
032f415
Merge branch 'master' into hallett/historical-impact-of-growth-in-hr-…
tbhallett Sep 16, 2024
5da00e0
plot breakdown by more causes - not just HTM
tbhallett Sep 16, 2024
8b38634
adjust time periods for the breakdowns
tbhallett Sep 16, 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
Git LFS file not shown
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,52 @@ def get_treatment_id_affecting_by_missing_consumables(_df):
plt.close(fig)


def table_2_relative_frequency_of_cons_use(results_folder: Path, output_folder: Path, resourcefilepath: Path):
"""Table 2: The relative frequency Consumables that are used."""

# Load the mapping between item_code and item_name
cons_names = pd.read_csv(
resourcefilepath / 'healthsystem' / 'consumables' / 'ResourceFile_Consumables_Items_and_Packages.csv'
)[['Item_Code', 'Items']].set_index('Item_Code').drop_duplicates()

def get_number_of_call_to_an_item_code(_df):
"""This summarizes the number of calls to a particular item_code, irrespective of the quantity requested."""
_df = drop_outside_period(_df)

counts_of_available = defaultdict(int)
counts_of_not_available = defaultdict(int)

for _, row in _df.iterrows():
for item, _ in eval(row['Item_Available']).items():
counts_of_available[item] += 1
for item, _ in eval(row['Item_NotAvailable']).items():
counts_of_not_available[item] += 1

return pd.concat(
{'Available': pd.Series(counts_of_available), 'Not_Available': pd.Series(counts_of_not_available)},
axis=1
).fillna(0).astype(int).stack()

items_called = summarize(
extract_results(
results_folder,
module='tlo.methods.healthsystem',
key='Consumables',
custom_generate_series=get_number_of_call_to_an_item_code,
do_scaling=True
),
only_mean=True,
collapse_columns=True
)

total_calls = items_called.unstack().sum(axis=1) # total calls by item_code (summing Available and Not_Availbale)
rfreq_calls = (total_calls / total_calls.sum()).sort_values(ascending=False).reset_index(name='rel_freq').rename(columns={'index': 'Item_Code'})
rfreq_calls = rfreq_calls.merge(cons_names.reset_index(), left_on='Item_Code', right_on='Item_Code', how='left')
rfreq_calls.to_csv(
output_folder / f"{PREFIX_ON_FILENAME}_Table_Of_Frequency_Consumables_Requested.csv",
index=False
)

def figure7_squeeze_factors(results_folder: Path, output_folder: Path, resourcefilepath: Path):
""" 'Figure 7': Squeeze Factors for the HSIs"""
make_graph_file_name = lambda stub: output_folder / f"{PREFIX_ON_FILENAME}_Fig7_{stub}.png" # noqa: E731
Expand Down Expand Up @@ -754,6 +800,10 @@ def apply(results_folder: Path, output_folder: Path, resourcefilepath: Path = No
results_folder=results_folder, output_folder=output_folder, resourcefilepath=resourcefilepath
)

table_2_relative_frequency_of_cons_use(
results_folder=results_folder, output_folder=output_folder, resourcefilepath=resourcefilepath
)

figure7_squeeze_factors(
results_folder=results_folder, output_folder=output_folder, resourcefilepath=resourcefilepath
)
Expand Down
Loading