@@ -864,31 +864,29 @@ def initialise_population(self, population):
864864 df ["tb_on_ipt" ] = False
865865 df ["tb_date_ipt" ] = pd .NaT
866866
867-
868867 # # ------------------ infection status ------------------ #
869- if self .sim .generate_event_chains is False or self .sim .generate_event_chains is None :
870- # WHO estimates of active TB for 2010 to get infected initial population
871- # don't need to scale or include treated proportion as no-one on treatment yet
872- inc_estimates = p ["who_incidence_estimates" ]
873- incidence_year = (inc_estimates .loc [
874- (inc_estimates .year == self .sim .date .year ), "incidence_per_100k"
875- ].values [0 ]) / 100_000
876-
877- incidence_year = incidence_year * p ["scaling_factor_WHO" ]
878-
879- self .assign_active_tb (
880- population ,
881- strain = "ds" ,
882- incidence = incidence_year )
883-
884- self .assign_active_tb (
885- population ,
886- strain = "mdr" ,
887- incidence = incidence_year * p ['prop_mdr2010' ])
888-
889- self .send_for_screening_general (
890- population
891- ) # send some baseline population for screening
868+ # WHO estimates of active TB for 2010 to get infected initial population
869+ # don't need to scale or include treated proportion as no-one on treatment yet
870+ inc_estimates = p ["who_incidence_estimates" ]
871+ incidence_year = (inc_estimates .loc [
872+ (inc_estimates .year == self .sim .date .year ), "incidence_per_100k"
873+ ].values [0 ]) / 100_000
874+
875+ incidence_year = incidence_year * p ["scaling_factor_WHO" ]
876+
877+ self .assign_active_tb (
878+ population ,
879+ strain = "ds" ,
880+ incidence = incidence_year )
881+
882+ self .assign_active_tb (
883+ population ,
884+ strain = "mdr" ,
885+ incidence = incidence_year * p ['prop_mdr2010' ])
886+
887+ self .send_for_screening_general (
888+ population
889+ ) # send some baseline population for screening
892890
893891 def initialise_simulation (self , sim ):
894892 """
@@ -901,10 +899,8 @@ def initialise_simulation(self, sim):
901899 sim .schedule_event (TbActiveEvent (self ), sim .date )
902900 sim .schedule_event (TbRegularEvents (self ), sim .date )
903901 sim .schedule_event (TbSelfCureEvent (self ), sim .date )
904-
905902 sim .schedule_event (TbActiveCasePoll (self ), sim .date + DateOffset (years = 1 ))
906903
907-
908904 # 2) log at the end of the year
909905 # Optional: Schedule the scale-up of programs
910906 if self .parameters ["type_of_scaleup" ] != 'none' :
@@ -1406,53 +1402,6 @@ def is_subset(col_for_set, col_for_subset):
14061402# # TB infection event
14071403# # ---------------------------------------------------------------------------
14081404
1409- class TbActiveCasePollGenerateData (RegularEvent , PopulationScopeEventMixin ):
1410- """The Tb Regular Poll Event for Data Generation for assigning active infections
1411- * selects everyone to develop an active infection and schedules onset of active tb
1412- sometime during the simulation
1413- """
1414-
1415- def __init__ (self , module ):
1416- super ().__init__ (module , frequency = DateOffset (years = 120 ))
1417-
1418- def apply (self , population ):
1419-
1420- df = population .props
1421- now = self .sim .date
1422- rng = self .module .rng
1423- # Make everyone who is alive and not infected (no-one should be) susceptible
1424- susc_idx = df .loc [
1425- df .is_alive
1426- & (df .tb_inf != "active" )
1427- ].index
1428-
1429- len (susc_idx )
1430-
1431- middle_index = len (susc_idx ) // 2
1432-
1433- # Will equally split two strains among the population
1434- list_ds = susc_idx [:middle_index ]
1435- list_mdr = susc_idx [middle_index :]
1436-
1437- # schedule onset of active tb. This will be equivalent to the "Onset", so it
1438- # doesn't matter how long after we have decided which infection this is.
1439- for person_id in list_ds :
1440- date_progression = now + pd .DateOffset (
1441- # At some point during their lifetime, this person will develop TB
1442- days = self .module .rng .randint (0 , 365 * (int (self .sim .end_date .year - self .sim .date .year )+ 1 ))
1443- )
1444- # set date of active tb - properties will be updated at TbActiveEvent poll daily
1445- df .at [person_id , "tb_scheduled_date_active" ] = date_progression
1446- df .at [person_id , "tb_strain" ] = "ds"
1447-
1448- for person_id in list_mdr :
1449- date_progression = now + pd .DateOffset (
1450- days = rng .randint (0 , 365 * int (self .sim .end_date .year - self .sim .start_date .year + 1 ))
1451- )
1452- # set date of active tb - properties will be updated at TbActiveEvent poll daily
1453- df .at [person_id , "tb_scheduled_date_active" ] = date_progression
1454- df .at [person_id , "tb_strain" ] = "mdr"
1455-
14561405
14571406class TbActiveCasePoll (RegularEvent , PopulationScopeEventMixin ):
14581407 """The Tb Regular Poll Event for assigning active infections
@@ -1527,6 +1476,7 @@ def apply(self, population):
15271476 self .module .update_parameters_for_program_scaleup ()
15281477 # note also culture test used in target/max scale-up in place of clinical dx
15291478
1479+
15301480class TbActiveEvent (RegularEvent , PopulationScopeEventMixin ):
15311481 """
15321482 * check for those with dates of active tb onset within last time-period
0 commit comments