Plural effusion ka pura mechanism and treatment bata
| Force | Effect |
|---|---|
| Capillary hydrostatic pressure ↑ | Fluid pleural space mein push hoti hai (transudate) |
| Intrapleural pressure ↓ (atelectasis) | Relative hydrostatic pressure badh jaata hai → fluid entry ↑ |
| Capillary oncotic pressure ↓ | Proteins fluid ko vessels mein nahi rok paate → fluid leaks |
| Microvascular permeability ↑ | Inflammation/infection → protein-rich fluid leaks (exudate) |
| Lymphatic obstruction | Fluid exit band → accumulation |

| Cause | Mechanism |
|---|---|
| Pneumonia / Parapneumonic | Bacterial toxins → pleural inflammation → permeability ↑ |
| Malignancy | Tumor lymphatic blockade + direct pleural invasion |
| Tuberculosis | Intense granulomatous infiltration → entry ↑, lymphatic exit ↓ (50% kam lymphatic flow) |
| Pulmonary Embolism | Bradykinin/VEGF → permeability ↑; atelectasis → intrapleural pressure ↓; CVP ↑ → exit ↓ |
| Rheumatoid/SLE | Immune-mediated pleuritis |
| Pancreatitis | Pancreatic enzymes → diaphragm cross karke pleural space mein |
| Cause | Treatment |
|---|---|
| CHF | Diuretics (furosemide), ACE inhibitors, salt restriction |
| Nephrotic syndrome | Diuretics, bilateral effusions responsive hote hain |
| Hepatic hydrothorax (Cirrhosis) | Sodium restriction + diuretics (first line); TIPS (portal pressure ↓ - 70-80% response); Indwelling pleural catheter (bridge to transplant) |
| Myxedema | Thyroid hormone replacement |
| Type | Mechanism | Common Causes | Treatment |
|---|---|---|---|
| Transudate | Hydrostatic ↑ / Oncotic ↓ / Diaphragm defect | CHF, Cirrhosis, Nephrotic | Treat cause + Diuretics |
| Exudate | Permeability ↑ / Lymphatic block | Pneumonia, Malignancy, TB, PE | Antibiotics/Pleurodesis/IPC |
| Empyema | Infected fluid (pus) | Bacterial pneumonia | Chest tube + Antibiotics |
| Chylothorax | Lymphatic duct leak | Trauma, Malignancy | NPO/TPN, Octreotide, Surgery |
| Hemothorax | Blood in pleural space | Trauma, Malignancy | Chest tube, Surgery |
Tuberclosis ka ek complete assignment complete krke dede jisse m college m submit kr payu
mkdir -p /home/daytona/workspace/tb-assignment && ls /home/daytona/workspace/
~/tb-assignment/generate_tb_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import ListFlowable, ListItem
OUTPUT = "/home/daytona/workspace/tb-assignment/Tuberculosis_Assignment.pdf"
# ── Page layout ──────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=2.5*cm, rightMargin=2.5*cm,
topMargin=2.5*cm, bottomMargin=2.5*cm,
title="Tuberculosis – A Comprehensive Medical Assignment",
author="MBBS Student"
)
W = A4[0] - 5*cm # usable width
# ── Colour palette ────────────────────────────────────────────────────────────
MAROON = colors.HexColor("#7B0000")
DARK_RED = colors.HexColor("#A30000")
LIGHT_BG = colors.HexColor("#FFF8F8")
HEADER_BG= colors.HexColor("#7B0000")
ROW_ALT = colors.HexColor("#FDE8E8")
WHITE = colors.white
GREY = colors.HexColor("#555555")
BORDER = colors.HexColor("#C0392B")
# ── Styles ────────────────────────────────────────────────────────────────────
base = getSampleStyleSheet()
title_style = ParagraphStyle(
"Title", parent=base["Title"],
fontSize=22, textColor=MAROON, leading=28,
alignment=TA_CENTER, spaceAfter=4
)
subtitle_style = ParagraphStyle(
"Subtitle", parent=base["Normal"],
fontSize=12, textColor=GREY, alignment=TA_CENTER, spaceAfter=2
)
meta_style = ParagraphStyle(
"Meta", parent=base["Normal"],
fontSize=10, textColor=GREY, alignment=TA_CENTER, spaceAfter=6
)
h1 = ParagraphStyle(
"H1", parent=base["Heading1"],
fontSize=15, textColor=WHITE, leading=20,
backColor=HEADER_BG, borderPadding=(5, 8, 5, 8),
spaceAfter=8, spaceBefore=14
)
h2 = ParagraphStyle(
"H2", parent=base["Heading2"],
fontSize=12, textColor=DARK_RED, leading=16,
spaceAfter=4, spaceBefore=10, borderPadding=(0,0,2,0),
underlineProportion=0
)
h3 = ParagraphStyle(
"H3", parent=base["Heading3"],
fontSize=11, textColor=MAROON, leading=14,
spaceAfter=3, spaceBefore=7, fontName="Helvetica-BoldOblique"
)
body = ParagraphStyle(
"Body", parent=base["Normal"],
fontSize=10, leading=15, textColor=colors.black,
alignment=TA_JUSTIFY, spaceAfter=5
)
bullet = ParagraphStyle(
"Bullet", parent=base["Normal"],
fontSize=10, leading=14, leftIndent=16,
bulletIndent=4, spaceAfter=3, textColor=colors.black
)
table_header_style = ParagraphStyle(
"TH", parent=base["Normal"],
fontSize=9, textColor=WHITE, fontName="Helvetica-Bold", leading=12
)
table_cell_style = ParagraphStyle(
"TC", parent=base["Normal"],
fontSize=9, textColor=colors.black, leading=12
)
ref_style = ParagraphStyle(
"Ref", parent=base["Normal"],
fontSize=9, textColor=GREY, leading=13, leftIndent=12,
spaceAfter=2
)
def B(text): return f"<b>{text}</b>"
def I(text): return f"<i>{text}</i>"
def BI(text): return f"<b><i>{text}</i></b>"
def h1p(text):
return Paragraph(f" {text}", h1)
def h2p(text):
return Paragraph(text, h2)
def h3p(text):
return Paragraph(text, h3)
def bp(text):
return Paragraph(text, body)
def bull(items):
return [Paragraph(f"• {i}", bullet) for i in items]
def make_table(headers, rows, col_widths=None):
data = [[Paragraph(h, table_header_style) for h in headers]]
for row in rows:
data.append([Paragraph(str(c), table_cell_style) for c in row])
if col_widths is None:
col_widths = [W / len(headers)] * len(headers)
style = TableStyle([
("BACKGROUND", (0,0), (-1,0), HEADER_BG),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [WHITE, ROW_ALT]),
("GRID", (0,0), (-1,-1), 0.4, BORDER),
("VALIGN", (0,0), (-1,-1), "TOP"),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING",(0,0), (-1,-1), 5),
])
return Table(data, colWidths=col_widths, style=style, hAlign="LEFT",
repeatRows=1)
def hr():
return HRFlowable(width="100%", thickness=0.8, color=BORDER, spaceAfter=6, spaceBefore=6)
# ═══════════════════════════════════════════════════════════════════════════════
# BUILD CONTENT
# ═══════════════════════════════════════════════════════════════════════════════
story = []
# ── COVER PAGE ─────────────────────────────────────────────────────────────────
story.append(Spacer(1, 1.5*cm))
story.append(Paragraph("TUBERCULOSIS", title_style))
story.append(Paragraph("A Comprehensive Medical Assignment", subtitle_style))
story.append(hr())
story.append(Spacer(1, 0.3*cm))
story.append(Paragraph("Course: MBBS | Subject: Respiratory Medicine / Community Medicine", meta_style))
story.append(Paragraph("Date of Submission: July 2026", meta_style))
story.append(Spacer(1, 0.5*cm))
# Cover box
cover_data = [
[Paragraph(B("Topic"), table_header_style), Paragraph("Tuberculosis (TB)", table_cell_style)],
[Paragraph(B("Subject Area"), table_header_style), Paragraph("Pulmonary Medicine, Microbiology, Pharmacology, Community Medicine", table_cell_style)],
[Paragraph(B("Pathogen"), table_header_style), Paragraph(BI("Mycobacterium tuberculosis") + " (Robert Koch, 1882)", table_cell_style)],
[Paragraph(B("Global Burden"), table_header_style), Paragraph("~10.6 million new cases/year; 2nd leading infectious disease killer (after HIV)", table_cell_style)],
[Paragraph(B("India's Burden"), table_header_style), Paragraph("~26% of global TB burden; highest case load worldwide", table_cell_style)],
]
cover_table = Table(cover_data, colWidths=[5*cm, W-5*cm],
style=TableStyle([
("BACKGROUND", (0,0), (0,-1), MAROON),
("TEXTCOLOR", (0,0), (0,-1), WHITE),
("BACKGROUND", (1,0), (1,-1), LIGHT_BG),
("GRID", (0,0), (-1,-1), 0.5, BORDER),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("TOPPADDING", (0,0), (-1,-1), 6),
("BOTTOMPADDING",(0,0),(-1,-1), 6),
("LEFTPADDING", (0,0), (-1,-1), 8),
]))
story.append(cover_table)
story.append(Spacer(1, 0.5*cm))
story.append(PageBreak())
# ── TABLE OF CONTENTS ─────────────────────────────────────────────────────────
story.append(h1p("TABLE OF CONTENTS"))
toc_items = [
("1.", "Introduction & Definition"),
("2.", "Epidemiology"),
("3.", "Etiology & Microbiology"),
("4.", "Classification of Tuberculosis"),
("5.", "Pathogenesis"),
("6.", "Clinical Features"),
("7.", "Investigations & Diagnosis"),
("8.", "Treatment"),
("9.", "Drug-Resistant Tuberculosis (MDR-TB / XDR-TB)"),
("10.", "Complications"),
("11.", "Prevention & Control (BCG, DOTS, RNTCP/NSP)"),
("12.", "Tuberculosis in Special Situations"),
("13.", "References"),
]
for num, topic in toc_items:
story.append(Paragraph(f"{num} {topic}", body))
story.append(PageBreak())
# ─────────────────────────────────────────────────────────────────────────────
# 1. INTRODUCTION
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("1. INTRODUCTION & DEFINITION"))
story.append(bp(
"Tuberculosis (TB) is a chronic infectious disease caused by the acid-fast bacillus "
+ BI("Mycobacterium tuberculosis") +
". It primarily affects the lungs (pulmonary TB) but can involve virtually any organ system "
"(extrapulmonary TB). The disease has plagued humanity for millennia — "
"skeletal evidence of spinal TB has been found in Egyptian mummies. "
"Robert Koch identified the causative organism in 1882, earning him the Nobel Prize."
))
story.append(bp(
"Despite the availability of effective chemotherapy for over 70 years, TB remains one of the "
"world's most devastating infectious diseases. The WHO Global TB Report estimates approximately "
B("10.6 million new cases") + " and " + B("1.6 million deaths") +
" annually. India bears the single largest national burden — approximately "
B("26% of global incidence") + "."
))
story.append(Spacer(1, 0.3*cm))
# ─────────────────────────────────────────────────────────────────────────────
# 2. EPIDEMIOLOGY
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("2. EPIDEMIOLOGY"))
story.append(h2p("2.1 Global Burden"))
story += bull([
"Approximately 10.6 million people developed TB in 2022.",
"TB is the 2nd leading cause of death from a single infectious agent (after HIV/AIDS).",
"Eight countries account for two-thirds of cases: India, Indonesia, China, Philippines, Pakistan, Nigeria, Bangladesh, and South Africa.",
"HIV co-infection dramatically increases TB risk: HIV+ individuals are 18× more likely to develop active TB.",
"Drug-resistant TB (MDR-TB, XDR-TB) constitutes a growing global emergency.",
])
story.append(h2p("2.2 Epidemiology in India"))
story += bull([
"India has the highest TB burden globally (~26% of world cases).",
"Estimated 2.69 million incident cases per year (2022 data).",
"Mortality: ~4.94 lakh deaths per year.",
"High-risk groups: malnourished, HIV-positive, diabetics, prisoners, migrants, healthcare workers.",
"Nikshay Poshan Yojana provides financial support to TB patients in India.",
])
story.append(h2p("2.3 Mode of Transmission"))
story.append(bp(
"TB is transmitted via " + B("airborne droplet nuclei") + " (1–5 μm diameter) generated when "
"infectious persons cough, sneeze, talk, or sing. These tiny particles can remain suspended "
"in the air for hours. A single cough may generate ~3,000 droplet nuclei. "
+ B("Close indoor contact") + " with a smear-positive case is the major risk factor. "
"Transmission via fomites, skin contact, or the GI tract (e.g., " + BI("M. bovis") + " via "
"unpasteurized milk) is possible but uncommon."
))
story.append(Spacer(1, 0.3*cm))
# ─────────────────────────────────────────────────────────────────────────────
# 3. ETIOLOGY & MICROBIOLOGY
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("3. ETIOLOGY & MICROBIOLOGY"))
story.append(h2p("3.1 The Organism"))
story.append(bp(
BI("Mycobacterium tuberculosis") + " belongs to the " + B("Mycobacterium tuberculosis complex (MTBC)") +
", which also includes " + BI("M. africanum, M. bovis, M. microti") + ", and " + BI("M. canettii") + ". "
"Humans are the " + B("only significant reservoir") + " of " + BI("M. tuberculosis") + "."
))
story += bull([
B("Morphology:") + " Slender, slightly curved, non-motile, non-spore-forming rod, 1–4 μm long.",
B("Staining:") + " Acid-fast bacillus (AFB) — retains carbol fuchsin after acid-alcohol decolorization (Ziehl-Neelsen stain). Gram-positive but poorly Gram-stained.",
B("Culture:") + " Grows on Lowenstein-Jensen (LJ) medium; forms rough, buff-coloured colonies in 3–8 weeks. Very slow growth (doubling time ~15–20 hours).",
B("Cell wall:") + " Rich in mycolic acids (unique long-chain fatty acids, C70–C90), arabinogalactan, and peptidoglycan — responsible for acid-fastness, resistance to many antibiotics, and immune evasion.",
B("Genome:") + " ~4.4 million bp, GC-rich (65.6%). Encodes type VII secretion systems (ESX-1 to ESX-5) crucial for virulence.",
B("Virulence factors:") + " ESAT-6 (pore-forming, facilitates phagosomal escape), cord factor (trehalose-6,6'-dimycolate), sulfatides (inhibit phagolysosome fusion), LAM (lipoarabinomannan — immunomodulatory).",
])
story.append(Spacer(1, 0.3*cm))
# ─────────────────────────────────────────────────────────────────────────────
# 4. CLASSIFICATION
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("4. CLASSIFICATION OF TUBERCULOSIS"))
story.append(h2p("4.1 By Anatomical Site"))
class_data = [
["Type", "Description", "Frequency"],
["Pulmonary TB", "Lungs ± tracheobronchial tree", "~80–85% of cases"],
["Extrapulmonary TB", "Any organ outside the lungs", "~10–20% of cases"],
["Disseminated (Miliary) TB", "Haematogenous spread; multiple organs", "Immunocompromised/children"],
]
story.append(make_table(class_data[0], class_data[1:], [5*cm, 8*cm, 4.5*cm]))
story.append(Spacer(1, 0.2*cm))
story.append(bp("Common extrapulmonary sites include:"))
story += bull([
"Pleura (Tuberculous pleurisy)",
"Lymph nodes (Scrofula — commonest extrapulmonary in developing countries)",
"Meninges (TB meningitis — most dangerous)",
"Bone and joint (Pott's disease — vertebral TB)",
"Genitourinary tract (Renal TB)",
"Pericardium, peritoneum, adrenal glands",
])
story.append(h2p("4.2 By Disease Status"))
status_data = [
["Category", "Definition", "Infectivity"],
["Latent TB Infection (LTBI)", "Positive TST/IGRA; no symptoms; normal CXR; bacteria alive but inactive", "NOT infectious"],
["Active (Primary) TB", "First infection with TB; symptomatic disease", "Infectious if pulmonary"],
["Reactivation (Post-primary) TB", "Reactivation of old infection (typically upper lobes, cavitary)", "Highly infectious"],
]
story.append(make_table(status_data[0], status_data[1:], [4*cm, 8*cm, 4.5*cm]))
story.append(h2p("4.3 WHO/Rntcp Classification (by treatment history)"))
who_data = [
["Category", "Definition"],
["New", "Never treated for TB or treated for <1 month"],
["Relapse", "Previously treated, declared cured/treatment completed; now bacteriologically confirmed"],
["Treatment after failure", "Previously treated with outcome of failure"],
["Treatment after loss to follow-up", "Previously treated; was lost to follow-up"],
["Transferred in", "Transferred from another TB register"],
["Other previously treated", "Other previously treated with unknown history"],
]
story.append(make_table(who_data[0], who_data[1:], [5*cm, W-5*cm]))
story.append(PageBreak())
# ─────────────────────────────────────────────────────────────────────────────
# 5. PATHOGENESIS
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("5. PATHOGENESIS"))
story.append(h2p("5.1 Stages of Infection"))
story.append(bp(
"The pathogenesis of TB follows a well-defined sequence after inhalation of droplet nuclei "
"containing " + BI("M. tuberculosis") + ":"
))
story.append(h3p("Stage 1 — Inhalation and Alveolar Deposition"))
story.append(bp(
"Droplet nuclei (1–5 μm) containing 1–3 bacilli bypass upper airway defenses and reach the "
"alveoli, typically in the " + B("lower lobes") + " (better ventilation). Here they are "
"phagocytosed by " + B("alveolar macrophages") + "."
))
story.append(h3p("Stage 2 — Intracellular Survival and Early Spread"))
story.append(bp(
BI("M. tuberculosis") + " is an " + B("intracellular pathogen") + " that has evolved "
"sophisticated mechanisms to survive inside macrophages:"
))
story += bull([
B("Phagosome arrest:") + " ESX-3 secretes EsxH which impedes phagosome maturation and MHC II antigen presentation.",
B("Phagolysosome fusion inhibition:") + " Sulfatides and LAM prevent acidification and fusion with lysosomes.",
B("Escape to cytosol:") + " ESAT-6 perforates the phagosomal membrane, facilitating cytosolic access.",
B("Cord factor:") + " Trehalose-6,6'-dimycolate inhibits leukocyte migration and induces granuloma formation.",
])
story.append(bp(
"Infected macrophages spread bacilli through lymphatics to the " + B("hilar lymph nodes") +
". The initial lung focus + enlarged hilar lymph node = " + B("Ghon's complex") +
" (Ghon's focus + lymph node involvement = Ranke complex)."
))
story.append(h3p("Stage 3 — Innate Immune Response"))
story.append(bp(
"Within days, " + B("neutrophils") + " and " + B("natural killer (NK) cells") +
" are recruited. Macrophages release pro-inflammatory cytokines (TNF-α, IL-1, IL-6, IL-12). "
"TNF-α is critical for granuloma formation. "
"IFN-γ activates macrophages to kill intracellular mycobacteria via reactive oxygen species (ROS) "
"and reactive nitrogen intermediates (RNI, including nitric oxide)."
))
story.append(h3p("Stage 4 — Adaptive Immunity and Granuloma Formation"))
story.append(bp(
"2–8 weeks after infection, " + B("T-cell–mediated immunity (CMI)") + " develops. "
+ B("CD4+ T cells") + " (Th1 type) are " + B("essential") +
" — they produce IFN-γ and TNF which activate macrophages. Depletion of CD4+ T cells "
"(as in HIV infection) leads to rapid progression to active disease."
))
story.append(bp(
"The hallmark lesion of TB is the " + B("granuloma (tubercle)") + " — a compact aggregate of:"
))
story += bull([
"Central area of " + B("caseous necrosis") + " (cheese-like; due to hypersensitivity reaction)",
"Surrounded by " + B("epithelioid macrophages") + " (activated macrophages)",
B("Langhans giant cells") + " (multinucleated, peripherally arranged nuclei)",
"Rim of " + B("lymphocytes") + " and fibroblasts",
])
story.append(bp(
"In immunocompetent hosts, granulomas " + B("contain") + " (not eliminate) the bacilli. "
"The bacteria can survive in a " + B("dormant state") + " for decades within granulomas "
"(latent TB). When immunity wanes, reactivation can occur."
))
story.append(h3p("Stage 5 — Progressive Primary TB or Latency"))
story.append(bp(
"In ~90–95% of immunocompetent individuals, primary infection is " + B("contained") +
" → " + B("Latent TB Infection (LTBI)") + ". The individual has a positive TST/IGRA "
"but no symptoms or active disease."
))
story.append(bp(
"In ~5–10% of infected persons (especially children, immunocompromised, malnourished), "
"progressive primary TB occurs. Haematogenous dissemination can lead to "
+ B("miliary TB") + " (diffuse millet-seed lesions) or " + B("TB meningitis") + "."
))
story.append(h3p("Stage 6 — Reactivation TB (Post-primary TB)"))
story.append(bp(
"5–10% of LTBI individuals will reactivate at some point in their lifetime. "
"Reactivation preferentially occurs in " + B("upper lobes") +
" (apex and posterior segments) due to higher oxygen tension. "
"Tissue destruction leads to " + B("cavitation") + ", which is the hallmark of "
"post-primary (reactivation) TB and is associated with high bacillary load and infectivity."
))
story.append(Spacer(1, 0.3*cm))
# ─────────────────────────────────────────────────────────────────────────────
# 6. CLINICAL FEATURES
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("6. CLINICAL FEATURES"))
story.append(h2p("6.1 Constitutional (Systemic) Symptoms"))
story += bull([
B("Fever:") + " Low-grade, afternoon rise; may be associated with evening pyrexia.",
B("Night sweats:") + " Drenching night sweats — classic symptom.",
B("Weight loss:") + " Significant, unexplained (>10% body weight); anorexia, fatigue.",
B("Malaise and fatigue:") + " General weakness and tiredness.",
])
story.append(h2p("6.2 Pulmonary Symptoms"))
story += bull([
B("Cough:") + " Initially dry, progressively productive; >3 weeks duration is a key alarm symptom.",
B("Hemoptysis:") + " Blood-streaked or frank hemoptysis — occurs in cavitary TB from erosion of blood vessels (Rasmussen's aneurysm).",
B("Dyspnea:") + " Due to extensive parenchymal disease, large pleural effusion, pneumothorax.",
B("Chest pain:") + " Pleuritic chest pain (sharp, worse on breathing) with pleural involvement.",
])
story.append(h2p("6.3 Extrapulmonary TB — Specific Features"))
ext_data = [
["Site", "Specific Features"],
["Pleural TB", "Unilateral exudative effusion, pleuritic pain, dyspnea; lymphocytic exudate"],
["TB Lymphadenitis", "Painless cervical lymphadenopathy; may caseate and form 'collar stud' abscess"],
["TB Meningitis", "Subacute headache, meningism, cranial nerve palsies, hydrocephalus; CSF: lymphocytic, high protein, low glucose"],
["Pott's Disease (Spinal TB)", "Back pain, kyphosis (gibbus deformity), paraplegia from cord compression; affects lower thoracic / upper lumbar vertebrae"],
["Renal TB", "Sterile pyuria, haematuria, dysuria; 'putty kidney' on imaging; 'moth-eaten' calyces on IVP"],
["Miliary TB", "Acute febrile illness; classic CXR: diffuse millet-seed nodules (1–2 mm) in all lung fields"],
["Pericardial TB", "Pericarditis, pericardial effusion, constrictive pericarditis"],
["Adrenal TB", "Addison's disease (adrenal insufficiency); bilateral adrenal calcification"],
]
story.append(make_table(ext_data[0], ext_data[1:], [5*cm, W-5*cm]))
story.append(PageBreak())
# ─────────────────────────────────────────────────────────────────────────────
# 7. INVESTIGATIONS & DIAGNOSIS
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("7. INVESTIGATIONS & DIAGNOSIS"))
story.append(h2p("7.1 Bacteriological (Gold Standard)"))
story.append(h3p("Sputum Smear Microscopy (Ziehl-Neelsen Stain)"))
story += bull([
"Simplest, cheapest, fastest method.",
"Two sputum samples (spot-morning-spot): at least 1 AFB-positive confirms pulmonary TB.",
"Sensitivity: ~45–80% (lower in HIV co-infection); Specificity: ~98%.",
"Detects NTM as well; cannot differentiate from " + BI("M. tuberculosis") + ".",
B("Fluorescence microscopy") + " (auramine-rhodamine stain) is more sensitive and faster.",
])
story.append(h3p("Sputum Culture"))
story += bull([
B("Lowenstein-Jensen (LJ) medium:") + " Solid egg-based medium; takes 3–8 weeks.",
B("MGIT (Mycobacteria Growth Indicator Tube):") + " Liquid broth; fluorescence-based; results in 1–3 weeks.",
"Gold standard for diagnosis and drug susceptibility testing (DST).",
"Minimum detectable: ~10 bacilli/mL.",
])
story.append(h3p("Molecular Tests"))
story += bull([
B("GeneXpert MTB/RIF (Xpert):") + " WHO-endorsed point-of-care test. Detects " + BI("M. tuberculosis") + " DNA AND rifampicin resistance in ~2 hours. Sensitivity ~89%, Specificity ~99%. Recommended as initial diagnostic test.",
B("CBNAAT (Cartridge-Based Nucleic Acid Amplification Test):") + " Used in RNTCP/NSP India.",
B("Line Probe Assay (LPA):") + " Detects resistance to INH and RIF; used for MDR-TB diagnosis.",
B("Whole genome sequencing (WGS):") + " Research/reference labs; detects all resistance patterns.",
])
story.append(h2p("7.2 Immunological Tests"))
story.append(h3p("Tuberculin Skin Test (TST / Mantoux Test)"))
story += bull([
"Intradermal injection of " + B("5 TU PPD (Purified Protein Derivative)") + " on volar forearm.",
"Reading at " + B("48–72 hours") + "; measure induration (not erythema).",
B("Interpretation:") + " ≥10 mm = positive (general population); ≥5 mm = positive in HIV/immunosuppressed; ≥15 mm = low-risk individuals.",
"False positives: BCG vaccination, NTM infection.",
"False negatives: HIV, malnutrition, miliary TB, steroid use (anergy).",
])
story.append(h3p("Interferon-Gamma Release Assays (IGRAs)"))
story += bull([
B("QuantiFERON-TB Gold Plus (QFT-Plus)") + " and " + B("T-SPOT.TB") + ".",
"Measure IFN-γ released by T cells in response to TB-specific antigens (ESAT-6, CFP-10).",
"More specific than TST (not affected by BCG vaccination).",
"One-time blood draw; no 48-hour return visit needed.",
"Preferred for LTBI diagnosis in low-incidence countries.",
])
story.append(h2p("7.3 Radiological Investigations"))
story += bull([
B("Chest X-ray:") + " Mandatory for all suspected TB cases. Primary TB: lower/mid zone consolidation + hilar lymphadenopathy. Reactivation TB: upper lobe infiltrates, cavities, nodules, fibrosis.",
B("CT Chest:") + " Superior for detecting subtle lesions, lymphadenopathy, mediastinal involvement, miliary disease.",
B("Chest Ultrasound:") + " Pleural effusion detection and guidance for thoracentesis.",
]
)
story.append(h2p("7.4 Other Investigations"))
inv_data = [
["Investigation", "Findings in TB"],
["CBC", "Normocytic anemia, raised ESR, leukopenia (miliary TB), monocytosis"],
["ESR", "Elevated (non-specific but useful for monitoring)"],
["LFT", "Mild elevation (hepatic TB; also drug monitoring)"],
["Pleural fluid analysis", "Exudate; lymphocytic predominance; glucose low; protein >3g/dL; ADA elevated (>40 IU/L strongly suggests TB)"],
["CSF analysis (TB meningitis)", "Clear/xanthochromic; lymphocytes ↑; glucose ↓; protein ↑; AFB smear/culture/GeneXpert"],
["Adenosine Deaminase (ADA)", "Elevated in pleural fluid (>40), CSF, ascitic fluid — highly suggestive of TB"],
["Biopsy (pleura/lymph node/liver)", "Caseating granulomas with Langhans giant cells; AFB on histology"],
]
story.append(make_table(inv_data[0], inv_data[1:], [5*cm, W-5*cm]))
story.append(PageBreak())
# ─────────────────────────────────────────────────────────────────────────────
# 8. TREATMENT
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("8. TREATMENT"))
story.append(h2p("8.1 Principles of Anti-Tuberculosis Therapy"))
story += bull([
"Combination therapy to prevent emergence of drug resistance.",
"Sufficient duration to eliminate all bacterial populations (replicating, dormant, intracellular).",
"Directly Observed Treatment, Short-course (" + B("DOTS") + ") to ensure adherence.",
"Daily treatment is preferred over intermittent (ATS/CDC/IDSA guidelines 2022).",
])
story.append(h2p("8.2 First-Line Anti-TB Drugs — RIPE"))
drug_data = [
["Drug", "Abbreviation", "Mechanism of Action", "Key Side Effects"],
["Isoniazid", "H / INH", "Inhibits mycolic acid synthesis (InhA enzyme); bactericidal", "Hepatotoxicity, peripheral neuropathy (prevent with pyridoxine), rash"],
["Rifampicin", "R / RIF", "Inhibits bacterial RNA polymerase (β-subunit); bactericidal; sterilizing", "Hepatotoxicity, orange discolouration of body fluids, drug interactions (CYP450 inducer)"],
["Pyrazinamide", "Z / PZA", "Active against intracellular/latent bacilli in acidic pH; sterilizing", "Hepatotoxicity, hyperuricaemia, arthralgia, photosensitivity"],
["Ethambutol", "E / EMB", "Inhibits arabinosyl transferase → blocks arabinogalactan synthesis; bacteriostatic", "Optic neuritis (dose-dependent, monitor visual acuity)"],
["Streptomycin", "S", "Aminoglycoside; inhibits 30S ribosomal subunit; bactericidal", "Ototoxicity (vestibular > auditory), nephrotoxicity, avoid in pregnancy"],
]
story.append(make_table(drug_data[0], drug_data[1:], [3.5*cm, 2.5*cm, 5.5*cm, 6*cm]))
story.append(Spacer(1, 0.3*cm))
story.append(h2p("8.3 Standard Treatment Regimen for Drug-Susceptible TB"))
story.append(bp(
"The standard 6-month regimen consists of two phases:"
))
reg_data = [
["Phase", "Duration", "Drugs", "Purpose"],
["Intensive Phase", "2 months", "HRZE (INH + RIF + PZA + EMB) daily", "Rapid killing of actively replicating bacilli; reduce infectivity"],
["Continuation Phase", "4 months", "HR (INH + RIF) daily", "Elimination of dormant/residual bacilli; prevent relapse"],
]
story.append(make_table(reg_data[0], reg_data[1:], [3.5*cm, 2.5*cm, 5.5*cm, 6*cm]))
story.append(Spacer(1, 0.2*cm))
story += bull([
B("Total duration:") + " 6 months (2HRZE + 4HR) for drug-susceptible pulmonary TB.",
B("TB meningitis, bone/joint TB:") + " Extended to 9–12 months (some guidelines recommend 2HRZE + 10HR).",
B("HIV co-infected:") + " Same 6-month regimen. ART should be started early (within 2 weeks for severe immunosuppression, CD4 <50).",
B("Pyridoxine (Vitamin B6) 25–50 mg/day:") + " Given with INH to prevent peripheral neuropathy.",
B("Adjunct corticosteroids:") + " Indicated in TB meningitis and pericarditis.",
])
story.append(h2p("8.4 Monitoring During Treatment"))
story += bull([
"Monthly clinical review: weight, symptoms, adherence.",
"Sputum AFB smear at end of month 2 (intensive phase); months 5 and 6.",
"LFT baseline and as clinically indicated (especially PZA/INH/RIF).",
"Visual acuity and colour vision: monthly if on EMB (especially if renal impairment).",
"CXR at baseline and on completion.",
])
story.append(PageBreak())
# ─────────────────────────────────────────────────────────────────────────────
# 9. MDR-TB / XDR-TB
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("9. DRUG-RESISTANT TUBERCULOSIS"))
story.append(h2p("9.1 Definitions"))
dr_data = [
["Type", "Definition"],
["Mono-resistant TB", "Resistant to exactly one first-line anti-TB drug"],
["Poly-resistant TB", "Resistant to more than one first-line drug, but not both INH and RIF together"],
["MDR-TB", "Resistant to at least " + B("Isoniazid AND Rifampicin") + " (the two most potent first-line drugs)"],
["Pre-XDR-TB", "MDR-TB + resistance to any fluoroquinolone"],
["XDR-TB", "MDR-TB + resistance to fluoroquinolone + at least one of bedaquiline or linezolid"],
["TDR-TB", "Totally drug-resistant TB (resistance to all tested drugs)"],
]
story.append(make_table(dr_data[0], dr_data[1:], [4*cm, W-4*cm]))
story.append(Spacer(1, 0.3*cm))
story.append(h2p("9.2 Causes of Drug Resistance (MDR-TB is Man-Made)"))
story += bull([
"Inadequate or irregular treatment (poor compliance).",
"Subtherapeutic drug doses or poor-quality drugs.",
"Premature discontinuation of treatment.",
"Monotherapy (adding a single drug to a failing regimen).",
"Transmission of already-resistant strains (primary resistance).",
"HIV co-infection (promotes mutation and spread).",
])
story.append(h2p("9.3 Treatment of MDR-TB"))
story.append(bp(
"MDR-TB treatment requires " + B("second-line drugs") + " administered for 18–24 months "
"(or shorter 9–12 month regimens under specific criteria). "
"WHO 2022 guidelines prioritise a " + B("BPaL or BPaLM regimen") + " (Bedaquiline + Pretomanid + Linezolid ± Moxifloxacin)."
))
mdr_data = [
["Drug Group", "Examples", "Notes"],
["Group A (Prioritize all 3)", "Levofloxacin/Moxifloxacin, Bedaquiline, Linezolid", "Cornerstone of MDR-TB regimen"],
["Group B (Add one or both)", "Clofazimine, Cycloserine/Terizidone", "Added when Group A drugs cannot be used"],
["Group C (Add to complete)", "Ethambutol, Delamanid, Pyrazinamide, Imipenem, Amikacin, Ethionamide", "Use only if Groups A and B insufficient"],
]
story.append(make_table(mdr_data[0], mdr_data[1:], [4*cm, 6*cm, W-10*cm]))
story.append(Spacer(1, 0.3*cm))
# ─────────────────────────────────────────────────────────────────────────────
# 10. COMPLICATIONS
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("10. COMPLICATIONS"))
comp_data = [
["Complication", "Mechanism"],
["Hemoptysis", "Erosion of pulmonary vessel; rupture of Rasmussen's aneurysm (in cavitary TB)"],
["Pneumothorax / Empyema", "Rupture of cavity into pleural space; secondary infection"],
["Respiratory failure", "Extensive bilateral disease; miliary TB"],
["Aspergilloma (Mycetoma)", "Aspergillus colonisation of old TB cavity"],
["Cor pulmonale", "Chronic hypoxia, pulmonary hypertension from fibrotic destruction"],
["Bronchopleural fistula", "Communication between bronchus and pleural space"],
["SIADH", "TB meningitis or pulmonary TB stimulating ADH secretion"],
["Addison's disease", "Bilateral adrenal destruction by TB"],
["Constrictive pericarditis", "Fibrocalcific healing of pericardial TB"],
["Drug-induced hepatitis", "INH, RIF, PZA hepatotoxicity"],
]
story.append(make_table(comp_data[0], comp_data[1:], [6*cm, W-6*cm]))
story.append(PageBreak())
# ─────────────────────────────────────────────────────────────────────────────
# 11. PREVENTION & CONTROL
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("11. PREVENTION & CONTROL"))
story.append(h2p("11.1 BCG Vaccination"))
story += bull([
B("Bacille Calmette-Guérin (BCG)") + " is the only licensed TB vaccine.",
"Live attenuated " + BI("Mycobacterium bovis") + " strain, developed by Calmette and Guérin (1921).",
B("Route and dose:") + " 0.1 mg / 0.1 mL " + B("intradermal") + " injection; site: just above left deltoid insertion. Newborns <4 weeks: 0.05 mL.",
B("Age:") + " At birth (institutional deliveries) or at 6 weeks (along with DPT and Polio) in India.",
B("Efficacy:") + " 80% protective against TB meningitis and miliary TB in children; variable protection against pulmonary TB.",
B("Post-vaccination reaction:") + " Papule develops at 2–3 weeks → ulcerates → heals in 6–12 weeks → permanent 4–8 mm scar.",
B("Contraindications:") + " Symptomatic HIV, severe immunodeficiency, active TB.",
B("Complications:") + " Suppurative lymphadenitis (1–10%); disseminated BCG (<1/million doses).",
])
story.append(h2p("11.2 DOTS — Directly Observed Treatment, Short-Course"))
story += bull([
"The " + B("cornerstone") + " of global TB control; recommended by WHO since 1993.",
"A healthcare worker or trained person " + B("directly observes") + " the patient swallowing every dose.",
"Ensures treatment completion and prevents drug resistance.",
B("Five components of DOTS:") + " (1) Government commitment; (2) Case detection by sputum smear microscopy; (3) Standardised short-course chemotherapy; (4) Uninterrupted drug supply; (5) Monitoring and evaluation system.",
])
story.append(h2p("11.3 RNTCP / National TB Elimination Programme (NTEP) — India"))
story += bull([
"India launched " + B("RNTCP (Revised National TB Control Programme)") + " in 1997.",
"Renamed " + B("National TB Elimination Programme (NTEP)") + " in 2020 with goal to eliminate TB by 2025 (ahead of SDG target of 2030).",
B("Nikshay Portal:") + " Digital platform for TB notification, patient tracking, and supply management.",
B("Nikshay Poshan Yojana:") + " ₹500/month direct benefit transfer to TB patients for nutritional support.",
B("Universal Drug Susceptibility Testing (UDST):") + " GeneXpert/CBNAAT for all new TB patients.",
B("Private sector engagement:") + " Mandatory TB notification from private practitioners.",
B("TB-Harega Desh-Jeetega") + " campaign: national movement to end TB.",
])
story.append(h2p("11.4 Other Prevention Measures"))
story += bull([
B("Infection control:") + " Adequate ventilation, UV germicidal irradiation, N-95 respirator for healthcare workers.",
B("Contact tracing:") + " Screen household and close contacts of index cases.",
B("Treatment of LTBI:") + " INH for 6 months (6H) or Rifapentine + INH for 12 weeks (3HP) for high-risk contacts.",
B("Nutritional support:") + " Malnutrition is a major risk factor; protein-calorie supplementation.",
B("HIV management:") + " ART reduces TB incidence by ~65% in HIV+ persons; Cotrimoxazole prophylaxis.",
])
story.append(PageBreak())
# ─────────────────────────────────────────────────────────────────────────────
# 12. SPECIAL SITUATIONS
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("12. TUBERCULOSIS IN SPECIAL SITUATIONS"))
story.append(h2p("12.1 TB in HIV Co-infection"))
story += bull([
"HIV is the " + B("single greatest risk factor") + " for progression from LTBI to active TB (18× increased risk).",
"Atypical presentation: lower lobe/diffuse infiltrates, absence of cavitation, frequent extrapulmonary TB.",
"CXR may be normal in advanced immunosuppression.",
"Treatment: Same 6-month regimen; ART started within 2 weeks (CD4 <50) or within 8 weeks.",
"Avoid rifampicin + protease inhibitors (drug interaction); use rifabutin instead.",
"Immune Reconstitution Inflammatory Syndrome (IRIS): paradoxical worsening after ART initiation.",
]
)
story.append(h2p("12.2 TB in Pregnancy"))
story += bull([
"Active TB in pregnancy is associated with adverse outcomes: premature delivery, low birth weight, fetal loss.",
"Treatment: HRZE is safe in pregnancy. " + B("Streptomycin is contraindicated") + " (ototoxicity in fetus).",
"INH + pyridoxine: safe throughout pregnancy.",
"Breastfeeding: Safe while on anti-TB treatment; continue therapy.",
])
story.append(h2p("12.3 TB in Renal Failure"))
story += bull([
"INH and RIF are hepatically metabolised — conventional dosing used.",
"EMB and PZA: reduce frequency (daily → 3×/week) in CrCl <30 mL/min.",
"Administer post-dialysis for patients on haemodialysis.",
"Monitor EMB toxicity (optic neuritis) closely.",
])
story.append(h2p("12.4 TB in Children"))
story += bull([
"Children are more prone to primary progressive TB and dissemination (miliary TB, TB meningitis).",
"Diagnosis is more difficult: sputum rarely obtainable; use gastric lavage or induced sputum.",
"TST and CXR are key diagnostic tools in children.",
"BCG vaccination is highly effective against childhood TB meningitis.",
"Treatment: Same HRZE regimen with weight-adjusted dosing.",
])
story.append(PageBreak())
# ─────────────────────────────────────────────────────────────────────────────
# 13. REFERENCES
# ─────────────────────────────────────────────────────────────────────────────
story.append(h1p("13. REFERENCES"))
refs = [
"Murray & Nadel's Textbook of Respiratory Medicine, 7th Edition (Elsevier, 2022) — Chapters 52 & 54.",
"Fishman's Pulmonary Diseases and Disorders, 6th Edition (McGraw-Hill, 2023).",
"Park's Textbook of Preventive and Social Medicine, 25th Edition (M/s Banarasidas Bhanot, 2021).",
"Textbook of Family Medicine, 9th Edition (Elsevier, 2016).",
"Goodman & Gilman's The Pharmacological Basis of Therapeutics, 14th Edition (McGraw-Hill, 2023).",
"WHO Global Tuberculosis Report 2023. World Health Organization, Geneva.",
"WHO Consolidated Guidelines on Tuberculosis — Module 4: Treatment (2022).",
"ATS/CDC/IDSA: Official American Thoracic Society/CDC/IDSA Clinical Practice Guidelines: Treatment of Drug-Susceptible Tuberculosis. CID 2016;63(7):e147–e195.",
"National TB Elimination Programme (NTEP) — India. Ministry of Health & Family Welfare, Govt. of India. www.ntep.in",
"Rajagopalan S, Yoshikawa TT. Tuberculosis in the elderly. Z Gerontol Geriatr. 2000;33(5):374–380.",
]
for i, ref in enumerate(refs, 1):
story.append(Paragraph(f"{i}. {ref}", ref_style))
story.append(Spacer(1, 0.5*cm))
story.append(hr())
story.append(Paragraph(
"This assignment was prepared for academic purposes. Content is based on standard medical textbooks and WHO guidelines (2022–2023).",
ParagraphStyle("Footer", parent=base["Normal"], fontSize=8, textColor=GREY, alignment=TA_CENTER)
))
# ── Build ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF saved to: {OUTPUT}")
cd /home/daytona/workspace/tb-assignment && python generate_tb_pdf.py 2>&1
cd /home/daytona/workspace/tb-assignment && python -c " content = open('generate…
cd /home/daytona/workspace/tb-assignment && python generate_tb_pdf.py 2>&1
cd /home/daytona/workspace/tb-assignment && python -c " import ast, sys with ope…
cd /home/daytona/workspace/tb-assignment && python -c " with open('generate_tb_p…
cd /home/daytona/workspace/tb-assignment && python -c " with open('generate_tb_p…
cd /home/daytona/workspace/tb-assignment && python -c " with open('generate_tb_p…
Download the Tuberculosis assignment PDF from the workspace folder once generated
ls /home/daytona/workspace/tb-assignment/ && python /home/daytona/workspace/tb-a…
ls -lh /home/daytona/workspace/tb-assignment/Tuberculosis_Assignment.pdf
Tuberculosis Assignment
PDF Document · PDF
| Section | Content |
|---|---|
| 1 | Introduction & Definition |
| 2 | Epidemiology (Global + India) |
| 3 | Etiology & Microbiology (M. tuberculosis, cell wall, virulence factors) |
| 4 | Classification (anatomical, WHO treatment categories) |
| 5 | Pathogenesis (Ghon complex, granuloma, latency, reactivation) |
| 6 | Clinical Features (pulmonary + all extrapulmonary sites) |
| 7 | Investigations & Diagnosis (ZN smear, culture, GeneXpert, TST, IGRA, ADA) |
| 8 | Treatment (DOTS, RIPE regimen, drug table with mechanisms & side effects) |
| 9 | MDR-TB / XDR-TB (definitions + WHO 2022 BPaL regimen) |
| 10 | Complications |
| 11 | Prevention & Control (BCG, DOTS, NTEP/RNTCP India, Nikshay) |
| 12 | Special Situations (HIV, Pregnancy, Renal failure, Children) |
| 13 | References (Murray & Nadel, Park's, WHO guidelines, NTEP) |
Generate a quick reference PDF cheat sheet for TB diagnosis/treatment
~/tb-assignment/generate_cheatsheet.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, FrameBreak, Frame, PageTemplate, BaseDocTemplate
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import KeepTogether
OUTPUT = "/home/daytona/workspace/tb-assignment/TB_Cheatsheet.pdf"
W, H = A4 # 595 x 842 pts
MARGIN = 0.7 * cm
# ── Colours ───────────────────────────────────────────────────────────────────
C_RED = colors.HexColor("#B71C1C")
C_DRED = colors.HexColor("#7B0000")
C_ORANGE = colors.HexColor("#E65100")
C_GREEN = colors.HexColor("#1B5E20")
C_BLUE = colors.HexColor("#0D47A1")
C_PURPLE = colors.HexColor("#4A148C")
C_TEAL = colors.HexColor("#004D40")
C_BGRED = colors.HexColor("#FFEBEE")
C_BGORANGE= colors.HexColor("#FFF3E0")
C_BGGREEN = colors.HexColor("#E8F5E9")
C_BGBLUE = colors.HexColor("#E3F2FD")
C_BGPURPLE= colors.HexColor("#F3E5F5")
C_BGTEAL = colors.HexColor("#E0F2F1")
C_YELLOW = colors.HexColor("#F57F17")
C_BGYELLOW= colors.HexColor("#FFFDE7")
C_GREY = colors.HexColor("#424242")
C_LGREY = colors.HexColor("#F5F5F5")
C_ALTROW = colors.HexColor("#FFCDD2")
WHITE = colors.white
BLACK = colors.black
# ── Two-column layout ─────────────────────────────────────────────────────────
col_w = (W - 2*MARGIN - 0.3*cm) / 2
col_h = H - 2*MARGIN - 1.2*cm # leave room for header strip
frame_left = Frame(MARGIN, MARGIN, col_w, col_h, leftPadding=2, rightPadding=4, topPadding=2, bottomPadding=2, id='left')
frame_right = Frame(MARGIN+col_w+0.3*cm, MARGIN, col_w, col_h, leftPadding=4, rightPadding=2, topPadding=2, bottomPadding=2, id='right')
# ── Header drawn on every page ────────────────────────────────────────────────
def draw_header(canvas, doc):
canvas.saveState()
# Top banner
canvas.setFillColor(C_DRED)
canvas.rect(0, H - 1.1*cm, W, 1.1*cm, fill=1, stroke=0)
canvas.setFillColor(WHITE)
canvas.setFont("Helvetica-Bold", 14)
canvas.drawCentredString(W/2, H - 0.75*cm, "TUBERCULOSIS | QUICK REFERENCE CHEAT SHEET")
canvas.setFont("Helvetica", 8)
canvas.drawRightString(W - MARGIN, H - 0.92*cm, "Murray & Nadel | Park's | WHO 2022")
# Bottom strip
canvas.setFillColor(C_DRED)
canvas.rect(0, 0, W, 0.45*cm, fill=1, stroke=0)
canvas.setFillColor(WHITE)
canvas.setFont("Helvetica", 7)
canvas.drawCentredString(W/2, 0.12*cm, "For educational/academic use only | MBBS Quick Reference")
canvas.restoreState()
doc = BaseDocTemplate(OUTPUT, pagesize=A4,
leftMargin=MARGIN, rightMargin=MARGIN,
topMargin=MARGIN + 1.15*cm, bottomMargin=MARGIN + 0.45*cm)
pt = PageTemplate(id='TwoCol', frames=[frame_left, frame_right], onPage=draw_header)
doc.addPageTemplates([pt])
# ── Style helpers ─────────────────────────────────────────────────────────────
base = getSampleStyleSheet()
def sec_head(text, bg=C_RED, fg=WHITE):
"""Section title bar."""
s = ParagraphStyle("SH", fontSize=8, fontName="Helvetica-Bold",
textColor=fg, backColor=bg,
borderPadding=(3,5,3,5), leading=11, spaceAfter=3, spaceBefore=5)
return Paragraph(text.upper(), s)
def sub_head(text, color=C_DRED):
s = ParagraphStyle("sub", fontSize=7.5, fontName="Helvetica-Bold",
textColor=color, leading=10, spaceBefore=4, spaceAfter=2)
return Paragraph(text, s)
def body(text, size=7):
s = ParagraphStyle("bd", fontSize=size, fontName="Helvetica",
textColor=BLACK, leading=9.5, spaceAfter=1)
return Paragraph(text, s)
def bull(text, color=C_DRED):
s = ParagraphStyle("bu", fontSize=7, fontName="Helvetica",
textColor=BLACK, leading=9, leftIndent=8, spaceAfter=1)
return Paragraph(f'<font color="{color.hexval()}"><b>•</b></font> {text}', s)
def note(text, bg=C_BGYELLOW, border=C_YELLOW):
s = ParagraphStyle("nt", fontSize=6.8, fontName="Helvetica-Oblique",
textColor=C_GREY, backColor=bg,
borderPadding=(2,4,2,4), leading=9, spaceAfter=3, spaceBefore=2)
return Paragraph(text, s)
def mini_table(headers, rows, col_widths, hbg=C_RED, altbg=C_BGRED):
th_s = ParagraphStyle("TH", fontSize=6.5, fontName="Helvetica-Bold",
textColor=WHITE, leading=9)
td_s = ParagraphStyle("TD", fontSize=6.5, fontName="Helvetica",
textColor=BLACK, leading=9)
data = [[Paragraph(h, th_s) for h in headers]]
for row in rows:
data.append([Paragraph(str(c), td_s) for c in row])
st = TableStyle([
("BACKGROUND", (0,0), (-1,0), hbg),
("ROWBACKGROUNDS",(0,1), (-1,-1), [WHITE, altbg]),
("GRID", (0,0), (-1,-1), 0.3, hbg),
("VALIGN", (0,0), (-1,-1), "TOP"),
("TOPPADDING", (0,0), (-1,-1), 2),
("BOTTOMPADDING", (0,0), (-1,-1), 2),
("LEFTPADDING", (0,0), (-1,-1), 3),
("RIGHTPADDING", (0,0), (-1,-1), 3),
])
return Table(data, colWidths=col_widths, style=st, hAlign="LEFT", repeatRows=1)
def hr(color=C_RED):
return HRFlowable(width="100%", thickness=0.5, color=color, spaceAfter=2, spaceBefore=2)
def sp(h=0.15):
return Spacer(1, h*cm)
# ═══════════════════════════════════════════════════════════════════════════════
# STORY
# ═══════════════════════════════════════════════════════════════════════════════
story = []
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# LEFT COLUMN
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# 1. KEY FACTS BOX
story.append(sec_head("Key Facts at a Glance", C_DRED))
kf_data = [
["Pathogen", "<i>Mycobacterium tuberculosis</i> (MTBC)"],
["Discovered", "Robert Koch, 1882"],
["Transmission", "Airborne droplet nuclei (1-5 um)"],
["Global burden", "~10.6 million new cases/year"],
["India burden", "~26% of global cases (#1 worldwide)"],
["Mortality", "~1.6 million deaths/year (WHO 2022)"],
["Latency rate", "90-95% infected persons remain latent"],
["Reactivation", "5-10% LTBI reactivate in lifetime"],
["HIV risk", "18x increased risk in HIV+ persons"],
]
kf_table = Table(
[[Paragraph(f"<b>{r[0]}</b>",
ParagraphStyle("kk",fontSize=6.5,fontName="Helvetica-Bold",textColor=C_DRED,leading=9)),
Paragraph(r[1],
ParagraphStyle("kv",fontSize=6.5,fontName="Helvetica",textColor=BLACK,leading=9))]
for r in kf_data],
colWidths=[2.2*cm, col_w-2.5*cm],
style=TableStyle([
("ROWBACKGROUNDS",(0,0),(-1,-1),[C_BGRED, WHITE]),
("GRID",(0,0),(-1,-1),0.3,C_RED),
("TOPPADDING",(0,0),(-1,-1),2),("BOTTOMPADDING",(0,0),(-1,-1),2),
("LEFTPADDING",(0,0),(-1,-1),3),("RIGHTPADDING",(0,0),(-1,-1),3),
]))
story.append(kf_table)
story.append(sp(0.15))
# 2. CLASSIFICATION
story.append(sec_head("Classification", C_BLUE))
story.append(sub_head("By site:", C_BLUE))
story.append(bull("<b>Pulmonary TB</b> - 80-85% of cases"))
story.append(bull("<b>Extrapulmonary TB</b> - 15-20% (pleural, lymph node, meningeal, bone, renal, pericardial)"))
story.append(bull("<b>Miliary/Disseminated TB</b> - haematogenous spread"))
story.append(sub_head("By disease status:", C_BLUE))
cls_rows = [
["LTBI","TST/IGRA +ve; no symptoms; NOT infectious; 5-10% reactivate"],
["Primary TB","1st infection; lower/mid zones; Ghon complex"],
["Reactivation TB","Upper lobe cavitary; high infectivity; endogenous reactivation"],
]
story.append(mini_table(["Type","Features"], cls_rows, [1.5*cm, col_w-1.8*cm], C_BLUE, C_BGBLUE))
story.append(sp(0.1))
story.append(sub_head("WHO Treatment Categories:", C_BLUE))
who_rows = [
["New","Never treated / <1 month"],
["Relapse","Previously cured; now bacteriologically +ve again"],
["Tx after failure","Previously treated; outcome = failure"],
["LTFU","Previously treated; lost to follow-up"],
]
story.append(mini_table(["Category","Definition"], who_rows, [2*cm, col_w-2.3*cm], C_BLUE, C_BGBLUE))
story.append(sp(0.1))
# 3. PATHOGENESIS FLOWCHART (as table)
story.append(sec_head("Pathogenesis - Step by Step", C_TEAL))
path_steps = [
["1","Inhalation","Droplet nuclei (1-5 um) reach alveoli (lower lobes)"],
["2","Macrophage uptake","Alveolar macrophages phagocytose bacilli"],
["3","Intracellular survival","ESX-3 blocks phagosome maturation; sulfatides inhibit phagolysosome fusion; ESAT-6 perforates membrane"],
["4","Lymphatic spread","Bacilli drain to hilar nodes -> Ghon complex (focus + node)"],
["5","Innate response","Neutrophils, NK cells; TNF-alpha, IL-12, IFN-gamma released"],
["6","Adaptive CMI","CD4+ Th1 cells (essential!); granuloma formation (2-8 wks)"],
["7","Granuloma","Caseous necrosis + epithelioid macrophages + Langhans giant cells + lymphocytes"],
["8a","LTBI (90-95%)","Bacteria contained in dormant state; TST/IGRA +ve"],
["8b","Active TB (5-10%)","Progressive disease; immunocompromised/children/HIV"],
["9","Reactivation","Upper lobes (high O2); cavitation; high bacillary load"],
]
story.append(mini_table(["#","Stage","Key Events"], path_steps,
[0.4*cm, 1.8*cm, col_w-2.5*cm], C_TEAL, C_BGTEAL))
# FRAME BREAK - switch to right column
story.append(FrameBreak())
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# RIGHT COLUMN
# ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
# 4. DIAGNOSIS ALGORITHM
story.append(sec_head("Diagnosis Algorithm", C_ORANGE))
story.append(sub_head("Step 1 - Clinical Suspicion:", C_ORANGE))
story.append(bull("Cough >2 weeks + any of: fever, night sweats, weight loss, hemoptysis"))
story.append(bull("High-risk: HIV+, DM, malnourished, close contact with TB case"))
story.append(sub_head("Step 2 - Sputum Tests (Pulmonary TB):", C_ORANGE))
dx_rows = [
["ZN Smear","Spot + Morning sample; AFB = pink rods on blue; Sens 45-80%; Spec 98%; CHEAP & FAST","1st line"],
["Fluorescence","Auramine-rhodamine; faster screening; higher sensitivity","1st line"],
["GeneXpert MTB/RIF","Detects MTB DNA + Rifampicin resistance; 2 hrs; Sens 89%, Spec 99%; WHO recommended","1st line"],
["Culture (LJ/MGIT)","Gold standard; 3-8 wks (LJ) / 1-3 wks (MGIT); DST possible","Confirmatory"],
["LPA (Line Probe)","Detects INH + RIF resistance; for MDR-TB diagnosis","MDR workup"],
]
story.append(mini_table(["Test","Details","Use"], dx_rows,
[1.8*cm, col_w-3.5*cm, 1.4*cm], C_ORANGE, C_BGORANGE))
story.append(sub_head("Step 3 - Immunological Tests:", C_ORANGE))
imm_rows = [
["Mantoux TST","5 TU PPD intradermal; read at 48-72h; measure induration (not redness)","BCG affects result"],
["IGRA (QFT/T-SPOT)","IFN-gamma response to ESAT-6 & CFP-10; blood test; unaffected by BCG","Preferred for LTBI"],
]
story.append(mini_table(["Test","Method","Advantage"], imm_rows,
[1.8*cm, col_w-3.6*cm, 1.5*cm], C_ORANGE, C_BGORANGE))
story.append(sub_head("TST Interpretation Cutoffs:", C_ORANGE))
tst_rows = [
[">=5 mm","HIV+; recent TB contact; immunosuppressed; organ transplant"],
[">=10 mm","General population; high-endemic country; healthcare worker; DM; CKD"],
[">=15 mm","No known risk factors"],
]
story.append(mini_table(["Induration","Positive if..."], tst_rows,
[1.3*cm, col_w-1.6*cm], C_ORANGE, C_BGORANGE))
story.append(sub_head("Key Fluid Tests (Extrapulmonary TB):", C_ORANGE))
story.append(bull("<b>Pleural fluid</b>: Exudate; lymphocytes dominant; ADA >40 IU/L (highly suggestive); protein >3g/dL; low glucose"))
story.append(bull("<b>CSF (TB meningitis)</b>: Clear/xanthochromic; lymphocytes; glucose LOW; protein HIGH; AFB smear/GeneXpert"))
story.append(bull("<b>ADA (Adenosine Deaminase)</b>: Elevated in pleural, CSF, ascitic fluid -- key TB marker"))
story.append(sp(0.1))
# 5. TREATMENT SECTION
story.append(sec_head("Treatment - Drug-Susceptible TB (DOTS)", C_GREEN))
story.append(note("DOTS = Directly Observed Treatment Short-course | Daily > Intermittent (ATS/CDC/IDSA 2022)"))
story.append(sub_head("Standard 6-Month Regimen (2HRZE + 4HR):", C_GREEN))
reg_rows = [
["Intensive\n2 months","H+R+Z+E (HRZE)\nAll 4 drugs DAILY","Rapidly kill replicating bacilli\nReduce infectivity within 2 weeks"],
["Continuation\n4 months","H+R (HR)\nBoth drugs DAILY","Eliminate dormant bacilli\nPrevent relapse"],
]
story.append(mini_table(["Phase","Drugs","Purpose"], reg_rows,
[1.6*cm, 2.5*cm, col_w-4.4*cm], C_GREEN, C_BGGREEN))
story.append(note("TB Meningitis / Bone-Joint TB: extend continuation to 7-10 months (total 9-12 months) | Add Pyridoxine 25-50mg/day with INH"))
story.append(sub_head("First-Line Drug Summary (RIPE):", C_GREEN))
drug_rows = [
["H - Isoniazid","Inhibits mycolic acid synthesis (InhA)","Hepatotoxicity, Peripheral neuropathy*","5 mg/kg/day (max 300mg)"],
["R - Rifampicin","Inhibits RNA polymerase (beta-subunit)","Hepatotox; Orange body fluids; CYP450 inducer","10 mg/kg/day (max 600mg)"],
["Z - Pyrazinamide","Active at acidic pH; kills intracellular/dormant bacilli","Hepatotox; Hyperuricaemia; Arthralgia","25 mg/kg/day"],
["E - Ethambutol","Inhibits arabinosyl transferase (cell wall)","Optic neuritis** (check vision monthly)","15-25 mg/kg/day"],
["S - Streptomycin","30S ribosome inhibitor; bactericidal","Ototoxicity; Nephrotoxicity; AVOID in pregnancy","15 mg/kg IM/day"],
]
story.append(mini_table(["Drug","Mechanism","Key Side Effect","Dose"],
drug_rows,
[2.3*cm, 2.5*cm, 2.5*cm, col_w-7.6*cm], C_GREEN, C_BGGREEN))
story.append(note("*Give Pyridoxine (Vit B6) 25-50mg with INH to prevent neuropathy | **Monitor visual acuity & colour vision on EMB"))
story.append(sub_head("MDR-TB / XDR-TB:", C_PURPLE))
mdr_rows = [
["MDR-TB","Resistant to INH + RIF","18-24 months; BPaL/BPaLM regimen"],
["Pre-XDR TB","MDR + fluoroquinolone resistance","WHO Group A drugs priority"],
["XDR-TB","MDR + fluroquinolone + bedaquiline or linezolid resistance","Highly specialist centre"],
]
story.append(mini_table(["Type","Definition","Treatment"],
mdr_rows, [1.5*cm, 2.8*cm, col_w-4.6*cm], C_PURPLE, C_BGPURPLE))
story.append(note("MDR-TB is MAN-MADE: caused by irregular/incomplete treatment, poor drugs, monotherapy, poor adherence"))
story.append(sub_head("WHO Drug Groups for MDR-TB:", C_PURPLE))
story.append(bull("<b>Group A (use all 3):</b> Levofloxacin/Moxifloxacin, Bedaquiline, Linezolid"))
story.append(bull("<b>Group B (add 1-2):</b> Clofazimine, Cycloserine"))
story.append(bull("<b>Group C (add to complete):</b> EMB, Delamanid, PZA, Imipenem, Amikacin"))
# Special situations compact box
story.append(sp(0.1))
story.append(sec_head("Special Situations - Quick Notes", C_DRED))
sp_rows = [
["HIV+","Same 6-month regimen; start ART within 2 wks (CD4<50) or 8 wks; IRIS possible; use Rifabutin if on PIs"],
["Pregnancy","HRZE safe; STREPTOMYCIN CONTRAINDICATED (fetal ototoxicity); Pyridoxine essential"],
["Renal failure","INH+RIF: normal dose; EMB+PZA: reduce to 3x/week if CrCl<30; give post-dialysis"],
["Hepatic disease","Avoid PZA if ALT>3xULN; use 9-month INH+RIF+EMB regimen"],
["Children","Gastric lavage/induced sputum for diagnosis; weight-adjusted dosing; BCG very protective"],
["Steroid use","Add steroids in TB meningitis (Dexamethasone) & pericarditis"],
]
story.append(mini_table(["Situation","Key Points"], sp_rows,
[1.8*cm, col_w-2.1*cm], C_DRED, C_BGRED))
# Prevention strip
story.append(sp(0.1))
story.append(sec_head("Prevention & Control", C_TEAL))
story.append(bull("<b>BCG vaccine:</b> Live attenuated M. bovis; intradermal; at birth (India); 80% protective vs childhood TB meningitis & miliary TB"))
story.append(bull("<b>DOTS:</b> Directly observed every dose; cornerstone of TB control worldwide"))
story.append(bull("<b>NTEP/India:</b> Goal - eliminate TB by 2025; GeneXpert for ALL; Nikshay portal; Rs 500/month Nikshay Poshan Yojana"))
story.append(bull("<b>LTBI treatment:</b> INH x 6 months (6H) OR Rifapentine+INH x 12 weeks (3HP) for high-risk contacts"))
story.append(bull("<b>Infection control:</b> N-95 masks; UV germicidal irradiation; adequate ventilation"))
# ── Build ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"Cheat sheet saved to: {OUTPUT}")
cd /home/daytona/workspace/tb-assignment && python generate_cheatsheet.py 2>&1
ls -lh /home/daytona/workspace/tb-assignment/TB_Cheatsheet.pdf
TB Cheatsheet
PDF Document · PDF