Source code for emodpy_tbhiv.interventions.tb_treat_basic
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.TB_Drug_Types.append( drug_name )
return config
[docs]def TBDrugTreatment(
camp,
trigger_treatment_list,
drug_name= 'DOTS',
inactivation_rate=0,
mortality_rate=0,
clearance_rate=0,
resistance_rate=0,
relapse_rate=0,
reduced_transmit=1.0,
start_day=1,
treatment_duration=180,
duration=-1,
property_restrictions_list=[],
nodeIDs=[],
cost=0,
black_period=0,
black_trigger='Blackout',
event_name='TBDrugTreatment'):
"""
Create and return triggered campaign event that issues an AntiTBDrug intervention. See :doc:`emod-tbhiv:parameter-campaign-individual-antitbdrug`
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: ... Defaults to 'DOTS',
inactivation_rate: ... Defaults to 0,
mortality_rate: ... Defaults to 0,
clearance_rate: ... Defaults to 0,
resistance_rate: ... Defaults to 0,
relapse_rate: ... Defaults to 0,
reduced_transmit: ... 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 )
act_intervention = s2c.get_class_with_defaults( "AntiTBDrug", schema_path )
# Third, do the actual settings
act_intervention.Drug_Type = drug_name
act_intervention.TB_Drug_Inactivation_Rate = inactivation_rate
act_intervention.TB_Drug_Cure_Rate = clearance_rate
act_intervention.TB_Drug_Resistance_Rate = resistance_rate
act_intervention.TB_Drug_Relapse_Rate = relapse_rate
act_intervention.TB_Drug_Mortality_Rate = mortality_rate
act_intervention.Reduced_Transmit = reduced_transmit
act_intervention.Durability_Profile = 'FIXED_DURATION_CONSTANT_EFFECT'
act_intervention.Primary_Decay_Time_Constant = treatment_duration
act_intervention.Cost_To_Consumer = cost
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,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=None ):
camp.add( TBDrugTreatment( camp, trigger_treatment_list=[ "Births" ], drug_name="DOTS" ) )
if filename is None:
filename = "tb_drug_treat.json"
camp.save( filename )
return filename