Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 0 additions & 3 deletions resources/ResourceFile_Diarrhoea/Parameter_values.csv

This file was deleted.

3 changes: 3 additions & 0 deletions resources/ResourceFile_Diarrhoea/parameter_values.csv
Git LFS file not shown
51 changes: 36 additions & 15 deletions src/tlo/methods/diarrhoea.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@ class Diarrhoea(Module, GenericFirstAppointmentsMixin):
'probability_of_severe_dehydration_if_some_dehydration':
Parameter(Types.REAL, 'probability that someone with diarrhoea and some dehydration develops severe '
'dehydration'),
'prob_remove_dehydration_no_treatment':
Parameter(Types.REAL, 'probability that someone with diarrhoea stops without treatment'),

# Parameters governing the duration of the episode
'prob_prolonged_diarr_rotavirus':
Expand Down Expand Up @@ -441,6 +443,9 @@ class Diarrhoea(Module, GenericFirstAppointmentsMixin):
Parameter(Types.INT, 'number of days reduced duration with zinc'),
'days_between_treatment_and_cure':
Parameter(Types.INT, 'number of days between any treatment being given in an HSI and the cure occurring.'),
'prob_clear_bacterial_infection_no_treatment':
Parameter(Types.REAL,
'probability clear bacterial infection no treatment.'),

# Parameters describing efficacy of the monovalent rotavirus vaccine (R1)
'rr_severe_dehydration_due_to_rotavirus_with_R1_under1yo':
Expand All @@ -449,6 +454,21 @@ class Diarrhoea(Module, GenericFirstAppointmentsMixin):
'rr_severe_dehydration_due_to_rotavirus_with_R1_over1yo':
Parameter(Types.REAL,
'relative risk of severe dehydration with rotavirus vaccine, for those aged 1 year and older.'),
'relative_prob_severe_dehydration_no_vaccine':
Parameter(Types.REAL,
'relative probability of severe dehydration without rotavirus vaccine.'),


# Parameters describing thresholds for severity of diarrhoea
'persistent_diarrhoea_threshold_days':
Parameter(Types.REAL,
'Days of symptoms after which classification is persistent diarrhoea.'),

# Parameters module design
'main_polling_frequency':
Parameter(Types.INT,
'Main polling frequency for event that runs acquisition of pathogens that cause Diarrhoea.'),

}

PROPERTIES = {
Expand All @@ -472,9 +492,10 @@ class Diarrhoea(Module, GenericFirstAppointmentsMixin):
'some', # <-- this level is not used currently.
'severe'
]),
'gi_duration_longer_than_13days': Property(Types.BOOL,
'persistent_diarrhoea_status': Property(Types.BOOL,
'Whether the duration of the current episode would last longer than '
'13 days if untreated. (False if does not have current episode)'),
'days set as threshold if untreated. '
'(False if does not have current episode)'),
'gi_number_of_episodes': Property(Types.INT,
"Number of episodes of diarrhoea caused by a pathogen"),

Expand Down Expand Up @@ -519,7 +540,7 @@ def read_parameters(self, resourcefilepath: Optional[Path]=None):

# Read parameters from the resourcefile
self.load_parameters_from_dataframe(
read_csv_files(resourcefilepath / 'ResourceFile_Diarrhoea', files='Parameter_values')
read_csv_files(resourcefilepath / 'ResourceFile_Diarrhoea', files='parameter_values')
)

# Check that every value has been read-in successfully
Expand All @@ -541,7 +562,7 @@ def initialise_population(self, population):
df.loc[df.is_alive, 'gi_pathogen'] = np.nan
df.loc[df.is_alive, 'gi_type'] = np.nan
df.loc[df.is_alive, 'gi_dehydration'] = np.nan
df.loc[df.is_alive, 'gi_duration_longer_than_13days'] = False
df.loc[df.is_alive, 'persistent_diarrhoea_status'] = False
df.loc[df.is_alive, 'gi_number_of_episodes'] = 0

# ---- Internal values ----
Expand Down Expand Up @@ -605,7 +626,7 @@ def on_birth(self, mother_id, child_id):
df.at[child_id, 'gi_pathogen'] = np.nan
df.at[child_id, 'gi_type'] = np.nan
df.at[child_id, 'gi_dehydration'] = np.nan
df.at[child_id, 'gi_duration_longer_than_13days'] = False
df.at[child_id, 'persistent_diarrhoea_status'] = False
df.at[child_id, 'gi_number_of_episodes'] = 0

# ---- Internal values ----
Expand Down Expand Up @@ -716,7 +737,7 @@ def do_treatment(self, person_id, hsi_event):
)

# STEP ONE: Aim to alleviate dehydration:
prob_remove_dehydration = 0.0
prob_remove_dehydration = p['prob_remove_dehydration_no_treatment']
if is_in_patient:
if hsi_event.get_consumables(item_codes=self.consumables_used_in_hsi['Treatment_Severe_Dehydration']):
# In-patient receiving IV fluids (WHO Plan C)
Expand All @@ -740,7 +761,7 @@ def do_treatment(self, person_id, hsi_event):
):
prob_clear_bacterial_infection = self.parameters['prob_antibiotic_cures_dysentery']
else:
prob_clear_bacterial_infection = 0.0
prob_clear_bacterial_infection = p['prob_clear_bacterial_infection_no_treatment']

# Determine type after treatment
type_after_treatment = 'watery' if self.rng.rand() < prob_clear_bacterial_infection else person.gi_type
Expand All @@ -750,7 +771,7 @@ def do_treatment(self, person_id, hsi_event):
if self.models.does_treatment_prevent_death(
pathogen=person.gi_pathogen,
type=(person.gi_type, type_after_treatment), # <-- type may have changed
duration_longer_than_13days=person.gi_duration_longer_than_13days,
duration_longer_than_13days=person.persistent_diarrhoea_status,
dehydration=(person.gi_dehydration, dehydration_after_treatment), # <-- dehydration may have changed
age_exact_years=person.age_exact_years,
ri_current_infection_status=person.ri_current_infection_status,
Expand Down Expand Up @@ -836,7 +857,7 @@ def end_episode(self, person_id, outcome):
'gi_pathogen',
'gi_type',
'gi_dehydration',
'gi_duration_longer_than_13days',
'persistent_diarrhoea_status',
'gi_date_of_onset',
'gi_scheduled_date_recovery',
'gi_scheduled_date_death',
Expand Down Expand Up @@ -867,7 +888,7 @@ def check_properties(self):
'gi_type',
'gi_dehydration']
]).all().all()
assert not df.loc[not_in_current_episode, 'gi_duration_longer_than_13days'].any()
assert not df.loc[not_in_current_episode, 'persistent_diarrhoea_status'].any()
assert pd.isnull(df.loc[not_in_current_episode, [
'gi_date_of_onset',
'gi_scheduled_date_recovery',
Expand Down Expand Up @@ -1109,7 +1130,7 @@ def get_dehydration(self, pathogen, va_rota_all_doses, age_years):
self.p['rr_severe_dehydration_due_to_rotavirus_with_R1_under1yo'] if age_years < 1 \
else self.p['rr_severe_dehydration_due_to_rotavirus_with_R1_over1yo']
else:
relative_prob_severe_dehydration_due_to_vaccine = 1.0
relative_prob_severe_dehydration_due_to_vaccine = self.p['relative_prob_severe_dehydration_no_vaccine']

if self.rng.rand() < self.p[f'prob_dehydration_by_{pathogen}']:
if self.rng.rand() < (
Expand Down Expand Up @@ -1264,7 +1285,7 @@ class DiarrhoeaPollingEvent(RegularEvent, PopulationScopeEventMixin):
"""

def __init__(self, module):
super().__init__(module, frequency=DateOffset(months=3))
super().__init__(module, frequency=DateOffset(months= module.parameters['main_polling_frequency']))
# NB. The frequency of the occurrences of this event can be edited safely.
self.fraction_of_a_year_until_next_polling_event = self.compute_fraction_of_year_between_polling_event()

Expand Down Expand Up @@ -1359,7 +1380,7 @@ def apply(self, person_id):
'gi_dehydration': m.models.get_dehydration(pathogen=self.pathogen,
va_rota_all_doses=person.va_rota_all_doses,
age_years=person.age_years),
'gi_duration_longer_than_13days': duration_in_days >= 13,
'persistent_diarrhoea_status': duration_in_days >= p['persistent_diarrhoea_threshold_days'],
'gi_date_of_onset': self.sim.date,
'gi_date_end_of_last_episode': date_of_outcome + DateOffset(days=p['days_between_treatment_and_cure']),
'gi_scheduled_date_recovery': pd.NaT, # <-- determined below
Expand All @@ -1371,7 +1392,7 @@ def apply(self, person_id):
if m.models.will_die(
pathogen=props_new['gi_pathogen'],
type=props_new['gi_type'],
duration_longer_than_13days=props_new['gi_duration_longer_than_13days'],
duration_longer_than_13days=props_new['persistent_diarrhoea_status'],
dehydration=props_new['gi_dehydration'],
age_exact_years=person['age_exact_years'],
ri_current_infection_status=person['ri_current_infection_status'],
Expand Down Expand Up @@ -1406,7 +1427,7 @@ def apply(self, person_id):
'pathogen': props_new['gi_pathogen'],
'type': props_new['gi_type'],
'dehydration': props_new['gi_dehydration'],
'duration_longer_than_13days': props_new['gi_duration_longer_than_13days'],
'duration_longer_than_13days': props_new['persistent_diarrhoea_status'],
'date_of_outcome': date_of_outcome,
'will_die': pd.isnull(props_new['gi_scheduled_date_recovery'])
},
Expand Down