[docs]defnew_diagnostic(camp,choices,intervention_name:str=None,disqualifying_properties:List[str]=None,new_property_value:str=None):""" Wrapper function to create and return a HIVRandomChoice intervention. Args: camp: emod_api.campaign object with schema_path set. choices: dict of events:probability, with probs summing up to 1.0 intervention_name (str): The name of the intervention. disqualifying_properties (list of str): A list of IndividualProperty key:value pairs that cause an intervention to be aborted new_property_value (str): An optional IndividualProperty key:value pair that will be assigned when the intervention is distributed. Returns: ReadOnlyDict: Schema-based smart dictionary representing a new """intervention=s2c.get_class_with_defaults("HIVRandomChoice",camp.schema_path)# We should probably check that choices is correctly formatted.choice_names=[]choice_probabilities=[]forkey,valueinchoices.items():choice_names.append(camp.get_send_trigger(key,old=True))choice_probabilities.append(value)intervention.Choice_Names=choice_namesintervention.Choice_Probabilities=choice_probabilitiesset_intervention_properties(intervention,intervention_name=intervention_name,disqualifying_properties=disqualifying_properties,new_property_value=new_property_value)returnintervention
[docs]defnew_intervention_event(camp,choices,start_day=1,coverage=1.0,node_ids=None,intervention_name:str=None,disqualifying_properties:List[str]=None,new_property_value:str=None):""" Diagnostic as scheduled event. """diag=new_diagnostic(camp,choices,intervention_name=intervention_name,disqualifying_properties=disqualifying_properties,new_property_value=new_property_value)# Coordinatorcoordinator=s2c.get_class_with_defaults("StandardEventCoordinator",camp.schema_path)coordinator.Intervention_Config=diagcoordinator.Demographic_Coverage=coverage# Eventevent=s2c.get_class_with_defaults("CampaignEvent",camp.schema_path)event.Event_Coordinator_Config=coordinatorevent.Start_Day=float(start_day)event.Nodeset_Config=utils.do_nodes(camp.schema_path,node_ids)from.importutilsashiv_utilshiv_utils.declutter(event)returnevent