@@ -447,6 +447,14 @@ def sample_eligible_treatment_success(_filter, _p, _condition):
447447 sample_eligible (men_wo_cond & (df .age_range == _age_range ), p [f'm_{ _age_range } ' ], condition )
448448 sample_eligible (women_wo_cond & (df .age_range == _age_range ), p [f'f_{ _age_range } ' ], condition )
449449
450+ # Initialise diabetes onset dates for those with prevalent diabetes
451+ if condition == 'diabetes' :
452+ has_diabetes = df .index [df .is_alive & df .nc_diabetes ]
453+
454+ for person_id in has_diabetes :
455+ if person_id not in self .diabetes_onset_dates :
456+ self .diabetes_onset_dates [person_id ] = self .sim .date
457+
450458 # ----- Set variables to false / NaT for everyone
451459 df .loc [df .is_alive , f'nc_{ condition } _date_last_test' ] = pd .NaT
452460 df .loc [df .is_alive , f'nc_{ condition } _ever_diagnosed' ] = False
@@ -1062,7 +1070,7 @@ def schedule_death_to_occur_before_next_poll(p_id, cond):
10621070 df .loc [idx_acquires_condition , f'nc_{ condition } ' ] = True
10631071
10641072 # Store onset dates only for diabetes
1065- if condition == 'nc_diabetes ' :
1073+ if condition == 'diabetes ' :
10661074 for person_id in idx_acquires_condition :
10671075 if person_id not in self .module .diabetes_onset_dates :
10681076 self .module .diabetes_onset_dates [person_id ] = self .sim .date
0 commit comments