Now I will be giving question in a chunks so please first go through them all then answer them in a proper format and flowcharts

Understood! Please go ahead and send your questions in chunks. Once you've shared them all, just let me know and I'll organize everything into a well-formatted response with flowcharts where applicable.

They are question of microbiology so give answers appropriately for university exams

Got it! Microbiology university exam questions - I'll make sure to give you detailed, exam-ready answers with proper headings, tables, and flowcharts.
Go ahead and send your questions whenever you're ready!

1) Miscellaneous topics

Asking for Preferences
No problem! It looks like you're still building up your question list. Please go ahead and send all your microbiology questions (in as many chunks as you need), and once you're done just say "done" or "answer now" - I'll then compile everything and give you complete, exam-ready answers with flowcharts all at once.

Lab diagnosis of plague. Zoonotic infections and their vectors. Emerging viral infections. Congenital toxoplasmosis. Congenital syphilis. Leptospira nosocomial infections. Oncogenesis and viral oncogenes

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File

MICROBIOLOGY - MISCELLANEOUS TOPICS

University Exam Answer Compilation


1. LABORATORY DIAGNOSIS OF PLAGUE

Causative Agent: Yersinia pestis - Gram-negative coccobacillus, member of Enterobacteriaceae

Flowchart: Lab Diagnosis of Plague

SUSPECTED PLAGUE CASE
(fever + bubo/pneumonia + epidemiological exposure within 10 days)
        |
        v
SPECIMEN COLLECTION
┌────────────────────────────────────────────────────────┐
│  Bubonic → Bubo aspirate                               │
│  Pneumonic → Sputum / BAL                              │
│  Septicemic → Blood cultures                           │
│  Post-mortem → Tissue samples (lymph node, liver, lung)│
└────────────────────────────────────────────────────────┘
        |
        v
PRESUMPTIVE (RAPID) TESTS
┌─────────────────────────────────────────────────────────────────┐
│ 1. Direct Microscopy                                            │
│    • Gram stain → Gram-negative coccobacilli                    │
│    • Wayson / Wright-Giemsa stain → Bipolar "safety-pin" staining│
│    • Immunofluorescence (DFA) → F1 antigen detection           │
│                                                                 │
│ 2. Rapid Antigen Detection (F1-RDT)                            │
│    • F1 antigen detected in aspirate/sputum/blood              │
│    • At least as sensitive as culture (Madagascar 2017 outbreak)│
│                                                                 │
│ 3. Serology                                                     │
│    • Single anti-F1 antibody titer (without prior vaccination)  │
└─────────────────────────────────────────────────────────────────┘
        |
        v
CONFIRMATORY TESTS (Reference Laboratory)
┌──────────────────────────────────────────────────────────────┐
│ 1. Culture                                                   │
│    • Blood agar / MacConkey agar at 28°C                     │
│    • Colonies: "hammered metal" appearance                   │
│    • Slow growth (48-72 hrs); pinpoint colonies at 37°C      │
│                                                              │
│ 2. Biochemical Tests                                         │
│    • Urease negative, oxidase negative                       │
│    • Non-motile at 37°C; motile at 22-28°C                   │
│    • Fails to ferment lactose                                │
│                                                              │
│ 3. Bacteriophage Lysis Test                                  │
│    • Specific Yersinia phage lyses colonies at 20°C & 37°C   │
│                                                              │
│ 4. PCR                                                       │
│    • Detects pla, caf1 (F1 antigen), pst1 genes              │
│    • Highly specific and sensitive                           │
│                                                              │
│ 5. Paired Serology (ELISA / Passive Haemagglutination)       │
│    • 4-fold rise in anti-F1 titer in paired sera             │
└──────────────────────────────────────────────────────────────┘
        |
        v
CASE CLASSIFICATION
┌───────────────┬──────────────────────────────────────────┐
│ Suspected     │ Clinical + Epidemiological criteria only │
│ Probable      │ Suspected + 1 presumptive test positive  │
│ Confirmed     │ Suspected + culture/PCR positive         │
└───────────────┴──────────────────────────────────────────┘
Key Points for Exam:
  • Bipolar "safety-pin" appearance on Wayson stain is pathognomonic
  • F1-RDT is the WHO-recommended rapid field test
  • Cultures must be handled in BSL-3 facilities
  • WHO framework: presumptive → probable → confirmed

2. ZOONOTIC INFECTIONS AND THEIR VECTORS

Definition: Zoonoses are infections naturally transmitted between vertebrate animals and humans. They account for >60% of all emerging infections.

Table: Major Zoonotic Infections and Vectors

DiseasePathogenAnimal ReservoirVector/Mode
PlagueYersinia pestisRodents (rats)Flea (Xenopsylla cheopis)
Lyme DiseaseBorrelia burgdorferiWhite-tailed deer / miceTick (Ixodes scapularis)
Rocky Mountain SFRickettsia rickettsiiDogs, rodentsTick (Dermacentor spp.)
Scrub TyphusOrientia tsutsugamushiRodentsMite (Trombiculid mite / chigger)
Typhus (Epidemic)Rickettsia prowazekiiHumans/Flying squirrelsBody louse (Pediculus humanus)
Typhus (Endemic/Murine)Rickettsia typhiRatsRat flea
RabiesRabies virusDogs, bats, foxesAnimal bite (direct)
BrucellosisBrucella spp.Cattle, goats, pigsContact / ingestion of milk
Q FeverCoxiella burnetiiCattle, sheep, goatsInhaled aerosol / tick
TularemiaFrancisella tularensisRabbits, rodentsTick, deer fly, direct contact
AnthraxBacillus anthracisCattle, sheepDirect contact / spores
LeishmaniasisLeishmania spp.Dogs, rodentsSandfly (Phlebotomus spp.)
MalariaPlasmodium spp.Humans (primates)Mosquito (Anopheles)
Dengue / Yellow FeverArbovirusesPrimatesMosquito (Aedes aegypti)
Japanese EncephalitisJE virusPigs, birdsMosquito (Culex tritaeniorhynchus)
LeptospirosisLeptospira interrogansRodentsContact with contaminated water/soil
ToxoplasmosisToxoplasma gondiiCats (definitive host)Oocysts in cat feces / raw meat
Hydatid DiseaseEchinococcus granulosusDogs/sheepIngestion of eggs

Flowchart: Route of Zoonotic Transmission

ANIMAL RESERVOIR
       |
  ┌────┴─────────────────────────────┐
  |          TRANSMISSION ROUTES     |
  |   ┌──────────────────────────┐   |
  |   │ Arthropod Vector         │   |
  |   │ (Tick, Flea, Mosquito,   │   |
  |   │  Mite, Sandfly, Louse)   │   |
  |   └──────────┬───────────────┘   |
  |              │                   |
  |   ┌──────────────────────────┐   |
  |   │ Direct Contact           │   |
  |   │ (bite, scratch, skin)    │   |
  |   └──────────────────────────┘   |
  |   ┌──────────────────────────┐   |
  |   │ Ingestion                │   |
  |   │ (milk, meat, water)      │   |
  |   └──────────────────────────┘   |
  |   ┌──────────────────────────┐   |
  |   │ Inhalation               │   |
  |   │ (aerosols, spores)       │   |
  |   └──────────────────────────┘   |
  └──────────────────────────────────┘
             |
             v
          HUMAN HOST

3. EMERGING VIRAL INFECTIONS

Definition: Emerging infections are those that have newly appeared in a population OR have existed but are rapidly increasing in incidence, geographic range, or host range.

Major Emerging Viral Infections

VirusFamilyYear EmergedKey Features
HIVRetroviridae1981CD4+ T cell destruction, AIDS
EbolaFiloviridae1976 (re-emerged 2014)Hemorrhagic fever, >50% CFR
NipahParamyxoviridae1999Encephalitis; pigs → humans
HendraParamyxoviridae1994Horses → humans
SARS-CoV-1Coronaviridae2002-03Bats → civets → humans
MERS-CoVCoronaviridae2012Dromedary camels → humans
SARS-CoV-2Coronaviridae2019COVID-19 pandemic
ZikaFlaviviridae2015 (Americas)Microcephaly, Guillain-Barre
Monkeypox (Mpox)PoxviridaeRe-emerged 2022Rodents → humans, skin lesions
MarburgFiloviridae1967Hemorrhagic fever, fruit bats
Avian Influenza H5N1Orthomyxoviridae1997Poultry → humans; high CFR
ChikungunyaTogaviridae2004 (Indian Ocean)Arthralgia, Aedes vector

Flowchart: Factors Driving Emergence of Viral Infections

FACTORS FAVORING EMERGENCE
┌──────────────────────────────────────────┐
│ Ecological Changes                       │
│ (deforestation, agriculture, mining)     │
│           +                              │
│ Human Demographics                       │
│ (urbanization, population growth)        │
│           +                              │
│ International Travel & Trade             │
│           +                              │
│ Viral Mutation / Recombination           │
│ (antigenic shift, drift)                 │
│           +                              │
│ Breakdown of Public Health Measures      │
│           +                              │
│ Immunocompromised Populations            │
└──────────────────────────────────────────┘
          |
          v
SPILLOVER EVENT (Zoonotic jump: animal → human)
          |
          v
  ┌────────────────────────────────────────┐
  │ No human-to-human transmission         │
  │ → Sporadic cases only (e.g., Nipah)    │
  │                                        │
  │ Human-to-human transmission possible   │
  │ → Epidemic / Pandemic (e.g., COVID-19) │
  └────────────────────────────────────────┘
          |
          v
RESPONSE: Surveillance → Containment → Vaccine Development

4. CONGENITAL TOXOPLASMOSIS

Causative Agent: Toxoplasma gondii (obligate intracellular protozoan) Definitive host: Cat | Intermediate hosts: All warm-blooded animals

Flowchart: Pathogenesis of Congenital Toxoplasmosis

Primary maternal infection during pregnancy
(ingestion of oocysts from cat feces / undercooked meat)
          |
          v
Maternal parasitemia (tachyzoites in blood)
          |
     Transplacental transmission
          |
     Risk varies with trimester:
     ┌──────────────────────────────────────────┐
     │ 1st Trimester: Low transmission (15%)    │
     │ BUT severe fetal damage if transmitted   │
     │                                          │
     │ 2nd Trimester: ~30% transmission         │
     │ Moderate severity                        │
     │                                          │
     │ 3rd Trimester: High transmission (65%)   │
     │ BUT milder / subclinical disease         │
     └──────────────────────────────────────────┘
          |
          v
CONGENITAL INFECTION IN NEONATE

Classic Triad of Congenital Toxoplasmosis (Sabin's Triad):

Chorioretinitis + Hydrocephalus + Intracranial Calcifications

Clinical Features:

FeatureDescription
ChorioretinitisMost common manifestation; may cause blindness
HydrocephalusPeriventricular calcifications (unlike CMV which are diffuse)
Intracranial calcificationsPeriventricular location
SeizuresDue to CNS involvement
HepatosplenomegalySystemic involvement
Jaundice, thrombocytopeniaIn severe cases
Subclinical at birth (80%)May present later with neurological/ocular sequelae

Laboratory Diagnosis:

SUSPECTED CONGENITAL TOXOPLASMOSIS
          |
    ┌─────┴───────┐
  Serological    Direct
    Tests        Tests
    |              |
IgM + IgA in   PCR on amniotic fluid
neonatal blood / CSF / urine
(IgM does not   (gold standard
cross placenta) for prenatal)
    |              |
IgG persistence Histology of
beyond 12 months placenta
(confirms congenital
infection vs maternal IgG)
    |
Brain imaging
(CT/MRI): periventricular
calcifications + hydrocephalus
    |
Ophthalmological exam
(chorioretinitis)
Treatment: Pyrimethamine + Sulfadiazine + Folinic acid for 12 months

5. CONGENITAL SYPHILIS

Causative Agent: Treponema pallidum (spirochete) Transmission: Transplacental (at any stage of pregnancy, all stages of maternal syphilis)

Flowchart: Pathogenesis

Maternal syphilis (any stage)
          |
    Transplacental spread of T. pallidum
          |
     ┌────┴──────────────────────┐
     │ Before 16 weeks:           │
     │ Langhans' cell layer of    │
     │ cytotrophoblast protects   │
     │ (rare transmission early) │
     └────────────────────────────┘
     After 16 weeks: Direct fetal infection
          |
          v
OUTCOMES: Stillbirth / Hydrops fetalis / Congenital syphilis

Clinical Features:

A. Early Congenital Syphilis (< 2 years of age)
FeatureDescription
SnufflesMucopurulent/bloody nasal discharge (highly infectious)
Maculopapular rashPalms and soles involved (pathognomonic)
Condylomata lataFlat moist papules at mucocutaneous junctions
OsteochondritisWimberger's sign (bilateral destruction of medial tibial metaphysis)
HepatosplenomegalyCommon
Pseudoparalysis of ParrotLimb paralysis due to osteochondritis
Anemia, thrombocytopeniaHematological
B. Late Congenital Syphilis (> 2 years of age)
FeatureDescription
Hutchinson's teethNotched, peg-shaped upper central incisors
Interstitial keratitisCorneal clouding; most common eye finding
Eighth nerve deafnessSensorineural hearing loss
Hutchinson's TriadAbove 3 features together
Saber shinsAnterior bowing of tibia
Saddle nose deformityDestruction of nasal cartilage
Clutton's jointsBilateral painless knee effusions
Moon molarsMulberry-shaped first molars

Laboratory Diagnosis:

NEONATAL EVALUATION FOR CONGENITAL SYPHILIS
          |
    ┌─────┴──────────────────────────┐
  Nontreponemal Tests           Treponemal Tests
  (screening)                   (confirmatory)
    |                               |
  VDRL / RPR                    FTA-ABS / TPHA / TP-PA
  - Monitor treatment           - Remain positive lifelong
  - Reactive if titer 4x        - IgM-FTA-ABS in neonate
    higher than maternal          (IgM does not cross placenta)
          |
  Additional Tests:
    • CSF-VDRL (neurosyphilis)
    • X-ray long bones (osteochondritis)
    • CBC (anemia, thrombocytopenia)
    • LFTs (hepatitis)
    • Dark-field microscopy of nasal secretions (snuffles)
    • PCR on lesion material / CSF
Treatment: Aqueous crystalline penicillin G IV for 10-14 days (drug of choice)

6. LEPTOSPIRA (LEPTOSPIROSIS)

Causative Agent: Leptospira interrogans (pathogenic species) - tightly coiled spirochete with hooked ends Classic Syndrome: Weil's disease (severe leptospirosis) = Jaundice + Renal failure + Hemorrhage

Classification:

Genus Leptospira
    |
    ├── L. interrogans (pathogenic) - >300 serovars
    │       Key serovars: icterohaemorrhagiae, canicola,
    │       pomona, grippotyphosa, hardjo
    └── L. biflexa (saprophytic/non-pathogenic)

Flowchart: Pathogenesis and Clinical Spectrum

EXPOSURE
Rodent urine-contaminated water/soil
(floods, rice fields, sewers, swimming)
          |
ENTRY: Intact mucous membranes or
       abraded skin
          |
LEPTOSPIREMIC PHASE (Days 1-7)
"Flu-like illness"
• Fever, chills, headache
• Myalgia (calf muscles prominent)
• Conjunctival suffusion
• Blood, CSF, urine: Leptospires detectable
          |
IMMUNE PHASE (Days 7-14)
• Antibody production
• Organisms clear from blood/CSF
• Leptospires appear in urine
          |
         ┌┴──────────────────────────────┐
    MILD FORM                    SEVERE FORM (Weil's Disease)
    (90% of cases)               (10% of cases)
    Self-limiting                    |
    recovery                   • Jaundice (hepatitis)
                               • Acute Renal Failure (AKI)
                               • Hemorrhage (thrombocytopenia)
                               • Pulmonary hemorrhage syndrome
                               • Myocarditis, Uveitis
                               • Aseptic meningitis
                               MORTALITY: 5-40% if untreated

Laboratory Diagnosis:

PhaseSpecimenTest
Week 1 (leptospiremic)Blood, CSFCulture (EMJH medium), PCR, Dark-field microscopy
Week 2+ (immune)UrineCulture, PCR
Week 2+SerumMAT (Microscopic Agglutination Test) - Gold standard serology
SerologyPaired sera4-fold rise in MAT titer; single titer ≥ 1:800
Culture: EMJH (Ellinghausen-McCullough-Johnson-Harris) medium at 28-30°C for up to 13 weeks
Microscopic Agglutination Test (MAT):
  • Gold standard for serodiagnosis
  • Requires live leptospires from reference lab
  • Serogroup-specific; titer ≥ 1:100 significant
Treatment:
  • Mild: Doxycycline 100 mg BD × 7 days OR Amoxicillin/Ampicillin
  • Severe (Weil's disease): IV Penicillin G OR IV Ceftriaxone
Prevention: Doxycycline 200 mg weekly (chemoprophylaxis during floods); rodent control; PPE

7. NOSOCOMIAL (HOSPITAL-ACQUIRED) INFECTIONS

Definition: An infection acquired in a healthcare setting that was not present or incubating at the time of admission; typically manifests >48 hours after admission.
Also termed Healthcare-Associated Infections (HAIs)

Common Types and Causative Agents:

TypeAbbreviationCommon Pathogens
Urinary Tract InfectionCAUTIE. coli, Klebsiella, Candida, Enterococcus
Surgical Site InfectionSSIS. aureus (MRSA), E. coli, Pseudomonas
Ventilator-Associated PneumoniaVAPPseudomonas aeruginosa, Acinetobacter, MRSA, Klebsiella
Central Line-Associated BSICLABSIS. aureus, CoNS, Candida spp.
Clostridioides difficile InfectionCDIC. difficile (post-antibiotic diarrhea)
Blood Stream InfectionBSIS. epidermidis, S. aureus, Candida

Flowchart: Chain of Nosocomial Infection

RESERVOIR OF INFECTION
(Patient, Staff, Equipment, Environment, Water)
          |
    SUSCEPTIBLE HOST
    (Immunocompromised, Elderly,
    Post-surgical, ICU patients,
    Diabetics, Burn patients)
          |
    PORTAL OF ENTRY
    ┌────────────────────────────┐
    │ Indwelling catheters       │
    │ IV lines, ventilators      │
    │ Surgical wounds            │
    │ Airborne route (droplets)  │
    └────────────────────────────┘
          |
    MODE OF TRANSMISSION
    ┌───────────────────────────────────────┐
    │ Contact (most common) - Direct &      │
    │         Indirect (hands of HCW)       │
    │ Droplet (respiratory pathogens)       │
    │ Airborne (TB, Aspergillus, Varicella) │
    │ Common Vehicle (contaminated fluids)  │
    └───────────────────────────────────────┘
          |
    NOSOCOMIAL INFECTION
          |
    ┌─────┴─────────────────────────────────┐
  MRSA  MDR-TB  VRE  ESBL   CRE  C. diff
  (Multidrug-Resistant Organisms - MDROs)

Prevention and Control:

STANDARD PRECAUTIONS (ALL patients)
├── Hand Hygiene (WHO 5 moments)
├── PPE (gloves, gown, mask, eye protection)
├── Safe injection practices
└── Proper waste disposal

TRANSMISSION-BASED PRECAUTIONS
├── Contact Precautions: MRSA, VRE, C. diff
├── Droplet Precautions: Influenza, Meningococcal disease
└── Airborne Precautions: TB, Measles, Varicella (negative pressure room)

DEVICE-SPECIFIC BUNDLES
├── CAUTI bundle: Catheter care, early removal
├── CLABSI bundle: Sterile insertion, hand hygiene
└── VAP bundle: Head-of-bed elevation 30-45°, oral care
Surveillance: National Healthcare Safety Network (NHSN) criteria used for defining HAIs

8. ONCOGENESIS AND VIRAL ONCOGENES

Definition: Viral oncogenesis refers to the process by which viruses induce malignant transformation of host cells.

Major Oncogenic Viruses (Oncoviruses):

VirusFamilyAssociated Cancer
EBV (HHV-4)HerpesviridaeBurkitt's lymphoma, Hodgkin's lymphoma, NPC
HPV 16 & 18PapillomaviridaeCervical carcinoma, Head & neck cancer, Anal cancer
HBVHepadnaviridaeHepatocellular carcinoma (HCC)
HCVFlaviviridaeHepatocellular carcinoma, B-cell lymphoma
HTLV-1RetroviridaeAdult T-cell leukemia/lymphoma (ATLL)
HHV-8 (KSHV)HerpesviridaeKaposi's sarcoma, Primary effusion lymphoma
MCV (Merkel Cell Polyomavirus)PolyomaviridaeMerkel cell carcinoma

Flowchart: Mechanisms of Viral Oncogenesis

VIRAL INFECTION OF HOST CELL
          |
    ┌─────┴──────────────────────────────────────────────────┐
    │                                                        │
 DIRECT MECHANISMS                          INDIRECT MECHANISMS
    │                                               │
 ┌──┴────────────────────────────┐        Chronic Inflammation
 │                               │        & Immune Evasion
 │ 1. INSERTIONAL MUTAGENESIS    │        (HBV, HCV → HCC)
 │  Viral DNA integrates near    │
 │  proto-oncogenes → activates  │
 │  them (e.g., HBV integration) │
 │                               │
 │ 2. VIRAL ONCOGENES (v-onc)    │
 │  Viral genome carries         │
 │  oncogenes (transduced from   │
 │  host proto-oncogenes)        │
 │  • v-src (RSV) → tyrosine     │
 │    kinase, uncontrolled        │
 │    cell proliferation         │
 │  • v-myc, v-ras, v-erbB       │
 │                               │
 │ 3. INACTIVATION OF TUMOR      │
 │  SUPPRESSOR GENES             │
 │  • HPV E6 protein → degrades  │
 │    p53 (via ubiquitin pathway)│
 │  • HPV E7 protein → binds pRb │
 │    (releases E2F → S-phase)   │
 │  • HBx protein of HBV →       │
 │    activates Src kinase,       │
 │    interacts with p53         │
 │                               │
 │ 4. TRANSACTIVATION            │
 │  Viral proteins activate host │
 │  cell growth genes            │
 │  • HTLV-1 Tax protein →       │
 │    activates NF-κB → IL-2     │
 │    receptor expression →      │
 │    T-cell proliferation       │
 │  • EBV LMP-1 → NF-κB pathway │
 └───────────────────────────────┘
          |
    Loss of cell cycle control
    Resistance to apoptosis
    Genomic instability
          |
          v
    MALIGNANT TRANSFORMATION

Viral Oncogenes vs. Proto-Oncogenes:

FeatureProto-oncogene (c-onc)Viral oncogene (v-onc)
LocationNormal host genomeCarried in retroviral genome
RegulationTightly regulatedUnregulated / constitutively active
FunctionNormal cell growthDrives uncontrolled proliferation
OriginCellularTransduced from cellular proto-oncogene
Examplec-src, c-myc, c-rasv-src (RSV), v-myc, v-ras

Key Exam Points - HPV Oncogenesis:

HPV 16/18 infects cervical epithelium
          |
Viral DNA integrates into host genome
          |
E6 protein expressed → Binds p53 → Ubiquitin-mediated degradation
          |
E7 protein expressed → Binds Rb protein → Releases E2F
          |
Uncontrolled DNA replication → Dysplasia → CIN → Carcinoma

QUICK REVISION TABLE

TopicKey Bug/VirusKey TestTreatment
PlagueY. pestisWayson stain (bipolar), F1-RDT, CultureStreptomycin / Gentamicin / Doxycycline
LeptospirosisL. interrogansMAT (gold standard), EMJH culturePenicillin G (severe), Doxycycline (mild)
Congenital ToxoplasmosisT. gondiiPCR amniotic fluid, IgM in neonate, CT brainPyrimethamine + Sulfadiazine + Folinic acid
Congenital SyphilisT. pallidumVDRL/RPR (screen), FTA-ABS (confirm), IgM-FTAPenicillin G IV × 10-14 days
Nosocomial InfectionsMRSA, Pseudomonas, E. coli, C. diffSite-specific culturesTargeted antibiotics + Infection control
Viral OncogenesisHPV, HBV, EBV, HTLV-1E6/E7 (HPV), HBx (HBV), Tax (HTLV-1)Vaccines (HPV, HBV), antivirals

Sources: Harrison's Principles of Internal Medicine 22E; Sherris & Ryan's Medical Microbiology 8E; Jawetz Melnick & Adelberg's Medical Microbiology 28E; Goldman-Cecil Medicine; Red Book 2021

Can you generate pdf and compile all the answers

Reading File
Running Command

ls -la /tmp/workspace/ 2>/dev/null || mkdir -p /tmp/workspace && echo "workspace ready"

Running Command

mkdir -p /tmp/workspace/microbiology-pdf && echo "dir created"

Writing File

~/microbiology-pdf/generate_pdf.py

from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.platypus.flowables import Flowable
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.pdfgen import canvas
import os

OUTPUT = "/tmp/workspace/microbiology-pdf/Microbiology_Miscellaneous_Topics.pdf"

# ── Page layout ──────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=A4,
    leftMargin=2*cm, rightMargin=2*cm,
    topMargin=2.5*cm, bottomMargin=2.5*cm,
    title="Microbiology - Miscellaneous Topics",
    author="Orris AI",
    subject="University Exam Answer Compilation"
)

W, H = A4

# ── Colour palette ────────────────────────────────────────────────────────────
DARK_BLUE   = colors.HexColor("#1a3a5c")
MED_BLUE    = colors.HexColor("#2563a8")
LIGHT_BLUE  = colors.HexColor("#d6e8ff")
ACCENT      = colors.HexColor("#e8f4f8")
BOX_BORDER  = colors.HexColor("#2563a8")
GREEN       = colors.HexColor("#1a6b2e")
GREEN_LIGHT = colors.HexColor("#d4edda")
ORANGE      = colors.HexColor("#c95c00")
ORANGE_LIGHT= colors.HexColor("#fff3cd")
RED         = colors.HexColor("#8b0000")
GREY_LIGHT  = colors.HexColor("#f5f5f5")
GREY_MED    = colors.HexColor("#cccccc")
WHITE       = colors.white

# ── Styles ────────────────────────────────────────────────────────────────────
styles = getSampleStyleSheet()

title_style = ParagraphStyle(
    "TitleStyle", fontSize=22, fontName="Helvetica-Bold",
    textColor=WHITE, alignment=TA_CENTER, spaceAfter=6, leading=28
)
subtitle_style = ParagraphStyle(
    "SubTitle", fontSize=11, fontName="Helvetica",
    textColor=colors.HexColor("#cce0ff"), alignment=TA_CENTER, spaceAfter=4
)
h1_style = ParagraphStyle(
    "H1", fontSize=14, fontName="Helvetica-Bold",
    textColor=WHITE, spaceBefore=10, spaceAfter=4, leading=18
)
h2_style = ParagraphStyle(
    "H2", fontSize=12, fontName="Helvetica-Bold",
    textColor=DARK_BLUE, spaceBefore=8, spaceAfter=3, leading=16
)
h3_style = ParagraphStyle(
    "H3", fontSize=10.5, fontName="Helvetica-Bold",
    textColor=MED_BLUE, spaceBefore=6, spaceAfter=2, leading=14
)
body_style = ParagraphStyle(
    "Body", fontSize=9.5, fontName="Helvetica",
    textColor=colors.HexColor("#222222"), spaceAfter=4,
    leading=14, alignment=TA_JUSTIFY
)
bullet_style = ParagraphStyle(
    "Bullet", fontSize=9.5, fontName="Helvetica",
    textColor=colors.HexColor("#222222"), spaceAfter=2,
    leading=13, leftIndent=14, bulletIndent=4
)
mono_style = ParagraphStyle(
    "Mono", fontSize=8.5, fontName="Courier",
    textColor=colors.HexColor("#1a1a1a"), spaceAfter=2,
    leading=12, leftIndent=10, backColor=GREY_LIGHT
)
note_style = ParagraphStyle(
    "Note", fontSize=9, fontName="Helvetica-Oblique",
    textColor=colors.HexColor("#555555"), spaceAfter=4,
    leading=13, leftIndent=10
)
triad_style = ParagraphStyle(
    "Triad", fontSize=11, fontName="Helvetica-Bold",
    textColor=RED, alignment=TA_CENTER, spaceAfter=4, leading=16
)

# ── Helper: coloured section header ──────────────────────────────────────────
def section_header(num, title, color=DARK_BLUE):
    data = [[Paragraph(f"  {num}   {title}", h1_style)]]
    t = Table(data, colWidths=[doc.width])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), color),
        ("ROUNDEDCORNERS", [6]),
        ("TOPPADDING", (0,0), (-1,-1), 8),
        ("BOTTOMPADDING", (0,0), (-1,-1), 8),
        ("LEFTPADDING", (0,0), (-1,-1), 8),
    ]))
    return t

def info_box(text, bg=ACCENT, border=BOX_BORDER):
    """Highlighted info / definition box."""
    p = Paragraph(text, ParagraphStyle(
        "InfoBox", fontSize=9.5, fontName="Helvetica",
        textColor=DARK_BLUE, leading=14, leftIndent=6
    ))
    t = Table([[p]], colWidths=[doc.width])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("BOX", (0,0), (-1,-1), 1, border),
        ("TOPPADDING", (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
        ("LEFTPADDING", (0,0), (-1,-1), 8),
        ("RIGHTPADDING", (0,0), (-1,-1), 8),
    ]))
    return t

def make_table(headers, rows, col_ratios=None):
    """Generic styled table."""
    if col_ratios:
        col_widths = [doc.width * r for r in col_ratios]
    else:
        col_widths = [doc.width / len(headers)] * len(headers)

    header_style = ParagraphStyle("TH", fontSize=9, fontName="Helvetica-Bold",
                                   textColor=WHITE, leading=12)
    cell_style   = ParagraphStyle("TD", fontSize=8.5, fontName="Helvetica",
                                   textColor=colors.HexColor("#111111"), leading=12)

    data = [[Paragraph(h, header_style) for h in headers]]
    for row in rows:
        data.append([Paragraph(str(c), cell_style) for c in row])

    t = Table(data, colWidths=col_widths, repeatRows=1)
    cmd = [
        ("BACKGROUND",  (0,0), (-1,0),  DARK_BLUE),
        ("BACKGROUND",  (0,1), (-1,-1), WHITE),
        ("ROWBACKGROUNDS", (0,1), (-1,-1), [WHITE, GREY_LIGHT]),
        ("GRID",        (0,0), (-1,-1), 0.4, GREY_MED),
        ("TOPPADDING",  (0,0), (-1,-1), 4),
        ("BOTTOMPADDING",(0,0),(-1,-1), 4),
        ("LEFTPADDING", (0,0), (-1,-1), 5),
        ("RIGHTPADDING",(0,0), (-1,-1), 5),
        ("VALIGN",      (0,0), (-1,-1), "TOP"),
    ]
    t.setStyle(TableStyle(cmd))
    return t

def flowchart_box(lines, title=None, bg=LIGHT_BLUE, border=MED_BLUE):
    """A preformatted flowchart block with monospaced text."""
    content = []
    if title:
        content.append(Paragraph(f"<b>{title}</b>", ParagraphStyle(
            "FCTitle", fontSize=9.5, fontName="Helvetica-Bold",
            textColor=DARK_BLUE, spaceAfter=3, leading=13
        )))
    for line in lines:
        content.append(Paragraph(line, ParagraphStyle(
            "FCLine", fontSize=8, fontName="Courier",
            textColor=colors.HexColor("#1a1a1a"), leading=11, spaceAfter=0
        )))
    t = Table([[content]], colWidths=[doc.width])
    t.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), bg),
        ("BOX",        (0,0), (-1,-1), 1, border),
        ("TOPPADDING", (0,0), (-1,-1), 8),
        ("BOTTOMPADDING",(0,0),(-1,-1), 8),
        ("LEFTPADDING",(0,0), (-1,-1), 10),
        ("RIGHTPADDING",(0,0),(-1,-1), 10),
    ]))
    return t

# ── Page numbers ──────────────────────────────────────────────────────────────
def add_page_number(canvas_obj, doc_obj):
    canvas_obj.saveState()
    canvas_obj.setFont("Helvetica", 8)
    canvas_obj.setFillColor(colors.HexColor("#888888"))
    page_num = canvas_obj.getPageNumber()
    canvas_obj.drawRightString(W - 2*cm, 1.2*cm, f"Page {page_num}")
    canvas_obj.drawString(2*cm, 1.2*cm, "Microbiology - Miscellaneous Topics | University Exam Notes")
    canvas_obj.setStrokeColor(GREY_MED)
    canvas_obj.line(2*cm, 1.5*cm, W - 2*cm, 1.5*cm)
    canvas_obj.restoreState()

# ═══════════════════════════════════════════════════════════════════════════════
# BUILD CONTENT
# ═══════════════════════════════════════════════════════════════════════════════
story = []

# ── COVER PAGE ────────────────────────────────────────────────────────────────
cover_data = [[Paragraph("MICROBIOLOGY", title_style)],
              [Paragraph("Miscellaneous Topics", ParagraphStyle(
                  "CovSub", fontSize=17, fontName="Helvetica-Bold",
                  textColor=colors.HexColor("#aed6f1"), alignment=TA_CENTER
              ))],
              [Spacer(1, 0.3*cm)],
              [Paragraph("University Exam Answer Compilation", subtitle_style)],
              [Spacer(1, 0.2*cm)],
              [Paragraph("Compiled from Harrison's Principles of Internal Medicine 22E | Jawetz Melnick &amp; Adelberg's Medical Microbiology 28E | Sherris &amp; Ryan's Medical Microbiology 8E", subtitle_style)],
]
cover_table = Table(cover_data, colWidths=[doc.width])
cover_table.setStyle(TableStyle([
    ("BACKGROUND", (0,0), (-1,-1), DARK_BLUE),
    ("TOPPADDING", (0,0), (-1,-1), 20),
    ("BOTTOMPADDING", (0,0), (-1,-1), 20),
    ("LEFTPADDING", (0,0), (-1,-1), 20),
    ("RIGHTPADDING", (0,0), (-1,-1), 20),
    ("ROUNDEDCORNERS", [10]),
]))
story.append(cover_table)
story.append(Spacer(1, 0.5*cm))

# Topics index
topics = [
    ("1", "Lab Diagnosis of Plague"),
    ("2", "Zoonotic Infections and Their Vectors"),
    ("3", "Emerging Viral Infections"),
    ("4", "Congenital Toxoplasmosis"),
    ("5", "Congenital Syphilis"),
    ("6", "Leptospira (Leptospirosis)"),
    ("7", "Nosocomial Infections"),
    ("8", "Oncogenesis and Viral Oncogenes"),
]
idx_style = ParagraphStyle("Idx", fontSize=10, fontName="Helvetica",
                            textColor=DARK_BLUE, leading=16)
idx_num_style = ParagraphStyle("IdxNum", fontSize=10, fontName="Helvetica-Bold",
                                textColor=MED_BLUE, leading=16)
idx_rows = [[Paragraph(n, idx_num_style), Paragraph(t, idx_style)] for n, t in topics]
idx_table = Table(idx_rows, colWidths=[1.2*cm, doc.width - 1.2*cm])
idx_table.setStyle(TableStyle([
    ("TOPPADDING", (0,0), (-1,-1), 4),
    ("BOTTOMPADDING", (0,0), (-1,-1), 4),
    ("LEFTPADDING", (0,0), (-1,-1), 6),
    ("LINEBELOW", (0,0), (-1,-1), 0.3, GREY_MED),
]))

story.append(Paragraph("<b>Topics Covered</b>", h2_style))
story.append(idx_table)
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════
# TOPIC 1: LABORATORY DIAGNOSIS OF PLAGUE
# ════════════════════════════════════════════════════════════════
story.append(section_header("1", "LABORATORY DIAGNOSIS OF PLAGUE"))
story.append(Spacer(1, 0.3*cm))

story.append(info_box(
    "<b>Causative Agent:</b> <i>Yersinia pestis</i> - Gram-negative coccobacillus, "
    "member of Enterobacteriaceae | <b>Disease:</b> Plague (Bubonic / Pneumonic / Septicemic)"
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Specimen Collection (by Form)", h2_style))
spec_rows = [
    ["Form of Plague", "Specimen of Choice"],
    ["Bubonic Plague", "Bubo aspirate (DO NOT incise - aspirate with saline)"],
    ["Pneumonic Plague", "Sputum / Bronchoalveolar lavage (BAL)"],
    ["Septicemic Plague", "Blood cultures (multiple sets)"],
    ["Post-mortem", "Lymph node, liver, spleen, lung tissue"],
]
story.append(make_table(spec_rows[0], spec_rows[1:], [0.35, 0.65]))
story.append(Spacer(1, 0.3*cm))

story.append(Paragraph("Flowchart: Diagnostic Algorithm for Plague", h2_style))
fc1 = [
    "SUSPECTED PLAGUE CASE",
    "(Fever + Bubo/Pneumonia + Epidemiological exposure within 10 days)",
    "         |",
    "         v",
    "SPECIMEN COLLECTION (as above)",
    "         |",
    "   +------+----------------------------------------------+",
    "   |                                                      |",
    "   v                                                      v",
    "PRESUMPTIVE (RAPID) TESTS                   CONFIRMATORY TESTS",
    "                                            (Reference Laboratory)",
    "1. Direct Microscopy                    1. Culture on blood/MacConkey agar",
    "   - Gram stain: Gram-neg coccobacilli     at 28 deg C (48-72 hrs)",
    "   - Wayson/Wright-Giemsa stain:           'Hammered metal' colonies",
    "     Bipolar 'safety-pin' appearance    2. Biochemical: urease -ve,",
    "   - Immunofluorescence (DFA):             oxidase -ve, non-motile at 37C",
    "     F1 antigen detection              3. Bacteriophage lysis test",
    "                                          (phage lyses at 20 and 37 deg C)",
    "2. F1-RDT (Rapid Antigen Detection)    4. PCR: pla, caf1, pst1 genes",
    "   WHO-recommended field test          5. Paired serology (ELISA/PHA):",
    "   Detects F1 antigen in aspirate/        4-fold rise in anti-F1 titer",
    "   sputum/blood",
    "",
    "3. Single Anti-F1 Serology",
    "   (without prior vaccination/infection)",
    "         |",
    "         v",
    "CASE CLASSIFICATION:",
    "  Suspected  = Clinical + Epidemiological criteria only",
    "  Probable   = Suspected + 1 presumptive test positive",
    "  Confirmed  = Suspected + Culture or PCR positive",
]
story.append(flowchart_box(fc1))
story.append(Spacer(1, 0.3*cm))

story.append(Paragraph("Key Diagnostic Points", h3_style))
for pt in [
    "Bipolar 'safety-pin' staining with Wayson stain is pathognomonic for Y. pestis",
    "F1-RDT: At least as sensitive as culture (proved in 2017 Madagascar outbreak)",
    "Cultures must be handled in BSL-3 facilities (Category A bioterrorism agent)",
    "WHO framework: Presumptive → Probable → Confirmed",
    "PCR targets: pla gene (plasminogen activator), caf1 (F1 capsule antigen), pst1",
]:
    story.append(Paragraph(f"• {pt}", bullet_style))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════
# TOPIC 2: ZOONOTIC INFECTIONS AND THEIR VECTORS
# ════════════════════════════════════════════════════════════════
story.append(section_header("2", "ZOONOTIC INFECTIONS AND THEIR VECTORS"))
story.append(Spacer(1, 0.3*cm))

story.append(info_box(
    "<b>Definition:</b> Zoonoses are infections naturally transmitted between vertebrate animals "
    "and humans. They account for &gt;60% of all emerging infections and are caused by the full "
    "range of pathogens: viruses, bacteria, fungi, protozoa, and helminths."
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Major Zoonotic Infections, Reservoirs, and Vectors", h2_style))
zoo_headers = ["Disease", "Pathogen", "Animal Reservoir", "Vector / Mode"]
zoo_rows = [
    ["Plague", "Yersinia pestis", "Rodents (rats)", "Flea (Xenopsylla cheopis)"],
    ["Lyme Disease", "Borrelia burgdorferi", "Deer / mice", "Tick (Ixodes scapularis)"],
    ["Rocky Mountain SF", "Rickettsia rickettsii", "Dogs, rodents", "Tick (Dermacentor spp.)"],
    ["Scrub Typhus", "Orientia tsutsugamushi", "Rodents", "Mite / Chigger (Trombiculid)"],
    ["Epidemic Typhus", "Rickettsia prowazekii", "Humans / Flying squirrels", "Body louse (Pediculus humanus)"],
    ["Murine Typhus", "Rickettsia typhi", "Rats", "Rat flea"],
    ["Rabies", "Rabies virus (Lyssavirus)", "Dogs, bats, foxes", "Animal bite (direct)"],
    ["Brucellosis", "Brucella spp.", "Cattle, goats, pigs", "Contact / Ingestion (milk)"],
    ["Q Fever", "Coxiella burnetii", "Cattle, sheep, goats", "Inhaled aerosol / Tick"],
    ["Tularemia", "Francisella tularensis", "Rabbits, rodents", "Tick, deer fly, direct contact"],
    ["Anthrax", "Bacillus anthracis", "Cattle, sheep", "Contact / spore inhalation"],
    ["Leishmaniasis", "Leishmania spp.", "Dogs, rodents", "Sandfly (Phlebotomus spp.)"],
    ["Leptospirosis", "Leptospira interrogans", "Rodents", "Contaminated water/soil contact"],
    ["Toxoplasmosis", "Toxoplasma gondii", "Cats (definitive host)", "Oocysts in feces / raw meat"],
    ["Japanese Encephalitis", "JE Virus (Flavivirus)", "Pigs, birds", "Mosquito (Culex tritaeniorhynchus)"],
    ["Dengue / Yellow Fever", "Arboviruses (Flavivirus)", "Primates", "Mosquito (Aedes aegypti)"],
    ["Hydatid Disease", "Echinococcus granulosus", "Dogs / sheep", "Ingestion of eggs"],
]
story.append(make_table(zoo_headers, zoo_rows, [0.22, 0.24, 0.27, 0.27]))
story.append(Spacer(1, 0.3*cm))

story.append(Paragraph("Flowchart: Routes of Zoonotic Transmission", h2_style))
fc2 = [
    "ANIMAL RESERVOIR",
    "       |",
    "  +----+---------------------------------------------------+",
    "  |        TRANSMISSION ROUTES TO HUMANS                   |",
    "  |  +----------------------------+                        |",
    "  |  | Arthropod Vector           |  Tick → Lyme, RMSF    |",
    "  |  | (Tick, Flea, Mosquito,     |  Flea → Plague        |",
    "  |  |  Mite, Sandfly, Louse)     |  Mosquito → Dengue    |",
    "  |  +----------------------------+                        |",
    "  |  +----------------------------+                        |",
    "  |  | Direct Contact             |  Bite → Rabies        |",
    "  |  | (bite, scratch, skin)      |  Handling → Tularemia |",
    "  |  +----------------------------+                        |",
    "  |  +----------------------------+                        |",
    "  |  | Ingestion                  |  Milk → Brucellosis   |",
    "  |  | (milk, meat, water)        |  Water → Leptospirosis|",
    "  |  +----------------------------+                        |",
    "  |  +----------------------------+                        |",
    "  |  | Inhalation                 |  Aerosol → Q Fever    |",
    "  |  | (aerosols, spores)         |  Spores → Anthrax     |",
    "  |  +----------------------------+                        |",
    "  +--------------------------------------------------------+",
    "             |",
    "             v",
    "          HUMAN HOST -> Disease",
]
story.append(flowchart_box(fc2))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════
# TOPIC 3: EMERGING VIRAL INFECTIONS
# ════════════════════════════════════════════════════════════════
story.append(section_header("3", "EMERGING VIRAL INFECTIONS", color=colors.HexColor("#1a5c2a")))
story.append(Spacer(1, 0.3*cm))

story.append(info_box(
    "<b>Definition:</b> Emerging infections are those that have <b>newly appeared</b> in a population "
    "OR have existed but are rapidly <b>increasing in incidence, geographic range, or host range</b>. "
    "Zoonotic spillover events are the primary driver of new emerging viral infections.",
    bg=GREEN_LIGHT, border=GREEN
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Major Emerging Viral Infections", h2_style))
evi_headers = ["Virus", "Family", "Year Emerged", "Key Features / Disease"]
evi_rows = [
    ["HIV", "Retroviridae", "1981", "AIDS; CD4+ T-cell destruction"],
    ["Ebola", "Filoviridae", "1976 (re-emerg 2014)", "Viral hemorrhagic fever; CFR >50%"],
    ["Nipah", "Paramyxoviridae", "1999", "Encephalitis; pigs → humans"],
    ["Hendra", "Paramyxoviridae", "1994", "Horses → humans; encephalitis"],
    ["SARS-CoV-1", "Coronaviridae", "2002-03", "Bats → civets → humans; pneumonia"],
    ["MERS-CoV", "Coronaviridae", "2012", "Dromedary camels → humans; pneumonia"],
    ["SARS-CoV-2", "Coronaviridae", "2019", "COVID-19 global pandemic"],
    ["Zika", "Flaviviridae", "2015 (Americas)", "Microcephaly, Guillain-Barre; Aedes vector"],
    ["Mpox (Monkeypox)", "Poxviridae", "Re-emerg 2022", "Rodents → humans; skin lesions"],
    ["Marburg", "Filoviridae", "1967", "Hemorrhagic fever; fruit bats"],
    ["Avian Influenza H5N1", "Orthomyxoviridae", "1997", "Poultry → humans; high CFR"],
    ["Chikungunya", "Togaviridae", "2004 (Indian Ocean)", "Severe arthralgia; Aedes vector"],
]
story.append(make_table(evi_headers, evi_rows, [0.2, 0.2, 0.17, 0.43]))
story.append(Spacer(1, 0.3*cm))

story.append(Paragraph("Flowchart: Factors Driving Emergence + Epidemic Potential", h2_style))
fc3 = [
    "FACTORS FAVORING EMERGENCE",
    "+--------------------------------------------------+",
    "| Ecological Changes (deforestation, agriculture)  |",
    "|           +                                      |",
    "| Human Demographics (urbanization, overpopulation)|",
    "|           +                                      |",
    "| International Travel & Trade                     |",
    "|           +                                      |",
    "| Viral Mutation / Recombination                   |",
    "|   (antigenic shift, drift, reassortment)         |",
    "|           +                                      |",
    "| Breakdown of Public Health Measures              |",
    "|           +                                      |",
    "| Immunocompromised Populations (HIV, transplant)  |",
    "+--------------------------------------------------+",
    "          |",
    "          v",
    "SPILLOVER EVENT (Zoonotic jump: animal --> human)",
    "          |",
    "  +-------+--------------------------------------+",
    "  |                                              |",
    "  v                                              v",
    "No sustained human-to-human            Sustained human-to-human",
    "transmission                           transmission",
    "-> Sporadic/dead-end cases             -> Epidemic / Pandemic",
    "   (e.g. Nipah, H5N1)                    (e.g. COVID-19, HIV)",
    "          |",
    "          v",
    "RESPONSE: Surveillance -> Containment -> Vaccine/Antiviral Development",
]
story.append(flowchart_box(fc3, bg=GREEN_LIGHT, border=GREEN))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════
# TOPIC 4: CONGENITAL TOXOPLASMOSIS
# ════════════════════════════════════════════════════════════════
story.append(section_header("4", "CONGENITAL TOXOPLASMOSIS"))
story.append(Spacer(1, 0.3*cm))

story.append(info_box(
    "<b>Causative Agent:</b> <i>Toxoplasma gondii</i> (obligate intracellular protozoan) | "
    "<b>Definitive Host:</b> Cat | <b>Intermediate Hosts:</b> All warm-blooded animals including humans"
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Sabin's Classic Triad of Congenital Toxoplasmosis", h2_style))
story.append(info_box(
    "Chorioretinitis   +   Hydrocephalus   +   Intracranial Calcifications (periventricular)",
    bg=ORANGE_LIGHT, border=ORANGE
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Flowchart: Pathogenesis and Trimester-Risk", h2_style))
fc4a = [
    "Primary Maternal Infection (PRIMARY - not reactivation)",
    "(Ingestion of oocysts from cat feces / undercooked meat)",
    "          |",
    "          v",
    "Maternal Parasitemia (tachyzoites circulate in blood)",
    "          |",
    "     Transplacental Transmission",
    "          |",
    "     Risk varies with trimester:",
    "  +---------------------------------------------------------+",
    "  | 1st Trimester: ~15% transmission rate                  |",
    "  |   BUT severe fetal damage if transmission occurs       |",
    "  |   (Hydrocephalus, cerebral necrosis, stillbirth)       |",
    "  |                                                         |",
    "  | 2nd Trimester: ~30% transmission rate                  |",
    "  |   Moderate severity (chorioretinitis, calcifications)  |",
    "  |                                                         |",
    "  | 3rd Trimester: ~65% transmission rate                  |",
    "  |   BUT milder / usually subclinical disease at birth    |",
    "  |   May present later with neurological/ocular sequelae  |",
    "  +---------------------------------------------------------+",
    "          |",
    "          v",
    "CONGENITAL INFECTION IN NEONATE",
    "   80%: Subclinical at birth (but sequelae develop later)",
    "   20%: Symptomatic - chorioretinitis, seizures, rash",
]
story.append(flowchart_box(fc4a))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Clinical Features", h2_style))
ct_headers = ["Feature", "Description"]
ct_rows = [
    ["Chorioretinitis", "Most common manifestation; can cause permanent blindness"],
    ["Hydrocephalus", "Due to aqueduct obstruction; macrocephaly, bulging fontanelle"],
    ["Intracranial Calcifications", "Periventricular location (cf. CMV: diffuse throughout brain)"],
    ["Seizures", "Due to CNS involvement"],
    ["Hepatosplenomegaly", "Systemic reticuloendothelial involvement"],
    ["Jaundice, Thrombocytopenia", "Severe systemic disease"],
    ["Subclinical at birth (80%)", "Presents months-years later with chorioretinitis/neurodevelopmental delay"],
]
story.append(make_table(ct_headers, ct_rows, [0.35, 0.65]))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Laboratory Diagnosis", h2_style))
fc4b = [
    "SUSPECTED CONGENITAL TOXOPLASMOSIS",
    "          |",
    "    +------+--------------------------+",
    "    |                                 |",
    "  SEROLOGICAL TESTS              DIRECT TESTS",
    "    |                                 |",
    "  IgM + IgA in neonatal blood    PCR on amniotic fluid",
    "  (IgM does NOT cross placenta)   (prenatal gold standard)",
    "  IgM positive = neonatal         Also: CSF, urine, blood",
    "  infection confirmed",
    "    |                                 |",
    "  IgG persistence beyond          Histology of placenta",
    "  12 months confirms              (tachyzoites/bradyzoites)",
    "  (vs. passively acquired",
    "   maternal IgG that wanes)",
    "          |",
    "  Brain Imaging (CT/MRI):",
    "  Periventricular calcifications + Hydrocephalus",
    "          |",
    "  Ophthalmological Exam:",
    "  Chorioretinitis (macular scarring)",
    "          |",
    "  Audiological Assessment",
]
story.append(flowchart_box(fc4b))
story.append(Spacer(1, 0.2*cm))

story.append(info_box(
    "<b>Treatment:</b> Pyrimethamine + Sulfadiazine + Folinic acid (leucovorin) for 12 months | "
    "<b>Prevention:</b> Avoid cat litter, cook meat thoroughly, wash hands; "
    "Spiramycin given to pregnant women with primary infection to reduce transplacental transmission",
    bg=GREEN_LIGHT, border=GREEN
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════
# TOPIC 5: CONGENITAL SYPHILIS
# ════════════════════════════════════════════════════════════════
story.append(section_header("5", "CONGENITAL SYPHILIS"))
story.append(Spacer(1, 0.3*cm))

story.append(info_box(
    "<b>Causative Agent:</b> <i>Treponema pallidum</i> (spirochete) | "
    "<b>Transmission:</b> Transplacental at any stage of pregnancy and in any stage of maternal syphilis"
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Flowchart: Pathogenesis", h2_style))
fc5a = [
    "Maternal Syphilis (any stage: Primary, Secondary, Latent, Tertiary)",
    "          |",
    "    Transplacental spread of T. pallidum",
    "          |",
    "     +----+----------------------------------------------+",
    "     | Before 16 weeks:                                  |",
    "     | Langhans' cell layer of cytotrophoblast PROTECTS  |",
    "     | (rare transmission in 1st trimester)              |",
    "     +---------------------------------------------------+",
    "     After 16 weeks: Direct fetal invasion occurs",
    "          |",
    "          v",
    "OUTCOMES: Stillbirth | Hydrops fetalis | Prematurity | Congenital Syphilis",
    "Risk greatest in Primary & Secondary maternal syphilis",
]
story.append(flowchart_box(fc5a))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("A. Early Congenital Syphilis (< 2 years of age)", h2_style))
ecs_headers = ["Feature", "Description"]
ecs_rows = [
    ["Snuffles", "Mucopurulent/bloody nasal discharge - highly infectious; earliest sign"],
    ["Maculopapular rash", "Involves palms and soles - pathognomonic finding"],
    ["Condylomata lata", "Flat moist papules at mucocutaneous junctions"],
    ["Osteochondritis", "Wimberger's sign: bilateral destruction of medial tibial metaphysis on X-ray"],
    ["Pseudoparalysis of Parrot", "Limb pseudoparalysis due to painful osteochondritis"],
    ["Hepatosplenomegaly", "Common systemic finding"],
    ["Anemia, Thrombocytopenia", "Hematological manifestations"],
    ["Pemphigus syphiliticus", "Bullous lesions on palms and soles in neonates"],
]
story.append(make_table(ecs_headers, ecs_rows, [0.35, 0.65]))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("B. Late Congenital Syphilis (> 2 years of age)", h2_style))
lcs_headers = ["Feature", "Description"]
lcs_rows = [
    ["Hutchinson's Teeth", "Notched, peg-shaped, widely spaced upper central incisors"],
    ["Interstitial Keratitis", "Corneal clouding with vascularization - most common late eye finding"],
    ["Eighth Nerve Deafness", "Bilateral sensorineural hearing loss"],
    ["Hutchinson's Triad", "Above THREE features together (teeth + keratitis + deafness)"],
    ["Saber Shins", "Anterior bowing of tibia due to periostitis"],
    ["Saddle Nose Deformity", "Destruction of nasal septum cartilage"],
    ["Clutton's Joints", "Bilateral painless synovial effusions at knee joints"],
    ["Moon Molars", "Mulberry-shaped (dome-shaped) first molars"],
    ["Rhagades", "Linear scars around mouth, nose, anus from early congenital infection"],
]
story.append(make_table(lcs_headers, lcs_rows, [0.32, 0.68]))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Laboratory Diagnosis", h2_style))
fc5b = [
    "NEONATAL EVALUATION FOR CONGENITAL SYPHILIS",
    "          |",
    "    +------+-------------------------------+",
    "  Nontreponemal Tests (Screening)    Treponemal Tests (Confirmatory)",
    "  VDRL / RPR                         FTA-ABS / TPHA / TP-PA",
    "  - Reactive if neonatal titer       - Remain positive lifelong",
    "    is >= 4x maternal titer          - IgM-FTA-ABS in neonate",
    "  - Used to monitor treatment          confirms active infection",
    "    response (should fall)             (IgM does NOT cross placenta)",
    "          |",
    "  Additional Investigations:",
    "    * CSF-VDRL: diagnosis of neurosyphilis",
    "    * X-ray long bones: osteochondritis (Wimberger's sign)",
    "    * CBC: anemia, thrombocytopenia",
    "    * LFTs: hepatitis",
    "    * Dark-field microscopy: nasal discharge (snuffles)",
    "    * PCR on lesion material / CSF / blood",
]
story.append(flowchart_box(fc5b))
story.append(Spacer(1, 0.2*cm))

story.append(info_box(
    "<b>Treatment (DOC):</b> Aqueous crystalline Penicillin G IV for 10-14 days | "
    "<b>Alternative:</b> Procaine Penicillin G IM daily for 10-14 days | "
    "Serology (RPR/VDRL) should be rechecked at 3, 6, 12 months to confirm cure",
    bg=GREEN_LIGHT, border=GREEN
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════
# TOPIC 6: LEPTOSPIRA
# ════════════════════════════════════════════════════════════════
story.append(section_header("6", "LEPTOSPIRA (LEPTOSPIROSIS)", color=colors.HexColor("#5c3a1a")))
story.append(Spacer(1, 0.3*cm))

story.append(info_box(
    "<b>Causative Agent:</b> <i>Leptospira interrogans</i> (pathogenic) - tightly coiled spirochete "
    "with characteristic <b>hooked ends</b> | <b>Classic Syndrome:</b> Weil's Disease = "
    "Jaundice + Acute Renal Failure + Hemorrhage (Weil's Triad)"
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Classification of Genus Leptospira", h2_style))
for line in [
    "• Pathogenic: L. interrogans (>300 serovars; key ones: icterohaemorrhagiae, canicola, pomona, grippotyphosa, hardjo)",
    "• Saprophytic (non-pathogenic): L. biflexa",
    "• Key serogroups cross-react serologically; MAT identifies serogroup specificity",
]:
    story.append(Paragraph(line, bullet_style))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Flowchart: Pathogenesis and Clinical Spectrum", h2_style))
fc6 = [
    "EXPOSURE",
    "Rodent urine-contaminated water/soil (floods, rice fields, sewers, swimming)",
    "          |",
    "ENTRY: Intact mucous membranes OR Abraded/cut skin",
    "          |",
    "LEPTOSPIREMIC PHASE (Days 1-7): 'First Week / Flu-like illness'",
    "  * Fever, chills, severe headache",
    "  * Myalgia (calf muscles - very prominent, tenderness)",
    "  * Conjunctival suffusion (pathognomonic sign)",
    "  * Specimen: Blood / CSF -> Leptospires detectable by culture/PCR",
    "          |",
    "IMMUNE (LEPTOSPIRURIC) PHASE (Days 7-14):",
    "  * Antibody production begins",
    "  * Organisms cleared from blood and CSF",
    "  * Leptospires appear in URINE",
    "  * Specimen: Urine -> Culture/PCR",
    "          |",
    "         +----------------------+------------------------+",
    "         |                                               |",
    "  MILD FORM (90%)                          SEVERE FORM - WEIL'S DISEASE (10%)",
    "  Self-limiting recovery (1-2 wks)         * Jaundice (hepatocellular damage)",
    "                                           * Acute Kidney Injury (oliguria)",
    "                                           * Hemorrhage (thrombocytopenia,",
    "                                             pulmonary hemorrhage - ARDS)",
    "                                           * Myocarditis, Arrhythmias",
    "                                           * Aseptic Meningitis",
    "                                           * Anterior Uveitis (late)",
    "                                           MORTALITY: 5-40% if untreated",
]
story.append(flowchart_box(fc6, bg=ORANGE_LIGHT, border=ORANGE))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Laboratory Diagnosis", h2_style))
ld6_headers = ["Phase", "Specimen", "Test", "Notes"]
ld6_rows = [
    ["Week 1 (Leptospiremic)", "Blood, CSF", "Culture (EMJH medium), PCR, Dark-field microscopy", "Best window for culture"],
    ["Week 2+ (Immune/Leptospiruric)", "Urine", "Culture, PCR", "Culture for up to 13 weeks"],
    ["Week 2+ (Serology)", "Serum (paired)", "MAT (Microscopic Agglutination Test)", "GOLD STANDARD serology; titer >=1:800 diagnostic"],
    ["Serology (screening)", "Serum", "ELISA (IgM)", "More rapid; less specific than MAT"],
]
story.append(make_table(ld6_headers, ld6_rows, [0.22, 0.18, 0.35, 0.25]))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Key Points about MAT:", h3_style))
for pt in [
    "MAT (Microscopic Agglutination Test) = GOLD STANDARD for serodiagnosis",
    "Requires live leptospires from reference laboratory (BSL-2 facility)",
    "Serogroup-specific; titer >= 1:100 significant; >= 1:800 with single serum is diagnostic",
    "4-fold rise in titer between acute and convalescent sera is confirmatory",
]:
    story.append(Paragraph(f"• {pt}", bullet_style))
story.append(Spacer(1, 0.2*cm))

story.append(info_box(
    "<b>Treatment:</b> Mild: Doxycycline 100mg BD x 7 days OR Amoxicillin | "
    "Severe (Weil's): IV Penicillin G OR IV Ceftriaxone | "
    "<b>Chemoprophylaxis:</b> Doxycycline 200mg once weekly (during flood exposure) | "
    "<b>Prevention:</b> Rodent control, PPE, avoid contaminated water",
    bg=GREEN_LIGHT, border=GREEN
))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════
# TOPIC 7: NOSOCOMIAL INFECTIONS
# ════════════════════════════════════════════════════════════════
story.append(section_header("7", "NOSOCOMIAL (HOSPITAL-ACQUIRED) INFECTIONS", color=colors.HexColor("#5c1a1a")))
story.append(Spacer(1, 0.3*cm))

story.append(info_box(
    "<b>Definition:</b> An infection acquired in a healthcare setting that was <b>NOT present or "
    "incubating at the time of admission</b> - typically manifests <b>&gt;48 hours after admission</b>. "
    "Also termed Healthcare-Associated Infections (HAIs)."
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Common Types of Nosocomial Infections", h2_style))
nos_headers = ["Type", "Abbrev.", "Most Common Pathogens", "Risk Factors"]
nos_rows = [
    ["Urinary Tract Infection", "CAUTI", "E. coli, Klebsiella, Candida, Enterococcus", "Indwelling urinary catheter"],
    ["Surgical Site Infection", "SSI", "S. aureus (MRSA), E. coli, Pseudomonas", "Diabetes, obesity, immunosuppression"],
    ["Ventilator-Associated Pneumonia", "VAP", "Pseudomonas aeruginosa, Acinetobacter, MRSA, Klebsiella", "Mechanical ventilation, ICU"],
    ["Central Line-Associated BSI", "CLABSI", "S. aureus, CoNS, Candida spp.", "Central venous catheters"],
    ["C. difficile Infection", "CDI", "Clostridioides difficile", "Antibiotic use, elderly, PPI use"],
    ["Blood Stream Infection", "BSI", "S. epidermidis, S. aureus, Candida", "IV lines, immunocompromised"],
]
story.append(make_table(nos_headers, nos_rows, [0.25, 0.1, 0.35, 0.3]))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Flowchart: Chain of Nosocomial Infection", h2_style))
fc7a = [
    "RESERVOIR OF INFECTION",
    "(Patient, Healthcare Staff, Equipment, Hospital Environment, Water/Air)",
    "          |",
    "    SUSCEPTIBLE HOST",
    "    (Immunocompromised, Elderly, Post-surgical, ICU patients,",
    "     Neonates, Diabetics, Burn patients, Malignancy)",
    "          |",
    "    PORTAL OF ENTRY",
    "    +----------------------------------------------+",
    "    | Indwelling urinary catheters (CAUTI)         |",
    "    | Intravenous lines (CLABSI)                   |",
    "    | Endotracheal tube / Ventilator (VAP)         |",
    "    | Surgical wounds (SSI)                        |",
    "    | Gastrointestinal tract (C. diff after ABx)   |",
    "    +----------------------------------------------+",
    "          |",
    "    MODE OF TRANSMISSION",
    "    +----------------------------------------------------+",
    "    | Contact (MOST COMMON) - Direct & Indirect (hands) |",
    "    | Droplet - Influenza, N. meningitidis              |",
    "    | Airborne - TB, Aspergillus, Varicella, Measles    |",
    "    | Common Vehicle - Contaminated IV fluids, blood    |",
    "    +----------------------------------------------------+",
    "          |",
    "    NOSOCOMIAL INFECTION",
    "          |",
    "+----+------+-----+--------+-----+----------+",
    "MRSA  MDR-TB  VRE  ESBL-EC  CRE   C. diff",
    "(Multidrug-Resistant Organisms - MDROs)",
]
story.append(flowchart_box(fc7a, bg=ORANGE_LIGHT, border=ORANGE))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Prevention and Control", h2_style))
fc7b = [
    "STANDARD PRECAUTIONS (ALL patients, every encounter)",
    "  - Hand Hygiene: WHO 5 Moments (before/after patient contact,",
    "    before aseptic procedure, after body fluid exposure, after touching environment)",
    "  - Personal Protective Equipment (PPE): gloves, gown, mask, eye protection",
    "  - Safe injection practices",
    "  - Respiratory hygiene / cough etiquette",
    "  - Safe handling and disposal of sharps and waste",
    "",
    "TRANSMISSION-BASED PRECAUTIONS (Additional, for specific pathogens)",
    "  Contact Precautions: MRSA, VRE, C. difficile, scabies, RSV",
    "  Droplet Precautions: Influenza, Pertussis, Meningococcal, Mumps",
    "  Airborne Precautions: TB, Measles, Varicella (negative pressure room required)",
    "",
    "DEVICE-SPECIFIC BUNDLES",
    "  CAUTI bundle: Strict insertion sterility, daily review, early removal",
    "  CLABSI bundle: Sterile insertion, maximal barrier precautions, chlorhexidine skin prep",
    "  VAP bundle: Head-of-bed elevation 30-45 deg, oral care, sedation holidays",
    "",
    "ANTIMICROBIAL STEWARDSHIP: Prevents emergence of MDROs",
    "SURVEILLANCE: National Healthcare Safety Network (NHSN) criteria",
]
story.append(flowchart_box(fc7b, bg=GREEN_LIGHT, border=GREEN))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════
# TOPIC 8: ONCOGENESIS AND VIRAL ONCOGENES
# ════════════════════════════════════════════════════════════════
story.append(section_header("8", "ONCOGENESIS AND VIRAL ONCOGENES"))
story.append(Spacer(1, 0.3*cm))

story.append(info_box(
    "<b>Definition:</b> Viral oncogenesis is the process by which viruses induce <b>malignant "
    "transformation</b> of host cells. Viruses causing cancer are called <b>Oncoviruses</b>. "
    "They account for approximately 15-20% of all human cancers worldwide."
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Major Oncogenic Viruses (Oncoviruses)", h2_style))
onc_headers = ["Virus", "Family", "Oncogene/Mechanism", "Associated Cancer"]
onc_rows = [
    ["EBV (HHV-4)", "Herpesviridae", "LMP-1, LMP-2 -> NF-kB activation", "Burkitt's lymphoma, Hodgkin's lymphoma, Nasopharyngeal carcinoma"],
    ["HPV 16 & 18", "Papillomaviridae", "E6 degrades p53; E7 inactivates pRb", "Cervical carcinoma, Head & neck cancer, Anal cancer"],
    ["HBV", "Hepadnaviridae", "HBx protein -> Src kinase, p53 interaction; insertional mutagenesis", "Hepatocellular carcinoma (HCC)"],
    ["HCV", "Flaviviridae", "NS5A, Core protein; chronic inflammation -> cirrhosis -> HCC", "Hepatocellular carcinoma, B-cell lymphoma"],
    ["HTLV-1", "Retroviridae", "Tax protein -> NF-kB -> IL-2R/IL-2 autocrine loop", "Adult T-cell Leukemia/Lymphoma (ATLL)"],
    ["HHV-8 (KSHV)", "Herpesviridae", "v-cyclin, v-FLIP, LANA protein", "Kaposi's sarcoma, Primary effusion lymphoma"],
    ["MCV (Merkel Cell Polyomavirus)", "Polyomaviridae", "sT antigen -> Rb inactivation", "Merkel cell carcinoma"],
]
story.append(make_table(onc_headers, onc_rows, [0.16, 0.18, 0.32, 0.34]))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Flowchart: Mechanisms of Viral Oncogenesis", h2_style))
fc8a = [
    "VIRAL INFECTION OF HOST CELL",
    "          |",
    "    +------+--------------------------------------------------+",
    "    |                                                          |",
    " DIRECT MECHANISMS                            INDIRECT MECHANISMS",
    "    |                                               |",
    " +--+---------------------------+        Chronic Inflammation &",
    " |                              |        Immune Evasion",
    " | 1. INSERTIONAL MUTAGENESIS   |        (HBV, HCV -> Cirrhosis -> HCC)",
    " |  Viral DNA integrates near   |",
    " |  proto-oncogenes -> activates|",
    " |  them OR disrupts tumor      |",
    " |  suppressor genes            |",
    " |  (e.g., HBV integration)     |",
    " |                              |",
    " | 2. VIRAL ONCOGENES (v-onc)   |",
    " |  Virus carries oncogenes     |",
    " |  transduced from host cells  |",
    " |  v-src (RSV): tyrosine kinase|",
    " |  v-myc, v-ras, v-erbB        |",
    " |  -> Constitutively active    |",
    " |  -> Uncontrolled proliferation|",
    " |                              |",
    " | 3. INACTIVATION OF TUMOR     |",
    " |    SUPPRESSOR GENES          |",
    " |  HPV E6 -> p53 degradation   |",
    " |    (via ubiquitin pathway)   |",
    " |  HPV E7 -> binds pRb ->      |",
    " |    releases E2F -> S-phase   |",
    " |  HBx -> interacts with p53   |",
    " |                              |",
    " | 4. TRANSACTIVATION           |",
    " |  Viral proteins activate     |",
    " |  host cell growth genes      |",
    " |  HTLV-1 Tax -> NF-kB ->      |",
    " |    IL-2R expression ->       |",
    " |    T-cell proliferation      |",
    " |  EBV LMP-1 -> NF-kB pathway  |",
    " +------------------------------+",
    "          |",
    "  Loss of cell cycle control",
    "  Resistance to apoptosis",
    "  Genomic instability",
    "          |",
    "          v",
    "    MALIGNANT TRANSFORMATION",
]
story.append(flowchart_box(fc8a))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Viral Oncogenes vs. Proto-Oncogenes (c-onc)", h2_style))
comp_headers = ["Feature", "Proto-oncogene (c-onc)", "Viral oncogene (v-onc)"]
comp_rows = [
    ["Location", "Normal host genome", "Carried in retroviral genome"],
    ["Regulation", "Tightly regulated", "Unregulated / Constitutively active"],
    ["Function", "Normal cell growth signals", "Drives uncontrolled cell proliferation"],
    ["Origin", "Cellular", "Transduced from host proto-oncogene"],
    ["Example", "c-src, c-myc, c-ras, c-erbB", "v-src (RSV), v-myc, v-ras"],
]
story.append(make_table(comp_headers, comp_rows, [0.22, 0.39, 0.39]))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph("Flowchart: HPV-Induced Cervical Oncogenesis (Key Exam Example)", h2_style))
fc8b = [
    "HPV 16/18 infects cervical basal epithelium (via micro-abrasions)",
    "          |",
    "Viral DNA integrates into host genome (E2 gene disrupted -> E6/E7 overexpressed)",
    "          |",
    "    +------+-----------------------------------+",
    "    |                                          |",
    "  E6 protein                               E7 protein",
    "  Binds p53 -> Ubiquitin-mediated          Binds Rb protein ->",
    "  degradation -> Loss of                   Releases transcription",
    "  apoptosis / DNA repair                   factor E2F ->",
    "    |                                      S-phase entry ->",
    "    +--------------------------------------+",
    "          |",
    "  Uncontrolled DNA replication",
    "  Accumulation of mutations",
    "          |",
    "  Dysplasia -> CIN I -> CIN II -> CIN III -> Cervical Carcinoma",
    "          |",
    "  Prevention: HPV vaccine (Gardasil, Cervarix) + Pap smear screening",
]
story.append(flowchart_box(fc8b, bg=ORANGE_LIGHT, border=ORANGE))
story.append(PageBreak())

# ════════════════════════════════════════════════════════════════
# QUICK REVISION TABLE
# ════════════════════════════════════════════════════════════════
story.append(section_header("*", "QUICK REVISION TABLE - All 8 Topics"))
story.append(Spacer(1, 0.3*cm))

qr_headers = ["Topic", "Key Bug/Virus", "Pathognomonic/Key Test", "Treatment (DOC)"]
qr_rows = [
    ["Plague", "Yersinia pestis", "Wayson stain: bipolar 'safety-pin'; F1-RDT", "Streptomycin / Gentamicin / Doxycycline"],
    ["Zoonoses", "Multiple (Rickettsia, Borrelia, Leishmania...)", "Vector identification; serology", "Varies by pathogen"],
    ["Emerging Viral", "HIV, Ebola, SARS-CoV-2, HPV, Nipah...", "PCR/RT-PCR; serology; viral culture", "Antivirals; supportive; vaccines"],
    ["Congenital Toxoplasmosis", "Toxoplasma gondii", "PCR amniotic fluid; IgM in neonate; CT brain (periventricular calcifications)", "Pyrimethamine + Sulfadiazine + Folinic acid x 12 months"],
    ["Congenital Syphilis", "Treponema pallidum", "VDRL/RPR screen; FTA-ABS confirm; IgM-FTA-ABS; dark-field (snuffles)", "Aqueous Penicillin G IV x 10-14 days"],
    ["Leptospirosis", "Leptospira interrogans", "MAT (gold standard serology); EMJH culture; PCR blood/urine", "IV Penicillin G (severe); Doxycycline (mild)"],
    ["Nosocomial Infections", "MRSA, Pseudomonas, E. coli, C. diff, Candida", "Site-specific cultures; NHSN criteria", "Targeted ABx + Infection Control bundles"],
    ["Viral Oncogenesis", "HPV, HBV, EBV, HTLV-1, HHV-8", "HPV: E6/E7; HBV: HBx; HTLV-1: Tax protein", "Vaccines (HPV, HBV); antivirals; screening"],
]
story.append(make_table(qr_headers, qr_rows, [0.2, 0.22, 0.33, 0.25]))
story.append(Spacer(1, 0.4*cm))

story.append(note_style and Paragraph(
    "Sources: Harrison's Principles of Internal Medicine 22E (McGraw-Hill, 2025) | "
    "Jawetz Melnick & Adelberg's Medical Microbiology 28E | "
    "Sherris & Ryan's Medical Microbiology 8E | Goldman-Cecil Medicine | Red Book 2021",
    note_style
))

# ── BUILD ─────────────────────────────────────────────────────────────────────
doc.build(story, onFirstPage=add_page_number, onLaterPages=add_page_number)
print(f"PDF generated: {OUTPUT}")
Running Command

cd /tmp/workspace/microbiology-pdf && python generate_pdf.py 2>&1

Running Command

ls -lh /tmp/workspace/microbiology-pdf/Microbiology_Miscellaneous_Topics.pdf

Your PDF is ready! Here's the download link:

Microbiology Miscellaneous Topics

PDF Document · PDF


What's included in the PDF (44 KB, fully formatted):
#TopicContents
1Lab Diagnosis of PlagueSpecimen collection, diagnostic algorithm flowchart, case classification table
2Zoonotic Infections & VectorsFull table (17 diseases), transmission routes flowchart
3Emerging Viral InfectionsTable of 12 major viruses, emergence factors flowchart
4Congenital ToxoplasmosisSabin's triad, trimester-risk flowchart, lab diagnosis flowchart
5Congenital SyphilisPathogenesis flowchart, early & late features tables, lab diagnosis
6LeptospiraPathogenesis/clinical spectrum flowchart, MAT notes, treatment
7Nosocomial InfectionsChain-of-infection flowchart, prevention bundles, MDRO summary
8Viral OncogenesisOncovirus table, mechanisms flowchart, HPV-cervical cancer pathway
*Quick Revision TableAll 8 topics - bug, key test, treatment in one page
PDF features:
  • Color-coded section headers per topic
  • All flowcharts rendered as formatted blocks
  • Highlighted definition/treatment boxes
  • Page numbers + running footer
  • A4 size, print-ready
This is a shared conversation. Sign in to Orris to start your own chat.