Hii
What can you do
Explain senile cataract according to standard mbbs textbook of ophthalmology

| Symptom | Mechanism |
|---|---|
| Reduced visual acuity | Progressive opacification |
| Loss of contrast sensitivity | Light scattering |
| Change in colour perception | Difficulty perceiving blue colours |
| Glare | Light scattering; worse at night (e.g. car headlights) |
| Monocular diplopia | Especially with point light sources |
| Poor night vision | Reduced light transmission |

| Stage | Description |
|---|---|
| Immature | Lens is partially opaque; red reflex still present |
| Mature | Lens is completely opaque; no red reflex |
| Hypermature | Shrunken, wrinkled anterior capsule due to leakage of water out of the lens |
| Morgagnian | Hypermature cataract in which liquefaction of cortex allows the nucleus to sink inferiorly |
Create pdf of thi
ls -la /home/daytona/workspace/ 2>/dev/null || mkdir -p /home/daytona/workspace && ls -la /home/daytona/workspace/
mkdir -p /home/daytona/workspace/senile-cataract
~/senile-cataract/generate_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm
from reportlab.lib import colors
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, KeepTogether
)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import Image as RLImage
import urllib.request
import io
import os
OUTPUT = "/home/daytona/workspace/senile-cataract/Senile_Cataract.pdf"
# ── Download images ──────────────────────────────────────────────────────────
IMG_ANATOMY = "https://cdn.orris.care/cdss_images/a2674d6ec496b5de9e01cd831d3b38fad72b4369b523c13cca36a6fd099d9385.png"
IMG_TYPES = "https://cdn.orris.care/cdss_images/29451237b3f1b4220de6fc97dc359b8089c1b6b5647538ce70183e87ed5d4d85.png"
def download_image(url, filename):
path = f"/home/daytona/workspace/senile-cataract/{filename}"
if not os.path.exists(path):
urllib.request.urlretrieve(url, path)
return path
anatomy_img = download_image(IMG_ANATOMY, "anatomy.png")
types_img = download_image(IMG_TYPES, "types.png")
# ── Document setup ────────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=2*cm, rightMargin=2*cm,
topMargin=2.2*cm, bottomMargin=2.2*cm,
title="Senile Cataract",
author="Orris Medical AI"
)
W, H = A4
TW = W - 4*cm # text width
# ── Styles ────────────────────────────────────────────────────────────────────
BASE = getSampleStyleSheet()
TITLE = ParagraphStyle("TITLE", parent=BASE["Title"],
fontSize=22, textColor=colors.HexColor("#1a3a5c"),
spaceAfter=4, leading=26, alignment=TA_CENTER)
SUBTITLE = ParagraphStyle("SUBTITLE", parent=BASE["Normal"],
fontSize=11, textColor=colors.HexColor("#4a6fa5"),
spaceAfter=14, alignment=TA_CENTER, italic=True)
H1 = ParagraphStyle("H1", parent=BASE["Heading1"],
fontSize=13, textColor=colors.white,
backColor=colors.HexColor("#1a3a5c"),
spaceBefore=14, spaceAfter=6,
leftIndent=-0.5*cm, rightIndent=-0.5*cm,
borderPad=5, leading=18)
H2 = ParagraphStyle("H2", parent=BASE["Heading2"],
fontSize=11, textColor=colors.HexColor("#1a3a5c"),
spaceBefore=10, spaceAfter=4, leading=16,
borderPad=2)
H3 = ParagraphStyle("H3", parent=BASE["Heading3"],
fontSize=10.5, textColor=colors.HexColor("#2e6da4"),
spaceBefore=8, spaceAfter=3, leading=14, bold=True)
BODY = ParagraphStyle("BODY", parent=BASE["Normal"],
fontSize=9.5, leading=14, spaceAfter=4, alignment=TA_JUSTIFY,
textColor=colors.HexColor("#222222"))
BULLET = ParagraphStyle("BULLET", parent=BASE["Normal"],
fontSize=9.5, leading=13, leftIndent=14, spaceAfter=2,
bulletIndent=4, textColor=colors.HexColor("#222222"))
CAPTION = ParagraphStyle("CAPTION", parent=BASE["Normal"],
fontSize=8.5, textColor=colors.HexColor("#555555"),
alignment=TA_CENTER, spaceAfter=8, italic=True)
HIGHLIGHT = ParagraphStyle("HIGHLIGHT", parent=BASE["Normal"],
fontSize=9.5, leading=13, leftIndent=12,
backColor=colors.HexColor("#eaf2fb"),
borderPad=6, spaceAfter=6,
textColor=colors.HexColor("#1a3a5c"))
SOURCE = ParagraphStyle("SOURCE", parent=BASE["Normal"],
fontSize=8, textColor=colors.HexColor("#888888"),
alignment=TA_CENTER, spaceBefore=20, italic=True)
def h1(text):
return Paragraph(f" {text}", H1)
def h2(text):
return Paragraph(text, H2)
def h3(text):
return Paragraph(text, H3)
def body(text):
return Paragraph(text, BODY)
def bullet(text):
return Paragraph(f"• {text}", BULLET)
def highlight(text):
return Paragraph(text, HIGHLIGHT)
def sp(n=6):
return Spacer(1, n)
def hr():
return HRFlowable(width="100%", thickness=0.5, color=colors.HexColor("#cccccc"), spaceAfter=4)
# ── Build content ─────────────────────────────────────────────────────────────
story = []
# Title block
story.append(sp(10))
story.append(Paragraph("Senile (Age-Related) Cataract", TITLE))
story.append(Paragraph("Based on Kanski's Clinical Ophthalmology: A Systematic Approach, 10th Edition", SUBTITLE))
story.append(HRFlowable(width="100%", thickness=2, color=colors.HexColor("#1a3a5c"), spaceAfter=14))
# ── DEFINITION ───────────────────────────────────────────────────────────────
story.append(h1("1. Definition"))
story.append(body(
"<b>Cataract</b> is opacification of the crystalline lens. "
"<b>Senile (age-related) cataract</b> refers to lens opacity that occurs as a consequence of normal ageing. "
"It is the <b>commonest cause of reversible visual disability in the world.</b>"
))
story.append(highlight("⚠ There is NO medical treatment to prevent the development or progression of cataract. "
"Phacoemulsification with IOL implantation is the definitive treatment."))
story.append(sp())
# ── ANATOMY ──────────────────────────────────────────────────────────────────
story.append(h1("2. Lens Anatomy"))
story.append(body(
"The lens is a biconvex, transparent structure held in place by <b>zonules</b> arising from the ciliary body. "
"Its primary function is to focus light on the retina."
))
bullet_items = [
"<b>Capsule</b> – acellular membrane enclosing the lens",
"<b>Epithelial cells</b> – cuboid cells beneath the anterior capsule; <b>germinative zone</b> cells divide continuously and differentiate into lens fibres",
"<b>Cortex</b> – peripheral lens substance made of newer lens fibres",
"<b>Nucleus</b> – central, denser older lens fibres",
]
for b in bullet_items:
story.append(bullet(b))
story.append(sp(8))
img = RLImage(anatomy_img, width=TW*0.85, height=TW*0.85*0.42)
story.append(img)
story.append(Paragraph("Fig. 10.1 – (A) Cross-sectional anatomy of the anterior segment; (B) Histological cross-section of the lens showing zones", CAPTION))
story.append(sp())
# ── EFFECT ON VISION ─────────────────────────────────────────────────────────
story.append(h1("3. Effect on Vision"))
story.append(body(
"Cataracts develop slowly and in early stages alter vision subtly. "
"The effect depends on: (a) type of cataract, (b) extent of opacification, (c) position of opacification."
))
symptoms_data = [
["Symptom", "Mechanism"],
["Reduced visual acuity", "Progressive opacification; initially correctable with glasses"],
["Loss of contrast sensitivity", "Light scattering within the lens"],
["Change in colour perception", "Difficulty perceiving blue colours (urochrome pigment)"],
["Glare", "Light scattering; worse at night (e.g. oncoming car headlights)"],
["Monocular diplopia", "Especially with point light sources"],
["Poor night vision", "Reduced light transmission through opaque lens"],
]
t = Table(symptoms_data, colWidths=[TW*0.4, TW*0.6])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), colors.HexColor("#1a3a5c")),
("TEXTCOLOR", (0,0), (-1,0), colors.white),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#f0f5fb"), colors.white]),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#bbbbbb")),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
]))
story.append(t)
story.append(sp())
# ── TYPES ─────────────────────────────────────────────────────────────────────
story.append(h1("4. Types of Age-Related Cataract"))
story.append(sp(8))
img2 = RLImage(types_img, width=TW*0.9, height=TW*0.9*1.18)
story.append(img2)
story.append(Paragraph(
"Fig. 10.2 – Age-related cataract: (A) Posterior subcapsular; (B) PSC on retroillumination with Wedl cells (arrow); "
"(C) Nuclear sclerosis; (D) Nuclear sclerosis on retroillumination – nucleus-cortex demarcation (arrow); "
"(E) Cortical cataract; (F) Cortical spokes on retroillumination; (G) Christmas tree; (H) Christmas tree on retroillumination",
CAPTION))
story.append(sp())
# Type 1
story.append(h3("4.1 Posterior Subcapsular Cataract (PSC)"))
for b in [
"Located just in front of the <b>posterior capsule</b>",
"Granular or plaque-like on oblique slit lamp; <b>black and vacuolated on retroillumination</b>",
"Vacuoles = swollen migratory lens epithelial cells (<b>Bladder cells / Wedl cells</b>)",
"Located at the <b>nodal point</b> of the eye → even small opacity causes profound visual loss",
"Characteristic symptom: <b>glare</b> from oncoming headlights",
"Symptoms worsen with <b>miosis</b> (near tasks, bright sunlight)",
]:
story.append(bullet(b))
story.append(sp(4))
# Type 2
story.append(h3("4.2 Nuclear Sclerotic Cataract"))
for b in [
"Exaggeration of normal ageing change",
"Causes <b>myopia</b> due to increased refractive index of nucleus",
'<b>"Second sight of the aged"</b> – elderly patients can read without glasses again',
"<b>Yellowish hue</b> due to deposition of <b>urochrome pigment</b>",
"Best assessed with <b>oblique slit lamp beam</b>",
"When advanced: nucleus appears <b>brown (brunescent)</b>; rarely <b>black (nigra)</b>",
]:
story.append(bullet(b))
story.append(sp(4))
# Type 3
story.append(h3("4.3 Cortical Cataract"))
for b in [
"Involves anterior, posterior or equatorial cortex",
"Begins as <b>clefts and vacuoles</b> between lens fibres due to cortical hydration",
"Progresses to <b>cuneiform (wedge-shaped) or radial spoke-like opacities</b>",
"Often initially in the <b>inferonasal quadrant</b>",
"<b>Glare</b> is a common symptom",
]:
story.append(bullet(b))
story.append(sp(4))
# Type 4
story.append(h3("4.4 Christmas Tree Cataract"))
for b in [
"Polychromatic, needle-like crystalline deposits",
"Multicoloured sparkling appearance (like a Christmas tree)",
"Seen on direct illumination and retroillumination",
]:
story.append(bullet(b))
story.append(sp())
# ── MATURITY ──────────────────────────────────────────────────────────────────
story.append(h1("5. Cataract Maturity (Stages)"))
maturity_data = [
["Stage", "Description"],
["Immature", "Lens partially opaque; red reflex still present"],
["Mature", "Lens completely opaque; red reflex absent"],
["Hypermature", "Shrunken, wrinkled anterior capsule due to water leakage out of the lens"],
["Morgagnian", "Hypermature cataract with liquefied cortex; nucleus sinks inferiorly"],
]
t2 = Table(maturity_data, colWidths=[TW*0.25, TW*0.75])
t2.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), colors.HexColor("#2e6da4")),
("TEXTCOLOR", (0,0), (-1,0), colors.white),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#f0f5fb"), colors.white]),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#bbbbbb")),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
]))
story.append(t2)
story.append(sp())
# ── SYSTEMIC ASSOCIATIONS ─────────────────────────────────────────────────────
story.append(h1("6. Cataract in Systemic Disease"))
story.append(h3("6.1 Diabetes Mellitus"))
for b in [
"Hyperglycaemia → high aqueous glucose → diffuses into lens",
"Glucose metabolized to <b>sorbitol</b> (aldose reductase) → osmotic overhydration",
"Refractive fluctuation with plasma glucose: hyperglycaemia = <b>myopia</b>",
"Classic <b>snowflake cortical opacity</b> – rare; young diabetics; may mature within days",
"Age-related cataract occurs <b>earlier</b> in diabetics; nuclear sclerosis rapid",
"~1 in 5 cataract surgery patients have diabetes",
]:
story.append(bullet(b))
story.append(sp(4))
story.append(h3("6.2 Other Systemic Associations"))
for b in [
"Chronic steroid use → posterior subcapsular cataract",
"Myotonic dystrophy",
"Neurofibromatosis type 2",
"Down syndrome",
"Galactosaemia (in children)",
]:
story.append(bullet(b))
story.append(sp())
# ── SECONDARY CATARACT ────────────────────────────────────────────────────────
story.append(h1("7. Secondary (Complicated) Cataract"))
story.append(body(
"Develops as a result of primary ocular disease."
))
secondary_data = [
["Cause", "Features"],
["Chronic anterior uveitis", "Most common cause; both inflammation and steroid therapy causative; polychromatic lustre at posterior pole earliest sign"],
["Acute angle closure glaucoma", "Glaukomflecken – small grey-white subcapsular opacities (focal lens epithelial infarcts); pathognomonic"],
["High myopia", "Posterior subcapsular opacity + early nuclear sclerosis"],
["Hereditary fundus dystrophies\n(RP, Leber, gyrate atrophy, Stickler)", "Usually posterior subcapsular opacity"],
]
t3 = Table(secondary_data, colWidths=[TW*0.38, TW*0.62])
t3.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), colors.HexColor("#1a3a5c")),
("TEXTCOLOR", (0,0), (-1,0), colors.white),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#f0f5fb"), colors.white]),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#bbbbbb")),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
story.append(t3)
story.append(sp())
# ── MANAGEMENT ────────────────────────────────────────────────────────────────
story.append(h1("8. Management"))
story.append(h3("8.1 Indications for Surgery"))
for b in [
"Cataract significantly impairs quality of life or daily activities",
"Secondary complication (e.g. phacomorphic glaucoma, phacolytic glaucoma)",
]:
story.append(bullet(b))
story.append(sp(4))
story.append(h3("8.2 Surgical Methods"))
surgical_data = [
["Method", "Details"],
["Phacoemulsification\n(GOLD STANDARD)", "Ultrasonic emulsification via small incision (~2.4–2.8 mm); foldable IOL implanted; rapid recovery, low astigmatism"],
["ECCE (Manual Extracapsular)", "Larger incision; nucleus expressed intact; used where phaco unavailable or for hard brunescent nuclei"],
["ICCE (Intracapsular)", "Entire lens including capsule removed; largely obsolete"],
]
t4 = Table(surgical_data, colWidths=[TW*0.32, TW*0.68])
t4.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), colors.HexColor("#2e6da4")),
("TEXTCOLOR", (0,0), (-1,0), colors.white),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,1), (-1,-1), [colors.HexColor("#f0f5fb"), colors.white]),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#bbbbbb")),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
story.append(t4)
story.append(sp(4))
story.append(h3("8.3 Key Preoperative Considerations"))
for b in [
"<b>Alpha-blockers</b> (e.g. tamsulosin) → <b>Intraoperative Floppy Iris Syndrome (IFIS)</b> – must be disclosed",
"Manage <b>anticoagulants</b> per local protocol (check INR within 24 h in stable patients)",
"Screen for allergy: iodine, latex, antibiotics, sticking plaster",
"Check for MRSA carriage",
"<b>Pupillary RAPD</b> – cataract never causes RAPD; if present, suggests posterior pole pathology",
"Corneal endothelial cell count (specular microscopy) if cornea guttata suspected",
]:
story.append(bullet(b))
story.append(sp())
# ── HIGH YIELD ────────────────────────────────────────────────────────────────
story.append(h1("9. High-Yield Exam Points"))
hyl = [
("Most common cause", "Reversible blindness worldwide"),
("No medical treatment", "Prevents or reverses cataract"),
("PSC", "Worst impact per opacity size (nodal point); worse with miosis"),
("Nuclear sclerosis", "Myopia + 'second sight'; yellow/brown hue; urochrome pigment"),
("Cortical", "Spoke-like opacities; starts inferonasally"),
("Morgagnian", "Liquefied cortex; nucleus sinks — hypermature stage"),
("Glaukomflecken", "Pathognomonic of previous acute angle closure"),
("Second sight of aged", "Nuclear myopia → can read without glasses"),
("Gold standard surgery", "Phacoemulsification + IOL"),
("Tamsulosin", "Alpha-blocker → causes IFIS during phaco"),
]
hyl_table = Table(hyl, colWidths=[TW*0.35, TW*0.65])
hyl_table.setStyle(TableStyle([
("FONTNAME", (0,0), (-1,-1), "Helvetica"),
("FONTNAME", (0,0), (0,-1), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("ROWBACKGROUNDS", (0,0), (-1,-1), [colors.HexColor("#eaf2fb"), colors.HexColor("#f7fafd")]),
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#bbbbbb")),
("LEFTPADDING", (0,0), (-1,-1), 8),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("TEXTCOLOR", (0,0), (0,-1), colors.HexColor("#1a3a5c")),
]))
story.append(hyl_table)
story.append(sp(20))
story.append(hr())
story.append(Paragraph(
"Source: Kanski's Clinical Ophthalmology: A Systematic Approach, 10th Edition – Chapter 10: The Lens | "
"Generated by Orris Medical AI | For educational purposes only",
SOURCE))
# ── Build ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF created: {OUTPUT}")
python /home/daytona/workspace/senile-cataract/generate_pdf.py
ls -lh /home/daytona/workspace/senile-cataract/Senile_Cataract.pdf
Senile Cataract
PDF Document · PDF