Source code for emodpy_tbhiv.interventions.cash

from emod_api import schema_to_class as s2c
import emod_api.interventions.common as common
import emod_api.interventions.utils as utils
from emodpy_tbhiv.interventions import purge_campaign_event

co_event = "HCCashDistributed"

[docs]def triggered_cash( camp, amount=100, coverage=1.0, start_day=1, triggers=["Births"], property_restrictions_list=[], nodeIDs=[], event_name='Seed_Money'): """ Create and return scheduled campaign event that supplements individuals' health care budgets. Args: camp: Centralized campaign module instance. amount: How much money to give them. Just constant for now. start_day: The timestep when this campaign event takes effect. Defaults to 1. triggers: Signals upon which to trigger distribution of cash. Default=["Births"], property_restrictions_list: Optiional list of Individual Properties to limit the intervention to. nodeIDs: Optiona list of node ids to target. Defaults to all. event_name: Undocumented. Returns: New campaign event that can be added to the campaign. """ schema_path = camp.schema_path act_intervention = s2c.get_class_with_defaults( "GiveCash", schema_path ) act_intervention.Budget_Amount_Constant = amount bcast_intervention = s2c.get_class_with_defaults( "BroadcastEvent", schema_path ) bcast_intervention.Broadcast_Event = camp.get_send_trigger( co_event ) event = common.TriggeredCampaignEvent( camp, Start_Day=start_day, Demographic_Coverage=coverage, Triggers=triggers, Intervention_List=[ act_intervention, bcast_intervention ], Node_Ids=nodeIDs, Property_Restrictions=property_restrictions_list, Event_Name=event_name ) purge_campaign_event( event ) return event
[docs]def cash( camp, amount=100, coverage=1.0, start_day=1, property_restrictions_list=[], nodeIDs=[], event_name='Cash'): """ Create and return scheduled campaign event that supplements individuals' health care budgets. Args: camp: Centralized campaign module instance. amount: How much money to give them. Just constant for now. start_day: The timestep when this campaign event takes effect. Defaults to 1. property_restrictions_list: Optiional list of Individual Properties to limit the intervention to. nodeIDs: Optiona list of node ids to target. Defaults to all. event_name: Undocumented. Returns: New campaign event that can be added to the campaign. """ schema_path = camp.schema_path act_intervention = s2c.get_class_with_defaults( "GiveCash", schema_path ) act_intervention.Budget_Amount_Constant = amount bcast_intervention = s2c.get_class_with_defaults( "BroadcastEvent", schema_path ) bcast_intervention.Broadcast_Event = camp.get_send_trigger( co_event ) event = common.ScheduledCampaignEvent( camp, Start_Day=start_day, Demographic_Coverage=coverage, Intervention_List=[ act_intervention, bcast_intervention ], Node_Ids=nodeIDs, Property_Restrictions=property_restrictions_list ) purge_campaign_event( event ) return event
[docs]def new_intervention_as_file( camp, filename="cash.json" ): camp.add( cash( camp ) ) camp.save( filename ) return filename