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
54 changes: 45 additions & 9 deletions src/tlo/methods/cardio_metabolic_disorders.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,12 @@ class CardioMetabolicDisorders(Module, GenericFirstAppointmentsMixin):
**hsi_events_param_dicts, **initial_prev_param_dicts, **other_params_dict,
'prob_care_provided_given_seek_emergency_care': Parameter(
Types.REAL, "The probability that correct care is fully provided to persons that have sought emergency care"
" for a Cardio-metabolic disorder.")
" for a Cardio-metabolic disorder."),
"probability_of_seeking_further_med_appointment_if_unavailable": Parameter(
Types.REAL,
"Probability that a person who 'should' be on medication will seek another appointment (the following "
"day and try for each of the next 7 days) if refill appointment was not available.",
),
}

# Convert conditions and events to dicts and merge together into PROPERTIES
Expand Down Expand Up @@ -1600,13 +1605,14 @@ def apply(self, person_id, squeeze_factor):

# Don't advise those with CKD to lose weight, but do so for all other conditions if BMI is higher than normal
if self.condition != 'chronic_kidney_disease' and (df.at[person_id, 'li_bmi'] > 2):
self.add_equipment({'Weighing scale'})
if not df.at[person_id, 'nc_ever_weight_loss_treatment']:
self.add_equipment({'Weighing scale'})

self.sim.population.props.at[person_id, 'nc_ever_weight_loss_treatment'] = True
# Schedule a post-weight loss event for individual to potentially lose weight in next 6-12 months:
self.sim.schedule_event(CardioMetabolicDisordersWeightLossEvent(m, person_id),
random_date(self.sim.date + pd.DateOffset(months=6),
self.sim.date + pd.DateOffset(months=12), m.rng))
self.sim.population.props.at[person_id, 'nc_ever_weight_loss_treatment'] = True
# Schedule a post-weight loss event for individual to potentially lose weight in next 6-12 months:
self.sim.schedule_event(CardioMetabolicDisordersWeightLossEvent(m, person_id),
random_date(self.sim.date + pd.DateOffset(months=6),
self.sim.date + pd.DateOffset(months=12), m.rng))

# If person is already on medication, do not do anything
if person[f'nc_{self.condition}_on_medication']:
Expand Down Expand Up @@ -1732,10 +1738,40 @@ def apply(self, person_id, squeeze_factor):
priority=1
)

def did_not_run(self):
# If this HSI event did not run, then the persons ceases to be taking medication
def did_not_run_weather_event(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure it's worth renaming - this would either require, in the HealthSystem, you checking whether it is the appropriate CMD before calling did_not_run_weather_event, or ensuring that the did_not_run fnc in every HSI in the model is renamed did_not_run_weather_event

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this also applies to never ran

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed: there is logic in the call_and_record_weather events that checks for CMD-related HSIs. Clunky, but functional for the moment!

# If this HSI event never ran, then the persons ceases to be taking medication. However, they have
# a probability of restarting treatment again.
person_id = self.target
self.sim.population.props.at[person_id, f'nc_{self.condition}_on_medication'] = False
# The individual will try again to restart treatment
if (self.module.rng.random_sample() <
self.module.parameters[f'{self.condition}_hsi'].get('pr_seeking_further_appt_if_drug_not_available')):
self.sim.modules['HealthSystem'].schedule_hsi_event(
hsi_event=HSI_CardioMetabolicDisorders_StartWeightLossAndMedication,
topen=self.sim.date + pd.DateOffset(
days= (self.sim.modules["HealthSystem"].parameters["scale_factor_delay_in_seeking_care_weather"] * 1)),
tclose=self.sim.date + pd.DateOffset(
days=(self.sim.modules["HealthSystem"].parameters["scale_factor_delay_in_seeking_care_weather"] * 1 + 15)),
# number of days of climate disruption
priority=1
)
def never_ran_weather_event(self):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it seems very odd that did_not_run and never_ran are identical. But I guess this makes sense since in the CMD any delay in care is equivalent to a complete cancellation...

# If this HSI event never ran, then the persons ceases to be taking medication. However, they have
# a probability of restarting treatment again.
person_id = self.target
self.sim.population.props.at[person_id, f'nc_{self.condition}_on_medication'] = False
# The individual will try again to restart treatment
if (self.module.rng.random_sample() <
self.module.parameters[f'{self.condition}_hsi'].get('pr_seeking_further_appt_if_drug_not_available')):
self.sim.modules['HealthSystem'].schedule_hsi_event(
hsi_event=HSI_CardioMetabolicDisorders_StartWeightLossAndMedication,
topen=self.sim.date + pd.DateOffset(
days= (self.sim.modules["HealthSystem"].parameters["scale_factor_delay_in_seeking_care_weather"])),
tclose=self.sim.date + pd.DateOffset(
days=(self.sim.modules["HealthSystem"].parameters["scale_factor_delay_in_seeking_care_weather"] + 15)), # keep gap as above
# number of days of climate disruption
priority=1
)


class HSI_CardioMetabolicDisorders_SeeksEmergencyCareAndGetsTreatment(HSI_Event, IndividualScopeEventMixin):
Expand Down
Loading
Loading