Skip to content
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

New analysis functionality for the maternal and newborn health modules (intervention analysis) #1531

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
0c7aa41
created mnh_outcome_logger to eventually replace logging for complica…
joehcollins Oct 7, 2024
87d6f1f
created mnh_outcome_logger to eventually replace logging for complica…
joehcollins Oct 7, 2024
cdd9842
added first logging to pregnancy supervisor
joehcollins Oct 7, 2024
b9a193d
finalising logging event
joehcollins Oct 8, 2024
ada05e0
add health system logging
joehcollins Oct 8, 2024
bfac245
old logging removed
joehcollins Oct 8, 2024
905091b
fix
joehcollins Oct 8, 2024
5a04b44
fix
joehcollins Oct 8, 2024
c62d5df
fix
joehcollins Oct 8, 2024
d8423e1
comments for clarity
joehcollins Oct 8, 2024
a6b12fe
removed counting which wasnt needed
joehcollins Oct 8, 2024
5ca2314
fixes to pregnancy_supervisor test
joehcollins Oct 9, 2024
c271e72
Merge branch 'master' into jcollins/updated_mnh_logging
joehcollins Oct 10, 2024
09a216f
fix denom error
joehcollins Oct 10, 2024
03161e0
fix indentation error
joehcollins Oct 10, 2024
de3ee93
added missing logging
joehcollins Oct 10, 2024
0acf362
removed unused variable
joehcollins Nov 11, 2024
8cc45ab
additional counters and updates to mnh_
joehcollins Dec 2, 2024
2055304
Merge branch 'master' into jcollins/updated_mnh_logging
joehcollins Dec 2, 2024
593f9cd
update calculate_risk_of_death_from_causes to allow for cause of deat…
joehcollins Dec 2, 2024
f7c9e68
updates to resource files (new parameters, tweaked values)
joehcollins Dec 2, 2024
3940cce
new params and updates for intervention analysis in pregnancy_supervi…
joehcollins Dec 2, 2024
efca3d8
Added new function to determine whether an intervention can be delive…
joehcollins Dec 2, 2024
5bbd1f3
Added new function to determine whether updates to labour.py to use t…
joehcollins Dec 2, 2024
a89a034
Added new function to determine whether updates to newborn_outcomes.p…
joehcollins Dec 2, 2024
cff9142
fixes to exsisting tests
joehcollins Dec 2, 2024
25c95f0
new tests to check new analysis function
joehcollins Dec 2, 2024
24dc669
linitng
joehcollins Dec 2, 2024
a232152
update ResourceFile_Improved_Healthsystem_And_Healthcare_Seeking.xlsx…
joehcollins Dec 2, 2024
06bcdaf
Merge branch 'master' into jcollins/mnh_modules_update_intervention_a…
tbhallett Dec 13, 2024
07da536
Merge branch 'master' into jcollins/mnh_modules_update_intervention_a…
tbhallett Dec 15, 2024
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
tbhallett marked this conversation as resolved.
Show resolved Hide resolved
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/ResourceFile_LabourSkilledBirthAttendance.xlsx
Git LFS file not shown
4 changes: 2 additions & 2 deletions resources/ResourceFile_PregnancySupervisor.xlsx
Git LFS file not shown
374 changes: 145 additions & 229 deletions src/tlo/methods/care_of_women_during_pregnancy.py

Large diffs are not rendered by default.

442 changes: 148 additions & 294 deletions src/tlo/methods/labour.py

Large diffs are not rendered by default.

74 changes: 31 additions & 43 deletions src/tlo/methods/newborn_outcomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,28 +523,23 @@ def apply_risk_of_congenital_anomaly(self, child_id):

if self.rng.random_sample() < params['prob_congenital_heart_anomaly']:
self.congeintal_anomalies.set(child_id, 'heart')
logger.info(key='newborn_complication', data={'newborn': child_id,
'type': 'congenital_heart_anomaly'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['congenital_heart_anomaly'] += 1

if self.rng.random_sample() < params['prob_limb_musc_skeletal_anomaly']:
self.congeintal_anomalies.set(child_id, 'limb_musc_skeletal')
logger.info(key='newborn_complication', data={'newborn': child_id,
'type': 'limb_or_musculoskeletal_anomaly'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['limb_or_musculoskeletal_anomaly'] += 1

if self.rng.random_sample() < params['prob_urogenital_anomaly']:
self.congeintal_anomalies.set(child_id, 'urogenital')
logger.info(key='newborn_complication', data={'newborn': child_id,
'type': 'urogenital_anomaly'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['urogenital_anomaly'] += 1

if self.rng.random_sample() < params['prob_digestive_anomaly']:
self.congeintal_anomalies.set(child_id, 'digestive')
logger.info(key='newborn_complication', data={'newborn': child_id,
'type': 'digestive_anomaly'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['digestive_anomaly'] += 1

if self.rng.random_sample() < params['prob_other_anomaly']:
self.congeintal_anomalies.set(child_id, 'other')
logger.info(key='newborn_complication', data={'newborn': child_id,
'type': 'other_anomaly'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['other_anomaly'] += 1

def apply_risk_of_neonatal_infection_and_sepsis(self, child_id):
"""
Expand All @@ -558,9 +553,7 @@ def apply_risk_of_neonatal_infection_and_sepsis(self, child_id):
# The linear model calculates the individuals probability of early_onset_neonatal_sepsis
if self.eval(self.nb_linear_models['early_onset_neonatal_sepsis'], child_id):
df.at[child_id, 'nb_early_onset_neonatal_sepsis'] = True

logger.info(key='newborn_complication', data={'newborn': child_id,
'type': 'early_onset_sepsis'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['early_onset_sepsis'] += 1

def apply_risk_of_encephalopathy(self, child_id, timing):
"""
Expand Down Expand Up @@ -592,8 +585,7 @@ def apply_risk_of_encephalopathy(self, child_id, timing):
else:
df.at[child_id, 'nb_encephalopathy'] = 'severe_enceph'

logger.info(key='newborn_complication', data={'newborn': child_id,
'type': f'{df.at[child_id, "nb_encephalopathy"]}'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter[f'{df.at[child_id, "nb_encephalopathy"]}'] += 1

# Check all encephalopathy cases receive a grade
if df.at[child_id, 'nb_encephalopathy'] == 'none':
Expand All @@ -616,9 +608,7 @@ def apply_risk_of_preterm_respiratory_distress_syndrome(self, child_id):
# Use the linear model to calculate individual risk and make changes
if self.eval(self.nb_linear_models['rds_preterm'], child_id):
df.at[child_id, 'nb_preterm_respiratory_distress'] = True

logger.info(key='newborn_complication', data={'newborn': child_id,
'type': 'respiratory_distress_syndrome'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['respiratory_distress_syndrome'] += 1

def apply_risk_of_not_breathing_at_birth(self, child_id):
"""
Expand All @@ -638,9 +628,7 @@ def apply_risk_of_not_breathing_at_birth(self, child_id):
# explicitly modelled
elif self.rng.random_sample() < params['prob_failure_to_transition']:
df.at[child_id, 'nb_not_breathing_at_birth'] = True

logger.info(key='newborn_complication', data={'newborn': child_id,
'type': 'not_breathing_at_birth'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['not_breathing_at_birth'] += 1

def scheduled_week_one_postnatal_event(self, individual_id):
"""
Expand Down Expand Up @@ -912,8 +900,11 @@ def kangaroo_mother_care(self, hsi_event):
if (df.at[person_id, 'nb_low_birth_weight_status'] != 'normal_birth_weight') or \
(df.at[person_id, 'nb_low_birth_weight_status'] != 'macrosomia'):

kmc_delivered = pregnancy_helper_functions.check_int_deliverable(
self, int_name='kmc', hsi_event=hsi_event, q_param=[params['prob_kmc_available']])

# Check KMC can be delivered
if self.rng.random_sample() < params['prob_kmc_available']:
if kmc_delivered:
# Store treatment as a property of the newborn used to apply treatment effect
df.at[person_id, 'nb_kangaroo_mother_care'] = True

Expand Down Expand Up @@ -964,42 +955,38 @@ def assessment_and_treatment_newborn_sepsis(self, hsi_event, facility_type):
"""
df = self.sim.population.props
person_id = int(hsi_event.target)
l_params = self.sim.modules['Labour'].current_parameters
pnc_location = 'hc' if facility_type == '1a' else 'hp'

# We assume that only hospitals are able to deliver full supportive care for neonatal sepsis, full supportive
# care evokes a stronger treatment effect than injectable antibiotics alone

if df.at[person_id, 'nb_early_onset_neonatal_sepsis'] or df.at[person_id, 'pn_sepsis_late_neonatal'] or\
df.at[person_id, 'pn_sepsis_early_neonatal']:

# Run HCW check
sf_check = pregnancy_helper_functions.check_emonc_signal_function_will_run(self.sim.modules['Labour'],
sf='iv_abx',
hsi_event=hsi_event)
if facility_type != '1a':

# check consumables
avail = pregnancy_helper_functions.return_cons_avail(
self, hsi_event,
neo_sepsis_treatment_delivered = pregnancy_helper_functions.check_int_deliverable(
self, int_name='neo_sepsis_treatment_supp_care', hsi_event=hsi_event,
q_param=[l_params['prob_hcw_avail_iv_abx'], l_params[f'mean_hcw_competence_{pnc_location}']],
cons=self.item_codes_nb_consumables['sepsis_supportive_care_core'],
opt_cons=self.item_codes_nb_consumables['sepsis_supportive_care_optional'])
opt_cons=self.item_codes_nb_consumables['sepsis_supportive_care_optional'],
equipment={'Drip stand', 'Infusion pump'})

# Then, if the consumables are available, treatment for sepsis is delivered
if avail and sf_check:
if neo_sepsis_treatment_delivered:
df.at[person_id, 'nb_supp_care_neonatal_sepsis'] = True
pregnancy_helper_functions.log_met_need(self, 'neo_sep_supportive_care', hsi_event)
hsi_event.add_equipment({'Drip stand', 'Infusion pump'})

# The same pattern is then followed for health centre care
else:
avail = pregnancy_helper_functions.return_cons_avail(
self, hsi_event,
neo_sepsis_treatment_delivered = pregnancy_helper_functions.check_int_deliverable(
self, int_name='neo_sepsis_treatment_abx', hsi_event=hsi_event,
q_param=[l_params['prob_hcw_avail_iv_abx'], l_params[f'mean_hcw_competence_{pnc_location}']],
cons=self.item_codes_nb_consumables['sepsis_abx'],
opt_cons=self.item_codes_nb_consumables['iv_drug_equipment'])
opt_cons=self.item_codes_nb_consumables['iv_drug_equipment'],
equipment={'Drip stand', 'Infusion pump'})

if avail and sf_check:
if neo_sepsis_treatment_delivered:
df.at[person_id, 'nb_inj_abx_neonatal_sepsis'] = True
pregnancy_helper_functions.log_met_need(self, 'neo_sep_abx', hsi_event)
hsi_event.add_equipment({'Drip stand', 'Infusion pump', 'Oxygen cylinder, with regulator'})

def link_twins(self, child_one, child_two, mother_id):
"""
Expand All @@ -1021,6 +1008,7 @@ def link_twins(self, child_one, child_two, mother_id):
'date_of_delivery': self.sim.date}

logger.info(key='twin_birth', data=twin_birth, description='A record of each birth of twin pairs')
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['twin_birth'] += 1

# Finally we log the second live birth and add another to the womans parity
df.at[mother_id, 'la_parity'] += 1
Expand Down Expand Up @@ -1157,14 +1145,14 @@ def on_birth(self, mother_id, child_id):
if (df.at[child_id, 'nb_low_birth_weight_status'] == 'low_birth_weight') or\
(df.at[child_id, 'nb_low_birth_weight_status'] == 'very_low_birth_weight') or\
(df.at[child_id, 'nb_low_birth_weight_status'] == 'extremely_low_birth_weight'):
logger.info(key='newborn_complication', data={'newborn': child_id, 'type': 'low_birth_weight'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['low_birth_weight'] += 1

elif df.at[child_id, 'nb_low_birth_weight_status'] == 'macrosomia':
logger.info(key='newborn_complication', data={'newborn': child_id, 'type': 'macrosomia'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['macrosomia'] += 1

df.at[child_id, 'nb_size_for_gestational_age'] = mni[mother_id]['birth_size']
if df.at[child_id, 'nb_size_for_gestational_age'] == 'small_for_gestational_age':
logger.info(key='newborn_complication', data={'newborn': child_id, 'type': 'small_for_gestational_age'})
self.sim.modules['PregnancySupervisor'].mnh_outcome_counter['small_for_gestational_age'] += 1

df.at[child_id, 'nb_early_init_breastfeeding'] = False
df.at[child_id, 'nb_breastfeeding_status'] = 'none'
Expand Down
Loading
Loading