Skip to content

Commit 3a6c1e0

Browse files
Fix to mode 1 running footprint log (#1805)
1 parent 7253f1a commit 3a6c1e0

File tree

1 file changed

+7
-36
lines changed

1 file changed

+7
-36
lines changed

src/tlo/methods/healthsystem.py

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2134,38 +2134,11 @@ def run_individual_level_events_in_mode_1(
21342134
assert self.mode_appt_constraints == 1
21352135

21362136
if _list_of_individual_hsi_event_tuples:
2137-
# Examine total call on health officers time from the HSI events in the list:
2138-
2139-
# For all events in the list, expand the appt-footprint of the event to give the demands on each
2140-
# officer-type in each facility_id and clinic.
2141-
footprints_of_all_individual_level_hsi_event = defaultdict(list)
2142-
## _list_of_individual_hsi_event_tuples is a flat list, whereas we will now
2143-
## store the footprint by clinic; as we loop over the list of events to be run, we
2144-
## will retrieve the updated footprint using get_appt_footprint_as_time_request.
2145-
## We want to ensure that we update the footprint of the ``correct'' event. We will
2146-
## therefore also store the number of the event in the original flat list in a
2147-
## dictionary keyed by clinics.
2148-
event_num_of_all_individual_level_hsi_event = defaultdict(list)
2149-
for eve_num, event_tuple in enumerate(_list_of_individual_hsi_event_tuples):
2150-
event_clinic = event_tuple.clinic_eligibility
2151-
footprints_of_all_individual_level_hsi_event[event_clinic].append(
2152-
event_tuple.hsi_event.expected_time_requests
2153-
)
2154-
event_num_of_all_individual_level_hsi_event[event_clinic].append(eve_num)
2155-
2156-
# For each clinic, compute total appointment footprint across all events
2157-
2158-
for clinic, footprint in footprints_of_all_individual_level_hsi_event.items():
2159-
for hsi_footprint in footprint:
2160-
# Counter.update method when called with dict-like argument adds counts
2161-
# from argument to Counter object called from
2162-
self.running_total_footprint[clinic].update(hsi_footprint)
21632137

21642138
for ev_num, event in enumerate(_list_of_individual_hsi_event_tuples):
21652139
_priority = event.priority
21662140
clinic = event.clinic_eligibility
21672141
event = event.hsi_event
2168-
21692142
# store appt_footprint before running
21702143
_appt_footprint_before_running = event.EXPECTED_APPT_FOOTPRINT
21712144

@@ -2175,6 +2148,7 @@ def run_individual_level_events_in_mode_1(
21752148
ok_to_run = self.check_if_all_required_officers_have_nonzero_capabilities(
21762149
event.expected_time_requests, clinic=clinic)
21772150
if ok_to_run:
2151+
21782152
# Compute the bed days that are allocated to this HSI and provide this information to the HSI
21792153
if sum(event.BEDDAYS_FOOTPRINT.values()):
21802154
event._received_info_about_bed_days = self.bed_days.issue_bed_days_according_to_availability(
@@ -2197,21 +2171,18 @@ def run_individual_level_events_in_mode_1(
21972171
# check its formatting:
21982172
assert self.appt_footprint_is_valid(actual_appt_footprint)
21992173

2200-
# Update load factors:
2201-
updated_call = self.get_appt_footprint_as_time_request(
2202-
facility_info=event.facility_info, appt_footprint=actual_appt_footprint
2203-
)
2204-
ev_num_in_clinics_fp = event_num_of_all_individual_level_hsi_event[clinic].index(ev_num)
2205-
original_call = footprints_of_all_individual_level_hsi_event[clinic][ev_num_in_clinics_fp]
2206-
footprints_of_all_individual_level_hsi_event[clinic][ev_num_in_clinics_fp] = updated_call
2207-
self.running_total_footprint[clinic] -= original_call
2208-
self.running_total_footprint[clinic] += updated_call
22092174

22102175
else:
22112176
# no actual footprint is returned so take the expected initial declaration as the actual,
22122177
# as recorded before the HSI event run
22132178
actual_appt_footprint = _appt_footprint_before_running
22142179

2180+
# Update load factors:
2181+
actual_call = self.get_appt_footprint_as_time_request(
2182+
facility_info=event.facility_info, appt_footprint=actual_appt_footprint
2183+
)
2184+
self.running_total_footprint[clinic].update(actual_call)
2185+
22152186
# Write to the log
22162187
self.record_hsi_event(
22172188
hsi_event=event,

0 commit comments

Comments
 (0)