@@ -554,6 +554,15 @@ class HealthSystem(Module):
554
554
"and custom (user can freely set these factors as parameters in the analysis)." ,
555
555
),
556
556
557
+ 'dynamic_HR_scaling_factor' : Parameter (
558
+ Types .REAL , "Factor by which HR capabilities are scaled at regular intervals of 1 year"
559
+ ),
560
+
561
+ 'scale_HR_by_popsize' : Parameter (
562
+ Types .BOOL , "Decide whether to scale HR capabilities by population size every year. Can be used in addition to"
563
+ "dynamic_HR_scaling_factor"
564
+ ),
565
+
557
566
'tclose_overwrite' : Parameter (
558
567
Types .INT , "Decide whether to overwrite tclose variables assigned by disease modules" ),
559
568
@@ -904,6 +913,12 @@ def initialise_simulation(self, sim):
904
913
sim .schedule_event (HealthSystemChangeMode (self ),
905
914
Date (self .parameters ["year_mode_switch" ], 1 , 1 ))
906
915
916
+ # Schedule recurring event which will rescale daily capabilities at regular intervals.
917
+ # Note: if want to use Demography's popsize_by_year for current year too (see options in DynamicRescalingHRCapabilities),
918
+ # need to ensure that the DynamicRescalingHRCapabilities event takes place *after* the DemographyLoggerEvent has been called.
919
+ # Could achieve this for example by scheduling the former to happen on 2nd of Feb..
920
+ sim .schedule_event (DynamicRescalingHRCapabilities (self ), Date (sim .date + DateOffset (years = 1 )))
921
+
907
922
def on_birth (self , mother_id , child_id ):
908
923
self .bed_days .on_birth (self .sim .population .props , mother_id , child_id )
909
924
@@ -2842,6 +2857,29 @@ def apply(self, population):
2842
2857
self .module .bed_days .availability = self ._parameters ['beds_availability' ]
2843
2858
2844
2859
2860
+ class DynamicRescalingHRCapabilities (RegularEvent , PopulationScopeEventMixin ):
2861
+ """ This event exists to scale the daily capabilities assumed at fixed time intervals"""
2862
+ def __init__ (self , module ):
2863
+ super ().__init__ (module , frequency = DateOffset (years = 1 ))
2864
+
2865
+ def apply (self , population ):
2866
+
2867
+ # The following assumes that self.module._daily_capabilities is initialised once at start of simulation,
2868
+ # which I believe is correct
2869
+
2870
+ # Rescale daily capabilities by specified amount
2871
+ self .module ._daily_capabilities *= self .module .parameters ['dynamic_HR_scaling_factor' ]
2872
+
2873
+ # Rescale daily capabilities by population size, if this option is included
2874
+ if self .module .parameters ['scale_HR_by_popsize' ]:
2875
+ demog = self .sim .modules ['Demography' ]
2876
+ if self .sim .date .year > 2010 :
2877
+ # Either
2878
+ self .module ._daily_capabilities *= population .props .is_alive .sum ()/ demog .popsize_by_year [self .sim .date .year - 1 ]
2879
+ # Or, if ensuring DemographyLoggingEvent at start of the year takes place *before* this rescaling
2880
+ # self.module._daily_capabilities *= demog.popsize_by_year[self.sim.date.year]/demog.popsize_by_year[self.sim.date.year - 1]
2881
+
2882
+
2845
2883
class HealthSystemChangeMode (RegularEvent , PopulationScopeEventMixin ):
2846
2884
""" This event exists to change the priority policy adopted by the
2847
2885
HealthSystem at a given year. """
0 commit comments