MBBS 1st Year Biochemistry Practical – Important Topics (Viva + Practical Exam) 1. Urine Analysis (Most Important) Normal urine constituents Abnormal urine constituents Tests for: Protein (Albumin) Glucose (Benedict's test) Ketone bodies (Rothera's test) Bile salts (Hay's test) Bile pigments (Fouchet's test) 2. Instruments & Spotters Colorimeter Spectrophotometer pH meter Centrifuge Flame photometer Electrophoresis apparatus Chromatography apparatus 3. Principles Asked in Viva Beer-Lambert law Colorimetry Spectrophotometry Buffer and pH Chromatography Electrophoresis ELISA principle 4. Estimations Blood glucose (GOD-POD method) Serum bilirubin Blood urea Serum creatinine Total protein and A:G ratio Cholesterol Triglycerides SGOT (AST) and SGPT (ALT) Alkaline phosphatase (ALP) 5. Important Clinical Cases for Viva Diabetes mellitus Jaundice Renal failure Nephrotic syndrome Proteinuria Dyslipidemia Myocardial infarction Gout Liver disease 6. Frequently Asked Viva Questions Normal blood glucose value Normal urine pH Normal serum bilirubin Normal blood urea Normal serum creatinine Functions of liver and kidney tests Causes of glycosuria and proteinuria 7. Must-Read Spotting Topics Vitamins and deficiency diseases Amino acids Carbohydrates Enzyme inhibitors Tumor markers Chromatography patterns One-Day Revision Priority 1. Urine analysis 2. Colorimeter + Beer-Lambert law 3. Blood glucose estimation 4. LFT and KFT parameters 5. Clinical case discussions (Diabetes, Jaundice, Renal failure) 6. Spotters and instruments These topics cover the majority of questions commonly asked in first-year MBBS biochemistry

Asking for Preferences
Reading File
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Running Command

mkdir -p /home/daytona/workspace/biochem-practical

Writing File

~/biochem-practical/study_notes.md

# MBBS 1st Year Biochemistry Practical – Complete Revision Notes

---

## SECTION 1: URINE ANALYSIS (Most Important)

### Normal Urine Constituents
| Parameter | Normal Value |
|---|---|
| Volume | 1000–1500 mL/day |
| pH | 4.5–8.0 (average 6.0) |
| Specific gravity | 1.003–1.030 |
| Color | Pale yellow to amber (due to urochrome) |
| Odor | Aromatic (due to volatile acids) |
| Turbidity | Clear |

**Organic constituents:** Urea (largest component – 25–30 g/day), creatinine (1–2 g/day), uric acid (0.5–1 g/day), ammonia, hippuric acid, amino acids (trace), vitamins.

**Inorganic constituents:** NaCl (largest inorganic – 10–15 g/day), phosphates, sulfates, potassium, calcium.

---

### Abnormal Urine Constituents
| Substance | Condition |
|---|---|
| Protein (albumin) | Nephrotic syndrome, glomerulonephritis, UTI |
| Glucose | Diabetes mellitus, renal glycosuria |
| Ketone bodies | Diabetic ketoacidosis, starvation, prolonged vomiting |
| Bile pigments (bilirubin) | Obstructive/hepatic jaundice |
| Bile salts | Obstructive jaundice |
| Blood (hematuria) | UTI, renal stones, glomerulonephritis |
| Pus (pyuria) | UTI, renal TB |
| Casts | Renal tubular damage, nephrotic syndrome |

---

### Test 1: Protein (Albumin) – Heat Coagulation Test
**Principle:** Protein denatures and precipitates on heating at acidic pH.

**Procedure:**
1. Fill 2/3 of a test tube with urine
2. Tilt and heat the upper portion over a flame until it boils
3. Add 2–3 drops of 1% acetic acid (to precipitate albumin, not phosphates)
4. Compare with unheated lower portion

**Result:** White turbidity = protein positive

**Other tests:** Sulphosalicylic acid test (turbidity with SSA), Roberts ring test (ring at junction of urea solution and urine)

---

### Test 2: Glucose – Benedict's Test
**Principle:** Glucose (reducing sugar) reduces Cu²⁺ (cupric) to Cu⁺ (cuprous) in alkaline medium, forming brick-red cuprous oxide precipitate.

**Reagent:** Benedict's reagent = sodium citrate + sodium carbonate + copper sulphate

**Procedure:**
1. Take 5 mL Benedict's reagent in a test tube
2. Add 8 drops of urine
3. Boil for 2 minutes OR place in boiling water bath for 5 minutes
4. Observe color change

**Results:**
| Color | Glucose level |
|---|---|
| Blue (no change) | Negative (<0.5%) |
| Green precipitate | Trace (+) |
| Yellow precipitate | 0.5–1% (++) |
| Orange precipitate | 1–2% (+++) |
| Brick-red precipitate | >2% (++++) |

**Note:** Benedict's test detects ALL reducing sugars (galactose, fructose, lactose, maltose). To confirm glucose specifically, use glucose oxidase test.

---

### Test 3: Ketone Bodies – Rothera's Test
**Principle:** Acetone and acetoacetic acid react with sodium nitroprusside in alkaline medium to form a purple/violet ring.

**Reagent:** Rothera's reagent = ammonium sulphate + sodium nitroprusside (sodium nitroferricyanide)

**Procedure:**
1. Fill test tube half with urine
2. Add excess Rothera's reagent (solid, enough to saturate)
3. Mix gently to dissolve
4. Carefully layer concentrated ammonia solution along the side of the test tube

**Result:** Purple/violet ring at junction = ketone bodies present

**Note:** Beta-hydroxybutyrate does NOT react (no keto group). Rothera's detects only acetone and acetoacetate.

---

### Test 4: Bile Salts – Hay's Test (Sulphur Flower Test)
**Principle:** Bile salts lower surface tension of urine. When sulphur powder is sprinkled on urine, it sinks if bile salts are present (because surface tension is reduced).

**Procedure:**
1. Take urine in a beaker
2. Sprinkle powdered sulphur (flowers of sulphur) on the surface
3. Observe whether sulphur floats or sinks

**Result:**
- Sulphur sinks = Bile salts PRESENT
- Sulphur floats = Bile salts ABSENT

---

### Test 5: Bile Pigments – Fouchet's Test
**Principle:** Fouchet's reagent (ferric chloride in trichloroacetic acid) oxidizes bilirubin to biliverdin, which is green in color.

**Procedure:**
1. Take 10 mL urine, add 5 mL of 10% barium chloride solution
2. Mix and filter (barium precipitates bile pigments)
3. Spread filter paper flat, add 1–2 drops of Fouchet's reagent to the precipitate on the paper

**Result:** Green color on filter paper = bile pigments (bilirubin) present

**Note:** Fouchet's reagent = 25g trichloroacetic acid + 10 mL of 10% FeCl₃ in 100 mL water

---

## SECTION 2: INSTRUMENTS & SPOTTERS

### Colorimeter
- **Purpose:** Measures intensity of colored solutions
- **Principle:** Beer-Lambert law – absorbance is proportional to concentration
- **Components:** Light source → Filter → Cuvette → Photodetector → Galvanometer
- **Uses in lab:** Blood glucose, bilirubin, urea, protein estimation
- **Light source:** Tungsten lamp (visible light, 400–700 nm)
- **Key difference from spectrophotometer:** Uses filters (not monochromators), less precise

### Spectrophotometer
- **Purpose:** Measures absorbance at specific wavelengths
- **Principle:** Beer-Lambert law; uses a monochromator (prism or diffraction grating) for precise wavelength selection
- **Components:** Light source → Monochromator → Cuvette → Detector → Readout
- **UV-Vis range:** 190–1100 nm
- **Advantages:** More precise, can use any wavelength

### pH Meter
- **Purpose:** Measures H⁺ ion concentration (pH)
- **Principle:** Potentiometry – measures electromotive force (EMF) using glass electrode + reference electrode
- **Glass electrode:** Contains HCl solution, inner reference electrode (Ag/AgCl)
- **Calibration:** Always calibrate with buffer solutions of known pH (e.g., pH 4 and pH 7)
- **Uses:** Blood gas analysis, buffer preparation

### Centrifuge
- **Purpose:** Separates components by density using centrifugal force
- **Principle:** Denser particles sediment at higher speed
- **Types:**
  - Low speed (< 10,000 rpm) – routine urine, blood separation
  - High speed (10,000–50,000 rpm) – cell organelles
  - Ultracentrifuge (>50,000 rpm) – lipoproteins, ribosomes, viruses
- **RCF (Relative Centrifugal Force):** RCF = 1.118 × 10⁻⁵ × r × N² (r = radius in cm, N = rpm)

### Flame Photometer
- **Purpose:** Measures concentration of alkali metals (Na⁺, K⁺, Li⁺)
- **Principle:** Atoms excited by flame emit characteristic wavelengths; intensity is proportional to concentration
- **Na⁺:** Yellow flame (589 nm)
- **K⁺:** Violet/lilac flame (768 nm)
- **Li⁺:** Red flame (671 nm)
- **Uses:** Serum Na⁺ and K⁺ estimation

### Electrophoresis Apparatus
- **Purpose:** Separates charged molecules (proteins, DNA, lipoproteins) based on charge and size
- **Principle:** Molecules migrate in electric field toward opposite charge; separation depends on charge-to-mass ratio
- **Types:**
  - Paper electrophoresis
  - Cellulose acetate electrophoresis (serum proteins)
  - Gel electrophoresis (SDS-PAGE for proteins, agarose for DNA)
  - Capillary electrophoresis
- **Serum protein bands (anodal to cathodal):** Albumin > α1 > α2 > β > γ globulins
- **Uses:** Hemoglobin variants, M-band in myeloma, hypo/hyperproteinemia

### Chromatography Apparatus
- **Principle:** Separation based on differential distribution between stationary and mobile phase
- **Types:**
  - **Paper chromatography (PC):** Paper is stationary phase; solvent is mobile phase; Rf value identifies substances
  - **Thin Layer Chromatography (TLC):** Silica gel on glass plate; faster than PC
  - **Column chromatography:** Stationary phase in column; sample flows through
  - **HPLC (High Performance Liquid Chromatography):** High pressure; detects HbA1c, vitamins, drugs
  - **Ion exchange chromatography:** Separates based on charge; used for amino acids
  - **Gel filtration (molecular sieve):** Separates by molecular size
  - **Affinity chromatography:** Ligand-specific binding; used for enzyme purification
- **Rf value:** Distance traveled by substance / Distance traveled by solvent (range 0–1)

---

## SECTION 3: PRINCIPLES – VIVA ESSENTIALS

### Beer-Lambert Law
**Statement:** The absorbance of a solution is directly proportional to the concentration of the solute AND the path length of light through the solution.

**Formula:** A = ε × c × l
- A = Absorbance (optical density)
- ε = Molar extinction coefficient (L·mol⁻¹·cm⁻¹)
- c = Concentration (mol/L)
- l = Path length (cm)

**Also:** A = log₁₀(I₀/I) = log₁₀(1/T) where T = transmittance

**Deviations occur when:**
- Very high or very low concentrations
- Fluorescent or light-scattering solutions
- Polychromatic light is used

**Practical application:** Plot standard curve (OD vs. concentration), then read unknown concentration from the curve.

---

### Buffer and pH
- **Buffer:** A solution that resists changes in pH when small amounts of acid or base are added
- **Components:** Weak acid + its conjugate base (or weak base + conjugate acid)
- **Henderson-Hasselbalch equation:** pH = pKa + log [A⁻]/[HA]
- **Buffer capacity:** Maximum at pH = pKa; efficient within ±1 pH unit of pKa
- **Blood buffers:**
  1. Bicarbonate buffer (most important in plasma): H₂CO₃/HCO₃⁻ (pKa 6.1, ratio 1:20 at pH 7.4)
  2. Phosphate buffer (intracellular, urine): H₂PO₄⁻/HPO₄²⁻
  3. Protein buffer (albumin, hemoglobin)
  4. Hemoglobin buffer (most important intracellular blood buffer)

---

### ELISA Principle
**ELISA = Enzyme-Linked Immunosorbent Assay**

**Principle:** Antigen-antibody reaction detected by enzyme-labeled antibody; enzyme converts substrate to colored product measured photometrically.

**Types:**
1. **Direct ELISA:** Antigen coated on plate → enzyme-labeled antibody added → substrate added → color measured
2. **Indirect ELISA:** Antigen → primary antibody → enzyme-labeled secondary antibody → substrate
3. **Sandwich ELISA:** Capture antibody → antigen → detection antibody → enzyme-labeled antibody (most sensitive)
4. **Competitive ELISA:** Competes between labeled and unlabeled antigen

**Uses:** HIV diagnosis, hepatitis B (HBsAg), pregnancy test (hCG), hormone assays, tumor markers

---

## SECTION 4: BIOCHEMICAL ESTIMATIONS

### Blood Glucose – GOD-POD Method
**Full name:** Glucose Oxidase–Peroxidase method

**Principle (2-step enzymatic reaction):**
1. Glucose + O₂ → Gluconic acid + H₂O₂ (by Glucose Oxidase)
2. H₂O₂ + 4-aminoantipyrine + phenol → Quinoneimine dye (pink/red) + H₂O (by Peroxidase – Trinder's reaction)

**Intensity of pink color is proportional to glucose concentration (read at 505 nm)**

**Normal Values:**
| Test | Value |
|---|---|
| Fasting blood glucose | 70–110 mg/dL (3.9–6.1 mmol/L) |
| Post-prandial (2h) | <140 mg/dL |
| Random | <200 mg/dL |
| HbA1c (diabetic control) | <7% |

**Advantages:** Specific for D-glucose; not affected by other reducing sugars

---

### Serum Bilirubin – Van den Bergh Test (Jendrassik-Grof Method)
**Principle:** Bilirubin reacts with diazotized sulphanilic acid to form azobilirubin (pink/red).
- **Direct bilirubin (conjugated):** Reacts directly with diazo reagent in aqueous medium
- **Indirect bilirubin (unconjugated):** Requires alcohol (methanol) as an accelerator to react
- **Total bilirubin** = Direct + Indirect

**Normal values:**
| Fraction | Value |
|---|---|
| Total bilirubin | 0.2–1.2 mg/dL |
| Direct (conjugated) | 0–0.4 mg/dL |
| Indirect (unconjugated) | 0.2–0.8 mg/dL |

---

### Blood Urea – Diacetyl Monoxime Method / Urease Method
**Diacetyl monoxime method:** Urea reacts with diacetyl monoxime in acidic conditions with heat to form a yellow Diazine compound (read at 540 nm).

**Urease method:** Urea → NH₃ + CO₂ (by urease) → NH₃ reacts with Nessler's reagent to give yellow color, OR with Berthelot reaction (phenol + hypochlorite → indophenol blue).

**Normal values:** Blood urea: 10–40 mg/dL | BUN (Blood Urea Nitrogen): 7–20 mg/dL

---

### Serum Creatinine – Jaffe's Method
**Principle:** Creatinine reacts with picric acid in alkaline medium to form an orange-red complex (Jaffe reaction). Read at 520 nm.

**Normal values:**
| Sex | Value |
|---|---|
| Males | 0.7–1.4 mg/dL |
| Females | 0.5–1.1 mg/dL |

**GFR:** Creatinine clearance = (U × V) / P (U = urine creatinine, V = urine volume/min, P = plasma creatinine). Normal: 80–120 mL/min.

---

### Total Protein and A:G Ratio
**Biuret method:** Peptide bonds react with Cu²⁺ in alkaline medium to form a violet/purple complex. Read at 540 nm.

**Normal values:**
| Parameter | Value |
|---|---|
| Total protein | 6.0–8.0 g/dL |
| Albumin | 3.5–5.0 g/dL |
| Globulin | 2.0–3.5 g/dL |
| A:G ratio | 1.5–2.5:1 |

**Albumin estimation:** Bromocresol green (BCG) dye-binding method.

**Reversed A:G ratio (< 1):** Cirrhosis, nephrotic syndrome, malnutrition, multiple myeloma.

---

### Cholesterol – Liebermann-Burchard / Enzymatic Method
**Liebermann-Burchard:** Cholesterol + acetic anhydride + conc. H₂SO₄ → green/blue color. Older method.

**Enzymatic (CHOD-PAP):**
1. Cholesterol esters → Cholesterol + fatty acids (by Cholesterol Esterase)
2. Cholesterol + O₂ → Cholest-4-en-3-one + H₂O₂ (by Cholesterol Oxidase)
3. H₂O₂ + 4-aminoantipyrine + phenol → Quinoneimine (red) (by Peroxidase)

**Normal values:**
| Parameter | Value |
|---|---|
| Total cholesterol | <200 mg/dL |
| LDL cholesterol | <100 mg/dL (optimal) |
| HDL cholesterol | >40 mg/dL (males), >50 mg/dL (females) |
| Triglycerides | <150 mg/dL |

---

### Liver Function Tests (LFT)
| Test | Normal Value | Elevated In |
|---|---|---|
| SGOT/AST | 10–40 IU/L | MI, hepatitis, muscle disease |
| SGPT/ALT | 7–56 IU/L | Hepatitis, fatty liver (more liver-specific) |
| ALP | 44–147 IU/L | Cholestasis, bone disease, hepatitis |
| Total protein | 6–8 g/dL | — |
| Albumin | 3.5–5 g/dL | Low in cirrhosis |
| Total bilirubin | 0.2–1.2 mg/dL | Jaundice of any cause |
| GGT | 8–61 IU/L | Alcohol liver disease, cholestasis |
| PT/INR | 11–13 sec / 0.9–1.1 | Liver synthetic failure |

**De Ritis ratio (AST:ALT):**
- >2:1 → Alcoholic liver disease
- <1:1 → Viral hepatitis

---

### Kidney Function Tests (KFT)
| Test | Normal Value | Elevated In |
|---|---|---|
| Blood urea | 10–40 mg/dL | Renal failure, dehydration, high protein diet |
| Serum creatinine | 0.7–1.4 mg/dL | Renal failure, rhabdomyolysis |
| Uric acid | 2.5–7 mg/dL (M), 1.5–6 (F) | Gout, renal failure, tumor lysis |
| GFR/Creatinine clearance | 80–120 mL/min | Low in CKD |
| Serum Na⁺ | 135–145 mEq/L | — |
| Serum K⁺ | 3.5–5.0 mEq/L | High in renal failure |

---

## SECTION 5: CLINICAL CASES FOR VIVA

### Diabetes Mellitus
**Urine findings:** Glycosuria (glucose +), ketonuria (in type 1 DKA), microalbuminuria (early nephropathy)
**Blood findings:** Fasting glucose >126 mg/dL; HbA1c >6.5%
**Biochemical basis:** Insulin deficiency → hyperglycemia → exceeds renal threshold (180 mg/dL) → glycosuria
**Renal threshold for glucose:** 180 mg/dL

---

### Jaundice
**Types and urine findings:**
| Type | Urine Bilirubin | Urine Urobilinogen | Urine Bile Salts |
|---|---|---|---|
| Hemolytic (pre-hepatic) | Absent | Increased | Absent |
| Hepatocellular (hepatic) | Present | Variable | Present |
| Obstructive (post-hepatic) | Present (↑↑) | Absent | Present |

**Key:** Conjugated bilirubin is water-soluble → appears in urine. Unconjugated is bound to albumin → does NOT appear in urine.

---

### Renal Failure
**Acute:** Oliguria, elevated creatinine/urea, hyperkalemia, metabolic acidosis
**Chronic (CKD):** Uremia, anemia (↓EPO), hyperphosphatemia, hypocalcemia, hypertension
**Urine:** Protein +, casts (granular, waxy), hematuria
**Nephrotic syndrome:** Protein >3.5 g/day, hypoalbuminemia, edema, hyperlipidemia, lipiduria

---

### Myocardial Infarction – Cardiac Biomarkers
| Marker | Rises | Peaks | Returns to normal |
|---|---|---|---|
| Troponin I/T | 3–6 h | 24–48 h | 7–14 days |
| CK-MB | 4–8 h | 12–24 h | 2–3 days |
| Myoglobin | 1–3 h | 6–12 h | 1–2 days |
| LDH | 24–48 h | 3–5 days | 10–14 days |

**SGOT (AST)** also rises in MI (4–8 h, peak 18–36 h). That's why AST is part of LFT and was historically used for MI.

---

### Gout
**Cause:** Hyperuricemia → uric acid crystals in joints (monosodium urate)
**Normal uric acid:** Males 3.5–7 mg/dL; Females 2.5–6 mg/dL
**Gout diagnosis:** >7 mg/dL in males; needle-shaped crystals under microscope
**Biochemistry:** Purine catabolism → hypoxanthine → xanthine → uric acid (by xanthine oxidase)
**Treatment:** Allopurinol (xanthine oxidase inhibitor)

---

### Dyslipidemia
- **Primary hypercholesterolemia:** ↑LDL (familial hypercholesterolemia – LDL receptor defect)
- **Hypertriglyceridemia:** ↑VLDL, ↑chylomicrons
- **Cardiovascular risk:** LDL is atherogenic; HDL is protective
- **Friedewald formula:** LDL = Total cholesterol - HDL - (TG/5)

---

## SECTION 6: FREQUENTLY ASKED VIVA QUESTIONS

| Question | Answer |
|---|---|
| Normal fasting blood glucose | 70–110 mg/dL |
| Normal urine pH | 4.5–8.0 (average 6.0) |
| Normal serum bilirubin | 0.2–1.2 mg/dL |
| Normal blood urea | 10–40 mg/dL |
| Normal serum creatinine | 0.7–1.4 mg/dL (males) |
| Renal threshold for glucose | 180 mg/dL |
| Glycosuria without diabetes | Renal glycosuria (low renal threshold) |
| Proteinuria causes | Nephrotic syndrome, glomerulonephritis, fever, exercise, preeclampsia |
| Most sensitive LFT | ALT (SGPT) for hepatocellular damage |
| Enzyme specific for liver | ALT (SGPT) and GGT |
| Functions tested by LFT | Synthetic (albumin, PT), excretory (bilirubin), cellular (AST, ALT, ALP) |

---

## SECTION 7: SPOTTING TOPICS

### Vitamins and Deficiency Diseases
| Vitamin | Deficiency Disease | Key Feature |
|---|---|---|
| A (Retinol) | Night blindness, Xerophthalmia | Fat-soluble |
| B1 (Thiamine) | Beriberi (dry/wet), Wernicke's | Coenzyme: TPP |
| B2 (Riboflavin) | Angular stomatitis, glossitis | Coenzyme: FAD/FMN |
| B3 (Niacin) | Pellagra (3 D's: Diarrhea, Dermatitis, Dementia) | NAD/NADP |
| B6 (Pyridoxine) | Peripheral neuropathy, sideroblastic anemia | Coenzyme: PLP |
| B9 (Folate) | Megaloblastic anemia, NTDs | Coenzyme: THF |
| B12 (Cobalamin) | Megaloblastic anemia, subacute combined degeneration | Pernicious anemia (IF deficiency) |
| C (Ascorbic acid) | Scurvy (perifollicular hemorrhage, gum bleeding) | Collagen hydroxylation |
| D (Calciferol) | Rickets (child), Osteomalacia (adult) | Ca²⁺/phosphate metabolism |
| E (Tocopherol) | Hemolytic anemia (neonate), neurodegeneration | Antioxidant |
| K | Bleeding disorder (↑PT), hemorrhagic disease of newborn | Clotting factors II, VII, IX, X |

---

### Amino Acids Classification
| Type | Examples |
|---|---|
| Essential (9) | Val, Leu, Ile, Lys, Met, Phe, Thr, Trp, His |
| Non-essential | Gly, Ala, Ser, Asp, Glu, Asn, Gln, Arg, Tyr, Cys, Pro |
| Acidic | Asp, Glu |
| Basic | Lys, Arg, His |
| Aromatic | Phe, Tyr, Trp |
| Sulfur-containing | Met, Cys |
| Glucogenic | Most amino acids |
| Ketogenic only | Leu, Lys |

---

### Carbohydrates
| Test | Result | What it detects |
|---|---|---|
| Molisch test | Purple ring | All carbohydrates |
| Benedict's test | Brick-red | Reducing sugars |
| Seliwanoff's test | Red color (faster) | Ketoses (fructose) |
| Bial's test | Blue-green | Pentoses |
| Barfoed's test | Red precipitate | Monosaccharides (not disaccharides) |
| Iodine test | Blue-black | Starch |
| Fehling's test | Brick-red | Reducing sugars |

---

### Enzyme Inhibitors
| Type | Mechanism | Example |
|---|---|---|
| Competitive | Resembles substrate; binds active site; reversible | Malonate (inhibits succinate DH), Statins (HMG-CoA reductase) |
| Non-competitive | Binds allosteric site; doesn't affect substrate binding | Heavy metals (Hg²⁺, Pb²⁺) |
| Uncompetitive | Binds enzyme-substrate complex only | Lithium (inositol monophosphatase) |
| Irreversible | Covalent binding | Organophosphates (acetylcholinesterase), aspirin (COX) |
| Suicide inhibitor | Mechanism-based irreversible | Allopurinol → oxypurinol (xanthine oxidase) |

**Vmax and Km in inhibition:**
| Inhibitor | Vmax | Km |
|---|---|---|
| Competitive | Unchanged | Increased |
| Non-competitive | Decreased | Unchanged |
| Uncompetitive | Decreased | Decreased |

---

### Tumor Markers
| Marker | Tumor |
|---|---|
| AFP (Alpha-fetoprotein) | Hepatocellular carcinoma, germ cell tumors |
| CEA | Colorectal carcinoma |
| PSA | Prostate carcinoma |
| CA 125 | Ovarian carcinoma |
| CA 19-9 | Pancreatic carcinoma |
| CA 15-3 | Breast carcinoma |
| β-hCG | Choriocarcinoma, hydatidiform mole |
| LDH | Lymphoma, leukemia (non-specific) |
| NSE | Neuroblastoma, small cell lung Ca |

---

## ONE-DAY REVISION PRIORITY CHECKLIST
- [ ] Urine tests: Heat coagulation, Benedict's, Rothera's, Hay's, Fouchet's
- [ ] Normal urine values and abnormal constituents
- [ ] Beer-Lambert law formula and applications
- [ ] Colorimeter vs Spectrophotometer differences
- [ ] GOD-POD method for blood glucose
- [ ] Normal blood glucose, bilirubin, urea, creatinine values
- [ ] LFT panel: AST, ALT, ALP, bilirubin, albumin, PT
- [ ] KFT panel: urea, creatinine, uric acid, GFR
- [ ] Jaundice types: urine bilirubin + urobilinogen findings
- [ ] Cardiac biomarkers and their timings
- [ ] Vitamin deficiency diseases
- [ ] Enzyme inhibitor types: Vmax and Km changes
- [ ] Tumor markers (at least 5 important ones)

---

*All content sourced from standard MBBS biochemistry curriculum and Tietz Textbook of Laboratory Medicine.*
Writing File

~/biochem-practical/create_pptx.js

const pptxgen = require("pptxgenjs");
const pres = new pptxgen();
pres.layout = 'LAYOUT_16x9';
pres.title = 'MBBS 1st Year Biochemistry Practical';
pres.author = 'Orris AI';

// ─── Color Palette ───────────────────────────────────────────────────────────
const C = {
  navy:    "1A2B5E",   // primary dark
  teal:    "0E7C7B",   // accent green-blue
  amber:   "F4A623",   // highlight
  white:   "FFFFFF",
  offWhite:"F0F4FF",
  light:   "D6E4F0",
  red:     "C0392B",
  gray:    "555555",
  darkBg:  "0D1B3E",
  rowEven: "E8F0FE",
  rowOdd:  "FFFFFF",
};

// ─── Helper: slide background ────────────────────────────────────────────────
function setNavyBg(slide) {
  slide.background = { color: C.darkBg };
}
function setOffWhiteBg(slide) {
  slide.background = { color: C.offWhite };
}

// ─── Helper: section header bar ──────────────────────────────────────────────
function addHeaderBar(slide, text, sub) {
  slide.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.1, fill: { color: C.navy } });
  slide.addText(text, { x: 0.3, y: 0.1, w: 9.4, h: 0.6, fontSize: 22, bold: true, color: C.white, margin: 0 });
  if (sub) {
    slide.addText(sub, { x: 0.3, y: 0.68, w: 9.4, h: 0.38, fontSize: 12, color: C.amber, margin: 0 });
  }
}

// ─── Helper: accent line ─────────────────────────────────────────────────────
function accentLine(slide, y) {
  slide.addShape(pres.ShapeType.rect, { x: 0.3, y, w: 1.2, h: 0.06, fill: { color: C.teal } });
}

// ─── Helper: table builder ───────────────────────────────────────────────────
function makeTable(slide, headers, rows, x, y, w, h) {
  const colW = headers.map(() => w / headers.length);
  const tableRows = [];
  // header
  tableRows.push(headers.map(h => ({
    text: h,
    options: { bold: true, color: C.white, fill: C.navy, fontSize: 10, align: "center", valign: "middle" }
  })));
  rows.forEach((row, i) => {
    const fill = i % 2 === 0 ? C.rowEven : C.rowOdd;
    tableRows.push(row.map(cell => ({
      text: cell,
      options: { fill, fontSize: 9, color: C.gray, valign: "middle" }
    })));
  });
  slide.addTable(tableRows, { x, y, w, h, colW, border: { type: "solid", color: C.light, pt: 0.5 }, rowH: 0.28 });
}

// ─── Helper: bullet box ──────────────────────────────────────────────────────
function bulletBox(slide, items, x, y, w, h, fontSize=11) {
  const textArr = items.map((item, idx) => ({
    text: item,
    options: { bullet: { type: "bullet" }, color: C.gray, fontSize, breakLine: idx < items.length - 1 }
  }));
  slide.addText(textArr, { x, y, w, h, valign: "top" });
}

// ─── Helper: color chip label ────────────────────────────────────────────────
function chipLabel(slide, text, x, y, bgColor, textColor=C.white, fontSize=10) {
  slide.addShape(pres.ShapeType.roundRect, { x, y, w: 1.5, h: 0.32, fill: { color: bgColor }, line: { color: bgColor }, rectRadius: 0.08 });
  slide.addText(text, { x, y, w: 1.5, h: 0.32, fontSize, bold: true, color: textColor, align: "center", valign: "middle", margin: 0 });
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 1 – Title Slide
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setNavyBg(s);
  s.addShape(pres.ShapeType.rect, { x: 0, y: 4.2, w: 10, h: 1.4, fill: { color: C.teal }, line: { color: C.teal } });
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 0.22, h: 5.625, fill: { color: C.amber }, line: { color: C.amber } });
  s.addText("MBBS 1st Year", { x: 0.5, y: 0.5, w: 9, h: 0.55, fontSize: 18, color: C.amber, bold: false, margin: 0 });
  s.addText("BIOCHEMISTRY\nPRACTICAL", { x: 0.5, y: 1.0, w: 9, h: 1.8, fontSize: 42, bold: true, color: C.white, align: "left", margin: 0 });
  s.addText("Complete Revision Notes", { x: 0.5, y: 2.8, w: 9, h: 0.55, fontSize: 20, color: C.light, margin: 0 });
  s.addText("Viva + Practical Exam Preparation", { x: 0.5, y: 4.32, w: 9, h: 0.55, fontSize: 16, color: C.white, bold: true, margin: 0 });
  s.addText("Urine Analysis • Instruments • Estimations • Clinical Cases • Spotters", {
    x: 0.5, y: 4.92, w: 9, h: 0.4, fontSize: 10, color: C.offWhite, margin: 0
  });
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 2 – Table of Contents
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Contents at a Glance", "7 Key Sections for Exam Preparation");
  const sections = [
    ["01", "Urine Analysis", "Tests, Normal & Abnormal Constituents"],
    ["02", "Instruments & Principles", "Colorimeter, Spectrophotometer, Beer-Lambert"],
    ["03", "Biochemical Estimations", "GOD-POD, Jaffe, Biuret, Van den Bergh"],
    ["04", "LFT & KFT Parameters", "Normal values, clinical significance"],
    ["05", "Clinical Case Viva", "Diabetes, Jaundice, Renal Failure, MI"],
    ["06", "Spotters", "Vitamins, Amino Acids, Tumor Markers"],
    ["07", "Rapid-Fire Q&A", "Top 20 viva questions with answers"],
  ];
  sections.forEach(([num, title, desc], i) => {
    const y = 1.2 + i * 0.6;
    s.addShape(pres.ShapeType.rect, { x: 0.3, y, w: 0.5, h: 0.38, fill: { color: C.teal }, line: { color: C.teal } });
    s.addText(num, { x: 0.3, y, w: 0.5, h: 0.38, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
    s.addText(title, { x: 0.9, y: y + 0.01, w: 3.2, h: 0.22, fontSize: 13, bold: true, color: C.navy, margin: 0 });
    s.addText(desc, { x: 0.9, y: y + 0.2, w: 8.5, h: 0.18, fontSize: 9, color: C.gray, margin: 0 });
  });
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 3 – Urine Analysis Overview
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Section 1 – Urine Analysis", "Normal constituents, abnormal findings");
  
  // Left panel – normal values
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.2, w: 4.2, h: 3.8, fill: { color: C.white }, line: { color: C.light } });
  s.addText("Normal Urine Parameters", { x: 0.4, y: 1.25, w: 4.0, h: 0.35, fontSize: 12, bold: true, color: C.navy, margin: 0 });
  makeTable(s,
    ["Parameter", "Normal Value"],
    [
      ["Volume/day", "1000–1500 mL"],
      ["pH", "4.5–8.0 (avg 6.0)"],
      ["Sp. Gravity", "1.003–1.030"],
      ["Color", "Pale yellow–amber"],
      ["Protein", "Absent (trace)"],
      ["Glucose", "Absent"],
      ["Ketones", "Absent"],
      ["Bile salts", "Absent"],
    ],
    0.3, 1.6, 4.2, 3.0
  );

  // Right panel – abnormal
  s.addShape(pres.ShapeType.rect, { x: 5.3, y: 1.2, w: 4.4, h: 3.8, fill: { color: C.white }, line: { color: C.light } });
  s.addText("Abnormal Findings & Causes", { x: 5.4, y: 1.25, w: 4.2, h: 0.35, fontSize: 12, bold: true, color: C.red, margin: 0 });
  makeTable(s,
    ["Substance", "Condition"],
    [
      ["Proteinuria", "Nephrotic syndrome, UTI"],
      ["Glycosuria", "Diabetes mellitus"],
      ["Ketonuria", "DKA, starvation"],
      ["Bilirubin", "Hepatic/obstructive jaundice"],
      ["Bile salts", "Obstructive jaundice"],
      ["Hematuria", "Stones, UTI, glomerulonephritis"],
      ["Casts", "Tubular damage, nephrosis"],
    ],
    5.3, 1.6, 4.4, 3.0
  );
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 4 – Urine Tests (Practical Procedures)
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Urine Tests – Practical Procedures", "Protein, Glucose, Ketones, Bile Salts, Bile Pigments");
  
  makeTable(s,
    ["Test", "Principle", "Reagent/Method", "Positive Result"],
    [
      ["Heat Coagulation\n(Protein)", "Protein denatures/precipitates on heating in acid", "Heat + 1% acetic acid", "White turbidity (persists after acid)"],
      ["Benedict's Test\n(Glucose)", "Cu²⁺ reduced to Cu⁺ by reducing sugars → Cu₂O", "Benedict's reagent\n(boil 2 min)", "Green/Yellow/Orange/Brick-red (trace to +4)"],
      ["Rothera's Test\n(Ketones)", "Acetone/acetoacetate + nitroprusside → purple ring", "Rothera's reagent + concentrated ammonia", "Purple/violet ring at junction"],
      ["Hay's Test\n(Bile Salts)", "Bile salts lower surface tension → sulphur sinks", "Flowers of sulphur sprinkled on urine", "Sulphur sinks"],
      ["Fouchet's Test\n(Bile Pigments)", "FeCl₃ oxidizes bilirubin → biliverdin (green)", "BaCl₂ precipitation + Fouchet's reagent on filter paper", "Green color on paper"],
    ],
    0.3, 1.2, 9.5, 4.2
  );
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 5 – Instruments
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Section 2 – Laboratory Instruments", "Principles and Clinical Uses");

  makeTable(s,
    ["Instrument", "Principle", "Key Feature", "Clinical Use"],
    [
      ["Colorimeter", "Beer-Lambert law; measures light absorption of colored solution", "Filters (not monochromator); 400–700 nm", "Glucose, bilirubin, urea, protein"],
      ["Spectrophotometer", "Beer-Lambert law; monochromator for precise wavelength", "Diffraction grating; UV-Vis 190–1100 nm", "All colorimetric assays + UV"],
      ["pH Meter", "Potentiometry; glass electrode EMF proportional to [H⁺]", "Glass + reference (Ag/AgCl) electrode; needs calibration", "Blood gas, buffer prep"],
      ["Centrifuge", "Centrifugal force separates by density", "Speed: Low (<10k), High (<50k), Ultra (>50k) rpm", "Urine analysis, cell separation"],
      ["Flame Photometer", "Atoms excited by flame emit characteristic wavelengths", "Na=yellow 589nm; K=violet 768nm; Li=red 671nm", "Serum Na⁺, K⁺ estimation"],
      ["Electrophoresis", "Charged molecules migrate in electric field by charge/mass ratio", "Cellulose acetate, SDS-PAGE, agarose gel", "Serum proteins, Hb variants, DNA"],
    ],
    0.3, 1.2, 9.5, 4.2
  );
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 6 – Beer-Lambert Law
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Beer-Lambert Law", "The Foundation of Colorimetric Estimations");

  // Formula box
  s.addShape(pres.ShapeType.rect, { x: 1.5, y: 1.25, w: 7, h: 1.1, fill: { color: C.navy }, line: { color: C.navy }, rectRadius: 0.12 });
  s.addText("A = ε × c × l", { x: 1.5, y: 1.3, w: 7, h: 0.65, fontSize: 32, bold: true, color: C.amber, align: "center", margin: 0 });
  s.addText("A = Absorbance | ε = Molar extinction coeff. | c = Concentration | l = Path length", {
    x: 1.5, y: 1.9, w: 7, h: 0.4, fontSize: 9, color: C.light, align: "center", margin: 0
  });

  // Left: key points
  s.addText("Key Concepts", { x: 0.4, y: 2.55, w: 4.5, h: 0.35, fontSize: 13, bold: true, color: C.navy, margin: 0 });
  bulletBox(s, [
    "A = log₁₀(I₀/I) = log₁₀(1/T), where T = Transmittance",
    "A is directly proportional to concentration (linear relationship)",
    "Standard curve: Plot A vs. known concentrations → read unknown",
    "Colorimeter uses filters; Spectrophotometer uses monochromator",
    "Best absorbance wavelength = λmax of the colored compound",
  ], 0.4, 2.9, 4.6, 2.5, 10);

  // Right: deviations
  s.addShape(pres.ShapeType.rect, { x: 5.2, y: 2.5, w: 4.5, h: 2.9, fill: { color: "FFF3CD" }, line: { color: C.amber } });
  s.addText("⚠ Deviations from Beer-Lambert Law", { x: 5.3, y: 2.55, w: 4.3, h: 0.35, fontSize: 12, bold: true, color: C.red, margin: 0 });
  bulletBox(s, [
    "Very high concentrations (>0.01 M) → molecular interactions",
    "Very low concentrations → measurement error",
    "Polychromatic (non-monochromatic) light",
    "Fluorescence or scattering by solution",
    "Chemical reactions occurring in solution",
  ], 5.3, 2.9, 4.2, 2.3, 10);
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 7 – Blood Glucose Estimation
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Section 3 – Blood Glucose (GOD-POD Method)", "Enzymatic estimation – most specific for D-glucose");

  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.2, w: 9.4, h: 1.5, fill: { color: C.white }, line: { color: C.light } });
  s.addText("Reaction Steps", { x: 0.5, y: 1.25, w: 5, h: 0.3, fontSize: 12, bold: true, color: C.navy, margin: 0 });
  s.addText("Step 1 (Glucose Oxidase):", { x: 0.5, y: 1.6, w: 3.5, h: 0.3, fontSize: 11, bold: true, color: C.teal, margin: 0 });
  s.addText("Glucose + O₂  →  Gluconic acid + H₂O₂", { x: 4.0, y: 1.6, w: 5.5, h: 0.3, fontSize: 11, color: C.gray, margin: 0 });
  s.addText("Step 2 (Peroxidase – Trinder):", { x: 0.5, y: 1.95, w: 3.5, h: 0.3, fontSize: 11, bold: true, color: C.red, margin: 0 });
  s.addText("H₂O₂ + 4-aminoantipyrine + Phenol  →  Pink Quinoneimine dye + H₂O", { x: 4.0, y: 1.95, w: 5.5, h: 0.3, fontSize: 11, color: C.gray, margin: 0 });

  s.addText("Pink color intensity ∝ Glucose concentration  |  Read at 505 nm", {
    x: 0.5, y: 2.45, w: 9, h: 0.35, fontSize: 11, bold: true, color: C.amber, align: "center", margin: 0
  });

  makeTable(s,
    ["Test", "Normal Value", "Pre-diabetes", "Diabetes"],
    [
      ["Fasting", "70–110 mg/dL", "100–125 mg/dL", "≥126 mg/dL"],
      ["2h Post-prandial", "<140 mg/dL", "140–199 mg/dL", "≥200 mg/dL"],
      ["Random", "<200 mg/dL", "—", "≥200 + symptoms"],
      ["HbA1c", "<5.7%", "5.7–6.4%", "≥6.5%"],
    ],
    0.3, 2.85, 9.4, 2.5
  );

  s.addText("Renal threshold for glucose: 180 mg/dL | Glycosuria occurs when blood glucose exceeds this threshold", {
    x: 0.5, y: 5.25, w: 9, h: 0.3, fontSize: 9, color: C.gray, italic: true, margin: 0
  });
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 8 – LFT
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Liver Function Tests (LFT)", "Normal values and clinical significance");

  makeTable(s,
    ["Test", "Normal Value", "Enzyme/Method", "Elevated In"],
    [
      ["SGPT / ALT", "7–56 IU/L", "Alanine aminotransferase", "Hepatitis, fatty liver, drug toxicity (liver-specific)"],
      ["SGOT / AST", "10–40 IU/L", "Aspartate aminotransferase", "Hepatitis, MI, muscle disease, alcoholic liver"],
      ["Alkaline Phosphatase (ALP)", "44–147 IU/L", "ALP (phosphomonoesterase)", "Cholestasis, bone disease, hepatitis"],
      ["Total Bilirubin", "0.2–1.2 mg/dL", "Van den Bergh / Jendrassik-Grof", "Jaundice of any cause"],
      ["Direct Bilirubin", "0–0.4 mg/dL", "Conjugated (water-soluble)", "Obstructive/hepatic jaundice"],
      ["Albumin", "3.5–5.0 g/dL", "BCG dye-binding", "Low in cirrhosis, nephrotic syndrome"],
      ["Total Protein", "6.0–8.0 g/dL", "Biuret method", "—"],
      ["PT / INR", "11–13 sec / 0.9–1.1", "Clotting factors (liver-synthesized)", "Liver synthetic failure, Vit K deficiency"],
    ],
    0.3, 1.2, 9.4, 4.2
  );

  s.addText("De Ritis Ratio (AST:ALT): >2:1 = Alcoholic liver disease | <1:1 = Viral hepatitis", {
    x: 0.5, y: 5.2, w: 9, h: 0.3, fontSize: 10, bold: true, color: C.teal, margin: 0
  });
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 9 – KFT
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Kidney Function Tests (KFT)", "Normal values, methods, and clinical significance");

  makeTable(s,
    ["Test", "Normal Value", "Method", "Elevated In"],
    [
      ["Blood Urea", "10–40 mg/dL (BUN: 7–20)", "Diacetyl monoxime / Urease-Berthelot", "Renal failure, dehydration, high protein diet"],
      ["Serum Creatinine", "M: 0.7–1.4 / F: 0.5–1.1 mg/dL", "Jaffe's (picric acid-alkaline)", "Renal failure, rhabdomyolysis"],
      ["Uric Acid", "M: 3.5–7 / F: 2.5–6 mg/dL", "Enzymatic (uricase)", "Gout, renal failure, tumor lysis syndrome"],
      ["GFR / Creatinine Clearance", "80–120 mL/min", "Cockcroft-Gault / CKD-EPI", "Decreased in CKD (GFR <60 for >3 months)"],
      ["Serum Na⁺", "135–145 mEq/L", "Flame photometry / ISE", "SIADH (low), diabetes insipidus (high)"],
      ["Serum K⁺", "3.5–5.0 mEq/L", "Flame photometry / ISE", "High in renal failure; Low in diarrhea/diuretics"],
    ],
    0.3, 1.2, 9.4, 3.9
  );

  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 5.1, w: 9.4, h: 0.45, fill: { color: C.darkBg }, line: { color: C.darkBg } });
  s.addText("Creatinine Clearance = (U × V) / P  |  U = urine creatinine (mg/dL), V = urine vol/min (mL/min), P = plasma creatinine (mg/dL)", {
    x: 0.4, y: 5.12, w: 9.2, h: 0.38, fontSize: 9, color: C.amber, align: "center", margin: 0
  });
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 10 – Jaundice Clinical Case
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Section 5 – Clinical Viva: Jaundice", "Types and urine/blood biochemistry findings");

  makeTable(s,
    ["Parameter", "Hemolytic (Pre-hepatic)", "Hepatocellular (Hepatic)", "Obstructive (Post-hepatic)"],
    [
      ["Urine Bilirubin", "Absent ✗", "Present ✓", "Present ++ ✓"],
      ["Urine Urobilinogen", "Increased ↑↑", "Variable (↑ or ↓)", "Absent ✗"],
      ["Urine Bile Salts", "Absent ✗", "Present ✓", "Present ✓✓"],
      ["Stool Color", "Dark (↑stercobilin)", "Normal/pale", "Pale/clay-colored"],
      ["Serum Direct Bili", "Normal", "Increased", "Increased ↑↑"],
      ["Serum Indirect Bili", "Increased ↑↑", "Increased", "Normal/slight"],
      ["ALT/AST", "Normal", "Very high ↑↑↑", "Moderate ↑"],
      ["ALP", "Normal", "Moderate ↑", "Very high ↑↑↑"],
      ["Cause", "Hemolysis, G6PD, thalassemia", "Viral/alcoholic hepatitis, cirrhosis", "Gallstones, pancreatic Ca"],
    ],
    0.3, 1.2, 9.4, 4.2
  );

  s.addText("Key: Conjugated bilirubin is water-soluble → appears in urine. Unconjugated bilirubin is albumin-bound → does NOT appear in urine.", {
    x: 0.5, y: 5.3, w: 9, h: 0.28, fontSize: 9, italic: true, color: C.navy, margin: 0
  });
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 11 – Diabetes + Renal Failure Cases
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Clinical Viva: Diabetes, Renal Failure & MI", "Key biochemical findings for viva");

  // Diabetes
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.15, w: 2.9, h: 0.38, fill: { color: C.teal }, line: { color: C.teal } });
  s.addText("Diabetes Mellitus", { x: 0.3, y: 1.15, w: 2.9, h: 0.38, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
  bulletBox(s, [
    "Urine: Glucose +, Ketones + (in DKA/T1DM), Protein + (late nephropathy)",
    "Blood glucose: Fasting >126 mg/dL, HbA1c >6.5%",
    "Renal threshold: 180 mg/dL (glycosuria above this level)",
    "Renal glycosuria: Normal blood glucose but low renal threshold",
  ], 0.3, 1.55, 4.2, 1.8, 9);

  // Renal failure
  s.addShape(pres.ShapeType.rect, { x: 5.3, y: 1.15, w: 4.4, h: 0.38, fill: { color: C.red }, line: { color: C.red } });
  s.addText("Renal Failure / Nephrotic Syndrome", { x: 5.3, y: 1.15, w: 4.4, h: 0.38, fontSize: 12, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
  bulletBox(s, [
    "Acute: Oliguria, ↑creatinine, ↑urea, hyperkalemia, metabolic acidosis",
    "Chronic (CKD): Uremia, anemia (↓EPO), ↑phosphate, ↓Ca²⁺",
    "Nephrotic: Protein >3.5g/day, hypoalbuminemia, edema, hyperlipidemia, lipiduria",
    "Urine: Protein ++, casts (granular, waxy, RBC casts in nephritic)",
  ], 5.3, 1.55, 4.4, 1.8, 9);

  // Cardiac biomarkers
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 3.5, w: 9.4, h: 0.38, fill: { color: C.navy }, line: { color: C.navy } });
  s.addText("Myocardial Infarction – Cardiac Biomarkers", { x: 0.3, y: 3.5, w: 9.4, h: 0.38, fontSize: 13, bold: true, color: C.white, align: "center", valign: "middle", margin: 0 });
  makeTable(s,
    ["Marker", "Rises At", "Peaks At", "Returns Normal"],
    [
      ["Troponin I/T (gold standard)", "3–6 hours", "24–48 hours", "7–14 days"],
      ["CK-MB", "4–8 hours", "12–24 hours", "2–3 days"],
      ["Myoglobin (earliest)", "1–3 hours", "6–12 hours", "1–2 days"],
      ["LDH (latest)", "24–48 hours", "3–5 days", "10–14 days"],
    ],
    0.3, 3.9, 9.4, 1.65
  );
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 12 – Spotters: Vitamins
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Section 6 – Spotters: Vitamins & Deficiency Diseases", "Water-soluble and fat-soluble vitamins");

  makeTable(s,
    ["Vitamin", "Name", "Deficiency Disease", "Key Biochemistry"],
    [
      ["A", "Retinol", "Night blindness, Xerophthalmia", "Fat-soluble; visual cycle rhodopsin"],
      ["B1", "Thiamine", "Beriberi (dry/wet), Wernicke's encephalopathy", "Coenzyme: TPP; pyruvate decarboxylation"],
      ["B2", "Riboflavin", "Angular stomatitis, glossitis, cheilosis", "Coenzyme: FAD, FMN"],
      ["B3", "Niacin", "Pellagra (Diarrhea, Dermatitis, Dementia)", "Coenzyme: NAD⁺, NADP⁺"],
      ["B6", "Pyridoxine", "Peripheral neuropathy, sideroblastic anemia", "Coenzyme: PLP; transamination"],
      ["B9", "Folate", "Megaloblastic anemia, Neural tube defects (NTDs)", "Coenzyme: THF; one-carbon transfer"],
      ["B12", "Cobalamin", "Megaloblastic anemia, Subacute combined degeneration", "Requires intrinsic factor (IF); pernicious anemia"],
      ["C", "Ascorbic acid", "Scurvy (perifollicular hemorrhage, gum bleeding)", "Collagen hydroxylation (Pro, Lys)"],
      ["D", "Calciferol", "Rickets (child), Osteomalacia (adult)", "Ca²⁺/phosphate metabolism; activated in kidney"],
      ["K", "Phylloquinone", "Bleeding disorder, hemorrhagic disease of newborn", "Clotting factors II, VII, IX, X; carboxylation"],
    ],
    0.3, 1.2, 9.4, 4.3
  );
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 13 – Spotters: Amino Acids & Enzyme Inhibitors
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Spotters: Amino Acids & Enzyme Inhibitors", "Classification, essential AAs, inhibitor Vmax/Km changes");

  // Left column – amino acids
  s.addShape(pres.ShapeType.rect, { x: 0.3, y: 1.2, w: 4.7, h: 4.2, fill: { color: C.white }, line: { color: C.light } });
  s.addText("Amino Acid Classification", { x: 0.4, y: 1.25, w: 4.5, h: 0.3, fontSize: 12, bold: true, color: C.navy, margin: 0 });
  makeTable(s,
    ["Type", "Examples"],
    [
      ["Essential (9)", "Val, Leu, Ile, Lys, Met, Phe, Thr, Trp, His"],
      ["Acidic", "Asp, Glu"],
      ["Basic", "Lys, Arg, His"],
      ["Aromatic", "Phe, Tyr, Trp"],
      ["Sulfur-containing", "Met, Cys"],
      ["Ketogenic ONLY", "Leu, Lys"],
      ["Both keto+gluco", "Phe, Tyr, Trp, Ile, Thr"],
    ],
    0.3, 1.6, 4.7, 3.7
  );

  // Right column – enzyme inhibitors
  s.addShape(pres.ShapeType.rect, { x: 5.2, y: 1.2, w: 4.5, h: 4.2, fill: { color: C.white }, line: { color: C.light } });
  s.addText("Enzyme Inhibitors – Vmax & Km", { x: 5.3, y: 1.25, w: 4.3, h: 0.3, fontSize: 12, bold: true, color: C.navy, margin: 0 });
  makeTable(s,
    ["Type", "Vmax", "Km", "Example"],
    [
      ["Competitive", "Unchanged", "Increased ↑", "Malonate (succinate DH), Statins"],
      ["Non-competitive", "Decreased ↓", "Unchanged", "Heavy metals (Hg²⁺, Pb²⁺)"],
      ["Uncompetitive", "Decreased ↓", "Decreased ↓", "Lithium (inositol phosphatase)"],
      ["Irreversible", "Decreased ↓", "—", "Organophosphates (AChE), Aspirin (COX)"],
    ],
    5.2, 1.6, 4.5, 3.7
  );
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 14 – Tumor Markers & Carbohydrate Tests
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Tumor Markers & Carbohydrate Tests", "Spotters must-know");

  // Left – tumor markers
  s.addText("Tumor Markers", { x: 0.4, y: 1.25, w: 4, h: 0.35, fontSize: 13, bold: true, color: C.navy, margin: 0 });
  makeTable(s,
    ["Marker", "Tumor"],
    [
      ["AFP", "Hepatocellular carcinoma, germ cell tumors"],
      ["CEA", "Colorectal carcinoma"],
      ["PSA", "Prostate carcinoma"],
      ["CA 125", "Ovarian carcinoma"],
      ["CA 19-9", "Pancreatic carcinoma"],
      ["CA 15-3", "Breast carcinoma"],
      ["β-hCG", "Choriocarcinoma, hydatidiform mole"],
      ["NSE", "Neuroblastoma, small cell lung Ca"],
    ],
    0.3, 1.6, 4.5, 3.8
  );

  // Right – carbohydrate tests
  s.addText("Carbohydrate Tests (Qualitative)", { x: 5.2, y: 1.25, w: 4.5, h: 0.35, fontSize: 13, bold: true, color: C.navy, margin: 0 });
  makeTable(s,
    ["Test", "Positive Result", "Detects"],
    [
      ["Molisch", "Purple ring", "ALL carbohydrates"],
      ["Benedict's", "Brick-red ppt", "Reducing sugars"],
      ["Seliwanoff's", "Red (fast)", "Ketoses (fructose)"],
      ["Bial's", "Blue-green", "Pentoses"],
      ["Barfoed's", "Red precipitate", "Monosaccharides (not disaccharides)"],
      ["Iodine test", "Blue-black", "Starch"],
      ["Fehling's", "Brick-red ppt", "Reducing sugars"],
    ],
    5.2, 1.6, 4.5, 3.8
  );
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 15 – Rapid-Fire Q&A
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setOffWhiteBg(s);
  addHeaderBar(s, "Section 7 – Rapid-Fire Viva Q&A", "Top questions and one-line answers");

  makeTable(s,
    ["Question", "Answer"],
    [
      ["Normal fasting blood glucose?", "70–110 mg/dL"],
      ["Normal urine pH?", "4.5–8.0 (average 6.0)"],
      ["Normal serum bilirubin?", "Total: 0.2–1.2 mg/dL"],
      ["Normal blood urea?", "10–40 mg/dL"],
      ["Normal serum creatinine (male)?", "0.7–1.4 mg/dL"],
      ["Renal threshold for glucose?", "180 mg/dL"],
      ["Rothera's test detects?", "Acetone + Acetoacetate (NOT β-OH butyrate)"],
      ["Hay's test: sulphur sinks or floats if +ve?", "Sinks (bile salts lower surface tension)"],
      ["Most liver-specific enzyme?", "ALT (SGPT)"],
      ["De Ritis ratio >2:1 suggests?", "Alcoholic liver disease"],
      ["Gold standard cardiac biomarker?", "Troponin I or Troponin T"],
      ["Enzyme inhibited by allopurinol?", "Xanthine oxidase"],
      ["Competitive inhibition: Vmax/Km?", "Vmax unchanged; Km increased"],
      ["Vitamin for collagen hydroxylation?", "Vitamin C (Ascorbic acid)"],
      ["Pellagra is deficiency of?", "Niacin (Vitamin B3) – NAD/NADP"],
    ],
    0.3, 1.2, 9.4, 4.3
  );
}

// ═══════════════════════════════════════════════════════════════════════
// SLIDE 16 – One-Day Revision Priority
// ═══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setNavyBg(s);
  s.addShape(pres.ShapeType.rect, { x: 0, y: 0, w: 10, h: 1.1, fill: { color: C.teal }, line: { color: C.teal } });
  s.addText("ONE-DAY REVISION PRIORITY", { x: 0.3, y: 0.15, w: 9.4, h: 0.55, fontSize: 24, bold: true, color: C.white, margin: 0 });
  s.addText("Focus on these 6 topics to cover >80% of common questions", { x: 0.3, y: 0.7, w: 9.4, h: 0.3, fontSize: 11, color: C.offWhite, margin: 0 });

  const priorities = [
    ["01", "Urine Analysis", "Heat coagulation, Benedict's, Rothera's, Hay's, Fouchet's procedures + normal values"],
    ["02", "Colorimeter + Beer-Lambert", "Formula A=εcl, standard curve, colorimeter vs spectrophotometer differences"],
    ["03", "Blood Glucose Estimation", "GOD-POD reaction steps, normal values table (fasting/PP/HbA1c), renal threshold 180mg/dL"],
    ["04", "LFT + KFT Parameters", "All normal values, De Ritis ratio, Jaffe's/Biuret/Van den Bergh methods"],
    ["05", "Clinical Case Discussions", "Jaundice types (urine bilirubin/urobilinogen), DM urine findings, cardiac biomarker timings"],
    ["06", "Spotters & Instruments", "Vitamin deficiency diseases, carbohydrate tests, tumor markers, enzyme inhibitor Vmax/Km"],
  ];

  priorities.forEach(([num, title, desc], i) => {
    const y = 1.2 + i * 0.71;
    s.addShape(pres.ShapeType.rect, { x: 0.3, y, w: 0.55, h: 0.52, fill: { color: C.amber }, line: { color: C.amber } });
    s.addText(num, { x: 0.3, y, w: 0.55, h: 0.52, fontSize: 18, bold: true, color: C.navy, align: "center", valign: "middle", margin: 0 });
    s.addText(title, { x: 1.0, y: y + 0.02, w: 8.7, h: 0.25, fontSize: 13, bold: true, color: C.amber, margin: 0 });
    s.addText(desc, { x: 1.0, y: y + 0.25, w: 8.7, h: 0.25, fontSize: 10, color: C.light, margin: 0 });
  });
}

// Write the file
pres.writeFile({ fileName: "/home/daytona/workspace/biochem-practical/Biochemistry_Practical_Revision.pptx" })
  .then(() => console.log("DONE: PPTX saved"))
  .catch(e => { console.error("ERROR:", e); process.exit(1); });
Running Command

cd /home/daytona/workspace/biochem-practical && node create_pptx.js 2>&1

Writing File

~/biochem-practical/create_pdf.py

#!/usr/bin/env python3
"""Generate Biochemistry Practical PDF using ReportLab"""

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.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT

# ─── Colors ──────────────────────────────────────────────────────────────────
NAVY   = colors.HexColor("#1A2B5E")
TEAL   = colors.HexColor("#0E7C7B")
AMBER  = colors.HexColor("#F4A623")
RED    = colors.HexColor("#C0392B")
LGRAY  = colors.HexColor("#F0F4FF")
DGRAY  = colors.HexColor("#555555")
WHITE  = colors.white
ROWODD = colors.HexColor("#E8F0FE")

W, H = A4
MARGIN = 1.8 * cm

doc = SimpleDocTemplate(
    "/home/daytona/workspace/biochem-practical/Biochemistry_Practical_Notes.pdf",
    pagesize=A4, leftMargin=MARGIN, rightMargin=MARGIN,
    topMargin=MARGIN, bottomMargin=MARGIN
)

styles = getSampleStyleSheet()

# Custom paragraph styles
S = {
    "title": ParagraphStyle("title", fontSize=26, textColor=WHITE,
        fontName="Helvetica-Bold", spaceAfter=4, alignment=TA_CENTER, leading=32),
    "subtitle": ParagraphStyle("subtitle", fontSize=13, textColor=LGRAY,
        fontName="Helvetica", spaceAfter=2, alignment=TA_CENTER),
    "h1": ParagraphStyle("h1", fontSize=15, textColor=WHITE,
        fontName="Helvetica-Bold", spaceBefore=10, spaceAfter=4, leading=18,
        backColor=NAVY, leftIndent=-MARGIN+1.8*cm, rightIndent=-MARGIN+1.8*cm,
        borderPad=5),
    "h2": ParagraphStyle("h2", fontSize=12, textColor=NAVY,
        fontName="Helvetica-Bold", spaceBefore=8, spaceAfter=3),
    "h3": ParagraphStyle("h3", fontSize=10.5, textColor=TEAL,
        fontName="Helvetica-Bold", spaceBefore=5, spaceAfter=2),
    "body": ParagraphStyle("body", fontSize=9.5, textColor=DGRAY,
        fontName="Helvetica", spaceAfter=2, leading=14),
    "bullet": ParagraphStyle("bullet", fontSize=9.5, textColor=DGRAY,
        fontName="Helvetica", leftIndent=14, firstLineIndent=-14,
        spaceAfter=2, leading=14, bulletText="•"),
    "note": ParagraphStyle("note", fontSize=9, textColor=RED,
        fontName="Helvetica-Oblique", spaceAfter=3, leftIndent=6),
    "formula": ParagraphStyle("formula", fontSize=12, textColor=NAVY,
        fontName="Helvetica-Bold", spaceAfter=4, alignment=TA_CENTER,
        backColor=LGRAY, borderPad=6),
    "toc": ParagraphStyle("toc", fontSize=10, textColor=NAVY,
        fontName="Helvetica", spaceAfter=3, leftIndent=8),
}

def section_heading(text):
    return [
        Spacer(1, 0.25*cm),
        Table([[Paragraph(text, S["h1"])]],
              colWidths=[W - 2*MARGIN],
              style=TableStyle([
                  ("BACKGROUND", (0,0),(-1,-1), NAVY),
                  ("TOPPADDING",(0,0),(-1,-1),6),
                  ("BOTTOMPADDING",(0,0),(-1,-1),6),
                  ("LEFTPADDING",(0,0),(-1,-1),8),
              ])),
        Spacer(1, 0.15*cm),
    ]

def make_table(headers, rows, col_widths=None):
    col_w = W - 2*MARGIN
    if col_widths:
        cw = [col_w * f for f in col_widths]
    else:
        cw = [col_w / len(headers)] * len(headers)
    
    data = [[Paragraph(f"<b>{h}</b>", ParagraphStyle("th", fontSize=9,
              textColor=WHITE, fontName="Helvetica-Bold", alignment=TA_CENTER))
             for h in headers]]
    for i, row in enumerate(rows):
        bg = ROWODD if i % 2 == 0 else WHITE
        data.append([Paragraph(str(c), ParagraphStyle("td", fontSize=8.5,
                      textColor=DGRAY, fontName="Helvetica", leading=12))
                     for c in row])
    
    ts = TableStyle([
        ("BACKGROUND", (0,0), (-1,0), NAVY),
        ("ROWBACKGROUNDS", (0,1), (-1,-1), [ROWODD, WHITE]),
        ("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#D6E4F0")),
        ("TOPPADDING",(0,0),(-1,-1),4),
        ("BOTTOMPADDING",(0,0),(-1,-1),4),
        ("LEFTPADDING",(0,0),(-1,-1),5),
        ("VALIGN",(0,0),(-1,-1),"TOP"),
    ])
    return Table(data, colWidths=cw, style=ts, repeatRows=1)

def b(text): return f"<b>{text}</b>"
def i(text): return f"<i>{text}</i>"
def teal(text): return f'<font color="#0E7C7B"><b>{text}</b></font>'
def red(text): return f'<font color="#C0392B"><b>{text}</b></font>'

# ═══════════════════════════════════════════════════════════════
story = []

# ─── COVER ───────────────────────────────────────────────────────────────────
cover_data = [[
    Paragraph("MBBS 1st YEAR", ParagraphStyle("c1", fontSize=14, textColor=AMBER,
        fontName="Helvetica-Bold", alignment=TA_CENTER)),
    Paragraph("BIOCHEMISTRY PRACTICAL", ParagraphStyle("c2", fontSize=22, textColor=WHITE,
        fontName="Helvetica-Bold", alignment=TA_CENTER)),
    Paragraph("Complete Revision Notes", ParagraphStyle("c3", fontSize=13, textColor=LGRAY,
        fontName="Helvetica", alignment=TA_CENTER)),
    Paragraph("Viva + Practical Exam | All 7 Sections", ParagraphStyle("c4", fontSize=10,
        textColor=AMBER, fontName="Helvetica", alignment=TA_CENTER)),
]]
cover_data2 = [
    [Paragraph("MBBS 1st YEAR", ParagraphStyle("c1", fontSize=14, textColor=AMBER,
        fontName="Helvetica-Bold", alignment=TA_CENTER))],
    [Paragraph("BIOCHEMISTRY PRACTICAL", ParagraphStyle("c2", fontSize=22, textColor=WHITE,
        fontName="Helvetica-Bold", alignment=TA_CENTER))],
    [Paragraph("Complete Revision Notes", ParagraphStyle("c3", fontSize=13, textColor=LGRAY,
        fontName="Helvetica", alignment=TA_CENTER))],
    [Paragraph("Viva + Practical Exam | All 7 Sections", ParagraphStyle("c4", fontSize=10,
        textColor=AMBER, fontName="Helvetica", alignment=TA_CENTER))],
]
cover_t = Table(cover_data2, colWidths=[W - 2*MARGIN],
    style=TableStyle([
        ("BACKGROUND",(0,0),(-1,-1), NAVY),
        ("TOPPADDING",(0,0),(-1,-1), 14),
        ("BOTTOMPADDING",(0,0),(-1,-1), 14),
        ("LEFTPADDING",(0,0),(-1,-1), 20),
    ]))
story.append(Spacer(1, 0.5*cm))
story.append(cover_t)
story.append(Spacer(1, 0.4*cm))

# ─── SECTION 1: URINE ANALYSIS ──────────────────────────────────────────────
story += section_heading("SECTION 1 – URINE ANALYSIS  (Most Important)")

story.append(Paragraph(b("Normal Urine Parameters"), S["h2"]))
story.append(make_table(
    ["Parameter", "Normal Value"],
    [
        ["Volume/day","1000–1500 mL"],["pH","4.5–8.0 (average 6.0)"],
        ["Specific Gravity","1.003–1.030"],["Color","Pale yellow to amber (urochrome)"],
        ["Protein","Absent / trace"],["Glucose","Absent"],
        ["Ketones","Absent"],["Bile salts/pigments","Absent"],
    ], [0.35, 0.65]
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph(b("Organic Constituents:"), S["h3"]))
story.append(Paragraph("Urea (largest, 25–30 g/day), creatinine (1–2 g/day), uric acid, ammonia, hippuric acid, amino acids (trace), vitamins.", S["body"]))
story.append(Paragraph(b("Inorganic Constituents:"), S["h3"]))
story.append(Paragraph("NaCl (largest inorganic, 10–15 g/day), phosphates, sulfates, potassium, calcium.", S["body"]))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph(b("Abnormal Urine Constituents"), S["h2"]))
story.append(make_table(
    ["Substance","Condition"],
    [
        ["Protein (albumin)","Nephrotic syndrome, glomerulonephritis, UTI, fever"],
        ["Glucose","Diabetes mellitus, renal glycosuria (low renal threshold)"],
        ["Ketone bodies","DKA, starvation, prolonged vomiting, high-fat diet"],
        ["Bile pigments","Hepatic or obstructive jaundice"],
        ["Bile salts","Obstructive jaundice"],
        ["Blood (hematuria)","UTI, renal stones, glomerulonephritis, tumors"],
        ["Pus (pyuria)","UTI, renal tuberculosis"],
        ["Casts","Renal tubular damage, nephrotic syndrome"],
    ], [0.3, 0.7]
))
story.append(Spacer(1, 0.3*cm))

story.append(Paragraph(b("Urine Tests – Practical Procedures"), S["h2"]))
story.append(make_table(
    ["Test","Principle","Reagent/Procedure","Positive Result"],
    [
        ["Heat Coagulation (Protein)","Protein denatures & precipitates on heating at acid pH","Heat top 2/3 of tube → add 1% acetic acid","White turbidity (persists after acid)"],
        ["Benedict's Test (Glucose)","Cu²⁺ → Cu⁺ (cuprous oxide) by reducing sugar in alkaline medium","5 mL Benedict's + 8 drops urine → boil 2 min","Green→Yellow→Orange→Brick-red (trace to 4+)"],
        ["Rothera's Test (Ketones)","Acetone/acetoacetate + nitroprusside → purple ring in alkali","Rothera's reagent (solid) → layer concentrated ammonia","Purple/violet ring at junction"],
        ["Hay's Test (Bile Salts)","Bile salts lower surface tension → sulphur sinks","Sprinkle flowers of sulphur on urine surface","Sulphur sinks (↓surface tension)"],
        ["Fouchet's Test (Bile Pigments)","FeCl₃ oxidizes bilirubin → biliverdin (green)","BaCl₂ precipitate on filter paper + 1–2 drops Fouchet's reagent","Green color on filter paper"],
    ], [0.18, 0.27, 0.31, 0.24]
))
story.append(Paragraph("⚠ Rothera's test does NOT detect β-hydroxybutyrate (lacks keto group). Benedict's detects ALL reducing sugars — use glucose oxidase for specificity.", S["note"]))

# ─── SECTION 2: INSTRUMENTS ─────────────────────────────────────────────────
story += section_heading("SECTION 2 – INSTRUMENTS & PRINCIPLES")

story.append(make_table(
    ["Instrument","Principle","Key Features","Clinical Uses"],
    [
        ["Colorimeter","Beer-Lambert law; absorption of colored solution","Uses filters (400–700 nm); Tungsten lamp","Blood glucose, bilirubin, urea, protein"],
        ["Spectrophotometer","Beer-Lambert law; monochromator for precise λ","Diffraction grating; UV-Vis 190–1100 nm; more precise","All colorimetric assays + UV absorption"],
        ["pH Meter","Potentiometry; glass electrode EMF ∝ [H⁺]","Glass + Ag/AgCl reference electrode; calibrate with known buffers","Blood gas analysis, buffer preparation"],
        ["Centrifuge","Centrifugal force separates by density","Low (<10k rpm), High (<50k rpm), Ultra (>50k rpm)","Urine, blood separation, cell organelles"],
        ["Flame Photometer","Excited atoms emit characteristic λ","Na=589nm (yellow), K=768nm (violet), Li=671nm (red)","Serum Na⁺ and K⁺ measurement"],
        ["Electrophoresis","Charged molecules migrate in electric field","Paper, cellulose acetate, SDS-PAGE, agarose","Serum proteins, Hb variants, DNA/RNA"],
        ["Chromatography","Differential distribution between stationary/mobile phase","Paper, TLC, Column, HPLC, Ion exchange, Affinity","Amino acids, HbA1c, vitamins, drug monitoring"],
    ], [0.18, 0.27, 0.27, 0.28]
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph(b("Beer-Lambert Law"), S["h2"]))
story.append(Table(
    [[Paragraph("A = ε × c × l", ParagraphStyle("f", fontSize=14, textColor=NAVY,
        fontName="Helvetica-Bold", alignment=TA_CENTER))]],
    colWidths=[W - 2*MARGIN],
    style=TableStyle([
        ("BACKGROUND",(0,0),(-1,-1), LGRAY),
        ("TOPPADDING",(0,0),(-1,-1),8),("BOTTOMPADDING",(0,0),(-1,-1),8),
        ("LEFTPADDING",(0,0),(-1,-1),10),
    ])
))
story.append(Spacer(1, 0.1*cm))
story.append(Paragraph("A = Absorbance | ε = molar extinction coefficient | c = concentration (mol/L) | l = path length (cm)", S["body"]))
story.append(Paragraph("Also: A = log₁₀(I₀/I) = log₁₀(1/Transmittance). Deviations occur at very high/low concentrations, polychromatic light, or fluorescent solutions.", S["body"]))
story.append(Paragraph(b("Buffer & Henderson-Hasselbalch:"), S["h3"]))
story.append(Paragraph("pH = pKa + log[A⁻]/[HA]. Blood buffers (order of importance): Bicarbonate (plasma) → Phosphate (intracellular/urine) → Hemoglobin (intracellular) → Protein.", S["body"]))

story.append(Paragraph(b("ELISA Principle"), S["h2"]))
story.append(Paragraph("Enzyme-Linked Immunosorbent Assay: Antigen–antibody reaction detected by enzyme-labeled antibody. Enzyme converts substrate to colored product measured photometrically.", S["body"]))
story.append(make_table(
    ["ELISA Type","Principle"],
    [
        ["Direct","Ag coated → enzyme-labeled Ab → substrate → color"],
        ["Indirect","Ag → primary Ab → enzyme-labeled secondary Ab → substrate"],
        ["Sandwich (most sensitive)","Capture Ab → Ag → detection Ab → enzyme-labeled Ab → substrate"],
        ["Competitive","Labeled vs. unlabeled antigen compete for Ab binding"],
    ], [0.3, 0.7]
))
story.append(Paragraph("Uses: HIV diagnosis, HBsAg, hCG (pregnancy), hormones, tumor markers, TORCH.", S["body"]))

# ─── SECTION 3: ESTIMATIONS ─────────────────────────────────────────────────
story += section_heading("SECTION 3 – BIOCHEMICAL ESTIMATIONS")

story.append(Paragraph(b("Blood Glucose – GOD-POD Method"), S["h2"]))
story.append(Paragraph("Step 1 (Glucose Oxidase): Glucose + O₂ → Gluconic acid + H₂O₂", S["body"]))
story.append(Paragraph("Step 2 (Peroxidase – Trinder): H₂O₂ + 4-aminoantipyrine + Phenol → Pink Quinoneimine dye + H₂O", S["body"]))
story.append(Paragraph("Read at 505 nm. Pink color intensity ∝ glucose concentration. Specific for D-glucose (not affected by other reducing sugars).", S["note"]))
story.append(make_table(
    ["Test","Normal","Pre-Diabetes","Diabetes Mellitus"],
    [
        ["Fasting","70–110 mg/dL","100–125 mg/dL","≥126 mg/dL"],
        ["2h Post-prandial","<140 mg/dL","140–199 mg/dL","≥200 mg/dL"],
        ["Random","<200 mg/dL","—","≥200 mg/dL + symptoms"],
        ["HbA1c","<5.7%","5.7–6.4%","≥6.5%"],
    ], [0.3, 0.23, 0.23, 0.24]
))
story.append(Spacer(1, 0.15*cm))

story.append(Paragraph(b("Serum Bilirubin – Van den Bergh / Jendrassik-Grof Method"), S["h2"]))
story.append(Paragraph("Bilirubin + diazotized sulphanilic acid → azobilirubin (pink/red). Direct (conjugated) reacts in aqueous; Indirect (unconjugated) requires methanol.", S["body"]))
story.append(make_table(
    ["Fraction","Normal Value"],
    [
        ["Total bilirubin","0.2–1.2 mg/dL"],
        ["Direct (conjugated)","0–0.4 mg/dL"],
        ["Indirect (unconjugated)","0.2–0.8 mg/dL"],
    ], [0.45, 0.55]
))
story.append(Spacer(1, 0.15*cm))

story.append(Paragraph(b("Blood Urea"), S["h2"]))
story.append(Paragraph("Diacetyl monoxime method: urea + diacetyl monoxime in acidic heat → yellow Diazine compound (540 nm). OR Urease method: urea → NH₃ → Berthelot reaction (indophenol blue).", S["body"]))
story.append(Paragraph("Normal: Blood urea 10–40 mg/dL | BUN (Blood Urea Nitrogen): 7–20 mg/dL", S["body"]))
story.append(Spacer(1, 0.1*cm))

story.append(Paragraph(b("Serum Creatinine – Jaffe's Method"), S["h2"]))
story.append(Paragraph("Creatinine + picric acid in alkaline medium → orange-red complex (Jaffe reaction). Read at 520 nm.", S["body"]))
story.append(Paragraph("Normal: Males 0.7–1.4 mg/dL | Females 0.5–1.1 mg/dL | GFR normal: 80–120 mL/min", S["body"]))
story.append(Spacer(1, 0.1*cm))

story.append(Paragraph(b("Total Protein – Biuret Method"), S["h2"]))
story.append(Paragraph("Peptide bonds + Cu²⁺ in alkaline medium → violet/purple complex. Read at 540 nm.", S["body"]))
story.append(make_table(
    ["Parameter","Normal Value"],
    [
        ["Total protein","6.0–8.0 g/dL"],
        ["Albumin","3.5–5.0 g/dL"],
        ["Globulin","2.0–3.5 g/dL"],
        ["A:G ratio","1.5–2.5:1 (reversed <1 in cirrhosis, nephrotic syndrome, myeloma)"],
    ], [0.35, 0.65]
))
story.append(Spacer(1, 0.1*cm))

story.append(Paragraph(b("Cholesterol – Enzymatic (CHOD-PAP) Method"), S["h2"]))
story.append(Paragraph("1. Cholesterol esterase → free cholesterol. 2. Cholesterol oxidase → H₂O₂. 3. Peroxidase (Trinder) → red quinoneimine. Read at 500 nm.", S["body"]))
story.append(make_table(
    ["Lipid Parameter","Normal Value"],
    [
        ["Total cholesterol","<200 mg/dL"],
        ["LDL cholesterol","<100 mg/dL (optimal)"],
        ["HDL cholesterol",">40 mg/dL (males), >50 mg/dL (females)"],
        ["Triglycerides","<150 mg/dL"],
        ["Friedewald formula","LDL = Total cholesterol - HDL - (TG/5)"],
    ], [0.45, 0.55]
))

# ─── SECTION 4: LFT & KFT ──────────────────────────────────────────────────
story += section_heading("SECTION 4 – LIVER & KIDNEY FUNCTION TESTS")

story.append(Paragraph(b("Liver Function Tests (LFT)"), S["h2"]))
story.append(make_table(
    ["Test","Normal Value","Method","Elevated In"],
    [
        ["SGPT / ALT","7–56 IU/L","Alanine aminotransferase","Viral hepatitis, fatty liver (most liver-specific)"],
        ["SGOT / AST","10–40 IU/L","Aspartate aminotransferase","MI, hepatitis, alcohol, muscle disease"],
        ["ALP","44–147 IU/L","Phosphomonoesterase","Cholestasis, bone disease, hepatitis"],
        ["GGT","8–61 IU/L","Gamma-glutamyl transferase","Alcohol liver disease, cholestasis"],
        ["Total bilirubin","0.2–1.2 mg/dL","Van den Bergh","Jaundice of any cause"],
        ["Direct bilirubin","0–0.4 mg/dL","Van den Bergh (aqueous)","Obstructive/hepatic jaundice"],
        ["Albumin","3.5–5.0 g/dL","BCG dye-binding","Low in cirrhosis, nephrotic syndrome"],
        ["PT/INR","11–13 sec / 0.9–1.1","Clotting (liver-synthesized factors)","Liver synthetic failure, Vit K deficiency"],
    ], [0.2, 0.2, 0.25, 0.35]
))
story.append(Paragraph(b("De Ritis Ratio (AST:ALT): >2:1 = Alcoholic liver disease | <1:1 = Viral hepatitis"), S["note"]))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph(b("Kidney Function Tests (KFT)"), S["h2"]))
story.append(make_table(
    ["Test","Normal Value","Method","Elevated In"],
    [
        ["Blood urea","10–40 mg/dL","Diacetyl monoxime / Urease","Renal failure, dehydration, high protein diet"],
        ["Serum creatinine","M: 0.7–1.4 / F: 0.5–1.1 mg/dL","Jaffe's reaction","Renal failure, rhabdomyolysis"],
        ["Uric acid","M: 3.5–7 / F: 2.5–6 mg/dL","Uricase enzymatic","Gout, renal failure, tumor lysis"],
        ["GFR","80–120 mL/min","Creatinine clearance","<60 mL/min/1.73m² = CKD"],
        ["Serum Na⁺","135–145 mEq/L","Flame photometry / ISE","High in DI; low in SIADH"],
        ["Serum K⁺","3.5–5.0 mEq/L","Flame photometry / ISE","High in renal failure; Low in diarrhea"],
        ["Phosphate","2.5–4.5 mg/dL","Molybdate method","High in CKD (causes renal osteodystrophy)"],
    ], [0.21, 0.24, 0.22, 0.33]
))
story.append(Paragraph("Creatinine Clearance = (U × V) / P  |  U = urine creatinine, V = urine vol/min (mL/min), P = plasma creatinine", S["note"]))

# ─── SECTION 5: CLINICAL CASES ──────────────────────────────────────────────
story += section_heading("SECTION 5 – CLINICAL CASES FOR VIVA")

story.append(Paragraph(b("Jaundice – Types and Biochemistry"), S["h2"]))
story.append(make_table(
    ["Parameter","Hemolytic (Pre-hepatic)","Hepatocellular (Hepatic)","Obstructive (Post-hepatic)"],
    [
        ["Urine Bilirubin","Absent ✗","Present ✓","Present ++ ✓"],
        ["Urine Urobilinogen","Increased ↑↑","Variable","Absent ✗"],
        ["Urine Bile Salts","Absent ✗","Present ✓","Present ✓✓"],
        ["Stool Color","Dark (↑stercobilin)","Normal/pale","Pale/clay-colored"],
        ["Serum Direct Bili","Normal","Increased","Markedly increased ↑↑"],
        ["Serum Indirect Bili","Increased ↑↑","Increased","Normal/slight"],
        ["ALT/AST","Normal","Very high ↑↑↑","Moderate ↑"],
        ["ALP","Normal","Moderate ↑","Very high ↑↑↑"],
    ], [0.23, 0.26, 0.26, 0.25]
))
story.append(Paragraph("Key: Conjugated bilirubin is water-soluble → appears in urine. Unconjugated bilirubin is albumin-bound → does NOT appear in urine.", S["note"]))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph(b("Diabetes Mellitus"), S["h2"]))
for t in [
    "Urine: Glucose +, Ketones + (in DKA/Type 1), Protein + (early nephropathy = microalbuminuria)",
    "Blood: Fasting glucose >126 mg/dL, HbA1c >6.5%, 2h post-prandial >200 mg/dL",
    "Renal threshold for glucose: 180 mg/dL – glycosuria occurs when blood glucose exceeds this",
    "Renal glycosuria: Normal blood glucose but low renal threshold (kidney defect, not DM)",
]:
    story.append(Paragraph(t, S["bullet"]))
story.append(Spacer(1, 0.15*cm))

story.append(Paragraph(b("Myocardial Infarction – Cardiac Biomarkers"), S["h2"]))
story.append(make_table(
    ["Marker","Rises At","Peaks At","Returns Normal"],
    [
        ["Troponin I/T (gold standard)","3–6 hours","24–48 hours","7–14 days"],
        ["CK-MB","4–8 hours","12–24 hours","2–3 days"],
        ["Myoglobin (earliest)","1–3 hours","6–12 hours","1–2 days"],
        ["SGOT / AST","4–8 hours","18–36 hours","3–4 days"],
        ["LDH (latest)","24–48 hours","3–5 days","10–14 days"],
    ], [0.33, 0.20, 0.20, 0.27]
))
story.append(Spacer(1, 0.15*cm))

story.append(Paragraph(b("Gout"), S["h2"]))
story.append(Paragraph("Hyperuricemia → monosodium urate crystal deposition in joints. Males >7 mg/dL. Pathway: Purines → Hypoxanthine → Xanthine → Uric acid (xanthine oxidase). Treatment: Allopurinol (xanthine oxidase inhibitor).", S["body"]))
story.append(Spacer(1, 0.15*cm))

story.append(Paragraph(b("Nephrotic Syndrome"), S["h2"]))
story.append(Paragraph("Massive proteinuria (>3.5 g/day), hypoalbuminemia, generalized edema, hyperlipidemia, lipiduria. Reversed A:G ratio. ↑LDL, ↑cholesterol.", S["body"]))

# ─── SECTION 6: SPOTTERS ────────────────────────────────────────────────────
story += section_heading("SECTION 6 – SPOTTING TOPICS")

story.append(Paragraph(b("Vitamins and Deficiency Diseases"), S["h2"]))
story.append(make_table(
    ["Vitamin","Name","Deficiency Disease","Key Biochemistry"],
    [
        ["A","Retinol","Night blindness, Xerophthalmia","Fat-soluble; visual cycle rhodopsin"],
        ["B1","Thiamine","Beriberi (dry/wet), Wernicke's","Coenzyme: TPP; pyruvate decarboxylation"],
        ["B2","Riboflavin","Angular stomatitis, glossitis","Coenzyme: FAD, FMN"],
        ["B3","Niacin","Pellagra (3D: Diarrhea, Dermatitis, Dementia)","Coenzyme: NAD⁺, NADP⁺"],
        ["B6","Pyridoxine","Peripheral neuropathy, sideroblastic anemia","Coenzyme: PLP; transamination"],
        ["B9","Folate","Megaloblastic anemia, Neural tube defects","Coenzyme: THF; one-carbon transfer"],
        ["B12","Cobalamin","Megaloblastic anemia, SACD (subacute combined degeneration)","Requires intrinsic factor; pernicious anemia = IF deficiency"],
        ["C","Ascorbic acid","Scurvy (perifollicular hemorrhage, gum bleeding)","Collagen hydroxylation of Pro & Lys"],
        ["D","Calciferol","Rickets (child), Osteomalacia (adult)","Ca²⁺/phosphate; activated in kidney"],
        ["E","Tocopherol","Hemolytic anemia (neonate), neurodegeneration","Fat-soluble antioxidant"],
        ["K","Phylloquinone","Bleeding, hemorrhagic disease of newborn","Clotting factors II, VII, IX, X; carboxylation"],
    ], [0.07, 0.14, 0.33, 0.46]
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph(b("Amino Acid Classification"), S["h2"]))
story.append(make_table(
    ["Type","Examples"],
    [
        ["Essential (9)","Val, Leu, Ile, Lys, Met, Phe, Thr, Trp, His"],
        ["Acidic","Asp, Glu"],
        ["Basic","Lys, Arg, His"],
        ["Aromatic","Phe, Tyr, Trp"],
        ["Sulfur-containing","Met, Cys"],
        ["Ketogenic ONLY","Leu, Lys"],
        ["Both ketogenic + glucogenic","Phe, Tyr, Trp, Ile, Thr"],
    ], [0.35, 0.65]
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph(b("Carbohydrate Tests"), S["h2"]))
story.append(make_table(
    ["Test","Positive Result","What It Detects"],
    [
        ["Molisch","Purple ring","ALL carbohydrates"],
        ["Benedict's","Brick-red precipitate","Reducing sugars"],
        ["Seliwanoff's","Red color (faster than aldoses)","Ketoses (fructose)"],
        ["Bial's","Blue-green","Pentoses (ribose, xylose)"],
        ["Barfoed's","Red precipitate (3–5 min)","Monosaccharides (not disaccharides)"],
        ["Iodine test","Blue-black color","Starch (amylose)"],
        ["Fehling's","Brick-red precipitate","Reducing sugars"],
    ], [0.25, 0.35, 0.4]
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph(b("Enzyme Inhibitors"), S["h2"]))
story.append(make_table(
    ["Type","Vmax","Km","Mechanism","Example"],
    [
        ["Competitive","Unchanged","Increased ↑","Competes at active site; reversible","Malonate (succinate DH), Statins"],
        ["Non-competitive","Decreased ↓","Unchanged","Allosteric site; doesn't affect substrate binding","Heavy metals (Hg²⁺, Pb²⁺)"],
        ["Uncompetitive","Decreased ↓","Decreased ↓","Binds enzyme-substrate complex only","Lithium (inositol phosphatase)"],
        ["Irreversible","Decreased ↓","—","Covalent bond to enzyme","Organophosphates (AChE), Aspirin (COX)"],
        ["Suicide inhibitor","Decreased ↓","—","Mechanism-based covalent inhibition","Allopurinol → oxypurinol (XO)"],
    ], [0.2, 0.1, 0.1, 0.3, 0.3]
))
story.append(Spacer(1, 0.2*cm))

story.append(Paragraph(b("Tumor Markers"), S["h2"]))
story.append(make_table(
    ["Marker","Tumor"],
    [
        ["AFP (Alpha-fetoprotein)","Hepatocellular carcinoma, germ cell tumors"],
        ["CEA (Carcinoembryonic antigen)","Colorectal carcinoma"],
        ["PSA (Prostate-specific antigen)","Prostate carcinoma"],
        ["CA 125","Ovarian carcinoma"],
        ["CA 19-9","Pancreatic carcinoma"],
        ["CA 15-3","Breast carcinoma"],
        ["β-hCG","Choriocarcinoma, hydatidiform mole"],
        ["NSE (Neuron-specific enolase)","Neuroblastoma, small cell lung cancer"],
        ["LDH (Lactate dehydrogenase)","Lymphoma, leukemia (non-specific)"],
    ], [0.35, 0.65]
))

# ─── SECTION 7: RAPID-FIRE Q&A ──────────────────────────────────────────────
story += section_heading("SECTION 7 – RAPID-FIRE VIVA Q&A")

story.append(make_table(
    ["Question","Answer"],
    [
        ["Normal fasting blood glucose?","70–110 mg/dL (3.9–6.1 mmol/L)"],
        ["Normal urine pH?","4.5–8.0 (average 6.0)"],
        ["Normal serum bilirubin?","Total: 0.2–1.2 mg/dL"],
        ["Normal blood urea?","10–40 mg/dL"],
        ["Normal serum creatinine (male)?","0.7–1.4 mg/dL"],
        ["Renal threshold for glucose?","180 mg/dL"],
        ["Rothera's test positive substance?","Acetone + Acetoacetate (NOT β-OH butyrate)"],
        ["Hay's test: sulphur sinks or floats if +ve?","Sinks (bile salts lower surface tension)"],
        ["Most liver-specific enzyme?","ALT (SGPT)"],
        ["De Ritis ratio >2:1 suggests?","Alcoholic liver disease"],
        ["Gold standard cardiac biomarker?","Troponin I or Troponin T"],
        ["Earliest cardiac biomarker?","Myoglobin (rises 1–3 hours)"],
        ["Enzyme inhibited by allopurinol?","Xanthine oxidase"],
        ["Competitive inhibition: Vmax/Km?","Vmax unchanged; Km increased"],
        ["Vitamin for collagen hydroxylation?","Vitamin C (Ascorbic acid)"],
        ["Pellagra is deficiency of?","Niacin (Vitamin B3) – NAD/NADP"],
        ["Intrinsic factor deficiency causes?","Pernicious anemia (Vit B12 malabsorption)"],
        ["Normal A:G ratio?","1.5–2.5:1; reversed (<1) in cirrhosis, nephrotic syndrome"],
        ["What does Fouchet's reagent contain?","25g trichloroacetic acid + 10 mL 10% FeCl₃ in 100 mL water"],
        ["GOD-POD reads at which wavelength?","505 nm"],
        ["Jaffe's method detects?","Creatinine (with picric acid in alkaline medium)"],
        ["Normal serum uric acid (males)?","3.5–7.0 mg/dL"],
        ["Normal GFR / creatinine clearance?","80–120 mL/min"],
        ["Chromatography Rf value range?","0 to 1 (Rf = substance distance / solvent distance)"],
        ["Normal serum potassium?","3.5–5.0 mEq/L"],
    ], [0.55, 0.45]
))

story.append(Spacer(1, 0.3*cm))
# ─── One-Day Revision Checklist ──────────────────────────────────────────────
story.append(Table(
    [[Paragraph(b("ONE-DAY REVISION PRIORITY CHECKLIST"), ParagraphStyle("ckbox",
        fontSize=13, textColor=WHITE, fontName="Helvetica-Bold", alignment=TA_CENTER))]],
    colWidths=[W - 2*MARGIN],
    style=TableStyle([
        ("BACKGROUND",(0,0),(-1,-1), TEAL),
        ("TOPPADDING",(0,0),(-1,-1),8),("BOTTOMPADDING",(0,0),(-1,-1),8),
    ])
))
for item in [
    "1. Urine Analysis – 5 tests (procedures, principles, positive results)",
    "2. Beer-Lambert Law – formula, standard curve, deviation conditions",
    "3. Blood Glucose GOD-POD – reaction steps, normal table, renal threshold",
    "4. LFT + KFT – all normal values, De Ritis ratio, Jaffe/Biuret/Van den Bergh methods",
    "5. Jaundice types – urine bilirubin, urobilinogen, bile salts comparison table",
    "6. Cardiac biomarkers – Troponin, CK-MB, Myoglobin timing",
    "7. Vitamin deficiency diseases – all 11 vitamins",
    "8. Enzyme inhibitor Vmax/Km – competitive, non-competitive, uncompetitive",
    "9. Tumor markers – at least AFP, CEA, PSA, CA 125, CA 19-9",
    "10. Carbohydrate tests – Molisch, Benedict's, Seliwanoff's, Bial's",
]:
    story.append(Paragraph(f"☐  {item}", S["bullet"]))

story.append(Spacer(1, 0.3*cm))
story.append(Paragraph(i("Notes compiled from standard MBBS biochemistry curriculum and Tietz Textbook of Laboratory Medicine."),
    ParagraphStyle("foot", fontSize=8, textColor=DGRAY, alignment=TA_CENTER, fontName="Helvetica-Oblique")))

# BUILD
doc.build(story)
print("PDF saved successfully.")

MBBS 1st Year Biochemistry Practical – Important Topics (Viva + Practical Exam) 1. Urine Analysis (Most Important) Normal urine constituents Abnormal urine constituents Tests for: Protein (Albumin) Glucose (Benedict's test) Ketone bodies (Rothera's test) Bile salts (Hay's test) Bile pigments (Fouchet's test) topics cover the majority of questions commonly asked in first-year MBBS biochemistry practicals and viva examinations.

Asking for Preferences
Reading File
Finding Sources
Finding Sources
Reading File
Finding Sources
Finding Sources
Running Command

mkdir -p /home/daytona/workspace/urine-analysis

Writing File

~/urine-analysis/create_pdf.py

#!/usr/bin/env python3
"""Urine Analysis – Complete Revision Notes PDF"""

from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT

# ── Palette ──────────────────────────────────────────────────────────
NAVY   = colors.HexColor("#1A2E5C")
TEAL   = colors.HexColor("#0E8A87")
AMBER  = colors.HexColor("#F5A623")
RED    = colors.HexColor("#C0392B")
GREEN  = colors.HexColor("#1E7E34")
LGRAY  = colors.HexColor("#F0F4FF")
DGRAY  = colors.HexColor("#444444")
MGRAY  = colors.HexColor("#888888")
WHITE  = colors.white
ROW1   = colors.HexColor("#E8F4F8")
ROW2   = colors.HexColor("#FFFFFF")
AMBER_PALE = colors.HexColor("#FFF8E7")
TEAL_PALE  = colors.HexColor("#E6F7F7")
RED_PALE   = colors.HexColor("#FDF0EF")

W, H   = A4
MARGIN = 1.6 * cm
TW     = W - 2 * MARGIN   # usable table width

doc = SimpleDocTemplate(
    "/home/daytona/workspace/urine-analysis/Urine_Analysis_Notes.pdf",
    pagesize=A4,
    leftMargin=MARGIN, rightMargin=MARGIN,
    topMargin=MARGIN,  bottomMargin=MARGIN,
    title="Urine Analysis – MBBS Biochemistry Practical"
)

# ── Style helpers ─────────────────────────────────────────────────────
def S(name, **kw):
    defaults = dict(fontName="Helvetica", fontSize=10, textColor=DGRAY,
                    spaceAfter=3, leading=14)
    defaults.update(kw)
    return ParagraphStyle(name, **defaults)

STYLES = {
    "h1":     S("h1",  fontSize=15, fontName="Helvetica-Bold", textColor=WHITE,
                spaceAfter=0, leading=20),
    "h2":     S("h2",  fontSize=12, fontName="Helvetica-Bold", textColor=NAVY,
                spaceBefore=10, spaceAfter=4, leading=16),
    "h3":     S("h3",  fontSize=10.5, fontName="Helvetica-Bold", textColor=TEAL,
                spaceBefore=6, spaceAfter=3, leading=14),
    "body":   S("body"),
    "bullet": S("bullet", leftIndent=14, firstLineIndent=-10, bulletText="▸"),
    "note":   S("note",   fontSize=9,  fontName="Helvetica-Oblique", textColor=RED,
                leftIndent=6, spaceAfter=4),
    "tip":    S("tip",    fontSize=9,  fontName="Helvetica-Oblique", textColor=GREEN,
                leftIndent=6, spaceAfter=4),
    "formula":S("formula",fontSize=13, fontName="Helvetica-Bold", textColor=NAVY,
                alignment=TA_CENTER, spaceAfter=4),
    "center": S("center", alignment=TA_CENTER, fontName="Helvetica-Bold",
                fontSize=9, textColor=DGRAY),
    "th":     S("th",  fontSize=9,  fontName="Helvetica-Bold", textColor=WHITE,
                alignment=TA_CENTER, leading=12, spaceAfter=0),
    "td":     S("td",  fontSize=8.8, fontName="Helvetica", textColor=DGRAY,
                leading=12, spaceAfter=0),
    "td_c":   S("td_c",fontSize=8.8, fontName="Helvetica", textColor=DGRAY,
                alignment=TA_CENTER, leading=12, spaceAfter=0),
}

def sec(title, subtitle=None):
    """Dark navy section banner."""
    rows = [[Paragraph(title, STYLES["h1"])]]
    if subtitle:
        rows.append([Paragraph(subtitle, S("sub", fontSize=9, textColor=AMBER,
                                           fontName="Helvetica", spaceAfter=0))])
    t = Table(rows, colWidths=[TW],
              style=TableStyle([
                  ("BACKGROUND",(0,0),(-1,-1),NAVY),
                  ("TOPPADDING",(0,0),(-1,-1),7),
                  ("BOTTOMPADDING",(0,0),(-1,-1),7),
                  ("LEFTPADDING",(0,0),(-1,-1),10),
                  ("RIGHTPADDING",(0,0),(-1,-1),10),
              ]))
    return [Spacer(1, 0.25*cm), t, Spacer(1, 0.15*cm)]

def tbl(headers, rows, widths, row_colors=(ROW1, ROW2)):
    cw = [TW * f for f in widths]
    data = [[Paragraph(h, STYLES["th"]) for h in headers]]
    for i, row in enumerate(rows):
        bg = row_colors[i % 2]
        data.append([
            Paragraph(str(c), STYLES["td_c"] if j == 0 and len(headers) > 2
                      else STYLES["td"])
            for j, c in enumerate(row)
        ])
    ts = TableStyle([
        ("BACKGROUND",(0,0),(-1,0), NAVY),
        ("ROWBACKGROUNDS",(0,1),(-1,-1), list(row_colors)),
        ("GRID",(0,0),(-1,-1), 0.3, colors.HexColor("#C8D8E8")),
        ("TOPPADDING",(0,0),(-1,-1),4),
        ("BOTTOMPADDING",(0,0),(-1,-1),4),
        ("LEFTPADDING",(0,0),(-1,-1),5),
        ("VALIGN",(0,0),(-1,-1),"TOP"),
    ])
    return Table(data, colWidths=cw, style=ts, repeatRows=1)

def callout(text, bg=TEAL_PALE, border=TEAL, bold=False):
    st = "Helvetica-Bold" if bold else "Helvetica-Oblique"
    col = TEAL if bold else RED
    t = Table([[Paragraph(text, S("co", fontSize=9, fontName=st,
                                  textColor=col, spaceAfter=0))]],
              colWidths=[TW],
              style=TableStyle([
                  ("BACKGROUND",(0,0),(-1,-1), bg),
                  ("LEFTBORDERPADDING",(0,0),(-1,-1), 4),
                  ("BOX",(0,0),(-1,-1), 1.5, border),
                  ("TOPPADDING",(0,0),(-1,-1),5),
                  ("BOTTOMPADDING",(0,0),(-1,-1),5),
                  ("LEFTPADDING",(0,0),(-1,-1),8),
              ]))
    return [t, Spacer(1, 0.1*cm)]

def b(t): return f"<b>{t}</b>"
def sp(n=1): return Spacer(1, n * 0.18 * cm)

# ══════════════════════════════════════════════════════════════════════
story = []

# ── COVER ─────────────────────────────────────────────────────────────
cover = Table([
    [Paragraph("MBBS 1st YEAR  ·  BIOCHEMISTRY PRACTICAL",
               S("cv1", fontSize=11, fontName="Helvetica-Bold",
                 textColor=AMBER, alignment=TA_CENTER, spaceAfter=0))],
    [Paragraph("URINE ANALYSIS",
               S("cv2", fontSize=32, fontName="Helvetica-Bold",
                 textColor=WHITE, alignment=TA_CENTER, spaceAfter=0))],
    [Paragraph("Complete Revision Notes",
               S("cv3", fontSize=14, fontName="Helvetica",
                 textColor=colors.HexColor("#D6E8F0"), alignment=TA_CENTER, spaceAfter=0))],
    [Spacer(1, 0.3*cm)],
    [Paragraph("Normal &amp; Abnormal Constituents  ·  Heat Coagulation  ·  Benedict's Test",
               S("cv4", fontSize=9.5, fontName="Helvetica",
                 textColor=colors.HexColor("#AAC8D8"), alignment=TA_CENTER, spaceAfter=0))],
    [Paragraph("Rothera's Test  ·  Hay's Test  ·  Fouchet's Test  ·  Clinical Viva Q&amp;A",
               S("cv5", fontSize=9.5, fontName="Helvetica",
                 textColor=colors.HexColor("#AAC8D8"), alignment=TA_CENTER, spaceAfter=0))],
], colWidths=[TW],
style=TableStyle([
    ("BACKGROUND",(0,0),(-1,-1), NAVY),
    ("TOPPADDING",(0,0),(-1,-1),14),
    ("BOTTOMPADDING",(0,0),(-1,-1),14),
    ("LEFTPADDING",(0,0),(-1,-1),20),
    ("RIGHTPADDING",(0,0),(-1,-1),20),
    ("LINEBELOW",(0,1),(-1,1), 1.5, AMBER),
]))
story.append(Spacer(1, 0.4*cm))
story.append(cover)
story.append(sp(2))

# ══════════════════════════════════════════════════════════════════════
# SECTION 1 – PHYSICAL CHARACTERISTICS
# ══════════════════════════════════════════════════════════════════════
story += sec("SECTION 1 – PHYSICAL CHARACTERISTICS OF NORMAL URINE",
             "Harper's Illustrated Biochemistry (32nd Ed.) · Tietz Textbook of Laboratory Medicine")

story.append(Paragraph(b("What is a Complete Urinalysis?"), STYLES["h2"]))
story.append(Paragraph(
    "A complete urinalysis includes assessment of the physical characteristics of urine "
    "(volume, color, odor, appearance, specific gravity, pH) together with detection of "
    "abnormal chemical constituents. It is an essential and inexpensive investigation in "
    "clinical biochemistry. — Harper's Biochemistry, 32nd Ed.",
    STYLES["body"]))
story.append(sp())

story.append(tbl(
    ["Parameter", "Normal Value", "Clinical Notes"],
    [
        ["Volume / 24 h", "1000–1500 mL/day\n(obligatory minimum ~500 mL)", "Oliguria <400 mL/day; Anuria <100 mL/day; Polyuria >3 L/day"],
        ["Color", "Pale yellow to amber\n(urochrome pigment)", "Colorless = dilute / diabetes insipidus; Dark amber = concentrated / dehydration; Red/brown = hematuria or myoglobinuria"],
        ["Odor", "Aromatic (volatile acids)", "Ammoniacal = UTI (bacterial decomposition); Fruity/sweet = ketones (DKA); Fishy = trimethylaminuria"],
        ["Appearance", "Clear / transparent", "Turbidity = UTI, phosphaturia, urates. Frothy = proteinuria"],
        ["pH", "4.5–8.0\n(average 6.0)", "Acidic after protein-rich meal; Alkaline after vegetable diet, UTI with Proteus. Blood pH is always 7.35–7.45"],
        ["Specific Gravity", "1.003–1.030\n(average 1.015–1.020)", "Low in diabetes insipidus (1.001–1.005); Fixed at ~1.010 = severe renal impairment (isosthenuria)"],
        ["Protein", "< 150 mg/24 h total\n< 30 mg/24 h albumin", "Microalbuminuria (30–300 mg/24h) = earliest marker of diabetic nephropathy"],
        ["Glucose", "Absent\n(< 130 mg/24 h)", "Glycosuria when blood glucose exceeds renal threshold (180 mg/dL)"],
        ["Ketone bodies", "Absent (trace)", "Acetone + Acetoacetate + β-Hydroxybutyrate"],
        ["Bile pigments", "Absent", "Only conjugated bilirubin (water-soluble) appears in urine"],
        ["Bile salts", "Absent", "Sodium glycocholate and taurocholate"],
    ],
    [0.20, 0.28, 0.52]
))
story.append(sp())

# Organic + inorganic table
story.append(Paragraph(b("Normal Chemical Constituents of Urine"), STYLES["h2"]))
story.append(tbl(
    ["Constituent", "Amount / Day", "Notes"],
    [
        ["Urea (organic, largest)", "25–30 g", "End-product of protein catabolism; 80% of urinary nitrogen"],
        ["Creatinine", "1–2 g", "Constant daily output; derived from creatine phosphate in muscle; best marker of renal function"],
        ["Uric acid", "0.5–1 g", "End-product of purine catabolism; elevated in gout & renal failure"],
        ["Ammonia", "0.3–1 g", "Buffers urinary acid; produced by renal tubular cells from glutamine"],
        ["Hippuric acid", "0.1–1 g", "Conjugate of benzoic acid + glycine; elevated with benzoate-rich diet"],
        ["NaCl (largest inorganic)", "10–15 g", "Varies with dietary salt intake"],
        ["Phosphates", "1–1.5 g", "Important urinary buffer (H₂PO₄⁻ / HPO₄²⁻)"],
        ["Sulphates", "1.5–3 g", "Derived from cysteine, methionine catabolism"],
        ["Potassium", "2–4 g", "Urinary K⁺ loss increased by aldosterone"],
        ["Calcium", "0.1–0.3 g", "Increased in hypercalcemia; kidney stones if combined with oxalate"],
    ],
    [0.32, 0.18, 0.50]
))
story.append(sp())

# ══════════════════════════════════════════════════════════════════════
# SECTION 2 – ABNORMAL CONSTITUENTS
# ══════════════════════════════════════════════════════════════════════
story += sec("SECTION 2 – ABNORMAL URINE CONSTITUENTS", "Pathological conditions and their urinary markers")

story.append(tbl(
    ["Abnormal Substance", "Condition / Disease", "Mechanism"],
    [
        ["Protein (albumin)\nProteinuria",
         "Nephrotic syndrome, glomerulonephritis, diabetic nephropathy, UTI, pre-eclampsia, fever, vigorous exercise",
         "Loss of glomerular basement membrane integrity → albumin leaks into filtrate. >150 mg/day = proteinuria; >3.5 g/day = nephrotic range"],
        ["Glucose\nGlycosuria",
         "Diabetes mellitus (most common), renal glycosuria, pregnancy",
         "Blood glucose exceeds renal threshold (180 mg/dL) → tubular reabsorption capacity exceeded. Renal glycosuria = normal blood glucose + low renal threshold"],
        ["Ketone bodies\nKetonuria",
         "Diabetic ketoacidosis (DKA), starvation, prolonged vomiting, high-fat diet, alcoholic ketoacidosis",
         "Excess fatty acid oxidation → acetyl-CoA → ketogenesis. Acetone + Acetoacetate + β-OH butyrate"],
        ["Bile pigments\n(Bilirubin)",
         "Hepatocellular jaundice (hepatitis, cirrhosis), obstructive jaundice (gallstones, Ca pancreas)",
         "Only conjugated (direct) bilirubin is water-soluble and appears in urine. Unconjugated is albumin-bound → cannot pass glomerulus"],
        ["Bile salts",
         "Obstructive jaundice (bile duct obstruction)",
         "Bile salts (glycocholate, taurocholate) regurgitate into blood when bile duct blocked → excreted in urine"],
        ["Blood (Haematuria)",
         "UTI, renal calculi, glomerulonephritis, renal tumours, trauma, IgA nephropathy",
         "Intact RBCs or free haemoglobin in urine. Microscopic haematuria not visible to naked eye"],
        ["Pus (Pyuria)\n>10 WBC/HPF",
         "Urinary tract infection (E. coli most common), renal tuberculosis, pyelonephritis",
         "Neutrophils migrate into urine in response to bacterial infection. Cloudy urine with fishy odour"],
        ["Casts",
         "Nephrotic/nephritic syndrome, acute tubular necrosis, chronic renal disease",
         "Protein matrix formed in renal tubules. Hyaline (mild proteinuria) → Granular (tubular damage) → Waxy (advanced disease) → RBC casts (glomerulonephritis)"],
        ["Haemoglobin (Haemoglobinuria)",
         "Intravascular haemolysis: G6PD deficiency, ABO incompatibility, paroxysmal nocturnal haemoglobinuria, malaria (blackwater fever)",
         "Free Hb in plasma exceeds haptoglobin binding capacity → filtered at glomerulus → red/brown urine"],
        ["Myoglobin (Myoglobinuria)",
         "Rhabdomyolysis: crush injury, malignant hyperthermia, statin toxicity, severe exercise",
         "Myoglobin (MW 17,000) is freely filtered; causes acute tubular necrosis → acute renal failure"],
    ],
    [0.22, 0.33, 0.45]
))
story += callout(
    "⚠ Key Point: Conjugated (direct) bilirubin = water-soluble → passes glomerulus → appears in urine.\n"
    "Unconjugated (indirect) bilirubin = bound to albumin → does NOT appear in urine.",
    bg=AMBER_PALE, border=AMBER, bold=True
)
story.append(sp())

# ══════════════════════════════════════════════════════════════════════
# SECTION 3 – URINE TESTS
# ══════════════════════════════════════════════════════════════════════
story += sec("SECTION 3 – FIVE URINE TESTS  (Practical Procedures)",
             "Principle · Reagents · Step-by-step Procedure · Result · Clinical Significance")

# ── TEST 1: PROTEIN ────────────────────────────────────────────────────
story.append(Paragraph("TEST 1 – Protein (Albumin): Heat Coagulation Test", STYLES["h2"]))

story.append(tbl(
    ["Aspect", "Details"],
    [
        ["Principle", "Proteins denature and precipitate on heating at acidic pH. Acetic acid is added to distinguish protein precipitate (persists) from calcium/magnesium phosphate precipitate (dissolves in acid)."],
        ["Reagents Required", "Test tube, spirit lamp, 1% glacial acetic acid"],
        ["Procedure",
         "1. Fill a test tube 2/3 with clear urine (if turbid, filter first)\n"
         "2. Tilt at 45° and heat only the UPPER portion over a flame until it boils\n"
         "3. Compare upper (heated) portion with lower (unheated) portion\n"
         "4. If turbidity appears: add 2–3 drops of 1% acetic acid\n"
         "5. Observe result"],
        ["Positive Result", "White turbidity or precipitate that PERSISTS after adding acetic acid → Protein PRESENT"],
        ["Negative Control", "Turbidity that DISAPPEARS after acetic acid = phosphates (false positive eliminated)"],
        ["Grading",
         "Trace (+): Slight cloudiness\n"
         "+ : Distinct cloudiness, no flocculation\n"
         "++ : Heavy turbidity, granular appearance\n"
         "+++ : Heavy precipitate\n"
         "++++ : Solid clot of precipitate"],
        ["Clinical Significance",
         "Nephrotic syndrome (massive proteinuria >3.5g/day)\n"
         "Glomerulonephritis (haematuria + proteinuria)\n"
         "Diabetic nephropathy (microalbuminuria is earliest sign)\n"
         "UTI, fever, pre-eclampsia, multiple myeloma (Bence Jones protein)\n"
         "Orthostatic proteinuria (benign – present only when standing)"],
        ["Other Protein Tests",
         "Sulphosalicylic acid test (SSA): 3–5 drops SSA + urine → white turbidity\n"
         "Roberts ring test: urine carefully layered over Roberts reagent → white ring at junction\n"
         "Dipstick (bromocresol green): semi-quantitative, quick screening"],
    ], [0.22, 0.78]
))
story += callout(
    "✓ Viva Tip: Normal protein excretion < 150 mg/24h (< 30 mg albumin). Microalbuminuria "
    "(30–300 mg albumin/24h) is the EARLIEST detectable marker of diabetic nephropathy. "
    "The major protein in glomerular proteinuria is albumin. — Harper's Biochemistry 32nd Ed.",
    bg=TEAL_PALE, border=TEAL
)
story.append(sp(2))

# ── TEST 2: GLUCOSE ───────────────────────────────────────────────────
story.append(Paragraph("TEST 2 – Glucose: Benedict's Qualitative Test", STYLES["h2"]))

story.append(tbl(
    ["Aspect", "Details"],
    [
        ["Principle",
         "Glucose (a reducing sugar) reduces cupric ions (Cu²⁺) to cuprous ions (Cu⁺) in alkaline medium at high temperature, forming an insoluble brick-red/orange precipitate of cuprous oxide (Cu₂O).\n\n"
         "Cu²⁺ (blue) + Reducing sugar → Cu⁺ + Gluconic acid → Cu₂O precipitate (red)"],
        ["Benedict's Reagent Composition",
         "Copper sulphate (CuSO₄) – provides Cu²⁺\n"
         "Sodium citrate – chelates Cu²⁺, preventing premature precipitation in alkaline medium\n"
         "Sodium carbonate (Na₂CO₃) – provides alkaline medium"],
        ["Procedure",
         "1. Take 5 mL Benedict's reagent in a test tube\n"
         "2. Add 8 drops (0.4 mL) of urine\n"
         "3. Mix well\n"
         "4. Place in boiling water bath for 5 minutes (OR heat directly over flame for 2 minutes)\n"
         "5. Allow to cool and observe color change"],
        ["Results – Color Interpretation",
         "Blue (no change) = Negative (< 0.5% glucose)\n"
         "Green precipitate (+) = Trace (0.1–0.5%)\n"
         "Yellow precipitate (++) = 0.5–1%\n"
         "Orange precipitate (+++) = 1–2%\n"
         "Brick-red precipitate (++++) = > 2%"],
        ["Clinical Significance",
         "Diabetes mellitus: most common cause of glycosuria\n"
         "Renal glycosuria: blood glucose normal but renal threshold lowered\n"
         "Pregnancy: renal threshold lowers → gestational glycosuria\n"
         "Liver disease: excess galactose or fructose in urine"],
        ["Important Notes",
         "Benedict's detects ALL reducing sugars (glucose, galactose, fructose, lactose, maltose, pentoses)\n"
         "To confirm specifically glucose: use Glucose Oxidase test (GOD-POD) or dipstick\n"
         "Non-glucose reducing substances: uric acid, creatinine, glucuronic acid (drugs) → false positive\n"
         "Renal threshold for glucose = 180 mg/dL"],
    ], [0.22, 0.78]
))
story += callout(
    "⚠ Benedict's test detects ALL reducing sugars, NOT specifically glucose. "
    "A positive Benedict's test in the absence of diabetes may indicate galactosuria (galactosemia) or "
    "fructosuria. Use glucose oxidase method for specificity.",
    bg=RED_PALE, border=RED
)
story.append(sp(2))

# ── TEST 3: KETONES ───────────────────────────────────────────────────
story.append(Paragraph("TEST 3 – Ketone Bodies: Rothera's Test", STYLES["h2"]))

story.append(tbl(
    ["Aspect", "Details"],
    [
        ["Principle",
         "Acetone and acetoacetic acid (acetoacetate) react with sodium nitroprusside "
         "[Na₂Fe(CN)₅NO] in strongly alkaline medium to form a purple/violet-coloured "
         "complex (Legal's reaction). The colour forms as a distinct ring at the interface "
         "of urine and ammonia.\n\n"
         "Acetone / Acetoacetate + Sodium nitroprusside + NH₄OH → Purple/violet ring"],
        ["Rothera's Reagent Composition",
         "Ammonium sulphate [(NH₄)₂SO₄] – saturates the solution\n"
         "Sodium nitroprusside (sodium nitroferricyanide) – reacts with ketone bodies"],
        ["Procedure",
         "1. Fill a test tube half-full with urine\n"
         "2. Add an excess of Rothera's reagent solid (enough to saturate the solution)\n"
         "3. Shake gently to dissolve\n"
         "4. Carefully pour (layer) strong liquid ammonia (or concentrated NH₄OH) along the side of the tilted test tube\n"
         "5. Allow to stand for 2–3 minutes WITHOUT mixing\n"
         "6. Observe for ring at the junction of the two layers"],
        ["Positive Result",
         "Purple / violet ring at the junction = Ketone bodies PRESENT"],
        ["Clinical Significance",
         "Diabetic ketoacidosis (DKA): Type 1 DM most common; also severe Type 2\n"
         "Starvation ketonuria: prolonged fasting, low-carbohydrate diet\n"
         "Alcoholic ketoacidosis\n"
         "Persistent vomiting (e.g., hyperemesis gravidarum)\n"
         "High-fat, low-carbohydrate diet (ketogenic diet)"],
        ["Important Limitations",
         "Rothera's test detects ONLY acetone and acetoacetate\n"
         "β-Hydroxybutyrate (β-OH butyrate) is NOT detected (lacks a keto/carbonyl group)\n"
         "β-OH butyrate is actually the most abundant ketone body in DKA (~78%)\n"
         "Dipstick tests also use nitroprusside reaction – same limitation applies\n"
         "A separate enzymatic test (β-OH butyrate dehydrogenase) is used for β-OH butyrate"],
    ], [0.22, 0.78]
))
story += callout(
    "⚠ Critical Viva Point: Rothera's test does NOT detect β-hydroxybutyrate "
    "(the most abundant ketone body in DKA). β-Hydroxybutyrate lacks a keto group "
    "and does not react with nitroprusside. — Henry's Clinical Diagnosis, Lab Methods",
    bg=RED_PALE, border=RED
)
story.append(sp(2))

# ── TEST 4: BILE SALTS ────────────────────────────────────────────────
story.append(Paragraph("TEST 4 – Bile Salts: Hay's Sulphur Test", STYLES["h2"]))

story.append(tbl(
    ["Aspect", "Details"],
    [
        ["Principle",
         "Bile salts (sodium glycocholate and sodium taurocholate) are surface-active agents "
         "(detergents). They markedly reduce the surface tension of urine. Sulphur powder "
         "(flowers of sulphur) has a low density and normally floats on water due to surface tension. "
         "When bile salts are present, surface tension is reduced sufficiently that sulphur sinks to "
         "the bottom of the liquid.\n\n"
         "Normal urine (high surface tension) → sulphur FLOATS\n"
         "Urine + bile salts (low surface tension) → sulphur SINKS"],
        ["Reagent", "Flowers of sulphur (powdered elemental sulphur, S)"],
        ["Procedure",
         "1. Take fresh urine in a clean beaker or wide-mouthed vessel (do NOT use a narrow test tube)\n"
         "2. Sprinkle a small amount (a pinch) of powdered sulphur gently onto the surface of the urine\n"
         "3. Observe immediately whether sulphur floats or sinks\n"
         "4. Do NOT shake or disturb the surface"],
        ["Positive Result",
         "Sulphur SINKS to the bottom = Bile salts PRESENT\n"
         "Sulphur FLOATS on surface = Bile salts ABSENT"],
        ["Clinical Significance",
         "Obstructive jaundice (primary finding): bile duct blocked → bile salts regurgitate into blood and excreted in urine\n"
         "Hepatocellular jaundice: bile salts may be present\n"
         "Haemolytic jaundice: bile salts are ABSENT"],
        ["Important Notes",
         "Test must be done on fresh urine\n"
         "Foam test: Bile salts cause persistent yellow foam when urine is shaken vigorously\n"
         "Surface tension of normal urine ≈ 66 dynes/cm; bile salts reduce it to < 40 dynes/cm\n"
         "Hay's test is a qualitative test only – negative in purely haemolytic jaundice"],
    ], [0.22, 0.78]
))
story += callout(
    "✓ Memory Aid: 'Bile salts SINK sulphur' – bile salts act like soap (detergent), "
    "lowering surface tension, so the sulphur can no longer float. Hay's test is POSITIVE "
    "in obstructive and hepatic jaundice, but NEGATIVE in haemolytic (pre-hepatic) jaundice.",
    bg=TEAL_PALE, border=TEAL
)
story.append(sp(2))

# ── TEST 5: BILE PIGMENTS ─────────────────────────────────────────────
story.append(Paragraph("TEST 5 – Bile Pigments (Bilirubin): Fouchet's Test", STYLES["h2"]))

story.append(tbl(
    ["Aspect", "Details"],
    [
        ["Principle",
         "Bilirubin (a yellow bile pigment) is oxidised by ferric chloride (FeCl₃) in an "
         "acidic medium (trichloroacetic acid) to biliverdin, which is green in colour.\n\n"
         "Bilirubin (yellow) + FeCl₃ → Biliverdin (green)\n\n"
         "Trichloroacetic acid (TCA) first precipitates proteins and concentrates bilirubin on a barium chloride "
         "precipitate, making the test more sensitive."],
        ["Fouchet's Reagent Composition",
         "25 g trichloroacetic acid (TCA)\n"
         "10 mL of 10% ferric chloride (FeCl₃) solution\n"
         "Made up to 100 mL with distilled water"],
        ["Procedure",
         "1. Take 10 mL of urine in a test tube\n"
         "2. Add 5 mL of 10% barium chloride (BaCl₂) solution\n"
         "3. Mix well – BaCl₂ precipitates bile pigments (bilirubin is adsorbed onto BaSO₄ precipitate)\n"
         "4. Filter through Whatman No.1 filter paper; a yellowish precipitate is on the filter paper\n"
         "5. Spread the filter paper flat on a tile or glass plate\n"
         "6. Add 1–2 drops of Fouchet's reagent to the precipitate on the filter paper\n"
         "7. Observe for colour change"],
        ["Positive Result",
         "GREEN colour on the filter paper = Bile pigments (bilirubin) PRESENT\n"
         "Bluish-green = also positive"],
        ["Clinical Significance",
         "Hepatocellular jaundice: hepatitis A/B/C, alcoholic hepatitis, cirrhosis\n"
         "Obstructive jaundice: gallstones, carcinoma head of pancreas, cholangiocarcinoma\n"
         "Bilirubinuria is ABSENT in haemolytic (pre-hepatic) jaundice – unconjugated bilirubin cannot pass glomerulus"],
        ["Why BaCl₂ is used first",
         "BaCl₂ acts as a carrier – it precipitates bilirubin sulphate from urine, concentrating it on the filter paper. "
         "This step increases sensitivity of Fouchet's test for detecting small amounts of bilirubin."],
    ], [0.22, 0.78]
))
story += callout(
    "⚠ Bilirubinuria is ABSENT in haemolytic jaundice because in haemolytic jaundice, "
    "bilirubin is unconjugated (indirect) – bound to albumin, water-insoluble, cannot be "
    "filtered at the glomerulus. Only conjugated (direct) bilirubin is water-soluble and "
    "appears in urine.",
    bg=AMBER_PALE, border=AMBER, bold=True
)
story.append(sp())

# ══════════════════════════════════════════════════════════════════════
# SECTION 4 – JAUNDICE DIFFERENTIAL TABLE
# ══════════════════════════════════════════════════════════════════════
story += sec("SECTION 4 – JAUNDICE: DIFFERENTIAL DIAGNOSIS BY URINE TESTS",
             "Most commonly asked comparison table in viva examinations")

story.append(tbl(
    ["Finding", "Haemolytic\n(Pre-hepatic)", "Hepatocellular\n(Hepatic)", "Obstructive\n(Post-hepatic)"],
    [
        ["Urine colour",       "Normal/dark\n(↑urobilinogen)",     "Amber/dark",             "Dark brown (bile-stained)"],
        ["Urine bilirubin\n(Fouchet's)", "ABSENT ✗",              "PRESENT ✓",              "PRESENT ++ ✓"],
        ["Urine bile salts\n(Hay's test)", "ABSENT ✗",            "PRESENT ✓",              "PRESENT ✓✓"],
        ["Urine urobilinogen", "INCREASED ↑↑",                    "Variable\n(↑ early, ↓ late)", "ABSENT ✗"],
        ["Urine protein",      "Absent (usually)",                "Present ± ",             "Usually absent"],
        ["Stool colour",       "Dark\n(↑stercobilin)",            "Normal/pale",            "Pale/clay\n(absent stercobilin)"],
        ["Serum direct bili",  "Normal",                          "Increased",              "Markedly increased ↑↑"],
        ["Serum indirect bili","Markedly increased ↑↑",           "Increased",              "Normal / slight ↑"],
        ["ALT / AST",          "Normal",                          "Very high ↑↑↑",          "Moderate ↑"],
        ["ALP",                "Normal",                          "Moderate ↑",             "Markedly high ↑↑↑"],
        ["Common causes",      "G6PD deficiency,\nhaemolytic anaemia, thalassaemia, transfusion reaction",
                               "Viral hepatitis (A,B,C,E),\nalcoholic hepatitis, cirrhosis, drug-induced",
                               "Gallstones, carcinoma\nhead of pancreas,\ncholangiocarcinoma"],
    ],
    [0.24, 0.25, 0.25, 0.26],
    row_colors=(ROW1, ROW2)
))
story += callout(
    "Mnemonic: In Haemolytic jaundice – Bile SALTS and PIGMENTS are both ABSENT in urine "
    "(because unconjugated bilirubin can't pass the glomerulus). "
    "In Obstructive jaundice – both are PRESENT (conjugated bilirubin spills into blood and then urine).",
    bg=TEAL_PALE, border=TEAL
)
story.append(sp())

# ══════════════════════════════════════════════════════════════════════
# SECTION 5 – SUMMARY TABLE
# ══════════════════════════════════════════════════════════════════════
story += sec("SECTION 5 – QUICK REFERENCE SUMMARY", "All 5 tests at a glance")

story.append(tbl(
    ["Test", "What Detected", "Principle (1 line)", "Reagent", "Positive Result", "Absent In"],
    [
        ["Heat Coagulation", "Protein\n(albumin)",
         "Protein denatures on heating at acid pH",
         "1% acetic acid + heat",
         "White turbidity (persists in acid)",
         "Normal urine"],
        ["Benedict's Test", "Glucose\n(reducing sugars)",
         "Cu²⁺ reduced to Cu⁺ → Cu₂O (brick-red)",
         "Benedict's reagent\n(CuSO₄ + Na citrate + Na₂CO₃)",
         "Green→orange→brick-red precipitate",
         "Normal urine, haemolytic jaundice"],
        ["Rothera's Test", "Ketone bodies\n(acetone + acetoacetate)",
         "Nitroprusside + ketones → purple ring in alkali",
         "Rothera's reagent\n+ concentrated ammonia",
         "Purple/violet ring at junction",
         "Normal urine; β-OH butyrate NOT detected"],
        ["Hay's Test\n(Sulphur test)", "Bile salts",
         "Bile salts lower surface tension → sulphur sinks",
         "Flowers of sulphur",
         "Sulphur SINKS",
         "Haemolytic jaundice, normal urine"],
        ["Fouchet's Test", "Bile pigments\n(bilirubin)",
         "FeCl₃ oxidises bilirubin → biliverdin (green)",
         "BaCl₂ + Fouchet's reagent\n(TCA + FeCl₃)",
         "GREEN colour on filter paper",
         "Haemolytic jaundice, normal urine"],
    ],
    [0.17, 0.14, 0.22, 0.19, 0.17, 0.11]
))
story.append(sp(2))

# ══════════════════════════════════════════════════════════════════════
# SECTION 6 – VIVA Q&A
# ══════════════════════════════════════════════════════════════════════
story += sec("SECTION 6 – RAPID-FIRE VIVA QUESTIONS & ANSWERS",
             "Most commonly asked viva questions with concise answers")

qa_pairs = [
    ("What is the normal pH of urine?",
     "4.5–8.0 (average 6.0). Acidic in morning fasted state."),
    ("What is the normal specific gravity of urine?",
     "1.003–1.030. Fixed at 1.010 (isosthenuria) indicates severe renal impairment."),
    ("What is the renal threshold for glucose?",
     "180 mg/dL. Glycosuria occurs when blood glucose exceeds this value."),
    ("What is microalbuminuria? Why is it clinically important?",
     "30–300 mg albumin/24h. It is the earliest detectable marker of diabetic nephropathy "
     "and indicates early glomerular damage. (Harper's Biochemistry 32nd Ed.)"),
    ("Why does Rothera's test NOT detect β-hydroxybutyrate?",
     "β-Hydroxybutyrate lacks a keto (-C=O) group adjacent to the -OH group, so it does not "
     "react with sodium nitroprusside. Rothera's detects only acetone and acetoacetate."),
    ("Why is bile bilirubin absent in haemolytic jaundice?",
     "In haemolytic jaundice, bilirubin is unconjugated (indirect) – water-insoluble and "
     "albumin-bound. It cannot be filtered at the glomerulus and therefore does not appear in urine."),
    ("What does Hay's test measure and what is its principle?",
     "Hay's test detects bile salts. Principle: bile salts are detergents that lower surface tension of "
     "urine. Sulphur powder sinks when surface tension is reduced (bile salts present)."),
    ("What is the reagent used in Fouchet's test?",
     "Fouchet's reagent = 25g trichloroacetic acid + 10 mL of 10% FeCl₃ in 100 mL distilled water. "
     "FeCl₃ oxidises bilirubin to biliverdin (green)."),
    ("Why is acetic acid added in the heat coagulation test?",
     "Acetic acid acidifies urine to precipitate protein (albumin) and simultaneously dissolves "
     "false-positive phosphate precipitates. Protein turbidity persists in acid; phosphates dissolve."),
    ("Which ketone body is most abundant in DKA?",
     "β-Hydroxybutyrate (~78%), followed by acetoacetate (~20%), then acetone (~2%). "
     "Only acetone and acetoacetate are detected by Rothera's test."),
    ("What causes glycosuria without diabetes mellitus?",
     "Renal glycosuria (lowered renal threshold, Fanconi syndrome), pregnancy, "
     "administration of large glucose infusion."),
    ("What is nephrotic syndrome? What are its urine findings?",
     "Nephrotic syndrome: proteinuria >3.5 g/day, hypoalbuminaemia, generalised oedema, "
     "hyperlipidaemia, lipiduria. Urine: protein ++++, fatty casts, oval fat bodies."),
    ("What is Benedict's reagent composition?",
     "Copper sulphate (CuSO₄) + Sodium citrate + Sodium carbonate (Na₂CO₃). "
     "Citrate chelates Cu²⁺ to prevent premature precipitation in alkaline medium."),
    ("What colour does each positive result give in Benedict's test?",
     "Green (+) → Yellow (++) → Orange (+++) → Brick-red (++++) — corresponds to "
     "increasing glucose concentration from trace to >2%."),
    ("What is the foam test for bile salts?",
     "When urine is shaken vigorously, bile salts produce persistent yellow foam. "
     "Normal urine produces only white foam that disappears quickly."),
]

for q, a in qa_pairs:
    story.append(Table(
        [[Paragraph(f"Q: {q}", S("qt", fontSize=9.5, fontName="Helvetica-Bold",
                                  textColor=NAVY, spaceAfter=0)),
          Paragraph(f"A: {a}", S("at", fontSize=9.2, fontName="Helvetica",
                                  textColor=DGRAY, spaceAfter=0))]],
        colWidths=[TW*0.40, TW*0.60],
        style=TableStyle([
            ("BACKGROUND",(0,0),(0,-1), LGRAY),
            ("BACKGROUND",(1,0),(1,-1), WHITE),
            ("GRID",(0,0),(-1,-1), 0.3, colors.HexColor("#C8D8E8")),
            ("TOPPADDING",(0,0),(-1,-1),5),
            ("BOTTOMPADDING",(0,0),(-1,-1),5),
            ("LEFTPADDING",(0,0),(-1,-1),6),
            ("VALIGN",(0,0),(-1,-1),"TOP"),
            ("LINEAFTER",(0,0),(0,-1), 1.5, TEAL),
        ])
    ))
    story.append(sp(0.8))

story.append(sp(2))

# ── Footer ─────────────────────────────────────────────────────────────
story.append(HRFlowable(width=TW, thickness=1, color=NAVY))
story.append(Spacer(1, 0.1*cm))
story.append(Paragraph(
    "Sources: Harper's Illustrated Biochemistry 32nd Ed. · Henry's Clinical Diagnosis and Management by "
    "Laboratory Methods · Tietz Textbook of Laboratory Medicine 7th Ed.",
    S("foot", fontSize=7.5, textColor=MGRAY, fontName="Helvetica-Oblique", alignment=TA_CENTER, spaceAfter=0)
))

# ── BUILD ──────────────────────────────────────────────────────────────
doc.build(story)
print("PDF saved: Urine_Analysis_Notes.pdf")
Writing File

~/urine-analysis/create_pptx.js

const pptxgen = require("pptxgenjs");
const pres = new pptxgen();
pres.layout = "LAYOUT_16x9";
pres.title = "Urine Analysis – MBBS Biochemistry Practical";
pres.author = "Orris AI";

// ── Palette ───────────────────────────────────────────────────────────
const C = {
  navy:      "1A2E5C",
  teal:      "0E8A87",
  amber:     "F5A623",
  red:       "C0392B",
  green:     "1E7E34",
  white:     "FFFFFF",
  offWhite:  "F0F4FF",
  pale:      "E6F7F7",
  amberPale: "FFF8E7",
  redPale:   "FDF0EF",
  gray:      "444444",
  lgray:     "D6E4F0",
  darkBg:    "0D1B3E",
  row1:      "E8F4F8",
};

// ── Helpers ───────────────────────────────────────────────────────────
const setBg = (slide, color) => { slide.background = { color }; };

function hdr(slide, title, sub, accentColor = C.teal) {
  slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:1.05, fill:{ color:C.navy } });
  slide.addShape(pres.ShapeType.rect, { x:0, y:0, w:0.18, h:5.625, fill:{ color:accentColor }, line:{ color:accentColor } });
  slide.addText(title, { x:0.3, y:0.08, w:9.5, h:0.55, fontSize:20, bold:true, color:C.white, margin:0 });
  if (sub) slide.addText(sub, { x:0.3, y:0.65, w:9.5, h:0.35, fontSize:10, color:C.amber, margin:0 });
}

function makeTable(slide, headers, rows, x, y, w, h) {
  const n = headers.length;
  const cw = Array(n).fill(w / n);
  const data = [];
  data.push(headers.map(h => ({
    text: h,
    options: { bold:true, color:C.white, fill:C.navy, fontSize:9, align:"center", valign:"middle" }
  })));
  rows.forEach((row, i) => {
    const fill = i % 2 === 0 ? C.row1 : C.white;
    data.push(row.map(cell => ({
      text: String(cell),
      options: { fill, fontSize:8.8, color:C.gray, valign:"top" }
    })));
  });
  slide.addTable(data, {
    x, y, w, h, colW: cw,
    border: { type:"solid", color:C.lgray, pt:0.5 },
    rowH: 0
  });
}

function makeTable2(slide, headers, rows, x, y, w, h, colW) {
  const data = [];
  data.push(headers.map(h => ({
    text: h,
    options: { bold:true, color:C.white, fill:C.navy, fontSize:9, align:"center", valign:"middle" }
  })));
  rows.forEach((row, i) => {
    const fill = i % 2 === 0 ? C.row1 : C.white;
    data.push(row.map(cell => ({
      text: String(cell),
      options: { fill, fontSize:8.5, color:C.gray, valign:"top" }
    })));
  });
  slide.addTable(data, {
    x, y, w, h, colW,
    border: { type:"solid", color:C.lgray, pt:0.5 },
    rowH: 0
  });
}

function bullets(slide, items, x, y, w, h, fontSize=10, color=C.gray) {
  const arr = items.map((txt, i) => ({
    text: txt,
    options: { bullet:{ type:"bullet" }, color, fontSize, breakLine: i < items.length-1 }
  }));
  slide.addText(arr, { x, y, w, h, valign:"top" });
}

function callout(slide, text, x, y, w, h, bg, border, textColor=C.gray) {
  slide.addShape(pres.ShapeType.roundRect, { x, y, w, h, fill:{ color:bg }, line:{ color:border, pt:1.5 }, rectRadius:0.08 });
  slide.addText(text, { x:x+0.1, y:y+0.05, w:w-0.2, h:h-0.1, fontSize:9, color:textColor, italic:true, wrap:true, margin:0 });
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 1 – Title
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.darkBg);
  // left accent bar
  s.addShape(pres.ShapeType.rect, { x:0, y:0, w:0.35, h:5.625, fill:{ color:C.amber }, line:{ color:C.amber } });
  // decorative teal strip
  s.addShape(pres.ShapeType.rect, { x:0, y:3.9, w:10, h:1.7, fill:{ color:C.teal }, line:{ color:C.teal } });

  s.addText("MBBS 1st Year · Biochemistry Practical", { x:0.55, y:0.5, w:9, h:0.45, fontSize:14, color:C.amber, bold:false, margin:0 });
  s.addText("URINE ANALYSIS", { x:0.55, y:0.95, w:9, h:1.3, fontSize:48, bold:true, color:C.white, margin:0 });
  s.addText("Complete Revision Notes", { x:0.55, y:2.25, w:9, h:0.5, fontSize:18, color:colors => C.offWhite, margin:0 });

  s.addText("Complete Revision Notes", { x:0.55, y:2.25, w:9, h:0.45, fontSize:18, color:C.offWhite, margin:0 });
  s.addText("Normal & Abnormal Constituents  ·  Heat Coagulation  ·  Benedict's Test  ·  Rothera's Test  ·  Hay's Test  ·  Fouchet's Test",
    { x:0.55, y:2.72, w:9, h:0.38, fontSize:9.5, color:C.lgray, margin:0 });

  s.addText("Viva Q&A  ·  Jaundice Differential  ·  Clinical Significance", {
    x:0.55, y:3.98, w:9, h:0.38, fontSize:11, bold:true, color:C.white, margin:0
  });
  s.addText("Source: Harper's Illustrated Biochemistry 32nd Ed. · Henry's Clinical Diagnosis · Tietz Lab Medicine 7th Ed.", {
    x:0.55, y:4.42, w:9, h:0.35, fontSize:8.5, color:C.offWhite, italic:true, margin:0
  });
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 2 – Normal Physical Characteristics
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Normal Physical Characteristics of Urine", "Harper's Biochemistry: 'Physical characteristics include volume, odor, color, appearance, specific gravity, and pH'");

  makeTable(s,
    ["Parameter", "Normal Value", "Clinical Significance / Abnormal States"],
    [
      ["Volume / 24 h", "1000–1500 mL/day", "Oliguria <400 mL/day (renal failure, dehydration) · Polyuria >3 L/day (DM, DI) · Anuria <100 mL/day (acute renal failure)"],
      ["Color", "Pale yellow – amber\n(urochrome pigment)", "Colorless = dilute / diabetes insipidus · Dark amber = dehydration · Red/brown = haematuria or myoglobinuria · Dark brown = bile-stained (jaundice)"],
      ["Odor", "Aromatic\n(volatile organic acids)", "Fruity/sweet = ketones (DKA) · Ammoniacal = UTI/bacteria · Fishy = trimethylaminuria"],
      ["Appearance", "Clear, transparent", "Turbid = UTI, phosphaturia · Frothy = proteinuria (bile salts cause persistent yellow foam)"],
      ["pH", "4.5–8.0\n(average 6.0)", "Acid = protein-rich diet, fever, DKA · Alkaline = vegetarian diet, UTI (Proteus), renal tubular acidosis"],
      ["Specific Gravity", "1.003–1.030\n(avg 1.015–1.020)", "Very low (1.001–1.005) = diabetes insipidus · Fixed at 1.010 (isosthenuria) = severe renal impairment"],
    ],
    0.3, 1.15, 9.4, 4.15
  );
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 3 – Normal Chemical Constituents
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Normal Chemical Constituents of Urine", "Organic and inorganic components — commonly asked in spotters");

  // Two-column layout
  // Left – organic
  s.addShape(pres.ShapeType.rect, { x:0.3, y:1.15, w:4.5, h:4.1, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Organic Constituents", { x:0.35, y:1.2, w:4.4, h:0.3, fontSize:11, bold:true, color:C.teal, margin:0 });
  makeTable2(s,
    ["Substance", "Amount/Day"],
    [
      ["Urea (largest organic)", "25–30 g"],
      ["Creatinine", "1–2 g"],
      ["Uric acid", "0.5–1 g"],
      ["Ammonia", "0.3–1 g"],
      ["Hippuric acid", "0.1–1 g"],
      ["Amino acids (trace)", "1–2 g"],
      ["Vitamins / hormones", "Trace"],
    ],
    0.3, 1.5, 4.5, 3.55, [2.8, 1.7]
  );

  // Right – inorganic
  s.addShape(pres.ShapeType.rect, { x:5.2, y:1.15, w:4.5, h:4.1, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Inorganic Constituents", { x:5.25, y:1.2, w:4.4, h:0.3, fontSize:11, bold:true, color:C.navy, margin:0 });
  makeTable2(s,
    ["Substance", "Amount/Day"],
    [
      ["NaCl (largest inorganic)", "10–15 g"],
      ["Phosphates", "1–1.5 g"],
      ["Sulphates", "1.5–3 g"],
      ["Potassium", "2–4 g"],
      ["Calcium", "0.1–0.3 g"],
      ["Magnesium", "0.1–0.2 g"],
      ["Bicarbonate (variable)", "< 1 g"],
    ],
    5.2, 1.5, 4.5, 3.55, [2.8, 1.7]
  );
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 4 – Abnormal Constituents
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Abnormal Urine Constituents", "Pathological conditions and their urinary markers — 'Protein, glucose, blood, ketone bodies, bile salts, and bile pigments are abnormal constituents' — Harper's 32nd Ed.");

  makeTable(s,
    ["Abnormal Substance", "Disease / Condition", "Mechanism"],
    [
      ["Protein (albumin)\nProteinuria", "Nephrotic syndrome, glomerulonephritis,\nDiabetic nephropathy, UTI, pre-eclampsia", "Loss of glomerular BM integrity → albumin leaks. >150 mg/day = proteinuria; >3.5 g/day = nephrotic range. Microalbuminuria 30–300 mg/day = earliest sign of diabetic nephropathy"],
      ["Glucose\nGlycosuria", "Diabetes mellitus, renal glycosuria,\npregnancy, Fanconi syndrome", "Blood glucose > renal threshold (180 mg/dL) → tubular reabsorption overwhelmed. Renal glycosuria = normal blood glucose + low threshold"],
      ["Ketone bodies\nKetonuria", "DKA, starvation, alcoholic ketoacidosis,\nprolonged vomiting, ketogenic diet", "Excess fatty acid oxidation → ketogenesis. 3 bodies: acetone (2%), acetoacetate (20%), β-OH butyrate (78%)"],
      ["Bile pigments (bilirubin)\nBilirubinuria", "Hepatocellular jaundice, obstructive jaundice\n(ABSENT in haemolytic jaundice)", "Only conjugated bilirubin (water-soluble) crosses glomerulus. Unconjugated is albumin-bound → cannot appear in urine"],
      ["Bile salts", "Obstructive jaundice, hepatic jaundice\n(ABSENT in haemolytic jaundice)", "Bile salts regurgitate into blood when bile duct blocked → filtered at glomerulus → appear in urine"],
      ["Blood (haematuria)", "UTI, renal calculi, glomerulonephritis,\nIgA nephropathy, tumours", "Intact RBCs or free haemoglobin. RBC casts → glomerulonephritis"],
      ["Casts", "Nephrotic/nephritic syndrome,\nacute tubular necrosis (ATN)", "Protein matrix formed in tubules. Hyaline → Granular → Waxy → RBC casts (progressive severity)"],
    ],
    0.3, 1.15, 9.4, 4.1
  );
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 5 – TEST 1: Heat Coagulation (Protein)
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Test 1 – Protein (Albumin): Heat Coagulation Test", "Most commonly done urine test in practical exam", C.navy);

  // Left panel – procedure
  s.addShape(pres.ShapeType.rect, { x:0.3, y:1.15, w:4.55, h:4.1, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Principle & Procedure", { x:0.4, y:1.2, w:4.3, h:0.3, fontSize:11, bold:true, color:C.navy, margin:0 });
  bullets(s, [
    "Principle: Protein denatures & precipitates on heating at acid pH",
    "Acetic acid differentiates protein precipitate (PERSISTS) from phosphate precipitate (dissolves)",
    "Step 1: Fill test tube 2/3 with urine",
    "Step 2: Tilt 45°, heat UPPER portion only until it boils",
    "Step 3: Compare with lower (unheated) portion",
    "Step 4: If turbidity appears → add 2–3 drops 1% acetic acid",
    "Positive: White turbidity persists after acid = PROTEIN PRESENT",
    "Negative: Turbidity dissolves in acid = phosphates (false +ve eliminated)",
  ], 0.4, 1.55, 4.3, 3.5, 9.5, C.gray);

  // Right panel – grading + significance
  s.addShape(pres.ShapeType.rect, { x:5.2, y:1.15, w:4.5, h:2.1, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Result Grading", { x:5.3, y:1.2, w:4.3, h:0.3, fontSize:11, bold:true, color:C.teal, margin:0 });
  makeTable2(s,
    ["Grade", "Appearance", "Approx. Protein"],
    [
      ["Negative", "Clear blue (no change)", "< 30 mg/dL"],
      ["Trace (+)", "Slight cloudiness", "30 mg/dL"],
      ["+ +", "Distinct turbidity", "100 mg/dL"],
      ["+ + +", "Heavy turbidity, granular", "200–300 mg/dL"],
      ["+ + + +", "Solid clot of precipitate", "> 500 mg/dL"],
    ],
    5.2, 1.5, 4.5, 1.55, [0.9, 1.6, 1.3]
  );

  s.addShape(pres.ShapeType.rect, { x:5.2, y:3.35, w:4.5, h:1.9, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Clinical Significance", { x:5.3, y:3.4, w:4.3, h:0.3, fontSize:11, bold:true, color:C.red, margin:0 });
  bullets(s, [
    "Nephrotic syndrome (>3.5 g/day – massive)",
    "Glomerulonephritis (+ haematuria)",
    "Diabetic nephropathy (microalbuminuria early)",
    "UTI, fever, strenuous exercise (transient)",
    "Pre-eclampsia / eclampsia",
    "Orthostatic proteinuria (benign)",
  ], 5.3, 3.7, 4.3, 1.4, 9, C.gray);

  callout(s, "Microalbuminuria (30–300 mg albumin/24h) is the EARLIEST detectable marker of diabetic nephropathy. — Harper's 32nd Ed.",
    0.3, 5.25, 9.4, 0.35, C.pale, C.teal, C.teal);
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 6 – TEST 2: Benedict's Test
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Test 2 – Glucose: Benedict's Qualitative Test", "Reducing sugar detection — Cu²⁺ → Cu⁺ (cuprous oxide) reaction");

  // Principle box
  s.addShape(pres.ShapeType.rect, { x:0.3, y:1.15, w:9.4, h:0.85, fill:{ color:C.navy }, line:{ color:C.navy } });
  s.addText("Principle: Glucose (reducing sugar) reduces Cu²⁺  →  Cu⁺  →  Cu₂O (brick-red precipitate) in alkaline medium on heating", {
    x:0.4, y:1.22, w:9.2, h:0.6, fontSize:11, bold:true, color:C.amber, align:"center", margin:0 });

  // Left – procedure
  s.addShape(pres.ShapeType.rect, { x:0.3, y:2.1, w:3.8, h:3.3, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Procedure", { x:0.4, y:2.15, w:3.6, h:0.28, fontSize:11, bold:true, color:C.navy, margin:0 });
  bullets(s, [
    "Take 5 mL Benedict's reagent in test tube",
    "Add 8 drops (0.4 mL) of urine",
    "Mix well",
    "Place in boiling water bath 5 min\n(OR heat directly 2 min)",
    "Cool and observe colour change",
    "Reagent: CuSO₄ + Na citrate + Na₂CO₃",
    "(Citrate chelates Cu²⁺ to prevent\npremature precipitation in alkaline pH)",
  ], 0.4, 2.45, 3.6, 2.8, 9.2, C.gray);

  // Middle – colour chart
  s.addShape(pres.ShapeType.rect, { x:4.2, y:2.1, w:2.8, h:3.3, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Colour Interpretation", { x:4.3, y:2.15, w:2.6, h:0.28, fontSize:11, bold:true, color:C.teal, margin:0 });

  const colorChips = [
    ["3030B0", "Blue (no change)", "Negative", "< 0.5%"],
    ["228B22", "Green precipitate", "Trace (+)", "0.1–0.5%"],
    ["DAA520", "Yellow precipitate", "++ ", "0.5–1%"],
    ["FF8C00", "Orange precipitate", "+++", "1–2%"],
    ["B22222", "Brick-red precipitate", "++++", "> 2%"],
  ];
  colorChips.forEach(([hex, label, grade, conc], i) => {
    const y = 2.5 + i * 0.54;
    s.addShape(pres.ShapeType.rect, { x:4.25, y, w:0.22, h:0.35, fill:{ color:hex }, line:{ color:hex } });
    s.addText(grade, { x:4.5, y: y+0.04, w:0.55, h:0.28, fontSize:9, bold:true, color:C.gray, margin:0 });
    s.addText(conc, { x:5.05, y: y+0.04, w:0.55, h:0.28, fontSize:9, color:C.gray, margin:0 });
    s.addText(label, { x:5.6, y: y+0.04, w:1.35, h:0.28, fontSize:8.5, color:C.gray, italic:true, margin:0 });
  });

  // Right – notes
  s.addShape(pres.ShapeType.rect, { x:7.1, y:2.1, w:2.6, h:3.3, fill:{ color:C.amberPale }, line:{ color:C.amber } });
  s.addText("⚠ Important Notes", { x:7.2, y:2.15, w:2.4, h:0.28, fontSize:11, bold:true, color:C.red, margin:0 });
  bullets(s, [
    "Detects ALL reducing sugars (not specific for glucose)",
    "Also detects: galactose, fructose, lactose, maltose, pentoses",
    "False +ve: uric acid, creatinine, glucuronides (drugs)",
    "For glucose specificity → use GOD-POD (glucose oxidase)",
    "Renal threshold = 180 mg/dL",
    "Pregnancy: reduced threshold → glycosuria possible with normal blood glucose",
  ], 7.2, 2.5, 2.35, 2.75, 8.8, C.gray);

  callout(s, "Galactosuria (galactosaemia in newborns) gives a positive Benedict's but negative glucose oxidase test – important to distinguish!",
    0.3, 5.26, 9.4, 0.34, C.redPale, C.red, C.red);
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 7 – TEST 3: Rothera's Test
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Test 3 – Ketone Bodies: Rothera's Test", "Sodium nitroprusside reaction — Henry's Clinical Diagnosis: 'Rothera method detects acetoacetic acid and acetone'");

  // Principle
  s.addShape(pres.ShapeType.rect, { x:0.3, y:1.15, w:9.4, h:0.72, fill:{ color:C.navy }, line:{ color:C.navy } });
  s.addText("Principle: Acetone/Acetoacetate + Na nitroprusside + NH₄OH  →  Purple/violet ring at junction of two layers", {
    x:0.4, y:1.22, w:9.2, h:0.55, fontSize:11, bold:true, color:C.amber, align:"center", margin:0 });

  // Left
  s.addShape(pres.ShapeType.rect, { x:0.3, y:1.95, w:4.8, h:3.0, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Procedure", { x:0.4, y:2.0, w:4.6, h:0.28, fontSize:11, bold:true, color:C.navy, margin:0 });
  bullets(s, [
    "Reagent: Ammonium sulphate + Sodium nitroprusside (solid)",
    "Step 1: Fill test tube half-full with urine",
    "Step 2: Add excess Rothera's solid – shake to dissolve",
    "Step 3: Carefully LAYER concentrated ammonia (NH₄OH)\nalong the side of the tilted test tube",
    "Step 4: Stand 2–3 min WITHOUT mixing",
    "Step 5: Observe junction of two layers",
    "POSITIVE: Purple/violet ring at junction",
  ], 0.4, 2.3, 4.6, 2.5, 9.5, C.gray);

  // Right
  s.addShape(pres.ShapeType.rect, { x:5.2, y:1.95, w:4.5, h:3.0, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Ketone Bodies – Clinical Context", { x:5.3, y:2.0, w:4.3, h:0.28, fontSize:11, bold:true, color:C.teal, margin:0 });
  makeTable2(s,
    ["Ketone Body", "% in DKA", "Detected by Rothera's?"],
    [
      ["β-Hydroxybutyrate", "~78% (majority)", "NO ✗ (no keto group)"],
      ["Acetoacetate", "~20%", "YES ✓"],
      ["Acetone", "~2%", "YES ✓"],
    ],
    5.2, 2.3, 4.5, 1.35, [1.7, 1.4, 1.4]
  );
  s.addText("Causes of Ketonuria:", { x:5.3, y:3.75, w:4.3, h:0.28, fontSize:10, bold:true, color:C.red, margin:0 });
  bullets(s, [
    "Diabetic ketoacidosis (DKA) — Type 1 DM most common",
    "Starvation / prolonged fasting",
    "Alcoholic ketoacidosis",
    "Prolonged vomiting (hyperemesis gravidarum)",
    "High-fat / ketogenic diet",
  ], 5.3, 4.05, 4.3, 1.65, 9, C.gray);

  callout(s, "⚠ Critical Viva: β-Hydroxybutyrate is the MOST ABUNDANT ketone body (~78%) in DKA yet is NOT detected by Rothera's test. It lacks a keto group so does not react with nitroprusside. — Henry's Clinical Diagnosis",
    0.3, 5.02, 9.4, 0.55, C.redPale, C.red, C.red);
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 8 – TEST 4: Hay's Test
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Test 4 – Bile Salts: Hay's Sulphur Test", "Surface tension method — bile salts as biological detergents");

  s.addShape(pres.ShapeType.rect, { x:0.3, y:1.15, w:9.4, h:0.68, fill:{ color:C.navy }, line:{ color:C.navy } });
  s.addText("Principle: Bile salts (detergents) lower surface tension of urine → sulphur powder can no longer float → SINKS to the bottom", {
    x:0.4, y:1.2, w:9.2, h:0.55, fontSize:11, bold:true, color:C.amber, align:"center", margin:0 });

  // Left – procedure
  s.addShape(pres.ShapeType.rect, { x:0.3, y:1.93, w:4.8, h:2.55, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Procedure", { x:0.4, y:1.98, w:4.6, h:0.28, fontSize:11, bold:true, color:C.navy, margin:0 });
  bullets(s, [
    "Reagent: Flowers of sulphur (powdered elemental sulphur, S)",
    "Step 1: Pour fresh urine into a clean beaker (use wide vessel — NOT a narrow test tube)",
    "Step 2: Gently sprinkle powdered sulphur on the surface",
    "Step 3: Observe immediately — do NOT shake or disturb",
    "POSITIVE: Sulphur SINKS → Bile salts PRESENT",
    "NEGATIVE: Sulphur FLOATS → Bile salts ABSENT",
    "Foam test (alternate): shake vigorously → persistent yellow foam = positive",
  ], 0.4, 2.28, 4.6, 2.1, 9.5, C.gray);

  // Middle – visual result boxes
  s.addShape(pres.ShapeType.rect, { x:5.2, y:1.93, w:2.1, h:2.55, fill:{ color:"E8FFF0" }, line:{ color:C.green } });
  s.addText("POSITIVE", { x:5.2, y:2.05, w:2.1, h:0.35, fontSize:13, bold:true, color:C.green, align:"center", margin:0 });
  s.addText("Sulphur\nSINKS ↓", { x:5.2, y:2.5, w:2.1, h:0.9, fontSize:16, bold:true, color:C.green, align:"center", margin:0 });
  s.addText("Bile salts PRESENT\n(Obstructive/Hepatic jaundice)", { x:5.2, y:3.5, w:2.1, h:0.7, fontSize:8.5, color:C.gray, align:"center", margin:0 });

  s.addShape(pres.ShapeType.rect, { x:7.5, y:1.93, w:2.2, h:2.55, fill:{ color:C.redPale }, line:{ color:C.red } });
  s.addText("NEGATIVE", { x:7.5, y:2.05, w:2.2, h:0.35, fontSize:13, bold:true, color:C.red, align:"center", margin:0 });
  s.addText("Sulphur\nFLOATS ↑", { x:7.5, y:2.5, w:2.2, h:0.9, fontSize:16, bold:true, color:C.red, align:"center", margin:0 });
  s.addText("Bile salts ABSENT\n(Normal or Haemolytic jaundice)", { x:7.5, y:3.5, w:2.2, h:0.7, fontSize:8.5, color:C.gray, align:"center", margin:0 });

  // Bottom – significance
  s.addShape(pres.ShapeType.rect, { x:0.3, y:4.58, w:9.4, h:0.6, fill:{ color:C.pale }, line:{ color:C.teal } });
  s.addText("Bile Salts in Jaundice: PRESENT in obstructive and hepatocellular jaundice · ABSENT in haemolytic (pre-hepatic) jaundice\nBile salts = sodium glycocholate + sodium taurocholate. Surface tension of normal urine ≈ 66 dynes/cm; bile salts reduce it to < 40 dynes/cm.",
    { x:0.5, y:4.62, w:9.0, h:0.52, fontSize:8.8, color:C.teal, margin:0 });
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 9 – TEST 5: Fouchet's Test
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Test 5 – Bile Pigments (Bilirubin): Fouchet's Test", "Oxidation of bilirubin to biliverdin by FeCl₃ in acid medium");

  s.addShape(pres.ShapeType.rect, { x:0.3, y:1.15, w:9.4, h:0.68, fill:{ color:C.navy }, line:{ color:C.navy } });
  s.addText("Principle: FeCl₃ (in TCA) oxidises bilirubin (yellow) → biliverdin (GREEN) + BaCl₂ concentrates bilirubin on filter paper", {
    x:0.4, y:1.2, w:9.2, h:0.55, fontSize:11, bold:true, color:C.amber, align:"center", margin:0 });

  // Left – procedure
  s.addShape(pres.ShapeType.rect, { x:0.3, y:1.93, w:4.8, h:3.45, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Procedure (Step-by-step)", { x:0.4, y:1.98, w:4.6, h:0.28, fontSize:11, bold:true, color:C.navy, margin:0 });
  bullets(s, [
    "Fouchet's Reagent: 25g TCA + 10 mL of 10% FeCl₃ in 100 mL water",
    "Step 1: Take 10 mL urine in test tube",
    "Step 2: Add 5 mL of 10% BaCl₂ solution; mix well",
    "(BaCl₂ precipitates bilirubin sulphate onto a carrier)",
    "Step 3: Filter through Whatman No.1 filter paper",
    "(Yellowish precipitate collects on filter paper)",
    "Step 4: Spread filter paper flat on a tile/glass plate",
    "Step 5: Add 1–2 drops Fouchet's reagent to the precipitate",
    "Step 6: Observe for colour change",
    "POSITIVE: GREEN or bluish-green colour = Bile pigments PRESENT",
  ], 0.4, 2.28, 4.6, 2.95, 9.2, C.gray);

  // Right – reagent box + significance
  s.addShape(pres.ShapeType.rect, { x:5.2, y:1.93, w:4.5, h:1.7, fill:{ color:C.amberPale }, line:{ color:C.amber } });
  s.addText("Why BaCl₂ is used first:", { x:5.3, y:1.98, w:4.3, h:0.28, fontSize:10, bold:true, color:C.navy, margin:0 });
  s.addText("BaCl₂ acts as a carrier/adsorbent. It precipitates bilirubin sulphate from urine and concentrates it onto the filter paper. This greatly increases the sensitivity of the test for detecting small amounts of bilirubin.", {
    x:5.3, y:2.28, w:4.3, h:1.2, fontSize:9, color:C.gray, margin:0 });

  s.addShape(pres.ShapeType.rect, { x:5.2, y:3.73, w:4.5, h:1.65, fill:{ color:C.white }, line:{ color:C.lgray } });
  s.addText("Clinical Significance", { x:5.3, y:3.78, w:4.3, h:0.28, fontSize:11, bold:true, color:C.red, margin:0 });
  bullets(s, [
    "Hepatocellular jaundice: viral hepatitis (A/B/C/E), cirrhosis, drug-induced",
    "Obstructive jaundice: gallstones, Ca pancreas, cholangiocarcinoma",
    "ABSENT in haemolytic (pre-hepatic) jaundice",
    "(Unconjugated bilirubin is albumin-bound → cannot cross glomerulus)",
  ], 5.3, 4.08, 4.3, 1.2, 9, C.gray);

  callout(s, "KEY: Only CONJUGATED (direct) bilirubin is water-soluble and appears in urine. UNCONJUGATED (indirect) bilirubin is albumin-bound and does NOT appear in urine.",
    0.3, 5.42, 9.4, 0.38, C.amberPale, C.amber, C.red);
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 10 – Summary Table: All 5 Tests
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Summary – All 5 Urine Tests at a Glance", "Quick reference for practical exam and viva");

  makeTable2(s,
    ["Test", "Detects", "Principle", "Reagent", "Positive Result", "Absent In"],
    [
      ["Heat\nCoagulation", "Protein\n(albumin)", "Denaturation at acid pH", "Heat + 1%\nacetic acid", "White turbidity\n(persists in acid)", "Normal urine"],
      ["Benedict's\nTest", "Glucose\n(reducing sugars)", "Cu²⁺ → Cu⁺ → Cu₂O\n(brick-red)", "Benedict's reagent\n(CuSO₄+citrate+Na₂CO₃)", "Green→Yellow→\nOrange→Brick-red", "Normal urine;\nHaemolytic jaundice"],
      ["Rothera's\nTest", "Ketones\n(acetone +\nacetoacetate)", "Nitroprusside +\nketones → purple ring\nin alkali", "Rothera's reagent\n+ conc. ammonia", "Purple/violet ring\nat junction", "Normal urine;\nβ-OH butyrate NOT detected"],
      ["Hay's Test\n(Sulphur)", "Bile salts", "Bile salts lower\nsurface tension → S sinks", "Flowers of\nsulphur (powder)", "Sulphur SINKS", "Normal urine;\nHaemolytic jaundice"],
      ["Fouchet's\nTest", "Bile pigments\n(bilirubin)", "FeCl₃ oxidises bilirubin\n→ biliverdin (green)", "BaCl₂ + Fouchet's\nreagent (TCA+FeCl₃)", "GREEN on\nfilter paper", "Normal urine;\nHaemolytic jaundice"],
    ],
    0.3, 1.15, 9.4, 4.15, [0.92, 0.92, 1.75, 1.80, 1.65, 1.56]
  );
  callout(s, "Hay's Test + Fouchet's Test: BOTH positive in obstructive and hepatic jaundice, BOTH negative in haemolytic (pre-hepatic) jaundice",
    0.3, 5.37, 9.4, 0.22, C.pale, C.teal, C.teal);
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 11 – Jaundice Differential (Urine Tests)
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Jaundice – Urine Test Differential Diagnosis", "Most-asked viva comparison table");

  makeTable2(s,
    ["Finding", "Haemolytic (Pre-hepatic)", "Hepatocellular (Hepatic)", "Obstructive (Post-hepatic)"],
    [
      ["Urine bilirubin\n(Fouchet's)", "ABSENT ✗", "PRESENT ✓", "PRESENT ++ ✓"],
      ["Urine bile salts\n(Hay's test)", "ABSENT ✗", "PRESENT ✓", "PRESENT ✓✓"],
      ["Urine urobilinogen", "INCREASED ↑↑", "Variable\n(↑ early, ↓ late)", "ABSENT ✗"],
      ["Urine colour", "Normal / dark\n(↑ urobilinogen)", "Amber / dark", "Dark brown\n(bile-stained)"],
      ["Stool colour", "Dark\n(↑ stercobilin)", "Normal / pale", "Pale / clay-coloured\n(↓ stercobilin)"],
      ["Serum indirect bili", "Markedly ↑↑", "Increased", "Normal / slight ↑"],
      ["Serum direct bili", "Normal", "Increased", "Markedly ↑↑"],
      ["ALT / AST", "Normal", "Very high ↑↑↑", "Moderate ↑"],
      ["ALP", "Normal", "Moderate ↑", "Very high ↑↑↑"],
      ["Common examples", "G6PD deficiency,\nhaemolytic anaemia", "Viral hepatitis,\ncirrhosis", "Gallstones,\nCa pancreas"],
    ],
    0.3, 1.15, 9.4, 4.1, [2.0, 2.4, 2.4, 2.6]
  );
  callout(s, "Mnemonic: Haemolytic jaundice – bile tests ABSENT in urine (unconjugated bilirubin can't cross glomerulus). Obstructive – bile tests PRESENT (conjugated bilirubin floods blood and urine).",
    0.3, 5.33, 9.4, 0.27, C.amberPale, C.amber, C.red);
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 12 – Viva Q&A
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.offWhite);
  hdr(s, "Rapid-Fire Viva Q&A – Urine Analysis", "Top 12 questions with one-line answers");

  const qa = [
    ["Normal urine pH?", "4.5–8.0 (average 6.0)"],
    ["Normal urine specific gravity?", "1.003–1.030 (avg 1.015–1.020)"],
    ["Renal threshold for glucose?", "180 mg/dL"],
    ["What is microalbuminuria?", "30–300 mg albumin/24h = earliest sign of diabetic nephropathy"],
    ["Why does Rothera's miss β-OH butyrate?", "β-OH butyrate lacks a keto group; does not react with nitroprusside"],
    ["Hay's test: sulphur sinks or floats if positive?", "SINKS (bile salts lower surface tension)"],
    ["What does Fouchet's reagent contain?", "25g TCA + 10 mL 10% FeCl₃ in 100 mL water"],
    ["Why add acetic acid in heat coagulation test?", "To dissolve false-positive phosphate precipitate; protein turbidity persists"],
    ["Most abundant ketone body in DKA?", "β-Hydroxybutyrate (~78%)"],
    ["Why is bilirubin absent in haemolytic jaundice urine?", "Unconjugated bilirubin is albumin-bound (water-insoluble) → cannot cross glomerulus"],
    ["Benedict's detects glucose specifically?", "NO – detects ALL reducing sugars. Use glucose oxidase for specificity."],
    ["Both bile tests positive (Hay's + Fouchet's) but urobilinogen absent?", "Obstructive (post-hepatic) jaundice"],
  ];

  makeTable2(s,
    ["Question", "Answer"],
    qa,
    0.3, 1.15, 9.4, 4.15, [5.2, 4.2]
  );
  callout(s, "Remember: In haemolytic jaundice – urobilinogen is INCREASED but bile pigments and bile salts are ABSENT in urine.",
    0.3, 5.35, 9.4, 0.27, C.pale, C.teal, C.teal);
}

// ══════════════════════════════════════════════════════════════════════
// SLIDE 13 – Final Revision Checklist
// ══════════════════════════════════════════════════════════════════════
{
  const s = pres.addSlide();
  setBg(s, C.darkBg);
  s.addShape(pres.ShapeType.rect, { x:0, y:0, w:10, h:1.0, fill:{ color:C.teal }, line:{ color:C.teal } });
  s.addText("Exam Day – Urine Analysis Checklist", { x:0.3, y:0.1, w:9.4, h:0.55, fontSize:22, bold:true, color:C.white, margin:0 });
  s.addText("Check each point before entering the exam hall", { x:0.3, y:0.65, w:9.4, h:0.3, fontSize:10, color:C.offWhite, margin:0 });

  const checkItems = [
    ["Physical parameters", "Volume 1–1.5 L | pH 4.5–8.0 | Sp. Gr 1.003–1.030 | Color pale yellow (urochrome)"],
    ["Abnormal constituents", "Protein → nephrotic; Glucose → DM; Ketones → DKA; Bile pigments/salts → jaundice; Casts → renal damage"],
    ["Heat Coagulation", "Heat upper portion → add 1% acetic acid → white turbidity that PERSISTS = protein +ve"],
    ["Benedict's Test", "5 mL reagent + 8 drops urine → boil → blue→green→yellow→orange→brick-red (increasing glucose)"],
    ["Rothera's Test", "Rothera's reagent + layer ammonia → purple ring = ketones. Does NOT detect β-OH butyrate"],
    ["Hay's Test", "Sprinkle sulphur powder → SINKS = bile salts present. ABSENT in haemolytic jaundice"],
    ["Fouchet's Test", "BaCl₂ → filter paper → Fouchet's reagent → GREEN = bile pigments. ABSENT in haemolytic jaundice"],
    ["Jaundice differential", "Haemolytic: bile tests absent, urobilinogen ↑↑ | Obstructive: bile tests +, urobilinogen absent"],
    ["Benedict's specificity", "NOT specific for glucose (detects all reducing sugars); use glucose oxidase for confirmation"],
    ["Rothera's key fact", "β-Hydroxybutyrate (most abundant in DKA, ~78%) is NOT detected by Rothera's test"],
  ];

  checkItems.forEach(([topic, detail], i) => {
    const x = i < 5 ? 0.3 : 5.2;
    const y = 1.1 + (i % 5) * 0.85;
    const w = 4.55;
    s.addShape(pres.ShapeType.rect, { x, y, w, h:0.75, fill:{ color:"182748" }, line:{ color:C.teal, pt:0.8 } });
    s.addText(`✓ ${topic}`, { x:x+0.12, y:y+0.05, w:w-0.2, h:0.25, fontSize:9.5, bold:true, color:C.amber, margin:0 });
    s.addText(detail, { x:x+0.12, y:y+0.3, w:w-0.2, h:0.38, fontSize:8.5, color:C.offWhite, wrap:true, margin:0 });
  });
}

// ── Write file ──────────────────────────────────────────────────────
pres.writeFile({ fileName: "/home/daytona/workspace/urine-analysis/Urine_Analysis_Presentation.pptx" })
  .then(() => console.log("PPTX saved."))
  .catch(e => { console.error("ERROR:", e); process.exit(1); });
Running Command

cd /home/daytona/workspace/urine-analysis && python3 create_pdf.py 2>&1 && node create_pptx.js 2>&1

Editing File

~/urine-analysis/create_pptx.js

Error: String not found in file: '  s.addText("Complete Revision Notes", { x:0.55, y:2.25, w:9, h:0.5, fontSize:18, color:colors => C.offWhite, margin:0 });
  s.addText("Complete Revision Notes", { x:0.55, y:2.25, w:9, h:0.45, fontSize:18, color:C.offWhite, margin:0 });'
Searching Content

"color:colors" in ~/urine-analysis

Running Command

sed -i 's/color:colors => C.offWhite/color:C.offWhite/g' /home/daytona/workspace/urine-analysis/create_pptx.js && node /home/daytona/workspace/urine-analysis/create_pptx.js 2>&1

Reading File
Editing File

~/urine-analysis/create_pptx.js

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/urine-analysis/create_pptx.js'
Running Command

node /home/daytona/workspace/urine-analysis/create_pptx.js 2>&1

Writing File

~/urine-analysis/create_flashcards.py

#!/usr/bin/env python3
"""Urine Analysis – Flashcard Q&A PDF (2-column card layout, print & cut)"""

from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Spacer, Paragraph
from reportlab.lib.enums import TA_CENTER, TA_LEFT

W, H = A4
MARGIN = 1.2 * cm

NAVY    = colors.HexColor("#1A2E5C")
TEAL    = colors.HexColor("#0E8A87")
AMBER   = colors.HexColor("#F5A623")
RED     = colors.HexColor("#C0392B")
GREEN   = colors.HexColor("#1B7A34")
WHITE   = colors.white
LGRAY   = colors.HexColor("#F0F4FF")
DGRAY   = colors.HexColor("#333333")
AMBERLT = colors.HexColor("#FFF3CC")
TEALLT  = colors.HexColor("#E0F5F5")
REDLT   = colors.HexColor("#FDECEA")
GREENLT = colors.HexColor("#E8F8EC")
NAVYLT  = colors.HexColor("#E8EEF8")

doc = SimpleDocTemplate(
    "/home/daytona/workspace/urine-analysis/Urine_Analysis_Flashcards.pdf",
    pagesize=A4,
    leftMargin=MARGIN, rightMargin=MARGIN,
    topMargin=MARGIN, bottomMargin=MARGIN,
    title="Urine Analysis Flashcards – MBBS Biochemistry"
)

def S(name, **kw):
    d = dict(fontName="Helvetica", fontSize=9, textColor=DGRAY, leading=12, spaceAfter=0)
    d.update(kw)
    return ParagraphStyle(name, **d)

CARD_W = (W - 2*MARGIN - 0.4*cm) / 2   # two cards side by side

def card(q_text, a_text, q_color=NAVY, a_color=TEAL, bg_q=NAVYLT, bg_a=TEALLT, category=""):
    """Returns a 2-cell table (Question | Answer) as one flashcard row."""
    cat_style = S("cat", fontSize=7.5, textColor=WHITE, fontName="Helvetica-Bold",
                  spaceAfter=0, leading=10)
    q_style   = S("q", fontSize=9.5, textColor=DGRAY, fontName="Helvetica-Bold",
                  leading=13, spaceAfter=0)
    a_style   = S("a", fontSize=9.2, textColor=DGRAY, fontName="Helvetica",
                  leading=13, spaceAfter=0)

    q_cell = Table(
        [[Paragraph(category, cat_style)],
         [Spacer(1, 0.05*cm)],
         [Paragraph(f"Q: {q_text}", q_style)]],
        colWidths=[CARD_W - 0.3*cm],
        style=TableStyle([
            ("BACKGROUND",(0,0),(0,0), q_color),
            ("BACKGROUND",(0,1),(-1,-1), bg_q),
            ("TOPPADDING",(0,0),(-1,-1),4),
            ("BOTTOMPADDING",(0,0),(-1,-1),4),
            ("LEFTPADDING",(0,0),(-1,-1),6),
        ])
    )
    a_cell = Table(
        [[Paragraph("ANSWER", S("alabel", fontSize=7.5, textColor=WHITE,
                                 fontName="Helvetica-Bold", spaceAfter=0, leading=10))],
         [Spacer(1, 0.05*cm)],
         [Paragraph(a_text, a_style)]],
        colWidths=[CARD_W - 0.3*cm],
        style=TableStyle([
            ("BACKGROUND",(0,0),(0,0), a_color),
            ("BACKGROUND",(0,1),(-1,-1), bg_a),
            ("TOPPADDING",(0,0),(-1,-1),4),
            ("BOTTOMPADDING",(0,0),(-1,-1),4),
            ("LEFTPADDING",(0,0),(-1,-1),6),
        ])
    )
    return q_cell, a_cell

def make_card_row(pairs):
    """pairs = list of (q, a, cat, colors...) tuples, 2 per row"""
    rows = []
    for i in range(0, len(pairs), 2):
        left  = pairs[i]
        right = pairs[i+1] if i+1 < len(pairs) else None
        q1, a1 = card(*left)
        if right:
            q2, a2 = card(*right)
            rows.append(Table([[q1, q2]], colWidths=[CARD_W, CARD_W],
                style=TableStyle([("LEFTPADDING",(0,0),(-1,-1),2), ("RIGHTPADDING",(0,0),(-1,-1),2), ("TOPPADDING",(0,0),(-1,-1),2), ("BOTTOMPADDING",(0,0),(-1,-1),2)])))
            rows.append(Table([[a1, a2]], colWidths=[CARD_W, CARD_W],
                style=TableStyle([("LEFTPADDING",(0,0),(-1,-1),2), ("RIGHTPADDING",(0,0),(-1,-1),2), ("TOPPADDING",(0,0),(-1,-1),0), ("BOTTOMPADDING",(0,0),(-1,-1),3), ("LINEBELOW",(0,0),(-1,-1),0.8, colors.HexColor("#C0C8D8"))])))
        else:
            rows.append(Table([[q1, ""]], colWidths=[CARD_W, CARD_W],
                style=TableStyle([("LEFTPADDING",(0,0),(-1,-1),2), ("RIGHTPADDING",(0,0),(-1,-1),2), ("TOPPADDING",(0,0),(-1,-1),2), ("BOTTOMPADDING",(0,0),(-1,-1),2)])))
            rows.append(Table([[a1, ""]], colWidths=[CARD_W, CARD_W],
                style=TableStyle([("LEFTPADDING",(0,0),(-1,-1),2), ("RIGHTPADDING",(0,0),(-1,-1),2), ("TOPPADDING",(0,0),(-1,-1),0), ("BOTTOMPADDING",(0,0),(-1,-1),3), ("LINEBELOW",(0,0),(-1,-1),0.8, colors.HexColor("#C0C8D8"))])))
    return rows

story = []

# ── COVER STRIP ────────────────────────────────────────────────────────
cover = Table([
    [Paragraph("URINE ANALYSIS  ·  MBBS BIOCHEMISTRY PRACTICAL",
               S("ct", fontSize=13, fontName="Helvetica-Bold", textColor=WHITE, alignment=TA_CENTER, spaceAfter=0))],
    [Paragraph("Flashcard Q&amp;A  ·  30 Cards  ·  Print &amp; Cut",
               S("cs", fontSize=9, fontName="Helvetica", textColor=AMBERLT, alignment=TA_CENTER, spaceAfter=0))],
], colWidths=[W - 2*MARGIN],
style=TableStyle([
    ("BACKGROUND",(0,0),(-1,-1), NAVY),
    ("TOPPADDING",(0,0),(-1,-1),8), ("BOTTOMPADDING",(0,0),(-1,-1),8),
    ("LEFTPADDING",(0,0),(-1,-1),10),
    ("LINEBELOW",(0,-1),(-1,-1), 2.5, AMBER),
]))
story.append(cover)
story.append(Spacer(1, 0.25*cm))

# ══════════════════════════════════════════════════════════════════════
# FLASHCARD DATA: (question, answer, category, q_color, a_color, bg_q, bg_a)
# ══════════════════════════════════════════════════════════════════════

# Shorthand for category colors
def basic(q, a, cat="Physical Parameters"):
    return (q, a, cat, NAVY, TEAL, NAVYLT, TEALLT)
def test(q, a, cat="Urine Tests"):
    return (q, a, cat, colors.HexColor("#0B5563"), TEAL, colors.HexColor("#E0EEF2"), TEALLT)
def abnorm(q, a, cat="Abnormal Constituents"):
    return (q, a, cat, RED, colors.HexColor("#9B1B0F"), REDLT, colors.HexColor("#FADCD9"))
def jaund(q, a, cat="Jaundice / Clinical"):
    return (q, a, cat, AMBER, colors.HexColor("#B87A10"), AMBERLT, colors.HexColor("#FFF0C0"))
def viva(q, a, cat="Viva – Key Fact"):
    return (q, a, cat, GREEN, colors.HexColor("#155228"), GREENLT, colors.HexColor("#D4F0DC"))

cards = [
    # ── Physical parameters ──────────────────────────────────────────
    basic("What is the normal urine volume per 24 hours?",
          "1000–1500 mL/day\nOliguria < 400 mL/day · Polyuria > 3 L/day · Anuria < 100 mL/day"),

    basic("What is the normal urine pH?",
          "4.5–8.0 (average 6.0)\nAcidic in morning fasted state; Alkaline after vegetable diet or in UTI (Proteus)"),

    basic("What is the normal urine specific gravity?",
          "1.003–1.030 (average 1.015–1.020)\nFixed at ~1.010 (isosthenuria) = severe renal impairment\nLow 1.001–1.005 = diabetes insipidus"),

    basic("What gives urine its yellow color?",
          "Urochrome (urobilin) pigment\nDark amber = concentrated/dehydrated · Colorless = dilute/diabetes insipidus · Dark brown = bile-stained"),

    basic("What is the normal protein excretion in urine?",
          "< 150 mg/24h total protein; < 30 mg/24h albumin\nBelow limit of detection by routine tests (Heat coagulation / SSA)"),

    basic("What are the organic constituents of urine?",
          "Urea (25–30 g/day – largest organic)\nCreatinine (1–2 g/day) · Uric acid (0.5–1 g/day)\nAmmonia (0.3–1 g/day) · Hippuric acid"),

    basic("What is the largest inorganic constituent of urine?",
          "NaCl (sodium chloride) = 10–15 g/day\nOthers: Phosphates (1–1.5 g), Sulphates (1.5–3 g), Potassium (2–4 g), Calcium (0.1–0.3 g)"),

    basic("What is the renal threshold for glucose?",
          "180 mg/dL\nGlycosuria occurs when blood glucose exceeds this value, overwhelming tubular reabsorption capacity"),

    # ── Abnormal constituents ────────────────────────────────────────
    abnorm("What is microalbuminuria and why is it important?",
           "30–300 mg albumin/24 hours\nIt is the EARLIEST detectable marker of diabetic nephropathy.\nIndicates early glomerular damage before overt proteinuria. — Harper's 32nd Ed."),

    abnorm("What are the three ketone bodies? Which is most abundant in DKA?",
           "1. β-Hydroxybutyrate (~78%) – MOST ABUNDANT\n2. Acetoacetate (~20%)\n3. Acetone (~2%)\nRothera's test detects only #2 and #3 – NOT β-hydroxybutyrate"),

    abnorm("What type of bilirubin appears in urine and why?",
           "ONLY conjugated (direct) bilirubin appears in urine.\nIt is water-soluble and can be filtered at the glomerulus.\nUnconjugated bilirubin is albumin-bound (water-insoluble) → cannot cross glomerulus"),

    abnorm("Name four causes of glycosuria without diabetes mellitus.",
           "1. Renal glycosuria (low renal threshold – Fanconi syndrome)\n2. Pregnancy (reduced renal threshold)\n3. Intravenous glucose infusion\n4. After a very heavy carbohydrate meal"),

    abnorm("What are urinary casts? Name types in order of severity.",
           "Protein cylinders formed in renal tubules:\n1. Hyaline – mild proteinuria\n2. Granular – tubular damage\n3. Waxy – advanced chronic disease\n4. RBC casts – glomerulonephritis (nephritic syndrome)"),

    # ── Test 1: Heat Coagulation ──────────────────────────────────────
    test("What is the principle of the Heat Coagulation Test?",
         "Protein denatures and precipitates on heating at acidic pH.\nAcetic acid added to distinguish protein precipitate (PERSISTS in acid) from phosphate precipitate (DISSOLVES in acid)"),

    test("Step-by-step procedure for Heat Coagulation Test?",
         "1. Fill test tube 2/3 with urine\n2. Tilt 45°, heat UPPER portion until it boils\n3. Compare with lower (unheated) portion\n4. If turbid: add 2–3 drops 1% acetic acid\nPositive: white turbidity persists after acetic acid"),

    test("Why is acetic acid added in the Heat Coagulation Test?",
         "To eliminate false positives from phosphate precipitation.\nPhosphates dissolve in acid → turbidity disappears.\nAlbumin precipitates in acid → turbidity PERSISTS.\nConclusion: persistent turbidity = true proteinuria"),

    # ── Test 2: Benedict's ────────────────────────────────────────────
    test("What is the principle of Benedict's Test?",
         "Glucose (a reducing sugar) reduces Cu²⁺ (cupric) to Cu⁺ (cuprous) in alkaline medium on heating.\nForms insoluble brick-red cuprous oxide (Cu₂O) precipitate.\nCu²⁺ (blue) → Cu₂O (brick-red)"),

    test("What are the ingredients of Benedict's reagent?",
         "1. Copper sulphate (CuSO₄) – provides Cu²⁺ ions\n2. Sodium citrate – chelates Cu²⁺ to prevent premature precipitation in alkaline medium\n3. Sodium carbonate (Na₂CO₃) – provides alkaline medium"),

    test("What colors indicate in Benedict's test? (Negative to 4+)",
         "Blue (no change) = Negative (<0.5%)\nGreen precipitate = Trace (+) (0.1–0.5%)\nYellow precipitate = ++ (0.5–1%)\nOrange precipitate = +++ (1–2%)\nBrick-red precipitate = ++++ (>2%)"),

    test("Does Benedict's test specifically detect glucose?",
         "NO – Benedict's detects ALL reducing sugars:\nGlucose, Galactose, Fructose, Lactose, Maltose, Pentoses.\nAlso false +ve: uric acid, creatinine, glucuronides.\nFor glucose specifically → use Glucose Oxidase (GOD-POD) method"),

    # ── Test 3: Rothera's ─────────────────────────────────────────────
    test("What is the principle of Rothera's Test?",
         "Acetone and acetoacetate react with sodium nitroprusside [Na₂Fe(CN)₅NO] in strongly alkaline medium (ammonia) to form a purple/violet ring at the junction of the two layers"),

    test("Step-by-step procedure for Rothera's Test?",
         "1. Fill test tube half-full with urine\n2. Add excess Rothera's reagent (solid) – shake to dissolve\n3. Carefully LAYER concentrated ammonia along the side\n4. Do NOT mix – stand 2–3 minutes\nPositive: Purple/violet ring at the junction"),

    test("Why does Rothera's test NOT detect β-hydroxybutyrate?",
         "β-Hydroxybutyrate (β-OH butyrate) lacks a keto (C=O) group adjacent to the -OH group.\nSodium nitroprusside only reacts with compounds containing a keto group.\nβ-OH butyrate is the MOST ABUNDANT ketone body in DKA (~78%) but is missed!"),

    # ── Test 4: Hay's ─────────────────────────────────────────────────
    test("What is the principle of Hay's Sulphur Test?",
         "Bile salts are detergents (surface-active agents) that markedly reduce the surface tension of urine.\nSulphur powder floats on normal urine (high surface tension).\nWhen bile salts are present, surface tension ↓ → sulphur SINKS",
         cat="Hay's Test – Bile Salts"),

    test("How do you perform Hay's Test?",
         "1. Pour fresh urine into a wide beaker (NOT narrow test tube)\n2. Gently sprinkle powdered sulphur (flowers of sulphur) on the surface\n3. Do NOT shake – observe immediately\nPositive: Sulphur SINKS → Bile salts PRESENT\nNegative: Sulphur FLOATS → Bile salts ABSENT",
         cat="Hay's Test – Bile Salts"),

    # ── Test 5: Fouchet's ─────────────────────────────────────────────
    test("What is the principle of Fouchet's Test?",
         "Ferric chloride (FeCl₃) in acidic medium (trichloroacetic acid) oxidises bilirubin (yellow) to biliverdin (GREEN).\nBaCl₂ first concentrates bilirubin as a precipitate on filter paper, increasing sensitivity.",
         cat="Fouchet's Test – Bile Pigments"),

    test("What is the composition of Fouchet's reagent?",
         "25 g trichloroacetic acid (TCA)\n+ 10 mL of 10% ferric chloride (FeCl₃)\n+ made up to 100 mL with distilled water.\n\nBaCl₂ (barium chloride) is used separately first to precipitate bilirubin.",
         cat="Fouchet's Test – Bile Pigments"),

    test("Step-by-step procedure for Fouchet's Test?",
         "1. Add 5 mL BaCl₂ (10%) to 10 mL urine; mix\n2. Filter – bilirubin collected on filter paper\n3. Lay paper flat; add 1–2 drops Fouchet's reagent to precipitate\nPositive: GREEN colour = bile pigments present",
         cat="Fouchet's Test – Bile Pigments"),

    # ── Jaundice differential ─────────────────────────────────────────
    jaund("In which type of jaundice are bile salts and bile pigments ABSENT in urine?",
          "Haemolytic (pre-hepatic) jaundice.\nReason: In haemolytic jaundice, bilirubin is UNCONJUGATED (indirect) – albumin-bound and water-insoluble → cannot cross the glomerulus → absent in urine"),

    jaund("What are urine findings in OBSTRUCTIVE jaundice?",
          "Bile pigments (bilirubin): PRESENT ++ (Fouchet's positive)\nBile salts: PRESENT ++ (Hay's sulphur sinks)\nUrobilinogen: ABSENT (bile blocked, no enterohepatic circulation)\nUrine color: dark brown, bile-stained"),

    jaund("Compare urobilinogen in all three types of jaundice.",
          "Haemolytic: INCREASED ↑↑ (excess bilirubin → excess urobilinogen)\nHepatocellular: Variable (↑ early when liver damaged; ↓ late if bile ducts also involved)\nObstructive: ABSENT (bile cannot reach intestine → no urobilinogen formed)"),

    # ── Clinical viva ─────────────────────────────────────────────────
    viva("What is the difference between renal glycosuria and diabetic glycosuria?",
         "Renal glycosuria: blood glucose is NORMAL but renal threshold is LOW (Fanconi syndrome, tubular defect). Benedict's positive but fasting glucose normal.\nDiabetic glycosuria: blood glucose is ELEVATED (>180 mg/dL) → exceeds renal threshold"),

    viva("What foam test can be done for bile salts in urine?",
         "Shake the urine sample vigorously in a test tube.\nPresence of bile salts → persistent YELLOW foam that does not disappear.\nNormal urine or albumin → white foam that quickly disappears.\n(Bile salts lower surface tension and stabilize foam)"),
]

story += make_card_row(cards)

# Footer
story.append(Spacer(1, 0.3*cm))
story.append(Table(
    [[Paragraph(
        "Source: Harper's Illustrated Biochemistry 32nd Ed. · Henry's Clinical Diagnosis and Management by Laboratory Methods · Tietz Textbook of Laboratory Medicine 7th Ed.",
        S("ft", fontSize=7.5, fontName="Helvetica-Oblique", textColor=colors.HexColor("#888888"), alignment=TA_CENTER, spaceAfter=0)
    )]],
    colWidths=[W - 2*MARGIN],
    style=TableStyle([("TOPPADDING",(0,0),(-1,-1),4), ("LINEABOVE",(0,0),(-1,-1),0.5, NAVY)])
))

doc.build(story)
print("Flashcards PDF saved: Urine_Analysis_Flashcards.pdf")
Running Command

cd /home/daytona/workspace/urine-analysis && python3 create_flashcards.py 2>&1

Editing File

~/urine-analysis/create_flashcards.py

Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/urine-analysis/create_flashcards.py'
Running Command

cd /home/daytona/workspace/urine-analysis && python3 create_flashcards.py 2>&1

Give the pdf

Running Command

ls -lh /home/daytona/workspace/urine-analysis/ 2>&1

Running Command

cd /home/daytona/workspace/urine-analysis && python3 -c " from reportlab.lib.pagesizes import A4 from reportlab.lib.styles import ParagraphStyle from reportlab.lib.units import cm from reportlab.lib import colors from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Spacer, Paragraph from reportlab.lib.enums import TA_CENTER W, H = A4 MARGIN = 1.2 * cm NAVY = colors.HexColor('#1A2E5C') TEAL = colors.HexColor('#0E8A87') AMBER = colors.HexColor('#F5A623') RED = colors.HexColor('#C0392B') GREEN = colors.HexColor('#1B7A34') WHITE = colors.white DGRAY = colors.HexColor('#333333') AMBERLT = colors.HexColor('#FFF3CC') TEALLT = colors.HexColor('#E0F5F5') REDLT = colors.HexColor('#FDECEA') GREENLT = colors.HexColor('#E8F8EC') NAVYLT = colors.HexColor('#E8EEF8') TW = W - 2*MARGIN CARD_W = (TW - 0.4*cm) / 2 def Sty(name, **kw): d = dict(fontName='Helvetica', fontSize=9, textColor=DGRAY, leading=12, spaceAfter=0) d.update(kw) return ParagraphStyle(name, **d) def make_card(q, a, cat, qbg, abg, qbar, abar): qcell = Table( [[Paragraph(str(cat), Sty('ct', fontSize=7.5, fontName='Helvetica-Bold', textColor=WHITE, spaceAfter=0))], [Paragraph('Q: '+str(q), Sty('q', fontSize=9.5, fontName='Helvetica-Bold', textColor=DGRAY, leading=13))]], colWidths=[CARD_W-0.3*cm], style=TableStyle([ ('BACKGROUND',(0,0),(0,0), qbar), ('BACKGROUND',(0,1),(-1,-1), qbg), ('TOPPADDING',(0,0),(-1,-1),4),('BOTTOMPADDING',(0,0),(-1,-1),4), ('LEFTPADDING',(0,0),(-1,-1),6), ]) ) acell = Table( [[Paragraph('ANSWER', Sty('al', fontSize=7.5, fontName='Helvetica-Bold', textColor=WHITE, spaceAfter=0))], [Paragraph(str(a), Sty('a', fontSize=9, fontName='Helvetica', textColor=DGRAY, leading=13))]], colWidths=[CARD_W-0.3*cm], style=TableStyle([ ('BACKGROUND',(0,0),(0,0), abar), ('BACKGROUND',(0,1),(-1,-1), abg), ('TOPPADDING',(0,0),(-1,-1),4),('BOTTOMPADDING',(0,0),(-1,-1),4), ('LEFTPADDING',(0,0),(-1,-1),6), ]) ) return qcell, acell CARDS = [ # (question, answer, category, qbg, abg, qbar, abar) ('Normal urine volume per 24 hours?','1000-1500 mL/day. Oliguria <400 mL/day. Polyuria >3 L/day. Anuria <100 mL/day.','Physical Parameters',NAVYLT,TEALLT,NAVY,TEAL), ('Normal urine pH?','4.5-8.0 (average 6.0). Acidic in fasted morning state. Alkaline in vegetarian diet, UTI (Proteus).','Physical Parameters',NAVYLT,TEALLT,NAVY,TEAL), ('Normal urine specific gravity?','1.003-1.030 (avg 1.015-1.020). Fixed 1.010 = isosthenuria (severe renal impairment). Low 1.001-1.005 = diabetes insipidus.','Physical Parameters',NAVYLT,TEALLT,NAVY,TEAL), ('What pigment gives urine its yellow colour?','Urochrome (urobilin). Dark amber = concentrated. Colourless = dilute/DI. Dark brown = bile-stained (jaundice).','Physical Parameters',NAVYLT,TEALLT,NAVY,TEAL), ('Normal protein excretion in urine?','<150 mg/24h total. <30 mg/24h albumin. Microalbuminuria = 30-300 mg albumin/24h = earliest sign of diabetic nephropathy.','Physical Parameters',NAVYLT,TEALLT,NAVY,TEAL), ('Largest organic constituent of urine?','Urea: 25-30 g/day (80% of urinary nitrogen). Others: Creatinine 1-2g, Uric acid 0.5-1g, Ammonia 0.3-1g.','Normal Constituents',NAVYLT,TEALLT,NAVY,TEAL), ('Largest inorganic constituent of urine?','NaCl: 10-15 g/day. Others: Sulphates 1.5-3g, Phosphates 1-1.5g, Potassium 2-4g, Calcium 0.1-0.3g.','Normal Constituents',NAVYLT,TEALLT,NAVY,TEAL), ('What is the renal threshold for glucose?','180 mg/dL. Glycosuria occurs when blood glucose exceeds this value, overwhelming tubular reabsorption capacity.','Abnormal Constituents',REDLT,REDLT,RED,RED), ('What is microalbuminuria? Clinical significance?','30-300 mg albumin/24 hours. EARLIEST detectable marker of diabetic nephropathy. Indicates early glomerular damage. (Harper s Biochemistry 32nd Ed.)','Abnormal Constituents',REDLT,REDLT,RED,RED), ('3 ketone bodies - which is most abundant in DKA?','1. b-Hydroxybutyrate (~78%) - MOST ABUNDANT. 2. Acetoacetate (~20%). 3. Acetone (~2%). Rothera s detects only #2 and #3.','Abnormal Constituents',REDLT,REDLT,RED,RED), ('Which bilirubin appears in urine and why?','Only CONJUGATED (direct) bilirubin - water-soluble, filtered at glomerulus. Unconjugated bilirubin is albumin-bound (water-insoluble) so cannot cross the glomerulus.','Abnormal Constituents',REDLT,REDLT,RED,RED), ('Types of urinary casts in order of severity?','1. Hyaline - mild proteinuria. 2. Granular - tubular damage. 3. Waxy - advanced disease. 4. RBC casts - glomerulonephritis (nephritic syndrome).','Abnormal Constituents',REDLT,REDLT,RED,RED), ('Principle of Heat Coagulation Test (Protein)?','Protein denatures and precipitates on heating at acid pH. Acetic acid added: protein turbidity PERSISTS (true positive). Phosphate turbidity DISSOLVES (false positive eliminated).','Test 1 - Protein',TEALLT,TEALLT,TEAL,TEAL), ('Procedure for Heat Coagulation Test?','1. Fill test tube 2/3 with urine. 2. Tilt 45 degrees, heat UPPER portion until boiling. 3. Compare with lower portion. 4. Add 2-3 drops 1% acetic acid. Positive: white turbidity persists.','Test 1 - Protein',TEALLT,TEALLT,TEAL,TEAL), ('Why add acetic acid in Heat Coagulation Test?','To eliminate false positives. Phosphates dissolve in acid (turbidity disappears). Albumin precipitates in acid (turbidity PERSISTS). Only persistent turbidity = true proteinuria.','Test 1 - Protein',TEALLT,TEALLT,TEAL,TEAL), ('Principle of Benedict s Test?','Glucose reduces Cu2+ (cupric) to Cu+ (cuprous) in alkaline medium on heating -> forms brick-red cuprous oxide precipitate (Cu2O). Cu2+ blue -> Cu2O brick-red.','Test 2 - Glucose',TEALLT,TEALLT,TEAL,TEAL), ('Composition of Benedict s reagent?','1. Copper sulphate (CuSO4) - provides Cu2+. 2. Sodium citrate - chelates Cu2+, prevents premature precipitation. 3. Sodium carbonate (Na2CO3) - provides alkaline medium.','Test 2 - Glucose',TEALLT,TEALLT,TEAL,TEAL), ('Benedict s test colour grading (Neg to +4)?','Blue = Negative (<0.5%). Green precipitate = Trace +. Yellow = ++ (0.5-1%). Orange = +++ (1-2%). Brick-red = ++++ (>2%).','Test 2 - Glucose',TEALLT,TEALLT,TEAL,TEAL), ('Is Benedict s test specific for glucose?','NO - detects ALL reducing sugars: glucose, galactose, fructose, lactose, maltose, pentoses. Also false +ve: uric acid, creatinine. For glucose specifically: use GOD-POD (glucose oxidase).','Test 2 - Glucose',TEALLT,TEALLT,TEAL,TEAL), ('Principle of Rothera s Test (Ketones)?','Acetone and acetoacetate react with sodium nitroprusside in strongly alkaline medium (ammonia) to form a purple/violet ring at the junction of the two liquid layers.','Test 3 - Ketones',TEALLT,TEALLT,TEAL,TEAL), ('Procedure for Rothera s Test?','1. Half-fill test tube with urine. 2. Add excess Rothera s reagent (solid), shake to dissolve. 3. Carefully LAYER concentrated ammonia along the side. 4. Do NOT mix. Stand 2-3 min. Positive: purple/violet ring.','Test 3 - Ketones',TEALLT,TEALLT,TEAL,TEAL), ('Why does Rothera s test NOT detect b-hydroxybutyrate?','b-Hydroxybutyrate lacks a keto (C=O) group. Sodium nitroprusside only reacts with compounds containing a keto group. b-OH butyrate is the MOST ABUNDANT ketone body in DKA (~78%) yet is MISSED. (Henry s Clinical Diagnosis)','Test 3 - Ketones',TEALLT,TEALLT,TEAL,TEAL), ('Principle of Hay s Sulphur Test (Bile Salts)?','Bile salts are detergents that markedly lower surface tension of urine. Sulphur powder floats on normal urine (high surface tension). When bile salts present, surface tension falls -> sulphur SINKS.','Test 4 - Bile Salts',NAVYLT,NAVYLT,NAVY,NAVY), ('How to perform Hay s Test?','1. Pour fresh urine into wide beaker. 2. Gently sprinkle sulphur powder on surface. 3. Do NOT shake - observe immediately. Positive: sulphur SINKS = bile salts present. Negative: sulphur FLOATS = bile salts absent.','Test 4 - Bile Salts',NAVYLT,NAVYLT,NAVY,NAVY), ('Principle of Fouchet s Test (Bile Pigments)?','FeCl3 in acidic TCA medium oxidises bilirubin (yellow) to biliverdin (GREEN). BaCl2 is used first to concentrate bilirubin on filter paper, increasing sensitivity.','Test 5 - Bile Pigments',NAVYLT,NAVYLT,NAVY,NAVY), ('Composition of Fouchet s reagent?','25g trichloroacetic acid (TCA) + 10 mL of 10% FeCl3 + made up to 100 mL with distilled water. BaCl2 (10%) is used separately first to precipitate bilirubin onto filter paper.','Test 5 - Bile Pigments',NAVYLT,NAVYLT,NAVY,NAVY), ('Procedure for Fouchet s Test?','1. Add 5 mL BaCl2 (10%) to 10 mL urine; mix well. 2. Filter through filter paper - precipitate on paper. 3. Lay paper flat, add 1-2 drops Fouchet s reagent to precipitate. Positive: GREEN colour.','Test 5 - Bile Pigments',NAVYLT,NAVYLT,NAVY,NAVY), ('In which jaundice are bile tests ABSENT in urine?','Haemolytic (pre-hepatic) jaundice. Bilirubin is UNCONJUGATED - albumin-bound, water-insoluble -> cannot cross glomerulus -> absent in urine. Hay s and Fouchet s both negative.','Jaundice / Clinical',AMBERLT,AMBERLT,colors.HexColor(\"B87A10\"),colors.HexColor(\"B87A10\")), ('Urine findings in Obstructive jaundice?','Bile pigments: PRESENT ++ (Fouchet s positive). Bile salts: PRESENT ++ (Hay s: sulphur sinks). Urobilinogen: ABSENT (bile cannot reach intestine). Colour: dark brown, bile-stained.','Jaundice / Clinical',AMBERLT,AMBERLT,colors.HexColor(\"B87A10\"),colors.HexColor(\"B87A10\")), ('Urobilinogen in all 3 types of jaundice?','Haemolytic: INCREASED ++ (excess bilirubin -> excess urobilinogen). Hepatocellular: Variable. Obstructive: ABSENT (bile blocked, no enterohepatic circulation -> no urobilinogen).','Jaundice / Clinical',AMBERLT,AMBERLT,colors.HexColor(\"B87A10\"),colors.HexColor(\"B87A10\")), ('What is the foam test for bile salts?','Shake urine vigorously. Bile salts -> persistent YELLOW foam. Normal urine or albumin -> white foam that quickly disappears. Bile salts stabilize foam by lowering surface tension.','Viva Key Facts',GREENLT,GREENLT,GREEN,GREEN), ('Renal glycosuria vs diabetic glycosuria?','Renal glycosuria: blood glucose NORMAL but renal threshold LOW (Fanconi syndrome). Benedict s positive but fasting glucose normal. Diabetic glycosuria: blood glucose ELEVATED (>180 mg/dL) -> exceeds renal threshold.','Viva Key Facts',GREENLT,GREENLT,GREEN,GREEN), ] doc = SimpleDocTemplate('/home/daytona/workspace/urine-analysis/Urine_Analysis_Flashcards.pdf', pagesize=A4, leftMargin=MARGIN, rightMargin=MARGIN, topMargin=MARGIN, bottomMargin=MARGIN, title='Urine Analysis Flashcards') story = [] # Cover story.append(Table([ [Paragraph('URINE ANALYSIS - MBBS BIOCHEMISTRY PRACTICAL', Sty('ct', fontSize=13, fontName='Helvetica-Bold', textColor=WHITE, alignment=TA_CENTER, spaceAfter=0))], [Paragraph('Flashcard Q&amp;A - 32 Cards - Print &amp; Cut', Sty('cs', fontSize=9, textColor=AMBERLT, alignment=TA_CENTER, spaceAfter=0))], ], colWidths=[TW], style=TableStyle([ ('BACKGROUND',(0,0),(-1,-1), NAVY), ('TOPPADDING',(0,0),(-1,-1),8),('BOTTOMPADDING',(0,0),(-1,-1),8), ('LEFTPADDING',(0,0),(-1,-1),10), ('LINEBELOW',(0,-1),(-1,-1),2.5,AMBER), ]))) story.append(Spacer(1,0.2*cm)) for i in range(0, len(CARDS), 2): left = CARDS[i] right = CARDS[i+1] if i+1 < len(CARDS) else None ql, al = make_card(*left) if right: qr, ar = make_card(*right) story.append(Table([[ql,qr]], colWidths=[CARD_W,CARD_W], style=TableStyle([('LEFTPADDING',(0,0),(-1,-1),2),('RIGHTPADDING',(0,0),(-1,-1),2),('TOPPADDING',(0,0),(-1,-1),2),('BOTTOMPADDING',(0,0),(-1,-1),2)]))) story.append(Table([[al,ar]], colWidths=[CARD_W,CARD_W], style=TableStyle([('LEFTPADDING',(0,0),(-1,-1),2),('RIGHTPADDING',(0,0),(-1,-1),2),('TOPPADDING',(0,0),(-1,-1),0),('BOTTOMPADDING',(0,0),(-1,-1),3),('LINEBELOW',(0,0),(-1,-1),0.8,colors.HexColor('C0C8D8'))]))) else: story.append(Table([[ql,'']], colWidths=[CARD_W,CARD_W], style=TableStyle([('LEFTPADDING',(0,0),(-1,-1),2),('RIGHTPADDING',(0,0),(-1,-1),2),('TOPPADDING',(0,0),(-1,-1),2),('BOTTOMPADDING',(0,0),(-1,-1),2)]))) story.append(Table([[al,'']], colWidths=[CARD_W,CARD_W], style=TableStyle([('LEFTPADDING',(0,0),(-1,-1),2),('RIGHTPADDING',(0,0),(-1,-1),2),('TOPPADDING',(0,0),(-1,-1),0),('BOTTOMPADDING',(0,0),(-1,-1),3),('LINEBELOW',(0,0),(-1,-1),0.8,colors.HexColor('C0C8D8'))]))) story.append(Spacer(1,0.2*cm)) story.append(Table([[Paragraph('Source: Harper s Illustrated Biochemistry 32nd Ed. Henry s Clinical Diagnosis. Tietz Textbook of Laboratory Medicine 7th Ed.', Sty('f',fontSize=7.5,fontName='Helvetica-Oblique',textColor=colors.HexColor('888888'),alignment=TA_CENTER,spaceAfter=0))]], colWidths=[TW], style=TableStyle([('TOPPADDING',(0,0),(-1,-1),4),('LINEABOVE',(0,0),(-1,-1),0.5,NAVY)]))) doc.build(story) print('Flashcards PDF saved.') " 2>&1

Running Command

cd /home/daytona/workspace/urine-analysis && python3 -c " from reportlab.lib.pagesizes import A4 from reportlab.lib.styles import ParagraphStyle from reportlab.lib.units import cm from reportlab.lib import colors from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Spacer, Paragraph from reportlab.lib.enums import TA_CENTER W, H = A4 MARGIN = 1.2 * cm NAVY = colors.HexColor('#1A2E5C') TEAL = colors.HexColor('#0E8A87') AMBER = colors.HexColor('#F5A623') RED = colors.HexColor('#C0392B') GREEN = colors.HexColor('#1B7A34') BROWN = colors.HexColor('#B87A10') WHITE = colors.white DGRAY = colors.HexColor('#333333') AMBERLT = colors.HexColor('#FFF3CC') TEALLT = colors.HexColor('#E0F5F5') REDLT = colors.HexColor('#FDECEA') GREENLT = colors.HexColor('#E8F8EC') NAVYLT = colors.HexColor('#E8EEF8') TW = W - 2*MARGIN CARD_W = (TW - 0.4*cm) / 2 def Sty(name, **kw): d = dict(fontName='Helvetica', fontSize=9, textColor=DGRAY, leading=12, spaceAfter=0) d.update(kw) return ParagraphStyle(name, **d) def make_card(q, a, cat, qbg, abg, qbar, abar): qcell = Table( [[Paragraph(cat, Sty('ct', fontSize=7.5, fontName='Helvetica-Bold', textColor=WHITE, spaceAfter=0))], [Paragraph('Q: '+q, Sty('q', fontSize=9.5, fontName='Helvetica-Bold', textColor=DGRAY, leading=13))]], colWidths=[CARD_W-0.3*cm], style=TableStyle([('BACKGROUND',(0,0),(0,0),qbar),('BACKGROUND',(0,1),(-1,-1),qbg), ('TOPPADDING',(0,0),(-1,-1),4),('BOTTOMPADDING',(0,0),(-1,-1),4),('LEFTPADDING',(0,0),(-1,-1),6)])) acell = Table( [[Paragraph('ANSWER', Sty('al', fontSize=7.5, fontName='Helvetica-Bold', textColor=WHITE, spaceAfter=0))], [Paragraph(a, Sty('a', fontSize=9, fontName='Helvetica', textColor=DGRAY, leading=13))]], colWidths=[CARD_W-0.3*cm], style=TableStyle([('BACKGROUND',(0,0),(0,0),abar),('BACKGROUND',(0,1),(-1,-1),abg), ('TOPPADDING',(0,0),(-1,-1),4),('BOTTOMPADDING',(0,0),(-1,-1),4),('LEFTPADDING',(0,0),(-1,-1),6)])) return qcell, acell CARDS = [ ('Normal urine volume per 24 hours?','1000-1500 mL/day. Oliguria <400 mL/day. Polyuria >3 L/day. Anuria <100 mL/day.','Physical Parameters',NAVYLT,TEALLT,NAVY,TEAL), ('Normal urine pH?','4.5-8.0 (average 6.0). Acidic in fasted morning state. Alkaline with vegetarian diet or in UTI caused by Proteus.','Physical Parameters',NAVYLT,TEALLT,NAVY,TEAL), ('Normal urine specific gravity?','1.003-1.030 (average 1.015-1.020). Fixed at 1.010 = isosthenuria (severe renal impairment). Very low 1.001-1.005 = diabetes insipidus.','Physical Parameters',NAVYLT,TEALLT,NAVY,TEAL), ('What pigment gives urine its yellow colour?','Urochrome (urobilin). Dark amber = concentrated/dehydrated. Colourless = dilute or diabetes insipidus. Dark brown = bile-stained in jaundice.','Physical Parameters',NAVYLT,TEALLT,NAVY,TEAL), ('Normal protein excretion in 24-hour urine?','Total protein: <150 mg/24h. Albumin: <30 mg/24h. Both below routine test detection limit. Microalbuminuria = 30-300 mg albumin/24h.','Normal Constituents',NAVYLT,TEALLT,NAVY,TEAL), ('Largest organic and inorganic constituents of urine?','Organic: Urea (25-30 g/day, 80% of urinary nitrogen). Inorganic: NaCl (10-15 g/day). Others: Creatinine, Uric acid, Phosphates, Sulphates.','Normal Constituents',NAVYLT,TEALLT,NAVY,TEAL), ('What is the renal threshold for glucose?','180 mg/dL. When blood glucose exceeds 180 mg/dL, tubular reabsorption capacity is overwhelmed and glucose appears in urine (glycosuria).','Abnormal Constituents',REDLT,REDLT,RED,RED), ('What is microalbuminuria and why is it important?','30-300 mg albumin per 24 hours. EARLIEST detectable marker of diabetic nephropathy. Indicates early glomerular basement membrane damage. Harper\'s Biochemistry 32nd Ed.','Abnormal Constituents',REDLT,REDLT,RED,RED), ('Three ketone bodies - which is most abundant in DKA?','1. Beta-Hydroxybutyrate (~78%) - MOST ABUNDANT. 2. Acetoacetate (~20%). 3. Acetone (~2%). Rothera\'s test detects ONLY #2 and #3. Beta-OH butyrate is MISSED.','Abnormal Constituents',REDLT,REDLT,RED,RED), ('Which form of bilirubin appears in urine and why?','ONLY conjugated (direct) bilirubin - water-soluble, can be filtered at glomerulus. Unconjugated bilirubin is albumin-bound (water-insoluble) - CANNOT cross the glomerular filter.','Abnormal Constituents',REDLT,REDLT,RED,RED), ('Types of urinary casts in order of severity?','1. Hyaline - mild proteinuria. 2. Granular - tubular damage. 3. Waxy - advanced chronic disease. 4. RBC casts - glomerulonephritis (nephritic syndrome).','Abnormal Constituents',REDLT,REDLT,RED,RED), ('Causes of proteinuria (at least 4)?','Nephrotic syndrome (>3.5 g/day). Glomerulonephritis. Diabetic nephropathy. UTI. Pre-eclampsia. Fever. Vigorous exercise (transient). Multiple myeloma (Bence Jones protein).','Abnormal Constituents',REDLT,REDLT,RED,RED), ('Principle of Heat Coagulation Test for protein?','Protein denatures and precipitates on heating at acid pH. Acetic acid differentiates: protein turbidity PERSISTS in acid (true +ve) vs phosphate turbidity DISSOLVES in acid (false +ve).','Test 1 - Protein',TEALLT,TEALLT,TEAL,TEAL), ('Procedure of Heat Coagulation Test?','1. Fill 2/3 of test tube with urine. 2. Tilt 45 degrees, heat UPPER portion until boiling. 3. Compare with unheated lower portion. 4. Add 2-3 drops 1% acetic acid. Positive: white turbidity persists.','Test 1 - Protein',TEALLT,TEALLT,TEAL,TEAL), ('Why is acetic acid added in the Heat Coagulation Test?','To eliminate false positives from phosphate precipitation. Phosphate turbidity DISSOLVES in acid. Albumin turbidity PERSISTS in acid. Only persistent turbidity after acetic acid = true proteinuria.','Test 1 - Protein',TEALLT,TEALLT,TEAL,TEAL), ('Principle of Benedict\'s Test for glucose?','Glucose reduces Cu2+ (cupric) to Cu+ (cuprous) in alkaline medium on heating. Forms brick-red insoluble cuprous oxide (Cu2O) precipitate. Blue Cu2+ solution turns red with increasing glucose.','Test 2 - Glucose',TEALLT,TEALLT,TEAL,TEAL), ('Composition of Benedict\'s reagent?','1. Copper sulphate (CuSO4) - provides Cu2+ ions. 2. Sodium citrate - chelates Cu2+ to prevent premature precipitation in alkaline medium. 3. Sodium carbonate (Na2CO3) - provides alkaline medium.','Test 2 - Glucose',TEALLT,TEALLT,TEAL,TEAL), ('Colour grading in Benedict\'s test (Negative to 4+)?','Blue = Negative (<0.5%). Green precipitate = Trace (+) 0.1-0.5%. Yellow = ++ (0.5-1%). Orange = +++ (1-2%). Brick-red = ++++ (>2%).','Test 2 - Glucose',TEALLT,TEALLT,TEAL,TEAL), ('Is Benedict\'s test specific for glucose?','NO - detects ALL reducing sugars: glucose, galactose, fructose, lactose, maltose, pentoses. Also false +ve: uric acid, creatinine, glucuronides. For glucose specifically - use GOD-POD method.','Test 2 - Glucose',TEALLT,TEALLT,TEAL,TEAL), ('Principle of Rothera\'s Test for ketone bodies?','Acetone and acetoacetate react with sodium nitroprusside (Na2Fe(CN)5NO) in strongly alkaline medium (ammonia) forming a purple/violet ring at the junction of the two liquid layers.','Test 3 - Ketones',TEALLT,TEALLT,TEAL,TEAL), ('Step-by-step procedure for Rothera\'s Test?','1. Half-fill test tube with urine. 2. Add excess Rothera\'s reagent (solid), shake to dissolve. 3. Carefully LAYER concentrated ammonia along the side. 4. Do NOT mix. Stand 2-3 min. Positive: purple/violet ring at junction.','Test 3 - Ketones',TEALLT,TEALLT,TEAL,TEAL), ('Why does Rothera\'s test NOT detect beta-hydroxybutyrate?','Beta-hydroxybutyrate lacks a keto (C=O) group. Nitroprusside only reacts with keto-containing compounds. Beta-OH butyrate is the MOST ABUNDANT ketone body in DKA (~78%) yet is completely MISSED by this test. Henry\'s Clinical Diagnosis.','Test 3 - Ketones',TEALLT,TEALLT,TEAL,TEAL), ('Principle of Hay\'s Sulphur Test for bile salts?','Bile salts are detergents that markedly reduce surface tension of urine. Sulphur floats on normal urine (high surface tension). When bile salts present, surface tension falls and sulphur SINKS to the bottom.','Test 4 - Bile Salts',NAVYLT,NAVYLT,NAVY,NAVY), ('Procedure of Hay\'s Test?','1. Pour fresh urine into wide beaker (not a narrow tube). 2. Gently sprinkle sulphur powder on surface. 3. Do NOT shake - observe immediately. Positive: sulphur SINKS = bile salts present. Negative: sulphur FLOATS = absent.','Test 4 - Bile Salts',NAVYLT,NAVYLT,NAVY,NAVY), ('Principle of Fouchet\'s Test for bile pigments?','FeCl3 in acidic trichloroacetic acid (TCA) medium oxidises bilirubin (yellow) to biliverdin (GREEN). BaCl2 is used first to precipitate and concentrate bilirubin on filter paper, increasing sensitivity.','Test 5 - Bile Pigments',NAVYLT,NAVYLT,NAVY,NAVY), ('Composition of Fouchet\'s reagent?','25g trichloroacetic acid (TCA) + 10 mL of 10% ferric chloride (FeCl3) + made up to 100 mL distilled water. BaCl2 solution (10%) is used separately FIRST to precipitate bilirubin.','Test 5 - Bile Pigments',NAVYLT,NAVYLT,NAVY,NAVY), ('Procedure of Fouchet\'s Test?','1. Add 5 mL of 10% BaCl2 to 10 mL urine; mix well. 2. Filter - yellowish precipitate on paper. 3. Lay paper flat; add 1-2 drops Fouchet\'s reagent to precipitate. Positive: GREEN colour on filter paper.','Test 5 - Bile Pigments',NAVYLT,NAVYLT,NAVY,NAVY), ('In which jaundice are BOTH bile tests negative in urine?','Haemolytic (pre-hepatic) jaundice. Bilirubin is unconjugated - albumin-bound, water-insoluble, cannot cross glomerulus. Therefore: Fouchet\'s negative (no bilirubin) AND Hay\'s negative (no bile salts).','Jaundice - Clinical',AMBERLT,AMBERLT,BROWN,BROWN), ('Urine test findings in Obstructive jaundice?','Fouchet\'s: POSITIVE (bile pigments ++) . Hay\'s: POSITIVE (sulphur sinks, bile salts ++). Urobilinogen: ABSENT (bile cannot reach intestine - no enterohepatic circulation). Colour: dark brown, bile-stained.','Jaundice - Clinical',AMBERLT,AMBERLT,BROWN,BROWN), ('Compare urobilinogen in all 3 types of jaundice?','Haemolytic: INCREASED ++ (excess bilirubin produced). Hepatocellular: Variable (up early, down late). Obstructive: ABSENT (bile blocked, no urobilinogen formed in intestine).','Jaundice - Clinical',AMBERLT,AMBERLT,BROWN,BROWN), ('What is the foam test for bile salts?','Shake urine sample vigorously in a test tube. Bile salts produce persistent YELLOW foam. Normal urine or albumin produce only white foam that quickly disappears. Bile salts lower surface tension and stabilize foam.','Viva Key Facts',GREENLT,GREENLT,GREEN,GREEN), ('Renal glycosuria vs diabetic glycosuria - difference?','Renal glycosuria: blood glucose NORMAL but renal threshold is LOW (Fanconi syndrome, tubular defect). Benedict\'s positive but fasting glucose is normal. Diabetic glycosuria: blood glucose ELEVATED >180 mg/dL.','Viva Key Facts',GREENLT,GREENLT,GREEN,GREEN), ] doc = SimpleDocTemplate('/home/daytona/workspace/urine-analysis/Urine_Analysis_Flashcards.pdf', pagesize=A4, leftMargin=MARGIN, rightMargin=MARGIN, topMargin=MARGIN, bottomMargin=MARGIN, title='Urine Analysis Flashcards') story = [] story.append(Table([ [Paragraph('URINE ANALYSIS - MBBS BIOCHEMISTRY PRACTICAL', Sty('ct', fontSize=13, fontName='Helvetica-Bold', textColor=WHITE, alignment=TA_CENTER))], [Paragraph('Flashcard Q&amp;A - 32 Cards - Print &amp; Cut', Sty('cs', fontSize=9, textColor=AMBERLT, alignment=TA_CENTER))], ], colWidths=[TW], style=TableStyle([ ('BACKGROUND',(0,0),(-1,-1),NAVY), ('TOPPADDING',(0,0),(-1,-1),8),('BOTTOMPADDING',(0,0),(-1,-1),8), ('LEFTPADDING',(0,0),(-1,-1),10), ('LINEBELOW',(0,-1),(-1,-1),2.5,AMBER), ]))) story.append(Spacer(1,0.2*cm)) for i in range(0, len(CARDS), 2): left = CARDS[i] right = CARDS[i+1] if i+1 < len(CARDS) else None ql,al = make_card(*left) sep = TableStyle([('LEFTPADDING',(0,0),(-1,-1),2),('RIGHTPADDING',(0,0),(-1,-1),2),('TOPPADDING',(0,0),(-1,-1),2),('BOTTOMPADDING',(0,0),(-1,-1),2)]) sep2 = TableStyle([('LEFTPADDING',(0,0),(-1,-1),2),('RIGHTPADDING',(0,0),(-1,-1),2),('TOPPADDING',(0,0),(-1,-1),0),('BOTTOMPADDING',(0,0),(-1,-1),3),('LINEBELOW',(0,0),(-1,-1),0.8,colors.HexColor('#C0C8D8'))]) if right: qr,ar = make_card(*right) story.append(Table([[ql,qr]],colWidths=[CARD_W,CARD_W],style=sep)) story.append(Table([[al,ar]],colWidths=[CARD_W,CARD_W],style=sep2)) else: story.append(Table([[ql,'']],colWidths=[CARD_W,CARD_W],style=sep)) story.append(Table([[al,'']],colWidths=[CARD_W,CARD_W],style=sep2)) story.append(Spacer(1,0.2*cm)) story.append(Table([[Paragraph('Sources: Harper\'s Illustrated Biochemistry 32nd Ed. Henry\'s Clinical Diagnosis and Management by Laboratory Methods. Tietz Textbook of Laboratory Medicine 7th Ed.', Sty('f',fontSize=7.5,fontName='Helvetica-Oblique',textColor=colors.HexColor('#888888'),alignment=TA_CENTER))]], colWidths=[TW],style=TableStyle([('TOPPADDING',(0,0),(-1,-1),4),('LINEABOVE',(0,0),(-1,-1),0.5,NAVY)]))) doc.build(story) print('Flashcards PDF saved.') " 2>&1

All three files are ready. Here are your downloads:

Your Urine Analysis Files are Ready

1. PDF – Complete Study Notes

Urine Analysis Notes

PDF Document · PDF

6 Sections — Physical parameters, Normal constituents, Abnormal constituents, All 5 test procedures with step-by-step tables, Jaundice differential diagnosis, and 15 rapid-fire Viva Q&A pairs. Sourced directly from Harper's Biochemistry 32nd Ed. and Henry's Clinical Diagnosis.

2. PowerPoint Presentation

Urine Analysis Presentation

Presentation · PPTX

13 slides with dark navy + teal design — Title, Normal parameters, Constituents, Abnormal findings, one dedicated slide per test (Heat Coagulation, Benedict's, Rothera's, Hay's, Fouchet's), a colour-coded Benedict's chart, Summary table, Jaundice differential, Viva Q&A, and Exam Day Checklist.

3. Flashcard Q&A Sheet (Print & Cut)

Urine Analysis Flashcards

PDF Document · PDF

32 colour-coded flashcards in a 2-column print-and-cut format. Cards are grouped by category (Physical Parameters, Abnormal Constituents, each of the 5 tests, Jaundice/Clinical, Viva Key Facts) with Question on top and Answer below each pair.

Quick Revision Reminders

Key FactRemember
Rothera's misses what?β-Hydroxybutyrate (most abundant in DKA at ~78%) - no keto group
Hay's positive = sulphur?Sinks (bile salts lower surface tension)
Fouchet's positive colour?Green (bilirubin → biliverdin)
Bile tests absent in which jaundice?Haemolytic (unconjugated bilirubin is albumin-bound)
Microalbuminuria clinical significance?Earliest sign of diabetic nephropathy (Harper's 32nd Ed.)
Benedict's specificity?NOT specific - detects all reducing sugars
This is a shared conversation. Sign in to Orris to start your own chat.