def add_MSAT(cb, start_days, coverage, drug_configs, receiving_drugs_event, repetitions, interval, treatment_delay, diagnostic_type, diagnostic_threshold, nodes, expire_recent_drugs, node_property_restrictions, ind_property_restrictions, target_group, trigger_condition_list, triggered_campaign_delay, listening_duration): event_config = drug_configs + [receiving_drugs_event] IP_restrictions = [] if expire_recent_drugs: event_config.append(expire_recent_drugs) IP_restrictions = [{"DrugStatus": "None"}] if treatment_delay == 0: msat_cfg = event_config else: msat_cfg = [{ "class": "DelayedIntervention", "Delay_Distribution": "FIXED_DURATION", "Delay_Period": treatment_delay, "Actual_IndividualIntervention_Configs": event_config }] # MSAT controlled by MalariaDiagnostic campaign event rather than New_Diagnostic_Sensitivity if trigger_condition_list: add_diagnostic_survey( cb, coverage=coverage, repetitions=repetitions, tsteps_btwn=interval, target=target_group, start_day=start_days[0], diagnostic_type=diagnostic_type, diagnostic_threshold=diagnostic_threshold, node_cfg=nodes, positive_diagnosis_configs=msat_cfg, IP_restrictions=ind_property_restrictions, NP_restrictions=node_property_restrictions, pos_diag_IP_restrictions=IP_restrictions, trigger_condition_list=trigger_condition_list, listening_duration=listening_duration, triggered_campaign_delay=triggered_campaign_delay) else: for start_day in start_days: add_diagnostic_survey(cb, coverage=coverage, repetitions=repetitions, tsteps_btwn=interval, target=target_group, start_day=start_day, diagnostic_type=diagnostic_type, diagnostic_threshold=diagnostic_threshold, node_cfg=nodes, positive_diagnosis_configs=msat_cfg, IP_restrictions=ind_property_restrictions, NP_restrictions=node_property_restrictions, pos_diag_IP_restrictions=IP_restrictions)
def rcd_followthrough(cb, coverage=1, delivery_method="MTAT"): # Listen for Diagnostic_Survey_0 and implement a diagnostic survey, then broadcast TestedPositive or TestedNegative. # Then, if TestedPositive, then administer drugs and broadcast Received_RCD_Drugs # Drug setup drug_code = 'AL' drug_configs = drug_configs_from_code(cb, drug_code=drug_code) # set up events to broadcast when receiving reactive campaign drug receiving_drugs_event = { "class": "BroadcastEvent", "Broadcast_Event": "Received_RCD_Drugs" } event_config = drug_configs + [receiving_drugs_event] if delivery_method == "MTAT": add_diagnostic_survey(cb, coverage=coverage, start_day=1, diagnostic_type='BLOOD_SMEAR_PARASITES', diagnostic_threshold=0, trigger_condition_list=['Diagnostic_Survey_0'], event_name='Reactive MSAT level 0', positive_diagnosis_configs=event_config, listening_duration=-1) elif delivery_method == "MDA": add_drug_campaign(cb, coverage=coverage, drug_code=drug_code, start_days=[1], campaign_type="MDA", trigger_condition_list=["Diagnostic_Survey_0"], listening_duration=-1 ) # def add_drug_campaign(cb, campaign_type: str = 'MDA', drug_code: str = None, start_days: list = None, # coverage: float = 1.0, # repetitions: int = 1, tsteps_btwn_repetitions: int = 60, # diagnostic_type: str = 'BLOOD_SMEAR', # diagnostic_threshold: float = 40, fmda_radius: int = 0, # node_selection_type: str = 'DISTANCE_ONLY', # trigger_coverage: float = 1.0, snowballs: int = 0, treatment_delay: int = 0, # triggered_campaign_delay: int = 0, nodeIDs: list = None, target_group: any = 'Everyone', # drug_ineligibility_duration: int = 0, # node_property_restrictions: list = None, ind_property_restrictions: list = None, # disqualifying_properties: list = None, trigger_condition_list: list = None, # listening_duration: int = -1, adherent_drug_configs: list = None, # target_residents_only: int = 1, # check_eligibility_at_trigger: bool = False): return {"delivery_method": delivery_method, "coverage": coverage}
def add_rfMSAT(cb, start_day, coverage, drug_configs, receiving_drugs_event, interval, treatment_delay, trigger_coverage, diagnostic_type, diagnostic_threshold, fmda_radius, node_selection_type, snowballs, nodes, expire_recent_drugs, node_property_restrictions, ind_property_restrictions, trigger_condition_list, listening_duration, triggered_campaign_delay): fmda_setup = fmda_cfg(fmda_radius, node_selection_type) # no trigger used snowball_setup = [deepcopy(fmda_setup) for x in range(snowballs + 1)] snowball_trigger = 'Diagnostic_Survey_' snowball_setup[0]['Event_Trigger'] = snowball_trigger + "0" rcd_event = { "Event_Name": "Trigger RCD MSAT", "class": "CampaignEvent", "Start_Day": start_day, "Event_Coordinator_Config": { "class": "StandardInterventionDistributionEventCoordinator", "Intervention_Config": { "class": "NodeLevelHealthTriggeredIV", # "Blackout_On_First_Occurrence": 1, # "Blackout_Event_Trigger": "rfMSAT_Blackout_Event_Trigger", # "Blackout_Period": 1, "Demographic_Coverage": trigger_coverage, "Node_Property_Restrictions": node_property_restrictions, "Trigger_Condition_List": ["Received_Treatment"], # triggered by successful health-seeking "Duration": interval, # interval argument indicates how long RCD will be implemented "Actual_IndividualIntervention_Config": { "class": "DelayedIntervention", "Delay_Distribution": "FIXED_DURATION", "Delay_Period": 0, "Actual_IndividualIntervention_Configs": [snowball_setup[0]] } } }, "Nodeset_Config": nodes } cb.add_event(rcd_event) event_config = drug_configs + [receiving_drugs_event] IP_restrictions = [] if expire_recent_drugs: event_config.append(expire_recent_drugs) IP_restrictions = [{"DrugStatus": "None"}] add_diagnostic_survey( cb, coverage=coverage, start_day=start_day, diagnostic_type=diagnostic_type, diagnostic_threshold=diagnostic_threshold, node_cfg=nodes, trigger_condition_list=[snowball_setup[0]['Event_Trigger']], event_name='Reactive MSAT level 0', positive_diagnosis_configs=event_config, IP_restrictions=ind_property_restrictions, NP_restrictions=node_property_restrictions, pos_diag_IP_restrictions=IP_restrictions) for snowball in range(snowballs): snowball_setup[snowball + 1]['Event_Trigger'] = snowball_trigger + str(snowball + 1) event_config = [snowball_setup[snowball + 1], receiving_drugs_event ] + drug_configs curr_trigger = snowball_trigger + str(snowball) add_diagnostic_survey(cb, coverage=coverage, start_day=start_day, diagnostic_type=diagnostic_type, diagnostic_threshold=diagnostic_threshold, node_cfg=nodes, trigger_condition_list=[curr_trigger], event_name='Snowball level ' + str(snowball), positive_diagnosis_configs=event_config, IP_restrictions=ind_property_restrictions, NP_restrictions=node_property_restrictions, pos_diag_IP_restrictions=IP_restrictions)
def add_fMDA(cb, start_days, trigger_coverage, coverage, drug_configs, receiving_drugs_event, repetitions, interval, treatment_delay, diagnostic_type, diagnostic_threshold, fmda_radius, node_selection_type, nodes, expire_recent_drugs, node_property_restrictions, ind_property_restrictions, target_group, trigger_condition_list, listening_duration, triggered_campaign_delay): fmda_trigger = "Give_Drugs_fMDA" fmda_setup = [ fmda_cfg(fmda_radius, node_selection_type, event_trigger=fmda_trigger) ] interventions = drug_configs + [receiving_drugs_event] if expire_recent_drugs: interventions = interventions + [expire_recent_drugs] drugstatus = {"DrugStatus": "None"} if ind_property_restrictions: for item in ind_property_restrictions: item.update(drugstatus) else: ind_property_restrictions = [drugstatus] if treatment_delay > 0: fmda_setup = [{ "class": "DelayedIntervention", "Delay_Distribution": "FIXED_DURATION", "Delay_Period": treatment_delay, "Actual_IndividualIntervention_Configs": fmda_setup }] if trigger_condition_list: add_diagnostic_survey( cb, coverage=trigger_coverage, repetitions=repetitions, tsteps_btwn=interval, target=target_group, start_day=start_days[0], diagnostic_type=diagnostic_type, diagnostic_threshold=diagnostic_threshold, node_cfg=nodes, positive_diagnosis_configs=fmda_setup, IP_restrictions=ind_property_restrictions, NP_restrictions=node_property_restrictions, trigger_condition_list=trigger_condition_list, listening_duration=listening_duration, triggered_campaign_delay=triggered_campaign_delay) fmda_distribute_drugs = { "Event_Name": "Distribute fMDA", "class": "CampaignEvent", "Start_Day": start_days[0], "Event_Coordinator_Config": { "class": "StandardInterventionDistributionEventCoordinator", "Intervention_Config": { "class": "NodeLevelHealthTriggeredIV", "Demographic_Coverage": coverage, "Blackout_Event_Trigger": "fMDA_Blackout_Event_Trigger", "Blackout_Period": 1, "Blackout_On_First_Occurrence": 0, "Target_Residents_Only": 1, "Node_Property_Restrictions": node_property_restrictions, "Property_Restrictions_Within_Node": ind_property_restrictions, "Duration": listening_duration, "Trigger_Condition_List": [fmda_trigger], "Actual_IndividualIntervention_Config": { "Intervention_List": interventions, "class": "MultiInterventionDistributor" } } }, "Nodeset_Config": nodes } cb.add_event(fmda_distribute_drugs) else: for start_day in start_days: # separate event for each repetition, otherwise RCD and fMDA can get entangled. for rep in range(repetitions): add_diagnostic_survey( cb, coverage=trigger_coverage, repetitions=1, tsteps_btwn=interval, target=target_group, start_day=start_day + interval * rep, diagnostic_type=diagnostic_type, diagnostic_threshold=diagnostic_threshold, node_cfg=nodes, positive_diagnosis_configs=fmda_setup, IP_restrictions=ind_property_restrictions, NP_restrictions=node_property_restrictions) fmda_distribute_drugs = { "Event_Name": "Distribute fMDA", "class": "CampaignEvent", "Start_Day": start_day + interval * rep + treatment_delay, "Event_Coordinator_Config": { "class": "StandardInterventionDistributionEventCoordinator", "Intervention_Config": { "class": "NodeLevelHealthTriggeredIV", "Demographic_Coverage": coverage, "Blackout_Event_Trigger": "fMDA_Blackout_Event_Trigger", "Blackout_Period": 1, "Blackout_On_First_Occurrence": 0, "Target_Residents_Only": 1, "Node_Property_Restrictions": node_property_restrictions, "Property_Restrictions_Within_Node": ind_property_restrictions, "Duration": 2, #no confusion, but might as well just leave this 2 days. "Trigger_Condition_List": [fmda_trigger], "Actual_IndividualIntervention_Config": { "Intervention_List": interventions, "class": "MultiInterventionDistributor" } } }, "Nodeset_Config": nodes } cb.add_event(fmda_distribute_drugs)