intervention_systems
add_diagnostic_survey(campaign, drug=None, diagnostic_type=DiagnosticType.BLOOD_SMEAR_PARASITES, detection_threshold=40, measurement_sensitivity=0.1, treatment_delay=None, start_day=1, node_ids=None, event_name='Diagnostic Survey', positive_diagnosis_configs=None, negative_diagnosis_configs=None, received_test_event='Received_Test', target_demographics_config=None, property_restrictions=None, disqualifying_properties=None, repetition_config=None, trigger_condition_list=None, duration=-1, triggered_campaign_delay=None, check_eligibility_at_trigger=False, expire_recent_drugs=False)
Add a scheduled or triggered diagnostic survey to the campaign using a MalariaDiagnostic. Upon positive or negative diagnosis, the interventions in positive_diagnosis_configs or negative_diagnosis_configs are distributed to the individual.
The drug parameter provides a convenient shorthand: when set, it builds drug intervention configs and appends them to positive_diagnosis_configs automatically. If treatment_delay is also set, the drugs are wrapped in a DelayedIntervention.
The diagnostic broadcasts "TestedPositive" and "TestedNegative" events.
If positive_diagnosis_configs or negative_diagnosis_configs are provided,
separate triggered events listen for internal tether broadcasts and distribute the
configured interventions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
The campaign object to which events will be added. |
required |
drug
|
Union[str, list]
|
Drug regimen to distribute on positive diagnosis. Either a drug code
string from |
None
|
diagnostic_type
|
Union[DiagnosticType, str]
|
Type of malaria diagnostic. See
DiagnosticType for valid values.
Default: |
BLOOD_SMEAR_PARASITES
|
detection_threshold
|
float
|
Detection threshold whose units depend on diagnostic_type. Default: 40. |
40
|
measurement_sensitivity
|
float
|
Volume of blood tested in microliters (blood-smear diagnostics). Default: 0.1. |
0.1
|
treatment_delay
|
BaseDistribution
|
Delay distribution between positive diagnosis and drug distribution.
Only used when drug is provided. For example,
|
None
|
start_day
|
float
|
Simulation day the survey is created. If triggered, runs on trigger. Default: 1. |
1
|
node_ids
|
Optional[List[int]]
|
Node IDs where the survey applies. |
None
|
event_name
|
str
|
Descriptive name for the campaign event. Default: |
'Diagnostic Survey'
|
positive_diagnosis_configs
|
list
|
Intervention objects distributed to individuals who test positive. If drug is also provided, the drug interventions are appended to this list. |
None
|
negative_diagnosis_configs
|
list
|
Intervention objects distributed to individuals who test negative. |
None
|
received_test_event
|
str
|
Event broadcast when an individual receives the test.
Default: |
'Received_Test'
|
target_demographics_config
|
TargetDemographicsConfig
|
Targeting configuration (coverage, age range, gender). |
None
|
property_restrictions
|
PropertyRestrictions
|
Individual/node property restrictions for receiving the diagnostic. |
None
|
disqualifying_properties
|
list
|
Property key:value pairs that prevent an individual from receiving the diagnostic. |
None
|
repetition_config
|
RepetitionConfig
|
Repetition configuration. For scheduled surveys, passed directly to
|
None
|
trigger_condition_list
|
list
|
Events that trigger the survey. If |
None
|
duration
|
float
|
Days to listen for trigger events. |
-1
|
triggered_campaign_delay
|
BaseDistribution
|
Delay distribution between trigger and survey distribution. |
None
|
check_eligibility_at_trigger
|
bool
|
If |
False
|
expire_recent_drugs
|
bool
|
If |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None, adds events to the campaign. |
Source code in emodpy_malaria/campaign/intervention_systems.py
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | |
add_drug_campaign(campaign, campaign_type=CampaignType.MDA, drug=None, start_days=None, target_demographics_config=None, repetition_config=None, property_restrictions=None, node_ids=None, drug_ineligibility_duration=0, receiving_drugs_event_name='Received_Campaign_Drugs', disqualifying_properties=None, diagnostic_type=DiagnosticType.BLOOD_SMEAR_PARASITES, diagnostic_threshold=40, measurement_sensitivity=0.1, treatment_delay=None, fmda_radius=0, node_selection_type=NodeSelectionType.DISTANCE_ONLY, trigger_coverage=1.0, snowballs=0, trigger_condition_list=None, duration=-1, triggered_campaign_delay=None, check_eligibility_at_trigger=False, trigger_name=None, birth_property_restrictions=None)
Add a drug intervention campaign from a list of malaria campaign types.
Campaign types:
- MDA / SMC -- Mass drug administration. Distributes drugs directly.
- MSAT / MTAT -- Mass screening and treatment. Runs a diagnostic survey and distributes drugs on positive result.
- fMDA -- Focal mass drug administration. Diagnostic survey triggers drug distribution to the individual's node and neighboring nodes.
- rfMSAT -- Reactive focal mass screening and treatment. Treatment of an index case triggers diagnostic surveys on neighboring nodes, cascading via snowballs.
- rfMDA -- Reactive focal mass drug administration. Treatment of an index case triggers drug distribution to neighboring nodes.
- PMC -- Preventive malaria chemoprevention (birth-triggered). Distributes drugs to newborns after a configurable delay.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
The campaign object. |
required |
campaign_type
|
Union[CampaignType, str]
|
The type of drug campaign:
Default: |
MDA
|
drug
|
(Union[str, list[AdherentDrug]], required)
|
The drug regimen to distribute. Either a drug code string from
|
None
|
start_days
|
list
|
Simulation days for drug distribution. Default: |
None
|
target_demographics_config
|
TargetDemographicsConfig
|
Targeting configuration (coverage, age, gender, residents_only). |
None
|
repetition_config
|
RepetitionConfig
|
Repetition and interval configuration. |
None
|
property_restrictions
|
PropertyRestrictions
|
Individual/node property restrictions. |
None
|
node_ids
|
Optional[List[int]]
|
Node IDs. |
None
|
drug_ineligibility_duration
|
float
|
Days to set |
0
|
receiving_drugs_event_name
|
str
|
Event broadcast on drug receipt. Default: |
'Received_Campaign_Drugs'
|
disqualifying_properties
|
list
|
Properties that prevent drug receipt. |
None
|
diagnostic_type
|
Union[DiagnosticType, str]
|
Diagnostic type for screening campaigns.
Default: |
BLOOD_SMEAR_PARASITES
|
diagnostic_threshold
|
float
|
Detection threshold. Default: 40. |
40
|
measurement_sensitivity
|
float
|
Measurement sensitivity. Default: 0.1. |
0.1
|
treatment_delay
|
BaseDistribution
|
Delay distribution between diagnosis and drug distribution (MSAT, fMDA)
or between index case treatment and RCD response (rfMSAT, rfMDA).
For example, |
None
|
fmda_radius
|
float
|
Radius in km for focal response. Default: 0. |
0
|
node_selection_type
|
Union[NodeSelectionType, str]
|
Node selection for focal broadcasts.
Default: |
DISTANCE_ONLY
|
trigger_coverage
|
float
|
Fraction of trigger events initiating RCD (rfMSAT, rfMDA) or fraction receiving diagnostic in fMDA. Default: 1.0. |
1.0
|
snowballs
|
int
|
Number of cascading snowball rounds for rfMSAT. Default: 0. |
0
|
trigger_condition_list
|
list
|
Events that trigger the campaign. |
None
|
duration
|
float
|
Days to listen for triggers. |
-1
|
triggered_campaign_delay
|
BaseDistribution
|
Delay distribution after trigger before campaign runs. |
None
|
check_eligibility_at_trigger
|
bool
|
Check property restrictions at trigger time vs distribution time. Default: False. |
False
|
trigger_name
|
str
|
PMC trigger name (e.g. |
None
|
birth_property_restrictions
|
PropertyRestrictions
|
Property restrictions for the PMC birth trigger event. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
dict |
dict
|
Metadata with campaign type, drug code, and coverage info. |
Source code in emodpy_malaria/campaign/intervention_systems.py
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 | |
add_treatment_seeking(campaign, targets, drug=None, start_day=1, node_ids=None, property_restrictions=None, drug_ineligibility_duration=0, duration=-1, broadcast_event_name='Received_Treatment')
Add event-triggered treatment-seeking behavior to the campaign. When an individual
broadcasts one of the trigger events (e.g. NewClinicalCase), they receive a
drug regimen and a broadcast event indicating treatment was received.
Each entry in targets produces a separate triggered campaign event, allowing different trigger/coverage/age/delay combinations in the same call.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
The campaign object to which events will be added. |
required |
targets
|
(list[dict], required)
|
A list of dictionaries, each defining one trigger-and-target combination. Each dictionary supports the following keys:
Example:: |
required |
drug
|
list[str]
|
Names of antimalarial drugs to distribute. Each name must match a drug
configured in the simulation's Malaria_Drug_Params.
Default: |
None
|
start_day
|
float
|
The simulation day on which the triggered event begins listening. Default: 1. |
1
|
node_ids
|
Optional[List[int]]
|
Node IDs where the event applies. If |
None
|
property_restrictions
|
PropertyRestrictions
|
A PropertyRestrictions object specifying individual property restrictions for receiving treatment. Default: None. |
None
|
drug_ineligibility_duration
|
float
|
Number of days an individual is ineligible for additional drugs after
receiving treatment. Implemented by setting the individual property
|
0
|
duration
|
float
|
Number of days the triggered event listens for triggers. A value of -1 means it listens indefinitely. Default: -1. |
-1
|
broadcast_event_name
|
str
|
Event broadcast when an individual receives treatment.
Default: |
'Received_Treatment'
|
Returns:
| Type | Description |
|---|---|
None
|
None, adds events to the campaign. |
Example
from emodpy_malaria.campaign.intervention_systems import add_treatment_seeking from emod_api import campaign as api_campaign my_campaign = api_campaign my_campaign.set_schema("path_to_schema.json") from emodpy_malaria.campaign.common import PropertyRestrictions add_treatment_seeking( ... campaign=my_campaign, ... targets=[ ... {"trigger": "NewClinicalCase", "coverage": 0.8, "rate": 0.3}, ... {"trigger": "NewSevereCase", "coverage": 0.9} ... ], ... drug=["Artemether", "Lumefantrine"], ... start_day=1, ... property_restrictions=PropertyRestrictions( ... individual_property_restrictions=[["Risk:High"]]), ... drug_ineligibility_duration=14 ... )
Source code in emodpy_malaria/campaign/intervention_systems.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 | |
drug_configs_from_code(campaign, drug_code)
Build a list of AntimalarialDrug interventions from a shorthand drug code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
campaign
|
(campaign, required)
|
The campaign object. |
required |
drug_code
|
(str, required)
|
A key from |
required |
Returns:
| Type | Description |
|---|---|
list[AntimalarialDrug]
|
list[AntimalarialDrug]: One intervention per drug in the regimen. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If drug_code is not in |