Source code for emodpy_tbhiv.interventions.tbhiv_treat

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
from functools import partial

co_event = "TbDrugDistributed"

def _add_drug( config, drug_name ):
    config.parameters.TBHIV_Drug_Types.append( drug_name )
    return config

[docs]def TBHIVDrugTreatment( camp, trigger_treatment_list, drug_name, latent_multiplier=1.0, active_multiplier=1.0, start_day=1, duration=-1, property_restrictions_list=[], nodeIDs=[], cost=0, black_period=0, black_trigger='Blackout', event_name='TBHIVDrugTreatment'): """ Create and return triggered campaign event that issues a 'TBHIVConfigurableTBdrug' intervention. See :doc:`emod-tbhiv:parameter-campaign-individual-tbhivconfigurabletbdrug` Args: camp: The :py:obj:`emod_api:emod_api.campaign` module instance which serves as the campaign accumulator. trigger_treatment_list: List of 1 or more triggers (or events or signals) which are listened to and trigger the distribution of the intervention. There is no default. drug_name: ... latent_multiplier: ... Defaults to 1.0. active_multiplier: ... Defaults to 1.0. start_day: The timestep when this campaign event takes effect. Defaults to 1. duration: How long the campaign event remains in effect. Defaults to forever. property_restrictions_list: Optiional list of Individual Properties to limit the intervention to. nodeIDs: Optiona list of node ids to target. Defaults to all. cost: Per unit 'price' of each intervention. black_period: Undocumented. black_trigger: Undocumented. event_name: Undocumented. Returns: New campaign event that can be added to the campaign. """ schema_path = camp.schema_path add_this_drug = partial( _add_drug, drug_name=drug_name ) camp.implicits.append( add_this_drug ) bcast_intervention = s2c.get_class_with_defaults( "BroadcastEvent", schema_path ) bcast_intervention.Broadcast_Event = camp.get_send_trigger( co_event ) act_intervention = s2c.get_class_with_defaults( "TBHIVConfigurableTBdrug", schema_path ) act_intervention.TB_Drug_Name = drug_name act_intervention.Latency_Multiplier = latent_multiplier act_intervention.Active_Multiplier = active_multiplier act_intervention.Durability_Profile = 'FIXED_DURATION_CONSTANT_EFFECT' act_intervention.Remaining_Doses = 1 act_intervention.Cost_To_Consumer = cost event = common.TriggeredCampaignEvent( camp, start_day,event_name, trigger_treatment_list, [ act_intervention, bcast_intervention ], Node_Ids=nodeIDs, Duration=duration, Property_Restrictions=property_restrictions_list ) purge_campaign_event( event ) return event
[docs]def new_intervention_as_file( camp, filename="tb_drug_treat.json" ): camp.add( TBHIVDrugTreatment( camp, trigger_treatment_list=[ "Births" ], drug_name="DOTS" ) ) camp.save( filename ) return filename