~/covid19-study-guide/generate_pdf.py
#!/usr/bin/env python3
"""
COVID-19 MBBS Study Guide PDF Generator
Uses ReportLab for a professional, exam-ready study guide.
"""
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm, mm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, PageBreak, KeepTogether
)
from reportlab.platypus.flowables import HRFlowable
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
import os
OUTPUT_PATH = "/home/daytona/workspace/covid19-study-guide/COVID19_MBBS_Study_Guide.pdf"
# ── Colour palette ─────────────────────────────────────────────────────────────
DEEP_BLUE = colors.HexColor("#1a3a5c")
MID_BLUE = colors.HexColor("#2563A8")
ACCENT_TEAL = colors.HexColor("#0e7490")
LIGHT_BLUE = colors.HexColor("#dbeafe")
LIGHT_TEAL = colors.HexColor("#e0f7fa")
YELLOW_HL = colors.HexColor("#fef9c3")
RED_WARN = colors.HexColor("#dc2626")
RED_LIGHT = colors.HexColor("#fee2e2")
GREEN_OK = colors.HexColor("#166534")
GREEN_LIGHT = colors.HexColor("#dcfce7")
ORANGE = colors.HexColor("#ea580c")
ORANGE_LIGHT= colors.HexColor("#fff7ed")
GREY_BG = colors.HexColor("#f1f5f9")
DARK_TEXT = colors.HexColor("#1e293b")
WHITE = colors.white
TABLE_HEADER= colors.HexColor("#1e40af")
# ── Page template ──────────────────────────────────────────────────────────────
def add_page_number(canvas, doc):
canvas.saveState()
# Header bar
canvas.setFillColor(DEEP_BLUE)
canvas.rect(0, A4[1] - 1.4*cm, A4[0], 1.4*cm, fill=1, stroke=0)
canvas.setFillColor(WHITE)
canvas.setFont("Helvetica-Bold", 9)
canvas.drawString(1*cm, A4[1] - 0.9*cm, "COVID-19 (SARS-CoV-2)")
canvas.drawRightString(A4[0] - 1*cm, A4[1] - 0.9*cm, "2nd MBBS Microbiology | Exam Study Guide")
# Footer bar
canvas.setFillColor(DEEP_BLUE)
canvas.rect(0, 0, A4[0], 1.0*cm, fill=1, stroke=0)
canvas.setFillColor(WHITE)
canvas.setFont("Helvetica", 8)
canvas.drawString(1*cm, 0.35*cm, "Based on Apurba Sastri Microbiology | Sherris & Ryan | Goldman-Cecil")
canvas.drawRightString(A4[0] - 1*cm, 0.35*cm, f"Page {doc.page}")
canvas.restoreState()
# ── Style definitions ──────────────────────────────────────────────────────────
styles = getSampleStyleSheet()
def S(name, **kw):
return ParagraphStyle(name, **kw)
COVER_TITLE = S("CoverTitle",
fontSize=32, textColor=WHITE, fontName="Helvetica-Bold",
alignment=TA_CENTER, spaceAfter=6, leading=38)
COVER_SUBTITLE = S("CoverSub",
fontSize=16, textColor=colors.HexColor("#bfdbfe"),
fontName="Helvetica", alignment=TA_CENTER, spaceAfter=4)
COVER_DETAIL = S("CoverDetail",
fontSize=12, textColor=colors.HexColor("#e0f2fe"),
fontName="Helvetica", alignment=TA_CENTER, spaceAfter=3)
H1 = S("H1",
fontSize=16, textColor=WHITE, fontName="Helvetica-Bold",
alignment=TA_LEFT, spaceAfter=2, leading=20,
backColor=MID_BLUE, leftIndent=-0.5*cm, borderPad=6)
H2 = S("H2",
fontSize=13, textColor=DEEP_BLUE, fontName="Helvetica-Bold",
spaceBefore=10, spaceAfter=4, borderPadding=(0, 0, 2, 0))
H3 = S("H3",
fontSize=11, textColor=ACCENT_TEAL, fontName="Helvetica-Bold",
spaceBefore=6, spaceAfter=3)
BODY = S("Body",
fontSize=9.5, textColor=DARK_TEXT, fontName="Helvetica",
leading=14, spaceAfter=4, alignment=TA_JUSTIFY)
BULLET = S("Bullet",
fontSize=9.5, textColor=DARK_TEXT, fontName="Helvetica",
leading=13, spaceAfter=2, leftIndent=14, bulletIndent=0,
bulletText="•")
SUBBULLET = S("SubBullet",
fontSize=9, textColor=DARK_TEXT, fontName="Helvetica",
leading=12, spaceAfter=1, leftIndent=28, bulletIndent=14,
bulletText="–")
BOLD_BODY = S("BoldBody",
fontSize=9.5, textColor=DARK_TEXT, fontName="Helvetica-Bold",
leading=14, spaceAfter=2)
EXAM_TIP = S("ExamTip",
fontSize=9, textColor=colors.HexColor("#7c2d12"),
fontName="Helvetica-BoldOblique",
backColor=ORANGE_LIGHT, leftIndent=8, rightIndent=8,
borderPad=5, spaceBefore=4, spaceAfter=4, leading=13)
WARN = S("Warn",
fontSize=9, textColor=RED_WARN, fontName="Helvetica-Bold",
backColor=RED_LIGHT, leftIndent=8, rightIndent=8,
borderPad=4, spaceBefore=3, spaceAfter=3, leading=13)
MNEMONIC = S("Mnemonic",
fontSize=10, textColor=GREEN_OK, fontName="Helvetica-Bold",
backColor=GREEN_LIGHT, leftIndent=8, rightIndent=8,
borderPad=6, spaceBefore=4, spaceAfter=4, leading=15, alignment=TA_CENTER)
NOTE = S("Note",
fontSize=8.5, textColor=colors.HexColor("#374151"),
fontName="Helvetica-Oblique", leading=12, spaceAfter=3,
leftIndent=10)
# ── Helper: section header ──────────────────────────────────────────────────────
def section_header(num, title, color=MID_BLUE):
tbl = Table(
[[f" {num}. {title} "]],
colWidths=[17.6*cm]
)
tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), color),
("TEXTCOLOR", (0,0), (-1,-1), WHITE),
("FONTNAME", (0,0), (-1,-1), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 13),
("TOPPADDING", (0,0), (-1,-1), 7),
("BOTTOMPADDING",(0,0),(-1,-1), 7),
("LEFTPADDING", (0,0), (-1,-1), 8),
("ROWBACKGROUNDS", (0,0), (-1,-1), [color]),
]))
return tbl
def sub_header(title, color=ACCENT_TEAL):
tbl = Table([[f" {title} "]], colWidths=[17.6*cm])
tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), color),
("TEXTCOLOR", (0,0), (-1,-1), WHITE),
("FONTNAME", (0,0), (-1,-1), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 11),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING",(0,0),(-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 8),
]))
return tbl
def make_table(headers, rows, col_widths=None, header_color=TABLE_HEADER, alt_color=LIGHT_BLUE):
data = [headers] + rows
tbl = Table(data, colWidths=col_widths)
style = [
("BACKGROUND", (0,0), (-1,0), header_color),
("TEXTCOLOR", (0,0), (-1,0), WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 8.5),
("FONTNAME", (0,1), (-1,-1), "Helvetica"),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#cbd5e1")),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 5),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("ROWBACKGROUNDS",(0,1),(-1,-1),[WHITE, alt_color]),
]
tbl.setStyle(TableStyle(style))
return tbl
def box_table(content_rows, bg=LIGHT_BLUE, border=MID_BLUE):
tbl = Table(content_rows, colWidths=[17.6*cm])
tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("BOX", (0,0), (-1,-1), 1.2, border),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 10),
("FONTNAME", (0,0), (-1,-1), "Helvetica"),
("FONTSIZE", (0,0), (-1,-1), 9),
]))
return tbl
def hr(color=MID_BLUE, thickness=0.8):
return HRFlowable(width="100%", thickness=thickness, color=color, spaceAfter=4, spaceBefore=4)
def sp(h=0.2):
return Spacer(1, h*cm)
def P(text, style=BODY):
return Paragraph(text, style)
def B(text):
return Paragraph(text, BULLET)
def SB(text):
return Paragraph(text, SUBBULLET)
# ═══════════════════════════════════════════════════════════════════════════════
# BUILD DOCUMENT
# ═══════════════════════════════════════════════════════════════════════════════
def build():
doc = SimpleDocTemplate(
OUTPUT_PATH,
pagesize=A4,
topMargin=1.8*cm,
bottomMargin=1.4*cm,
leftMargin=1.5*cm,
rightMargin=1.5*cm,
title="COVID-19 MBBS Study Guide",
author="Orris AI | Medical Education",
)
story = []
# ──────────────────────────────────────────────────────────────────────────
# COVER PAGE
# ──────────────────────────────────────────────────────────────────────────
# Blue gradient cover block via table
cover_data = [
[Paragraph("COVID-19", S("ct", fontSize=42, textColor=WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER, leading=48))],
[Paragraph("SARS-CoV-2", S("cs", fontSize=22, textColor=colors.HexColor("#93c5fd"),
fontName="Helvetica-Bold", alignment=TA_CENTER))],
[Spacer(1, 0.3*cm)],
[Paragraph("Comprehensive MBBS Exam Study Guide", S("x1", fontSize=16,
textColor=colors.HexColor("#e0f2fe"), fontName="Helvetica",
alignment=TA_CENTER))],
[Paragraph("2nd Year | Microbiology", S("x2", fontSize=13,
textColor=colors.HexColor("#bfdbfe"), fontName="Helvetica",
alignment=TA_CENTER))],
[Spacer(1, 0.5*cm)],
[Paragraph("Definition · Morphology · Virulence Factors · Pathogenesis<br/>"
"Clinical Manifestations · Complications · Lab Diagnosis · Treatment",
S("x3", fontSize=10, textColor=colors.HexColor("#cbd5e1"),
fontName="Helvetica-Oblique", alignment=TA_CENTER, leading=16))],
[Spacer(1, 0.6*cm)],
[Paragraph("Reference: Apurba Sastri Microbiology | Sherris & Ryan 8e | Goldman-Cecil Medicine",
S("x4", fontSize=9, textColor=colors.HexColor("#94a3b8"),
fontName="Helvetica", alignment=TA_CENTER))],
]
cover = Table(cover_data, colWidths=[17.6*cm])
cover.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), DEEP_BLUE),
("TOPPADDING", (0,0), (-1,-1), 8),
("BOTTOMPADDING",(0,0), (-1,-1), 8),
("LEFTPADDING", (0,0), (-1,-1), 20),
("RIGHTPADDING", (0,0), (-1,-1), 20),
("BOX", (0,0), (-1,-1), 2, MID_BLUE),
]))
story += [sp(1.5), cover, sp(0.8)]
# Quick-ref badge
badge = make_table(
["📌 EXAM QUICK REFERENCE", "", "", ""],
[
["Agent", "SARS-CoV-2 (Beta-coronavirus)", "Gold Std Diagnosis", "RT-PCR (NP swab)"],
["Genome", "+ve sense ssRNA (~30 kb)", "Key Receptor", "ACE2 + TMPRSS2"],
["Size", "80–160 nm; Enveloped", "Incubation", "2–14 days (avg 5 days)"],
["Key Symptoms", "Fever, Dry cough, Anosmia, Ageusia", "Treatment", "Remdesivir + Dexamethasone"],
["Worst Complication", "ARDS / Cytokine Storm / DIC", "Pediatric Complication", "MIS-C (Kawasaki-like)"],
],
col_widths=[3.5*cm, 5.3*cm, 4.3*cm, 4.5*cm],
header_color=DEEP_BLUE
)
story += [badge, PageBreak()]
# ──────────────────────────────────────────────────────────────────────────
# SECTION 1 — DEFINITION
# ──────────────────────────────────────────────────────────────────────────
story += [section_header("1", "DEFINITION"), sp(0.2),
P("<b>COVID-19</b> (Coronavirus Disease-2019) is an <b>acute infectious respiratory illness</b> caused by "
"<b>SARS-CoV-2</b> (Severe Acute Respiratory Syndrome Coronavirus-2), a novel <b>beta-coronavirus</b> "
"that emerged in Wuhan, Hubei Province, China in <b>December 2019</b>."),
sp(0.1),
P("It was declared a <b>global pandemic by WHO on March 11, 2020</b>. The disease ranges from mild "
"flu-like illness to severe pneumonia, ARDS, and multi-organ dysfunction syndrome (MODS)."),
sp(0.2),
make_table(
["Feature", "Detail"],
[
["Disease name", "Coronavirus Disease-2019 (COVID-19)"],
["Causative agent", "SARS-CoV-2 (Severe Acute Respiratory Syndrome Coronavirus-2)"],
["Family / Genus", "Coronaviridae / Betacoronavirus"],
["Pandemic declared", "WHO — March 11, 2020"],
["Origin", "Wuhan, Hubei Province, China (December 2019)"],
["Global cases (Oct 2023)", "~770 million confirmed cases; ~6.9 million deaths"],
],
col_widths=[5*cm, 12.6*cm]
),
sp(0.3)]
# ──────────────────────────────────────────────────────────────────────────
# SECTION 2 — MORPHOLOGY
# ──────────────────────────────────────────────────────────────────────────
story += [section_header("2", "MORPHOLOGY OF SARS-CoV-2"), sp(0.2),
sub_header("2A. Basic Virion Properties"), sp(0.1),
make_table(
["Property", "Description"],
[
["Type", "Enveloped, positive-sense single-stranded RNA virus (+ssRNA)"],
["Size", "80–160 nm (one of the largest RNA viruses)"],
["Shape", "Roughly spherical/pleomorphic with crown-like spike projections"],
["Genome", "~30 kb — largest RNA genome of any known virus"],
["Capsid symmetry", "Helical nucleocapsid"],
["Envelope", "Lipid bilayer envelope derived from ER-Golgi membranes"],
["Replication site", "Cytoplasm"],
["Replication enzyme", "RNA-dependent RNA Polymerase (RdRp) — viral-encoded"],
],
col_widths=[4.5*cm, 13.1*cm]
),
sp(0.25),
sub_header("2B. Structural Proteins (4 Major)"), sp(0.1),
make_table(
["Protein", "Location", "Function / Significance"],
[
["Spike (S) Glycoprotein",
"Surface — club/petal projections",
"Binds ACE2 receptor (S1 = RBD); S2 = fusion domain; gives corona appearance; primary vaccine target; mutates to form variants"],
["Membrane (M) Glycoprotein",
"Embedded in envelope",
"Most abundant structural protein; maintains envelope shape and integrity; involved in budding"],
["Envelope (E) Glycoprotein\n(Small Envelope)",
"Embedded in envelope",
"Ion channel (viroporin); essential for viral assembly and release; virulence factor"],
["Nucleocapsid (N) Phosphoprotein",
"Internal — bound to RNA",
"Packages viral RNA into helical nucleocapsid; important diagnostic antigen (detected in rapid antigen tests); involved in immune evasion"],
["Hemagglutinin-Esterase (HE)",
"Surface (some beta-CoV)",
"Aids attachment; less prominent in SARS-CoV-2 vs. other betacoronaviruses"],
],
col_widths=[4*cm, 4.2*cm, 9.4*cm]
),
sp(0.2),
P("🔬 <b>Diagram note:</b> The corona (crown) appearance under electron microscopy is due to the "
"Spike glycoproteins projecting from the lipid envelope like a solar corona or crown of thorns. "
"The name 'Coronavirus' derives from this appearance.", NOTE),
sp(0.2),
sub_header("2C. Replication Cycle Summary"), sp(0.1),
make_table(
["Step", "Event"],
[
["1. Attachment", "Spike S1 RBD binds ACE2 receptor on host cell"],
["2. Priming", "TMPRSS2 (host serine protease) cleaves S1/S2 junction → enables fusion"],
["3. Fusion/Entry", "S2 mediates viral envelope-cell membrane fusion → endocytosis"],
["4. Uncoating", "Viral RNA (+ssRNA) released into cytoplasm"],
["5. Translation", "+ssRNA acts directly as mRNA → polyprotein synthesis → cleavage by proteases"],
["6. Replication", "RdRp synthesizes genomic RNA + subgenomic RNAs"],
["7. Assembly", "Structural proteins + RNA assemble in cytoplasm"],
["8. Budding", "Virus acquires envelope from ER-Golgi membrane; released by exocytosis"],
],
col_widths=[3.5*cm, 14.1*cm]
),
sp(0.3)]
# ──────────────────────────────────────────────────────────────────────────
# SECTION 3 — VIRULENCE FACTORS
# ──────────────────────────────────────────────────────────────────────────
story += [section_header("3", "VIRULENCE FACTORS"), sp(0.2),
make_table(
["Virulence Factor", "Mechanism / Significance"],
[
["Spike (S) Glycoprotein — RBD",
"Binds ACE2 with ~10× higher affinity than SARS-CoV-1. High ACE2 affinity = high infectivity. "
"D614G mutation in RBD increases ACE2 binding affinity → ↑transmissibility"],
["TMPRSS2 Co-receptor",
"Host transmembrane serine protease 2 primes Spike for entry; co-expressed with ACE2 in lung "
"epithelium, gut, kidney → enhances cell-to-cell spread"],
["ACE2 Multi-organ Expression",
"ACE2 present on: lung alveolar cells, heart myocytes, kidney tubular cells, intestinal "
"enterocytes, vascular endothelium, olfactory sustentacular cells → explains multi-organ tropism"],
["IFN-I Antagonism (Immune Evasion)",
"Nonstructural proteins (NSPs) of SARS-CoV-2 antagonize Type I Interferon (IFN-α/β) genes. "
"Very little IFN-1 in serum of severe patients → unchecked viral replication"],
["Exonuclease (ExoN) Proofreading",
"Unique proofreading ability → limits random mutations → allows controlled, selective "
"evolution of adaptive variants (unlike influenza which mutates randomly)"],
["Cytokine Storm Induction",
"Massive dysregulated release of IL-1β, IL-6, IL-8, TNF-α, CCL2, MIP1-α → "
"immunopathological lung injury, vascular permeability, ARDS, DIC"],
["Asymptomatic Transmission",
"~20–40% infections asymptomatic; peak viral shedding at/before symptom onset "
"(unlike SARS-CoV-1 where shedding peaked after symptoms) → facilitates widespread spread"],
["Furin Cleavage Site",
"SARS-CoV-2 has a unique furin cleavage site at S1/S2 junction (absent in SARS-CoV-1) → "
"enhanced entry into broad range of cell types"],
["Variants of Concern (VoC)",
"Mutations in Spike RBD increase transmissibility, pathogenicity, and immune evasion. "
"Delta (India): ↑transmissibility + virulence. Omicron: highest transmissibility, partial immune escape"],
],
col_widths=[5*cm, 12.6*cm]
),
sp(0.3)]
# ──────────────────────────────────────────────────────────────────────────
# SECTION 4 — PATHOGENESIS
# ──────────────────────────────────────────────────────────────────────────
story += [section_header("4", "PATHOGENESIS"), sp(0.2),
sub_header("4A. Step-by-Step Pathogenesis"), sp(0.1)]
steps = [
("STEP 1", "Entry & Upper Respiratory Tract Infection",
"Virus enters via respiratory route → infects nasopharyngeal/oropharyngeal ciliated epithelial cells. "
"Spike S1 RBD binds ACE2. TMPRSS2 cleaves S protein → S2 mediates membrane fusion → "
"viral RNA released into cytoplasm."),
("STEP 2", "Viral Replication (Cytoplasm)",
"+ssRNA translated into polyprotein → cleaved into RdRp, ExoN, and other NSPs. "
"RdRp directs RNA synthesis. Structural proteins (S, M, E, N) synthesized from subgenomic RNAs. "
"Assembly in cytoplasm; budding from ER-Golgi membranes."),
("STEP 3", "Lower Respiratory Spread",
"Virus migrates from upper airways down to alveolar epithelial cells (Type I & II pneumocytes), "
"vascular endothelial cells, alveolar macrophages. Viral load in upper tract peaks early then "
"declines within 7 days."),
("STEP 4", "Innate Immune Evasion",
"NSPs block IFN-I production (anti-IFN strategy). Low IFN-I → unchecked viral replication. "
"Simultaneously, pro-inflammatory cytokines IL-6, IL-1β, TNF-α elevated. This 'decoupling' of "
"antiviral vs. inflammatory response is a key immunopathological mechanism."),
("STEP 5", "Cytokine Storm (Severe Disease)",
"Massive dysregulated immune activation: T lymphocytes, monocytes, neutrophils recruited → "
"apoptosis of infected cells. Cytokine storm: IL-1β, IL-6, IL-8, TNF-α, CCL2, MIP1-α. "
"Older patients show higher lymphocytopenia + neutrophilia + elevated inflammatory markers."),
("STEP 6", "Pulmonary Injury",
"Diffuse Alveolar Damage (DAD): hyaline membrane formation, alveolar flooding with exudates. "
"Endothelial injury → microangiopathy, microthrombosis, aberrant angiogenesis. "
"Pulmonary edema fills alveolar spaces → early-phase ARDS. "
"Lymphocytic myocarditis and pericarditis can also occur."),
("STEP 7", "Systemic Spread & DIC",
"ACE2 expression in heart, kidney, intestine, liver → multi-organ infection. "
"Activated neutrophils/monocytes accumulate in lung, heart, kidney, liver. "
"Elevated D-dimer + prolonged PT → DIC pathway. Hypercoagulable state → thromboembolism."),
]
for code, title, desc in steps:
row_data = [[
Paragraph(f"<b>{code}</b>", S("sc", fontSize=9, textColor=WHITE,
fontName="Helvetica-Bold", alignment=TA_CENTER)),
Paragraph(f"<b>{title}</b><br/><font size='9'>{desc}</font>",
S("sd", fontSize=9, textColor=DARK_TEXT, fontName="Helvetica", leading=13))
]]
t = Table(row_data, colWidths=[2.2*cm, 15.4*cm])
t.setStyle(TableStyle([
("BACKGROUND", (0,0),(0,0), DEEP_BLUE),
("BACKGROUND", (1,0),(1,0), GREY_BG),
("VALIGN", (0,0),(-1,-1), "TOP"),
("TOPPADDING", (0,0),(-1,-1), 5),
("BOTTOMPADDING",(0,0),(-1,-1), 5),
("LEFTPADDING", (0,0),(-1,-1), 6),
("BOX", (0,0),(-1,-1), 0.5, colors.HexColor("#cbd5e1")),
("TEXTCOLOR", (0,0),(0,0), WHITE),
]))
story += [t, sp(0.05)]
story += [sp(0.2),
P("⚡ <b>Key Immunological Concept:</b> Cell-mediated immunity (T cells) controls acute infection "
"and reduces disease severity. Humoral immunity (antibodies) provides longer-lasting protection. "
"Severe disease = high antibody but impaired T cell response.", EXAM_TIP),
sp(0.3)]
# ──────────────────────────────────────────────────────────────────────────
# SECTION 5 — CLINICAL MANIFESTATIONS
# ──────────────────────────────────────────────────────────────────────────
story += [section_header("5", "CLINICAL MANIFESTATIONS & SYMPTOMS"), sp(0.2),
sub_header("5A. Severity Classification"), sp(0.1),
make_table(
["Severity", "Clinical Definition", "% Cases\n(unvaccinated)"],
[
["Asymptomatic", "SARS-CoV-2 detected; no symptoms; still infectious", "~40%"],
["Mild", "Symptoms present; no hypoxia (SpO₂ >94%); no pneumonia", "~40%"],
["Moderate", "Lower respiratory tract disease on imaging; SpO₂ >94%", "~15%"],
["Severe", "SpO₂ <94%; RR >30/min; bilateral infiltrates on imaging", "~15%"],
["Critical", "Respiratory failure + shock + multi-organ dysfunction", "~5%"],
],
col_widths=[3*cm, 11.5*cm, 3.1*cm]
),
sp(0.2),
sub_header("5B. Symptoms — From Common to Severe"), sp(0.1),
make_table(
["Category", "Symptoms"],
[
["Cardinal Triad\n(most common)", "Fever | Dry Cough | Fatigue"],
["Distinctive Features\n(COVID-specific)", "Anosmia (loss of smell) | Ageusia (loss of taste)"],
["General", "Myalgia | Headache | Sore throat | Nasal congestion | Rhinorrhea"],
["Respiratory", "Shortness of breath / Dyspnea | Chest tightness | Low SpO₂"],
["GI Symptoms\n(esp. Omicron)", "Nausea | Vomiting | Diarrhea | Abdominal pain"],
["Neurological", "Confusion | Delirium | Cerebral symptoms (severe disease)"],
["Warning Signs\n(Emergency)", "Severe dyspnea at rest | Persistent chest pain | Cyanosis (bluish lips/face) | SpO₂ <90% | Confusion"],
],
col_widths=[4*cm, 13.6*cm]
),
sp(0.2),
P("🧪 <b>Incubation Period:</b> 2–14 days (average <b>5 days</b>). Viral shedding begins 2–3 days "
"before symptom onset. Peak transmission at or just before symptom onset.", EXAM_TIP),
sp(0.2),
sub_header("5C. Risk Factors for Severe Disease"), sp(0.1),
P("Age >65 years (strongest risk factor) | Obesity | Diabetes | Hypertension | Cardiovascular disease | "
"Chronic lung disease (COPD, asthma) | Chronic kidney disease | Cancer | Immunocompromised states | "
"Sickle cell disease | Transplant recipients | Severe obesity", BODY),
sp(0.3)]
# ──────────────────────────────────────────────────────────────────────────
# SECTION 6 — COMPLICATIONS
# ──────────────────────────────────────────────────────────────────────────
story += [section_header("6", "COMPLICATIONS"), sp(0.2),
sub_header("6A. Suppurative Complications (Infectious / Direct)"), sp(0.1),
P("These arise from direct viral cytopathology, secondary bacterial superinfection, or "
"healthcare-associated infection in hospitalized patients.", BODY),
make_table(
["Complication", "Pathogenesis / Details"],
[
["Secondary Bacterial Pneumonia",
"Most common suppurative complication. Organisms: S. aureus (MRSA), S. pneumoniae, "
"Klebsiella pneumoniae, P. aeruginosa. Occurs in ventilated/ICU patients."],
["Ventilator-Associated Pneumonia (VAP)",
"Complication of mechanical ventilation in critically ill COVID-19 patients. "
"Multi-drug resistant organisms common."],
["Septic Shock",
"Overwhelming bacterial sepsis from secondary superinfection → multi-organ failure. "
"Elevated procalcitonin, fever, hemodynamic instability."],
["Lung Abscess",
"Rare; caused by bacterial superinfection of necrotic COVID-19 lung tissue."],
["Empyema",
"Pus in pleural cavity; rare secondary bacterial complication."],
],
col_widths=[5*cm, 12.6*cm],
header_color=RED_WARN,
alt_color=RED_LIGHT
),
sp(0.2),
sub_header("6B. Non-Suppurative Complications (Immune-Mediated / Systemic)"), sp(0.1),
P("These result from the dysregulated immune response, cytokine storm, hypercoagulable state, "
"or post-infectious immune mechanisms — not direct bacterial infection.", BODY),
make_table(
["System", "Complication", "Mechanism"],
[
["Pulmonary", "ARDS (Acute Respiratory Distress Syndrome)",
"Cytokine storm → diffuse alveolar damage → hyaline membranes, alveolar flooding"],
["Pulmonary", "Pulmonary Embolism / DVT",
"Hypercoagulable state (elevated D-dimer, fibrinogen, factor VIII)"],
["Pulmonary", "Post-COVID Pulmonary Fibrosis",
"Residual scarring from severe DAD"],
["Cardiovascular", "Myocarditis & Pericarditis",
"Direct viral (ACE2-mediated) + immune-mediated lymphocytic inflammation"],
["Cardiovascular", "Arrhythmias",
"Cardiac inflammation, electrolyte disturbances, autonomic dysfunction"],
["Haematological", "DIC (Disseminated Intravascular Coagulation)",
"Cytokine-driven endothelial activation → microvascular thrombosis; ↑D-dimer, ↑PT"],
["Neurological", "Guillain-Barré Syndrome (GBS)",
"Post-infectious molecular mimicry → immune-mediated polyneuropathy (demyelinating)"],
["Neurological", "Acute Flaccid Myelitis",
"Post-infectious immune-mediated spinal cord inflammation"],
["Neurological", "Encephalopathy / Delirium",
"Cytokine-mediated neuroinflammation; hypoxia in severe disease"],
["Neurological", "Stroke / Cerebral Venous Sinus Thrombosis",
"Hypercoagulable state → arterial/venous thrombosis"],
["Renal", "Acute Kidney Injury (AKI)",
"ACE2-mediated direct viral tubular injury + cytokine storm"],
["Paediatric\n(Special)", "MIS-C — Multisystem Inflammatory Syndrome in Children",
"Post-COVID immune-mediated; Kawasaki-like features: fever, myocarditis, shock, "
"CORONARY ARTERY ANEURYSMS; Tx: IVIG + aspirin"],
["Long-term", "Long-COVID / PASC",
"Fatigue, brain fog, dyspnea, myalgia >4 weeks after acute illness; "
"Possible chronic organ damage (lung, heart, kidney, brain)"],
],
col_widths=[3*cm, 5.2*cm, 9.4*cm],
header_color=ACCENT_TEAL,
alt_color=LIGHT_TEAL
),
sp(0.2),
P("⚠️ <b>Exam Favourite:</b> GBS is the post-infectious non-suppurative neurological complication. "
"MIS-C is the paediatric post-COVID complication (Kawasaki-like, <b>coronary artery aneurysm</b> is key). "
"ARDS is the most severe acute complication.", WARN),
sp(0.3)]
# ──────────────────────────────────────────────────────────────────────────
# SECTION 7 — LAB DIAGNOSIS
# ──────────────────────────────────────────────────────────────────────────
story += [section_header("7", "LABORATORY DIAGNOSIS"), sp(0.2),
sub_header("7A. Virological / Direct Tests"), sp(0.1),
make_table(
["Test", "Target", "Specimen", "Sensitivity", "Use"],
[
["RT-PCR (NAAT)\n★ GOLD STANDARD",
"Viral RNA (ORF1, N gene, E gene)",
"Nasopharyngeal / Oropharyngeal swab",
"Very High (>95%)",
"Definitive diagnosis of CURRENT infection"],
["Rapid Antigen Test (RAT)",
"Viral Nucleocapsid (N) protein antigen",
"Nasal swab",
"Moderate (70–85%)",
"Rapid screening; (+)ve reliable; (-)ve needs RT-PCR confirmation"],
["BioFire Respiratory Panel 2.1",
"Nucleic acids of 15 viruses + 4 bacteria",
"NP swab",
"High",
"Multiplex — differentiates COVID-19 from other respiratory pathogens simultaneously"],
["Viral Culture",
"Live virus isolation",
"NP swab (BSL-3)",
"N/A",
"Research only; not for routine clinical diagnosis"],
],
col_widths=[3.5*cm, 3.8*cm, 3.2*cm, 2.4*cm, 4.7*cm]
),
sp(0.2),
sub_header("7B. Serological Tests"), sp(0.1),
make_table(
["Test", "Target", "Timing", "Use"],
[
["IgM Antibody", "Anti-SARS-CoV-2 IgM", "Appears: 5–7 days after infection",
"Early infection marker (less specific)"],
["IgG Antibody", "Anti-SARS-CoV-2 IgG (esp. anti-Spike, anti-N)",
"Appears: 10–14 days; peaks 3–4 weeks",
"Past infection, immune surveillance — NOT for acute diagnosis"],
["Neutralising Antibody", "Inhibits Spike-ACE2 binding", "Post-infection/vaccination",
"Research; assessing protective immunity"],
],
col_widths=[3.5*cm, 5*cm, 4.5*cm, 4.6*cm]
),
sp(0.2),
sub_header("7C. Supportive Lab Findings in Severe COVID-19"), sp(0.1),
make_table(
["Investigation", "Finding in Severe COVID-19", "Significance"],
[
["CBC", "Lymphopenia (↓CD4/CD8 T cells) + Neutrophilia", "Hallmark of severe disease; marker of cytokine storm"],
["D-dimer", "Markedly elevated", "DIC / venous thromboembolism risk"],
["CRP", "Very high (>100 mg/L in severe)", "Systemic inflammation marker"],
["IL-6", "Highly elevated", "Key cytokine storm mediator; targets for tocilizumab"],
["Ferritin", "Elevated (hyperferritinaemia)", "Macrophage activation; inflammation"],
["LDH", "Elevated", "Tissue necrosis, widespread damage"],
["Procalcitonin", "Elevated if bacterial superinfection", "Differentiates bacterial from viral"],
["Troponin / BNP", "Elevated", "Myocarditis / cardiac injury"],
["Prothrombin Time", "Prolonged", "DIC; coagulation pathway activation"],
["Creatinine / BUN", "Elevated", "AKI involvement"],
["Chest X-ray / CT", "Bilateral ground-glass opacities, consolidation, 'crazy-paving' pattern",
"Viral pneumonia / ARDS pattern — peripheral, bilateral"],
["SpO₂ / ABG", "SpO₂ <90%; PaO₂ <60 mmHg; type 1 respiratory failure", "Hypoxaemia, ARDS"],
],
col_widths=[3.8*cm, 7*cm, 6.8*cm]
),
sp(0.2),
P("📌 <b>Key Diagnostic Principle:</b> Antibody tests detect PAST infection/immunity only. "
"For CURRENT infection diagnosis: always use RT-PCR or RAT. "
"Wastewater surveillance of SARS-CoV-2 RNA helps track community-level prevalence.", EXAM_TIP),
sp(0.3)]
# ──────────────────────────────────────────────────────────────────────────
# SECTION 8 — TREATMENT
# ──────────────────────────────────────────────────────────────────────────
story += [section_header("8", "TREATMENT"), sp(0.2),
sub_header("8A. Antiviral Therapy"), sp(0.1),
make_table(
["Drug", "Class / Mechanism", "Indication", "Route"],
[
["Remdesivir", "Nucleotide analogue; inhibits RdRp → blocks viral RNA synthesis",
"Hospitalized patients requiring O₂; given for 5 days", "IV infusion"],
["Nirmatrelvir/Ritonavir\n(Paxlovid)", "Viral 3CL-protease inhibitor (Nirmatrelvir);\nRitonavir boosts levels",
"High-risk outpatients within 5 days of symptom onset", "Oral"],
["Molnupiravir", "Mutagenic nucleoside analogue; induces viral RNA errors",
"Alternative for high-risk outpatients (if Paxlovid not available)", "Oral"],
],
col_widths=[3.8*cm, 6*cm, 5.3*cm, 2.5*cm]
),
sp(0.2),
sub_header("8B. Anti-Inflammatory / Immunomodulatory Therapy"), sp(0.1),
make_table(
["Drug", "Class / Mechanism", "Indication"],
[
["Dexamethasone ★",
"Corticosteroid; suppresses cytokine storm; reduces inflammation-mediated lung injury",
"Hospitalised patients requiring supplemental O₂ or ventilation. 6 mg/day × 10 days. "
"DO NOT use in mild disease (may worsen outcome)."],
["Tocilizumab",
"Anti-IL-6 receptor monoclonal antibody; blocks IL-6 signalling",
"Severe/critical COVID-19 with cytokine storm and elevated CRP; used with dexamethasone"],
["Baricitinib",
"JAK1/JAK2 inhibitor; blocks cytokine signalling pathway",
"Hospitalised adults requiring O₂, NIV, or mechanical ventilation; alternative to tocilizumab"],
],
col_widths=[4*cm, 6.5*cm, 7.1*cm]
),
sp(0.2),
sub_header("8C. Monoclonal Antibodies (mAbs)"), sp(0.1),
make_table(
["Drug", "Target", "Use"],
[
["Bamlanivimab", "SARS-CoV-2 Spike glycoprotein", "High-risk outpatients; prevents progression (FDA EUA)"],
["Casirivimab + Imdevimab (REGEN-COV)", "Spike RBD (cocktail — two mAbs)", "High-risk patients; prevents hospitalisation"],
["Bebtelovimab / Sotrovimab", "Spike protein (different epitopes)", "Omicron-active; replacing earlier mAbs"],
],
col_widths=[5*cm, 6.5*cm, 6.1*cm]
),
sp(0.1),
P("⚠️ Note: Efficacy of monoclonal antibodies varies by variant. Many early mAbs (bamlanivimab, "
"casirivimab+imdevimab) have reduced activity against Omicron subvariants.", NOTE),
sp(0.2),
sub_header("8D. Supportive Care (Severe / Critical Disease)"), sp(0.1),
make_table(
["Intervention", "Details"],
[
["Supplemental Oxygen", "Low-flow (nasal cannula) → High-flow nasal O₂ (HFNO) → Non-invasive ventilation (NIV) → Invasive mechanical ventilation"],
["Prone Positioning", "Improves oxygenation in ARDS by recruiting posterior lung segments; ≥16 hours/day recommended"],
["Mechanical Ventilation", "For respiratory failure (PaO₂/FiO₂ <150 mmHg); lung-protective strategy: low tidal volume 6 mL/kg, PEEP titration"],
["Anticoagulation", "Prophylactic / therapeutic heparin for VTE prevention/treatment; guided by D-dimer and clinical risk"],
["Vasopressors", "Noradrenaline for septic shock maintaining MAP ≥65 mmHg"],
["ICU Care", "Continuous monitoring, multi-organ support, nutritional support, prevention of secondary infections"],
],
col_widths=[4.5*cm, 13.1*cm]
),
sp(0.2),
sub_header("8E. Prevention & Vaccines"), sp(0.1),
make_table(
["Vaccine / Measure", "Type / Details", "Efficacy"],
[
["Pfizer-BioNTech (Comirnaty)", "mRNA — encodes Spike glycoprotein; 2 doses, 3 weeks apart",
"~95% vs. severe disease (original strain)"],
["Moderna (Spikevax)", "mRNA — encodes Spike glycoprotein; 2 doses, 4 weeks apart",
"~94% vs. severe disease"],
["Johnson & Johnson (Janssen)", "Replication-incompetent human adenovirus vector (Ad26); single dose",
"~66–72% vs. symptomatic disease"],
["Covishield / AstraZeneca", "ChAdOx1 adenovirus vector encoding Spike; 2 doses", "~70–90% vs. severe disease"],
["Covaxin (Bharat Biotech)", "Whole-inactivated virus; 2 doses; widely used in India",
"~77% vs. symptomatic disease"],
["Non-pharmacological", "Masking (N95 > surgical > cloth) | Social distancing ≥6 feet | "
"Hand hygiene (≥60% alcohol sanitiser) | Ventilation | Quarantine/Isolation", "Additive protection"],
],
col_widths=[4.5*cm, 7.5*cm, 5.6*cm]
),
sp(0.3)]
# ──────────────────────────────────────────────────────────────────────────
# SECTION 9 — MNEMONICS & EXAM TIPS
# ──────────────────────────────────────────────────────────────────────────
story += [section_header("9", "MNEMONICS & EXAM TIPS", color=colors.HexColor("#065f46")), sp(0.2),
P("📝 <b>MNEMONIC — Structural Proteins of Coronavirus: S.M.E.N</b>", BOLD_BODY),
P(" <b>S</b> — Spike glycoprotein (binds ACE2; vaccine target)<br/>"
" <b>M</b> — Membrane glycoprotein (most abundant)<br/>"
" <b>E</b> — Envelope glycoprotein (ion channel; virulence)<br/>"
" <b>N</b> — Nucleocapsid phosphoprotein (packages RNA; diagnostic antigen)", BODY),
sp(0.1),
P("📝 <b>MNEMONIC — Symptoms of COVID-19: FACT-CAD</b>", BOLD_BODY),
P(" <b>F</b> — Fever<br/>"
" <b>A</b> — Anosmia / Ageusia<br/>"
" <b>C</b> — Cough (dry)<br/>"
" <b>T</b> — Tiredness / Fatigue<br/>"
" <b>C</b> — Chest pain<br/>"
" <b>A</b> — Aches (myalgia, headache)<br/>"
" <b>D</b> — Dyspnea (shortness of breath)", BODY),
sp(0.1),
P("📝 <b>MNEMONIC — Cytokines in Cytokine Storm: IL-6 = I Let-6 go</b>", BOLD_BODY),
P("Key cytokines: <b>IL-1β, IL-6, IL-8, TNF-α, CCL2</b> — all elevated in severe COVID-19. "
"IL-6 is THE most important → targeted by Tocilizumab.", BODY),
sp(0.2),
make_table(
["Exam Question Type", "Key Answer"],
[
["Gold standard diagnosis of COVID-19", "RT-PCR of nasopharyngeal swab"],
["Unique feature distinguishing COVID-19 from other respiratory viruses", "Anosmia + Ageusia (loss of smell and taste)"],
["Receptor used by SARS-CoV-2 for cell entry", "ACE2 (+ TMPRSS2 for priming)"],
["Most severe acute complication of COVID-19", "ARDS (Acute Respiratory Distress Syndrome)"],
["Post-infectious neurological complication", "Guillain-Barré Syndrome (GBS)"],
["Paediatric post-COVID complication", "MIS-C — features of Kawasaki disease including coronary artery aneurysms"],
["Treatment of severe COVID-19 (drug of choice for hospitalised)", "Dexamethasone 6 mg/day × 10 days + Remdesivir"],
["Why SARS-CoV-2 is more contagious than SARS-CoV-1", "Asymptomatic transmission; peak viral shedding BEFORE symptom onset (vs. after in SARS-CoV-1)"],
["Component detected by rapid antigen test", "Nucleocapsid (N) protein antigen"],
["Which vaccine platform is used by Pfizer/Moderna", "mRNA vaccine encoding Spike glycoprotein"],
["Severity classification: critical illness", "Respiratory failure + shock + multi-organ dysfunction (~5% of cases)"],
["What gives coronavirus its name?", "Crown-like spike projections visible on EM (corona = crown in Latin)"],
],
col_widths=[7.5*cm, 10.1*cm],
header_color=colors.HexColor("#065f46"),
alt_color=GREEN_LIGHT
),
sp(0.3)]
# ──────────────────────────────────────────────────────────────────────────
# SECTION 10 — QUICK SUMMARY TABLE
# ──────────────────────────────────────────────────────────────────────────
story += [section_header("10", "QUICK SUMMARY — ONE-PAGE REVISION"), sp(0.2),
make_table(
["Category", "Key Points"],
[
["Agent", "SARS-CoV-2 | Family: Coronaviridae | Genus: Betacoronavirus"],
["Genome", "+ssRNA, ~30 kb, largest RNA genome, helical nucleocapsid, enveloped"],
["Size", "80–160 nm"],
["Key Receptor", "ACE2 (Angiotensin-Converting Enzyme 2) + TMPRSS2"],
["Transmission", "Respiratory droplets (primary) | Aerosol | Contact (minor)"],
["Incubation", "2–14 days (average 5 days)"],
["Key Structural Proteins", "Spike (S), Membrane (M), Envelope (E), Nucleocapsid (N)"],
["Virulence Factors", "Spike RBD–ACE2 binding | TMPRSS2 | IFN-I antagonism | Cytokine storm | Asymptomatic transmission | Furin cleavage site"],
["Pathogenesis", "URT entry → ACE2 binding → replication → cytokine storm → DAD → ARDS/DIC"],
["Cardinal Symptoms", "Fever | Dry Cough | Anosmia | Ageusia | Fatigue"],
["Severity Spectrum", "40% asymptomatic | 40% mild | 15% moderate | 15% severe | 5% critical"],
["Lab Diagnosis", "RT-PCR (gold std) | RAT (rapid) | BioFire panel | Antibody (past exposure only)"],
["Suppurative Complications", "Bacterial superinfection | VAP | Septic shock | Lung abscess"],
["Non-Suppurative Complications", "ARDS | DIC | Myocarditis | GBS | MIS-C | Stroke | AKI | Long COVID"],
["Treatment", "Remdesivir (antiviral) + Dexamethasone (anti-inflammatory) + Supportive care"],
["Prevention", "mRNA vaccines (Pfizer, Moderna) | Masking | Social distancing | Hand hygiene"],
["Most Severe Acute Complication", "ARDS with respiratory failure"],
["Paediatric Complication", "MIS-C — Kawasaki-like, coronary artery aneurysms, myocarditis"],
["Post-Infectious Neurological", "Guillain-Barré Syndrome (GBS) — acute inflammatory demyelinating polyneuropathy"],
["Long-term Sequelae", "Long-COVID / PASC — fatigue, brain fog, dyspnea >4 weeks"],
],
col_widths=[5*cm, 12.6*cm]
),
sp(0.4),
P("Sources: <b>Sherris & Ryan's Medical Microbiology 8e</b> (pp. 355–368) | "
"<b>Goldman-Cecil Medicine 27e</b> (Chapter 336) | "
"<b>Robbins & Cotran Pathologic Basis of Disease 10e</b> | "
"<b>Harrison's Principles of Internal Medicine 22e</b> | "
"Aligned with Apurba Sastri Microbiology syllabus", NOTE)]
doc.build(story, onFirstPage=add_page_number, onLaterPages=add_page_number)
print(f"PDF generated: {OUTPUT_PATH}")
return OUTPUT_PATH
if __name__ == "__main__":
build()