Skip to content

Commit 52f48c6

Browse files
mmsuarezcostamarghe-molarotbhallett
authored
Param Revamp - ALRI (#1730)
* remove hardcoding and update param values * test linting change * test linting change * fix linting error * Add hardcoded param * ruff fixes * update notes and ref column * revert ruff fixes on documents outside alri module * rename * csv params clean-up * move alias * Revert "move alias" This reverts commit a4b42f7. * update base odds deaths -> local --------- Co-authored-by: Margherita Molaro <48129834+marghe-molaro@users.noreply.github.com> Co-authored-by: Tim Hallett <39991060+tbhallett@users.noreply.github.com>
1 parent c07383f commit 52f48c6

File tree

6 files changed

+41
-21
lines changed

6 files changed

+41
-21
lines changed

resources/ResourceFile_Alri/Calculations.csv

Lines changed: 0 additions & 3 deletions
This file was deleted.

resources/ResourceFile_Alri/Lazzerini CFR.csv

Lines changed: 0 additions & 3 deletions
This file was deleted.

resources/ResourceFile_Alri/Parameter_values.csv

Lines changed: 0 additions & 3 deletions
This file was deleted.

resources/ResourceFile_Alri/Pathogen_specific.csv

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
version https://git-lfs.github.com/spec/v1
2+
oid sha256:e2b417a870b56a1301f13c0fa9e0624a395e4e5e598b506052db7b741d42ea16
3+
size 13358

src/tlo/methods/alri.py

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,29 @@ class Alri(Module, GenericFirstAppointmentsMixin):
744744
Parameter(Types.REAL,
745745
'The probability for scheduling a follow-up appointment following treatment failure'
746746
),
747+
748+
# Module configuration parameters -----
749+
'main_polling_frequency':
750+
Parameter(Types.INT,
751+
'Frequency of main polling event in months'
752+
),
753+
'child_age_threshold':
754+
Parameter(Types.INT,
755+
'Maximum age in years for child classification'
756+
),
757+
'inpatient_bed_days':
758+
Parameter(Types.INT,
759+
'Number of bed days required for inpatient care of ALRI'
760+
),
761+
'treatment_window_days':
762+
Parameter(Types.INT,
763+
'Buffer window days that ALRI treatment event can be scheduled'
764+
),
765+
'follow_up_appointment_days':
766+
Parameter(Types.INT,
767+
'Days after which follow-up appointment is scheduled'
768+
),
769+
747770
}
748771

749772
PROPERTIES = {
@@ -828,7 +851,7 @@ def read_parameters(self, resourcefilepath: Optional[Path] = None):
828851
* Define symptoms
829852
"""
830853
self.load_parameters_from_dataframe(
831-
read_csv_files(resourcefilepath / 'ResourceFile_Alri', files='Parameter_values')
854+
read_csv_files(resourcefilepath / 'ResourceFile_Alri', files='parameter_values')
832855
)
833856

834857
self.check_params_read_in_ok()
@@ -1372,7 +1395,8 @@ def do_at_generic_first_appt(
13721395
# Action taken when a child (under 5 years old) presents at a
13731396
# generic appointment (emergency or non-emergency) with symptoms
13741397
# of `cough` or `difficult_breathing`.
1375-
if individual_properties["age_years"] <= 5 and (
1398+
p = self.parameters
1399+
if individual_properties["age_years"] <= p['child_age_threshold'] and (
13761400
("cough" in symptoms) or ("difficult_breathing" in symptoms)
13771401
):
13781402
self.record_sought_care_for_alri()
@@ -1384,7 +1408,7 @@ def do_at_generic_first_appt(
13841408
schedule_hsi_event(
13851409
event,
13861410
topen=self.sim.date,
1387-
tclose=self.sim.date + pd.DateOffset(days=1),
1411+
tclose=self.sim.date + pd.DateOffset(days=p['treatment_window_days']),
13881412
priority=1,
13891413
)
13901414

@@ -1901,7 +1925,7 @@ class AlriPollingEvent(RegularEvent, PopulationScopeEventMixin):
19011925
age-groups. This is a small effect when the frequency of the polling event is high."""
19021926

19031927
def __init__(self, module):
1904-
super().__init__(module, frequency=DateOffset(months=2))
1928+
super().__init__(module, frequency=DateOffset(months=module.parameters['main_polling_frequency']))
19051929

19061930
@property
19071931
def fraction_of_year_between_polling_event(self):
@@ -1919,7 +1943,7 @@ def get_probs_of_acquiring_pathogen(self, interval_as_fraction_of_a_year: float)
19191943
# Compute the incidence rate for each person getting Alri and then convert into a probability
19201944
# getting all children that do not currently have an Alri episode (never had or last episode resolved)
19211945
mask_could_get_new_alri_event = (
1922-
df.is_alive & (df.age_years < 5) & ~df.ri_current_infection_status &
1946+
df.is_alive & (df.age_years < m.parameters['child_age_threshold']) & ~df.ri_current_infection_status &
19231947
((df.ri_end_of_current_episode < self.sim.date) | pd.isnull(df.ri_end_of_current_episode))
19241948
)
19251949

@@ -2273,7 +2297,8 @@ def _as_in_patient(self, facility_level):
22732297
f'{self._treatment_id_stub}_Inpatient{"_Followup" if self.is_followup_following_treatment_failure else ""}'
22742298
self.EXPECTED_APPT_FOOTPRINT = self.make_appt_footprint({})
22752299
self.ACCEPTED_FACILITY_LEVEL = facility_level
2276-
self.BEDDAYS_FOOTPRINT = self.make_beddays_footprint({'general_bed': 7})
2300+
bed_days = self.module.parameters['inpatient_bed_days']
2301+
self.BEDDAYS_FOOTPRINT = self.make_beddays_footprint({'general_bed': bed_days})
22772302

22782303
def _refer_to_next_level_up(self):
22792304
"""Schedule this event to occur again today at the next level-up (if there is a next level-up)."""
@@ -2290,6 +2315,8 @@ def _next_in_sequence(seq: tuple, x: str):
22902315
_next_level_up = _next_in_sequence(self._facility_levels, self.ACCEPTED_FACILITY_LEVEL)
22912316

22922317
if _next_level_up is not None:
2318+
p = self.module.parameters
2319+
22932320
self.sim.modules['HealthSystem'].schedule_hsi_event(
22942321
HSI_Alri_Treatment(
22952322
module=self.module,
@@ -2298,7 +2325,7 @@ def _next_in_sequence(seq: tuple, x: str):
22982325
facility_level=_next_level_up
22992326
),
23002327
topen=self.sim.date,
2301-
tclose=self.sim.date + pd.DateOffset(days=1),
2328+
tclose=self.sim.date + pd.DateOffset(days=p['treatment_window_days']),
23022329
priority=0)
23032330

23042331
def _refer_to_become_inpatient(self):
@@ -2318,8 +2345,10 @@ def _refer_to_become_inpatient(self):
23182345
priority=0)
23192346

23202347
def _schedule_follow_up_following_treatment_failure(self):
2321-
"""Schedule a copy of this event to occur in 5 days time as a 'follow-up' appointment at this level
2348+
"""Schedule a copy of this event to occur as a 'follow-up' appointment at this level
23222349
(if above "0") and as an in-patient."""
2350+
2351+
p = self.module.parameters
23232352
self.sim.modules['HealthSystem'].schedule_hsi_event(
23242353
HSI_Alri_Treatment(
23252354
module=self.module,
@@ -2328,7 +2357,7 @@ def _schedule_follow_up_following_treatment_failure(self):
23282357
facility_level=self.ACCEPTED_FACILITY_LEVEL if self.ACCEPTED_FACILITY_LEVEL != "0" else "1a",
23292358
is_followup_following_treatment_failure=True,
23302359
),
2331-
topen=self.sim.date + pd.DateOffset(days=5),
2360+
topen=self.sim.date + pd.DateOffset(days=p['follow_up_appointment_days']),
23322361
tclose=None,
23332362
priority=0)
23342363

0 commit comments

Comments
 (0)