This is for medicine posting. I am 2nd year MBBS Student Can you tell me the significance of asking these things for medicine history taking with definition and what things to rule out. You can take long time to collect the information

Reading File
Running Command

cd /tmp/workspace/attachments/d674b850-1b3c-4cd5-a4fb-32ebcf3bfe0d/ && python3 -c " import pdfplumber with pdfplumber.open('PDF.pdf') as pdf: for i, page in enumerate(pdf.pages): text = page.extract_text() print(f'=== PAGE {i+1} ===') print(text) print() "

Reading File
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Finding Sources
Here is the complete, detailed explanation for your medicine posting proforma. I have covered all four systems - GIT, CNS, Respiratory, and CVS - with definitions, clinical significance, and what conditions each question helps rule out.

Medicine History Taking - Significance, Definitions & Differential Diagnoses

How to use this guide

For each symptom you ask about:
  • Definition = what exactly is the symptom
  • Why you ask it = clinical significance
  • What to rule out = the differential diagnoses your question is narrowing down

SYSTEM 1: GASTROINTESTINAL SYSTEM


CHIEF COMPLAINTS

1. Abdominal Pain

Definition: Subjective sensation of discomfort or distress in the abdomen due to stimulation of pain receptors in the abdominal viscera, parietal peritoneum, or referred from extra-abdominal sources.
Why you ask these sub-questions:
Sub-questionSignificance
SiteVisceral pain is poorly localised; parietal pain is well localised. Site points to the organ involved
TypeColicky = hollow viscus obstruction (bowel, biliary, ureteric); Burning = peptic ulcer; Constant dull = solid organ capsule stretch
OnsetSudden = perforation, torsion, vascular event; Gradual = inflammatory, neoplastic
RadiationBiliary colic → right shoulder; Pancreatitis → back; Renal colic → groin
Aggravating/RelievingEating relieves duodenal ulcer; worsens gastric ulcer; fatty food worsens biliary colic
EpisodesRecurrent episodic = peptic ulcer, biliary colic, irritable bowel
What to rule out:
  • Peptic ulcer disease (PUD) - epigastric, burning, meal-related
  • Acute appendicitis - starts periumbilical, shifts to RIF, McBurney's point
  • Biliary colic / acute cholecystitis - RUQ, post-fatty meal, Murphy's sign
  • Pancreatitis - epigastric, radiates to back, band-like, alcohol/gallstone history
  • Intestinal obstruction - central colicky + distension + vomiting + constipation
  • Renal/ureteric colic - flank to groin, haematuria
  • Mesenteric ischemia - post-prandial, severe, out of proportion to examination
  • Aortic aneurysm - pulsatile mass, tearing pain
  • Referred pain from MI, lower lobe pneumonia, diabetic ketoacidosis

2. Abdominal Distension

Definition: Increase in the abdominal girth beyond normal, perceived subjectively by the patient as bloating or visible protrusion of the abdomen.
Why you ask:
  • The classic teaching mnemonic is 5 Fs: Fat, Fluid (ascites), Flatus, Faeces, Foetus
  • Associated pain helps differentiate inflammatory vs. non-inflammatory cause
  • Urine output: decreased output with distension → hepatic/cardiac/nephrotic ascites affecting kidney perfusion
  • Pedal oedema + distension → systemic disease (cardiac, hepatic, renal, nutritional)
  • Puffiness of face → nephrotic syndrome (early morning, periorbital)
What to rule out:
  • Ascites (cirrhosis, malignancy, cardiac failure, nephrotic syndrome, TB peritonitis)
  • Intestinal obstruction / ileus (absent bowel sounds, distension, pain)
  • Obesity
  • Pregnancy (always ask in females of reproductive age - CRITICAL before examination)
  • Ovarian cyst / uterine fibroid (central/lower abdomen)
  • Retroperitoneal mass
  • Organomegaly (hepatosplenomegaly)

3. Abdominal Lump

Definition: A palpable mass felt within the abdominal cavity or abdominal wall, distinct from normal abdominal organs.
Why you ask:
  • Site tells you the quadrant and therefore the likely organ of origin
  • Duration and progression: rapid growth = malignancy / abscess; slow chronic = cyst, benign tumour
  • Associated pain: inflammatory lumps (appendicular mass, amoebic abscess) are tender; malignant masses may be non-tender until late
  • Skin over lump: redness = abscess; tethering/peau d'orange = malignancy
What to rule out:
  • Hepatomegaly (RUQ - moves with respiration, cannot get above it)
  • Splenomegaly (LUQ - notched edge, moves to RIF, cannot palpate between it and costal margin)
  • Renal mass (bimanually palpable, ballotable, band of colonic resonance in front)
  • Mesenteric/omental cyst (central, mobile, resonant all around)
  • Retroperitoneal sarcoma (fixed, deep)
  • Ovarian cyst / carcinoma (lower abdomen, female)
  • Colorectal carcinoma (along colon distribution)
  • Appendicular mass / amoebic liver abscess
  • Lymph node mass (para-aortic)

4. Dysphagia

Definition: Difficulty in swallowing - the sensation that food or liquid sticks or passes abnormally during the act of swallowing.
Distinguish from:
  • Odynophagia = painful swallowing (different from difficulty)
  • Globus = constant sensation of a lump in the throat without actual swallowing difficulty
Why you ask:
  • Solids only initially, then progressing to liquids = mechanical (structural/obstructive) cause - carcinoma oesophagus, stricture, web
  • Solids AND liquids from the start = motility disorder (achalasia cardia, diffuse oesophageal spasm)
  • Progression (getting worse) = malignancy (carcinoma oesophagus - progressive dysphagia is hallmark)
  • Fluctuating = motility disorder, peptic stricture
What to rule out:
  • Carcinoma oesophagus (progressive, solids → liquids, weight loss, elderly)
  • Achalasia cardia (liquids and solids, regurgitation of undigested food, young adult)
  • Peptic stricture (history of GERD, heartburn)
  • Pharyngeal pouch / Zenker's diverticulum (regurgitation of undigested food, gurgling neck swelling)
  • Plummer-Vinson syndrome (iron deficiency anaemia, post-cricoid web, middle-aged women)
  • External compression by lymph nodes, mediastinal tumour, aortic aneurysm
  • Bulbar/pseudobulbar palsy (neurological - nasal regurgitation, dysarthria)

5. Flatulence

Definition: The presence and passage of excessive gas in the gastrointestinal tract, manifested as belching (eructation) or passing flatus per rectum.
Why you ask:
  • History of belching + bloating after certain foods → malabsorption / food intolerance
  • Diarrhoea + flatulence → lactase deficiency, coeliac disease, Giardiasis
  • Intestinal parasites → Giardia lamblia causes profound flatulence and steatorrhoea
  • Food allergy history → specific food trigger (lactose, gluten, fructose)
What to rule out:
  • Aerophagia (excessive air swallowing - anxiety, eating fast)
  • Irritable Bowel Syndrome (IBS)
  • Lactose intolerance (flatulence + diarrhoea after dairy)
  • Coeliac disease (gluten sensitivity - steatorrhoea, malabsorption)
  • Giardiasis (frothy, foul-smelling diarrhoea + flatulence, travel history)
  • Intestinal malabsorption syndromes

6. Vomiting / Nausea

Definition:
  • Nausea = subjective unpleasant sensation of an urge to vomit, without actual expulsion
  • Vomiting (emesis) = forceful expulsion of gastric contents through the mouth due to contraction of abdominal muscles and diaphragm with relaxation of lower oesophageal sphincter
Why you ask:
  • Colour: Bilious (green/yellow) = post-pyloric obstruction; Non-bilious = gastric outlet/pyloric obstruction or proximal cause
  • Blood-stained = haematemesis (upper GI bleed - see below)
  • Foul smelling / faeculent = intestinal obstruction (distal small bowel / large bowel)
  • Food particles = gastric outlet obstruction (pyloric stenosis - food eaten 6-8 hrs ago)
  • Projectile = pyloric stenosis (especially in infants), raised intracranial pressure
  • Relation to meals: Immediately after = oesophageal (regurgitation rather than true vomit); 1-4 hrs = gastric ulcer; >6 hrs = gastric outlet obstruction
What to rule out:
  • Pyloric stenosis / gastric outlet obstruction (projectile, food, non-bilious, succussion splash)
  • Acute gastroenteritis (vomiting + diarrhoea, infectious)
  • Intestinal obstruction (feculent, abdominal distension)
  • Raised intracranial pressure (projectile, without nausea, headache)
  • Hepatitis / Pancreatitis
  • Drugs (opioids, digoxin, chemotherapy)
  • Metabolic causes (uraemia, Addison's disease, hypercalcaemia)
  • Pregnancy (morning, 1st trimester)

7. Haematemesis

Definition: Vomiting of blood originating from the upper gastrointestinal tract (proximal to the Ligament of Treitz). The blood may appear bright red (fresh, brisk bleed) or coffee-ground (altered by gastric acid).
Why you ask:
  • Colour: Bright red = active bleeding (varices, Mallory-Weiss); coffee-ground = slower bleed, blood altered by acid
  • Episodes and timing: Post-alcohol vomiting then haematemesis = Mallory-Weiss tear
  • Amount: Large volume = variceal bleed (life-threatening)
  • Previous similar: Recurrent = peptic ulcer, varices
What to rule out:
  • Peptic ulcer disease (most common cause - duodenal > gastric ulcer)
  • Oesophageal varices (portal hypertension, cirrhosis - massive bleed)
  • Mallory-Weiss tear (forceful vomiting/retching → laceration at gastro-oesophageal junction)
  • Oesophagitis / erosive gastritis (NSAIDs, alcohol)
  • Gastric carcinoma
  • Dieulafoy's lesion (large aberrant submucosal artery)
  • Aorto-enteric fistula (post-aortic surgery)
  • Haemobilia (blood in bile duct)

8. Diarrhoea

Definition: Increase in stool frequency (>3 stools/day), decrease in consistency, or increase in daily stool weight (>200 g/day).
Why you ask:
  • Consistency: Watery = secretory (cholera, ETEC) or osmotic; Semisolid with blood/mucus = inflammatory (dysentery, IBD, carcinoma)
  • Blood-stained: Fresh blood = large bowel cause (colitis, carcinoma); Mixed with stool = inflammatory bowel disease, carcinoma colon
  • Mucus: Mucus + blood = amoebic/bacillary dysentery, IBD
  • Tenesmus (painful straining to defecate with sense of incomplete evacuation) = rectal pathology (proctitis, carcinoma rectum)
  • Foul smelling + fatty (steatorrhoea) = malabsorption (pancreatic exocrine insufficiency, coeliac)
  • Episodes / timing: Nocturnal diarrhoea = organic cause (IBD, microscopic colitis) - rules out functional IBS (IBS does not cause nocturnal diarrhoea)
  • Duration: <2 weeks = acute infectious; >4 weeks = chronic - IBD, malabsorption, neoplasm
What to rule out:
  • Infective gastroenteritis (acute - Salmonella, Shigella, V. cholerae, Campylobacter)
  • Amoebic colitis (blood + mucus, tropical setting)
  • Inflammatory Bowel Disease - Crohn's disease / Ulcerative colitis (chronic, recurrent, blood in stool)
  • Coeliac disease (steatorrhoea, malabsorption)
  • Carcinoma colon / rectum (change in bowel habit, blood, older age)
  • IBS (functional - no nocturnal diarrhoea, no blood, stress-related)
  • Lactose intolerance
  • Hyperthyroidism
  • Drugs (antibiotics causing C. difficile colitis)

9. Melaena

Definition: Passage of black, tarry, foul-smelling stools due to degradation of blood by intestinal bacteria and enzymes. Indicates bleeding from the upper GI tract (as little as 50-100 mL of blood from stomach/duodenum). Blood turns black due to conversion of haemoglobin to haematin by gastric acid and bacterial action.
Why you ask:
  • Sticking to pan: Melaena stools are sticky, tarry - distinguishes from dark stools due to iron/bismuth
  • Associated straining: Haematochezia (bright red per rectum) from lower GI bleed vs. melaena from upper GI
  • Duration: Active ongoing = urgent, needs endoscopy
  • False melaena: Iron tablets, bismuth, activated charcoal, beetroot (dark but NOT tarry/foul-smelling)
What to rule out:
  • Peptic ulcer (most common source)
  • Oesophageal/gastric varices
  • Gastric carcinoma
  • Aorto-enteric fistula
  • Small bowel bleed (Meckel's diverticulum, small bowel tumour)
  • A very slow right-sided colonic bleed can rarely cause melaena

10. Jaundice

Definition: Yellow discolouration of the skin, sclerae, and mucous membranes due to deposition of bilirubin in tissues when serum bilirubin exceeds 2-3 mg/dL (clinical jaundice). Subclinical jaundice begins at >1 mg/dL.
Three types to differentiate:
  • Pre-hepatic (haemolytic): Excess RBC breakdown → unconjugated bilirubin
  • Hepatic (hepatocellular): Liver cell damage → both fractions raised
  • Post-hepatic (obstructive/cholestatic): Bile duct obstruction → conjugated bilirubin regurgitates into blood
Why you ask:
  • Onset: Sudden = gallstone obstruction or acute hepatitis; Gradual = malignancy, chronic liver disease
  • Colour of urine: Dark urine (conjugated bilirubin, water-soluble, bilirubinuria) = hepatic/post-hepatic
  • Colour of stools: Pale/clay-coloured stools = obstructive (bile not reaching gut); Normal stool colour = haemolytic
  • Pruritus: Bile salts deposited in skin - seen in obstructive jaundice
  • Fever + jaundice: Hepatitis (viral, alcoholic), ascending cholangitis (Charcot's triad: jaundice + fever + RUQ pain)
  • Pain: Painful jaundice = biliary colic / cholangitis; Painless jaundice = malignancy (Ca head of pancreas - Courvoisier's sign)
  • Weight loss: Malignancy
What to rule out:
  • Viral hepatitis (A, B, C, E) - fever, prodrome, tender hepatomegaly
  • Alcoholic hepatitis
  • Drug-induced liver injury (DILI)
  • Haemolytic anaemia (pre-hepatic - no bilirubinuria, urine is normal or dark with urobilinogen)
  • Choledocholithiasis (biliary colic, fever - Charcot's triad)
  • Carcinoma head of pancreas (painless, progressive, Courvoisier's law)
  • Cholangiocarcinoma
  • Primary biliary cholangitis (middle-aged women, pruritus, ALP raised)
  • Autoimmune hepatitis
  • Wilson's disease (young patient, KF rings on slit-lamp - hence your proforma asks for Fundus/KF ring examination)

11. Fever (in GI context)

Definition: Core body temperature above 37.5°C (oral) or 38°C (rectal), representing a regulated elevation in the thermoregulatory set point, usually driven by pyrogens (endogenous: IL-1, IL-6, TNF; exogenous: LPS).
Why you ask:
  • Pattern: Continuous (typhoid, lobar pneumonia), Remittent (drops but not to normal - viral fever), Intermittent (swings to normal - malaria, UTI), Hectic/Septic (large swings - abscess), Pel-Ebstein (HL - periodic), Saddle-back (dengue)
  • Chills and rigors: Bacteraemia, malaria, pyelonephritis, cholangitis
  • Night sweats: TB (characteristic), lymphoma, HIV, chronic brucellosis
  • Grade: Low-grade prolonged = TB, malignancy, autoimmune; High-grade spiking = abscess, cholangitis
What to rule out:
  • Amoebic/pyogenic liver abscess (fever + RUQ pain + hepatomegaly)
  • Infective endocarditis (persistent fever, heart murmur, embolic phenomena)
  • Typhoid fever (step-ladder fever, relative bradycardia, rose spots)
  • Malaria (intermittent fever, cyclical chills)
  • TB (low-grade, evening rise, night sweats)
  • Lymphoma (Pel-Ebstein fever pattern in Hodgkin's)
  • Cholangitis (Charcot's triad)
  • Intra-abdominal abscess

12. Oedema (in GI context)

Definition: Abnormal accumulation of interstitial fluid in the tissue spaces, resulting in swelling. Classified as pitting (serum proteins normal, mainly due to hydrostatic forces) vs. non-pitting (lymphoedema, myxoedema - proteins deposit in interstitium).
Why you ask:
  • Site: Periorbital (morning, early nephrotic); Bilateral pedal (cardiac, hepatic, nephrotic, hypoalbuminaemic); Unilateral (local - DVT, lymphatic)
  • Pitting vs. non-pitting: Pitting = protein-related, hydrostatic; Non-pitting = lymphoedema, myxoedema
  • Time variation: Worse in evening = cardiac/venous; Worse in morning = renal
  • Associated ascites: Hepatic cause (pre-hepatic portal hypertension); Cardiac (right heart failure); Nephrotic
  • Oliguria: Nephrotic/nephritic syndrome - fluid retained, less urine output
What to rule out:
  • Right-sided heart failure (JVP raised, hepatomegaly, bilateral dependent oedema)
  • Nephrotic syndrome (massive proteinuria >3.5g/day, hypoalbuminaemia, pitting oedema)
  • Liver cirrhosis (hypoalbuminaemia, portal hypertension - ascites + oedema)
  • Hypoalbuminaemia from any cause (malnutrition, malabsorption, protein-losing enteropathy)
  • Chronic venous insufficiency (venous oedema - unilateral or bilateral lower limbs)
  • Lymphoedema (non-pitting, skin changes)
  • Hypothyroidism/myxoedema (non-pitting, periorbital)

13. Oliguria

Definition: Urine output less than 400 mL/day (or <0.5 mL/kg/hour) in adults. Anuria = <100 mL/day.
Why you ask in GI history:
  • Upper GI bleed → haemorrhagic shock → pre-renal oliguria
  • Cirrhosis + ascites → hepatorenal syndrome (oliguria with normal tubules)
  • Jaundice → bile cast nephropathy
  • Peritonitis/sepsis → acute kidney injury
  • Urine colour (dark = bilirubinuria in obstructive jaundice; cola/tea-coloured = acute glomerulonephritis; haematuria = renal cause)
What to rule out:
  • Hepatorenal syndrome (cirrhosis + ascites + oliguria with low urine Na <10)
  • Pre-renal AKI (dehydration, blood loss, third spacing)
  • Acute tubular necrosis (ATN - from ischaemia or nephrotoxin)
  • Obstructive uropathy (post-renal)

14. Burning Sensation (Heartburn)

Definition: Retrosternal burning discomfort that typically radiates from the epigastrium upward toward the throat, caused by reflux of acidic gastric contents into the oesophagus.
Distinguish from:
  • Chest pain of cardiac origin (though GERD can closely mimic angina)
  • Dysphagia
Why you ask:
  • Post-meal worsening, lying flat, bending forward → GERD/hiatus hernia
  • Relieved by antacids → acid-peptic disease
  • Aggravated by spicy food, caffeine, NSAIDs
What to rule out:
  • GERD (Gastro-Oesophageal Reflux Disease)
  • Peptic ulcer disease
  • Hiatus hernia
  • Non-cardiac chest pain
  • Eosinophilic oesophagitis
  • Barrett's oesophagus (complication of chronic GERD - pre-malignant)

PAST HISTORY (GI System)

Item AskedSignificance
H/O TBTB can cause intestinal TB (ileocaecal most common), TB peritonitis, mesenteric lymphadenopathy - mimics Crohn's disease
H/O DMDiabetic gastroparesis (vomiting, bloating), increased susceptibility to infections, NAFLD
H/O HTNMesenteric ischaemia, increased cardiovascular risk; ACE inhibitors can cause diarrhoea
H/O JaundicePrevious hepatitis B/C → chronic liver disease/cirrhosis; Gallstone disease recurrence
H/O Bronchial AsthmaASA/NSAIDs for asthma-related symptoms can cause peptic ulcers; Alpha-1 antitrypsin deficiency causes both emphysema and liver cirrhosis
H/O EpilepsyAntiepileptic drugs (valproate, carbamazepine) → hepatotoxicity, DILI
H/O Blood TransfusionRisk of Hepatitis B, Hepatitis C, HIV - all causing liver disease
H/O Drug IntakeNSAIDs → peptic ulcer, GI bleed; Antibiotics → C. difficile colitis; Steroids → peptic ulcer

PERSONAL HISTORY (GI System)

ItemSignificance
DietVegetarian deficiency (B12 → megaloblastic anaemia); High fat diet → gallstones, NAFLD; Low fibre → constipation, diverticular disease, colorectal cancer
Loss of weight and appetiteRed flag = malignancy (GI cancer, lymphoma); also TB, hyperthyroidism, uncontrolled DM
Bowel and bladder habitsBaseline normal → to compare current change; Change in bowel habits in >40yr = colorectal carcinoma till proven otherwise
Sleep disturbancesNocturnal symptoms (diarrhoea, pain) = organic > functional; Symptoms only in day = may be functional
SmokingIncreases risk of peptic ulcer (decreases prostaglandin), gastric cancer, IBD (paradoxically protective against UC but worsens Crohn's)
AlcoholAlcoholic hepatitis, cirrhosis, pancreatitis, varices, Mallory-Weiss tear, thiamine deficiency (Wernicke's)
Exposure to endemic areasAmoebic liver abscess, hepatitis A/E (faeco-oral), typhoid, echinococcal cyst

SYSTEM 2: CNS


HISTORY OF PRESENTING ILLNESS

1. Weakness

Definition: Reduction in muscle power/force generation below the expected normal for the patient's age and sex. Distinguish from fatigue (normal power but patient tires quickly) and apraxia (inability to perform a learned motor task despite intact power).
Trunk muscle weakness (rolling over in bed, getting up):
  • Tests axial/truncal muscles
  • Rules out: Muscular dystrophy (Duchenne - unable to rise from floor), Polymyositis/Dermatomyositis (proximal > distal), Myasthenia gravis (fatigable weakness), Spinal cord lesion
Proximal vs. Distal pattern:
PatternTypical Causes
Proximal weakness (combing hair, squatting)Myopathy (muscular dystrophy, polymyositis, steroid myopathy, thyroid myopathy)
Distal weakness (buttoning, gripping chappals)Peripheral neuropathy (polyneuropathy - diabetes, GBS, CMT disease)
Proximal + DistalALS (amyotrophic lateral sclerosis), mixed neuropathy
Upper vs. Lower limb involvement:
  • Both UL and LL = quadriplegia → lesion at cervical cord or bilateral cortex
  • Both LL only = paraplegia → thoracic cord or bilateral cortex
  • One side (hemi) = hemiplegia → contralateral hemisphere or internal capsule
  • Single limb = monoplegia → cortical, peripheral nerve
What to rule out:
  • Stroke / TIA (sudden onset, UMN signs)
  • Spinal cord compression (band-like sensation, bladder symptoms, UMN below, LMN at level)
  • Peripheral neuropathy (GBS - ascending, areflexia; Diabetic; CMT)
  • Myasthenia gravis (fatigable, ocular involvement)
  • Muscular dystrophies
  • Motor neurone disease / ALS (both UMN + LMN signs simultaneously)
  • Hypokalemic periodic paralysis (episodic, after carbohydrate-heavy meals)
  • Multiple sclerosis (young, relapsing-remitting, demyelinating)

2. Associated Symptoms of Weakness

Stiffening of limbs (spasticity): Velocity-dependent increase in muscle tone with a clasp-knife quality. Indicates UMN (upper motor neuron) lesion - pyramidal tract involvement above the anterior horn cell. Rules out: stroke, spinal cord disease, MS, CP.
Giving away: Sudden loss of power during an action - can be due to pain inhibition (not true weakness) or fatigue (myasthenia).
Involuntary movements:
  • Fasciculations = spontaneous contraction of a motor unit, visible under skin; indicates LMN (lower motor neuron) disease or denervation - MND, radiculopathy
  • Twitching = brief muscle contractions - may be benign or indicate LMN disease
  • Tremors = rhythmic, oscillatory movement of a body part:
    • Resting tremor (pill-rolling, 4-6 Hz, suppressed by action) = Parkinson's disease
    • Action tremor (present during voluntary movement) = essential tremor, cerebellar
    • Intention tremor (worse on approaching target) = cerebellar disease
    • Postural tremor = enhanced physiological, drug-induced, hyperthyroidism

3. Cranial Nerve Symptoms

Why asked individually: Each cranial nerve tests a specific anatomical level of the brain. By mapping which cranial nerves are affected, you locate the lesion precisely.
CNSymptom askedSignificance and what it rules out
I (Olfactory)Disturbance of smellAnosmia: anterior cranial fossa fracture, meningioma, Parkinson's (early), olfactory groove meningioma
II (Optic)Visual disturbanceOptic neuritis (MS - unilateral, pain on movement), retinal detachment, glaucoma, raised ICP (papilloedema - bilateral blurring), pituitary adenoma (bitemporal hemianopia)
III, IV, VIDiplopia, squint, ptosisOculomotor palsy (CN III - ptosis, dilated pupil, "down and out" eye): posterior communicating artery aneurysm, uncal herniation, DM; CN VI palsy: raised ICP (false localizing sign), pontine lesion; Myasthenia gravis (fatigable ptosis)
V (Trigeminal)Difficulty eating, facial sensory lossTrigeminal neuralgia (lancinating unilateral facial pain, trigger zones), acoustic neuroma (CPA angle tumour compresses V), pontine lesion, Wallenberg's syndrome
VII (Facial)Drooling, angle of mouth deviation, inability to close eye, taste lossUMN facial palsy (spares forehead - frontalis has bilateral cortical supply) = stroke; LMN facial palsy (entire face including forehead) = Bell's palsy (idiopathic, HSV), Ramsay Hunt syndrome (herpes zoster - painful ear vesicles), parotid tumour
VIII (Vestibulocochlear)Hearing loss, vertigo, tinnitusHearing loss + vertigo: Meniere's disease (episodic, tinnitus, low-frequency hearing loss, fullness in ear); Acoustic neuroma (unilateral sensorineural hearing loss); Labyrinthitis; Aminoglycoside toxicity (cochlear damage)
IX, X (Glossopharyngeal + Vagus)Nasal regurgitation, nasal twang speech, dysphagiaBulbar palsy (LMN - flaccid, nasal speech, absent gag) vs. Pseudobulbar palsy (UMN - spastic, brisk jaw jerk, emotional lability); Causes: MND, brainstem stroke, GBS, diphtheria
XI (Spinal Accessory)Difficulty turning head, shoulder weaknessNeck dissection surgery injury; posterior fossa tumour; C-spine pathology
XII (Hypoglossal)Difficulty making food bolus, dysarthriaTongue wasting/fasciculation = LMN (MND, medullary lesion); Tongue deviates to side of lesion (LMN) or opposite side (UMN)

4. Sensory Disturbance

Definition: Abnormal perception or absence of sensation including pain, temperature, touch, vibration, or joint position sense, due to lesions along the sensory pathway from peripheral receptors to the sensory cortex.
Patterns and their localization:
Pattern askedLocalization
Hemi-anaesthesia (one half of body)Contralateral thalamus or cortex (hemispheric/thalamic lesion - stroke, space-occupying lesion)
Glove and stockingPeripheral neuropathy (diabetes, alcohol, B12 deficiency, GBS) - length-dependent, distal
Dermatomal distribution (root pains)Nerve root compression (radiculopathy) - disc prolapse, HNP (herniated nucleus pulposus), spondylosis
Band-like sensation over torsoSpinal cord lesion at the corresponding dermatome - spinal cord compression, transverse myelitis
Wash basin attacks (sudden fall on washing face with cold water)Vertebrobasilar insufficiency or cervical spondylosis affecting vertebral arteries
Difficulty walking in dark (positive Romberg's)Posterior column disease (dorsal columns carry vibration + JPS) - Subacute combined degeneration (B12 deficiency), tabes dorsalis (neurosyphilis), Friedreich's ataxia
Type of sensory disturbance:
  • Paraesthesia = abnormal sensation (tingling, burning, "pins and needles") without stimulus
  • Anaesthesia = complete loss of sensation
  • Hypoaesthesia = reduced sensation
  • Hyperaesthesia = increased sensitivity
  • Allodynia = pain from a normally non-painful stimulus (neuropathic pain)

5. Cerebellar Symptoms

Definition: Symptoms arising from dysfunction of the cerebellum or its connections, characterized by incoordination (ataxia) rather than weakness.
Symptom askedClinical significance
Apraxia (in cerebellar context - dyspraxia)Inability to perform coordinated purposive movements
Difficulty taking food to mouthIntention tremor / dysmetria of UL - tested by finger-nose test
Difficulty buttoningDysdiadochokinesia (inability to perform rapid alternating movements)
Swaying while walking / reeling sensationCerebellar gait (wide-based, staggering, cannot tandem walk)
DANISH mnemonic for cerebellar signs: Dysdiadochokinesia, Ataxia, Nystagmus, Intention tremor, Scanning speech, Hypotonia
What to rule out:
  • Multiple sclerosis (young adult, relapsing-remitting)
  • Cerebellar stroke / haemorrhage (sudden onset)
  • Cerebellar tumour (space-occupying lesion, raised ICP)
  • Alcoholic cerebellar degeneration
  • Paraneoplastic cerebellar syndrome (lung, ovarian cancer)
  • Hypothyroidism (cerebellar ataxia)
  • Spinocerebellar ataxias (hereditary)
  • Phenytoin toxicity (cerebellar ataxia as side effect)

6. Sphincteric Disturbances

Definition: Dysfunction of voluntary or reflex control over the urinary bladder (detrusor + sphincter) or bowel (external anal sphincter) due to neurological lesions.
Bladder symptoms:
SymptomMechanismLesion
Retention / HesitancyDetrusor-sphincter dyssynergia, or UMN lesion causing spastic bladder initially presenting as retentionAcute spinal cord lesion (spinal shock), BPH (non-neurological in males)
Precipitancy / Urge incontinenceUninhibited detrusor contractionsUMN lesion (stroke, MS, spinal cord disease) - hyperreflexic bladder
Incontinence / dribblingOverflow incontinence (atonic bladder)LMN/cauda equina lesion - lost detrusor tone
Bowel sphincter:
  • Constipation = UMN or autonomic dysfunction
  • Incontinence = LMN / cauda equina lesion (key sign of cauda equina syndrome - emergency)
  • Cauda equina syndrome must be ruled out: saddle anaesthesia + bladder/bowel incontinence + bilateral leg weakness = surgical emergency
Sexual dysfunction:
  • Impotence / Retrograde ejaculation = autonomic neuropathy (DM), spinal cord lesion, S2-S4 level involvement

7. Features of Raised ICP

The question asks: fever, headache, vomiting, blurring of vision, loss of consciousness/altered sensorium.
Raised ICP signs: Headache (worst in morning, worse on bending/coughing/Valsalva), projectile vomiting (without nausea), papilloedema (blurring of vision), altered sensorium. Late: Cushing's triad (hypertension + bradycardia + irregular breathing).
What to rule out:
  • Meningitis / Encephalitis (fever + headache + neck stiffness)
  • Space-occupying lesion (brain tumour, abscess)
  • Subarachnoid haemorrhage (thunderclap headache - worst headache of life)
  • Hypertensive encephalopathy
  • Hydrocephalus
  • Venous sinus thrombosis

8. H/O Vaccinations / Exanthematous Fevers (ADEM)

ADEM = Acute Disseminated Encephalomyelitis - an immune-mediated demyelinating condition that occurs 2-4 weeks after a viral illness (measles, varicella, mumps, rubella) or vaccination. Single episode of multifocal demyelination.
Why asked: To differentiate from MS (which is relapsing). Measles, chickenpox, pertussis vaccines (older generation) were classic triggers.

PAST HISTORY (CNS System)

ItemSignificance
HTNMost common cause of stroke (haemorrhagic and ischaemic), vascular dementia, hypertensive encephalopathy
DMDiabetic peripheral neuropathy (glove-stocking), autonomic neuropathy, lacunar stroke, mononeuropathy multiplex
TBTB meningitis (most dangerous - thick exudate at base of brain, cranial nerve palsies, hydrocephalus), tuberculoma
HIVHIV encephalopathy, cryptococcal meningitis, PML (JC virus), cerebral toxoplasmosis, CNS lymphoma
NeurosyphilisTabes dorsalis (posterior column loss), GPI (general paresis of insane), meningovascular syphilis
Dog bite / Anti-rabies vaccinationRabies (hydrophobia, aerophobia, encephalitis) or post-vaccine ADEM
Malignancy / ChemotherapyBrain metastases (lung, breast, colon, melanoma most common), chemo-induced peripheral neuropathy (vincristine, cisplatin), radiation-induced CNS damage
TIATransient Ischaemic Attack = warning sign before full stroke; asks about previous focal neuro deficits <24 hours duration
EpilepsyDrug interactions; post-ictal weakness (Todd's paralysis mimics stroke)

SYSTEM 3: RESPIRATORY SYSTEM


1. Cough

Definition: A forceful expulsive manoeuvre consisting of deep inspiration, glottic closure, contraction of expiratory muscles, and sudden glottic opening to expel irritants or secretions from the airway. It is a protective reflex.
Why you ask:
Sub-questionSignificance
DurationAcute <3 weeks = viral URTI, pneumonia; Subacute 3-8 weeks = post-infectious, pertussis; Chronic >8 weeks = important - must investigate thoroughly
OnsetSudden = foreign body (especially in children), pulmonary embolism
CharacterBarking cough = croup (laryngotracheobronchitis, children), epiglottitis; Whooping cough = Bordetella pertussis (inspiratory whoop); Bovine cough (no explosive quality) = recurrent laryngeal nerve palsy
Productive or dryProductive = infection, bronchiectasis, lung abscess; Dry = ILD (interstitial lung disease), early malignancy, ACE inhibitor-induced (bradykinin accumulation - chronic dry cough in 5-20%)
Aggravating factorsLying flat (postnasal drip, GERD); Cold air (asthma); Exercise (asthma, cardiac)
Diurnal variationMorning cough + copious sputum = bronchiectasis, chronic bronchitis; Nocturnal cough = asthma, GERD, cardiac (pulmonary oedema)
Seasonal variationSeasonal worsening = asthma (allergen trigger), COPD exacerbations in winter
What to rule out (Chronic cough):
  • Asthma (commonest cause in non-smoker, reversible, wheeze)
  • GERD / aspiration (cough after meals, lying down)
  • Post-nasal drip syndrome (rhinosinusitis)
  • Pulmonary tuberculosis (low-grade fever, weight loss, night sweats, haemoptysis)
  • Lung carcinoma (>40 years, smoker, haemoptysis, progressive)
  • Chronic bronchitis / COPD (smoker, >2 years, productive morning cough)
  • Bronchiectasis (copious purulent sputum, 3-layered sputum standing)
  • ACE inhibitor-induced cough (drug history)
  • ILD / Pulmonary fibrosis (dry cough, progressive dyspnoea)
  • Cardiac failure (orthopnea, PND, pink frothy sputum)

2. Expectoration (Sputum)

Definition: Mucus, cells, and other material expelled from the tracheobronchial tree by coughing.
CharacterSignificance
QuantityCopious (>200 mL/day) = bronchiectasis, lung abscess
Colour: Yellow/greenInfection (neutrophils + bacteria - purulent) - pneumonia, acute exacerbation COPD
Colour: Rusty/blood-tingedPneumococcal pneumonia ("rusty sputum" - classic)
Colour: Pink frothyPulmonary oedema (cardiac failure)
Colour: Black/tarryCoal dust (anthracosis), smoke inhalation
Colour: Red currant jellyKlebsiella pneumonia
Smell: Foul/offensiveAnaerobic infection - lung abscess, empyema, aspiration pneumonia
Consistency: Three layers on standingBronchiectasis (frothy top, mucoid middle, purulent bottom)
Blood-stainedHaemoptysis (see below)
Postural variationBronchiectasis (sputum increases on lying down in certain positions, gravity-dependent drainage)

3. Haemoptysis

Definition: Expectoration of blood or blood-stained sputum from the respiratory tract below the larynx.
Must distinguish from:
  • Haematemesis (from GI tract - mixed with food, dark, acidic reaction)
  • Epistaxis (from nose - often posterior drip, visible from nose)
Why you ask:
  • Fresh blood vs. altered: Fresh = active bleed; Blood-streaked sputum = chronic (TB, carcinoma)
  • Massive haemoptysis (>200-600 mL/24 hrs) = emergency: causes - bronchiectasis (mycetoma), aspergilloma, TB, carcinoma
What to rule out:
  • Pulmonary tuberculosis (most common worldwide cause of haemoptysis)
  • Lung carcinoma (smoker, progressive, weight loss)
  • Bronchiectasis (recurrent, purulent sputum, digital clubbing)
  • Pulmonary embolism + infarction (haemoptysis + sudden dyspnoea + pleuritic chest pain)
  • Mitral stenosis (pulmonary venous hypertension - remember your CVS proforma)
  • Goodpasture's syndrome (haemoptysis + glomerulonephritis)
  • Wegener's granulomatosis (now GPA)
  • Aspergilloma (in old TB cavity)
  • Pneumonia (blood-stained sputum)

4. Breathlessness (Dyspnoea)

Definition: Subjective experience of breathing discomfort that consists of qualitatively distinct sensations varying in intensity, resulting from interactions among multiple physiological, psychological, social, and environmental factors.
Grading - MRC / NYHA: Your proforma mentions NYHA grading (used in CVS too). For respiratory: MRC dyspnoea scale (Grade 0-4 or 1-5) or modified MRC (mMRC) is used.
mMRC GradeDescription
0No dyspnoea except strenuous exercise
1Dyspnoea on hurrying or walking up a slope
2Walks slower than contemporaries or stops for breath after 15 min on flat
3Stops for breath after 100 m or a few minutes on flat
4Too breathless to leave house, on dressing/undressing
Types asked:
TermDefinitionCause
OrthopnoeaDyspnoea on lying flat, relieved by sitting up; quantify by number of pillowsLeft heart failure (LVF) - increased venous return when supine raises LVEDP; Also bilateral pleural effusion, diaphragmatic palsy
PND (Paroxysmal Nocturnal Dyspnoea)Sudden dyspnoea waking patient from sleep, 1-2 hrs after going to bed, relieved by sitting up/standingLVF (nocturnal fluid redistribution + reduced adrenergic tone)
PlatypnoeaDyspnoea worse on sitting up, relieved by lying down (opposite of orthopnoea)Hepatopulmonary syndrome (liver disease + intrapulmonary shunts), ASD (orthodeoxia), right-to-left shunts
TrepopnoeaDyspnoea on lying on one side onlyUnilateral pleural effusion, asymmetric lung disease
What to rule out:
  • Asthma (episodic, reversible, wheeze)
  • COPD (chronic, progressive, smoker)
  • Left ventricular failure (orthopnoea, PND, bilateral crepitations)
  • Pulmonary embolism (sudden, pleuritic chest pain)
  • Pneumothorax (sudden, unilateral, tall young male)
  • Pleural effusion
  • Anaemia (dyspnoea on exertion)
  • Pulmonary fibrosis/ILD (progressive, dry cough, fine basal crepitations)
  • Cor pulmonale

5. Chest Pain (Respiratory Context)

Definition: Pain in the chest wall or thoracic cavity that may originate from the pleura, chest wall (musculoskeletal), lungs, oesophagus, mediastinum, or referred from abdomen or spine.
Important distinction: The lung parenchyma has NO pain receptors. Pulmonary pain is always from the pleura (parietal pleura is well innervated).
TypeCharacterCause
PleuriticSharp, stabbing, unilateral, worsened by deep breathing, coughingPleuritis (pneumonia, TB, SLE), pulmonary embolism/infarction, pneumothorax
Dull constantHeavy, non-positionalMalignant pleural disease, rib metastases
Central burningRetrosternalTracheitis, oesophageal (GERD)
MusculoskeletalLocalised, worsened by movement/palpationCostochondritis (Tietze syndrome), rib fracture

6. Wheeze

Definition: A continuous musical sound produced during breathing (usually expiratory) due to narrowing of airways.
  • Expiratory wheeze = lower airway obstruction (asthma, COPD)
  • Inspiratory stridor = upper airway obstruction (laryngeal/tracheal - foreign body, epiglottitis, croup)
  • Polyphonic wheeze = multiple airway levels = asthma, COPD
  • Monophonic wheeze = single point of obstruction = carcinoma obstructing a bronchus, foreign body
Diurnal variation: Worse early morning and at night = asthma (circadian rhythm of cortisol + airway cooling) Seasonal variation: Spring/autumn = allergic asthma (pollen) Skin rash / allergy: Atopic triad = asthma + allergic rhinitis + eczema (IgE-mediated)
What to rule out:
  • Bronchial asthma
  • COPD with acute exacerbation
  • Endobronchial tumour
  • Foreign body inhalation
  • Cardiac asthma (cardiac failure causing bronchospasm)
  • Anaphylaxis

7. Fever (Respiratory)

Same principles as GIT fever above, but in respiratory context:
  • Fever + cough + rust-coloured sputum = lobar pneumonia (Streptococcus pneumoniae)
  • Fever + cough + night sweats + weight loss = TB
  • Fever + rigors + purulent sputum = bacterial pneumonia, lung abscess
  • Low-grade fever + dry cough = atypical pneumonia (Mycoplasma, Chlamydia, Legionella)
  • Seasonal fever pattern = Influenza (winter), atypical pneumonias

PAST HISTORY (Respiratory)

ItemSignificance
H/O TBOld TB cavities → aspergilloma, bronchiectasis, post-TB fibrosis, recurrence; Milliary TB
H/O Bronchial Asthma / AllergiesBaseline, severity, trigger identification, previous hospitalisations/ICU admissions
Recurrent RTI / Whooping Cough / MeaslesChildhood lung infections → bronchiectasis (post-measles, post-pertussis), Williams-Campbell syndrome
H/O Penicillin injectionsPenicillin allergy - anaphylaxis risk; treatment of RHD prophylaxis
ATT (Anti-TB Treatment)Previous TB treatment - compliance, drug resistance (MDR-TB), hepatotoxicity from ATT
ARTHIV - opportunistic infections (PCP, TB, CMV pneumonia, Kaposi sarcoma)

OCCUPATIONAL HISTORY (respiratory - highly important)

OccupationDisease
Mining (coal)Pneumoconiosis / CWP (Coal Worker's Pneumoconiosis)
Silica exposure (sand-blasting, quarrying, granite)Silicosis
Asbestos (shipbuilding, insulation)Asbestosis, Mesothelioma, pleural plaques
Farming (mouldy hay)Hypersensitivity Pneumonitis (Farmer's Lung - Thermophilic actinomycetes)
Animal husbandry (birds)Bird-Breeder's Lung (pigeon/budgerigar - HP), Psittacosis, Q fever
Cotton textileByssinosis
WelderSiderosis, manganism (neurological)
Why this matters: Occupational lung disease is a direct cause of dyspnoea, cough, fibrosis. The asking of Occupational History is a legal and clinical necessity.

SYSTEM 4: CARDIOVASCULAR SYSTEM


1. Chest Pain (CVS)

Definition: Same as above - but in CVS context, cardiac pain (ischaemic) is the primary concern.
Ischaemic chest pain (angina/MI) characteristics:
  • Site: Central/retrosternal
  • Type/Nature: Tight, crushing, heavy, like "elephant sitting on chest" (not sharp/stabbing)
  • Radiation: Left arm, jaw, back (aortic dissection - also radiation to back), shoulder, neck
  • Duration: Stable angina <20 min, relieved by rest/nitrates; MI >20 min, not relieved
  • Onset: Exertional (stable angina), rest (unstable angina/MI), at night (variant Prinzmetal angina)
  • Associated symptoms: Sweating (diaphoresis), nausea/vomiting, dyspnoea = classic MI presentation
  • Aggravating: Exercise, cold weather, emotional stress, heavy meals
Why you ask about sweating, nausea, vomiting, SOB: These are autonomic features of MI and help distinguish from non-cardiac chest pain.
What to rule out:
  • Stable angina (exertional, relieved by rest or nitrates within 5 min)
  • Unstable angina / NSTEMI / STEMI (at rest, >20 min, unrelieved by nitrates)
  • Aortic dissection (tearing pain, maximal at onset, radiates to back, unequal pulses, BP difference in both arms)
  • Pulmonary embolism (pleuritic, sudden onset, dyspnoea, haemoptysis)
  • Pericarditis (sharp, pleuritic, relieved by leaning forward, friction rub)
  • GERD/oesophageal spasm (can mimic angina, relieved by antacids)
  • Costochondritis (localised, reproducible on palpation)

2. Breathlessness - NYHA Classification

NYHA (New York Heart Association) Functional Classification of cardiac dyspnoea:
ClassDescription
Class INo symptoms during ordinary activity
Class IISlight limitation of physical activity; comfortable at rest; ordinary activity causes symptoms
Class IIIMarked limitation of physical activity; comfortable at rest; less-than-ordinary activity causes symptoms
Class IVSymptoms at rest; unable to carry on any activity without discomfort
Types specific to CVS:
  • Orthopnoea and PND = LVF (as above)
  • Platypnoea = hepatopulmonary syndrome, intracardiac shunts
  • Trepopnoea = unilateral pleural effusion from cardiac failure, pericardial effusion
What to rule out: LVF, dilated cardiomyopathy, mitral stenosis (with pulmonary hypertension), pericardial effusion, cor pulmonale.

3. Palpitations

Definition: Unpleasant awareness of one's own heartbeat, described as racing, pounding, fluttering, or skipping.
Character askedSignificance
Regular vs. IrregularRegular and fast = SVT, atrial flutter, sinus tachycardia; Irregular = atrial fibrillation (irregularly irregular), ectopics (regularly irregular)
At rest vs. exertionAt rest = arrhythmia (VT, SVT); Exertional = HOCM (outflow obstruction on exertion), anaemia, thyrotoxicosis
Associated SOBSuggests cardiac cause with haemodynamic compromise
Sudden start and stopSVT (AV nodal re-entrant tachycardia - AVNRT) - "paroxysmal"
What to rule out:
  • Atrial fibrillation (AF) - irregularly irregular, thromboembolic risk
  • SVT / AVNRT (young patients, vagal manoeuvres terminate)
  • Ventricular tachycardia (VT) - structural heart disease, can degenerate to VF
  • Thyrotoxicosis (sinus tachycardia, tremor, weight loss, exophthalmos)
  • Anaemia (high output state)
  • Anxiety / panic disorder
  • WPW syndrome (delta wave, short PR on ECG)
  • Ectopic beats (patient feels the compensatory pause as "missed beat")

4. Haemoptysis (CVS context)

In CVS, haemoptysis is specifically significant in Mitral Stenosis:
  • Pulmonary venous hypertension → dilated pulmonary veins → rupture
  • Three types: Haemoptysis from rupture of pulmonary venules (bright red), pink frothy from acute pulmonary oedema, rusty sputum from pulmonary infarction (RV failure + PE)
Also in: Pulmonary embolism (with infarction), Eisenmenger's syndrome (reversed shunt)

5. Syncope

Definition: Sudden, transient, complete loss of consciousness due to global cerebral hypoperfusion, with rapid onset, short duration, and spontaneous complete recovery.
Distinguish from:
  • Presyncope = near-faint without loss of consciousness
  • Seizure = LOC with tonic-clonic movements, post-ictal confusion, incontinence
  • Drop attack = falls without LOC
  • Cataplexy = narcolepsy
Relation to exertionSignificance
Exertional syncopeHOCM (hypertrophic obstructive cardiomyopathy), severe aortic stenosis, pulmonary hypertension - outflow obstruction worsens on exertion; RED FLAG - can be pre-VF
Post-exertionalPost-exercise vasodilation
Postural (orthostatic)Autonomic failure (DM, Parkinson's, MSA), hypovolaemia, drugs (antihypertensives)
SituationalCough syncope, micturition syncope, Valsalva
Reflex (vasovagal)Prodrome of nausea/sweating/pallor, triggered by pain/fear/emotional stress - benign
What to rule out:
  • HOCM (young athlete, exertional syncope, family history SCD - sudden cardiac death)
  • Severe aortic stenosis (exertional syncope, angina, dyspnoea - classic triad)
  • Complete heart block (Stokes-Adams attacks - sudden LOC without prodrome, patient appears dead briefly then recovers)
  • VT/VF
  • Vasovagal syncope (benign, most common cause of syncope overall)
  • Orthostatic hypotension (postural drop >20/10 mmHg)
  • Pulmonary hypertension
  • Arrhythmia (sick sinus syndrome, long QT syndrome)
  • Aortic dissection (syncope may be presenting feature)

6. Swelling of Feet / Dependent Oedema

Definition: Oedema that accumulates in dependent parts of the body (feet/ankles in ambulant patients, sacrum in bedridden) due to hydrostatic pressure effects of gravity.
Why the specific questions:
QuestionSignificance
Time of day variationCardiac/venous oedema: worse in evening (all-day dependency), better in morning (feet elevated during sleep); Renal: worse in morning (periorbital + pedal)
Bilateral vs. UnilateralBilateral = systemic (cardiac, hepatic, renal, hypoalbuminaemic); Unilateral = local (DVT, lymphoedema, cellulitis)
Pitting vs. Non-pittingPitting = low oncotic pressure (hypoalbuminaemia) or raised hydrostatic pressure; Non-pitting = lymphoedema (after cancer surgery), myxoedema (hypothyroidism)
Sacral oedemaSpecifically in CVS posting = right heart failure (RHF) - dependent oedema shifts to sacrum when patient is recumbent
OliguriaCardiac output falls → renal underperfusion → oliguria
Fatigue and right hypochondric painHepatic congestion from RHF → tender hepatomegaly (right hypochondric pain)
What to rule out:
  • Right heart failure / Congestive cardiac failure (CCF) - JVP raised, hepatomegaly, dependent oedema
  • Nephrotic syndrome (proteinuria, hypoalbuminaemia, massive oedema)
  • Liver cirrhosis (hypoalbuminaemia + portal hypertension)
  • Deep vein thrombosis (unilateral, warm, tender calf)
  • Lymphoedema (non-pitting, follows lymph node surgery/radiation)
  • Hypothyroidism
  • Drugs (calcium channel blockers - amlodipine; NSAIDs)

PAST HISTORY (CVS System)

Rheumatic Fever History:

"Fever with sore throat / Fleeting joint pain / H/O taking Penicillins"
Jones Criteria for Rheumatic Fever (revised 2015):
Major criteria: Carditis (clinical/subclinical), Polyarthritis, Chorea (Sydenham's), Erythema marginatum, Subcutaneous nodules
Minor criteria: Fever, elevated ESR/CRP, prolonged PR interval
Significance: Rheumatic fever → Rheumatic Heart Disease (RHD) → mitral stenosis, mitral regurgitation, aortic stenosis, aortic regurgitation.
  • History of sore throat (Group A Streptococcal pharyngitis) is the precipitant
  • H/O Penicillin = prophylaxis to prevent recurrence = confirms RHD diagnosis in past
What to rule out in current admission: Active rheumatic fever vs. previously acquired valvular disease vs. infective endocarditis on rheumatic valve.

Infective Endocarditis (IE) History:

"Fever / Dental Procedures / GIT / Genitourinary Procedures"
Definition: Infection of the endocardium, most commonly involving native or prosthetic heart valves, caused by bacteria (or rarely fungi) that enter the bloodstream through a portal of entry.
Why these questions:
  • Dental procedures → Viridans streptococci (Strep. viridans) - most common organism in native valve IE
  • GIT / GU procedures / colonoscopy → Enterococci
  • IV drug use → Staph. aureus - right-sided IE (tricuspid valve)
  • Prosthetic valve / cardiac surgery → CONS (coagulase-negative Staph.), early prosthetic valve IE
What to rule out: This history is asked to identify the source of bacteraemia that seeded the valve.

Congenital Heart Disease (CHD) History:

"Failure of cry after birth / Failure to thrive / Recurrent RTI / Squatting / Cyanotic spells / Consanguinity"
History itemWhat it suggests
Failure of cry after birthSevere cyanotic CHD requiring immediate resuscitation (TGA, critical PS, critical AS)
Failure to thriveLarge left-to-right shunt (VSD, PDA, AV canal) - high pulmonary flow, fatigue on feeding, FTT
Recurrent RTILarge L→R shunt → pulmonary plethora → recurrent respiratory infections
SquattingFallot's tetralogy (squatting increases systemic vascular resistance → reduces R→L shunt → improves SpO2); Classic for cyanotic CHD
Cyanotic spells (Tet spells)Hypercyanotic spells in Tetralogy - treated with knee-chest position, morphine, propranolol
ConsanguinityAutosomal recessive CHDs; chromosomal anomalies (Down syndrome - AV canal, VSD; Turner - coarctation; Marfan - aortic root)

PERSONAL HISTORY (CVS)

ItemSignificance
SmokingMajor risk factor for atherosclerosis (IHD, peripheral vascular disease, stroke), endothelial dysfunction; Nicotine staining of fingers = clinical marker on examination
AlcoholAlcoholic cardiomyopathy (dilated cardiomyopathy), AF, hypertension; Binge drinking = "Holiday Heart Syndrome" (AF after binge)
Diet (Veg/Mixed)High saturated fat diet → dyslipidaemia → CAD; Vegetarian → lower cholesterol but possible B12 deficiency
Loss of weight / appetiteCardiac cachexia (severe CCF - catabolic state); Malignancy; TB

FAMILY HISTORY (CVS)

ItemWhy asked
CHD (Congenital Heart Disease)Familial CHDs, chromosomal syndromes
IHD (Ischaemic Heart Disease)Strong family history = premature CAD (first-degree male relative <55yr, female <65yr) is an independent risk factor
HTNEssential hypertension is polygenic, runs in families
DMType 2 DM has strong familial component, drives cardiovascular risk
SCD (Sudden Cardiac Death)HCM (AD), Long QT syndrome (AD), Brugada syndrome - familial arrhythmogenic conditions

MENSTRUAL / OBSTETRIC HISTORY (CVS)

ItemSignificance
Menarche / Cycle detailsOral contraceptive pills (OCP) → increased risk of venous thromboembolism, stroke, hypertension
Dysmenorrhoea / AmenorrhoeaEndometriosis may occasionally mimic cardiac symptoms; PCOS → metabolic syndrome → CVD risk
Number of pregnancies / ComplicationsPeripartum cardiomyopathy (last month of pregnancy to 5 months postpartum - dilated CMP); Pre-eclampsia → future hypertension/CVD risk
Recent deliveryPeripartum CMP, DVT/PE postpartum (hypercoagulable state)

GENERAL HISTORY (CVS Specific)

ItemSignificance
Right hypochondric pain / AppetiteHepatic congestion from RHF - congestive hepatopathy; Anorexia in CCF (hepatic congestion, gut wall oedema)
FatigueReduced cardiac output → poor perfusion of skeletal muscles; also in anaemia, thyroid disease
Cyanotic spellsCyanotic CHD; Hypercyanotic spells (Tet spells)
OliguriaReduced renal perfusion from low cardiac output (cardiorenal syndrome)

GENERAL OBSERVATIONS ACROSS ALL SYSTEMS

Why Duration / Onset / Progress Are Always Asked

These three form the temporal backbone of any history:
QuestionWhat it tells you
DurationAcute vs. Subacute vs. Chronic → narrows the differential list dramatically
OnsetSudden (vascular, obstructive, mechanical) vs. Gradual (inflammatory, neoplastic, metabolic)
ProgressionGetting worse (malignant, obstructive) vs. Intermittent/episodic (functional, vascular) vs. Static (old fixed lesion) vs. Improving (infective/inflammatory with treatment)

Why Aggravating and Relieving Factors Are Asked

These give you the pathophysiological mechanism:
  • Exertional worsening = inadequate supply (ischaemia, obstruction)
  • Positional changes = hydrostatic/mechanical
  • Drug-related = pharmacological
  • Food-related = gut motility or acid secretion
  • Relief by nitrates = coronary or oesophageal spasm (both respond)

QUICK REFERENCE TABLE - Red Flag Symptoms

SymptomRed Flag FeatureLikely Diagnosis
DysphagiaProgressive solids → liquids, weight loss, age >50Carcinoma oesophagus
Abdominal painSudden onset, board-like rigidityPerforation peritonitis
HaematemesisMassive, known liver disease, cirrhosisVariceal bleed (emergency)
Chest painTearing, maximal at onset, back radiationAortic dissection
Chest pain>20 min, not relieved by nitrates, diaphoresisSTEMI
SyncopeExertional, young person/athleteHOCM, AS, Arrhythmia
HaemoptysisSmoker >40 years, weight lossLung carcinoma
Weakness + bladder/bowel incontinenceSaddle anaesthesiaCauda equina syndrome (emergency)
Headache"Worst headache of life", sudden onsetSubarachnoid haemorrhage
BreathlessnessSudden, pleuritic chest pain, tachycardiaPulmonary embolism

This covers every item in your proforma across all four systems. For each symptom you ask in clinical posting, you are building a differential diagnosis and systematically narrowing it down - that is the entire purpose of history taking. Good history taking alone leads to the correct diagnosis in approximately 80% of cases.

Generate a quick reference PDF with differential diagnosis flowcharts for common presenting symptoms

Asking for Preferences
Running Command

ls /tmp/workspace/ && mkdir -p /tmp/workspace/ddx-flowcharts

Writing File

~/ddx-flowcharts/generate_pdf.py

"""
DDx Flowchart PDF Generator
Medicine Posting - Quick Reference for 2nd Year MBBS
Covers: GIT, CNS, Respiratory, CVS
Style: Decision-tree (Yes/No branches)
"""

import math
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, PageBreak, Table, TableStyle, HRFlowable
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_RIGHT
from reportlab.graphics.shapes import Drawing, Rect, String, Line, Polygon, Circle
from reportlab.graphics import renderPDF
from reportlab.graphics.shapes import Group
from reportlab.platypus.flowables import Flowable

# ── Colour palette ─────────────────────────────────────────────────────────────
C_HEADER_BG   = colors.HexColor("#1a3a5c")   # deep navy
C_HEADER_FG   = colors.white
C_SYSTEM_GIT  = colors.HexColor("#e8f5e9")   # pale green
C_SYSTEM_CNS  = colors.HexColor("#fce4ec")   # pale pink
C_SYSTEM_RS   = colors.HexColor("#e3f2fd")   # pale blue
C_SYSTEM_CVS  = colors.HexColor("#fff8e1")   # pale amber

C_ROOT        = colors.HexColor("#1a3a5c")   # dark navy - root node
C_QUESTION    = colors.HexColor("#1565c0")   # blue - decision node
C_YES_PATH    = colors.HexColor("#2e7d32")   # green - yes branch node
C_NO_PATH     = colors.HexColor("#b71c1c")   # red - no branch / further Q
C_DIAGNOSIS   = colors.HexColor("#4a148c")   # purple - final diagnosis
C_REDBOX      = colors.HexColor("#c62828")   # red flag box
C_KEYFACT     = colors.HexColor("#f57f17")   # orange - key fact

C_YES_LINE    = colors.HexColor("#388e3c")
C_NO_LINE     = colors.HexColor("#d32f2f")
C_ARROW       = colors.HexColor("#37474f")

W, H = A4  # 595 x 842 pts

# ── Custom Flowable: Decision Tree Drawing ─────────────────────────────────────

class FlowchartFlowable(Flowable):
    """
    Renders a decision-tree as a ReportLab Drawing.
    tree_data: list of node dicts with layout info.
    """

    def __init__(self, nodes, width=None, height=None):
        Flowable.__init__(self)
        self.nodes = nodes
        self.chart_width  = width  or (W - 40*mm)
        self.chart_height = height or 220*mm

    def wrap(self, aw, ah):
        return self.chart_width, self.chart_height

    def draw(self):
        d = Drawing(self.chart_width, self.chart_height)
        for node in self.nodes:
            self._draw_node(d, node)
        for node in self.nodes:
            self._draw_connections(d, node)
        d.drawOn(self.canv, 0, 0)

    def _draw_node(self, d, n):
        x, y = n['x'], n['y']
        w, h = n.get('w', 110), n.get('h', 26)
        kind = n.get('kind', 'question')

        # Box fill colour
        fill_map = {
            'root':      colors.HexColor("#1a3a5c"),
            'question':  colors.HexColor("#1565c0"),
            'yes':       colors.HexColor("#2e7d32"),
            'no':        colors.HexColor("#c62828"),
            'diag':      colors.HexColor("#4a148c"),
            'redflag':   colors.HexColor("#b71c1c"),
            'key':       colors.HexColor("#e65100"),
        }
        text_col = colors.white
        fill_col = fill_map.get(kind, colors.HexColor("#1565c0"))

        # Rounded rect
        r = Rect(x - w/2, y - h/2, w, h,
                 rx=6, ry=6,
                 fillColor=fill_col,
                 strokeColor=colors.white,
                 strokeWidth=0.8)
        d.add(r)

        label = n.get('label', '')
        font_size = n.get('fs', 7)
        lines = self._wrap_text(label, w - 8, font_size)
        line_h = font_size * 1.3
        total_text_h = len(lines) * line_h
        start_y = y + total_text_h/2 - line_h * 0.75

        for i, line in enumerate(lines):
            s = String(x, start_y - i * line_h, line,
                       fontName='Helvetica-Bold' if kind in ('root', 'diag', 'redflag') else 'Helvetica',
                       fontSize=font_size,
                       fillColor=text_col,
                       textAnchor='middle')
            d.add(s)

    def _draw_connections(self, d, n):
        for conn in n.get('connections', []):
            x1, y1 = n['x'], n['y'] - n.get('h', 26)/2
            tx_node = conn['to_node']
            x2, y2_top = tx_node['x'], tx_node['y'] + tx_node.get('h', 26)/2

            label   = conn.get('label', '')
            is_yes  = label.upper().startswith('Y')
            lc = C_YES_LINE if is_yes else C_NO_LINE

            # Draw elbow line: down from source, across, up to target
            mid_y = (y1 + y2_top) / 2

            line1 = Line(x1, y1, x1, mid_y, strokeColor=lc, strokeWidth=1.2)
            line2 = Line(x1, mid_y, x2, mid_y, strokeColor=lc, strokeWidth=1.2)
            line3 = Line(x2, mid_y, x2, y2_top, strokeColor=lc, strokeWidth=1.2)

            # Arrow head at destination
            arrow = Polygon([x2, y2_top,
                             x2 - 3, y2_top + 5,
                             x2 + 3, y2_top + 5],
                            fillColor=lc, strokeColor=lc, strokeWidth=0)
            d.add(line1); d.add(line2); d.add(line3); d.add(arrow)

            if label:
                lx = (x1 + x2) / 2 + (5 if x2 > x1 else -5)
                ly = mid_y + 2
                s = String(lx, ly, label,
                           fontName='Helvetica-Bold',
                           fontSize=6,
                           fillColor=lc,
                           textAnchor='middle')
                d.add(s)

    @staticmethod
    def _wrap_text(text, max_w, font_size):
        """Very simple word-wrap for labels."""
        words = text.split()
        lines, cur = [], []
        char_w = font_size * 0.55
        for w in words:
            test = ' '.join(cur + [w])
            if len(test) * char_w <= max_w:
                cur.append(w)
            else:
                if cur:
                    lines.append(' '.join(cur))
                cur = [w]
        if cur:
            lines.append(' '.join(cur))
        return lines or ['']


# ── Styles ─────────────────────────────────────────────────────────────────────

def make_styles():
    ss = getSampleStyleSheet()

    def add(name, **kw):
        if name not in ss:
            ss.add(ParagraphStyle(name=name, **kw))
        return ss[name]

    add('SystemTitle',
        fontName='Helvetica-Bold', fontSize=18,
        textColor=C_HEADER_FG, alignment=TA_CENTER,
        spaceAfter=4, spaceBefore=0)

    add('SympTitle',
        fontName='Helvetica-Bold', fontSize=13,
        textColor=C_HEADER_BG, alignment=TA_LEFT,
        spaceAfter=3, spaceBefore=10)

    add('SubHead',
        fontName='Helvetica-Bold', fontSize=9,
        textColor=C_HEADER_BG, alignment=TA_LEFT,
        spaceAfter=2, spaceBefore=4)

    add('Body8',
        fontName='Helvetica', fontSize=8,
        textColor=colors.HexColor("#212121"),
        leading=11, spaceAfter=2)

    add('RedFlag',
        fontName='Helvetica-Bold', fontSize=8,
        textColor=C_REDBOX,
        leading=11, spaceAfter=2)

    add('SmallCenter',
        fontName='Helvetica', fontSize=7,
        textColor=colors.grey,
        alignment=TA_CENTER, spaceAfter=0)

    add('Cover_Title',
        fontName='Helvetica-Bold', fontSize=28,
        textColor=C_HEADER_BG, alignment=TA_CENTER,
        spaceAfter=6)

    add('Cover_Sub',
        fontName='Helvetica', fontSize=13,
        textColor=colors.HexColor("#455a64"),
        alignment=TA_CENTER, spaceAfter=4)

    add('Cover_Tiny',
        fontName='Helvetica', fontSize=9,
        textColor=colors.grey,
        alignment=TA_CENTER, spaceAfter=2)

    return ss


# ── Node builder helpers ───────────────────────────────────────────────────────

def node(nid, x, y, label, kind='question', w=110, h=24, fs=7):
    return {'id': nid, 'x': x, 'y': y, 'label': label,
            'kind': kind, 'w': w, 'h': h, 'fs': fs, 'connections': []}

def connect(src, dst, label=''):
    src['connections'].append({'label': label, 'to_node': dst})


# ══════════════════════════════════════════════════════════════════════════════
# FLOWCHART DATA DEFINITIONS
# Each function returns (nodes_list, title, colour, height_pts)
# ══════════════════════════════════════════════════════════════════════════════

def chart_abdominal_pain():
    """Abdominal Pain DDx decision tree"""
    nodes = []
    CW = 520   # canvas width pts
    CH = 310   # canvas height pts

    root  = node('root',  260, 290, 'ABDOMINAL PAIN', 'root', w=160, h=28, fs=10)

    # Branch 1: Sudden vs gradual
    q1    = node('q1',    260, 255, 'Sudden onset?', 'question', w=130, h=22, fs=8)
    # Sudden YES → sub-branch
    q2    = node('q2',    100, 220, 'Board-like rigidity?', 'question', w=120, h=22, fs=7)
    d_perf= node('d_perf',100, 185, 'PERFORATION PERITONITIS', 'diag', w=135, h=22, fs=7)
    q3    = node('q3',    100, 150, 'Tearing, radiates to back?', 'question', w=130, h=22, fs=7)
    d_ao  = node('d_ao',  100, 115, 'AORTIC DISSECTION / ANEURYSM', 'redflag', w=145, h=22, fs=7)
    d_isc = node('d_isc', 245, 150, 'MESENTERIC ISCHAEMIA', 'diag', w=130, h=22, fs=7)

    # Sudden NO → gradual/colicky
    q4    = node('q4',    420, 230, 'Colicky character?', 'question', w=120, h=22, fs=7)
    q5    = node('q5',    330, 195, 'RIF + fever + tenderness?', 'question', w=135, h=22, fs=7)
    d_app = node('d_app', 330, 160, 'ACUTE APPENDICITIS', 'diag', w=125, h=22, fs=7)
    q6    = node('q6',    420, 163, 'Post-fatty meal, RUQ?', 'question', w=130, h=22, fs=7)
    d_bil = node('d_bil', 420, 128, 'BILIARY COLIC / CHOLECYSTITIS', 'diag', w=145, h=22, fs=7)
    q7    = node('q7',    420,  95, 'Radiates to back, alcohol?', 'question', w=140, h=22, fs=7)
    d_pan = node('d_pan', 420,  60, 'ACUTE PANCREATITIS', 'diag', w=125, h=22, fs=7)
    d_ren = node('d_ren', 260,  95, 'RENAL / URETERIC COLIC', 'diag', w=130, h=22, fs=7)

    # Chronic/gradual YES path
    q8    = node('q8',    260, 195, 'Meal-related + epigastric?', 'question', w=135, h=22, fs=7)
    d_pud = node('d_pud', 140, 160, 'PEPTIC ULCER DISEASE', 'diag', w=125, h=22, fs=7)
    d_ibs = node('d_ibs', 260, 162, 'IBS / FUNCTIONAL PAIN', 'diag', w=125, h=22, fs=7)

    nodes = [root, q1, q2, d_perf, q3, d_ao, d_isc, q4, q5, d_app, q6, d_bil, q7, d_pan, d_ren, q8, d_pud, d_ibs]

    connect(root, q1)
    connect(q1, q2, 'YES'); connect(q2, d_perf, 'YES')
    connect(q2, q3, 'NO'); connect(q3, d_ao, 'YES'); connect(q3, d_isc, 'NO')
    connect(q1, q4, 'NO'); connect(q4, q5, 'YES'); connect(q5, d_app, 'YES')
    connect(q4, q6, 'NO'); connect(q6, d_bil, 'YES')
    connect(q6, q7, 'NO'); connect(q7, d_pan, 'YES'); connect(q7, d_ren, 'NO')
    connect(q5, q8, 'NO'); connect(q8, d_pud, 'YES'); connect(q8, d_ibs, 'NO')

    return nodes, 'Abdominal Pain', C_SYSTEM_GIT, CH


def chart_jaundice():
    nodes = []
    CH = 290

    root   = node('root',   260, 275, 'JAUNDICE', 'root', w=140, h=28, fs=10)
    q1     = node('q1',     260, 245, 'Urine dark + stool pale?', 'question', w=145, h=22, fs=7)

    # YES = conjugated → post-hepatic or hepatocellular
    q2     = node('q2',     130, 213, 'Painful jaundice?', 'question', w=120, h=22, fs=7)
    d_chol = node('d_chol', 130, 180, 'CHOLEDOCHOLITHIASIS / CHOLANGITIS', 'diag', w=155, h=22, fs=7)
    q3     = node('q3',     310, 213, 'Painless + weight loss?', 'question', w=135, h=22, fs=7)
    d_ca   = node('d_ca',   310, 180, 'Ca HEAD OF PANCREAS (Courvoisier)', 'diag', w=155, h=22, fs=7)
    d_hep  = node('d_hep',  430, 213, 'HEPATOCELLULAR (Hepatitis / DILI / ALD)', 'diag', w=150, h=22, fs=6)

    # NO = urine normal / dark only urobilinogen → pre-hepatic
    q4     = node('q4',     260, 155, 'Anaemia + splenomegaly?', 'question', w=135, h=22, fs=7)
    d_haem = node('d_haem', 260, 122, 'HAEMOLYTIC JAUNDICE', 'diag', w=130, h=22, fs=7)
    q5     = node('q5',     420, 155, 'Young + KF ring + liver disease?', 'question', w=145, h=22, fs=7)
    d_wil  = node('d_wil',  420, 122, "WILSON'S DISEASE", 'diag', w=120, h=22, fs=7)
    d_gil  = node('d_gil',  420,  89, 'GILBERT / CRIGLER-NAJJAR', 'diag', w=135, h=22, fs=7)

    nodes = [root, q1, q2, d_chol, q3, d_ca, d_hep, q4, d_haem, q5, d_wil, d_gil]

    connect(root, q1)
    connect(q1, q2, 'YES'); connect(q2, d_chol, 'YES'); connect(q2, q3, 'NO')
    connect(q3, d_ca, 'YES'); connect(q3, d_hep, 'NO')
    connect(q1, q4, 'NO'); connect(q4, d_haem, 'YES'); connect(q4, q5, 'NO')
    connect(q5, d_wil, 'YES'); connect(q5, d_gil, 'NO')

    return nodes, 'Jaundice', C_SYSTEM_GIT, CH


def chart_haematemesis():
    CH = 280
    root   = node('root',   260, 265, 'HAEMATEMESIS', 'root', w=150, h=28, fs=10)
    q1     = node('q1',     260, 235, 'Known cirrhosis / portal HTN?', 'question', w=150, h=22, fs=7)
    d_var  = node('d_var',  130, 200, 'OESOPHAGEAL VARICES', 'redflag', w=135, h=22, fs=7)
    q2     = node('q2',     390, 200, 'NSAID / alcohol use?', 'question', w=125, h=22, fs=7)
    d_pud  = node('d_pud',  260, 200, 'PEPTIC ULCER / EROSIVE GASTRITIS', 'diag', w=145, h=22, fs=7)
    q3     = node('q3',     390, 168, 'Preceded by forceful vomiting?', 'question', w=150, h=22, fs=7)
    d_mw   = node('d_mw',   390, 135, 'MALLORY-WEISS TEAR', 'diag', w=130, h=22, fs=7)
    q4     = node('q4',     390, 103, 'Weight loss + dysphagia?', 'question', w=135, h=22, fs=7)
    d_ca   = node('d_ca',   390,  72, 'GASTRIC CARCINOMA', 'diag', w=120, h=22, fs=7)
    d_dieu = node('d_dieu', 220, 103, "DIEULAFOY'S / AORTO-ENTERIC", 'diag', w=145, h=22, fs=7)

    nodes = [root, q1, d_var, q2, d_pud, q3, d_mw, q4, d_ca, d_dieu]
    connect(root, q1)
    connect(q1, d_var, 'YES'); connect(q1, q2, 'NO')
    connect(q2, d_pud, 'YES'); connect(q2, q3, 'NO')
    connect(q3, d_mw, 'YES'); connect(q3, q4, 'NO')
    connect(q4, d_ca, 'YES'); connect(q4, d_dieu, 'NO')

    return nodes, 'Haematemesis', C_SYSTEM_GIT, CH


def chart_diarrhoea():
    CH = 280
    root   = node('root',   260, 265, 'DIARRHOEA', 'root', w=140, h=28, fs=10)
    q1     = node('q1',     260, 235, 'Acute (<2 weeks)?', 'question', w=130, h=22, fs=7)
    q2     = node('q2',     130, 202, 'Blood + mucus in stool?', 'question', w=130, h=22, fs=7)
    d_bac  = node('d_bac',  130, 169, 'BACILLARY DYSENTERY (Shigella)', 'diag', w=145, h=22, fs=7)
    d_amo  = node('d_amo',  130, 137, 'AMOEBIC COLITIS', 'diag', w=120, h=22, fs=7)
    d_ent  = node('d_ent',  280, 202, 'VIRAL / ETEC GASTROENTERITIS', 'diag', w=145, h=22, fs=7)
    # Chronic
    q3     = node('q3',     430, 202, 'Chronic (>4 weeks)?', 'question', w=130, h=22, fs=7)
    q4     = node('q4',     430, 169, 'Blood + nocturnal symptoms?', 'question', w=140, h=22, fs=7)
    d_ibd  = node('d_ibd',  430, 137, 'IBD (UC / CROHN\'S)', 'diag', w=120, h=22, fs=7)
    q5     = node('q5',     430, 105, 'Steatorrhoea + weight loss?', 'question', w=140, h=22, fs=7)
    d_mal  = node('d_mal',  430,  73, 'MALABSORPTION (Coeliac / EPI)', 'diag', w=145, h=22, fs=7)
    d_ibs  = node('d_ibs',  270, 105, 'IBS / MICROSCOPIC COLITIS', 'diag', w=135, h=22, fs=7)

    nodes = [root, q1, q2, d_bac, d_amo, d_ent, q3, q4, d_ibd, q5, d_mal, d_ibs]
    connect(root, q1)
    connect(q1, q2, 'YES'); connect(q2, d_bac, 'YES'); connect(q2, d_ent, 'NO')
    connect(q1, q3, 'NO'); connect(q3, q4, 'YES'); connect(q4, d_ibd, 'YES')
    connect(q4, q5, 'NO'); connect(q5, d_mal, 'YES'); connect(q5, d_ibs, 'NO')
    connect(q2, d_amo, 'NO')  # second branch after enteric

    return nodes, 'Diarrhoea', C_SYSTEM_GIT, CH


def chart_dysphagia():
    CH = 260
    root   = node('root',   260, 248, 'DYSPHAGIA', 'root', w=140, h=28, fs=10)
    q1     = node('q1',     260, 218, 'Solids AND liquids from onset?', 'question', w=150, h=22, fs=7)
    # YES = motility
    q2     = node('q2',     120, 186, 'Regurgitation of old food?', 'question', w=140, h=22, fs=7)
    d_ach  = node('d_ach',  120, 154, 'ACHALASIA CARDIA', 'diag', w=120, h=22, fs=7)
    d_des  = node('d_des',  120, 122, 'DIFFUSE OESOPHAGEAL SPASM', 'diag', w=140, h=22, fs=7)
    # NO = structural / progressive
    q3     = node('q3',     400, 186, 'Progressive solids → liquids?', 'question', w=145, h=22, fs=7)
    d_car  = node('d_car',  400, 154, 'Ca OESOPHAGUS', 'redflag', w=120, h=22, fs=7)
    q4     = node('q4',     400, 122, 'H/O GERD + heartburn?', 'question', w=130, h=22, fs=7)
    d_stri = node('d_stri', 400,  90, 'PEPTIC STRICTURE', 'diag', w=120, h=22, fs=7)
    d_pv   = node('d_pv',   240, 122, 'PLUMMER-VINSON / EXT COMPRESSION', 'diag', w=155, h=22, fs=6)

    nodes = [root, q1, q2, d_ach, d_des, q3, d_car, q4, d_stri, d_pv]
    connect(root, q1)
    connect(q1, q2, 'YES'); connect(q2, d_ach, 'YES'); connect(q2, d_des, 'NO')
    connect(q1, q3, 'NO'); connect(q3, d_car, 'YES'); connect(q3, q4, 'NO')
    connect(q4, d_stri, 'YES'); connect(q4, d_pv, 'NO')

    return nodes, 'Dysphagia', C_SYSTEM_GIT, CH


def chart_weakness():
    CH = 310
    root   = node('root',   260, 296, 'LIMB WEAKNESS', 'root', w=150, h=28, fs=10)
    q1     = node('q1',     260, 266, 'Sudden onset?', 'question', w=130, h=22, fs=7)
    d_str  = node('d_str',  120, 235, 'STROKE / TIA', 'redflag', w=115, h=22, fs=7)
    q2     = node('q2',     380, 235, 'Progressive onset?', 'question', w=130, h=22, fs=7)
    # UMN vs LMN
    q3     = node('q3',     380, 204, 'UMN signs (spasticity, brisk reflexes)?', 'question', w=155, h=22, fs=6)
    q4     = node('q4',     210, 204, 'LMN signs (wasting, fasciculations)?', 'question', w=155, h=22, fs=6)
    d_mnd  = node('d_mnd',  120, 172, 'MND / ALS (both UMN+LMN)', 'diag', w=135, h=22, fs=7)
    d_rad  = node('d_rad',  260, 172, 'RADICULOPATHY / GBS', 'diag', w=125, h=22, fs=7)
    q5     = node('q5',     420, 172, 'Spinal cord level (band + bladder)?', 'question', w=150, h=22, fs=6)
    d_sc   = node('d_sc',   420, 140, 'SPINAL CORD COMPRESSION', 'redflag', w=140, h=22, fs=7)
    d_ms   = node('d_ms',   420, 108, 'MULTIPLE SCLEROSIS (relapsing)', 'diag', w=145, h=22, fs=7)
    # Proximal weakness
    q6     = node('q6',     120, 140, 'Proximal > distal?', 'question', w=125, h=22, fs=7)
    d_myo  = node('d_myo',  120, 108, 'MYOPATHY / POLYMYOSITIS', 'diag', w=130, h=22, fs=7)
    d_mg   = node('d_mg',   120,  76, 'MYASTHENIA GRAVIS (fatigable)', 'diag', w=135, h=22, fs=7)

    nodes = [root, q1, d_str, q2, q3, q4, d_mnd, d_rad, q5, d_sc, d_ms, q6, d_myo, d_mg]
    connect(root, q1)
    connect(q1, d_str, 'YES'); connect(q1, q2, 'NO')
    connect(q2, q3, 'YES'); connect(q2, q4, 'NO')
    connect(q3, d_mnd, 'YES'); connect(q3, q5, 'NO')
    connect(q4, q6, 'YES'); connect(q4, d_rad, 'NO')
    connect(q5, d_sc, 'YES'); connect(q5, d_ms, 'NO')
    connect(q6, d_myo, 'YES'); connect(q6, d_mg, 'NO')

    return nodes, 'Limb Weakness', C_SYSTEM_CNS, CH


def chart_headache():
    CH = 300
    root   = node('root',   260, 285, 'HEADACHE', 'root', w=140, h=28, fs=10)
    q1     = node('q1',     260, 255, 'Thunderclap - worst ever?', 'question', w=150, h=22, fs=7)
    d_sah  = node('d_sah',  120, 222, 'SUBARACHNOID HAEMORRHAGE', 'redflag', w=150, h=22, fs=7)
    q2     = node('q2',     380, 222, 'Fever + neck stiffness?', 'question', w=140, h=22, fs=7)
    d_men  = node('d_men',  380, 190, 'MENINGITIS / ENCEPHALITIS', 'redflag', w=145, h=22, fs=7)
    q3     = node('q3',     260, 190, 'Progressive + vomiting + papilloedema?', 'question', w=160, h=22, fs=6)
    d_soc  = node('d_soc',  120, 158, 'SPACE-OCCUPYING LESION / Raised ICP', 'redflag', w=155, h=22, fs=7)
    q4     = node('q4',     380, 158, 'Unilateral, pulsatile, photophobia?', 'question', w=155, h=22, fs=7)
    d_mig  = node('d_mig',  380, 126, 'MIGRAINE', 'diag', w=110, h=22, fs=7)
    q5     = node('q5',     380,  94, 'Temporal, jaw claudication >50yr?', 'question', w=155, h=22, fs=7)
    d_gca  = node('d_gca',  380,  62, 'GIANT CELL ARTERITIS', 'redflag', w=130, h=22, fs=7)
    d_ten  = node('d_ten',  220,  94, 'TENSION / CLUSTER HEADACHE', 'diag', w=145, h=22, fs=7)

    nodes = [root, q1, d_sah, q2, d_men, q3, d_soc, q4, d_mig, q5, d_gca, d_ten]
    connect(root, q1)
    connect(q1, d_sah, 'YES'); connect(q1, q2, 'NO')
    connect(q2, d_men, 'YES'); connect(q2, q3, 'NO')
    connect(q3, d_soc, 'YES'); connect(q3, q4, 'NO')
    connect(q4, d_mig, 'YES'); connect(q4, q5, 'NO')
    connect(q5, d_gca, 'YES'); connect(q5, d_ten, 'NO')

    return nodes, 'Headache', C_SYSTEM_CNS, CH


def chart_cough():
    CH = 290
    root   = node('root',   260, 276, 'COUGH', 'root', w=130, h=28, fs=10)
    q1     = node('q1',     260, 246, 'Duration > 8 weeks (Chronic)?', 'question', w=155, h=22, fs=7)
    # Acute
    q2     = node('q2',     110, 214, 'Fever + productive sputum?', 'question', w=140, h=22, fs=7)
    d_pne  = node('d_pne',  110, 182, 'PNEUMONIA', 'diag', w=110, h=22, fs=7)
    d_urt  = node('d_urt',  110, 150, 'VIRAL URTI / ACUTE BRONCHITIS', 'diag', w=145, h=22, fs=7)
    # Chronic
    q3     = node('q3',     420, 214, 'Smoker > 10 pack-years?', 'question', w=145, h=22, fs=7)
    d_cop  = node('d_cop',  420, 182, 'COPD / CHRONIC BRONCHITIS', 'diag', w=140, h=22, fs=7)
    q4     = node('q4',     420, 150, 'Episodic + wheeze?', 'question', w=130, h=22, fs=7)
    d_ast  = node('d_ast',  420, 118, 'BRONCHIAL ASTHMA', 'diag', w=125, h=22, fs=7)
    q5     = node('q5',     420,  86, 'Fever + night sweats + wt loss?', 'question', w=155, h=22, fs=7)
    d_tb   = node('d_tb',   420,  54, 'PULMONARY TUBERCULOSIS', 'redflag', w=140, h=22, fs=7)
    q6     = node('q6',     260, 150, 'On ACE inhibitor?', 'question', w=130, h=22, fs=7)
    d_ace  = node('d_ace',  260, 118, 'ACE INHIBITOR COUGH', 'diag', w=130, h=22, fs=7)
    d_ild  = node('d_ild',  260,  86, 'ILD / MALIGNANCY', 'diag', w=120, h=22, fs=7)

    nodes = [root, q1, q2, d_pne, d_urt, q3, d_cop, q4, d_ast, q5, d_tb, q6, d_ace, d_ild]
    connect(root, q1)
    connect(q1, q2, 'NO'); connect(q2, d_pne, 'YES'); connect(q2, d_urt, 'NO')
    connect(q1, q3, 'YES'); connect(q3, d_cop, 'YES'); connect(q3, q4, 'NO')
    connect(q4, d_ast, 'YES'); connect(q4, q5, 'NO')
    connect(q5, d_tb, 'YES'); connect(q5, q6, 'NO')
    connect(q6, d_ace, 'YES'); connect(q6, d_ild, 'NO')

    return nodes, 'Cough', C_SYSTEM_RS, CH


def chart_dyspnoea():
    CH = 300
    root   = node('root',   260, 285, 'BREATHLESSNESS', 'root', w=155, h=28, fs=10)
    q1     = node('q1',     260, 255, 'Sudden onset?', 'question', w=130, h=22, fs=7)
    # Sudden
    q2     = node('q2',     120, 222, 'Pleuritic pain + tachycardia?', 'question', w=150, h=22, fs=7)
    d_pe   = node('d_pe',   120, 190, 'PULMONARY EMBOLISM', 'redflag', w=135, h=22, fs=7)
    q3     = node('q3',     120, 158, 'Absent breath sounds + hyper-resonance?', 'question', w=160, h=22, fs=6)
    d_pnx  = node('d_pnx',  120, 126, 'PNEUMOTHORAX', 'redflag', w=120, h=22, fs=7)
    d_af   = node('d_af',   260, 222, 'ACUTE LVF / AF', 'redflag', w=115, h=22, fs=7)
    # Chronic/progressive
    q4     = node('q4',     420, 222, 'Progressive over weeks-months?', 'question', w=150, h=22, fs=7)
    q5     = node('q5',     420, 190, 'Orthopnoea + PND?', 'question', w=130, h=22, fs=7)
    d_lvf  = node('d_lvf',  420, 158, 'CARDIAC FAILURE (LVF)', 'diag', w=130, h=22, fs=7)
    q6     = node('q6',     420, 126, 'Wheeze + obstructive?', 'question', w=130, h=22, fs=7)
    d_cop  = node('d_cop',  420,  94, 'ASTHMA / COPD', 'diag', w=115, h=22, fs=7)
    d_pf   = node('d_pf',   260, 126, 'ILD / PULMONARY FIBROSIS', 'diag', w=135, h=22, fs=7)

    nodes = [root, q1, q2, d_pe, q3, d_pnx, d_af, q4, q5, d_lvf, q6, d_cop, d_pf]
    connect(root, q1)
    connect(q1, q2, 'YES'); connect(q2, d_pe, 'YES'); connect(q2, q3, 'NO')
    connect(q3, d_pnx, 'YES'); connect(q3, d_af, 'NO')
    connect(q1, q4, 'NO'); connect(q4, q5, 'YES'); connect(q5, d_lvf, 'YES')
    connect(q5, q6, 'NO'); connect(q6, d_cop, 'YES'); connect(q6, d_pf, 'NO')

    return nodes, 'Breathlessness', C_SYSTEM_RS, CH


def chart_haemoptysis():
    CH = 270
    root   = node('root',   260, 258, 'HAEMOPTYSIS', 'root', w=140, h=28, fs=10)
    q1     = node('q1',     260, 228, 'Smoker >40 yrs + weight loss?', 'question', w=155, h=22, fs=7)
    d_ca   = node('d_ca',   120, 196, 'LUNG CARCINOMA', 'redflag', w=120, h=22, fs=7)
    q2     = node('q2',     380, 196, 'Fever + night sweats + cough?', 'question', w=150, h=22, fs=7)
    d_tb   = node('d_tb',   380, 164, 'PULMONARY TUBERCULOSIS', 'redflag', w=145, h=22, fs=7)
    q3     = node('q3',     380, 132, 'Copious purulent sputum + clubbing?', 'question', w=158, h=22, fs=6)
    d_bron = node('d_bron', 380, 100, 'BRONCHIECTASIS / ASPERGILLOMA', 'diag', w=150, h=22, fs=7)
    q4     = node('q4',     380,  68, 'Sudden dyspnoea + pleuritic pain?', 'question', w=155, h=22, fs=7)
    d_pe   = node('d_pe',   380,  36, 'PE + INFARCTION', 'redflag', w=115, h=22, fs=7)
    d_ms   = node('d_ms',   220, 100, 'MITRAL STENOSIS (MS)', 'diag', w=125, h=22, fs=7)

    nodes = [root, q1, d_ca, q2, d_tb, q3, d_bron, q4, d_pe, d_ms]
    connect(root, q1)
    connect(q1, d_ca, 'YES'); connect(q1, q2, 'NO')
    connect(q2, d_tb, 'YES'); connect(q2, q3, 'NO')
    connect(q3, d_bron, 'YES'); connect(q3, q4, 'NO')
    connect(q4, d_pe, 'YES'); connect(q4, d_ms, 'NO')

    return nodes, 'Haemoptysis', C_SYSTEM_RS, CH


def chart_chest_pain():
    CH = 310
    root   = node('root',   260, 298, 'CHEST PAIN', 'root', w=140, h=28, fs=10)
    q1     = node('q1',     260, 268, 'Tearing + maximal at onset + back radiation?', 'question', w=175, h=22, fs=6)
    d_ao   = node('d_ao',   110, 235, 'AORTIC DISSECTION', 'redflag', w=130, h=22, fs=7)
    q2     = node('q2',     380, 235, 'Central, crushing >20 min, diaphoresis?', 'question', w=160, h=22, fs=6)
    d_mi   = node('d_mi',   380, 202, 'STEMI / NSTEMI / ACS', 'redflag', w=120, h=22, fs=7)
    q3     = node('q3',     380, 170, 'Exertional, <20 min, relieved by GTN?', 'question', w=160, h=22, fs=6)
    d_ang  = node('d_ang',  380, 138, 'STABLE ANGINA', 'diag', w=115, h=22, fs=7)
    q4     = node('q4',     380, 106, 'Pleuritic + sudden SOB?', 'question', w=145, h=22, fs=7)
    d_pe   = node('d_pe',   380,  74, 'PULMONARY EMBOLISM', 'redflag', w=135, h=22, fs=7)
    q5     = node('q5',     380,  42, 'Sharp + relieved leaning forward?', 'question', w=155, h=22, fs=7)
    d_per  = node('d_per',  200,  74, 'PERICARDITIS', 'diag', w=115, h=22, fs=7)
    d_gerd = node('d_gerd', 200, 42, 'GERD / MUSCULOSKELETAL', 'diag', w=135, h=22, fs=7)

    nodes = [root, q1, d_ao, q2, d_mi, q3, d_ang, q4, d_pe, q5, d_per, d_gerd]
    connect(root, q1)
    connect(q1, d_ao, 'YES'); connect(q1, q2, 'NO')
    connect(q2, d_mi, 'YES'); connect(q2, q3, 'NO')
    connect(q3, d_ang, 'YES'); connect(q3, q4, 'NO')
    connect(q4, d_pe, 'YES'); connect(q4, q5, 'NO')
    connect(q5, d_per, 'YES'); connect(q5, d_gerd, 'NO')

    return nodes, 'Chest Pain', C_SYSTEM_CVS, CH


def chart_palpitations():
    CH = 280
    root   = node('root',   260, 265, 'PALPITATIONS', 'root', w=150, h=28, fs=10)
    q1     = node('q1',     260, 235, 'Irregular rhythm?', 'question', w=135, h=22, fs=7)
    d_af   = node('d_af',   120, 202, 'ATRIAL FIBRILLATION', 'diag', w=130, h=22, fs=7)
    q2     = node('q2',     380, 202, 'Regular + sudden start/stop?', 'question', w=150, h=22, fs=7)
    d_svt  = node('d_svt',  380, 170, 'SVT / AVNRT', 'diag', w=110, h=22, fs=7)
    q3     = node('q3',     380, 138, 'Exertional + syncope?', 'question', w=140, h=22, fs=7)
    d_vt   = node('d_vt',   380, 106, 'VT / HOCM', 'redflag', w=110, h=22, fs=7)
    q4     = node('q4',     380,  74, 'Weight loss + tremor + exophthalmos?', 'question', w=160, h=22, fs=6)
    d_thy  = node('d_thy',  380,  42, 'THYROTOXICOSIS', 'diag', w=120, h=22, fs=7)
    d_anx  = node('d_anx',  220,  74, 'ANXIETY / ANAEMIA / ECTOPICS', 'diag', w=145, h=22, fs=7)

    nodes = [root, q1, d_af, q2, d_svt, q3, d_vt, q4, d_thy, d_anx]
    connect(root, q1)
    connect(q1, d_af, 'YES'); connect(q1, q2, 'NO')
    connect(q2, d_svt, 'YES'); connect(q2, q3, 'NO')
    connect(q3, d_vt, 'YES'); connect(q3, q4, 'NO')
    connect(q4, d_thy, 'YES'); connect(q4, d_anx, 'NO')

    return nodes, 'Palpitations', C_SYSTEM_CVS, CH


def chart_syncope():
    CH = 285
    root   = node('root',   260, 272, 'SYNCOPE (LOC)', 'root', w=145, h=28, fs=10)
    q1     = node('q1',     260, 242, 'Exertional?', 'question', w=125, h=22, fs=7)
    d_hoc  = node('d_hoc',  120, 210, 'HOCM / SEVERE AS / PHT', 'redflag', w=140, h=22, fs=7)
    q2     = node('q2',     380, 210, 'Prodrome (nausea/diaphoresis)?', 'question', w=155, h=22, fs=7)
    d_vvs  = node('d_vvs',  380, 178, 'VASOVAGAL SYNCOPE (benign)', 'diag', w=145, h=22, fs=7)
    q3     = node('q3',     380, 146, 'Postural (standing → faint)?', 'question', w=145, h=22, fs=7)
    d_oh   = node('d_oh',   380, 114, 'ORTHOSTATIC HYPOTENSION', 'diag', w=140, h=22, fs=7)
    q4     = node('q4',     380,  82, 'Sudden, no prodrome (Stokes-Adams)?', 'question', w=158, h=22, fs=6)
    d_chb  = node('d_chb',  380,  50, 'COMPLETE HEART BLOCK / ARRHYTHMIA', 'redflag', w=155, h=22, fs=7)
    d_sei  = node('d_sei',  210,  82, 'SEIZURE (with post-ictal confusion)', 'diag', w=150, h=22, fs=7)

    nodes = [root, q1, d_hoc, q2, d_vvs, q3, d_oh, q4, d_chb, d_sei]
    connect(root, q1)
    connect(q1, d_hoc, 'YES'); connect(q1, q2, 'NO')
    connect(q2, d_vvs, 'YES'); connect(q2, q3, 'NO')
    connect(q3, d_oh, 'YES'); connect(q3, q4, 'NO')
    connect(q4, d_chb, 'YES'); connect(q4, d_sei, 'NO')

    return nodes, 'Syncope', C_SYSTEM_CVS, CH


def chart_oedema():
    CH = 280
    root   = node('root',   260, 265, 'PEDAL OEDEMA', 'root', w=145, h=28, fs=10)
    q1     = node('q1',     260, 235, 'Bilateral pitting?', 'question', w=135, h=22, fs=7)
    # Unilateral
    d_dvt  = node('d_dvt',  110, 202, 'DVT / CELLULITIS / LYMPHOEDEMA', 'diag', w=155, h=22, fs=7)
    # Bilateral
    q2     = node('q2',     390, 202, 'JVP raised + hepatomegaly?', 'question', w=150, h=22, fs=7)
    d_rhf  = node('d_rhf',  390, 170, 'RIGHT HEART FAILURE / CCF', 'diag', w=140, h=22, fs=7)
    q3     = node('q3',     390, 138, 'Massive proteinuria (frothy urine)?', 'question', w=158, h=22, fs=7)
    d_ns   = node('d_ns',   390, 106, 'NEPHROTIC SYNDROME', 'diag', w=130, h=22, fs=7)
    q4     = node('q4',     390,  74, 'Cirrhosis signs + ascites?', 'question', w=145, h=22, fs=7)
    d_cir  = node('d_cir',  390,  42, 'LIVER CIRRHOSIS (portal HTN + hypoalb)', 'diag', w=160, h=22, fs=6)
    d_misc = node('d_misc', 220,  74, 'HYPOALBUMINAEMIA / DRUG / HYPOTHYROIDISM', 'diag', w=160, h=22, fs=6)

    nodes = [root, q1, d_dvt, q2, d_rhf, q3, d_ns, q4, d_cir, d_misc]
    connect(root, q1)
    connect(q1, d_dvt, 'NO'); connect(q1, q2, 'YES')
    connect(q2, d_rhf, 'YES'); connect(q2, q3, 'NO')
    connect(q3, d_ns, 'YES'); connect(q3, q4, 'NO')
    connect(q4, d_cir, 'YES'); connect(q4, d_misc, 'NO')

    return nodes, 'Pedal Oedema', C_SYSTEM_CVS, CH


# ══════════════════════════════════════════════════════════════════════════════
# PAGE BUILDERS
# ══════════════════════════════════════════════════════════════════════════════

def system_header_table(title, subtitle, bg_color, ss):
    data = [[Paragraph(f'<b>{title}</b>', ss['SystemTitle']),
             Paragraph(subtitle, ss['SmallCenter'])]]
    t = Table(data, colWidths=[W - 40*mm, None])
    t.setStyle(TableStyle([
        ('BACKGROUND',   (0,0), (-1,-1), bg_color),
        ('TEXTCOLOR',    (0,0), (-1,-1), C_HEADER_FG),
        ('ROUNDEDCORNERS', [6]),
        ('TOPPADDING',   (0,0), (-1,-1), 6),
        ('BOTTOMPADDING',(0,0), (-1,-1), 6),
        ('LEFTPADDING',  (0,0), (-1,-1), 10),
        ('RIGHTPADDING', (0,0), (-1,-1), 10),
    ]))
    return t


def legend_table(ss):
    items = [
        ("■ ROOT", "#1a3a5c", "Starting symptom"),
        ("■ QUESTION", "#1565c0", "Decision point (Yes/No)"),
        ("■ YES path →", "#2e7d32", "Positive finding leads here"),
        ("■ DIAGNOSIS", "#4a148c", "Final diagnosis reached"),
        ("■ RED FLAG", "#c62828", "Emergency / urgent diagnosis"),
    ]
    rows = []
    for sym, col, desc in items:
        rows.append([
            Paragraph(f'<font color="{col}"><b>{sym}</b></font>', ss['Body8']),
            Paragraph(desc, ss['Body8']),
        ])
    t = Table(rows, colWidths=[60*mm, 80*mm])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), colors.HexColor("#f5f5f5")),
        ('GRID', (0,0), (-1,-1), 0.3, colors.HexColor("#bdbdbd")),
        ('TOPPADDING', (0,0), (-1,-1), 3),
        ('BOTTOMPADDING', (0,0), (-1,-1), 3),
        ('LEFTPADDING', (0,0), (-1,-1), 6),
    ]))
    return t


def make_chart_section(chart_func, ss):
    """Returns a list of flowables for one symptom chart."""
    nodes, title, bg, chart_h = chart_func()
    elems = []

    # Symptom title bar
    title_data = [[Paragraph(f'<b>{title}</b>', ss['SympTitle'])]]
    tt = Table(title_data, colWidths=[W - 40*mm])
    tt.setStyle(TableStyle([
        ('BACKGROUND',   (0,0), (-1,-1), bg),
        ('TOPPADDING',   (0,0), (-1,-1), 5),
        ('BOTTOMPADDING',(0,0), (-1,-1), 5),
        ('LEFTPADDING',  (0,0), (-1,-1), 8),
        ('RIGHTPADDING', (0,0), (-1,-1), 8),
        ('BOX', (0,0), (-1,-1), 0.5, colors.HexColor("#90a4ae")),
        ('ROUNDEDCORNERS', [4]),
    ]))
    elems.append(tt)
    elems.append(Spacer(1, 3*mm))

    # The flowchart drawing
    fc = FlowchartFlowable(nodes, width=W - 40*mm, height=chart_h)
    elems.append(fc)
    elems.append(Spacer(1, 4*mm))
    elems.append(HRFlowable(width="100%", thickness=0.5,
                             color=colors.HexColor("#cfd8dc")))
    elems.append(Spacer(1, 3*mm))

    return elems


# ── Red-flag summary table ─────────────────────────────────────────────────────

def red_flag_table(ss):
    data = [
        [Paragraph('<b>Symptom</b>', ss['SubHead']),
         Paragraph('<b>Red Flag Feature</b>', ss['SubHead']),
         Paragraph('<b>Emergency Diagnosis</b>', ss['SubHead'])],
        ['Abdominal Pain', 'Board-like rigidity, sudden onset', 'Perforation Peritonitis'],
        ['Abdominal Pain', 'Tearing, radiates to back', 'Aortic Dissection'],
        ['Haematemesis', 'Massive bleed + known cirrhosis', 'Variceal Bleed'],
        ['Jaundice', 'Painless + weight loss + Courvoisier', 'Ca Head of Pancreas'],
        ['Dysphagia', 'Progressive solids→liquids, weight loss', 'Ca Oesophagus'],
        ['Weakness', 'Saddle anaesthesia + bladder/bowel', 'Cauda Equina Syndrome'],
        ['Headache', 'Worst headache of life (thunderclap)', 'Subarachnoid Haemorrhage'],
        ['Headache', 'Fever + neck stiffness + Kernig', 'Bacterial Meningitis'],
        ['Cough/Haemoptysis', 'Smoker >40yr + weight loss', 'Lung Carcinoma'],
        ['Breathlessness', 'Sudden + pleuritic + tachycardia', 'Pulmonary Embolism'],
        ['Breathlessness', 'Sudden + absent breath sounds', 'Tension Pneumothorax'],
        ['Chest Pain', 'Tearing, maximal at onset, back rad', 'Aortic Dissection'],
        ['Chest Pain', 'Crushing >20 min, diaphoresis', 'STEMI / ACS'],
        ['Syncope', 'Exertional in young person/athlete', 'HOCM / Severe AS / VT'],
        ['Syncope', 'Sudden, no prodrome, Stokes-Adams', 'Complete Heart Block'],
        ['Fever + Rash', 'Petechial/purpuric rash + meningism', 'Meningococcal Septicaemia'],
    ]
    col_w = [(W-40*mm) * f for f in [0.20, 0.43, 0.37]]
    t = Table(data, colWidths=col_w, repeatRows=1)
    t.setStyle(TableStyle([
        ('BACKGROUND',   (0,0), (-1,0), C_HEADER_BG),
        ('TEXTCOLOR',    (0,0), (-1,0), colors.white),
        ('FONTNAME',     (0,0), (-1,0), 'Helvetica-Bold'),
        ('FONTSIZE',     (0,0), (-1,-1), 8),
        ('ROWBACKGROUNDS', (0,1), (-1,-1),
         [colors.HexColor("#ffebee"), colors.white]),
        ('GRID',         (0,0), (-1,-1), 0.4, colors.HexColor("#e0e0e0")),
        ('TOPPADDING',   (0,0), (-1,-1), 4),
        ('BOTTOMPADDING',(0,0), (-1,-1), 4),
        ('LEFTPADDING',  (0,0), (-1,-1), 5),
        ('RIGHTPADDING', (0,0), (-1,-1), 5),
        ('TEXTCOLOR',    (2,1), (2,-1), C_REDBOX),
        ('FONTNAME',     (2,1), (2,-1), 'Helvetica-Bold'),
    ]))
    return t


# ══════════════════════════════════════════════════════════════════════════════
# MAIN BUILD
# ══════════════════════════════════════════════════════════════════════════════

def build_pdf(out_path):
    ss = make_styles()

    doc = SimpleDocTemplate(
        out_path,
        pagesize=A4,
        leftMargin=20*mm, rightMargin=20*mm,
        topMargin=18*mm, bottomMargin=18*mm,
    )

    story = []

    # ── COVER ──────────────────────────────────────────────────────────────────
    story.append(Spacer(1, 30*mm))
    story.append(Paragraph('DDx FLOWCHARTS', ss['Cover_Title']))
    story.append(Paragraph('Quick Reference for Medicine Posting', ss['Cover_Sub']))
    story.append(Spacer(1, 6*mm))
    story.append(HRFlowable(width="60%", thickness=2, color=C_HEADER_BG))
    story.append(Spacer(1, 6*mm))
    story.append(Paragraph('2nd Year MBBS | History Taking & Differential Diagnosis', ss['Cover_Sub']))
    story.append(Spacer(1, 4*mm))
    story.append(Paragraph(
        'Covers: Gastrointestinal · Neurological · Respiratory · Cardiovascular Systems',
        ss['Cover_Tiny']))
    story.append(Spacer(1, 10*mm))

    # Legend
    story.append(Paragraph('<b>How to read the flowcharts</b>', ss['SubHead']))
    story.append(Spacer(1, 2*mm))
    story.append(legend_table(ss))
    story.append(Spacer(1, 6*mm))
    story.append(Paragraph(
        'At each QUESTION node, follow the GREEN arrow for YES and RED arrow for NO '
        'until you reach a DIAGNOSIS (purple) or RED FLAG (urgent/emergency) node.',
        ss['Body8']))
    story.append(Spacer(1, 8*mm))

    # Cover index
    index_items = [
        ('GIT System',  'Abdominal Pain · Jaundice · Haematemesis · Diarrhoea · Dysphagia'),
        ('CNS System',  'Limb Weakness · Headache'),
        ('Respiratory', 'Cough · Breathlessness · Haemoptysis'),
        ('CVS System',  'Chest Pain · Palpitations · Syncope · Pedal Oedema'),
        ('Summary',     'Red Flag Symptoms Quick Reference Table'),
    ]
    for sys_name, items in index_items:
        story.append(Paragraph(
            f'<b><font color="#1a3a5c">{sys_name}</font></b>  —  {items}',
            ss['Body8']))
        story.append(Spacer(1, 2*mm))

    story.append(PageBreak())

    # ── GIT ────────────────────────────────────────────────────────────────────
    git_title = system_header_table(
        '1. GASTROINTESTINAL SYSTEM', 'Abdominal Pain · Jaundice · Haematemesis · Diarrhoea · Dysphagia',
        C_HEADER_BG, ss)
    story.append(git_title)
    story.append(Spacer(1, 5*mm))

    for fn in [chart_abdominal_pain, chart_jaundice, chart_haematemesis, chart_diarrhoea, chart_dysphagia]:
        story += make_chart_section(fn, ss)

    story.append(PageBreak())

    # ── CNS ────────────────────────────────────────────────────────────────────
    cns_title = system_header_table(
        '2. CENTRAL NERVOUS SYSTEM', 'Limb Weakness · Headache',
        C_HEADER_BG, ss)
    story.append(cns_title)
    story.append(Spacer(1, 5*mm))

    for fn in [chart_weakness, chart_headache]:
        story += make_chart_section(fn, ss)

    story.append(PageBreak())

    # ── RESPIRATORY ────────────────────────────────────────────────────────────
    rs_title = system_header_table(
        '3. RESPIRATORY SYSTEM', 'Cough · Breathlessness · Haemoptysis',
        C_HEADER_BG, ss)
    story.append(rs_title)
    story.append(Spacer(1, 5*mm))

    for fn in [chart_cough, chart_dyspnoea, chart_haemoptysis]:
        story += make_chart_section(fn, ss)

    story.append(PageBreak())

    # ── CVS ────────────────────────────────────────────────────────────────────
    cvs_title = system_header_table(
        '4. CARDIOVASCULAR SYSTEM', 'Chest Pain · Palpitations · Syncope · Pedal Oedema',
        C_HEADER_BG, ss)
    story.append(cvs_title)
    story.append(Spacer(1, 5*mm))

    for fn in [chart_chest_pain, chart_palpitations, chart_syncope, chart_oedema]:
        story += make_chart_section(fn, ss)

    story.append(PageBreak())

    # ── RED FLAG SUMMARY ───────────────────────────────────────────────────────
    rf_header = system_header_table(
        'RED FLAG QUICK REFERENCE', 'Never miss these — Emergency Diagnoses by Symptom',
        C_REDBOX, ss)
    story.append(rf_header)
    story.append(Spacer(1, 5*mm))
    story.append(red_flag_table(ss))
    story.append(Spacer(1, 8*mm))
    story.append(Paragraph(
        '<b>Remember:</b> History alone leads to the correct diagnosis in ~80% of cases. '
        'A red flag symptom = STOP and rule out the emergency first.',
        ss['Body8']))

    # Build
    doc.build(story)
    print(f"PDF written to: {out_path}")


if __name__ == '__main__':
    build_pdf('/tmp/workspace/ddx-flowcharts/DDx_Flowcharts_Medicine_Posting.pdf')
Running Command

cd /tmp/workspace/ddx-flowcharts && python3 generate_pdf.py 2>&1

Running Command

ls -lh /tmp/workspace/ddx-flowcharts/DDx_Flowcharts_Medicine_Posting.pdf && python3 -c " from pypdf import PdfReader r = PdfReader('/tmp/workspace/ddx-flowcharts/DDx_Flowcharts_Medicine_Posting.pdf') print(f'Pages: {len(r.pages)}') for i, p in enumerate(r.pages): t = p.extract_text() print(f' Page {i+1}: {t[:80].strip()[:60]}...' if t else f' Page {i+1}: (graphic only)') "

12 pages, clean structure, all systems present. Here is your PDF:

DDx Flowcharts Medicine Posting

PDF Document · PDF


What's inside (12 pages):
Page(s)Content
1Cover + How to read + Index + Colour legend
2-4GIT System - Abdominal Pain, Jaundice, Haematemesis, Diarrhoea, Dysphagia
5-6CNS System - Limb Weakness, Headache
7-8Respiratory - Cough, Breathlessness, Haemoptysis
9-11CVS System - Chest Pain, Palpitations, Syncope, Pedal Oedema
12Red Flag Quick Reference Table - 17 emergency diagnoses by symptom
How the flowcharts work:
  • Each symptom starts at a dark blue ROOT node
  • At every blue QUESTION node: follow the green arrow for YES, red arrow for NO
  • Reach a purple DIAGNOSIS box or a red EMERGENCY box at the end of each branch
  • The entire approach mirrors exactly how you should think while taking history

Make a checklist PDF of normal vs abnormal examination findings

Asking for Preferences
Writing File

~/ddx-flowcharts/generate_checklist.py

"""
Normal vs Abnormal Examination Findings Checklist PDF
Medicine Posting - 2nd Year MBBS
All 4 Systems: GIT, CNS, Respiratory, CVS
Layout: Finding | Normal | Abnormal | Clinical Significance
"""

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

W, H = A4

# ── Colours ────────────────────────────────────────────────────────────────────
C_NAVY      = colors.HexColor("#1a3a5c")
C_WHITE     = colors.white
C_NORMAL    = colors.HexColor("#e8f5e9")   # light green
C_ABNORMAL  = colors.HexColor("#ffebee")   # light red
C_SIG       = colors.HexColor("#fff8e1")   # light amber
C_SECTION   = colors.HexColor("#e3f2fd")   # light blue - section subheading
C_NORMAL_TXT= colors.HexColor("#1b5e20")   # dark green
C_ABNORM_TXT= colors.HexColor("#b71c1c")   # dark red
C_SIG_TXT   = colors.HexColor("#e65100")   # dark orange

# System accent colours
SYS_GIT = colors.HexColor("#2e7d32")
SYS_CNS = colors.HexColor("#6a1b9a")
SYS_RS  = colors.HexColor("#1565c0")
SYS_CVS = colors.HexColor("#c62828")

# ── Styles ─────────────────────────────────────────────────────────────────────
def make_styles():
    ss = getSampleStyleSheet()

    def add(name, **kw):
        if name not in ss:
            ss.add(ParagraphStyle(name=name, **kw))
        return ss[name]

    add('CoverTitle',  fontName='Helvetica-Bold', fontSize=26,
        textColor=C_NAVY, alignment=TA_CENTER, spaceAfter=6)
    add('CoverSub',    fontName='Helvetica', fontSize=12,
        textColor=colors.HexColor("#455a64"), alignment=TA_CENTER, spaceAfter=4)
    add('CoverTiny',   fontName='Helvetica', fontSize=8,
        textColor=colors.grey, alignment=TA_CENTER, spaceAfter=2)

    add('SysHeader',   fontName='Helvetica-Bold', fontSize=14,
        textColor=C_WHITE, alignment=TA_LEFT, spaceAfter=0, leading=18)
    add('SecHead',     fontName='Helvetica-Bold', fontSize=9,
        textColor=C_NAVY, alignment=TA_LEFT, spaceAfter=0, leading=12)
    add('ColHead',     fontName='Helvetica-Bold', fontSize=8,
        textColor=C_WHITE, alignment=TA_CENTER, spaceAfter=0, leading=10)
    add('Cell',        fontName='Helvetica', fontSize=7.5,
        textColor=colors.HexColor("#212121"), leading=10, spaceAfter=0)
    add('CellBold',    fontName='Helvetica-Bold', fontSize=7.5,
        textColor=C_NAVY, leading=10, spaceAfter=0)
    add('CellNorm',    fontName='Helvetica', fontSize=7.5,
        textColor=C_NORMAL_TXT, leading=10, spaceAfter=0)
    add('CellAbn',     fontName='Helvetica', fontSize=7.5,
        textColor=C_ABNORM_TXT, leading=10, spaceAfter=0)
    add('CellSig',     fontName='Helvetica', fontSize=7,
        textColor=colors.HexColor("#4a148c"), leading=9.5, spaceAfter=0)
    add('Body8',       fontName='Helvetica', fontSize=8,
        textColor=colors.HexColor("#212121"), leading=11, spaceAfter=2)
    add('LegendHead',  fontName='Helvetica-Bold', fontSize=9,
        textColor=C_NAVY, spaceAfter=2)

    return ss

SS = make_styles()

# ── Column widths (A4 usable = W - 40mm = ~515pt) ─────────────────────────────
TW   = W - 40*mm   # total table width ≈ 515 pt
CW   = [TW*0.22, TW*0.19, TW*0.30, TW*0.29]  # Finding | Normal | Abnormal | Significance

# ── Helper builders ────────────────────────────────────────────────────────────

def p(text, style='Cell'):
    return Paragraph(text, SS[style])

def sys_header_block(title, subtitle, accent):
    """Full-width coloured header for each system."""
    data = [[
        Paragraph(f'<b>{title}</b>', SS['SysHeader']),
        Paragraph(subtitle, SS['CoverTiny'])
    ]]
    t = Table(data, colWidths=[TW * 0.6, TW * 0.4])
    t.setStyle(TableStyle([
        ('BACKGROUND',    (0,0), (-1,-1), accent),
        ('TOPPADDING',    (0,0), (-1,-1), 7),
        ('BOTTOMPADDING', (0,0), (-1,-1), 7),
        ('LEFTPADDING',   (0,0), (-1,-1), 10),
        ('RIGHTPADDING',  (0,0), (-1,-1), 10),
        ('VALIGN',        (0,0), (-1,-1), 'MIDDLE'),
        ('TEXTCOLOR',     (0,0), (-1,-1), C_WHITE),
    ]))
    return t

def col_header_row():
    return [
        p('<b>FINDING / TEST</b>', 'ColHead'),
        p('<b>NORMAL</b>', 'ColHead'),
        p('<b>ABNORMAL</b>', 'ColHead'),
        p('<b>CLINICAL SIGNIFICANCE</b>', 'ColHead'),
    ]

def section_row(title):
    """A merged section sub-heading row."""
    return [p(f'  {title}', 'SecHead'), '', '', '']

def row(finding, normal, abnormal, significance):
    return [
        p(finding, 'CellBold'),
        p(normal,  'CellNorm'),
        p(abnormal,'CellAbn'),
        p(significance, 'CellSig'),
    ]

def make_table(data_rows):
    """Assemble a styled table with column header + data rows."""
    all_rows = [col_header_row()] + data_rows
    t = Table(all_rows, colWidths=CW, repeatRows=1)

    # Base style
    style = [
        # Header row
        ('BACKGROUND',    (0,0), (-1,0), C_NAVY),
        ('TEXTCOLOR',     (0,0), (-1,0), C_WHITE),
        ('FONTNAME',      (0,0), (-1,0), 'Helvetica-Bold'),
        ('FONTSIZE',      (0,0), (-1,0), 8),
        ('ALIGN',         (0,0), (-1,0), 'CENTER'),
        ('VALIGN',        (0,0), (-1,-1), 'TOP'),
        ('TOPPADDING',    (0,0), (-1,-1), 3),
        ('BOTTOMPADDING', (0,0), (-1,-1), 3),
        ('LEFTPADDING',   (0,0), (-1,-1), 4),
        ('RIGHTPADDING',  (0,0), (-1,-1), 4),
        ('GRID',          (0,0), (-1,-1), 0.35, colors.HexColor("#bdbdbd")),
        ('ROWBACKGROUNDS',(0,1), (-1,-1), [C_WHITE, colors.HexColor("#f9f9f9")]),
    ]

    # Section rows: merge + highlight
    for i, r in enumerate(data_rows, start=1):
        if r[1] == '' and r[2] == '' and r[3] == '':
            style += [
                ('SPAN',       (0,i), (3,i)),
                ('BACKGROUND', (0,i), (3,i), C_SECTION),
                ('FONTNAME',   (0,i), (3,i), 'Helvetica-Bold'),
            ]

    t.setStyle(TableStyle(style))
    return t


# ══════════════════════════════════════════════════════════════════════════════
# DATA: GIT SYSTEM
# ══════════════════════════════════════════════════════════════════════════════

def git_general_data():
    return [
        section_row('GENERAL EXAMINATION'),
        row('Built & Nourishment',
            'Normal BMI (18.5-24.9)\nAdequate subcutaneous fat\nNormal mid-arm circumference',
            'Cachexia / wasting\nObesity (BMI >30)\nLow waist-hip ratio',
            'Cachexia → malignancy, TB, cirrhosis, IBD\nObesity → NAFLD, gallstones, DM'),
        row('Pallor',
            'Pink conjunctivae\nPink tongue and palms',
            'Pale conjunctivae\nPale tongue / palmar creases',
            'GI bleed (haematemesis, melaena)\nMalabsorption (Fe, B12, folate)\nAncylostomiasis'),
        row('Icterus (Jaundice)',
            'White sclerae\nNormal skin colour',
            'Yellow sclerae (earliest sign)\nYellow skin, mucous membranes',
            'Pre-hepatic / Hepatic / Post-hepatic jaundice\nSclerae go yellow first (high elastin content)'),
        row('Cyanosis',
            'Pink lips and tongue (central)\nWarm pink periphery',
            'Central: bluish tongue / lips\nPeripheral: bluish fingertips',
            'Central cyanosis with GI → hepatopulmonary syndrome\nAlpha-1 AT deficiency (emphysema + cirrhosis)'),
        row('Clubbing',
            'Normal nail fold angle <160°\nNo fluctuance',
            'Loss of nail fold angle >180°\nFluctuation of nail bed\nDrum-stick appearance',
            'GI causes: Crohn\'s, UC, cirrhosis, coeliac\nSchamroth sign: diamond gap lost'),
        row('Lymphadenopathy',
            'Not palpable',
            'Palpable nodes: soft/hard, tender/non-tender\nLeft supraclavicular (Virchow\'s node)',
            'Virchow\'s node (Troisier\'s sign) → GI malignancy\nHard non-tender → metastatic carcinoma'),
        row('Pedal Oedema',
            'No pitting on pressure',
            'Pitting oedema: bilateral/unilateral\nDepth graded 1+ to 4+',
            'Bilateral: liver cirrhosis (hypoalb + portal HTN)\nNephrotic, cardiac, nutritional'),

        section_row('SIGNS OF LIVER FAILURE'),
        row('Spider Naevi',
            'Absent (may have 1-5 in normal individuals)',
            '>5 spider naevi, especially upper trunk',
            'Portal hypertension / cirrhosis\nOestrogen excess (liver cannot metabolise)\nAlso in pregnancy'),
        row('Palmar Erythema',
            'Normal palm colour',
            'Erythema of thenar/hypothenar eminences\n(spares palm centre)',
            'Liver cirrhosis, RA, thyrotoxicosis, pregnancy\nVasodilation from elevated oestrogen'),
        row('Gynaecomastia',
            'No breast tissue in males',
            'Palpable glandular breast tissue in males',
            'Cirrhosis (↑ oestrogen)\nAlso: spironolactone, digoxin, cimetidine'),
        row('Leukonychia (White Nails)',
            'Pink nail beds',
            'Diffuse white discolouration of nails',
            'Hypoalbuminaemia (cirrhosis, nephrotic)\nMuehrcke\'s lines = parallel white bands'),
        row('Dupuytren\'s Contracture',
            'Full finger extension',
            'Flexion contracture of ring/little finger\nThickened palmar fascia',
            'Alcoholic liver disease\nAlso: DM, trauma, epileptic drugs'),
        row('Flapping Tremor (Asterixis)',
            'No flapping on outstretched hands',
            'Coarse, irregular flapping when wrists extended',
            'Hepatic encephalopathy (NH3 accumulation)\nAlso: CO2 retention, uraemia'),
        row('Parotid Enlargement',
            'Non-palpable',
            'Bilateral painless parotid enlargement',
            'Alcoholic liver disease (nutritional deficiency)\nAlso: mumps, Sjogren\'s, bulimia'),
        row('Testicular Atrophy',
            'Normal testicular size',
            'Reduced testicular volume',
            'Cirrhosis → hypothalamo-pituitary axis suppression'),
        row('Alopecia (in liver disease)',
            'Normal scalp hair',
            'Diffuse hair loss',
            'Zinc / nutritional deficiency in cirrhosis'),

        section_row('ABDOMINAL INSPECTION'),
        row('Shape of Abdomen',
            'Scaphoid (slightly concave) or flat in lying position',
            'Distended uniformly → ascites, obstruction\nLocalised bulge → hernia, mass, organomegaly\nEverted umbilicus → ascites',
            'Uniform distension with full flanks → ascites\nCentral distension → intestinal obstruction'),
        row('Skin over Abdomen',
            'Normal colour, no dilated veins\nNo scars or sinuses',
            'Caput medusae (dilated veins radiating from umbilicus)\nStretched shiny skin → ascites\nStriae',
            'Caput medusae → portal HTN (flow away from umbilicus)\nSVC obstruction: flow downward\nIVC obstruction: flow upward'),
        row('Umbilicus',
            'Central, inverted',
            'Everted → raised intra-abdominal pressure (ascites, mass)\nShifted → organomegaly, mass',
            'Everted umbilicus with distension → ascites / large mass'),
        row('Visible Peristalsis',
            'Not visible',
            'Visible gastric peristalsis (left to right)\nLadder pattern (intestinal)',
            'Gastric outlet obstruction (pyloric stenosis)\nIntestinal obstruction'),
        row('Visible Pulsations',
            'Epigastric pulsation may be normal in thin individuals',
            'Prominent, visible epigastric pulsation',
            'Aortic aneurysm\nRight ventricular hypertrophy (transmitted pulsation)'),

        section_row('ABDOMINAL PALPATION'),
        row('Tenderness',
            'No tenderness on palpation',
            'Localised: RIF (appendicitis), RUQ (cholecystitis), epigastric (PUD)\nGuarding: voluntary/involuntary muscle contraction\nRigidity: board-like, involuntary',
            'Guarding → peritoneal irritation\nRigidity → peritonitis\nRebound tenderness (Blumberg) → peritoneal involvement'),
        row('Liver',
            'Not palpable below costal margin OR just palpable at end of deep inspiration\nUpper border: 5th ICS (right mid-clavicular line)',
            'Palpable >2 cm below costal margin\nRCML or crossed midline\nTender / pulsatile / nodular / hard',
            'Tender hepatomegaly: hepatitis, CCF (congestive), liver abscess\nPulsatile liver: tricuspid regurgitation\nNodular hard: cirrhosis, metastases'),
        row('Spleen',
            'Not palpable',
            'Palpable below left costal margin\nNotched edge, moves to RIF on inspiration\nCannot insunate fingers between mass and costal margin',
            'Mild: 1-3 cm → infection (EBV, malaria, typhoid), CCF\nModerate: 3-8 cm → haemolysis, cirrhosis\nMassive: >8 cm → CML, Kala-azar, myelofibrosis'),
        row('Kidney',
            'Not palpable normally (right may be just palpable in thin individuals)',
            'Bimanually palpable, ballotable\nBand of colonic resonance anterior to mass',
            'Renal cell carcinoma, polycystic kidneys, hydronephrosis\nBand of resonance distinguishes kidney from spleen'),
        row('Murphy\'s Sign',
            'Negative: no arrest of inspiration on deep pressure RUQ',
            'Positive: arrest of inspiration on pressure over gallbladder',
            'Acute cholecystitis (sensitivity 65%, specificity 87%)'),
        row('McBurney\'s Tenderness',
            'No tenderness at McBurney\'s point (1/3 from ASIS to umbilicus)',
            'Maximum tenderness at McBurney\'s point',
            'Acute appendicitis\nRovsing\'s sign: pain at RIF on palpating LIF'),

        section_row('ABDOMINAL PERCUSSION'),
        row('Liver Span',
            'Normal liver span: 8-12 cm in right MCL by percussion',
            '<8 cm: small liver (cirrhosis end-stage, fulminant failure)\n>12 cm: hepatomegaly',
            'Dull percussion over 5th ICS to lower costal margin = liver'),
        row('Shifting Dullness',
            'Absent: flanks remain resonant on turning',
            'Present: dullness shifts to dependent flank on turning patient',
            'Ascites: needs >500 mL fluid to elicit shifting dullness\nSensitivity ~83%'),
        row('Fluid Thrill',
            'Absent',
            'Present: transmitted wave felt on opposite flank',
            'Tense ascites: large volume\nMore specific than shifting dullness\nAssistant\'s hand on mid-abdomen to prevent fat wave'),
        row('Traube\'s Space',
            'Resonant (air in gastric fundus and splenic flexure)',
            'Dull',
            'Splenomegaly obliterates Traube\'s space (9th-11th rib, left side)\nAlso dull: left pleural effusion, full stomach'),

        section_row('ABDOMINAL AUSCULTATION'),
        row('Bowel Sounds',
            '3-5 sounds/minute, small bowel\nHigh-pitched, gurgling',
            'Increased, high-pitched (tinkling)\nHyperactive\nAbsent (silent abdomen)',
            'Tinkling: early intestinal obstruction\nHyperactive: diarrhoea, gastroenteritis\nAbsent: paralytic ileus, peritonitis'),
        row('Venous Hum',
            'Absent',
            'Soft hum in epigastrium',
            'Portal hypertension: Cruveilhier-Baumgarten syndrome\nRecanalized umbilical vein'),
        row('Bruit',
            'Absent',
            'Hepatic bruit: hepatoma (systolic)\nSplenic bruit: haemangioma\nRenal bruit: renal artery stenosis\nAortic bruit: aneurysm',
            'Hepatoma bruit → hepatocellular carcinoma\nRenal bruit → renovascular hypertension'),
    ]

# ══════════════════════════════════════════════════════════════════════════════
# DATA: CNS SYSTEM
# ══════════════════════════════════════════════════════════════════════════════

def cns_general_data():
    return [
        section_row('HIGHER MENTAL FUNCTIONS'),
        row('Consciousness & Orientation',
            'Alert, oriented to Time/Place/Person\nGCS 15/15',
            'Confused, disoriented\nDrowsy / stuporous / comatose\nGCS <15',
            'Reduced GCS → brain injury, metabolic (hepatic, uraemic, DKA), structural\nAcute confusional state → meningitis, encephalitis, drugs'),
        row('Memory',
            'Immediate: recalls 3 words at 1 min\nRecent: recalls events of past days\nRemote: recalls distant events\nAll intact',
            'Immediate loss → frontal lobe\nRecent loss: earliest in Alzheimer\'s\nRemote loss: late dementia\nKorsakoff: recent loss + confabulation',
            'Hippocampus: recent memory\nFrontal lobe: working memory\nKorsakoff\'s → thiamine deficiency (Wernicke\'s)'),
        row('Speech',
            'Fluent, normal comprehension\nNormal naming, repetition\nNormal writing and reading',
            'Broca\'s aphasia: non-fluent, comprehension intact\nWernicke\'s: fluent, comprehension impaired, jargon speech\nDysarthria: slurred but language content normal',
            'Broca\'s area: posterior inferior frontal gyrus\nWernicke\'s: posterior superior temporal gyrus\nDysarthria: cerebellar, bulbar palsy, pseudobulbar'),

        section_row('CRANIAL NERVES'),
        row('CN I - Olfactory',
            'Identifies familiar odours bilaterally',
            'Anosmia (unilateral / bilateral)',
            'Unilateral: olfactory groove meningioma, anterior fossa fracture\nBilateral: Parkinson\'s (early), COVID-19, Kallmann\'s'),
        row('CN II - Optic',
            'Visual acuity 6/6 or 20/20\nNormal colour vision\nFull visual fields\nSharp disc margins on fundoscopy',
            'Reduced acuity / field defect\nPapilloedema (blurred disc margins)\nOptic atrophy (pale disc)',
            'Papilloedema → raised ICP (bilateral)\nOptic neuritis → MS (unilateral, painful)\nBitemporal hemianopia → pituitary adenoma'),
        row('CN III, IV, VI - Oculomotor',
            'Full and conjugate extraocular movements\nPupils equal, round, reactive to light (PERLA)\nNo ptosis or diplopia\nNo nystagmus',
            'Ptosis, dilated pupil, "down and out" eye → CN III palsy\nCN VI: medial deviation, diplopia on lateral gaze\nHorner\'s: ptosis + miosis + anhidrosis',
            'CN III: posterior communicating artery aneurysm, tentorial herniation, DM (pupil-sparing)\nHorner\'s → pancoast tumour, carotid dissection'),
        row('CN V - Trigeminal',
            'Normal facial sensation (all 3 divisions)\nNormal muscles of mastication, jaw deviates to midline',
            'Facial sensory loss in dermatomal distribution\nJaw deviation on opening (towards side of lesion - LMN)',
            'Trigeminal neuralgia: lancinating, trigger zones\nAcoustic neuroma compresses V at CPA\nJaw deviates to side of LMN lesion (weak pterygoid)'),
        row('CN VII - Facial',
            'Symmetrical facial expressions\nForehead wrinkles bilaterally on raising eyebrows\nTaste intact anterior 2/3 tongue',
            'LMN: entire face involved (forehead + lower)\nUMN: lower face only (forehead spared)\nLoss of taste anterior 2/3',
            'LMN facial palsy: Bell\'s palsy (HSV), Ramsay Hunt (VZV), parotid tumour, acoustic neuroma\nUMN: stroke (contralateral)'),
        row('CN VIII - Vestibulocochlear',
            'Hears whispered voice at 60 cm\nRinne: AC > BC (positive)\nWeber: no lateralisation',
            'Rinne negative (BC > AC) → conductive loss\nWeber lateralises: to deaf ear (conductive) or to good ear (SNHL)\nNystagmus (vestibular component)',
            'SNHL: acoustic neuroma, aminoglycoside toxicity, Meniere\'s\nConductive: otosclerosis, otitis media\nMeniere\'s: episodic vertigo + tinnitus + low-freq SNHL'),
        row('CN IX, X - Glossopharyngeal/Vagus',
            'Normal gag reflex\nUvula midline\nNormal palatal movement\nNormal swallowing\nNormal voice',
            'Absent gag (IX afferent, X efferent)\nUvula deviates away from lesion side (UMN) or towards lesion side (LMN)\nNasal voice, nasal regurgitation',
            'Bulbar palsy (LMN): MND, GBS, diphtheria, syringobulbia\nPseudoBulbar (UMN): stroke, MS, MND → brisk gag, dysarthria + dysphagia'),
        row('CN XI - Spinal Accessory',
            'Turns head against resistance (SCM)\nShrugs shoulder against resistance (trapezius)',
            'Weakness of head turning or shoulder shrugging',
            'Neck dissection injury\nForamen magnum / posterior fossa tumour'),
        row('CN XII - Hypoglossal',
            'Tongue midline, no wasting\nNormal tongue movements',
            'LMN: tongue deviates to side of lesion, wasting, fasciculations\nUMN: spastic tongue, deviates away',
            'LMN: medullary infarct, hypoglossal canal neuroma, MND\nBilateral: motor neurone disease, pseudobulbar palsy'),

        section_row('MOTOR SYSTEM'),
        row('Muscle Tone',
            'Normal tone: gentle resistance throughout range of movement',
            'Hypotonia: floppy, pendular reflexes (LMN, cerebellar)\nSpasticity: velocity-dependent, clasp-knife (UMN)\nRigidity: constant resistance throughout range\n  - Lead-pipe: Parkinson\'s\n  - Cogwheel: Parkinson\'s + tremor',
            'Spasticity → UMN (corticospinal)\nLead-pipe rigidity → Parkinson\'s (extrapyramidal)\nClasp-knife phenomenon: spinal cord injury'),
        row('Muscle Power (MRC Scale)',
            'MRC Grade 5: full power against resistance in all muscle groups\nSymmetrical',
            'Grade 0: no movement\nGrade 1: flicker\nGrade 2: movement only with gravity eliminated\nGrade 3: moves against gravity\nGrade 4: reduced power against resistance\nGrade 5-: just under normal',
            'Proximal weakness (4, 3) → myopathy\nDistal weakness → neuropathy\nHemi pattern → UMN (stroke, SOL)\nPara pattern → spinal cord'),
        row('Deep Tendon Reflexes',
            'Grade 2+ (normal) in all limbs\nSymmetrical\nBiceps C5-6, Triceps C7, Knee L3-4, Ankle S1-2',
            'Hyperreflexia (3+ or 4+) → UMN lesion\nHyporeflexia / areflexia → LMN, peripheral neuropathy, GBS\nSpread of reflex: corticospinal lesion\nClonus (>5 beats) → UMN',
            'UMN signs: ↑ tone + ↑ reflexes + ↑ plantar\nLMN signs: ↓ tone + ↓ reflexes + ↓ power + wasting + fasciculations'),
        row('Plantar Response',
            'Flexor plantar: toes curl downward on stroking outer sole',
            'Extensor plantar (Babinski sign): big toe extends, other toes fan out',
            'Positive Babinski → UMN lesion (corticospinal tract)\nNormal in infants <18 months\nElicited by stroking outer sole lateral to medial'),
        row('Superficial Reflexes',
            'Abdominal reflex: contraction of abdominal muscles\nCremasteric reflex present in males\nAnal reflex: anal wink on perianal scratch',
            'Absent abdominal reflex: UMN lesion (MS, cord lesion)\nAbsent cremasteric: UMN or inguinal surgery\nAbsent anal reflex: cauda equina lesion',
            'Abdominal reflex lost in 50% of MS patients\nLoss of anal reflex → cauda equina emergency'),

        section_row('SENSORY SYSTEM'),
        row('Touch / Pain / Temperature',
            'Normal touch, pain, temperature perception\nSymmetrical in all dermatomes',
            'Loss in dermatomal pattern → nerve root\nGlove-stocking loss → peripheral neuropathy\nHemisensory loss → thalamic/cortical\nSplit sensory loss → syringomyelia',
            'Syringomyelia: suspended sensory loss (cape distribution), pain + temperature lost, touch preserved\nBrown-Sequard: ipsilateral motor + proprioception, contralateral pain + temperature'),
        row('Vibration Sense',
            'Feels vibration of 128 Hz tuning fork at malleoli, patella, ASIS, sternum',
            'Loss at feet: peripheral neuropathy, dorsal column disease',
            'Dorsal columns carry vibration + joint position sense (ipsilateral)\nDiabetic neuropathy, B12 deficiency, tabes dorsalis'),
        row('Joint Position Sense (JPS)',
            'Correctly identifies up/down movements of toes/fingers',
            'Loss of JPS: positive Romberg\'s sign\nPseudoathetosis (writhing movements of hands with eyes closed)',
            'Posterior column disease (B12, tabes, SACD)\nRomberg positive: ataxia worse in dark, vestibular or cerebellar'),

        section_row('CEREBELLAR SIGNS'),
        row('Nystagmus',
            'Absent at rest and on gaze in all directions',
            'Horizontal nystagmus: fast phase away from lesion side\nVertical nystagmus: brainstem\nBidirectional: drugs (phenytoin)',
            'Cerebellar nystagmus: fast phase to side of lesion (ipsilateral)\nBrainstem: vertical or direction-changing nystagmus'),
        row('Dysmetria / Intention Tremor',
            'Smooth, accurate finger-nose-finger test\nHeel-shin test smooth',
            'Past-pointing on FNF (intention tremor, overshooting)\nHeel-shin: zig-zag path',
            'Ipsilateral cerebellar lesion → ipsilateral dysmetria\nIncrease as finger approaches target = intention tremor'),
        row('Dysdiadochokinesia',
            'Rapid alternating movements smooth and regular',
            'Irregular, clumsy rapid alternating movements',
            'Cerebellar lesion (ipsilateral)\nTest: rapid pronation-supination of hands'),
        row('Rebound Phenomenon',
            'Arm returns smoothly to position after resistance released',
            'Overshoot on release of resistance',
            'Cerebellar disease: lack of check reflex\nTest: pull arm against resistance, then suddenly release'),
        row('Gait',
            'Narrow-based, coordinated, normal heel-toe walking\nAble to tandem walk (heel-to-toe in straight line)',
            'Wide-based, ataxic, staggering gait → cerebellar\nSpastic, scissor gait → UMN bilateral\nSteppage gait → foot drop (LMN / peroneal nerve)\nParkinsonian: shuffling, festinant, reduced arm swing\nSensory ataxia: stamping, worse in dark',
            'Wide-based cerebellar gait: "drunk walk"\nParkinsonian gait: en-bloc turning, freezing, propulsion\nWaddling gait: proximal myopathy'),

        section_row('MENINGEAL SIGNS'),
        row('Neck Stiffness',
            'Full range of passive neck flexion without resistance',
            'Resistance to passive neck flexion\nNuchal rigidity',
            'Meningitis (bacterial, viral, TB, fungal)\nSAH (blood in CSF causes meningism)\nNot present in encephalitis alone'),
        row('Kernig\'s Sign',
            'Negative: can extend knee when hip flexed 90°',
            'Positive: pain and resistance to knee extension when hip at 90°',
            'Meningeal irritation → sensitivity ~27%, specificity ~95% for meningitis'),
        row('Brudzinski\'s Sign',
            'Negative: passive neck flexion does not flex hips',
            'Positive: involuntary hip and knee flexion on passive neck flexion',
            'Meningeal irritation (meningitis, SAH)\nMore sensitive than Kernig\'s in adults'),
    ]

# ══════════════════════════════════════════════════════════════════════════════
# DATA: RESPIRATORY SYSTEM
# ══════════════════════════════════════════════════════════════════════════════

def rs_general_data():
    return [
        section_row('GENERAL & VITAL SIGNS'),
        row('Respiratory Rate',
            'Adult: 12-18 breaths/minute\nRegular rhythm\nThoracoabdominal pattern',
            'Tachypnoea (>20/min): respiratory failure, fever, PE, metabolic acidosis\nBradypnoea (<12/min): CNS depression, opioid\nCheyne-Stokes: alternating hyperpnoea-apnoea\nKussmaul: deep, regular, rapid - DKA',
            'Tachypnoea is the most sensitive indicator of respiratory distress\nKussmaul breathing → metabolic acidosis (compensatory)'),
        row('Cyanosis',
            'Peripheral SpO2 >95%\nPink lips and tongue',
            'Central cyanosis: bluish tongue (SpO2 <85%)\nPeripheral: cold blue periphery with normal tongue',
            'Central cyanosis: V/Q mismatch, right-to-left shunt, hypoventilation\nPeripheral: vasoconstriction, cardiac failure, Raynaud\'s'),
        row('Clubbing',
            'Nail fold angle <160°, no fluctuation',
            'Increased nail fold angle, fluctuant nail bed\nCurved nails (watch-glass)\nDrum-stick fingers',
            'RS causes: lung carcinoma, mesothelioma, ILD, bronchiectasis, lung abscess, empyema\nNOT in COPD/asthma/PE'),
        row('Jugular Venous Pressure',
            '<4 cm above sternal angle at 45° (normal JVP)\nInspiratory fall in JVP (Kussmaul negative)',
            'Raised JVP: distended veins at 45°\nKussmaul\'s sign: JVP rises on inspiration',
            'Raised JVP in RS → cor pulmonale (right heart failure from lung disease)\nKussmaul\'s sign → constrictive pericarditis, severe RHF'),

        section_row('UPPER RESPIRATORY TRACT'),
        row('Nasal / Oral Cavity',
            'Clear nostrils, no DNS\nNormal tonsils, no discharge\nClean oral hygiene',
            'Flaring alae nasi: accessory muscle use in respiratory distress\nDeviated nasal septum\nPost-nasal drip, tonsillar enlargement\nOral candidiasis → HIV/immunosuppression',
            'Flaring alae nasi: significant respiratory distress\nPost-nasal drip → chronic cough'),
        row('Trachea',
            'Midline position on inspection and palpation',
            'Tracheal deviation:\nTowards lesion: collapse, fibrosis, pneumonectomy\nAway from lesion: large effusion, tension pneumothorax\nTracheal tug: severe dyspnoea',
            'Tracheal shift is crucial to determine the pathological side\nTracheal tug (Campbell\'s sign) → severe airflow obstruction'),

        section_row('CHEST INSPECTION'),
        row('Shape of Chest',
            'Elliptical, AP < transverse diameter\nSymmetrical\nNormal subcostal angle',
            'Barrel chest: AP ≥ transverse, horizontal ribs, ↑ subcostal angle\nPectus excavatum (funnel chest): depressed sternum\nPectus carinatum (pigeon chest): protruded sternum\nKyphoscoliosis: restrictive lung disease',
            'Barrel chest → emphysema/COPD (hyperinflation)\nKyphoscoliosis → restrictive defect (reduces lung volume)'),
        row('Chest Wall Movements',
            'Equal and symmetrical in all zones\nNormal expansion: 5-7 cm circumference increase',
            'Reduced on one side → pathology on that side (effusion, collapse, consolidation, pneumothorax)\nParadoxical breathing → flail chest\nAccessory muscle use: SCM, scalenes in distress',
            'Side with REDUCED movement = PATHOLOGICAL side\nParadoxical: segment moves in on inspiration = flail chest'),
        row('Intercostal Spaces',
            'Normal, symmetrical',
            'Bulging ICS: large pleural effusion, tension pneumothorax\nSunken / crowded ICS: collapse or old fibrosis',
            'Bulging ICS with trachea away → large effusion / tension pneumothorax'),

        section_row('CHEST PALPATION'),
        row('Chest Expansion (Palpation)',
            'Equal bilateral expansion of 5-7 cm\nSymmetrical finger movement on inspiration',
            'Reduced unilateral expansion: consolidation, collapse, effusion, pneumothorax, fibrosis',
            'The side with REDUCED expansion = diseased side'),
        row('Tactile Vocal Fremitus (TVF)',
            'Moderate, equal vibration felt bilaterally\nDecrease from apex to base normally',
            'Increased TVF: consolidation (sound conducted better through solid lung)\nDecreased / absent: pleural effusion (fluid blocks), pneumothorax (air), collapse',
            'TVF and VR (vocal resonance on auscultation) always change together\nIncreased = consolidation; Decreased = fluid/air/collapse'),
        row('Apex Beat (in chest exam)',
            'Felt in 5th ICS, mid-clavicular line, left side',
            'Displaced to right: left-sided push lesion (left effusion, left pneumothorax)\nDisplaced to left: left-sided pull or right-sided push',
            'Cor pulmonale may have RV heave (left parasternal)\nDeviation helps confirm tracheal shift side'),

        section_row('CHEST PERCUSSION'),
        row('Percussion Note',
            'Resonant over all lung fields\nDull over liver (5th ICS right)\nCardiac dullness (left 2nd-5th ICS)',
            'Dull: consolidation (lobar pneumonia), pleural effusion, collapse\nStony dull: pleural effusion (differentiated from consolidation)\nHyper-resonant: pneumothorax, emphysema',
            'Stony dull = pleural fluid (stone-like percussion note)\nHyper-resonant = air (pneumothorax)\nLobar pneumonia: dull + bronchial breathing + crackles + ↑ VR'),
        row('Upper Border of Liver Dullness',
            '5th ICS in right mid-clavicular line',
            'Raised: right lower lobe collapse / consolidation pushing liver up\nLowered: emphysema (hyperinflation), pneumothorax, interposition',
            'In COPD: liver pushed down, resonance extends below 5th ICS\nKronig\'s isthmus: band of resonance over apex (narrowed in TB)'),
        row('Shifting Dullness / Tidal Percussion',
            'Absent shifting dullness (no pleural fluid)',
            'Present shifting dullness → pleural effusion',
            'Tidal percussion: dullness rises with deep inspiration = confirmatory of effusion'),

        section_row('CHEST AUSCULTATION'),
        row('Breath Sounds',
            'Vesicular breath sounds: soft, rustling, inspiratory > expiratory, no pause between phases',
            'Bronchial breathing: loud, harsh, equal I:E, pause between phases, high-pitched (tubular)\nReduced/absent breath sounds: effusion, pneumothorax, collapse\nBronchovesicular: over manubrium, right apex normally',
            'Bronchial breathing → consolidation, large cavity (TB), upper lobe collapse (central)\nAbsent BS → pleural effusion, large pneumothorax'),
        row('Added Sounds - Crackles (Crepitations)',
            'Absent',
            'Fine crackles: dry, high-pitched, end-inspiratory (Velcro-like)\nCoarse crackles: bubbling, low-pitched\nPost-tussive crackles: appear after coughing\nCreeky crackles: pleural rub (can sound like crackles)',
            'Fine crackles (basal): pulmonary fibrosis (ILD), pulmonary oedema\nCoarse crackles: bronchiectasis, resolving pneumonia\nPost-tussive: bronchiectasis (clear with coughing)'),
        row('Added Sounds - Rhonchi / Wheeze',
            'Absent',
            'Expiratory wheeze: polyphonic (asthma, COPD)\nMonophonic wheeze: single obstructed bronchus (carcinoma, FB)\nInspiratory stridor: upper airway obstruction',
            'Polyphonic = multiple airways affected (asthma)\nMonophonic = single site (carcinoma, foreign body, mucus plug)\nStridor → laryngeal / tracheal obstruction → emergency'),
        row('Vocal Resonance (VR)',
            'Normal: muffled, low-pitched voice transmission\nSymmetrical bilaterally',
            'Increased VR: consolidation\nDecreased VR: effusion, pneumothorax\nWhispering pectoriloquy: "99" whispered heard clearly through consolidation\nAegophony: bleating / nasal quality at upper border of effusion\nBronchophony: "99" loudly transmitted through consolidation',
            'Aegophony: E-to-A change (sounds like "ay" instead of "eee") at effusion upper border\nWhispering pectoriloquy: most specific sign of consolidation'),
        row('Pleural Rub',
            'Absent',
            'Creaking, leathery sound, heard in both inspiration and expiration\nLocalised, does not clear with coughing',
            'Pleuritis: pneumonia, PE + infarction, TB, malignancy, SLE\nAlways implies parietal + visceral pleura friction (inflammation)'),
    ]

# ══════════════════════════════════════════════════════════════════════════════
# DATA: CVS SYSTEM
# ══════════════════════════════════════════════════════════════════════════════

def cvs_general_data():
    return [
        section_row('GENERAL EXAMINATION - CVS SPECIFIC'),
        row('Cyanosis',
            'Pink lips and tongue\nWarm pink periphery\nSpO2 >95%',
            'Central: tongue + lips blue\nPeripheral: cold blue extremities, warm trunk\nDifferential cyanosis: blue feet, pink hands (PDA with Eisenmenger)',
            'Differential cyanosis → PDA with reversed (R-to-L) shunt: lower body from PA (deoxygenated), upper from aorta\nCentral → Eisenmenger\'s, fallot, severe LVF'),
        row('Clubbing',
            'No clubbing (normal nail fold angle <160°)',
            'Bilateral pandigital clubbing: all 4 limbs\nBilateral fingers only: some CHD\nUnilateral right hand: subclavian involvement',
            'CVS causes: cyanotic CHD (Fallot, Eisenmenger), infective endocarditis, bacterial\nNot in non-cyanotic CHD unless IE develops'),
        row('Pedal Oedema',
            'No pitting on tibial pressure\nNo sacral oedema',
            'Pitting: bilateral, graded 1+-4+\nSacral (bedridden patients)\nAscites with bilateral LL oedema',
            'Bilateral pedal oedema with raised JVP + hepatomegaly = RHF/CCF\nSacral oedema = specific to bedbound CCF patients'),
        row('Xanthelasma / Xanthomas',
            'No lipid deposits around eyes or tendons',
            'Xanthelasma: yellow plaques at medial canthus of eyelids\nTendon xanthomas: Achilles, extensor tendons\nArcus senilis: white ring at corneal periphery',
            'Xanthelasma → hypercholesterolaemia (familial or secondary)\nArcus senilis >45yr → premature atherosclerosis\nAll are markers of dyslipidaemia → increased CAD risk'),
        row('Marfan\'s Habitus',
            'Normal arm span ≤ height\nUpper segment = Lower segment\nNormal thumb/wrist sign',
            'Arm span > height\nLower segment > upper segment\nPositive Steinberg thumb sign (thumb protrudes beyond ulnar border)\nPositive Walker-Murdoch wrist sign',
            'Marfan\'s → aortic root dilatation, aortic regurgitation, MVP\nHigh risk of aortic dissection'),

        section_row('VITAL SIGNS - CVS'),
        row('Pulse - Rate',
            '60-100/min (resting adult)',
            'Tachycardia >100: AF, SVT, VT, fever, anaemia, thyrotoxicosis, CCF\nBradycardia <60: complete heart block, sinus node disease, athletes, hypothyroid, beta-blockers',
            'Sudden tachycardia at rest → arrhythmia\nPulse deficit (apex > radial pulse) → AF'),
        row('Pulse - Rhythm',
            'Regular',
            'Irregularly irregular: AF (no two intervals equal)\nRegularly irregular: ectopics, Wenckebach (2nd degree AVB)\nPulsus bigeminus: every second beat is ectopic',
            'AF: most common sustained arrhythmia\nApex > radial pulse = pulse deficit = AF\nWenckebach: progressively longer PR → dropped beat'),
        row('Pulse - Volume',
            'Normal volume: moderate, symmetrical',
            'High volume (bounding): AR, PDA, fever, thyrotoxicosis, hyperdynamic states\nLow volume (thready): shock, cardiac tamponade, severe AS\nPulsus paradoxus: volume falls >10 mmHg on inspiration',
            'Bounding pulse → aortic regurgitation (AR)\nThready pulse → cardiogenic / hypovolaemic shock\nPulsus paradoxus → tamponade, severe asthma, constrictive pericarditis'),
        row('Pulse - Character',
            'Normal (dicrotic notch not palpable)',
            'Slow-rising (pulsus parvus et tardus): severe AS\nCollapsing (water-hammer): AR, PDA, AV fistula\nBisferiens pulse: two peaks per beat - AR + AS or HOCM\nDicrotic: bigeminy appearance - dilated cardiomyopathy, fever',
            'Water-hammer pulse: felt at radial artery raised above heart level\nQuincke\'s pulsation (nail bed) → AR\nDuroziez\'s sign (femoral bruit) → AR'),
        row('Blood Pressure',
            'Systolic 90-140 mmHg\nDiastolic 60-90 mmHg\nPulse pressure 30-40 mmHg\nNo significant radio-radial or radio-femoral delay',
            'Hypertension (HTN): >140/90 mmHg\nHypotension: <90/60 mmHg\nWidened PP (>60 mmHg): AR, PDA, fever, thyrotoxicosis\nNarrow PP (<25 mmHg): AS, cardiac tamponade\nRadio-femoral delay: coarctation of aorta',
            'Wide pulse pressure + bounding pulse → AR, PDA\nNarrow PP + slow-rising pulse → AS\nRadio-femoral delay: coarctation (difference in upper vs lower limb BP)\nHill\'s sign: popliteal > brachial BP by >20 mmHg → significant AR'),

        section_row('JVP ASSESSMENT'),
        row('Jugular Venous Pressure (JVP)',
            '<4 cm above sternal angle at 45°\nPulsatile (vs carotid which is not compressible)\nABD: Abdomino-jugular reflux (hepatojugular) negative',
            'Raised JVP: RHF, CCF, constrictive pericarditis, tamponade, SVC obstruction\nKussmaul\'s sign (JVP rises on inspiration): RCM, constrictive pericarditis\nSVC obstruction: non-pulsatile, no ABD response, prominent collaterals',
            'Hepatojugular reflux: apply pressure to liver → JVP rises and stays raised for >10 sec = RHF\nDistinguish JVP from carotid: JVP has dual pulsation (a, v waves), falls with inspiration, obliterated by compression'),
        row('JVP Waveforms',
            'a wave: before S1 (atrial contraction)\nv wave: before S2 (venous filling)\nNormal a > v wave',
            'Giant a wave: TS, RVH, pulmonary stenosis, complete heart block (cannon a)\nAbsent a wave: atrial fibrillation\nGiant v wave: tricuspid regurgitation\nX descent obliterated: cardiac tamponade\nM/W pattern with prominent x and y descents: constrictive pericarditis',
            'Cannon a wave: atrium contracts against closed tricuspid → CHB, nodal rhythm\nGiant v wave + pulsatile liver → tricuspid regurgitation'),

        section_row('PRECORDIAL EXAMINATION'),
        row('Inspection of Precordium',
            'No visible pulsations except possible apical impulse in thin individuals\nNo scars, sinuses, deformities',
            'Precordial bulge: childhood cardiac enlargement (chronic large heart)\nVisible apex beat displaced\nParasternal pulsation: RV enlargement\nAortic pulsation in 2nd R ICS: aneurysm / unfolded aorta\nPulmonary pulsation in 2nd L ICS: pulmonary hypertension',
            'Precordial bulge → long-standing childhood cardiomegaly\nParasternal heave → right ventricular hypertrophy (cor pulmonale, MS with PHT)'),
        row('Apex Beat',
            'Normal: 5th ICS, mid-clavicular line (left)\nNormal character: brief, localised tapping impulse',
            'Displaced outward/downward → cardiomegaly (LVH/LVD)\nHeaving (forceful, sustained): LVH (AS, HTN)\nHyperdynamic (forceful, brief, displaces hand): LVD/volume overload (AR, MR)\nTapping: palpable S1 → Mitral Stenosis\nDiffuse: LV dilatation\nAbsent: obesity, emphysema, pericardial effusion, dextrocardia',
            'Heaving → pressure overload (AS, HTN) = LVH\nHyperdynamic / thrusting → volume overload (AR, MR, VSD) = LV dilatation\nTapping apex = palpable loud S1 → always think MITRAL STENOSIS'),
        row('Parasternal Heave',
            'Absent: no pulsation felt at left sternal border',
            'Left parasternal heave: right ventricular hypertrophy / enlargement',
            'RVH → pulmonary hypertension (from MS, COPD), pulmonary stenosis\nGrade parasternal heave 1-3+'),
        row('Thrills',
            'Absent',
            'Systolic thrill at aortic area: severe AS\nSystolic thrill at pulmonary area: PS\nSystolic thrill at lower sternal border: VSD\nDiastolic thrill at apex: severe MS',
            'Thrill = palpable murmur (grade 4 or above)\nAortic thrill → severe AS\nDiastolic thrill at apex → severe MS (rough turbulent flow)'),

        section_row('AUSCULTATION - HEART SOUNDS'),
        row('First Heart Sound (S1)',
            'S1: closure of mitral (M1) and tricuspid (T1) valves\nLoud at apex, heard in all areas\nNormal loudness',
            'Loud S1: Mitral Stenosis (rheumatic)\nSoft S1: MR, LBBB, prolonged PR interval, poor LV function\nVariable S1: AF, complete heart block\nSplitting of S1: RBBB, Ebstein\'s anomaly',
            'Loud S1 → MITRAL STENOSIS (leaflets held open in diastole, snap shut)\nSoft S1 → MR, LVF, first degree AVB\nM1 before T1 (mitral closes first in systole)'),
        row('Second Heart Sound (S2)',
            'A2 before P2 (aortic closes before pulmonary)\nSingle at aortic area\nPhysiological splitting on inspiration (A2-P2 gap increases)',
            'Loud P2: pulmonary hypertension (PHT)\nSingle S2: severe AS (A2 inaudible), Fallot\'s (absent P2)\nFixed splitting: ASD (RA volume equalises throughout respiratory cycle)\nWidened splitting: RBBB, PS\nReversed (paradoxical) splitting: LBBB, severe AS',
            'Fixed split S2 → ASD (pathognomonic)\nLoud P2 → pulmonary hypertension (PHT)\nReversed split: A2 comes after P2, splitting narrows on inspiration (LBBB)'),
        row('Third Heart Sound (S3)',
            'Normal in children and young adults (<30 yr)\nAbnormal in adults >40yr',
            'Pathological S3 in adult: low-pitched, early diastolic, at apex with bell\nBest heard: left lateral position, expiration',
            'Pathological S3 → rapid ventricular filling in dilated LV (LVF, DCM, MR, AR)\nVentricular gallop rhythm: S1-S2-S3 like "Kentucky"\nRV S3 in RHF heard at lower sternal border, increases on inspiration'),
        row('Fourth Heart Sound (S4)',
            'Normally absent (may be normal in athletes)',
            'S4: low-pitched, presystolic sound just before S1\nBest heard: apex with bell, left lateral position',
            'S4 → stiff, non-compliant ventricle (atrial kick pushes blood into stiff LV)\nCauses: hypertensive heart disease, hypertrophic cardiomyopathy, HOCM, AS, acute MI\nAtrial gallop: S4-S1-S2 like "Tennessee"\nAbsent in AF (no atrial contraction)'),
        row('Opening Snap (OS)',
            'Absent',
            'High-pitched click in early diastole, best heard at lower left sternal border',
            'Mitral Stenosis (pliable non-calcified leaflets snap open)\nShorter A2-OS interval → more severe MS (higher LA pressure)\nA2-OS interval 0.04-0.12 sec'),

        section_row('AUSCULTATION - MURMURS'),
        row('Mid-Diastolic Murmur (MDM)',
            'Absent',
            'Low-pitched, rough, rumbling at apex\nBell of stethoscope, left lateral, expiration\nWith presystolic accentuation (in sinus rhythm)',
            'Mitral Stenosis: turbulent flow across narrowed MV in diastole\nTricuspid stenosis: MDM at lower sternal border, increases with inspiration (Carvallo\'s sign)\nPresystolic accentuation disappears in AF (no atrial contraction)'),
        row('Pan-Systolic Murmur (PSM)',
            'Absent',
            'High-pitched, blowing, throughout systole\nCovers S1 and S2',
            'Mitral Regurgitation: MR PSM at apex, conducted to axilla and back\nTricuspid Regurgitation: TR PSM at lower sternal border, increases with inspiration\nVSD: PSM at lower left sternal border (Maladie de Roger if small)'),
        row('Ejection Systolic Murmur (ESM)',
            'Absent (innocent murmurs may be grade 1-2, no radiation)',
            'High-pitched, crescendo-decrescendo, diamond-shaped\nStarts after S1, ends before S2\nPeak in midsystole',
            'Aortic Stenosis: harsh ESM at aortic area, conducted to carotids\nPulmonary Stenosis: ESM at pulmonary area, conducted to back\nHOCM: ESM at lower left sternal border, increases on Valsalva / standing\nInnocent murmur: grade ≤2, no thrill, no radiation, varies with posture'),
        row('Early Diastolic Murmur (EDM)',
            'Absent',
            'High-pitched, blowing, soft, decrescendo\nDiaphragm, patient sitting, leaning forward, breath held in expiration',
            'Aortic Regurgitation: EDM at left sternal border (2nd-4th ICS)\nMost audible at Erb\'s point (3rd ICS left sternal border)\nPulmonary Regurgitation: EDM at pulmonary area (PHT → Graham-Steell murmur)'),
        row('Continuous Murmur',
            'Absent',
            'High-pitched, machinery-type, peaks around S2\nCrescendo in systole, decrescendo in diastole\nHeard at left infraclavicular area (Gibson\'s area), conducted to back',
            'Patent Ductus Arteriosus (PDA): left-to-right shunt through ductus arteriosus\nPDA closes normally at 24-48 hrs of life\nOther: coronary AV fistula, pulmonary AV fistula, cervical venous hum (obliterated by gentle jugular pressure)'),

        section_row('OTHER SYSTEM EXAMINATION (CVS)'),
        row('Lungs (in CVS exam)',
            'Clear lung fields\nNo crackles at bases',
            'Bilateral basal fine crackles: pulmonary oedema (LVF)\nRight-sided pleural effusion: chronic CCF\nReduced breath sounds: effusion',
            'Bilateral basal crackles that do not clear with coughing → pulmonary oedema\nPost-tussive crackles clear → infection'),
        row('Abdomen (in CVS exam)',
            'Soft, non-tender\nLiver not palpable',
            'Hepatomegaly: pulsatile (TR), tender (congestive hepatopathy)\nHepato-jugular reflux positive\nAscites: shifting dullness, fluid thrill\nSplenomegaly: infective endocarditis (IE)',
            'Pulsatile hepatomegaly → tricuspid regurgitation (expansile pulsation)\nCongestive hepatomegaly → RHF (tender, smooth, firm)\nSplenomegaly in IE: Osler nodes + Roth spots + Janeway lesions = embolic phenomena'),
        row('Peripheral Signs of AR',
            'Absent',
            'Corrigan\'s pulse (bounding carotid)\nDeMusset\'s sign (head nodding with each beat)\nQuincke\'s pulsation (nail bed capillary pulsation)\nDuroziez\'s sign (femoral bruit with light compression)\nHill\'s sign (popliteal BP > brachial by >20 mmHg)\nTraube\'s sign (pistol-shot sounds over femoral artery)',
            'All peripheral signs of AR reflect wide pulse pressure and hyperdynamic circulation\nMost specific: Hill\'s sign and Duroziez\'s\nCorrigan\'s = classic visible neck pulsation of AR'),
    ]

# ══════════════════════════════════════════════════════════════════════════════
# TABLE STYLE APPLICATION
# ══════════════════════════════════════════════════════════════════════════════

def apply_table_style(table_obj, data_rows):
    """Apply cell-level background colours to Normal / Abnormal / Significance columns."""
    style_cmds = []
    for i, r in enumerate(data_rows, start=1):
        # Check if section row (merged)
        if r[1] == '' and r[2] == '' and r[3] == '':
            continue
        style_cmds += [
            ('BACKGROUND', (1, i), (1, i), C_NORMAL),
            ('BACKGROUND', (2, i), (2, i), C_ABNORMAL),
            ('BACKGROUND', (3, i), (3, i), C_SIG),
        ]
    table_obj.setStyle(TableStyle(style_cmds))
    return table_obj

# ══════════════════════════════════════════════════════════════════════════════
# BUILD PDF
# ══════════════════════════════════════════════════════════════════════════════

def build_checklist_pdf(out_path):
    ss = make_styles()

    doc = SimpleDocTemplate(
        out_path,
        pagesize=A4,
        leftMargin=20*mm, rightMargin=20*mm,
        topMargin=18*mm, bottomMargin=18*mm,
    )

    story = []

    # ── COVER ──────────────────────────────────────────────────────────────────
    story.append(Spacer(1, 25*mm))
    story.append(Paragraph('EXAMINATION CHECKLIST', ss['CoverTitle']))
    story.append(Paragraph('Normal vs Abnormal Findings + Clinical Significance', ss['CoverSub']))
    story.append(Spacer(1, 5*mm))
    story.append(HRFlowable(width="60%", thickness=2, color=C_NAVY))
    story.append(Spacer(1, 5*mm))
    story.append(Paragraph('Medicine Posting · 2nd Year MBBS', ss['CoverSub']))
    story.append(Spacer(1, 4*mm))
    story.append(Paragraph(
        'Systems covered: Gastrointestinal · Central Nervous System · Respiratory · Cardiovascular',
        ss['CoverTiny']))
    story.append(Spacer(1, 10*mm))

    # Colour legend
    legend_data = [
        [Paragraph('<b>Column Colour Guide</b>', ss['Body8']), '', '', ''],
        [Paragraph('FINDING / TEST', ss['ColHead']),
         Paragraph('NORMAL', ss['ColHead']),
         Paragraph('ABNORMAL', ss['ColHead']),
         Paragraph('CLINICAL SIGNIFICANCE', ss['ColHead'])],
        [Paragraph('What you are examining', ss['Body8']),
         Paragraph('Expected finding in a healthy person', ss['CellNorm']),
         Paragraph('Deviation from normal and clinical variants', ss['CellAbn']),
         Paragraph('What the abnormality means + what it suggests', ss['CellSig'])],
    ]
    lt = Table(legend_data, colWidths=CW)
    lt.setStyle(TableStyle([
        ('SPAN',         (0,0), (3,0)),
        ('BACKGROUND',   (0,0), (3,0), colors.HexColor("#eceff1")),
        ('BACKGROUND',   (0,1), (3,1), C_NAVY),
        ('BACKGROUND',   (1,2), (1,2), C_NORMAL),
        ('BACKGROUND',   (2,2), (2,2), C_ABNORMAL),
        ('BACKGROUND',   (3,2), (3,2), C_SIG),
        ('GRID',         (0,0), (-1,-1), 0.5, colors.HexColor("#bdbdbd")),
        ('TOPPADDING',   (0,0), (-1,-1), 4),
        ('BOTTOMPADDING',(0,0), (-1,-1), 4),
        ('LEFTPADDING',  (0,0), (-1,-1), 5),
        ('VALIGN',       (0,0), (-1,-1), 'MIDDLE'),
    ]))
    story.append(lt)
    story.append(Spacer(1, 8*mm))

    # Index
    index = [
        ('1. GIT System',  'General Examination · Signs of Liver Failure · Abdominal Inspection · Palpation · Percussion · Auscultation'),
        ('2. CNS System',  'Higher Mental Functions · Cranial Nerves (I-XII) · Motor System · Sensory System · Cerebellar Signs · Meningeal Signs'),
        ('3. Respiratory', 'General & Vital Signs · Upper RT · Chest Inspection/Palpation/Percussion/Auscultation'),
        ('4. CVS System',  'General Exam · Vital Signs (Pulse, BP, JVP) · Precordial · Heart Sounds · Murmurs · Peripheral Signs'),
    ]
    for sys_n, items in index:
        story.append(Paragraph(
            f'<b><font color="#1a3a5c">{sys_n}</font></b>  —  <font color="#455a64">{items}</font>',
            ss['Body8']))
        story.append(Spacer(1, 2*mm))

    story.append(PageBreak())

    # ── GIT ────────────────────────────────────────────────────────────────────
    story.append(sys_header_block(
        '1. GASTROINTESTINAL SYSTEM',
        'General · Liver Failure Signs · Abdomen Inspection/Palpation/Percussion/Auscultation',
        SYS_GIT))
    story.append(Spacer(1, 4*mm))

    git_rows = git_general_data()
    t = make_table(git_rows)
    apply_table_style(t, git_rows)
    story.append(t)
    story.append(PageBreak())

    # ── CNS ────────────────────────────────────────────────────────────────────
    story.append(sys_header_block(
        '2. CENTRAL NERVOUS SYSTEM',
        'Higher Mental Functions · Cranial Nerves · Motor · Sensory · Cerebellar · Meningeal',
        SYS_CNS))
    story.append(Spacer(1, 4*mm))

    cns_rows = cns_general_data()
    t = make_table(cns_rows)
    apply_table_style(t, cns_rows)
    story.append(t)
    story.append(PageBreak())

    # ── RESPIRATORY ────────────────────────────────────────────────────────────
    story.append(sys_header_block(
        '3. RESPIRATORY SYSTEM',
        'General · URT · Chest Inspection / Palpation / Percussion / Auscultation',
        SYS_RS))
    story.append(Spacer(1, 4*mm))

    rs_rows = rs_general_data()
    t = make_table(rs_rows)
    apply_table_style(t, rs_rows)
    story.append(t)
    story.append(PageBreak())

    # ── CVS ────────────────────────────────────────────────────────────────────
    story.append(sys_header_block(
        '4. CARDIOVASCULAR SYSTEM',
        'General · Pulse · BP · JVP · Precordium · Heart Sounds & Murmurs · Peripheral Signs',
        SYS_CVS))
    story.append(Spacer(1, 4*mm))

    cvs_rows = cvs_general_data()
    t = make_table(cvs_rows)
    apply_table_style(t, cvs_rows)
    story.append(t)
    story.append(PageBreak())

    # ── QUICK SUMMARY TABLE ────────────────────────────────────────────────────
    story.append(sys_header_block(
        'QUICK SUMMARY: KEY EXAMINATION MNEMONICS & RULES',
        'Must-know principles for clinical examination',
        C_NAVY))
    story.append(Spacer(1, 5*mm))

    summary_data = [
        [Paragraph('<b>System</b>', ss['ColHead']),
         Paragraph('<b>Key Rule / Mnemonic</b>', ss['ColHead']),
         Paragraph('<b>What it means</b>', ss['ColHead'])],

        [p('GIT - Liver', 'CellBold'), p('Cannot get above it + moves with respiration + dull to percussion = liver', 'CellNorm'), p('Distinguishes liver from other RUQ masses', 'CellSig')],
        [p('GIT - Spleen', 'CellBold'), p('Notched edge + moves to RIF + cannot insunate fingers between it and ribs', 'CellNorm'), p('Distinguishes spleen from kidney (kidney: ballotable, colonic band, can insunate)', 'CellSig')],
        [p('GIT - Ascites', 'CellBold'), p('Shifting dullness (>500 mL) + Fluid thrill (tense) + Puddle sign (120 mL)', 'CellNorm'), p('Order of sensitivity: puddle > shifting dullness > fluid thrill', 'CellSig')],
        [p('GIT - Liver Failure', 'CellBold'), p('CLAD + Flap: Clubbing, Leukonychia, Asterixis, Dupuytren + Flapping tremor', 'CellNorm'), p('All due to chronic liver disease / portal hypertension', 'CellSig')],
        [p('CNS - UMN vs LMN', 'CellBold'), p('UMN: ↑ tone, ↑ reflexes, Babinski +, no wasting\nLMN: ↓ tone, ↓ reflexes, Babinski -, wasting + fasciculations', 'CellNorm'), p('UMN = above anterior horn cell\nLMN = at or below AHC', 'CellSig')],
        [p('CNS - Cerebellar DANISH', 'CellBold'), p('D: Dysdiadochokinesia A: Ataxia N: Nystagmus I: Intention tremor S: Scanning speech H: Hypotonia', 'CellNorm'), p('All ipsilateral to cerebellar lesion', 'CellSig')],
        [p('CNS - Facial Palsy', 'CellBold'), p('Forehead spared → UMN (stroke)\nForehead involved → LMN (Bell\'s palsy)', 'CellNorm'), p('Frontalis has bilateral cortical representation - UMN lesion cannot abolish it alone', 'CellSig')],
        [p('RS - Side of Pathology', 'CellBold'), p('Side with REDUCED expansion + REDUCED TVF = pathological side\nTrachea deviates TOWARDS collapse/fibrosis\nTrachea deviates AWAY FROM effusion/pneumothorax', 'CellNorm'), p('Tracheal position + chest movement together identify the lesion side', 'CellSig')],
        [p('RS - Consolidation Triad', 'CellBold'), p('Dull percussion + Bronchial breathing + Increased VR/TVF', 'CellNorm'), p('All 3 needed for consolidation diagnosis clinically', 'CellSig')],
        [p('RS - Effusion Triad', 'CellBold'), p('Stony dull percussion + Absent/reduced BS + Reduced VR + Aegophony at upper border', 'CellNorm'), p('Stony dull (differentiated from simple dull) + aegophony = pleural effusion', 'CellSig')],
        [p('CVS - Mitral Stenosis', 'CellBold'), p('Tapping apex + MDM at apex (bell, left lateral, expiration) + Loud S1 + Opening snap + Parasternal heave (PHT)', 'CellNorm'), p('A2-OS interval inversely proportional to severity of MS', 'CellSig')],
        [p('CVS - Aortic Regurgitation', 'CellBold'), p('EDM at Erb\'s point (3rd ICS LSB) + Water-hammer pulse + Wide pulse pressure + Hill\'s sign + Corrigan\'s / DeMusset\'s', 'CellNorm'), p('AR = volume overload → hyperdynamic apex + thrusting', 'CellSig')],
        [p('CVS - Aortic Stenosis', 'CellBold'), p('Heaving apex + ESM conducted to carotids + Slow-rising pulse + Narrow pulse pressure\nTriad: angina + syncope + dyspnoea', 'CellNorm'), p('AS = pressure overload → heaving apex beat (sustained, forceful)', 'CellSig')],
        [p('CVS - Heart Sounds', 'CellBold'), p('S1: MV + TV closure (start systole)\nS2: AV + PV closure (start diastole)\nS3: rapid filling (pathological in adults >40 → LVF)\nS4: stiff ventricle (HTN, HCM, AS)', 'CellNorm'), p('"Lubb-Dubb" = S1-S2\nS3 gallop = "Kentucky"\nS4 gallop = "Tennessee"', 'CellSig')],
        [p('CVS - Murmur Positions', 'CellBold'), p('MR/MS: Left lateral, expiration\nAR: Sitting forward, expiration, at Erb\'s\nPS/AS: Sitting, held inspiration\nTR/TS: Supine, inspiration (↑ on inspiration = right-sided)', 'CellNorm'), p('Right-sided murmurs increase with inspiration (Carvallo\'s sign)\nLeft-sided murmurs increase with expiration', 'CellSig')],
    ]

    summary_cw = [TW*0.18, TW*0.46, TW*0.36]
    st = Table(summary_data, colWidths=summary_cw, repeatRows=1)
    st.setStyle(TableStyle([
        ('BACKGROUND',    (0,0), (-1,0), C_NAVY),
        ('TEXTCOLOR',     (0,0), (-1,0), C_WHITE),
        ('FONTNAME',      (0,0), (-1,0), 'Helvetica-Bold'),
        ('FONTSIZE',      (0,0), (-1,-1), 7.5),
        ('VALIGN',        (0,0), (-1,-1), 'TOP'),
        ('GRID',          (0,0), (-1,-1), 0.35, colors.HexColor("#bdbdbd")),
        ('TOPPADDING',    (0,0), (-1,-1), 3),
        ('BOTTOMPADDING', (0,0), (-1,-1), 3),
        ('LEFTPADDING',   (0,0), (-1,-1), 4),
        ('RIGHTPADDING',  (0,0), (-1,-1), 4),
        ('ROWBACKGROUNDS',(0,1), (-1,-1), [colors.white, colors.HexColor("#f5f5f5")]),
        ('BACKGROUND',    (1,1), (1,-1), colors.HexColor("#e8f5e9")),
        ('BACKGROUND',    (2,1), (2,-1), colors.HexColor("#fff8e1")),
    ]))
    story.append(st)

    doc.build(story)
    print(f"Checklist PDF written to: {out_path}")


if __name__ == '__main__':
    build_checklist_pdf('/tmp/workspace/ddx-flowcharts/Examination_Checklist_Normal_vs_Abnormal.pdf')
Running Command

cd /tmp/workspace/ddx-flowcharts && python3 generate_checklist.py 2>&1

Running Command

python3 -c " from pypdf import PdfReader r = PdfReader('/tmp/workspace/ddx-flowcharts/Examination_Checklist_Normal_vs_Abnormal.pdf') print(f'Pages: {len(r.pages)}') for i, p in enumerate(r.pages): t = p.extract_text() first = t.strip()[:70] if t else '(no text)' print(f' Page {i+1}: {first}') " ls -lh /tmp/workspace/ddx-flowcharts/Examination_Checklist_Normal_vs_Abnormal.pdf

12 pages, all systems covered, clean structure. Here is your PDF:

Examination Checklist Normal vs Abnormal

PDF Document · PDF


What's inside (12 pages):
Page(s)Content
1Cover + Colour guide legend + Contents index
2-3GIT System - General exam, Liver failure signs (spider naevi, asterixis, leukonychia etc), Abdominal inspection, Palpation (liver, spleen, kidney, Murphy's, McBurney's), Percussion, Auscultation
4-6CNS System - Higher mental functions, All 12 cranial nerves, Motor system (tone, power MRC scale, reflexes, Babinski), Sensory system, Cerebellar signs, Meningeal signs (Kernig's, Brudzinski's)
7-8Respiratory - Vital signs, Cyanosis/Clubbing, URT (trachea, flaring), Chest inspection, TVF, Percussion notes, Breath sounds, Added sounds (crackles, wheeze, pleural rub), Vocal resonance
9-11CVS - General exam (Marfan's, xanthelasma), Pulse (rate/rhythm/volume/character), BP, JVP waveforms, Precordium (apex beat, thrills, heave), All heart sounds + murmurs (S1-S4, MDM, PSM, ESM, EDM, continuous), Peripheral signs of AR
12Quick Summary - Key mnemonics, UMN vs LMN rules, DANISH, murmur positioning rules, consolidation vs effusion triad
Colour coding throughout:
  • 🟢 Green = Normal findings
  • 🔴 Red = Abnormal findings
  • 🟡 Amber = Clinical significance / what it means

Can you tell me the significance of doing all these examination and what to rule out . I need for every examination . You can take long time

Running Command

cd /tmp/workspace/attachments/d674b850-1b3c-4cd5-a4fb-32ebcf3bfe0d/ && python3 -c " import pdfplumber with pdfplumber.open('PDF (1).pdf') as pdf: for i, page in enumerate(pdf.pages): text = page.extract_text() print(f'=== PAGE {i+1} ===') print(text) print() "

Continue

This is a shared conversation. Sign in to Orris to start your own chat.