Basic TB Treatment¶
This module provides basic TB treatment functionality for TBsim simulations.
Main TB Treatment Module¶
- class tbsim.interventions.tb_treatment.EnhancedTBTreatment(pars=None, **kwargs)[source]¶
Bases:
Intervention
Enhanced TB treatment intervention that implements configurable drug types and treatment protocols.
This intervention manages the treatment of diagnosed TB cases by: - Selecting eligible individuals for treatment - Applying drug-specific treatment protocols - Tracking treatment outcomes (success/failure) - Managing post-treatment care-seeking behavior - Recording comprehensive treatment statistics
- Parameters:
drug_type (TBDrugType) – The type of drug regimen to use for treatment. Options include: - DOTS: Standard DOTS protocol - DOTS_IMPROVED: Enhanced DOTS with better adherence - FIRST_LINE_COMBO: First-line combination therapy
treatment_success_rate (float, default 0.85) – Base treatment success rate (can be overridden by drug-specific parameters)
reseek_multiplier (float, default 2.0) – Multiplier applied to care-seeking probability after treatment failure
reset_flags (bool, default True) – Whether to reset diagnosis and testing flags after treatment failure
- drug_parameters¶
Drug-specific parameters including cure rates and side effects
- Type:
Examples
Create a standard DOTS treatment intervention:
>>> treatment = EnhancedTBTreatment(drug_type=TBDrugType.DOTS)
Create a first-line combination treatment with custom parameters:
>>> treatment = EnhancedTBTreatment( ... drug_type=TBDrugType.FIRST_LINE_COMBO, ... reseek_multiplier=3.0, ... reset_flags=False ... )
Track treatment outcomes over time:
>>> treatment = EnhancedTBTreatment() >>> # After running simulation >>> cumulative_success = treatment.results['cum_treatment_success'] >>> treatment_failures = treatment.results['n_treatment_failure']
- __init__(pars=None, **kwargs)[source]¶
Initialize the enhanced TB treatment intervention.
- Parameters:
pars (dict, optional) – Dictionary of parameters to override defaults
**kwargs – Additional keyword arguments passed to parent class
- step()[source]¶
Execute one timestep of enhanced TB treatment.
This method performs the following operations: 1. Identifies eligible individuals (diagnosed with active TB) 2. Initiates treatment for eligible cases 3. Determines treatment outcomes based on drug-specific success rates 4. Updates individual states and flags based on outcomes 5. Manages post-treatment care-seeking behavior 6. Records treatment statistics for analysis
The treatment process follows standard TB treatment protocols where: - Successful treatment clears TB infection and restores susceptibility - Failed treatment triggers renewed care-seeking with increased probability - Treatment history is tracked for epidemiological analysis
- init_results()[source]¶
Initialize results tracking for the intervention.
This method sets up the data structures needed to track: - Number of individuals treated per timestep - Treatment success and failure counts - Cumulative treatment outcomes over time - Drug type used in each timestep
The results are designed to facilitate epidemiological analysis and intervention effectiveness evaluation.
- update_results()[source]¶
Update results for the current timestep.
This method records the treatment outcomes from the current timestep and maintains running totals for cumulative analysis. It processes: - Current timestep treatment counts - Success and failure outcomes - Drug type information - Cumulative totals for epidemiological analysis
The results are stored in the intervention’s results dictionary and can be accessed for post-simulation analysis and visualization.
Available Classes¶
- TBTreatment
Basic TB treatment intervention with success/failure logic
Key Features¶
Treatment Initiation: Start treatment for diagnosed TB cases
Success/Failure Logic: Realistic treatment outcome modeling
Care-seeking Behavior: Post-treatment health-seeking patterns
Flag Management: Reset diagnosis and testing flags after failure
Result Tracking: Comprehensive treatment outcome monitoring
Usage Examples¶
Basic TB treatment:
from tbsim.interventions.tb_treatment import TBTreatment
from tbsim import TB
# Add TB module and basic treatment
# Note: TBTreatment requires 'diagnosed' attribute
# This is typically added by diagnostic interventions
tb = TB()
treatment = TBTreatment()
sim = ss.Sim(
diseases=tb,
interventions=treatment
)
sim.run()
Custom treatment parameters:
treatment = TBTreatment(
treatment_success_rate=0.9, # 90% success rate
reseek_multiplier=3.0, # 3x care-seeking after failure
reset_flags=True # Reset diagnosis flags
)
Key Methods¶
- Treatment Management
step(): Execute treatment logic each time step
init_results(): Initialize treatment result tracking
update_results(): Update results during simulation
- Treatment Logic
Automatically identifies diagnosed TB cases
Applies treatment success/failure probabilities
Manages post-treatment care-seeking behavior
Tracks treatment outcomes and statistics
Treatment Outcomes¶
The module handles: - Treatment Success: Complete TB clearance and recovery - Treatment Failure: Failed treatment with renewed care-seeking - Care-seeking Multipliers: Increased health-seeking after failure - Flag Management: Reset of diagnosis and testing status
For advanced treatment capabilities, see the Enhanced TB Treatment Interventions module.