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

HealthSystem. Convert Excel files to CSV #1527

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

This file was deleted.

Git LFS file not shown
Git LFS file not shown

This file was deleted.

Git LFS file not shown

This file was deleted.

Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown

This file was deleted.

Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown

This file was deleted.

Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
37 changes: 19 additions & 18 deletions src/tlo/methods/healthsystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
HSIEventQueueItem,
HSIEventWrapper,
)
from tlo.util import read_csv_files

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -581,40 +582,40 @@ def read_parameters(self, data_folder):

# Data on the priority of each Treatment_ID that should be adopted in the queueing system according to different
# priority policies. Load all policies at this stage, and decide later which one to adopt.
self.parameters['priority_rank'] = pd.read_excel(path_to_resourcefiles_for_healthsystem / 'priority_policies' /
'ResourceFile_PriorityRanking_ALLPOLICIES.xlsx',
sheet_name=None)
self.parameters['priority_rank'] = read_csv_files(path_to_resourcefiles_for_healthsystem / 'priority_policies' /
'ResourceFile_PriorityRanking_ALLPOLICIES',
files=None)

self.parameters['HR_scaling_by_level_and_officer_type_table']: Dict = pd.read_excel(
self.parameters['HR_scaling_by_level_and_officer_type_table']: Dict = read_csv_files(
path_to_resourcefiles_for_healthsystem /
"human_resources" /
"scaling_capabilities" /
"ResourceFile_HR_scaling_by_level_and_officer_type.xlsx",
sheet_name=None # all sheets read in
"ResourceFile_HR_scaling_by_level_and_officer_type",
files=None # all sheets read in
)
# Ensure the mode of HR scaling to be considered in included in the tables loaded
assert (self.parameters['HR_scaling_by_level_and_officer_type_mode'] in
self.parameters['HR_scaling_by_level_and_officer_type_table']), \
(f"Value of `HR_scaling_by_level_and_officer_type_mode` not recognised: "
f"{self.parameters['HR_scaling_by_level_and_officer_type_mode']}")

self.parameters['HR_scaling_by_district_table']: Dict = pd.read_excel(
self.parameters['HR_scaling_by_district_table']: Dict = read_csv_files(
path_to_resourcefiles_for_healthsystem /
"human_resources" /
"scaling_capabilities" /
"ResourceFile_HR_scaling_by_district.xlsx",
sheet_name=None # all sheets read in
"ResourceFile_HR_scaling_by_district",
files=None # all sheets read in
)
# Ensure the mode of HR scaling by district to be considered in included in the tables loaded
assert self.parameters['HR_scaling_by_district_mode'] in self.parameters['HR_scaling_by_district_table'], \
f"Value of `HR_scaling_by_district_mode` not recognised: {self.parameters['HR_scaling_by_district_mode']}"

self.parameters['yearly_HR_scaling']: Dict = pd.read_excel(
self.parameters['yearly_HR_scaling']: Dict = read_csv_files(
path_to_resourcefiles_for_healthsystem /
"human_resources" /
"scaling_capabilities" /
"ResourceFile_dynamic_HR_scaling.xlsx",
sheet_name=None, # all sheets read in
"ResourceFile_dynamic_HR_scaling",
files=None, # all sheets read in
dtype={
'year': int,
'dynamic_HR_scaling_factor': float,
Expand Down Expand Up @@ -961,7 +962,7 @@ def format_daily_capabilities(self, use_funded_or_actual_staffing: str) -> tuple
self.parameters[f'Daily_Capabilities_{use_funded_or_actual_staffing}']
)
capabilities = capabilities.rename(columns={'Officer_Category': 'Officer_Type_Code'}) # neaten

# Create new column where capabilities per staff are computed
capabilities['Mins_Per_Day_Per_Staff'] = capabilities['Total_Mins_Per_Day']/capabilities['Staff_Count']

Expand All @@ -984,10 +985,10 @@ def format_daily_capabilities(self, use_funded_or_actual_staffing: str) -> tuple
# Merge in information about facility from Master Facilities List
mfl = self.parameters['Master_Facilities_List']
capabilities_ex = capabilities_ex.merge(mfl, on='Facility_ID', how='left')

# Create a copy of this to store staff counts
capabilities_per_staff_ex = capabilities_ex.copy()

# Merge in information about officers
# officer_types = self.parameters['Officer_Types_Table'][['Officer_Type_Code', 'Officer_Type']]
# capabilities_ex = capabilities_ex.merge(officer_types, on='Officer_Type_Code', how='left')
Expand All @@ -1000,7 +1001,7 @@ def format_daily_capabilities(self, use_funded_or_actual_staffing: str) -> tuple
how='left',
)
capabilities_ex = capabilities_ex.fillna(0)

capabilities_per_staff_ex = capabilities_per_staff_ex.merge(
capabilities[['Facility_ID', 'Officer_Type_Code', 'Mins_Per_Day_Per_Staff']],
on=['Facility_ID', 'Officer_Type_Code'],
Expand All @@ -1015,7 +1016,7 @@ def format_daily_capabilities(self, use_funded_or_actual_staffing: str) -> tuple
+ '_Officer_'
+ capabilities_ex['Officer_Type_Code']
)

# Give the standard index:
capabilities_per_staff_ex = capabilities_per_staff_ex.set_index(
'FacilityID_'
Expand Down Expand Up @@ -1055,7 +1056,7 @@ def _rescale_capabilities_to_capture_effective_capability(self):
)
if rescaling_factor > 1 and rescaling_factor != float("inf"):
self._daily_capabilities[officer] *= rescaling_factor

# We assume that increased daily capabilities is a result of each staff performing more
# daily patient facing time per day than contracted (or equivalently performing appts more
# efficiently).
Expand Down
Loading