-
Notifications
You must be signed in to change notification settings - Fork 16
Handling HSI_CardioMetabolicDisorders_Refill_Medication with climate disruptions. #1750
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -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']: | ||
|
|
@@ -1732,10 +1738,38 @@ 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): | ||
| # 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=1), | ||
| tclose=self.sim.date + pd.DateOffset( | ||
| days=self.sim.modules["HealthSystem"].parameters["scale_factor_delay_in_seeking_care_weather"] * 1), | ||
|
||
| # number of days of climate disruption | ||
| priority=1 | ||
| ) | ||
| def never_ran_weather_event(self): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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=1), | ||
| tclose=self.sim.date + pd.DateOffset( | ||
| days=self.sim.modules["HealthSystem"].parameters["scale_factor_delay_in_seeking_care_weather"] * 1), | ||
| # number of days of climate disruption | ||
| priority=1 | ||
| ) | ||
|
|
||
|
|
||
| class HSI_CardioMetabolicDisorders_SeeksEmergencyCareAndGetsTreatment(HSI_Event, IndividualScopeEventMixin): | ||
|
|
||
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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!