Skip to content

Commit ffe4dfc

Browse files
author
sm2511
committed
Update HR costing
1 parent a102b34 commit ffe4dfc

File tree

1 file changed

+37
-15
lines changed

1 file changed

+37
-15
lines changed

src/scripts/costing/costing.py

+37-15
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@
4747

4848

4949
# 1. HR cost
50-
'''
51-
Notes:
52-
1. Ignore squeeze factor, i.e. the actual capability used is costed
53-
2. ? capabilities_coefficient
54-
'''
5550
# 1.1 Overall HR Cost
5651
# Annual salary by officer type and facility level
5752
workbook = pd.read_excel((resourcefilepath / "ResourceFile_Costing.xlsx"),
@@ -68,30 +63,54 @@
6863
salary_df = pd.merge(hr_annual_salary, aggregate_frac_time_used_by_officer_type, on = ['OfficerType_FacilityLevel'])
6964
salary_df['Total_salary_by_cadre_and_level'] = salary_df['Salary_USD'] * salary_df['Value']
7065
scenario_cost = pd.DataFrame()
71-
scenario_cost['HR'] = salary_df['Total_salary_by_cadre_and_level'].sum() # Need to fix this!
66+
scenario_cost['HR'] = salary_df['Total_salary_by_cadre_and_level'].sum()
67+
68+
# Plot salary costs by cadre and facility level
69+
# Group by cadre and level
70+
total_salary_by_cadre = salary_df.groupby('Officer_Category')['Total_salary_by_cadre_and_level'].sum()
71+
total_salary_by_level = salary_df.groupby('Facility_Level')['Total_salary_by_cadre_and_level'].sum()
72+
73+
# If the folder doesn't exist, create it
74+
costing_outputs_folder = Path('./outputs/costing')
75+
if not os.path.exists(costing_outputs_folder):
76+
os.makedirs(costing_outputs_folder)
77+
78+
# Plot by cadre
79+
total_salary_by_cadre.plot(kind='bar')
80+
plt.xlabel('Officer_category')
81+
plt.ylabel('Total Salary')
82+
plt.title('Total Salary by Cadre')
83+
plt.savefig(costing_outputs_folder / 'total_salary_by_cadre.png')
84+
85+
# Plot by level
86+
total_salary_by_level.plot(kind='bar')
87+
plt.xlabel('Facility_Level')
88+
plt.ylabel('Total Salary')
89+
plt.title('Total Salary by Facility_Level')
90+
plt.savefig(costing_outputs_folder / 'total_salary_by_level.png')
91+
92+
# TODO Disaggregate by district using 'Frac_Time_Used_By_Facility_ID'
93+
# TODO Disaggregate by Treatment_ID - will need this for cost-effectiveness estimates - current log does not provide this
94+
95+
96+
97+
'''
98+
# Scratch pad
7299
73100
log['tlo.methods.healthsystem']['Capacity']['Frac_Time_Used_By_Facility_ID'] # for district disaggregation
74-
log['tlo.methods.healthsystem']['Capacity']['Frac_Time_Used_By_OfficerType'][0]
75101
76102
# Aggregate Daily capabilities to total used by cadre and facility level
77-
# Multiply these with the correct salary figure - need dictionary mapping (or read costing as a csv)
78-
79-
# Bar plot of salary costs by cadre and facility level
80103
81104
# log['tlo.methods.healthsystem.summary']['Capacity']['Frac_Time_Used_By_OfficerType']
82105
# 1.2 HR cost by Treatment_ID
83106
# For HR cost by Treatment_ID, multiply total cost by Officer type by fraction of time used for treatment_ID
84-
log['tlo.methods.healthsystem.summary']['HSI_Event']['TREATMENT_ID'][0] # what does this represent? why are there 3 rows (2 scenarios)
107+
log['tlo.methods.healthsystem.summary']['HSI_Event']['TREATMENT_ID'] # what does this represent? why are there 3 rows (2 scenarios)
85108
# But what we need is the HR use by Treatment_ID - Leave this for later?
86109
87110
# log['tlo.scenario']
88111
log['tlo.methods.healthsystem.summary']['HSI_Event']['Number_By_Appt_Type_Code']
89112
90113
91-
92-
93-
94-
95114
df = pd.DataFrame(log['tlo.methods.healthsystem.summary'])
96115
df.to_csv(outputfilepath / 'temp.csv')
97116
@@ -112,3 +131,6 @@ def read_parameters(self, data_folder):
112131
workbook = pd.read_excel((resourcefilepath / "ResourceFile_Costing.xlsx"),
113132
sheet_name = None)
114133
human_resources = workbook["human_resources"]
134+
135+
'''
136+

0 commit comments

Comments
 (0)