@@ -134,6 +134,8 @@ def __init__(self, name=None):
134134 Types .LIST , 'case fatality rate of severe pre-eclampsia in the postnatal period' ),
135135 'weekly_prob_death_severe_gest_htn' : Parameter (
136136 Types .LIST , 'weekly risk of death from severe hypertension in the postnatal period' ),
137+ 'bmi_obesity' : Parameter (
138+ Types .LIST , 'BMI for obesity classification' ),
137139
138140 # ANAEMIA
139141 'baseline_prob_anaemia_per_week' : Parameter (
@@ -205,7 +207,37 @@ def __init__(self, name=None):
205207 Types .LIST , 'Treatment effect of chlorhexidine cord care on early onset neonatal sepsis risk' ),
206208 'treatment_effect_anti_htns_progression_pn' : Parameter (
207209 Types .LIST , 'Treatment effect of oral anti hypertensives on progression from mild/mod to severe gestational'
208- 'hypertension' )
210+ 'hypertension' ),
211+
212+ # TIMING AND SCHEDULING PARAMETERS
213+ 'main_polling_event_frequency_weeks' : Parameter (
214+ Types .INT , ' PostnatalSupervisorEvent polling frequency in weeks' ),
215+ 'fistula_repair_min_days' : Parameter (
216+ Types .LIST , 'Minimum days after birth to schedule obstetric fistula repair' ),
217+ 'fistula_repair_max_days' : Parameter (
218+ Types .LIST , 'Maximum days after birth to schedule obstetric fistula repair' ),
219+ 'fistula_repair_appointment_window_days' : Parameter (
220+ Types .LIST , 'Number of days for fistula repair appointment scheduling window' ),
221+ 'emergency_postnatal_care_appointment_window_days' : Parameter (
222+ Types .LIST , 'Number of days for emergency postnatal care appointment scheduling window' ),
223+ 'pnc_one_maternal_appt_max_days_without_complications' : Parameter (
224+ Types .LIST , 'Maximum number of days from current date for pnc_one_maternal_appt if no complications' ),
225+ 'pnc_one_maternal_appt_window_days' : Parameter (
226+ Types .LIST , 'Number of days for pnc_one_maternal_appt scheduling window' ),
227+ 'postnatal_check_sepsis_appt_window_days' : Parameter (
228+ Types .LIST , 'Number of days for postnatal check if sepsis - scheduling window' ),
229+ 'pnc_one_neonatal_sepsis_appt_window_days' : Parameter (
230+ Types .LIST , 'Number of days for pnc_one_neonatal if sepsis - scheduling window' ),
231+ 'final_week_postnatal_period' : Parameter (
232+ Types .INT , 'Final week of the postnatal period - week 6' ),
233+ 'postnatal_reset_week' : Parameter (
234+ Types .INT , 'Week at which postnatal variables are reset overall: Changes made 2 weeks after'
235+ 'the end of the postnatal and neonatal period in case either the '
236+ 'mother or newborn are receiving treatment following the last PNC visit ' ),
237+ 'obstetric_fistula_repair_beddays' : Parameter (
238+ Types .INT , 'Number of beddays required for obstetric fistula repair' ),
239+ 'neonatal_period_end_days' : Parameter (
240+ Types .INT , 'End of neonatal period in days' )
209241 }
210242
211243 PROPERTIES = {
@@ -254,8 +286,7 @@ def initialise_simulation(self, sim):
254286 pregnancy_helper_functions .update_current_parameter_dictionary (self , list_position = 0 )
255287
256288 # Schedule the first instance of the PostnatalSupervisorEvent
257- sim .schedule_event (PostnatalSupervisorEvent (self ),
258- sim .date + DateOffset (days = 0 ))
289+ sim .schedule_event (PostnatalSupervisorEvent (self ), sim .date )
259290
260291 # Register dx_tests used as assessment for postnatal conditions during PNC visits
261292 params = self .current_parameters
@@ -365,12 +396,14 @@ def further_on_birth_postnatal_supervisor(self, mother_id):
365396 if care_seeking_for_repair :
366397 repair_hsi = HSI_PostnatalSupervisor_TreatmentForObstetricFistula (
367398 self , person_id = mother_id )
368- repair_date = self .sim .date + DateOffset (days = (self .rng .randint (7 , 42 )))
399+ repair_date = self .sim .date + DateOffset (days = (self .rng .randint (
400+ params ['fistula_repair_min_days' ], params ['fistula_repair_max_days' ])))
369401
370402 self .sim .modules ['HealthSystem' ].schedule_hsi_event (repair_hsi ,
371- priority = 0 ,
372- topen = repair_date ,
373- tclose = repair_date + DateOffset (days = 7 ))
403+ priority = 0 ,
404+ topen = repair_date ,
405+ tclose = repair_date +
406+ DateOffset (days = params ['fistula_repair_appointment_window_days' ]))
374407
375408 # ======================= CONTINUATION OF COMPLICATIONS INTO THE POSTNATAL PERIOD =========================
376409 # Certain conditions experienced in pregnancy are liable to continue into the postnatal period
@@ -676,23 +709,26 @@ def log_new_progressed_cases(disease):
676709 self .sim .modules ['Labour' ], person_id = person )
677710
678711 self .sim .modules ['HealthSystem' ].schedule_hsi_event (postnatal_check ,
679- priority = 0 ,
680- topen = self .sim .date ,
681- tclose = self .sim .date + DateOffset (days = 2 ))
712+ priority = 0 ,
713+ topen = self .sim .date ,
714+ tclose = self .sim .date +
715+ DateOffset (days = params ['emergency_postnatal_care_appointment_window_days' ]))
682716
683717 # For women who do not seek care we immediately apply risk of death due to complications
684718 for person in care_seekers .loc [~ care_seekers ].index :
685719 self .apply_risk_of_maternal_or_neonatal_death_postnatal (mother_or_child = 'mother' , individual_id = person )
686720
687- if week == 6 :
721+ if week == params [ 'final_week_postnatal_period' ] :
688722 # Here we reset any remaining pregnancy variables (as some are used as predictors in models in the postnatal
689723 # period)
690- week_6_women = df .is_alive & df .la_is_postpartum & (df .pn_postnatal_period_in_weeks == 6 )
724+ final_week_postnatal_period_women = (df .is_alive &
725+ df .la_is_postpartum &
726+ (df .pn_postnatal_period_in_weeks == params ['final_week_postnatal_period' ]))
691727
692728 self .sim .modules ['PregnancySupervisor' ].pregnancy_supervisor_property_reset (
693- id_or_index = week_6_women .loc [week_6_women ].index )
729+ id_or_index = final_week_postnatal_period_women .loc [final_week_postnatal_period_women ].index )
694730 self .sim .modules ['CareOfWomenDuringPregnancy' ].care_of_women_in_pregnancy_property_reset (
695- id_or_index = week_6_women .loc [week_6_women ].index )
731+ id_or_index = final_week_postnatal_period_women .loc [final_week_postnatal_period_women ].index )
696732
697733 def apply_risk_of_neonatal_complications_in_week_one (self , child_id , mother_id ):
698734 """
@@ -768,9 +804,10 @@ def set_postnatal_complications_neonates(self, upper_and_lower_day_limits):
768804 self .sim .modules ['NewbornOutcomes' ], person_id = person )
769805
770806 self .sim .modules ['HealthSystem' ].schedule_hsi_event (postnatal_check ,
771- priority = 0 ,
772- topen = self .sim .date ,
773- tclose = self .sim .date + DateOffset (days = 1 ))
807+ priority = 0 ,
808+ topen = self .sim .date ,
809+ tclose = self .sim .date +
810+ DateOffset (days = params ['postnatal_check_sepsis_appt_window_days' ]))
774811
775812 # And apply risk of death for newborns for which care is not sought
776813 for person in care_seeking .loc [~ care_seeking ].index :
@@ -860,10 +897,12 @@ class PostnatalSupervisorEvent(RegularEvent, PopulationScopeEventMixin):
860897 event ensures that the relevant postnatal/neonatal variables are reset for those who survive.
861898 """
862899 def __init__ (self , module , ):
863- super ().__init__ (module , frequency = DateOffset (weeks = 1 ))
900+ p = module .parameters
901+ super ().__init__ (module , frequency = DateOffset (weeks = p ['main_polling_event_frequency_weeks' ]))
864902
865903 def apply (self , population ):
866904 df = population .props
905+ params = self .module .parameters
867906 store_dalys_in_mni = pregnancy_helper_functions .store_dalys_in_mni
868907 mni = self .sim .modules ['PregnancySupervisor' ].mother_and_newborn_info
869908 mnh_counter = self .sim .modules ['PregnancySupervisor' ].mnh_outcome_counter
@@ -900,28 +939,32 @@ def apply(self, population):
900939 # newborn are receiving treatment following the last PNC visit (around day 42)
901940
902941 # Maternal variables
903- week_8_postnatal_women_htn = \
904- df .is_alive & df .la_is_postpartum & (df .pn_postnatal_period_in_weeks == 8 ) & \
905- (df .pn_htn_disorders .str .contains ('gest_htn|severe_gest_htn|mild_pre_eclamp|severe_pre_eclamp|eclampsia' ))
942+ reset_week_postnatal_women_htn = \
943+ (df .is_alive & df .la_is_postpartum &
944+ (df .pn_postnatal_period_in_weeks == params ['postnatal_reset_week' ]) &
945+ (df .pn_htn_disorders .str .contains ('gest_htn|severe_gest_htn|mild_pre_eclamp|severe_pre_eclamp|eclampsia' )))
906946
907947 # Schedule date of resolution for any women with hypertension
908- for person in week_8_postnatal_women_htn .loc [week_8_postnatal_women_htn ].index :
948+ for person in reset_week_postnatal_women_htn .loc [reset_week_postnatal_women_htn ].index :
909949 if not pd .isnull (mni [person ]['hypertension_onset' ]):
910950 store_dalys_in_mni (person , mni , 'hypertension_resolution' , self .sim .date )
911951
912- week_8_postnatal_women_anaemia = \
913- df .is_alive & df .la_is_postpartum & (df .pn_postnatal_period_in_weeks == 8 ) & \
914- (df .pn_anaemia_following_pregnancy != 'none' )
952+ reset_week_postnatal_women_anaemia = \
953+ (df .is_alive & df .la_is_postpartum &
954+ (df .pn_postnatal_period_in_weeks == params ['postnatal_reset_week' ]) &
955+ (df .pn_anaemia_following_pregnancy != 'none' ))
915956
916957 # Schedule date of resolution for any women with anaemia
917- for person in week_8_postnatal_women_anaemia .loc [week_8_postnatal_women_anaemia ].index :
958+ for person in reset_week_postnatal_women_anaemia .loc [reset_week_postnatal_women_anaemia ].index :
918959 store_dalys_in_mni (person , mni , f'{ df .at [person , "pn_anaemia_following_pregnancy" ]} _anaemia'
919960 f'_pp_resolution' , self .sim .date )
920961
921- week_8_postnatal_women = df .is_alive & df .la_is_postpartum & (df .pn_postnatal_period_in_weeks == 8 )
962+ reset_week_postnatal_women = (df .is_alive &
963+ df .la_is_postpartum &
964+ (df .pn_postnatal_period_in_weeks == params ['postnatal_reset_week' ]))
922965
923966 # Set mni[person]['delete_mni'] to True meaning after the next DALY event each womans MNI dict is deleted
924- for person in week_8_postnatal_women .loc [week_8_postnatal_women ].index :
967+ for person in reset_week_postnatal_women .loc [reset_week_postnatal_women ].index :
925968 pn_checks = df .at [person , 'la_pn_checks_maternal' ]
926969
927970 mni [person ]['delete_mni' ] = True
@@ -940,19 +983,20 @@ def apply(self, population):
940983 'visits' : df .at [person , 'la_pn_checks_maternal' ],
941984 'anaemia' : df .at [person , 'pn_anaemia_following_pregnancy' ]})
942985
943- df .loc [week_8_postnatal_women , 'pn_postnatal_period_in_weeks' ] = 0
944- df .loc [week_8_postnatal_women , 'la_is_postpartum' ] = False
945- df .loc [week_8_postnatal_women , 'la_pn_checks_maternal' ] = 0
946- df .loc [week_8_postnatal_women , 'pn_sepsis_late_postpartum' ] = False
947- df .loc [week_8_postnatal_women , 'pn_postpartum_haem_secondary' ] = False
986+ df .loc [reset_week_postnatal_women , 'pn_postnatal_period_in_weeks' ] = 0
987+ df .loc [reset_week_postnatal_women , 'la_is_postpartum' ] = False
988+ df .loc [reset_week_postnatal_women , 'la_pn_checks_maternal' ] = 0
989+ df .loc [reset_week_postnatal_women , 'pn_sepsis_late_postpartum' ] = False
990+ df .loc [reset_week_postnatal_women , 'pn_postpartum_haem_secondary' ] = False
948991
949- df .loc [week_8_postnatal_women , 'pn_htn_disorders' ] = 'none'
950- df .loc [week_8_postnatal_women , 'pn_anaemia_following_pregnancy' ] = 'none'
992+ df .loc [reset_week_postnatal_women , 'pn_htn_disorders' ] = 'none'
993+ df .loc [reset_week_postnatal_women , 'pn_anaemia_following_pregnancy' ] = 'none'
951994
952995 # For the neonates we now determine if they will develop any long term neurodevelopmental impairment following
953996 # survival of the neonatal period
954- week_5_postnatal_neonates = df .is_alive & (df .age_days > 28 ) & (df .age_days < 36 ) & (df .date_of_birth >
955- self .sim .start_date )
997+ week_5_postnatal_neonates = (df .is_alive & (df .age_days > params ['neonatal_period_end_days' ])
998+ & (df .age_days <= params ['neonatal_period_end_days' ] + 7 ) &
999+ (df .date_of_birth > self .sim .start_date ))
9561000
9571001 for person in week_5_postnatal_neonates .loc [week_5_postnatal_neonates ].index :
9581002 pn_checks = df .at [person , 'nb_pnc_check' ]
@@ -1157,7 +1201,8 @@ def log_new_progressed_cases(disease):
11571201 params ['prob_care_seeking_postnatal_emergency' ]):
11581202
11591203 self .sim .modules ['HealthSystem' ].schedule_hsi_event (
1160- pnc_one_maternal , priority = 0 , topen = self .sim .date , tclose = self .sim .date + pd .DateOffset (days = 2 ))
1204+ pnc_one_maternal , priority = 0 , topen = self .sim .date , tclose = self .sim .date +
1205+ pd .DateOffset (days = params ['pnc_one_maternal_appt_window_days' ]))
11611206
11621207 # If she will not receive treatment for her complications we apply risk of death now
11631208 else :
@@ -1166,9 +1211,12 @@ def log_new_progressed_cases(disease):
11661211 else :
11671212 # Women without complications in week one are scheduled to attend PNC in the future
11681213 if mni [individual_id ]['will_receive_pnc' ] == 'late' :
1169- appt_date = self .sim .date + pd .DateOffset (self .module .rng .randint (0 , 35 ))
1214+ appt_date = (self .sim .date +
1215+ pd .DateOffset (self .module .rng .randint (0 ,
1216+ params ['pnc_one_maternal_appt_max_days_without_complications' ])))
11701217 self .sim .modules ['HealthSystem' ].schedule_hsi_event (
1171- pnc_one_maternal , priority = 0 , topen = appt_date , tclose = appt_date + pd .DateOffset (days = 2 ))
1218+ pnc_one_maternal , priority = 0 , topen = appt_date , tclose = appt_date +
1219+ pd .DateOffset (days = params ['pnc_one_maternal_appt_window_days' ]))
11721220
11731221
11741222class PostnatalWeekOneNeonatalEvent (Event , IndividualScopeEventMixin ):
@@ -1216,9 +1264,10 @@ def apply(self, individual_id):
12161264 'emergency_neonate' ])):
12171265
12181266 self .sim .modules ['HealthSystem' ].schedule_hsi_event (pnc_one_neonatal ,
1219- priority = 0 ,
1220- topen = self .sim .date ,
1221- tclose = self .sim .date + pd .DateOffset (days = 1 ))
1267+ priority = 0 ,
1268+ topen = self .sim .date ,
1269+ tclose = self .sim .date +
1270+ pd .DateOffset (days = params ['pnc_one_neonatal_sepsis_appt_window_days' ]))
12221271 else :
12231272 # Apply risk of death for those who wont seek care
12241273 self .module .apply_risk_of_maternal_or_neonatal_death_postnatal (mother_or_child = 'child' ,
@@ -1249,7 +1298,8 @@ def __init__(self, module, person_id):
12491298 self .EXPECTED_APPT_FOOTPRINT = self .make_appt_footprint ({'MajorSurg' : 1 })
12501299 self .ACCEPTED_FACILITY_LEVEL = '1b'
12511300 self .ALERT_OTHER_DISEASES = []
1252- self .BEDDAYS_FOOTPRINT = self .make_beddays_footprint ({'general_bed' : 5 })
1301+ self .BEDDAYS_FOOTPRINT = (
1302+ self .make_beddays_footprint ({'general_bed' : module .parameters ['obstetric_fistula_repair_beddays' ]}))
12531303
12541304 def apply (self , person_id , squeeze_factor ):
12551305 df = self .sim .population .props
0 commit comments