Source code for emodpy_tbhiv.interventions.active_diagnostic
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
[docs]def ActiveDiagnostic(
camp,
trigger_treatment_list,
active_sensitivity=1.0,
active_specificity=1.0,
pos_event= 'TBTestPositive',
treatment_fraction= 1,
start_day=1,
duration=-1,
property_restrictions_list=[],
nodeIDs=[],
cost=0,
black_period=0,
black_trigger='Blackout',
event_name='TB Diagnosis Active Simple'):
"""
Create and return triggered campaign event that issues an ActiveDiagnostic intervention. See :doc:`emod-tbhiv:parameter-campaign-individual-activediagnostic`
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.
active_sensitivity: Sensitivity. Defaults to 1.0.
active_specificity: Specificity. Defaults to 1.0.
pos_event: Signal (or trigger) which is broadcast if the test is positive. Defaults to 'TBTestPositive',
treatment_fraction: Fraction of population testing positive you get the positive result effect.
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.
black_period: Undocumented.
black_trigger: Undocumented.
event_name: Undocumented.
Returns:
New campaign event that can be added to the campaign.
"""
# First, get the objects
schema_path = camp.schema_path
intervention = s2c.get_class_with_defaults( "ActiveDiagnostic", schema_path )
intervention.Base_Sensitivity = active_sensitivity
intervention.Base_Specificity = active_specificity
intervention.Treatment_Fraction = treatment_fraction
#intervention.Days_To_Diagnosis = 0
intervention.Event_Or_Config = 'Event' # should not be necessary
intervention.Positive_Diagnosis_Event = camp.get_send_trigger(pos_event)
intervention.Cost_To_Consumer = cost
event = common.TriggeredCampaignEvent( camp, start_day,event_name, trigger_treatment_list, [ intervention ], Node_Ids=nodeIDs, Duration=duration, Property_Restrictions=property_restrictions_list )
purge_campaign_event( event )
return event
[docs]def new_intervention_as_file( camp, start_day=1, filename=None ):
camp.add( ActiveDiagnostic( camp, trigger_treatment_list=[ "Births" ] ) )
if filename is None:
filename = "active_diag.json"
camp.save( filename )
return filename