Clinical cases for jaundice diabetes biochemistry MBBS

Reading File
Asking for Preferences
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
I now have excellent source material from Goldman-Cecil Medicine, Schwartz's Surgery, Tietz Lab Medicine, and Harper's Biochemistry. Let me compile the full clinical cases.

Clinical Cases for MBBS - Biochemistry: Jaundice & Diabetes


SECTION 1: JAUNDICE CASES


Case 1 - Prehepatic (Hemolytic) Jaundice

Presenting Complaint
A 22-year-old male college student presents with yellowish discoloration of eyes and skin for 3 days. He reports passing dark urine. No abdominal pain, fever, or history of alcohol use. He has a cousin with a similar episode.
Physical Examination
  • Icteric sclerae, mild pallor
  • Splenomegaly (2 cm below costal margin)
  • No hepatomegaly, no ascites, no spider naevi
Investigations
TestResultInterpretation
Total bilirubin5.8 mg/dLElevated
Direct (conjugated) bilirubin0.6 mg/dLNormal
Indirect (unconjugated) bilirubin5.2 mg/dLMarkedly elevated
Urine bilirubinAbsentKey finding
Urine urobilinogenMarkedly elevated-
Hb7.8 g/dLAnaemia
Reticulocyte count8%Elevated (hemolysis)
Peripheral smearSpherocytes, polychromasia-
Direct Coombs testPositiveImmune-mediated
LFTs (AST, ALT, ALP)Near normalLiver intact
Diagnosis: Autoimmune hemolytic anemia causing prehepatic jaundice
Biochemical Explanation
Excess red cell breakdown produces large amounts of unconjugated (indirect) bilirubin. This overwhelms the hepatocyte's conjugation system. Key points:
  • Unconjugated bilirubin is water-insoluble - bound to albumin in plasma - so it cannot be filtered by kidneys. Hence, no bilirubin in urine (acholuric jaundice).
  • Liver receives excess bilirubin, conjugates and excretes it as bile. This produces excess urobilinogen in the gut, absorbed back, and excreted in urine - hence urine urobilinogen is high.
  • Stools are dark (excess stercobilin).
"Dysfunction in any of the prehepatic, intrahepatic, or posthepatic phases can lead to jaundice." - Schwartz's Principles of Surgery, 11th Ed.

Case 2 - Hepatocellular Jaundice (Viral Hepatitis)

Presenting Complaint
A 19-year-old male presents with jaundice for 5 days. He had prodromal fatigue, nausea, anorexia, and low-grade fever for 2 weeks before jaundice appeared. He returned recently from a rural camp. He reports clay-colored stools and dark urine.
Physical Examination
  • Icterus ++, mild hepatomegaly (tender)
  • No splenomegaly, no ascites
  • Low-grade fever (38.1°C)
Investigations
TestResultInterpretation
Total bilirubin9.2 mg/dLElevated
Direct bilirubin6.4 mg/dLPredominantly conjugated
Indirect bilirubin2.8 mg/dLAlso elevated
Urine bilirubinPositive (3+)Conjugated leaks into urine
ALT1840 U/LMarkedly elevated (hepatocellular damage)
AST1240 U/LElevated, but ALT > AST
ALP180 U/LMildly elevated
Prothrombin time16 seconds (INR 1.4)Mildly prolonged
Anti-HAV IgMPositive
Urine urobilinogenInitially absent, then present
Diagnosis: Acute Hepatitis A (hepatocellular jaundice)
Biochemical Explanation
Viral injury damages hepatocytes. The impaired liver cannot:
  1. Take up bilirubin from blood
  2. Conjugate it efficiently
  3. Excrete conjugated bilirubin into bile
So both conjugated and unconjugated bilirubin rise. However, since conjugated bilirubin is water-soluble, it spills into urine - giving bilirubinuria (dark urine).
Why ALT > AST in viral hepatitis? ALT is cytoplasmic and highly specific for hepatocytes. It leaks early and selectively. AST is mitochondrial and elevates later. ALT:AST ratio >2 favors viral hepatitis; AST:ALT >2 suggests alcoholic hepatitis.
"In hepatocellular dysfunction caused by viral hepatitis, aminotransferase levels are elevated, with serum ALT higher than AST." - Goldman-Cecil Medicine
"ALT is considered more specific for liver disease than AST, because AST is elevated in cases of cardiac or skeletal muscle injury while ALT is not." - Harper's Illustrated Biochemistry, 32nd Ed.

Case 3 - Obstructive (Posthepatic) Jaundice

Presenting Complaint
A 55-year-old man presents with progressive yellowish discoloration of eyes for 3 weeks. He reports clay-colored (pale) stools, dark urine, and intense pruritus. He has lost 6 kg over 2 months. He is a smoker and has no prior liver disease. No fever, no abdominal pain.
Physical Examination
  • Deep jaundice (bilirubin clinically appears yellow-green)
  • Palpable, non-tender gallbladder (Courvoisier's sign)
  • Scratch marks over skin (pruritus)
  • No splenomegaly
Investigations
TestResultInterpretation
Total bilirubin18 mg/dLMarkedly elevated
Direct bilirubin15.8 mg/dLPredominantly conjugated
ALP680 U/LMarkedly elevated
GGT420 U/LMarkedly elevated
ALT/ASTMildly elevated (120/90 U/L)Secondary hepatocellular damage
Urine bilirubin4+Bilirubinuria
Urine urobilinogenAbsentBile not reaching gut
Stool colorPale/clayAbsent stercobilin
CA 19-9Markedly elevatedTumor marker
USG abdomenDilated CBD, dilated intrahepatic ducts, pancreatic head mass
CECT abdomenCarcinoma head of pancreas
Diagnosis: Carcinoma head of pancreas causing obstructive (posthepatic) jaundice
Biochemical Explanation
Obstruction prevents bile (containing conjugated bilirubin) from reaching the duodenum:
  • Conjugated bilirubin backs up into blood - high direct bilirubin
  • It is water-soluble - appears in urine (bilirubinuria)
  • No bile in gut - no urobilinogen - pale stools, absent urine urobilinogen
  • ALP and GGT elevated (cholestatic pattern) due to bile duct pressure inducing enzyme synthesis in bile duct epithelial cells
  • Pruritus from bile salt deposition in skin
"In patients with biliary obstruction or cholestatic liver diseases, bilirubin and alkaline phosphatase levels are elevated." - Goldman-Cecil Medicine
Courvoisier's sign (palpable non-tender gallbladder + jaundice) = obstructive jaundice due to malignancy until proven otherwise.

Case 4 - Hereditary Unconjugated Hyperbilirubinemia

Presenting Complaint
A 24-year-old medical student is incidentally found to have yellow eyes during a medical college physical examination. He had similar episodes during exams and after prolonged fasting. He denies any abdominal symptoms, fever, or dark urine. His father also has "yellow eyes."
Investigations
TestResult
Total bilirubin3.2 mg/dL
Direct bilirubin0.3 mg/dL
Indirect bilirubin2.9 mg/dL
LFTs (AST, ALT, ALP, albumin)All normal
Hb, reticulocyte count, peripheral smearNormal
Urine bilirubinAbsent
Urine urobilinogenNormal
Diagnosis: Gilbert's Syndrome
Discussion
Gilbert's syndrome is a benign genetic condition with reduced UGT1A1 (UDP-glucuronosyltransferase) enzyme activity - reducing conjugation of bilirubin by ~30%. Key features:
  • Autosomal recessive (TA repeat polymorphism in UGT1A1 promoter)
  • Mild unconjugated hyperbilirubinemia triggered by fasting, illness, stress, exercise
  • Completely benign - no treatment required
  • Differentiated from hemolysis by: normal Hb, normal reticulocytes, no splenomegaly
"Gilbert's syndrome is a genetic variant characterized by diminished activity of the enzyme glucuronyltransferase... It is a benign condition that affects approximately 4% to 7% of the population. Typically, the disease results in transient mild increases in unconjugated bilirubin levels and jaundice during episodes of fasting, stress, or illness." - Schwartz's Principles of Surgery, 11th Ed.

Jaundice Biochemistry Summary Table

FeaturePrehepaticHepatocellularPosthepatic
Serum bilirubinUnconjugated (indirect) ↑↑Both ↑Conjugated (direct) ↑↑
Urine bilirubinAbsentPresentPresent (4+)
Urine urobilinogen↑↑↑VariableAbsent
Stool colorDarkNormal/palePale/clay
ALT/ASTNormal↑↑↑ (ALT>AST in viral)Mildly ↑
ALPNormalMild ↑↑↑↑
Prothrombin timeNormalProlongedProlonged (Vit K malabsorption)
CauseHemolysis, Gilbert'sViral hepatitis, drugs, alcoholGallstones, Ca pancreas


SECTION 2: DIABETES MELLITUS CASES


Case 5 - Type 1 Diabetes Mellitus - New Onset

Presenting Complaint
A 14-year-old girl presents with 4 weeks of polyuria, polydipsia, and polyphagia. She has lost 5 kg despite eating well. Her mother noticed she has been unusually tired. Today she is drowsy with rapid deep breathing.
Physical Examination
  • BMI: 17 kg/m² (thin)
  • BP: 90/60 mmHg (postural drop)
  • HR: 122/min (tachycardia)
  • Respiratory rate: 28/min, Kussmaul breathing (deep, rapid, sighing)
  • Fruity/acetone odor on breath
  • Dry mucous membranes, reduced skin turgor
Investigations
TestResult
Random blood glucose520 mg/dL
Serum sodium128 mEq/L (pseudohyponatremia)
Serum potassium5.4 mEq/L (initially high, total body deficit)
Serum bicarbonate10 mEq/L (↓↓)
Arterial pH7.16 (acidosis)
Anion gap22 mEq/L (↑, wide-gap metabolic acidosis)
Serum ketones (beta-hydroxybutyrate)Strongly positive
Urine: glucose 4+, ketones 4+-
HbA1c11.2%
C-peptideVery low
Anti-GAD antibodyPositive
Diagnosis: New-onset Type 1 DM presenting with Diabetic Ketoacidosis (DKA)
Biochemical Pathogenesis of DKA
Absent insulin → 3 key consequences:
  1. Hyperglycemia: No glucose uptake into cells → hyperglycemia → osmotic diuresis → polyuria → dehydration → pseudohyponatremia
  2. Ketogenesis: Glucagon dominates → activates hormone-sensitive lipase → free fatty acids (FFAs) released from adipose → FFAs go to liver → beta-oxidation → excess acetyl-CoA → ketone bodies (acetoacetate, beta-hydroxybutyrate, acetone) → metabolic acidosis
  3. Protein catabolism: Muscle proteolysis → gluconeogenic amino acids → more hyperglycemia
Kussmaul breathing is the body's respiratory compensation for metabolic acidosis - hyperventilation blows off CO₂ to raise pH.
"The clinical history of DKA typically involves deterioration during several hours to days, with progressive polyuria, polydipsia... physical findings... include dry skin and mucous membranes, reduced jugular venous pressure, tachycardia, orthostatic hypotension, depressed mental function sometimes with frank coma, and deep, rapid respirations (Kussmaul breathing)." - Goldman-Cecil Medicine
DKA Diagnostic Criteria:
  • Blood glucose: variable (often >250 mg/dL, can occasionally be near-normal in "euglycemic DKA")
  • Serum bicarbonate: <18 mmol/L
  • Arterial pH: <7.3 (mild: 7.20-7.30; severe: <7.00)
  • Ketonemia/ketonuria: positive
"The diagnosis of diabetic ketoacidosis is based on the presence of hyperglycemia, ketosis, and acidosis." - Goldman-Cecil Medicine

Case 6 - Type 2 Diabetes Mellitus - Incidental Detection

Presenting Complaint
A 52-year-old obese man comes for routine check-up. He has no specific complaints but admits to "feeling tired and urinating frequently at night." He has hypertension on amlodipine. Father had diabetes. No polyuria, no weight loss. BMI: 29 kg/m².
Examination
  • BP 148/92 mmHg
  • BMI 29 kg/m², waist circumference 98 cm (abdominal obesity)
  • Acanthosis nigricans at neck and axillae
  • Fundus: no retinopathy yet
Investigations
TestResultReference
Fasting plasma glucose (×2)148 mg/dLDiagnostic if ≥126 mg/dL
2-hour OGTT (75g)230 mg/dLDiagnostic if ≥200 mg/dL
HbA1c8.1%Diagnostic if ≥6.5%
Fasting insulinHighInsulin resistance
Urinary microalbumin/creatinine38 mg/gEarly nephropathy
Total cholesterol236 mg/dLDyslipidemia
TG290 mg/dL, HDL 32 mg/dLMetabolic syndrome
Diagnosis: Type 2 Diabetes Mellitus with early nephropathy; Metabolic Syndrome
Discussion - Biochemical Basis
Acanthosis nigricans is a skin marker of insulin resistance - excess insulin stimulates keratinocyte and fibroblast growth via IGF-1 receptors.
ADA Diagnostic Criteria for Diabetes:
  • FPG ≥126 mg/dL (7.0 mmol/L) on 2 occasions
  • 2-hr plasma glucose ≥200 mg/dL during 75g OGTT
  • HbA1c ≥6.5%
  • Random plasma glucose ≥200 mg/dL with symptoms
"HbA1c ≥6.5% was selected as the decision point... HbA1c concentrations 5.7 to 6.4% indicate subjects at high risk of developing diabetes." - Tietz Textbook of Laboratory Medicine, 7th Ed.
HbA1c Biochemistry: Glucose attaches non-enzymatically to the N-terminal valine of the beta chain of HbA (glycation). The HbA1c level reflects average blood glucose over the preceding 8-12 weeks (the lifespan of RBCs). Formula: estimated average glucose (eAG) = (28.7 × HbA1c) - 46.7 mg/dL.

Case 7 - Hyperosmolar Hyperglycemic State (HHS)

Presenting Complaint
A 70-year-old man with known Type 2 DM on oral medications is brought in confused and lethargic. His family says he had poor oral intake and vomiting for 5 days due to a gastroenteritis. He has not taken his medications for 3 days.
Examination
  • GCS: 11/15 (E3V3M5)
  • Severe dehydration: sunken eyes, absent skin turgor, dry tongue
  • BP: 85/60 mmHg, HR: 128/min
  • No Kussmaul breathing, no fruity odor
Investigations
TestResult
Blood glucose810 mg/dL
Serum sodium155 mEq/L
Serum osmolality370 mOsm/kg (>320 = hyperosmolar)
Serum bicarbonate20 mEq/L (near normal)
Arterial pH7.36 (normal!)
Serum ketonesTrace/absent
BUN/Creatinine62/3.2 mg/dL (prerenal AKI)
Diagnosis: Hyperosmolar Hyperglycemic State (HHS)
DKA vs HHS Comparison:
FeatureDKAHHS
Type of DMUsually Type 1Usually Type 2
AgeYoungerOlder
Glucose250-600 mg/dL>600 mg/dL (often >800)
KetonesMarkedAbsent/trace
pH<7.3Normal
Serum HCO3<18 mEq/LNormal
Serum osmolality<320 mOsm/kg>320 mOsm/kg
OnsetHours-daysDays-weeks
Mortality~1-5%~10-20%
Why no ketosis in HHS? In Type 2 DM, residual insulin secretion is enough to suppress lipolysis and ketogenesis, but insufficient to prevent hyperglycemia. In DKA (Type 1), no insulin at all - unrestrained lipolysis drives ketone production.
"In the hyperosmolar hyperglycemic state, the clinical severity and levels of consciousness generally correlate with the severity and duration of hyperosmolarity. Up to 10% of patients present with frank coma." - Goldman-Cecil Medicine


SECTION 3: BIOCHEMISTRY INTEGRATION CASES


Case 8 - Diabetes with Jaundice (Integration Case)

Presenting Complaint
A 45-year-old man with Type 2 DM on metformin and a statin presents with jaundice for 10 days. He started a new herbal supplement 3 weeks ago. He has no fever, no abdominal pain, no change in stools.
Investigations
TestResult
Total bilirubin7.2 mg/dL
Direct bilirubin5.8 mg/dL
ALT960 U/L
ALP280 U/L
INR1.9
Viral hepatitis screen (A, B, C, E)Negative
Autoimmune markersNegative
USG abdomenNormal liver, no ductal dilatation
HbA1c9.8% (poorly controlled)
Diagnosis: Drug-induced liver injury (DILI) from herbal supplement causing hepatocellular jaundice
Teaching Points
  1. Diabetics are at higher risk of non-alcoholic fatty liver disease (NAFLD) and drug hepatotoxicity
  2. Always take a thorough drug/supplement history in any patient with jaundice
  3. Herbal supplements are a common but under-reported cause of DILI
  4. Poor glycemic control (HbA1c 9.8%) suggests longstanding hyperglycemia promoting hepatic steatosis as a background factor
  5. Biochemically: Hepatocellular pattern (ALT>>ALP); both conjugated and unconjugated bilirubin elevated; impaired synthetic function (raised INR)

Case 9 - Lactic Acidosis in a Diabetic Patient

Presenting Complaint
A 58-year-old man with Type 2 DM on metformin 2g/day presents with sudden breathlessness, confusion, and abdominal pain. He was recently started on an iodinated contrast agent for a CT scan. He has chronic kidney disease (CKD Stage 3, eGFR 28 mL/min).
Investigations
TestResult
Blood glucose180 mg/dL (mild)
Arterial pH7.08
Serum bicarbonate8 mEq/L
Lactate14 mmol/L (normal <2)
Anion gap28 mEq/L
Serum ketonesAbsent
Creatinine4.8 mg/dL (AKI on CKD)
Diagnosis: Metformin-associated lactic acidosis (MALA)
Biochemical Mechanism: Metformin inhibits mitochondrial complex I (NADH dehydrogenase), reducing oxidative phosphorylation. Pyruvate cannot enter the TCA cycle efficiently → accumulates → converted to lactate (anaerobic glycolysis). In renal failure, metformin accumulates (it is renally excreted), worsening the effect. Contrast-induced nephropathy is a precipitant.
Key rule: Metformin is contraindicated when eGFR <30 mL/min and should be withheld before contrast procedures.

Biochemistry Quick Reference for MBBS Exams

Bilirubin Pathway in Brief

  1. Heme (from Hb breakdown) → biliverdin (via heme oxygenase) → bilirubin (via biliverdin reductase)
  2. Unconjugated bilirubin + albumin → liver
  3. Hepatocyte: UDP-glucuronosyltransferase → bilirubin glucuronide (conjugated, water-soluble)
  4. Secreted into bile → intestine → urobilinogen (by gut bacteria) → stercobilinogen → stercobilin (brown stool)
  5. Some urobilinogen reabsorbed → portal vein → liver (enterohepatic circulation) → small amount excreted by kidney → urine urobilinogen

Insulin and Glucose Homeostasis in Brief

  • Post-meal: Glucose ↑ → insulin ↑ → glycogen synthesis, glucose uptake, protein synthesis, lipogenesis; glucagon ↓
  • Fasting: Glucose ↓ → glucagon ↑, insulin ↓ → glycogenolysis, gluconeogenesis, lipolysis, ketogenesis
  • Type 1 DM: Autoimmune (anti-GAD, anti-IA2 antibodies) destruction of beta cells → absolute insulin deficiency → DKA
  • Type 2 DM: Insulin resistance + progressive beta cell failure → relative deficiency → HHS, no ketosis

Sources:
  • Goldman-Cecil Medicine (International Ed.), Chapters 133 & 210
  • Schwartz's Principles of Surgery, 11th Ed., Chapter on Liver/Biliary
  • Harper's Illustrated Biochemistry, 32nd Ed., Chapter on LFTs
  • Tietz Textbook of Laboratory Medicine, 7th Ed., Chapters 47 & 51

For 1st and 2nd year too

Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Finding Sources
Reading File
Reading File
Reading File
Excellent material from Harrison's (2025), Medical Physiology, and Tietz. Now let me compile the 1st and 2nd year-focused cases.

Clinical Cases for 1st & 2nd Year MBBS

Biochemistry & Physiology Focus - Jaundice and Diabetes


PART A: JAUNDICE - 1ST & 2ND YEAR CASES


CASE J1 - "The Biochemistry Behind Yellow Eyes"

(Focuses on: Bilirubin Formation, Conjugation Pathway - 1st Year Biochemistry)
Vignette
A 20-year-old male presents to the college health center with yellow discoloration of the eyes. He is otherwise healthy, has no abdominal complaints, and the episode appeared after he skipped meals during exam week.
Examination: Mild icteric sclerae only. No pallor, no hepatomegaly, no lymphadenopathy.
Labs:
  • Total bilirubin: 3.1 mg/dL
  • Direct bilirubin: 0.2 mg/dL (indirect = 2.9 mg/dL)
  • LFTs, CBC: all normal
  • Urine bilirubin: absent
The Biochemistry Story
This is Gilbert's syndrome - the perfect case to teach the complete bilirubin pathway:

Step 1 - Where does bilirubin come from?

Old red blood cells (RBC lifespan ~120 days) are broken down in the reticuloendothelial system (spleen, liver, bone marrow):
Hemoglobin
    ↓  (globin released; heme extracted)
Heme (ferroprotoporphyrin IX)
    ↓  heme oxygenase (ER of macrophages)
    ↓  → CO released + Fe²⁺ released (recycled)
Biliverdin (green pigment)
    ↓  biliverdin reductase (cytosol)
Bilirubin (yellow-orange pigment)
"About 80-85% of the 4 mg/kg body weight of bilirubin produced each day is derived from the breakdown of hemoglobin in senescent red blood cells. The remainder comes from prematurely destroyed erythroid cells in bone marrow and from the turnover of hemoproteins such as myoglobin and cytochromes." - Harrison's Principles of Internal Medicine, 22nd Ed (2025)
Key fact for viva: CO released = one molecule per heme molecule. This is clinically measurable in breath CO tests of hemolysis.

Step 2 - Transport in blood

Bilirubin is water-insoluble (lipophilic) due to internal hydrogen bonding between its propionic acid groups and the imino/lactam groups of the opposite dipyrrolic half. It is called unconjugated (indirect) bilirubin.
It binds non-covalently to albumin for transport in blood to the liver.
"To be transported in blood, bilirubin must be solubilized. Solubilization is accomplished by the reversible, noncovalent binding of bilirubin to albumin." - Harrison's, 22nd Ed.
Why can't unconjugated bilirubin appear in urine? It is protein-bound and lipophilic - cannot be filtered by glomeruli. Therefore: no bilirubin in urine in prehepatic/unconjugated jaundice.

Step 3 - Hepatic uptake and conjugation

In hepatocytes:
  • Bilirubin separated from albumin at sinusoidal membrane
  • Taken up by carrier-mediated transport (OATP transporters)
  • Bound intracellularly to ligandin (glutathione-S-transferase family proteins) to prevent back-diffusion
  • In smooth endoplasmic reticulum: conjugated with glucuronic acid
Key enzyme: UDP-glucuronosyltransferase (UGT1A1)
Bilirubin + UDP-glucuronic acid  →  Bilirubin monoglucuronide
                    → further  →  Bilirubin diglucuronide
                                   (water-soluble = CONJUGATED bilirubin)
In Gilbert's syndrome: UGT1A1 activity is reduced ~30% (TA-repeat polymorphism in UGT1A1 promoter gene). During fasting, free fatty acids compete for albumin binding and displace bilirubin - so more unconjugated bilirubin floods the hepatocyte, overwhelming the reduced enzyme.

Step 4 - Excretion and fate in the gut

Conjugated bilirubin → excreted via MRP2 transporter → bile canaliculi → bile ducts → duodenum
In the intestine:
Conjugated bilirubin
    ↓  bacterial β-glucuronidases (distal ileum/colon)
Unconjugated bilirubin
    ↓  gut bacterial reduction
Urobilinogens (colorless)
    ↓  oxidation in stool
Stercobilin (brown color of stool)
Enterohepatic circulation: ~10-20% of urobilinogens reabsorbed → portal blood → liver (mostly re-excreted) → small fraction in urine as urobilinogen (normal ≤1 mg/dL in urine).

The Van den Bergh Reaction (Exam Favorite)

This lab test distinguishes direct vs indirect bilirubin:
  • Direct reaction (no accelerator): Conjugated bilirubin reacts directly with diazo reagent (diazotized sulfanilic acid) → purple color
  • Indirect reaction (add alcohol as accelerator): Unconjugated bilirubin reacts after alcohol disrupts albumin-binding
"The direct fraction provides an approximation of the conjugated bilirubin level in serum." - Harrison's, 22nd Ed.
Normal values: Total bilirubin 0.2-1.0 mg/dL; Direct <0.3 mg/dL; Indirect <0.7 mg/dL. Jaundice clinically visible when >3 mg/dL.

CASE J2 - "The Jaundiced Newborn"

(Focuses on: Neonatal Jaundice, Kernicterus, Physiological vs Pathological - 1st/2nd Year)
Vignette
A 3-day-old full-term male baby develops yellowish discoloration. Born by normal vaginal delivery. Mother is O positive, baby is A positive. Jaundice first noted on day 2, now on day 3, extending to the chest. Baby is breastfeeding well. No lethargy, no refusal to feed.
Examination: Icteric sclerae + face + chest. Kramer's zone II-III. No pallor, no hepatosplenomegaly.
Labs:
  • Total serum bilirubin: 12 mg/dL (Day 3)
  • Direct bilirubin: 0.4 mg/dL
  • Coombs test (DCT): Negative
  • Hb: 16 g/dL (normal for newborn)
Diagnosis: Physiological jaundice of the newborn

Why does physiological jaundice occur? (1st Year Biochemistry)

  1. High rate of RBC breakdown - fetal RBCs have shorter lifespan (70-90 days) and are replaced by adult RBCs postnatally. Massive bilirubin load.
  2. Immature UGT1A1 enzyme - neonatal hepatic UDP-glucuronosyltransferase is only ~1% of adult activity at birth, reaching adult levels by ~4-8 weeks. Cannot conjugate the excess bilirubin.
  3. High enterohepatic circulation - neonatal gut has:
    • High beta-glucuronidase activity (deconjugates bilirubin back)
    • Sterile gut initially (no bacteria to convert to urobilinogen)
    • Slow gut motility → more reabsorption of unconjugated bilirubin
  4. Low albumin - reduced binding capacity, more free bilirubin circulates

Why is unconjugated bilirubin dangerous in neonates? - Kernicterus

Unconjugated bilirubin (lipophilic + not bound to albumin = "free bilirubin") can cross the blood-brain barrier (BBB). In neonates, BBB is immature. It deposits in:
  • Basal ganglia (globus pallidus)
  • Cochlear nuclei
  • Cerebellum
→ Irreversible neurological damage = Kernicterus (kern = nucleus in German, icterus = jaundice)
Clinical features of kernicterus: opisthotonos, high-pitched cry, hearing loss, choreoathetosis, intellectual disability.
Treatment threshold: Phototherapy converts bilirubin to water-soluble photoisomers (lumirubin) that can be excreted in bile/urine without conjugation. Exchange transfusion for very high levels.

Physiological vs Pathological Neonatal Jaundice

FeaturePhysiologicalPathological
OnsetDay 2-3Within 24 hours
DurationResolves by day 7-10Persists >14 days
Rate of rise<5 mg/dL/day>5 mg/dL/day
Bilirubin typeUnconjugatedMay be conjugated (always pathological)
CauseNormal physiologyHemolysis, infection, metabolic

CASE J3 - "Obstructive Jaundice - The Biochemistry of Pale Stools"

(Focuses on: What happens when bile is blocked - 2nd Year)
Vignette
A 40-year-old obese woman presents with sudden onset severe right upper quadrant colicky pain, fever (39°C), and jaundice (Charcot's triad). She had similar but milder episodes before. Urine is cola-colored, stools are pale.
Labs:
  • Total bilirubin: 11 mg/dL; Direct: 9.5 mg/dL
  • ALP: 520 U/L; GGT: 390 U/L
  • ALT/AST: mildly elevated (180/120 U/L)
  • WBC: 16,000 (neutrophilia)
  • Urine bilirubin: 4+; Urine urobilinogen: absent
  • USG: Cholelithiasis, dilated CBD 12 mm, stone at CBD
Diagnosis: Choledocholithiasis with ascending cholangitis (obstructive jaundice)

Biochemistry: Why are the stools pale and urine dark?

Normal bile flow:
Conjugated bilirubin → bile → intestine → urobilinogen → stercobilin → BROWN STOOL
                                             ↓ (enterohepatic)
                                         kidney → urobilinogen in urine (trace)
When CBD is blocked:
Conjugated bilirubin CANNOT reach intestine:
  → Backs up into liver → sinusoids → bloodstream (high direct bilirubin)
  → Spills into urine (water-soluble) → DARK URINE (bilirubinuria)
  → No urobilinogen formed in gut → NO UROBILINOGEN IN URINE
  → No stercobilin → PALE/CLAY-COLORED STOOLS
Why ALP is elevated in obstruction?
Bile acids and bilirubin under back-pressure induce synthesis of alkaline phosphatase (ALP) in the bile duct epithelial cells (cholangiocytes). ALP is also solubilized from hepatocyte canalicular membranes by bile acids. GGT rises for the same reason. ALP elevation >3× normal with raised bilirubin and minimal aminotransferase rise = cholestatic pattern.
Why does pruritus occur? Bile salts deposit in skin, stimulating cutaneous nerve endings.
Why is PT prolonged in obstructive jaundice? Bile is required for absorption of fat-soluble vitamins (A, D, E, K). Vitamin K is essential for activation (gamma-carboxylation) of clotting factors II, VII, IX, X by carboxylase enzyme. Block in bile → Vitamin K deficiency → prolonged PT. (This corrects with parenteral Vit K - distinguishes from hepatocellular cause where PT does not correct.)


PART B: DIABETES - 1ST & 2ND YEAR CASES


CASE D1 - "Insulin: From Gene to Granule"

(Focuses on: Insulin Biosynthesis - 1st Year Biochemistry)
Vignette
A 16-year-old boy with newly diagnosed Type 1 DM is being counseled by his doctor. His mother asks: "How is insulin normally made in the body, and why is my son's body not making it?"

Insulin Biosynthesis - Step by Step

Gene: Insulin gene located on short arm of chromosome 11
Transcription in beta cell nucleus
         ↓
mRNA: encodes PREPROINSULIN (110 amino acids)
         ↓ translation on ribosomes
Preproinsulin enters rough ER
         ↓ signal peptidase cleaves 24-amino-acid leader (signal) sequence in ER lumen
PROINSULIN (86 amino acids) = B chain + C peptide + A chain (linear)
         ↓ transported to Golgi
3 disulfide bonds form (A6-A11, A7-B7, A20-B19)
         ↓ packaged in secretory granules
         ↓ specific proteases (PC1/3 and PC2) cleave at 2 sites
Insulin (51 amino acids) + C-peptide (31 amino acids)
"Insulin is initially synthesized as a single-chain 86-amino-acid precursor polypeptide, preproinsulin. Subsequent proteolytic processing removes the amino-terminal signal peptide, giving rise to proinsulin. Cleavage of an internal 31-residue fragment from proinsulin generates C-peptide with the A (21 amino acids) and B (30 amino acids) chains of insulin connected by disulfide bonds." - Harrison's, 22nd Ed. (2025)
Final insulin: A-chain (21 aa) + B-chain (30 aa) joined by 2 disulfide bonds between chains + 1 intrachain disulfide in A chain. Total: 51 amino acids.
C-peptide clinical use:
  • Secreted in 1:1 molar ratio with insulin
  • Longer half-life than insulin (cleared more slowly)
  • Used to measure endogenous insulin secretion
  • In Type 1 DM: C-peptide is very low/absent (beta cells destroyed)
  • In Type 2 DM: C-peptide initially normal or high (insulin resistance)
  • Helps distinguish: exogenous insulin injection (C-peptide low, insulin high) vs insulinoma (both C-peptide and insulin high)
Why is C-peptide not insulin-like? C-peptide has no confirmed receptor and essentially no metabolic activity.

CASE D2 - "Glucose Knocks on the Door - Insulin Secretion Mechanism"

(Focuses on: Beta Cell Physiology, Ion Channels, Sulfonylurea MOA - 2nd Year)
Vignette
A 58-year-old Type 2 DM patient is started on glibenclamide (a sulfonylurea). Explain to the patient how glucose normally triggers insulin release, and how his tablet helps.

The Glucose-Insulin Secretion Cascade

Glucose rises (post-meal) in blood
         ↓
Enters beta cell via GLUT2 transporter (GLUT1 in humans) - not insulin-dependent
         ↓
Phosphorylated by GLUCOKINASE (the "glucose sensor") → Glucose-6-phosphate
         ↓  glycolysis + oxidative phosphorylation
ATP generated → ATP:ADP ratio rises
         ↓
ATP-sensitive K⁺ channel (K_ATP channel) CLOSES
         ↓
K⁺ cannot leave → membrane depolarizes (from -70mV toward 0)
         ↓
Voltage-gated Ca²⁺ channels OPEN
         ↓
Ca²⁺ influx into beta cell
         ↓
Triggers fusion of secretory granules with plasma membrane
         ↓
INSULIN (+ C-peptide + proinsulin) released by EXOCYTOSIS
"Glucose phosphorylation by glucokinase is the rate-limiting step that controls glucose-regulated insulin secretion. Further metabolism of glucose-6-phosphate via glycolysis generates ATP, which inhibits the activity of an ATP-sensitive K+ channel... Inhibition of this K+ channel induces beta cell membrane depolarization, which opens voltage-dependent calcium channels (leading to an influx of calcium) and stimulates insulin secretion." - Harrison's, 22nd Ed. (2025)
How do sulfonylureas work? Sulfonylureas (glibenclamide, glipizide, gliclazide) directly bind to the SUR1 subunit of the K_ATP channel and keep it closed - mimicking the effect of ATP. This causes depolarization → Ca²⁺ influx → insulin release regardless of blood glucose level. This is why they can cause hypoglycemia even if glucose is normal (unlike metformin).

Two-Phase Insulin Secretion

PhaseTimingSource
First phase0-10 min (rapid spike)Pre-formed granules already docked at membrane
Second phase10-60 min (sustained)Newly synthesized + mobilized granules
In Type 2 DM: First-phase insulin secretion is lost early - one of the earliest detectable abnormalities. This causes the post-meal glucose spike that eventually damages blood vessels.

CASE D3 - "Where Does Glucose Go? - Insulin's Metabolic Actions"

(Focuses on: GLUT4, Glycolysis, Glycogen Synthesis, Lipogenesis - 2nd Year Biochemistry)
Vignette
A 2nd-year MBBS student asks: "After a rice meal, glucose rises. Insulin is released. Then what exactly happens biochemically in each tissue?"

Tissue-by-Tissue Actions of Insulin

Skeletal Muscle and Adipose Tissue:
  • Insulin → activates insulin receptor (tyrosine kinase receptor) → phosphorylates IRS-1/IRS-2
  • PI3K-Akt pathway activated → vesicles containing GLUT4 transporters migrate to cell membrane
  • GLUT4 insertion into membrane → glucose enters cell
  • GLUT4 is insulin-dependent (unlike GLUT1/GLUT2/GLUT3 which are constitutive)
In muscle: Glucose → glycolysis (ATP production) + glycogen synthesis (via glycogen synthase, activated by insulin through Akt phosphorylating and inactivating GSK-3)
In liver: Insulin → inhibits glycogenolysis + gluconeogenesis + promotes glycogen synthesis and glycolysis. Activates glucokinase (enzyme that phosphorylates glucose at high concentrations).
In adipose tissue: Glucose → glycerol-3-phosphate + fatty acids (lipogenesis) → stored as triglycerides. Insulin simultaneously inhibits hormone-sensitive lipase (HSL) - stopping lipolysis.

What happens in insulin deficiency (Type 1 DM or DKA)?

ProcessNormal (Insulin Present)DKA (No Insulin)
Glucose uptake (muscle/fat)Via GLUT4 - activeBLOCKED (no GLUT4 translocation)
Liver glycogenolysisSuppressedActivated by glucagon
GluconeogenesisSuppressedActivated (uses amino acids, glycerol)
Lipolysis (adipose)Inhibited by insulinUnrestrained - FFAs flood liver
Ketogenesis (liver)MinimalMassive (excess acetyl-CoA)

CASE D4 - "The Biochemistry of DKA"

(Focuses on: Ketone Body Formation, Anion Gap, Acid-Base - 2nd Year)
Vignette
A 14-year-old girl is brought in drowsy with fruity breath and deep rapid breathing. Blood glucose 480 mg/dL, pH 7.18, HCO₃ 9 mEq/L, Na 130, Cl 96. She has not taken insulin for 2 days.
Calculate the Anion Gap: AG = Na⁺ - (Cl⁻ + HCO₃⁻) = 130 - (96 + 9) = 25 mEq/L (elevated - normal is 8-12)
This is a high anion gap metabolic acidosis - the "missing" anions are ketoacids (acetoacetate and beta-hydroxybutyrate).

Ketone Body Biochemistry - The Full Pathway

Trigger: No insulin → glucagon dominates → activates hormone-sensitive lipase in adipose
Triglycerides (adipose)
    ↓  Hormone-sensitive lipase (activated by glucagon)
Glycerol + Free Fatty Acids (FFAs)
    ↓  FFAs enter liver
    ↓  Carnitine shuttle (carnitine acyltransferase I) - transfers FFA into mitochondria
Beta-oxidation → Acetyl-CoA generated MASSIVELY
Why can't acetyl-CoA enter TCA cycle normally in DKA?
  • Oxaloacetate (OAA) is depleted because:
    • Pyruvate (the precursor of OAA) is being diverted to gluconeogenesis
    • OAA itself is used in gluconeogenesis via PEPCK
  • Without OAA, acetyl-CoA cannot condense to form citrate → TCA blocked
Acetyl-CoA overflow → Ketogenesis:
2 × Acetyl-CoA → Acetoacetyl-CoA
                ↓  (+Acetyl-CoA via HMG-CoA synthase)
              HMG-CoA (in mitochondria)
                ↓  HMG-CoA lyase
         Acetoacetate + Acetyl-CoA

Acetoacetate  →  β-hydroxybutyrate (via beta-hydroxybutyrate dehydrogenase; NADH-dependent)
Acetoacetate  →  Acetone + CO₂ (spontaneous decarboxylation) ← fruity breath!
"The abundance of acetyl-CoA results from excessive mobilization of fatty acids from adipose tissue and their conversion by β-oxidation in the liver. The resulting excess acetyl-CoA is diverted to an alternative pathway in the mitochondria to form acetoacetic acid, β-hydroxybutyric acid, and acetone - three compounds known collectively as ketone bodies." - Tietz Textbook of Laboratory Medicine, 7th Ed.
Why does the liver produce ketones but cannot use them?
The liver lacks 3-ketoacid CoA transferase (thiophorase) - the enzyme needed to activate acetoacetate back to acetoacetyl-CoA for oxidation. So the liver makes ketones and ships them out for peripheral tissues (muscle, brain in starvation) to use as fuel.
How does insulin reverse DKA?
Insulin given IV
    ↓
Glucose uptake restored → OAA production restored
    ↓
Acetyl-CoA enters TCA cycle normally → ketogenesis stops
    ↓
Lipolysis suppressed → FFA supply to liver decreases
    ↓
Ketone bodies consumed faster than produced → ketoacidosis resolves

CASE D5 - "HbA1c - A Glycated Memory"

(Focuses on: Non-enzymatic Glycosylation, Amadori Product - 1st/2nd Year Biochemistry)
Vignette
A 2nd-year student asks: "How does HbA1c actually form? Why does it reflect 3 months of glucose control and not just today's blood sugar?"

Mechanism of HbA1c Formation

HbA1c forms by non-enzymatic glycosylation (glycation) - glucose attaches to proteins spontaneously without any enzyme.
Step 1 - Schiff base (Aldimine):
Glucose (aldehyde group) + NH₂ terminal valine of Hb beta chain
    → Unstable Schiff base (forms within hours, reversible)

Step 2 - Amadori product:
Schiff base undergoes Amadori rearrangement
    → Stable ketoamine (HbA1c) - this is IRREVERSIBLE once formed
Key facts:
  • Rate of HbA1c formation is directly proportional to blood glucose concentration (mass action)
  • HbA1c persists for the entire lifespan of the RBC (~120 days)
  • It reflects the weighted average of blood glucose over 8-12 weeks (recent weeks contribute more than earlier weeks due to RBC age distribution)
Conditions that falsely lower HbA1c:
  • Hemolytic anemia (RBCs destroyed before glycation accumulates)
  • Blood transfusion (new donor RBCs)
  • Pregnancy (increased RBC turnover)
  • Hemoglobin variants (HbS, HbC interfere with some assays)
Conditions that falsely raise HbA1c:
  • Iron deficiency anemia (older RBCs accumulate = more time for glycation)
  • Asplenia
"An HbA1c value ≥6.5% was selected as the diagnostic decision point, based on the prevalence of retinopathy." - Tietz Textbook of Laboratory Medicine, 7th Ed.

Quick Reference: MBBS Exam Must-Know Points

Bilirubin

FactAnswer
Enzyme making bilirubin from hemeHeme oxygenase (then biliverdin reductase)
% bilirubin from RBC breakdown80-85%
Key conjugating enzyme in liverUGT1A1 (UDP-glucuronosyltransferase)
Normal serum bilirubin0.2-1.0 mg/dL
Jaundice clinically visible at>3 mg/dL
Deficient enzyme in Gilbert'sUGT1A1 (30% reduced)
Deficient enzyme in Crigler-Najjar Type 1UGT1A1 (completely absent)
Why pale stools in obstructionNo bile → no stercobilin
Why dark urine in obstructionWater-soluble conjugated bilirubin in urine
Van den Bergh direct reaction testsConjugated (direct) bilirubin

Insulin & Diabetes

FactAnswer
Insulin gene locationChromosome 11 short arm
Precursor chainPreproinsulin (110 aa) → Proinsulin (86 aa) → Insulin (51 aa)
A chain amino acids21
B chain amino acids30
Glucose sensor enzyme in beta cellGlucokinase
Channel closed by insulin stimulusK_ATP channel (K⁺ channel)
Sulfonylurea binding siteSUR1 subunit of K_ATP channel
GLUT4 is found inMuscle and adipose (insulin-dependent)
Ketone bodies (3 types)Acetoacetate, Beta-hydroxybutyrate, Acetone
Enzyme making HMG-CoAHMG-CoA synthase (mitochondrial)
Why liver can't use ketonesLacks 3-ketoacid CoA transferase
HbA1c diagnostic cut-off≥6.5%
HbA1c reflects glucose over8-12 weeks (RBC lifespan)
C-peptide clinical useMarker of endogenous insulin secretion

Sources:
  • Harrison's Principles of Internal Medicine, 22nd Ed. (2025) - Bilirubin metabolism + Insulin biosynthesis/secretion
  • Medical Physiology (Boron & Boulpaep) - Beta cell physiology, insulin synthesis
  • Tietz Textbook of Laboratory Medicine, 7th Ed. - Ketogenesis, HbA1c, diagnosis
  • Goldman-Cecil Medicine - DKA clinical features and diagnosis

Generate a PDF study guide with all cases for quick revision

Reading File
Running Command

ls /home/daytona/workspace/ 2>/dev/null && echo "exists" || mkdir -p /home/daytona/workspace/mbbs-cases && echo "created"

Writing File

~/mbbs-cases/generate_pdf.py

#!/usr/bin/env python3
"""
MBBS Clinical Cases Study Guide PDF Generator
Topics: Jaundice & Diabetes Biochemistry
"""

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

OUTPUT_PATH = "/home/daytona/workspace/mbbs-cases/MBBS_ClinicalCases_Jaundice_Diabetes.pdf"

# ── Colour palette ──────────────────────────────────────────────────────────
C_DARK_BLUE   = colors.HexColor("#1a3a5c")
C_MED_BLUE    = colors.HexColor("#2e6da4")
C_LIGHT_BLUE  = colors.HexColor("#dbeaf7")
C_TEAL        = colors.HexColor("#1a6b6b")
C_LIGHT_TEAL  = colors.HexColor("#d4f0f0")
C_GOLD        = colors.HexColor("#c8860a")
C_LIGHT_GOLD  = colors.HexColor("#fef6e4")
C_RED         = colors.HexColor("#c0392b")
C_LIGHT_RED   = colors.HexColor("#fdecea")
C_GREEN       = colors.HexColor("#1e7a34")
C_LIGHT_GREEN = colors.HexColor("#e9f7ec")
C_PURPLE      = colors.HexColor("#6c3483")
C_LIGHT_PURPLE= colors.HexColor("#f4ecf7")
C_GREY_LIGHT  = colors.HexColor("#f5f5f5")
C_GREY_MID    = colors.HexColor("#cccccc")
C_BLACK       = colors.HexColor("#1a1a1a")
C_WHITE       = colors.white

# ── Styles ───────────────────────────────────────────────────────────────────
def build_styles():
    base = getSampleStyleSheet()

    styles = {}

    styles["cover_title"] = ParagraphStyle(
        "cover_title", fontName="Helvetica-Bold", fontSize=28,
        textColor=C_WHITE, alignment=TA_CENTER, spaceAfter=8, leading=34
    )
    styles["cover_sub"] = ParagraphStyle(
        "cover_sub", fontName="Helvetica", fontSize=14,
        textColor=colors.HexColor("#cce0f5"), alignment=TA_CENTER, spaceAfter=6
    )
    styles["cover_meta"] = ParagraphStyle(
        "cover_meta", fontName="Helvetica", fontSize=11,
        textColor=colors.HexColor("#a0c4e8"), alignment=TA_CENTER, spaceAfter=4
    )

    styles["h_part"] = ParagraphStyle(
        "h_part", fontName="Helvetica-Bold", fontSize=18,
        textColor=C_WHITE, alignment=TA_CENTER, spaceAfter=4, spaceBefore=6, leading=22
    )
    styles["h_section"] = ParagraphStyle(
        "h_section", fontName="Helvetica-Bold", fontSize=14,
        textColor=C_DARK_BLUE, spaceAfter=4, spaceBefore=14, leading=18
    )
    styles["h_case"] = ParagraphStyle(
        "h_case", fontName="Helvetica-Bold", fontSize=13,
        textColor=C_WHITE, spaceAfter=2, spaceBefore=2, leading=17
    )
    styles["h_sub"] = ParagraphStyle(
        "h_sub", fontName="Helvetica-Bold", fontSize=11,
        textColor=C_MED_BLUE, spaceAfter=3, spaceBefore=8, leading=14
    )
    styles["h_sub2"] = ParagraphStyle(
        "h_sub2", fontName="Helvetica-Bold", fontSize=10,
        textColor=C_TEAL, spaceAfter=2, spaceBefore=6, leading=13
    )
    styles["body"] = ParagraphStyle(
        "body", fontName="Helvetica", fontSize=9.5,
        textColor=C_BLACK, spaceAfter=4, leading=14, alignment=TA_JUSTIFY
    )
    styles["body_bold"] = ParagraphStyle(
        "body_bold", fontName="Helvetica-Bold", fontSize=9.5,
        textColor=C_BLACK, spaceAfter=4, leading=14
    )
    styles["bullet"] = ParagraphStyle(
        "bullet", fontName="Helvetica", fontSize=9.5,
        textColor=C_BLACK, spaceAfter=2, leading=13,
        leftIndent=12, firstLineIndent=-10
    )
    styles["quote"] = ParagraphStyle(
        "quote", fontName="Helvetica-Oblique", fontSize=9,
        textColor=colors.HexColor("#444444"), spaceAfter=4, leading=13,
        leftIndent=14, rightIndent=14, borderPad=4
    )
    styles["code"] = ParagraphStyle(
        "code", fontName="Courier", fontSize=8.5,
        textColor=C_DARK_BLUE, spaceAfter=3, leading=13,
        leftIndent=10, backColor=C_GREY_LIGHT
    )
    styles["table_hdr"] = ParagraphStyle(
        "table_hdr", fontName="Helvetica-Bold", fontSize=8.5,
        textColor=C_WHITE, alignment=TA_CENTER, leading=11
    )
    styles["table_cell"] = ParagraphStyle(
        "table_cell", fontName="Helvetica", fontSize=8.5,
        textColor=C_BLACK, alignment=TA_LEFT, leading=11
    )
    styles["table_cell_c"] = ParagraphStyle(
        "table_cell_c", fontName="Helvetica", fontSize=8.5,
        textColor=C_BLACK, alignment=TA_CENTER, leading=11
    )
    styles["source"] = ParagraphStyle(
        "source", fontName="Helvetica-Oblique", fontSize=8,
        textColor=colors.HexColor("#666666"), spaceAfter=2, leading=11
    )
    styles["footnote"] = ParagraphStyle(
        "footnote", fontName="Helvetica", fontSize=8,
        textColor=colors.HexColor("#777777"), spaceAfter=2, leading=11
    )
    return styles


# ── Helper flowables ─────────────────────────────────────────────────────────
def part_banner(text, color, styles):
    tbl = Table([[Paragraph(text, styles["h_part"])]], colWidths=[17*cm])
    tbl.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), color),
        ("ROUNDEDCORNERS", [6]),
        ("TOPPADDING",    (0,0), (-1,-1), 10),
        ("BOTTOMPADDING", (0,0), (-1,-1), 10),
        ("LEFTPADDING",   (0,0), (-1,-1), 12),
        ("RIGHTPADDING",  (0,0), (-1,-1), 12),
    ]))
    return tbl

def case_banner(text, color, styles):
    tbl = Table([[Paragraph(text, styles["h_case"])]], colWidths=[17*cm])
    tbl.setStyle(TableStyle([
        ("BACKGROUND", (0,0), (-1,-1), color),
        ("ROUNDEDCORNERS", [4]),
        ("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 tbl

def info_box(text, bg_color, border_color, styles, label=None):
    content = []
    if label:
        content.append(Paragraph(f"<b>{label}</b>", styles["body_bold"]))
    content.append(Paragraph(text, styles["body"]))
    tbl = Table([content], colWidths=[17*cm])
    tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), bg_color),
        ("BOX",           (0,0), (-1,-1), 1.5, border_color),
        ("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 tbl

def quote_box(text, source, styles):
    tbl = Table([
        [Paragraph(f'<i>"{text}"</i>', styles["quote"])],
        [Paragraph(f"— {source}", styles["source"])]
    ], colWidths=[17*cm])
    tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), C_GREY_LIGHT),
        ("LINEAFTER",     (0,0), (0,-1), 3, C_MED_BLUE),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 14),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
    ]))
    return tbl

def make_table(headers, rows, styles, col_widths=None, header_color=None):
    if header_color is None:
        header_color = C_DARK_BLUE
    header_row = [Paragraph(h, styles["table_hdr"]) for h in headers]
    data = [header_row]
    for i, row in enumerate(rows):
        data.append([Paragraph(str(cell), styles["table_cell"]) for cell in row])
    if col_widths is None:
        n = len(headers)
        col_widths = [17*cm / n] * n
    tbl = Table(data, colWidths=col_widths, repeatRows=1)
    ts = [
        ("BACKGROUND",    (0,0), (-1,0),  header_color),
        ("TEXTCOLOR",     (0,0), (-1,0),  C_WHITE),
        ("ROWBACKGROUNDS",(0,1), (-1,-1), [C_WHITE, C_GREY_LIGHT]),
        ("BOX",           (0,0), (-1,-1), 0.8, C_GREY_MID),
        ("INNERGRID",     (0,0), (-1,-1), 0.4, C_GREY_MID),
        ("TOPPADDING",    (0,0), (-1,-1), 5),
        ("BOTTOMPADDING", (0,0), (-1,-1), 5),
        ("LEFTPADDING",   (0,0), (-1,-1), 6),
        ("RIGHTPADDING",  (0,0), (-1,-1), 6),
        ("VALIGN",        (0,0), (-1,-1), "MIDDLE"),
    ]
    tbl.setStyle(TableStyle(ts))
    return tbl

def pathway_box(lines, styles):
    """Monospaced pathway/reaction box."""
    content = [Paragraph(line.replace(" ", "&nbsp;"), styles["code"]) for line in lines]
    tbl = Table([[c] for c in content], colWidths=[17*cm])
    tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), C_GREY_LIGHT),
        ("BOX",           (0,0), (-1,-1), 1, C_MED_BLUE),
        ("TOPPADDING",    (0,0), (-1,-1), 2),
        ("BOTTOMPADDING", (0,0), (-1,-1), 2),
        ("LEFTPADDING",   (0,0), (-1,-1), 8),
        ("RIGHTPADDING",  (0,0), (-1,-1), 8),
    ]))
    return tbl

def sp(n=1):
    return Spacer(1, n * 4 * mm)

def hr(color=C_GREY_MID, thickness=0.5):
    return HRFlowable(width="100%", thickness=thickness, color=color, spaceAfter=4, spaceBefore=4)


# ── Cover page ───────────────────────────────────────────────────────────────
def build_cover(styles):
    els = []

    # Full-width cover banner via a large table
    cover_data = [[
        Paragraph("MBBS BIOCHEMISTRY", styles["cover_title"]),
    ]]
    cover = Table(cover_data, colWidths=[17*cm])
    cover.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), C_DARK_BLUE),
        ("TOPPADDING",    (0,0), (-1,-1), 30),
        ("BOTTOMPADDING", (0,0), (-1,-1), 10),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
    ]))
    els.append(cover)

    sub_data = [[Paragraph("Clinical Cases Study Guide", styles["cover_sub"])]]
    sub = Table(sub_data, colWidths=[17*cm])
    sub.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), C_DARK_BLUE),
        ("TOPPADDING",    (0,0), (-1,-1), 2),
        ("BOTTOMPADDING", (0,0), (-1,-1), 20),
        ("LEFTPADDING",   (0,0), (-1,-1), 10),
        ("RIGHTPADDING",  (0,0), (-1,-1), 10),
    ]))
    els.append(sub)

    els.append(sp(3))

    topic_data = [
        [Paragraph("TOPICS COVERED", ParagraphStyle("tc", fontName="Helvetica-Bold",
            fontSize=11, textColor=C_MED_BLUE, alignment=TA_CENTER))],
        [Paragraph("Jaundice &nbsp;|&nbsp; Diabetes Mellitus &nbsp;|&nbsp; Biochemistry Integration",
            ParagraphStyle("tcs", fontName="Helvetica", fontSize=12,
            textColor=C_DARK_BLUE, alignment=TA_CENTER, leading=18))],
    ]
    topic_tbl = Table(topic_data, colWidths=[17*cm])
    topic_tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), C_LIGHT_BLUE),
        ("BOX",           (0,0), (-1,-1), 1.5, C_MED_BLUE),
        ("TOPPADDING",    (0,0), (-1,-1), 10),
        ("BOTTOMPADDING", (0,0), (-1,-1), 10),
    ]))
    els.append(topic_tbl)
    els.append(sp(3))

    # Year labels
    year_rows = [
        ["1st & 2nd Year",  "Biochemistry • Pathway Mechanisms • Physiology of Insulin & Bilirubin"],
        ["3rd Year (MBBS)", "Clinical Cases • Diagnosis • Management • Exam-Ready Discussions"],
    ]
    year_tbl = Table(year_rows, colWidths=[5*cm, 12*cm])
    year_tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (0,-1), C_MED_BLUE),
        ("BACKGROUND",    (1,0), (1,-1), C_LIGHT_BLUE),
        ("TEXTCOLOR",     (0,0), (0,-1), C_WHITE),
        ("FONTNAME",      (0,0), (0,-1), "Helvetica-Bold"),
        ("FONTSIZE",      (0,0), (-1,-1), 10),
        ("TOPPADDING",    (0,0), (-1,-1), 9),
        ("BOTTOMPADDING", (0,0), (-1,-1), 9),
        ("LEFTPADDING",   (0,0), (-1,-1), 12),
        ("INNERGRID",     (0,0), (-1,-1), 0.5, C_WHITE),
        ("BOX",           (0,0), (-1,-1), 1, C_MED_BLUE),
    ]))
    els.append(year_tbl)
    els.append(sp(3))

    # Contents list
    toc_items = [
        "PART 1 — 3rd Year MBBS: Clinical Cases",
        "  J1  Prehepatic Jaundice (Autoimmune Hemolytic Anemia)",
        "  J2  Hepatocellular Jaundice (Viral Hepatitis A)",
        "  J3  Obstructive / Posthepatic Jaundice (Ca Pancreas)",
        "  J4  Gilbert's Syndrome",
        "  D1  Type 1 DM — DKA (New Onset)",
        "  D2  Type 2 DM — Incidental Detection",
        "  D3  Hyperosmolar Hyperglycemic State (HHS)",
        "  D4  Drug-induced Liver Injury in a Diabetic",
        "  D5  Metformin-associated Lactic Acidosis",
        "",
        "PART 2 — 1st & 2nd Year MBBS: Biochemistry Deep Dives",
        "  J1  Bilirubin Pathway — Full Mechanism & Gilbert's Syndrome",
        "  J2  Physiological Neonatal Jaundice & Kernicterus",
        "  J3  Obstructive Jaundice — Why Pale Stools & Dark Urine?",
        "  D1  Insulin Biosynthesis — Gene to Granule",
        "  D2  Beta-cell Secretion — K_ATP Channel & Sulfonylureas",
        "  D3  Insulin's Metabolic Actions — GLUT4, Glycogen, Lipogenesis",
        "  D4  DKA Biochemistry — Ketone Bodies & Anion Gap",
        "  D5  HbA1c — Glycation, Amadori Product, Interpretation",
        "",
        "PART 3 — Quick Reference Tables (Exam Ready)",
    ]
    toc_data = [[Paragraph("CONTENTS", ParagraphStyle("toc_h", fontName="Helvetica-Bold",
        fontSize=11, textColor=C_DARK_BLUE))]]
    for item in toc_items:
        style = ParagraphStyle("toc_i", fontName="Helvetica-Bold" if "PART" in item else "Helvetica",
            fontSize=9, textColor=C_DARK_BLUE if "PART" in item else C_BLACK, leading=14)
        toc_data.append([Paragraph(item, style)])
    toc_tbl = Table(toc_data, colWidths=[17*cm])
    toc_tbl.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (0,0),  C_LIGHT_BLUE),
        ("BACKGROUND",    (0,1), (-1,-1), C_WHITE),
        ("BOX",           (0,0), (-1,-1), 1, C_MED_BLUE),
        ("TOPPADDING",    (0,0), (-1,-1), 4),
        ("BOTTOMPADDING", (0,0), (-1,-1), 4),
        ("LEFTPADDING",   (0,0), (-1,-1), 12),
        ("RIGHTPADDING",  (0,0), (-1,-1), 12),
    ]))
    els.append(toc_tbl)
    els.append(sp(2))

    meta = Table([[
        Paragraph("Based on: Harrison's 22nd Ed • Goldman-Cecil Medicine • Schwartz's Surgery • "
                  "Harper's Biochemistry • Tietz Lab Medicine • Medical Physiology",
                  ParagraphStyle("src", fontName="Helvetica-Oblique", fontSize=8,
                  textColor=colors.HexColor("#555"), alignment=TA_CENTER))
    ]], colWidths=[17*cm])
    meta.setStyle(TableStyle([
        ("BACKGROUND",    (0,0), (-1,-1), C_GREY_LIGHT),
        ("TOPPADDING",    (0,0), (-1,-1), 6),
        ("BOTTOMPADDING", (0,0), (-1,-1), 6),
    ]))
    els.append(meta)
    els.append(PageBreak())
    return els


# ── PAGE HEADER / FOOTER ─────────────────────────────────────────────────────
def on_page(canvas, doc):
    canvas.saveState()
    w, h = A4
    # Header bar
    canvas.setFillColor(C_DARK_BLUE)
    canvas.rect(doc.leftMargin, h - doc.topMargin + 4*mm,
                w - doc.leftMargin - doc.rightMargin, 6*mm, fill=1, stroke=0)
    canvas.setFont("Helvetica-Bold", 8)
    canvas.setFillColor(C_WHITE)
    canvas.drawString(doc.leftMargin + 3*mm, h - doc.topMargin + 6*mm,
                      "MBBS Biochemistry — Jaundice & Diabetes Clinical Cases")
    canvas.drawRightString(w - doc.rightMargin - 3*mm, h - doc.topMargin + 6*mm,
                           "Quick Revision Study Guide")
    # Footer
    canvas.setFillColor(C_MED_BLUE)
    canvas.rect(doc.leftMargin, doc.bottomMargin - 4*mm,
                w - doc.leftMargin - doc.rightMargin, 5*mm, fill=1, stroke=0)
    canvas.setFont("Helvetica", 7.5)
    canvas.setFillColor(C_WHITE)
    canvas.drawCentredString(w/2, doc.bottomMargin - 2*mm, f"Page {doc.page}")
    canvas.restoreState()


# ── CONTENT BUILDERS ─────────────────────────────────────────────────────────

def section_3rd_year(styles):
    els = []

    # ── PART 1 BANNER ──
    els.append(part_banner("PART 1 — 3rd Year MBBS: Clinical Cases", C_DARK_BLUE, styles))
    els.append(sp(2))
    els.append(Paragraph(
        "Each case presents a real-world clinical vignette followed by investigations, "
        "diagnosis, and a structured biochemical discussion mapped to the MBBS curriculum.",
        styles["body"]))
    els.append(sp(1))
    els.append(hr(C_MED_BLUE, 1.5))

    # ────────────────────────────────────────────────────────────────
    # JAUNDICE CASES
    # ────────────────────────────────────────────────────────────────
    els.append(Paragraph("JAUNDICE — CLINICAL CASES", styles["h_section"]))

    # ── Case J1 ──────────────────────────────────────────────────────
    els.append(case_banner("Case J1 — Prehepatic Jaundice | Autoimmune Hemolytic Anemia", C_MED_BLUE, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Presenting Complaint:</b> 22-year-old male with yellowish eyes and skin for 3 days. "
        "Dark urine. No abdominal pain, no fever, no alcohol use. Cousin has similar history.",
        C_LIGHT_BLUE, C_MED_BLUE, styles))
    els.append(sp(1))
    els.append(Paragraph("Investigations", styles["h_sub"]))
    els.append(make_table(
        ["Test", "Result", "Interpretation"],
        [
            ["Total bilirubin", "5.8 mg/dL", "Elevated"],
            ["Direct (conjugated) bilirubin", "0.6 mg/dL", "Normal"],
            ["Indirect (unconjugated) bilirubin", "5.2 mg/dL", "Markedly elevated"],
            ["Urine bilirubin", "ABSENT", "Key finding — acholuric jaundice"],
            ["Urine urobilinogen", "Markedly elevated", "Excess bile in gut"],
            ["Haemoglobin", "7.8 g/dL", "Anaemia"],
            ["Reticulocyte count", "8%", "Elevated — active haemolysis"],
            ["Peripheral smear", "Spherocytes, polychromasia", "Haemolytic pattern"],
            ["Direct Coombs (DCT)", "Positive", "Immune-mediated haemolysis"],
            ["AST/ALT/ALP", "Near normal", "Liver intact"],
        ],
        styles, [5.5*cm, 5*cm, 6.5*cm]
    ))
    els.append(sp(1))
    els.append(info_box("<b>Diagnosis:</b> Autoimmune Haemolytic Anaemia → Prehepatic (Haemolytic) Jaundice",
        C_LIGHT_GREEN, C_GREEN, styles))
    els.append(sp(1))
    els.append(Paragraph("Biochemical Explanation", styles["h_sub"]))
    for line in [
        "• Excess RBC breakdown → massive unconjugated (indirect) bilirubin load",
        "• Unconjugated bilirubin is <b>water-insoluble</b> (bound to albumin) → cannot be filtered by glomeruli → <b>no bilirubin in urine</b> (acholuric jaundice)",
        "• Liver conjugates and excretes excess bile → more urobilinogen in gut → reabsorbed → excreted in urine → <b>urine urobilinogen very high</b>",
        "• Stools are dark (excess stercobilin)",
        "• ALT/AST are normal — the liver itself is undamaged",
    ]:
        els.append(Paragraph(line, styles["bullet"]))
    els.append(sp(1))
    els.append(quote_box(
        "Prehepatic jaundice as a result of elevated levels of unconjugated bilirubin occurs from "
        "faulty prehepatic metabolism and usually arises from conditions that interfere with proper "
        "conjugation of bilirubin in the hepatocyte.",
        "Schwartz's Principles of Surgery, 11th Ed."
    ))
    els.append(sp(2))

    # ── Case J2 ──────────────────────────────────────────────────────
    els.append(case_banner("Case J2 — Hepatocellular Jaundice | Acute Viral Hepatitis A", C_TEAL, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Presenting Complaint:</b> 19-year-old male, jaundice 5 days. Prodrome: fatigue, nausea, "
        "anorexia, low-grade fever for 2 weeks. Recently returned from rural camp. "
        "Clay-colored stools, dark urine.",
        C_LIGHT_TEAL, C_TEAL, styles))
    els.append(sp(1))
    els.append(Paragraph("Investigations", styles["h_sub"]))
    els.append(make_table(
        ["Test", "Result", "Interpretation"],
        [
            ["Total bilirubin", "9.2 mg/dL", "Elevated"],
            ["Direct bilirubin", "6.4 mg/dL", "Predominantly conjugated"],
            ["Indirect bilirubin", "2.8 mg/dL", "Also elevated"],
            ["Urine bilirubin", "Positive (3+)", "Conjugated spills into urine"],
            ["ALT", "1840 U/L", "Markedly elevated — hepatocellular damage"],
            ["AST", "1240 U/L", "Elevated; ALT > AST (viral pattern)"],
            ["ALP", "180 U/L", "Mildly elevated"],
            ["INR", "1.4", "Mildly prolonged synthetic dysfunction"],
            ["Anti-HAV IgM", "Positive", "Confirms Hepatitis A"],
        ],
        styles, [5.5*cm, 5*cm, 6.5*cm]
    ))
    els.append(sp(1))
    els.append(info_box("<b>Diagnosis:</b> Acute Hepatitis A — Hepatocellular Jaundice",
        C_LIGHT_GREEN, C_GREEN, styles))
    els.append(sp(1))
    els.append(Paragraph("Biochemical Explanation", styles["h_sub"]))
    for line in [
        "• Viral injury → hepatocyte damage → impaired bilirubin uptake, conjugation AND excretion",
        "• Both conjugated and unconjugated bilirubin rise",
        "• Conjugated bilirubin (water-soluble) leaks into blood → filtered by kidneys → <b>bilirubinuria (dark urine)</b>",
        "• <b>ALT > AST</b> pattern: ALT is cytoplasmic and highly specific for hepatocytes; AST is mitochondrial (rises later, also in cardiac/muscle injury)",
        "• AST:ALT ratio >2 suggests alcoholic hepatitis; <1 favours viral hepatitis",
        "• Mildly prolonged INR: liver impairment reduces synthesis of clotting factors (II, VII, IX, X)",
    ]:
        els.append(Paragraph(line, styles["bullet"]))
    els.append(sp(1))
    els.append(quote_box(
        "In hepatocellular dysfunction caused by viral hepatitis, aminotransferase levels are elevated, "
        "with the serum ALT level higher than the AST level.",
        "Goldman-Cecil Medicine, International Ed."
    ))
    els.append(sp(2))

    # ── Case J3 ──────────────────────────────────────────────────────
    els.append(case_banner("Case J3 — Obstructive Jaundice | Carcinoma Head of Pancreas", C_GOLD, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Presenting Complaint:</b> 55-year-old male, progressive deep jaundice 3 weeks, "
        "clay-colored stools, dark urine, <b>intense pruritus</b>, 6 kg weight loss. "
        "No fever. <b>Courvoisier's sign positive</b> (palpable non-tender gallbladder).",
        C_LIGHT_GOLD, C_GOLD, styles))
    els.append(sp(1))
    els.append(Paragraph("Investigations", styles["h_sub"]))
    els.append(make_table(
        ["Test", "Result", "Interpretation"],
        [
            ["Total bilirubin", "18 mg/dL", "Markedly elevated"],
            ["Direct bilirubin", "15.8 mg/dL", "Predominantly conjugated"],
            ["ALP", "680 U/L", "Markedly elevated — cholestatic"],
            ["GGT", "420 U/L", "Markedly elevated — cholestatic"],
            ["ALT/AST", "120/90 U/L", "Mildly elevated (secondary)"],
            ["Urine bilirubin", "4+", "Bilirubinuria"],
            ["Urine urobilinogen", "ABSENT", "No bile reaching gut"],
            ["CA 19-9", "Markedly elevated", "Pancreatic tumour marker"],
            ["USG / CECT Abdomen", "Dilated CBD, pancreatic head mass", "Confirms obstruction"],
        ],
        styles, [5.5*cm, 5*cm, 6.5*cm]
    ))
    els.append(sp(1))
    els.append(info_box("<b>Diagnosis:</b> Carcinoma Head of Pancreas → Obstructive (Posthepatic) Jaundice",
        C_LIGHT_RED, C_RED, styles))
    els.append(sp(1))
    els.append(Paragraph("Biochemical Explanation", styles["h_sub"]))
    for line in [
        "• CBD obstruction → conjugated bilirubin cannot enter duodenum → backs up into bloodstream",
        "• Water-soluble conjugated bilirubin → filtered by kidneys → <b>bilirubinuria (dark urine)</b>",
        "• No bile in gut → no urobilinogen → <b>absent urine urobilinogen</b> → pale/clay stools",
        "• <b>ALP and GGT markedly elevated</b>: back-pressure induces ALP synthesis in bile duct epithelium",
        "• <b>Pruritus</b>: bile salt deposition in skin stimulates cutaneous nerve fibres",
        "• <b>Prolonged PT</b>: bile blockage → Vitamin K malabsorption → reduced synthesis of factors II, VII, IX, X",
        "• Courvoisier's sign = palpable non-tender gallbladder + jaundice → malignancy until proved otherwise",
    ]:
        els.append(Paragraph(line, styles["bullet"]))
    els.append(sp(2))

    # ── Case J4 ──────────────────────────────────────────────────────
    els.append(case_banner("Case J4 — Gilbert's Syndrome | Hereditary Unconjugated Hyperbilirubinaemia", C_PURPLE, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Presenting Complaint:</b> 24-year-old medical student, incidental yellow eyes during physical exam. "
        "Episodes with prolonged fasting and exam stress. Father also has 'yellow eyes'. "
        "No dark urine, no abdominal symptoms.",
        C_LIGHT_PURPLE, C_PURPLE, styles))
    els.append(sp(1))
    els.append(make_table(
        ["Test", "Result"],
        [
            ["Total bilirubin", "3.2 mg/dL"],
            ["Direct bilirubin", "0.3 mg/dL (indirect = 2.9 mg/dL)"],
            ["LFTs, albumin, INR", "All NORMAL"],
            ["CBC, reticulocytes, peripheral smear", "All NORMAL"],
            ["Urine bilirubin", "Absent"],
        ],
        styles, [8*cm, 9*cm]
    ))
    els.append(sp(1))
    els.append(info_box(
        "<b>Diagnosis:</b> Gilbert's Syndrome — benign hereditary unconjugated hyperbilirubinaemia. "
        "Defect: TA-repeat polymorphism in UGT1A1 promoter → ~30% reduced UDP-glucuronosyltransferase "
        "activity. Autosomal recessive. Affects 4-7% of population. No treatment needed.",
        C_LIGHT_GREEN, C_GREEN, styles))
    els.append(sp(2))

    # ────────────────────────────────────────────────────────────────
    # DIABETES CASES
    # ────────────────────────────────────────────────────────────────
    els.append(hr(C_DARK_BLUE, 1.5))
    els.append(Paragraph("DIABETES MELLITUS — CLINICAL CASES", styles["h_section"]))

    # ── Case D1 ──────────────────────────────────────────────────────
    els.append(case_banner("Case D1 — Type 1 DM | New-onset Diabetic Ketoacidosis (DKA)", C_RED, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Presenting Complaint:</b> 14-year-old girl, 4 weeks of polyuria, polydipsia, polyphagia, "
        "5 kg weight loss despite eating well. Today: drowsy, deep rapid breathing, fruity breath. "
        "BMI 17. BP 90/60, HR 122, RR 28/min (Kussmaul breathing).",
        C_LIGHT_RED, C_RED, styles))
    els.append(sp(1))
    els.append(Paragraph("Investigations", styles["h_sub"]))
    els.append(make_table(
        ["Test", "Result", "Significance"],
        [
            ["Blood glucose", "520 mg/dL", "Hyperglycaemia"],
            ["Serum Na", "128 mEq/L", "Pseudohyponatraemia (osmotic shift)"],
            ["Serum K", "5.4 mEq/L", "Initially high; total body deficit"],
            ["Serum HCO₃", "10 mEq/L", "Low — metabolic acidosis"],
            ["Arterial pH", "7.16", "Acidosis (severe if <7.0)"],
            ["Anion gap", "22 mEq/L", "High anion gap = ketoacids"],
            ["Serum ketones", "Strongly positive", "Ketoacidosis confirmed"],
            ["HbA1c", "11.2%", "Chronic uncontrolled hyperglycaemia"],
            ["C-peptide", "Very low", "Absent endogenous insulin"],
            ["Anti-GAD antibody", "Positive", "Autoimmune T1DM confirmed"],
        ],
        styles, [5*cm, 4.5*cm, 7.5*cm]
    ))
    els.append(sp(1))
    els.append(info_box("<b>Diagnosis:</b> New-onset Type 1 DM presenting as Diabetic Ketoacidosis (DKA)",
        C_LIGHT_RED, C_RED, styles))
    els.append(sp(1))
    els.append(Paragraph("DKA Diagnostic Criteria", styles["h_sub"]))
    els.append(make_table(
        ["Parameter", "Mild", "Moderate", "Severe"],
        [
            ["Blood glucose", ">250 mg/dL", ">250 mg/dL", ">250 mg/dL"],
            ["Arterial pH", "7.25 – 7.30", "7.00 – 7.24", "<7.00"],
            ["Serum HCO₃", "15 – 18 mEq/L", "10 – 15 mEq/L", "<10 mEq/L"],
            ["Ketones (serum/urine)", "Positive", "Positive", "Positive"],
            ["Anion gap", ">10", ">12", ">12"],
        ],
        styles, [5*cm, 4*cm, 4*cm, 4*cm], header_color=C_RED
    ))
    els.append(sp(1))
    els.append(Paragraph("Biochemical Pathogenesis of DKA", styles["h_sub"]))
    for line in [
        "<b>1. No insulin → hyperglycaemia:</b> No GLUT4 translocation → glucose not taken up by muscle/fat → hyperglycaemia → osmotic diuresis → polyuria → dehydration",
        "<b>2. No insulin → ketogenesis:</b> Glucagon dominates → activates hormone-sensitive lipase → FFAs flood liver → β-oxidation → excess acetyl-CoA → ketone bodies → metabolic acidosis",
        "<b>3. No insulin → protein catabolism:</b> Muscle proteolysis → gluconeogenic amino acids → even more hyperglycaemia",
        "<b>Kussmaul breathing:</b> Respiratory compensation for metabolic acidosis — hyperventilation blows off CO₂ to raise blood pH",
        "<b>Fruity breath:</b> From acetone (spontaneous decarboxylation of acetoacetate) — acetone is volatile and exhaled",
        "<b>Pseudohyponatraemia:</b> High glucose is osmotically active → draws water into vascular space → dilutes sodium",
    ]:
        els.append(Paragraph(line, styles["bullet"]))
    els.append(sp(1))
    els.append(quote_box(
        "The clinical history of DKA typically involves deterioration during several hours to days, with "
        "progressive polyuria, polydipsia... physical findings include dry skin and mucous membranes, "
        "reduced jugular venous pressure, tachycardia, orthostatic hypotension, depressed mental "
        "function, and deep rapid respirations (Kussmaul breathing).",
        "Goldman-Cecil Medicine, International Ed."
    ))
    els.append(sp(2))

    # ── Case D2 ──────────────────────────────────────────────────────
    els.append(case_banner("Case D2 — Type 2 DM | Incidental Detection + Metabolic Syndrome", C_TEAL, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Presenting Complaint:</b> 52-year-old obese man for routine check-up. Fatigue, nocturia. "
        "Hypertension on amlodipine. Father had diabetes. BMI 29, waist 98 cm. "
        "<b>Acanthosis nigricans</b> at neck and axillae (skin marker of insulin resistance).",
        C_LIGHT_TEAL, C_TEAL, styles))
    els.append(sp(1))
    els.append(make_table(
        ["Test", "Result", "Reference / Significance"],
        [
            ["Fasting plasma glucose (×2)", "148 mg/dL", "Diagnostic: ≥126 mg/dL"],
            ["2-hr OGTT (75g)", "230 mg/dL", "Diagnostic: ≥200 mg/dL"],
            ["HbA1c", "8.1%", "Diagnostic: ≥6.5%"],
            ["Fasting insulin", "Elevated", "Insulin resistance"],
            ["Urine microalbumin/creatinine", "38 mg/g", "Early nephropathy (>30 = microalbuminuria)"],
            ["TG / HDL", "290 / 32 mg/dL", "Dyslipidaemia — metabolic syndrome"],
        ],
        styles, [5.5*cm, 4*cm, 7.5*cm]
    ))
    els.append(sp(1))
    els.append(info_box(
        "<b>Diagnosis:</b> Type 2 DM with early diabetic nephropathy. Metabolic Syndrome "
        "(HTN + central obesity + dyslipidaemia + impaired glucose).",
        C_LIGHT_GREEN, C_GREEN, styles))
    els.append(sp(1))
    els.append(Paragraph("ADA Diagnostic Criteria for Diabetes (any one of the following):", styles["h_sub"]))
    for line in [
        "• FPG ≥126 mg/dL (7.0 mmol/L) on 2 occasions",
        "• 2-hr plasma glucose ≥200 mg/dL during 75g OGTT",
        "• HbA1c ≥6.5% (48 mmol/mol)",
        "• Random glucose ≥200 mg/dL with classic symptoms",
    ]:
        els.append(Paragraph(line, styles["bullet"]))
    els.append(sp(2))

    # ── Case D3 ──────────────────────────────────────────────────────
    els.append(case_banner("Case D3 — Hyperosmolar Hyperglycaemic State (HHS)", C_GOLD, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Presenting Complaint:</b> 70-year-old man, known T2DM, brought in confused and lethargic. "
        "Poor oral intake + vomiting × 5 days (gastroenteritis). Missed medications × 3 days. "
        "GCS 11/15. Severe dehydration. No Kussmaul breathing, no fruity odour.",
        C_LIGHT_GOLD, C_GOLD, styles))
    els.append(sp(1))
    els.append(Paragraph("DKA vs HHS — Key Differences", styles["h_sub"]))
    els.append(make_table(
        ["Feature", "DKA", "HHS"],
        [
            ["Usual diabetes type", "Type 1 (also Type 2)", "Type 2"],
            ["Age", "Younger", "Older (>60 yrs)"],
            ["Blood glucose", "250–600 mg/dL", ">600 mg/dL (often >800)"],
            ["Ketones", "Marked (4+)", "Absent / trace"],
            ["Arterial pH", "<7.30", "Normal (>7.35)"],
            ["Serum HCO₃", "<18 mEq/L", "Normal (>18 mEq/L)"],
            ["Serum osmolality", "Variable / <320", ">320 mOsm/kg"],
            ["Onset", "Hours to days", "Days to weeks"],
            ["Kussmaul breathing", "Present", "Absent"],
            ["Mortality", "~1–5%", "~10–20%"],
        ],
        styles, [5*cm, 6*cm, 6*cm], header_color=C_GOLD
    ))
    els.append(sp(1))
    els.append(info_box(
        "<b>Why no ketosis in HHS?</b> In T2DM, residual insulin secretion is sufficient to suppress "
        "hormone-sensitive lipase and halt lipolysis/ketogenesis — but insufficient to prevent severe "
        "hyperglycaemia. In T1DM (DKA), absolute zero insulin → unrestrained lipolysis.",
        C_LIGHT_GOLD, C_GOLD, styles))
    els.append(sp(2))

    # ── Cases D4 and D5 (shorter) ────────────────────────────────────
    els.append(case_banner("Case D4 — Drug-induced Liver Injury (DILI) in a Diabetic Patient", C_PURPLE, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Scenario:</b> 45-yr-old T2DM on metformin + statin, jaundice × 10 days after starting "
        "herbal supplement. No fever, normal USG (no ductal dilatation). Viral hepatitis screen: negative. "
        "ALT 960 U/L, Total Bilirubin 7.2 mg/dL, Direct 5.8, INR 1.9. HbA1c 9.8%.",
        C_LIGHT_PURPLE, C_PURPLE, styles))
    els.append(sp(1))
    for line in [
        "<b>Diagnosis:</b> Drug/herbal supplement-induced hepatocellular jaundice",
        "• Diabetics are at higher risk of NAFLD and hepatotoxicity — fatty liver as background",
        "• Hepatocellular pattern: ALT >> ALP; both conjugated and unconjugated bilirubin elevated",
        "• Impaired synthetic function: raised INR (reduced clotting factor synthesis)",
        "• Always take full drug/supplement history in any jaundice case",
        "• Poor HbA1c (9.8%) suggests chronic hyperglycaemia promoting hepatic steatosis",
    ]:
        els.append(Paragraph(line, styles["bullet"]))
    els.append(sp(2))

    els.append(case_banner("Case D5 — Metformin-associated Lactic Acidosis (MALA)", C_RED, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Scenario:</b> 58-yr-old T2DM on metformin 2g/day + CKD (eGFR 28). Recent IV contrast CT. "
        "Presents: breathlessness, confusion, abdominal pain. "
        "ABG: pH 7.08, HCO₃ 8, Lactate 14 mmol/L. Glucose 180 mg/dL. <b>Ketones: absent.</b>",
        C_LIGHT_RED, C_RED, styles))
    els.append(sp(1))
    for line in [
        "<b>Diagnosis:</b> Metformin-associated Lactic Acidosis — HIGH ANION GAP metabolic acidosis",
        "<b>Mechanism:</b> Metformin inhibits mitochondrial Complex I (NADH dehydrogenase) → pyruvate cannot enter TCA → accumulates → converted to <b>lactate (anaerobic glycolysis)</b>",
        "• In renal failure, metformin accumulates (renally excreted) → toxicity worsens",
        "• Contrast-induced nephropathy further precipitates AKI → even less metformin clearance",
        "<b>Rule:</b> Metformin contraindicated when eGFR <30 mL/min; withhold before contrast procedures",
        "<b>Differentiates from DKA:</b> glucose only mildly elevated, NO ketones, very high lactate",
    ]:
        els.append(Paragraph(line, styles["bullet"]))

    els.append(PageBreak())
    return els


def section_1st_2nd_year(styles):
    els = []

    els.append(part_banner("PART 2 — 1st & 2nd Year MBBS: Biochemistry Deep Dives", C_TEAL, styles))
    els.append(sp(2))
    els.append(Paragraph(
        "Mechanism-focused cases linking biochemical pathways to clinical presentations. "
        "Ideal for 1st and 2nd year students preparing for theory examinations.",
        styles["body"]))
    els.append(sp(1))
    els.append(hr(C_TEAL, 1.5))

    # ────────────────────────────────────────────────────────────────
    # JAUNDICE BIOCHEMISTRY
    # ────────────────────────────────────────────────────────────────
    els.append(Paragraph("JAUNDICE — BIOCHEMISTRY", styles["h_section"]))

    # J1 Bilirubin pathway
    els.append(case_banner("J1 — The Complete Bilirubin Pathway (Gilbert's Syndrome as Model)", C_MED_BLUE, styles))
    els.append(sp(1))
    els.append(Paragraph("Step 1 — Bilirubin Formation (Reticuloendothelial System)", styles["h_sub"]))
    els.append(pathway_box([
        "Haemoglobin  →  [globin released + heme extracted]",
        "Heme (ferroprotoporphyrin IX)",
        "  ↓  heme oxygenase (microsomal, ER of macrophages in spleen/liver/BM)",
        "  ↓  → CO released (1 mol/mol heme)  +  Fe²⁺ released (recycled to transferrin)",
        "Biliverdin  (green pigment)",
        "  ↓  biliverdin reductase (cytosol)",
        "Bilirubin  (yellow-orange pigment)  ← water-INSOLUBLE",
    ]))
    els.append(sp(1))
    els.append(Paragraph(
        "80–85% of bilirubin comes from senescent RBC breakdown (RBC lifespan ~120 days). "
        "Remaining 15–20% from premature erythroid cell destruction in bone marrow and turnover "
        "of myoglobin, cytochromes.",
        styles["body"]))
    els.append(sp(1))
    els.append(quote_box(
        "The formation of bilirubin occurs in reticuloendothelial cells, primarily in the spleen and liver. "
        "The first reaction, catalyzed by the microsomal enzyme heme oxygenase, oxidatively cleaves the "
        "alpha bridge of the porphyrin group. The second reaction, catalyzed by biliverdin reductase, "
        "reduces the central methylene bridge of biliverdin and converts it to bilirubin.",
        "Harrison's Principles of Internal Medicine, 22nd Ed. (2025)"
    ))
    els.append(sp(1))

    els.append(Paragraph("Step 2 — Transport in Blood", styles["h_sub"]))
    for line in [
        "• Bilirubin is <b>water-insoluble</b> — internal hydrogen bonds between propionic acid groups and imino/lactam groups make it hydrophobic",
        "• Binds reversibly and non-covalently to <b>albumin</b> for transport → called <b>unconjugated (indirect) bilirubin</b>",
        "• Protein-bound → too large to be glomerularly filtered → <b>NEVER appears in normal urine</b>",
        "• Clinically: urine bilirubin ABSENT in prehepatic/unconjugated jaundice = 'acholuric jaundice'",
    ]:
        els.append(Paragraph(line, styles["bullet"]))
    els.append(sp(1))

    els.append(Paragraph("Step 3 — Hepatic Uptake and Conjugation", styles["h_sub"]))
    els.append(pathway_box([
        "Unconjugated bilirubin–albumin complex arrives at hepatocyte sinusoidal membrane",
        "  ↓  carrier-mediated uptake (OATP transporters) — bilirubin taken in, albumin stays in blood",
        "  ↓  intracellular binding to ligandin (glutathione-S-transferase) — prevents back-diffusion",
        "Smooth ER:  Bilirubin + UDP-glucuronic acid",
        "  ↓  UDP-glucuronosyltransferase (UGT1A1)  ← KEY ENZYME",
        "Bilirubin monoglucuronide  →  Bilirubin diglucuronide  (water-SOLUBLE)",
        "  ↓  MRP2 transporter (active, ATP-dependent) at canalicular membrane",
        "Secreted into bile canaliculi  →  bile ducts  →  duodenum",
    ]))
    els.append(sp(1))
    els.append(info_box(
        "<b>Gilbert's Syndrome:</b> TA-repeat polymorphism in UGT1A1 promoter → ~30% reduced UGT1A1 "
        "activity. Autosomal recessive. Fasting/stress → FFAs compete for albumin, displace bilirubin, "
        "flooding the already-reduced conjugation system. Result: mild unconjugated hyperbilirubinaemia "
        "during fasting/illness. Completely benign — no treatment. 4–7% population prevalence.",
        C_LIGHT_BLUE, C_MED_BLUE, styles))
    els.append(sp(1))

    els.append(Paragraph("Step 4 — Intestinal Fate and Van den Bergh Reaction", styles["h_sub"]))
    els.append(pathway_box([
        "Conjugated bilirubin in intestine",
        "  ↓  bacterial beta-glucuronidases (distal ileum/colon)",
        "Unconjugated bilirubin  →  gut bacterial reduction",
        "Urobilinogens (colourless tetrapyrroles)",
        "  ↓  oxidation in stool → STERCOBILIN  (brown stool colour)",
        "  ↓  10–20% reabsorbed → portal blood → liver → re-excreted (enterohepatic circulation)",
        "  ↓  small fraction → kidney → URINE UROBILINOGEN (normal ≤1 mg/dL)",
    ]))
    els.append(sp(1))
    els.append(Paragraph(
        "<b>Van den Bergh reaction</b> (still used in labs): Bilirubin + diazotized sulfanilic acid "
        "→ purple azopigment (absorbance at 540 nm). "
        "<b>Direct fraction</b> = reacts without accelerator = conjugated bilirubin. "
        "<b>Indirect fraction</b> = reacts after adding alcohol (breaks albumin bond) = unconjugated bilirubin. "
        "Normal total bilirubin: 0.2–1.0 mg/dL. Jaundice clinically visible at >3 mg/dL.",
        styles["body"]))
    els.append(sp(2))

    # J2 Neonatal jaundice
    els.append(case_banner("J2 — Physiological Neonatal Jaundice and Kernicterus", C_GOLD, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Vignette:</b> 3-day-old full-term male, jaundice extending to chest (Kramer zone II–III). "
        "Total bilirubin 12 mg/dL, direct 0.4 mg/dL. DCT negative. Hb normal. Breastfeeding well.",
        C_LIGHT_GOLD, C_GOLD, styles))
    els.append(sp(1))
    els.append(Paragraph("Why Does Physiological Jaundice Occur?", styles["h_sub"]))
    els.append(make_table(
        ["Reason", "Explanation"],
        [
            ["High RBC breakdown", "Fetal RBCs have shorter lifespan (70–90 days). Massive bilirubin load postnatally"],
            ["Immature UGT1A1", "Neonatal UGT1A1 only ~1% of adult activity at birth. Reaches adult levels by 4–8 weeks"],
            ["High enterohepatic circulation", "High beta-glucuronidase in gut; sterile gut (no bacteria); slow motility → more reabsorption"],
            ["Low albumin", "Reduced binding capacity → more free unconjugated bilirubin circulates"],
        ],
        styles, [5*cm, 12*cm]
    ))
    els.append(sp(1))
    els.append(Paragraph("Kernicterus", styles["h_sub"]))
    for line in [
        "• Unconjugated bilirubin (lipophilic + unbound to albumin = 'free bilirubin') crosses the blood-brain barrier",
        "• Neonatal BBB is immature → especially vulnerable",
        "• Deposits in: <b>basal ganglia (globus pallidus)</b>, cochlear nuclei, cerebellum",
        "• Results in: opisthotonos, high-pitched cry, sensorineural hearing loss, choreoathetosis, intellectual disability",
        "<b>Phototherapy:</b> Blue light (420–480 nm) converts bilirubin to water-soluble photo-isomers (lumirubin) → excreted in bile/urine without conjugation",
    ]:
        els.append(Paragraph(line, styles["bullet"]))
    els.append(sp(1))
    els.append(Paragraph("Physiological vs Pathological Neonatal Jaundice", styles["h_sub"]))
    els.append(make_table(
        ["Feature", "Physiological", "Pathological"],
        [
            ["Onset", "Day 2–3", "Within 24 hours of birth"],
            ["Duration", "Resolves by day 7–10 (term)", "Persists >14 days"],
            ["Rate of rise", "<5 mg/dL/day", ">5 mg/dL/day"],
            ["Bilirubin type", "Unconjugated only", "Conjugated (always pathological)"],
            ["Common causes", "Normal physiology", "Haemolysis, infection, metabolic"],
        ],
        styles, [4*cm, 6.5*cm, 6.5*cm], header_color=C_GOLD
    ))
    els.append(sp(2))

    # J3 Obstructive biochemistry
    els.append(case_banner("J3 — Obstructive Jaundice: Why Pale Stools and Dark Urine?", C_TEAL, styles))
    els.append(sp(1))
    els.append(info_box(
        "<b>Vignette:</b> 40-year-old obese woman, Charcot's triad: RUQ pain + fever + jaundice. "
        "Cola urine, pale stools, intense pruritus. "
        "USG: gallstones, dilated CBD 12 mm, stone at CBD. Diagnosis: Choledocholithiasis.",
        C_LIGHT_TEAL, C_TEAL, styles))
    els.append(sp(1))
    els.append(pathway_box([
        "NORMAL:  Conjugated bilirubin → bile → intestine → urobilinogen → stercobilin → BROWN stool",
        "                                                      ↓ (enterhepatic)  → trace urobilinogen in urine",
        "",
        "OBSTRUCTION:",
        "  Conjugated bilirubin BLOCKED → backs up into bloodstream (high direct bilirubin)",
        "  Water-soluble → filtered by kidney → DARK URINE (bilirubinuria, +4)",
        "  No bile reaches gut → NO urobilinogen formed → ABSENT urine urobilinogen",
        "  No stercobilin → PALE / CLAY-COLOURED STOOLS",
    ]))
    els.append(sp(1))
    els.append(Paragraph("Why is ALP markedly elevated in obstruction?", styles["h_sub"]))
    els.append(Paragraph(
        "Back-pressure from bile induces synthesis of <b>alkaline phosphatase (ALP)</b> in cholangiocytes "
        "(bile duct epithelial cells). Bile acids also solubilize ALP from hepatocyte canalicular membranes. "
        "GGT rises by the same mechanism. Pattern: ALP ↑↑↑, GGT ↑↑↑, ALT/AST mildly elevated = "
        "<b>cholestatic (obstructive) pattern</b>.",
        styles["body"]))
    els.append(sp(1))
    els.append(Paragraph("Why is PT prolonged?", styles["h_sub"]))
    els.append(Paragraph(
        "Bile is required for absorption of <b>fat-soluble vitamins A, D, E, K</b>. "
        "Vitamin K activates (gamma-carboxylates) clotting factors <b>II, VII, IX, X</b> via carboxylase enzyme. "
        "Bile blockage → Vit K deficiency → prolonged PT. "
        "<b>Key test:</b> PT corrects with parenteral Vit K in obstructive jaundice but NOT in hepatocellular "
        "(liver too damaged to synthesise factors regardless of Vit K supply).",
        styles["body"]))
    els.append(sp(2))

    # ────────────────────────────────────────────────────────────────
    # DIABETES BIOCHEMISTRY
    # ────────────────────────────────────────────────────────────────
    els.append(hr(C_TEAL, 1.5))
    els.append(Paragraph("DIABETES — BIOCHEMISTRY", styles["h_section"]))

    # D1 Insulin biosynthesis
    els.append(case_banner("D1 — Insulin: From Gene to Secretory Granule", C_MED_BLUE, styles))
    els.append(sp(1))
    els.append(pathway_box([
        "Insulin gene  (short arm chromosome 11)",
        "  ↓  transcription → mRNA",
        "  ↓  translation on ribosomes → PREPROINSULIN (110 amino acids)",
        "    [contains: signal peptide + B chain + C peptide + A chain]",
        "  ↓  signal peptidase cleaves 24-aa leader in ER lumen",
        "PROINSULIN  (86 aa)  =  B + C + A  [linear chain; 3 disulfide bonds form]",
        "  ↓  packaged into secretory granules (trans-Golgi)",
        "  ↓  PC1/3 and PC2 proteases cleave at 2 sites",
        "INSULIN (51 aa: A-chain 21 aa + B-chain 30 aa)  +  C-PEPTIDE (31 aa)",
        "  ↓  stored in granule with Zinc",
        "  ↓  glucose stimulus → exocytosis → both secreted 1:1 into portal blood",
    ]))
    els.append(sp(1))
    els.append(make_table(
        ["Component", "Size", "Key Point"],
        [
            ["Preproinsulin", "110 amino acids", "Initial translation product; enters RER"],
            ["Proinsulin", "86 amino acids", "After signal peptide cleavage; folds in RER"],
            ["C-peptide", "31 amino acids", "Cleaved in Golgi; co-secreted 1:1 with insulin"],
            ["Insulin (mature)", "51 amino acids", "A-chain (21 aa) + B-chain (30 aa); 2 interchain + 1 intrachain disulfide bonds"],
        ],
        styles, [3.5*cm, 4*cm, 9.5*cm]
    ))
    els.append(sp(1))
    els.append(info_box(
        "<b>C-peptide clinical use:</b> Measures endogenous insulin secretion. "
        "Low C-peptide = Type 1 DM (beta cells destroyed). "
        "High insulin + low C-peptide = exogenous insulin injection. "
        "High insulin + high C-peptide = insulinoma (autonomous secretion).",
        C_LIGHT_BLUE, C_MED_BLUE, styles))
    els.append(sp(1))
    els.append(quote_box(
        "Insulin is initially synthesized as a single-chain 86-amino-acid precursor polypeptide, preproinsulin. "
        "Cleavage of an internal 31-residue fragment from proinsulin generates C-peptide with the A (21 amino "
        "acids) and B (30 amino acids) chains connected by disulfide bonds. The mature insulin molecule and "
        "C-peptide are stored together and co-secreted from secretory granules in the beta cells.",
        "Harrison's Principles of Internal Medicine, 22nd Ed. (2025)"
    ))
    els.append(sp(2))

    # D2 Beta cell secretion
    els.append(case_banner("D2 — Beta-cell Insulin Secretion: K_ATP Channel and Sulfonylureas", C_TEAL, styles))
    els.append(sp(1))
    els.append(pathway_box([
        "Glucose rises in blood post-meal",
        "  ↓  enters beta cell via GLUT2 (constitutive; not insulin-dependent)",
        "  ↓  GLUCOKINASE phosphorylates glucose → Glucose-6-phosphate  ← RATE-LIMITING STEP",
        "  ↓  glycolysis + oxidative phosphorylation → ATP generated (ATP:ADP ratio rises)",
        "  ↓  ATP-sensitive K⁺ channel (K_ATP) CLOSES",
        "  ↓  K⁺ cannot leave → membrane DEPOLARISES (–70 mV → 0 mV)",
        "  ↓  Voltage-gated Ca²⁺ channels OPEN",
        "  ↓  Ca²⁺ influx into beta cell",
        "  ↓  Secretory granules fuse with plasma membrane → EXOCYTOSIS",
        "  ↓  Insulin + C-peptide + proinsulin released into portal circulation",
    ]))
    els.append(sp(1))
    els.append(info_box(
        "<b>How do sulfonylureas work?</b> They bind directly to the <b>SUR1 subunit</b> of the K_ATP channel, "
        "keeping it closed regardless of glucose levels — mimicking ATP inhibition. This causes membrane "
        "depolarisation → Ca²⁺ influx → insulin release. "
        "Risk: hypoglycaemia even at normal blood glucose (unlike metformin).",
        C_LIGHT_TEAL, C_TEAL, styles))
    els.append(sp(1))
    els.append(Paragraph("Two-Phase Insulin Secretion", styles["h_sub"]))
    els.append(make_table(
        ["Phase", "Timing", "Source", "Lost in T2DM?"],
        [
            ["First phase (rapid spike)", "0–10 min", "Pre-formed granules already docked at membrane", "YES — lost early"],
            ["Second phase (sustained)", "10–60 min", "Newly synthesized + mobilized granules", "Partially preserved initially"],
        ],
        styles, [3.5*cm, 3*cm, 6*cm, 4.5*cm]
    ))
    els.append(sp(1))
    els.append(info_box(
        "<b>Key exam point:</b> Loss of first-phase insulin secretion is one of the earliest detectable "
        "abnormalities in Type 2 DM. It causes the post-meal glucose spike that eventually drives microvascular "
        "and macrovascular complications.",
        C_LIGHT_GOLD, C_GOLD, styles))
    els.append(sp(2))

    # D3 DKA biochemistry
    els.append(case_banner("D3 — DKA Biochemistry: Ketone Bodies, Anion Gap, Oxaloacetate Depletion", C_RED, styles))
    els.append(sp(1))
    els.append(Paragraph("Ketone Body Formation — Full Pathway", styles["h_sub"]))
    els.append(pathway_box([
        "No insulin → glucagon dominates → activates hormone-sensitive lipase (adipose)",
        "Triglycerides → Glycerol + Free Fatty Acids (FFAs)",
        "  ↓  FFAs enter liver",
        "  ↓  Carnitine acyltransferase I (CPTI) transports FAs into mitochondria",
        "  ↓  Beta-oxidation → massive Acetyl-CoA production",
        "",
        "WHY can't Acetyl-CoA enter TCA? → Oxaloacetate (OAA) is depleted!",
        "  (OAA is drained for gluconeogenesis via PEPCK → PEP)",
        "",
        "Acetyl-CoA overflow → KETOGENESIS:",
        "  2× Acetyl-CoA → Acetoacetyl-CoA",
        "  + Acetyl-CoA → HMG-CoA  [HMG-CoA synthase — mitochondrial]",
        "  HMG-CoA → Acetoacetate + Acetyl-CoA  [HMG-CoA lyase]",
        "  Acetoacetate → Beta-hydroxybutyrate  [NADH-dependent; beta-HB dehydrogenase]",
        "  Acetoacetate → Acetone + CO₂  [spontaneous decarboxylation → FRUITY BREATH]",
    ]))
    els.append(sp(1))
    els.append(info_box(
        "<b>Why can the liver make but not use ketones?</b> The liver lacks "
        "<b>3-ketoacid CoA transferase (thiophorase)</b> — the enzyme needed to convert acetoacetate back "
        "to acetoacetyl-CoA. So the liver makes ketones and ships them to muscle and brain (which have "
        "thiophorase) to use as fuel.",
        C_LIGHT_RED, C_RED, styles))
    els.append(sp(1))
    els.append(Paragraph("Anion Gap Calculation", styles["h_sub"]))
    els.append(Paragraph(
        "Anion Gap = Na⁺ − (Cl⁻ + HCO₃⁻)  |  Normal = 8–12 mEq/L",
        styles["body_bold"]))
    els.append(Paragraph(
        "In DKA: Ketoacids (acetoacetate + beta-hydroxybutyrate) are unmeasured anions → gap widens. "
        "Example: Na 130, Cl 96, HCO₃ 9 → AG = 130 − (96+9) = <b>25 mEq/L</b> (high). "
        "The 'missing' anions = ketoacids.",
        styles["body"]))
    els.append(sp(1))
    els.append(quote_box(
        "During prolonged starvation, or whenever carbohydrate metabolism is severely impaired as in "
        "untreated type 1 diabetes mellitus, the formation of acetyl-CoA exceeds the supply of oxaloacetate. "
        "The resulting excess acetyl-CoA is diverted to form acetoacetic acid, beta-hydroxybutyric acid, "
        "and acetone — three compounds known collectively as ketone bodies.",
        "Tietz Textbook of Laboratory Medicine, 7th Ed."
    ))
    els.append(sp(2))

    # D4 HbA1c
    els.append(case_banner("D4 — HbA1c: Glycation, Amadori Product, Clinical Interpretation", C_PURPLE, styles))
    els.append(sp(1))
    els.append(pathway_box([
        "Step 1 — Schiff Base (reversible, hours):",
        "  Glucose (aldehyde group) + NH₂-terminal valine of Hb beta chain",
        "  → Unstable Schiff base (aldimine)",
        "",
        "Step 2 — Amadori Rearrangement (irreversible):",
        "  Schiff base undergoes molecular rearrangement",
        "  → Stable ketoamine = HbA1c  ← persists for life of RBC",
    ]))
    els.append(sp(1))
    els.append(Paragraph(
        "Rate of HbA1c formation is directly proportional to ambient glucose concentration (mass-action). "
        "Reflects <b>weighted average blood glucose over 8–12 weeks</b> (recent weeks contribute more "
        "due to RBC age distribution). This is <b>non-enzymatic glycosylation (glycation)</b> — no enzyme involved.",
        styles["body"]))
    els.append(sp(1))
    els.append(make_table(
        ["HbA1c Value", "Interpretation", "Action"],
        [
            ["<5.7% (<39 mmol/mol)", "Normal", "No action"],
            ["5.7–6.4% (39–46 mmol/mol)", "Prediabetes (high risk)", "Lifestyle modification"],
            ["≥6.5% (≥48 mmol/mol)", "Diabetes mellitus", "Diagnostic + treat"],
            ["<7.0%", "Target for most T2DM patients", "Good control"],
            [">8.0%", "Poor glycaemic control", "Intensify therapy"],
        ],
        styles, [4.5*cm, 6.5*cm, 6*cm], header_color=C_PURPLE
    ))
    els.append(sp(1))
    els.append(Paragraph("Conditions Affecting HbA1c Accuracy", styles["h_sub"]))
    els.append(make_table(
        ["Falsely LOW HbA1c", "Falsely HIGH HbA1c"],
        [
            ["Haemolytic anaemia (RBCs destroyed early)", "Iron deficiency anaemia (older RBCs; more time for glycation)"],
            ["Recent blood transfusion (new donor RBCs)", "Asplenia (prolonged RBC lifespan)"],
            ["Pregnancy (increased RBC turnover)", "Renal failure (carbamylated Hb interferes)"],
            ["HbS, HbC variants (assay interference)", "Alcoholism"],
        ],
        styles, [8.5*cm, 8.5*cm], header_color=C_PURPLE
    ))

    els.append(PageBreak())
    return els


def section_quick_reference(styles):
    els = []

    els.append(part_banner("PART 3 — Quick Reference Tables (Exam Ready)", C_RED, styles))
    els.append(sp(2))

    # Jaundice comparison mega-table
    els.append(Paragraph("Jaundice — Master Comparison Table", styles["h_section"]))
    els.append(make_table(
        ["Feature", "Prehepatic", "Hepatocellular", "Posthepatic"],
        [
            ["Serum bilirubin", "Unconjugated (indirect) ↑↑", "Both ↑ (conjugated + unconjugated)", "Conjugated (direct) ↑↑"],
            ["Urine bilirubin", "ABSENT (acholuric)", "PRESENT (+1 to +3)", "PRESENT (+4)"],
            ["Urine urobilinogen", "↑↑↑ (excess production)", "Variable (↑ then ↓)", "ABSENT"],
            ["Stool colour", "Dark (excess stercobilin)", "Normal or pale", "Pale / clay-coloured"],
            ["ALT / AST", "Normal", "↑↑↑ (ALT > AST viral)", "Mildly elevated"],
            ["ALP / GGT", "Normal", "Mild ↑", "↑↑↑ (markedly)"],
            ["Serum albumin", "Normal", "Low in chronic disease", "Normal initially"],
            ["Prothrombin time", "Normal", "Prolonged (hepatocellular)", "Prolonged; corrects with Vit K"],
            ["Splenomegaly", "Common (haemolysis)", "May occur", "Absent usually"],
            ["Example causes", "Haemolysis, Gilbert's, G6PD", "Viral hepatitis, drugs, alcohol", "Gallstones, Ca pancreas, PSC"],
        ],
        styles, [4*cm, 4.3*cm, 4.3*cm, 4.4*cm]
    ))
    els.append(sp(2))

    # Bilirubin pathway enzyme table
    els.append(Paragraph("Bilirubin Pathway — Enzymes and Defects", styles["h_section"]))
    els.append(make_table(
        ["Step", "Enzyme", "Product", "Disease if Defective"],
        [
            ["Heme → Biliverdin", "Heme oxygenase", "Biliverdin + CO + Fe²⁺", "—"],
            ["Biliverdin → Bilirubin", "Biliverdin reductase", "Unconjugated bilirubin", "—"],
            ["Bilirubin → Glucuronide", "UGT1A1 (UDP-glucuronosyltransferase)", "Conjugated bilirubin", "Gilbert's (30% ↓), Crigler-Najjar (absent)"],
            ["Hepatocyte → Bile", "MRP2 transporter (ABCC2)", "Bilirubin excreted in bile", "Dubin-Johnson syndrome"],
            ["Gut deconjugation", "Bacterial beta-glucuronidase", "Urobilinogen", "—"],
        ],
        styles, [3.5*cm, 5*cm, 4.5*cm, 4*cm]
    ))
    els.append(sp(2))

    # Diabetes comparison
    els.append(Paragraph("Diabetes — Type 1 vs Type 2 vs DKA vs HHS", styles["h_section"]))
    els.append(make_table(
        ["Feature", "Type 1 DM", "Type 2 DM"],
        [
            ["Pathophysiology", "Autoimmune destruction of beta cells → absolute insulin deficiency", "Insulin resistance + relative beta cell failure"],
            ["Age of onset", "Usually <30 years (peak childhood)", "Usually >40 years (now increasingly younger)"],
            ["Body habitus", "Thin / normal BMI", "Obese (typically)"],
            ["Autoantibodies", "Anti-GAD, anti-IA2, anti-islet", "Absent"],
            ["C-peptide", "Very low / absent", "Normal or high initially"],
            ["Insulin needed", "Always (absolute requirement)", "May not require initially"],
            ["Acute complication", "Diabetic Ketoacidosis (DKA)", "Hyperosmolar Hyperglycaemic State (HHS)"],
            ["Ketosis", "Yes (no insulin → unrestrained lipolysis)", "No (residual insulin suppresses lipolysis)"],
            ["HLA association", "HLA-DR3, DR4", "Not HLA-associated"],
        ],
        styles, [4.5*cm, 6.3*cm, 6.2*cm]
    ))
    els.append(sp(2))

    # Insulin biosynthesis quick ref
    els.append(Paragraph("Insulin Biosynthesis — Quick Reference", styles["h_section"]))
    els.append(make_table(
        ["Fact", "Answer"],
        [
            ["Insulin gene chromosome", "Short arm of chromosome 11"],
            ["Initial translation product", "Preproinsulin (110 amino acids)"],
            ["After signal peptide cleavage", "Proinsulin (86 amino acids)"],
            ["Mature insulin size", "51 amino acids (A-chain 21 + B-chain 30)"],
            ["Number of disulfide bonds", "3 (2 interchain A-B + 1 intrachain in A chain)"],
            ["Co-secreted with insulin", "C-peptide (31 aa) in 1:1 molar ratio"],
            ["C-peptide clinical use", "Measures endogenous insulin secretion"],
            ["Beta cell glucose sensor enzyme", "Glucokinase (hexokinase IV)"],
            ["Channel closed by ATP in beta cell", "K_ATP channel (SUR1 + Kir6.2 subunits)"],
            ["Sulfonylurea binding site", "SUR1 subunit of K_ATP channel"],
            ["Insulin-dependent glucose transporter", "GLUT4 (in muscle and adipose)"],
            ["Constitutive glucose transporters", "GLUT1 (brain/RBC), GLUT2 (liver/beta cell), GLUT3 (neurons)"],
        ],
        styles, [7*cm, 10*cm]
    ))
    els.append(sp(2))

    # Ketone bodies table
    els.append(Paragraph("Ketone Bodies — Key Facts", styles["h_section"]))
    els.append(make_table(
        ["Ketone Body", "Formation", "Smell", "Detected By"],
        [
            ["Acetoacetate", "First formed — from HMG-CoA cleavage", "Slightly fruity", "Nitroprusside (Ketostix) — detects this"],
            ["Beta-hydroxybutyrate", "Reduction of acetoacetate (NADH-dependent)", "None", "NOT detected by Ketostix! Specific assay needed"],
            ["Acetone", "Spontaneous decarboxylation of acetoacetate", "Fruity / pear drops", "Exhaled in breath; Ketostix weakly positive"],
        ],
        styles, [4.5*cm, 5*cm, 3*cm, 4.5*cm]
    ))
    els.append(sp(1))
    els.append(info_box(
        "<b>Exam trap:</b> In severe DKA, beta-hydroxybutyrate may predominate over acetoacetate "
        "(because NADH is high, driving the equilibrium). Ketostix (nitroprusside) tests only detect "
        "acetoacetate — so severe DKA may appear 'ketone-negative' on dipstick. "
        "Always measure serum beta-hydroxybutyrate directly.",
        C_LIGHT_RED, C_RED, styles))
    els.append(sp(2))

    # HbA1c
    els.append(Paragraph("HbA1c — Diagnostic Reference", styles["h_section"]))
    els.append(make_table(
        ["HbA1c %", "mmol/mol", "Meaning", "Estimated Average Glucose (eAG)"],
        [
            ["<5.7%", "<39", "Normal", "<117 mg/dL"],
            ["5.7–6.4%", "39–46", "Prediabetes", "117–137 mg/dL"],
            ["6.5%", "48", "Diabetes (diagnostic cut-off)", "140 mg/dL"],
            ["7.0%", "53", "Target (most T2DM)", "154 mg/dL"],
            ["8.0%", "64", "Poor control — intensify", "183 mg/dL"],
            ["10.0%", "86", "Very poor control", "240 mg/dL"],
        ],
        styles, [3*cm, 3.5*cm, 5.5*cm, 5*cm]
    ))
    els.append(sp(1))
    els.append(Paragraph(
        "eAG formula: eAG (mg/dL) = (28.7 × HbA1c%) − 46.7",
        styles["body_bold"]))
    els.append(sp(2))

    # Sources footer
    els.append(hr(C_DARK_BLUE, 1))
    els.append(Paragraph("Primary Sources", styles["h_sub"]))
    sources = [
        "Harrison's Principles of Internal Medicine, 22nd Ed. (2025, McGraw-Hill) — Bilirubin metabolism, Insulin biosynthesis/secretion",
        "Goldman-Cecil Medicine, International Ed. — Jaundice diagnosis, DKA clinical features and management",
        "Schwartz's Principles of Surgery, 11th Ed. — Surgical jaundice, biliary obstruction",
        "Harper's Illustrated Biochemistry, 32nd Ed. — Liver function tests, aminotransferases",
        "Tietz Textbook of Laboratory Medicine, 7th Ed. — Ketogenesis, HbA1c, diabetes diagnosis",
        "Medical Physiology (Boron & Boulpaep) — Beta-cell physiology, insulin synthesis, GLUT transporters",
    ]
    for s in sources:
        els.append(Paragraph(f"• {s}", styles["source"]))

    return els


# ── Main build ────────────────────────────────────────────────────────────────
def build_pdf():
    os.makedirs(os.path.dirname(OUTPUT_PATH), exist_ok=True)

    doc = SimpleDocTemplate(
        OUTPUT_PATH,
        pagesize=A4,
        leftMargin=2*cm, rightMargin=2*cm,
        topMargin=2.2*cm, bottomMargin=2.2*cm,
        title="MBBS Clinical Cases Study Guide — Jaundice & Diabetes",
        author="Orris Medical Study Guide",
        subject="Biochemistry | Jaundice | Diabetes | MBBS",
    )

    styles = build_styles()

    story = []
    story += build_cover(styles)
    story += section_3rd_year(styles)
    story += section_1st_2nd_year(styles)
    story += section_quick_reference(styles)

    doc.build(story, onFirstPage=on_page, onLaterPages=on_page)
    print(f"PDF created: {OUTPUT_PATH}")

if __name__ == "__main__":
    build_pdf()
Running Command

cd /home/daytona/workspace/mbbs-cases && python3 generate_pdf.py 2>&1

Running Command

cd /home/daytona/workspace/mbbs-cases && grep -n "quote_box(" generate_pdf.py | head -30

Running Command

cd /home/daytona/workspace/mbbs-cases && sed -i 's/quote_box(\n/quote_box(/g' generate_pdf.py; python3 -c " import re with open('generate_pdf.py','r') as f: content = f.read() # Fix all quote_box calls - they need styles as 3rd arg # Pattern: quote_box(\"...\", \"...\") -> quote_box(\"...\", \"...\", styles) # The calls all end with 'Ed.\"' or similar followed by newlines and )) # Let's use a different approach - find all quote_box calls and add styles # Replace: quote_box(\n text,\n source\n)) -> quote_box(\n text,\n source,\n styles\n)) content = re.sub( r'quote_box\(([\s\S]*?)(\"[^\"]*\")\s*\n(\s*)\)', lambda m: 'quote_box(' + m.group(1) + m.group(2) + ',\n' + m.group(3) + 'styles\n' + m.group(3) + ')', content ) with open('generate_pdf.py','w') as f: f.write(content) print('done') "

Running Command

cd /home/daytona/workspace/mbbs-cases && python3 generate_pdf.py 2>&1

Running Command

cd /home/daytona/workspace/mbbs-cases && python3 -c " with open('generate_pdf.py','r') as f: content = f.read() # Make all helper functions use a global 'g_styles' instead of parameter # Simpler fix: just make styles a default parameter = None and use global # Replace function signatures to use default replacements = [ ('def quote_box(text, source, styles):', 'def quote_box(text, source, styles=None):'), ('def pathway_box(lines, styles):', 'def pathway_box(lines, styles=None):'), ('def info_box(text, bg_color, border_color, styles, label=None):', 'def info_box(text, bg_color, border_color, styles=None, label=None):'), ('def case_banner(text, color, styles):', 'def case_banner(text, color, styles=None):'), ('def part_banner(text, color, styles):', 'def part_banner(text, color, styles=None):'), ('def make_table(headers, rows, styles, col_widths=None, header_color=None):', 'def make_table(headers, rows, styles=None, col_widths=None, header_color=None):'), ] for old, new in replacements: content = content.replace(old, new) # Add global fallback at top of each helper # Actually simpler: add 'if styles is None: styles = _G_STYLES' and set _G_STYLES in build_pdf # Insert global var after build_styles function insert_after = 'def build_pdf():' insert_code = ''' def build_pdf(): global _G_STYLES ''' content = content.replace('def build_pdf():\n', insert_code) # Add _G_STYLES init after styles = build_styles() content = content.replace(' styles = build_styles()\n', ' styles = build_styles()\n global _G_STYLES\n _G_STYLES = styles\n') # Add fallback in each helper for func_name in ['quote_box', 'pathway_box', 'info_box', 'case_banner', 'part_banner', 'make_table']: # Find first line after def and add fallback pass # Simpler approach: just add 'if styles is None: styles = _G_STYLES' at start of each fallback = ' if styles is None: styles = _G_STYLES\n' for func in [ 'def quote_box(text, source, styles=None):\n', 'def pathway_box(lines, styles=None):\n', 'def info_box(text, bg_color, border_color, styles=None, label=None):\n', 'def case_banner(text, color, styles=None):\n', 'def part_banner(text, color, styles=None):\n', 'def make_table(headers, rows, styles=None, col_widths=None, header_color=None):\n', ]: content = content.replace(func, func + fallback) # Add _G_STYLES declaration at module level (after imports) content = content.replace( '# ── Colour palette', '_G_STYLES = None # Set in build_pdf\n\n# ── Colour palette' ) with open('generate_pdf.py','w') as f: f.write(content) print('done') "

Running Command

cd /home/daytona/workspace/mbbs-cases && python3 generate_pdf.py 2>&1

Running Command

ls -lh /home/daytona/workspace/mbbs-cases/MBBS_ClinicalCases_Jaundice_Diabetes.pdf

Your PDF study guide is ready!

MBBS ClinicalCases Jaundice Diabetes

PDF Document · PDF


Here's what's inside the PDF (professionally formatted with colour-coded sections, tables, pathway boxes, and textbook quotes):
Cover Page + Contents Table
Part 1 — 3rd Year MBBS: Clinical Cases
  • Case J1: Prehepatic Jaundice (Autoimmune Haemolytic Anaemia)
  • Case J2: Hepatocellular Jaundice (Acute Viral Hepatitis A)
  • Case J3: Obstructive Jaundice (Carcinoma Head of Pancreas) — Courvoisier's sign
  • Case J4: Gilbert's Syndrome
  • Case D1: Type 1 DM / DKA — new onset with full DKA severity criteria table
  • Case D2: Type 2 DM — incidental detection, metabolic syndrome
  • Case D3: HHS vs DKA full comparison table
  • Case D4: Drug-induced liver injury in a diabetic
  • Case D5: Metformin-associated lactic acidosis
Part 2 — 1st & 2nd Year MBBS: Biochemistry Deep Dives
  • Full bilirubin pathway with stepwise reaction boxes (heme oxygenase → UGT1A1 → MRP2 → gut)
  • Neonatal jaundice and kernicterus mechanism
  • Why pale stools, dark urine, and pruritus in obstruction — with pathway diagram
  • Insulin biosynthesis: preproinsulin → proinsulin → insulin (gene to granule)
  • Beta-cell K_ATP channel cascade and sulfonylurea mechanism of action
  • DKA ketone body formation pathway (HMG-CoA pathway, OAA depletion explained)
  • HbA1c: Schiff base → Amadori product, with causes of false results
Part 3 — Quick Reference Tables
  • Master jaundice comparison (prehepatic/hepatocellular/posthepatic)
  • Bilirubin enzyme defects table (Gilbert's, Crigler-Najjar, Dubin-Johnson)
  • Type 1 vs Type 2 DM comparison
  • Ketone bodies reference with the Ketostix exam trap
  • HbA1c diagnostic ranges with eAG formula
This is a shared conversation. Sign in to Orris to start your own chat.