can u makes notes. for this in detail explain in easy word and easy to understand with diagrams and handwritten notes
mkdir -p /tmp/workspace/general-medicine-notes && ls /tmp/workspace/
~/general-medicine-notes/create_notes.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import cm, mm
from reportlab.platypus import (SimpleDocTemplate, Paragraph, Spacer, Table,
TableStyle, HRFlowable, KeepTogether)
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.pdfgen import canvas
from reportlab.platypus import BaseDocTemplate, Frame, PageTemplate, PageBreak
from reportlab.graphics.shapes import Drawing, Rect, Circle, String, Line, Polygon, Ellipse
from reportlab.graphics import renderPDF
import io
# ββ Colour palette ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
NAVY = colors.HexColor("#1a237e")
BLUE = colors.HexColor("#1565c0")
LIGHT_BLUE= colors.HexColor("#e3f2fd")
TEAL = colors.HexColor("#00695c")
TEAL_LIGHT= colors.HexColor("#e0f2f1")
ORANGE = colors.HexColor("#e65100")
ORANGE_LIGHT = colors.HexColor("#fff3e0")
GREEN = colors.HexColor("#2e7d32")
GREEN_LIGHT = colors.HexColor("#e8f5e9")
RED = colors.HexColor("#c62828")
RED_LIGHT = colors.HexColor("#ffebee")
PURPLE = colors.HexColor("#6a1b9a")
PURPLE_LIGHT = colors.HexColor("#f3e5f5")
YELLOW = colors.HexColor("#f9a825")
YELLOW_LIGHT = colors.HexColor("#fffde7")
GRAY_BG = colors.HexColor("#f5f5f5")
DARK_TEXT = colors.HexColor("#212121")
MID_GRAY = colors.HexColor("#757575")
WHITE = colors.white
BLACK = colors.black
# ββ Page template with lined background βββββββββββββββββββββββββββββββββββββ
def draw_notebook_background(canv, doc):
canv.saveState()
w, h = A4
# Cream background
canv.setFillColor(colors.HexColor("#fffef7"))
canv.rect(0, 0, w, h, fill=1, stroke=0)
# Blue ruled lines
canv.setStrokeColor(colors.HexColor("#d0e8ff"))
canv.setLineWidth(0.4)
y = h - 40
while y > 20:
canv.line(15, y, w - 15, y)
y -= 22
# Red margin line
canv.setStrokeColor(colors.HexColor("#ffcdd2"))
canv.setLineWidth(1)
canv.line(50, h - 10, 50, 10)
# Page number
canv.setFont("Helvetica", 8)
canv.setFillColor(MID_GRAY)
canv.drawCentredString(w / 2, 10, f"General Medicine Notes | Page {doc.page}")
canv.restoreState()
# ββ Helper: coloured box heading ββββββββββββββββββββββββββββββββββββββββββββ
def section_header(text, bg=NAVY, fg=WHITE, font_size=15):
style = ParagraphStyle("hdr", fontName="Helvetica-Bold",
fontSize=font_size, textColor=fg,
backColor=bg, borderPad=6,
leading=font_size + 4, alignment=TA_LEFT)
return Paragraph(text, style)
def sub_header(text, color=BLUE):
style = ParagraphStyle("sub", fontName="Helvetica-Bold",
fontSize=11, textColor=color, leading=14)
return Paragraph(text, style)
def body(text, indent=0):
style = ParagraphStyle("body", fontName="Helvetica",
fontSize=9.5, leading=14, leftIndent=indent,
textColor=DARK_TEXT, alignment=TA_JUSTIFY)
return Paragraph(text, style)
def bullet(text, indent=20, color=BLUE):
bullet_char = "<bullet>•</bullet>"
style = ParagraphStyle("bul", fontName="Helvetica",
fontSize=9.5, leading=13, leftIndent=indent,
bulletIndent=indent - 12, textColor=DARK_TEXT,
bulletColor=color)
return Paragraph(f"<bullet><font color='#{color.hexval()[1:]}'>►</font></bullet> {text}", style)
def key_box(title, items, bg=LIGHT_BLUE, title_bg=BLUE):
"""Coloured key-points box."""
data = [[Paragraph(f"<b><font color='white'>{title}</font></b>",
ParagraphStyle("kh", fontName="Helvetica-Bold",
fontSize=10, textColor=WHITE))]]
for item in items:
data.append([Paragraph(f"▶ {item}",
ParagraphStyle("ki", fontName="Helvetica",
fontSize=9, textColor=DARK_TEXT,
leading=13))])
tbl = Table(data, colWidths=[16*cm])
tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), title_bg),
("BACKGROUND", (0,1), (-1,-1), bg),
("BOX", (0,0), (-1,-1), 0.8, title_bg),
("INNERGRID", (0,0), (-1,-1), 0.3, colors.HexColor("#bbdefb")),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 8),
]))
return tbl
def two_col_table(left_items, right_items, l_title="", r_title="",
l_bg=LIGHT_BLUE, r_bg=GREEN_LIGHT,
l_hdr=BLUE, r_hdr=GREEN):
def make_cell(items, hdr_bg, body_bg, title):
rows = []
if title:
rows.append(Paragraph(f"<b><font color='white'>{title}</font></b>",
ParagraphStyle("th", fontName="Helvetica-Bold",
fontSize=9, textColor=WHITE)))
for i in items:
rows.append(Paragraph(f"● {i}",
ParagraphStyle("td", fontName="Helvetica",
fontSize=8.5, leading=12)))
return rows
l_rows = make_cell(left_items, l_hdr, l_bg, l_title)
r_rows = make_cell(right_items, r_hdr, r_bg, r_title)
max_rows = max(len(l_rows), len(r_rows))
while len(l_rows) < max_rows: l_rows.append(Spacer(1,1))
while len(r_rows) < max_rows: r_rows.append(Spacer(1,1))
data = list(zip(l_rows, r_rows))
tbl = Table(data, colWidths=[7.8*cm, 7.8*cm], hAlign="LEFT")
tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (0, 0), l_hdr),
("BACKGROUND", (1,0), (1, 0), r_hdr),
("BACKGROUND", (0,1), (0,-1), l_bg),
("BACKGROUND", (1,1), (1,-1), r_bg),
("BOX", (0,0), (-1,-1), 0.8, NAVY),
("INNERGRID", (0,0), (-1,-1), 0.3, colors.HexColor("#cfd8dc")),
("VALIGN", (0,0), (-1,-1), "TOP"),
("TOPPADDING", (0,0),(-1,-1), 3),
("BOTTOMPADDING", (0,0),(-1,-1), 3),
("LEFTPADDING", (0,0),(-1,-1), 6),
]))
return tbl
# ββ Simple ASCII-style diagram using a Drawing βββββββββββββββββββββββββββββββ
def infection_diagram():
d = Drawing(400, 120)
boxes = [("SOURCE\n(Bacteria/\nVirus)", 20, 40), ("SPREAD\n(Air/Water/\nContact)", 130, 40),
("HOST\n(Human\nBody)", 240, 40), ("DISEASE\n(Signs &\nSymptoms)", 330, 40)]
colors_list = [RED, ORANGE, BLUE, GREEN]
for i, (label, x, col) in enumerate(zip([b[0] for b in boxes],
[b[1] for b in boxes],
colors_list)):
d.add(Rect(x, 25, 80, 70, fillColor=col, strokeColor=BLACK, strokeWidth=0.5,
rx=6, ry=6, fillOpacity=0.8))
for j, line in enumerate(label.split("\n")):
d.add(String(x+40, 80-j*12, line, fontSize=7.5, fillColor=WHITE,
fontName="Helvetica-Bold", textAnchor="middle"))
if i < 3:
d.add(Line(x+80, 60, x+110, 60, strokeColor=NAVY, strokeWidth=2))
d.add(Polygon([x+110, 55, x+120, 60, x+110, 65],
fillColor=NAVY, strokeColor=NAVY))
d.add(String(200, 8, "Chain of Infection", fontSize=9, fillColor=NAVY,
fontName="Helvetica-BoldOblique", textAnchor="middle"))
return d
def diabetes_diagram():
d = Drawing(420, 150)
# Central circle
d.add(Ellipse(210, 85, 55, 35, fillColor=ORANGE, strokeColor=ORANGE, fillOpacity=0.9))
d.add(String(210, 80, "DIABETES", fontSize=9, fillColor=WHITE,
fontName="Helvetica-Bold", textAnchor="middle"))
d.add(String(210, 68, "MELLITUS", fontSize=9, fillColor=WHITE,
fontName="Helvetica-Bold", textAnchor="middle"))
# Satellites
sats = [("Type 1\n(Autoimmune)", 60, 130, RED),
("Type 2\n(Insulin Resist.)", 60, 40, BLUE),
("Gestational\nDiabetes", 360, 130, GREEN),
("MODY\n(Genetic)", 360, 40, PURPLE)]
for label, x, y, col in sats:
d.add(Ellipse(x, y, 45, 25, fillColor=col, strokeColor=BLACK,
strokeWidth=0.5, fillOpacity=0.85))
for j, line in enumerate(label.split("\n")):
d.add(String(x, y+4-j*10, line, fontSize=7, fillColor=WHITE,
fontName="Helvetica-Bold", textAnchor="middle"))
# line to centre
d.add(Line(x + (40 if x < 200 else -40), y,
210 + (-45 if x < 200 else 45), 85,
strokeColor=col, strokeWidth=1.2, strokeDashArray=[3,2]))
d.add(String(210, 10, "Types of Diabetes Mellitus", fontSize=9,
fillColor=NAVY, fontName="Helvetica-BoldOblique", textAnchor="middle"))
return d
def heart_diagram():
d = Drawing(420, 140)
# Big heart shape approximation using ellipse
d.add(Ellipse(210, 75, 100, 55, fillColor=RED_LIGHT, strokeColor=RED, strokeWidth=1.5))
d.add(String(210, 78, "HEART", fontSize=11, fillColor=RED,
fontName="Helvetica-Bold", textAnchor="middle"))
d.add(String(210, 64, "Cardiovascular", fontSize=8, fillColor=DARK_TEXT,
fontName="Helvetica", textAnchor="middle"))
# Labels around
labels = [("Pericarditis", 60, 120), ("Myocarditis", 60, 40),
("Endocarditis", 360, 120), ("IHD / Angina", 360, 40),
("Hypertension", 210, 128), ("Cardiac Arrest", 210, 18)]
arrow_colors = [BLUE, GREEN, PURPLE, ORANGE, RED, TEAL]
for i, (lbl, x, y) in enumerate(labels):
d.add(Rect(x-42, y-10, 84, 20, fillColor=arrow_colors[i],
strokeColor=BLACK, strokeWidth=0.3, rx=4, ry=4, fillOpacity=0.8))
d.add(String(x, y+2, lbl, fontSize=7.5, fillColor=WHITE,
fontName="Helvetica-Bold", textAnchor="middle"))
d.add(String(210, 2, "Heart Diseases Overview", fontSize=9,
fillColor=NAVY, fontName="Helvetica-BoldOblique", textAnchor="middle"))
return d
def lung_diagram():
d = Drawing(420, 140)
# Left lung
d.add(Ellipse(145, 75, 60, 50, fillColor=colors.HexColor("#e8eaf6"),
strokeColor=BLUE, strokeWidth=1.5))
d.add(String(145, 78, "LEFT", fontSize=8, fillColor=BLUE,
fontName="Helvetica-Bold", textAnchor="middle"))
d.add(String(145, 66, "LUNG", fontSize=8, fillColor=BLUE,
fontName="Helvetica-Bold", textAnchor="middle"))
# Right lung
d.add(Ellipse(275, 75, 60, 50, fillColor=colors.HexColor("#e8eaf6"),
strokeColor=BLUE, strokeWidth=1.5))
d.add(String(275, 78, "RIGHT", fontSize=8, fillColor=BLUE,
fontName="Helvetica-Bold", textAnchor="middle"))
d.add(String(275, 66, "LUNG", fontSize=8, fillColor=BLUE,
fontName="Helvetica-Bold", textAnchor="middle"))
# Trachea
d.add(Rect(200, 95, 20, 30, fillColor=TEAL_LIGHT, strokeColor=TEAL, strokeWidth=1))
d.add(String(210, 113, "T", fontSize=7, fillColor=TEAL,
fontName="Helvetica-Bold", textAnchor="middle"))
# Bronchi lines
d.add(Line(200, 95, 175, 85, strokeColor=TEAL, strokeWidth=1.5))
d.add(Line(220, 95, 245, 85, strokeColor=TEAL, strokeWidth=1.5))
# Disease labels
diseases = [("Asthma", 50, 125), ("COPD", 50, 108), ("Pneumonia", 350, 125),
("TB", 350, 108), ("Emphysema", 145, 20), ("Bronchitis", 275, 20)]
cols2 = [RED, ORANGE, GREEN, PURPLE, BLUE, TEAL]
for i, (name, x, y) in enumerate(diseases):
d.add(Rect(x-32, y-8, 64, 16, fillColor=cols2[i], strokeColor=BLACK,
strokeWidth=0.3, rx=3, ry=3, fillOpacity=0.85))
d.add(String(x, y+2, name, fontSize=7.5, fillColor=WHITE,
fontName="Helvetica-Bold", textAnchor="middle"))
d.add(String(210, 4, "Respiratory System & Key Diseases", fontSize=9,
fillColor=NAVY, fontName="Helvetica-BoldOblique", textAnchor="middle"))
return d
def gi_diagram():
d = Drawing(420, 145)
organs = [("Mouth/Esophagus", 210, 128, BLUE, 65, 14),
("Stomach", 180, 105, GREEN, 50, 14),
("Small Intestine", 210, 78, ORANGE, 70, 14),
("Large Intestine", 240, 52, TEAL, 70, 14),
("Liver/Gall Bladder", 100, 105, RED, 80, 14),
("Pancreas", 310, 100, PURPLE, 55, 14)]
for name, x, y, col, w, h in organs:
d.add(Rect(x-w//2, y-h//2, w, h, fillColor=col, strokeColor=BLACK,
strokeWidth=0.4, rx=4, ry=4, fillOpacity=0.85))
d.add(String(x, y+2, name, fontSize=6.8, fillColor=WHITE,
fontName="Helvetica-Bold", textAnchor="middle"))
# Connecting lines
d.add(Line(210, 121, 180, 112, strokeColor=MID_GRAY, strokeWidth=1))
d.add(Line(180, 98, 210, 85, strokeColor=MID_GRAY, strokeWidth=1))
d.add(Line(210, 71, 240, 59, strokeColor=MID_GRAY, strokeWidth=1))
d.add(String(210, 4, "Digestive System Overview", fontSize=9,
fillColor=NAVY, fontName="Helvetica-BoldOblique", textAnchor="middle"))
return d
# ββ Build the PDF ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
output_path = "/tmp/workspace/general-medicine-notes/General_Medicine_Notes.pdf"
doc = BaseDocTemplate(output_path, pagesize=A4,
leftMargin=60, rightMargin=30,
topMargin=30, bottomMargin=30)
frame = Frame(doc.leftMargin, doc.bottomMargin,
doc.width, doc.height, id="main")
template = PageTemplate(id="notebook", frames=[frame],
onPage=draw_notebook_background)
doc.addPageTemplates([template])
story = []
SP = Spacer(1, 6)
SP2 = Spacer(1, 12)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# TITLE PAGE
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
title_style = ParagraphStyle("title", fontName="Helvetica-Bold",
fontSize=26, textColor=NAVY, leading=32,
alignment=TA_CENTER)
sub_title_style = ParagraphStyle("subtitle", fontName="Helvetica-BoldOblique",
fontSize=13, textColor=TEAL, leading=18,
alignment=TA_CENTER)
info_style = ParagraphStyle("info", fontName="Helvetica",
fontSize=10, textColor=DARK_TEXT, leading=16,
alignment=TA_CENTER)
story.append(Spacer(1, 50))
story.append(Paragraph("π GENERAL MEDICINE", title_style))
story.append(Spacer(1, 10))
story.append(Paragraph("Detailed Study Notes", sub_title_style))
story.append(Spacer(1, 20))
story.append(HRFlowable(width="80%", thickness=2, color=BLUE, hAlign="CENTER"))
story.append(Spacer(1, 20))
info_data = [
["Subject Title", "GENERAL MEDICINE"],
["Duration", "25 - 36 Months"],
["Total Hours", "60 Hours"],
["Theory / Lecture", "2 Hours / Week"],
["Assessment", "Written"],
]
info_tbl = Table(info_data, colWidths=[5*cm, 10*cm], hAlign="CENTER")
info_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (0,-1), LIGHT_BLUE),
("BACKGROUND", (1,0), (1,-1), WHITE),
("FONTNAME", (0,0), (0,-1), "Helvetica-Bold"),
("FONTNAME", (1,0), (1,-1), "Helvetica"),
("FONTSIZE", (0,0), (-1,-1), 10),
("TEXTCOLOR", (0,0), (0,-1), NAVY),
("BOX", (0,0), (-1,-1), 1, NAVY),
("INNERGRID", (0,0), (-1,-1), 0.5, BLUE),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0),(-1,-1), 5),
("LEFTPADDING", (0,0),(-1,-1), 10),
]))
story.append(info_tbl)
story.append(Spacer(1, 20))
story.append(HRFlowable(width="80%", thickness=2, color=BLUE, hAlign="CENTER"))
story.append(Spacer(1, 15))
story.append(Paragraph("Topics Covered:", ParagraphStyle("tc", fontName="Helvetica-Bold",
fontSize=11, textColor=BLUE,
alignment=TA_CENTER)))
topics = ["1. Infection | 2. Poisoning | 3. Food & Nutrition",
"4. Endocrine Diseases | 5. Diseases of the Blood",
"6. Digestive System | 7. Cardiovascular Disease",
"8. Respiratory Disease | 9. Skin Diseases",
"10. Pediatrics | 11. Psychiatric Disorders"]
for t in topics:
story.append(Paragraph(t, ParagraphStyle("tp", fontName="Helvetica",
fontSize=10, textColor=DARK_TEXT,
alignment=TA_CENTER, leading=16)))
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 1 - INFECTION
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 1: INFECTION [3 Hours]", NAVY))
story.append(SP)
story.append(body("Infection = When harmful germs (bacteria, viruses, fungi, parasites) enter the body and cause damage. Think of it like UNINVITED GUESTS breaking into your house and making a mess!"))
story.append(SP2)
story.append(sub_header("1.1 Chain of Infection (How it spreads)", BLUE))
story.append(SP)
story.append(infection_diagram())
story.append(SP2)
story.append(sub_header("1.2 Types of Infections", BLUE))
story.append(SP)
story.append(two_col_table(
["Localized - stays in one area (e.g. skin boil)",
"Generalized - spreads throughout body",
"Bacterial - caused by bacteria (e.g. TB, typhoid)",
"Viral - caused by viruses (e.g. HIV, flu)"],
["Fungal - caused by fungi (e.g. ringworm)",
"Parasitic - caused by parasites (e.g. malaria)",
"Food poisoning - from contaminated food",
"STDs - spread through sexual contact"],
"TYPES A-D", "TYPES E-H", LIGHT_BLUE, GREEN_LIGHT
))
story.append(SP2)
story.append(key_box("VACCINATIONS - Your Body's Shield!", [
"Vaccines train your immune system BEFORE the real infection arrives",
"They contain weak/dead germs - your body learns to fight them",
"Examples: BCG (TB), Polio vaccine, MMR (Measles, Mumps, Rubella)",
"Herd Immunity: if 70-80% are vaccinated, whole community is protected",
], LIGHT_BLUE, BLUE))
story.append(SP2)
story.append(key_box("HIV & AIDS - Simple Explanation", [
"HIV = Human Immunodeficiency Virus - attacks CD4 T-cells (your immune soldiers)",
"AIDS = Acquired Immunodeficiency Syndrome - final stage of HIV infection",
"Transmission: sexual contact, blood transfusion, sharing needles, mother to child",
"Remember: HIV positive != AIDS. AIDS is diagnosed when CD4 count < 200 cells/uL",
"Treatment: ART (Antiretroviral Therapy) - does not cure but controls the virus",
], RED_LIGHT, RED))
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 2 - POISONING
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 2: POISONING [2 Hours]", colors.HexColor("#b71c1c")))
story.append(SP)
story.append(body("Poisoning = entry of harmful substances into the body that disrupt normal function. Can be accidental, intentional, or occupational."))
story.append(SP2)
poison_data = [
[Paragraph("<b><font color='white'>Category</font></b>",
ParagraphStyle("ph", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Examples</font></b>",
ParagraphStyle("ph", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Key Signs</font></b>",
ParagraphStyle("ph", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE))],
[body("Pharmaceutical"), body("Paracetamol, Aspirin, Opioids"), body("Liver failure, bleeding, drowsiness")],
[body("Pesticides"), body("Organophosphates, Rodenticides"), body("Excessive sweating, seizures, small pupils")],
[body("Drugs of Misuse"), body("Heroin, Cocaine, Alcohol"), body("Altered consciousness, cardiac issues")],
[body("Envenomation"), body("Snake bite, Scorpion sting"), body("Local swelling, paralysis, coagulopathy")],
[body("Chemical"), body("Acid, Alkali, Carbon Monoxide"), body("Burns, headache, coma")],
]
poison_tbl = Table(poison_data, colWidths=[4*cm, 5.5*cm, 6*cm])
poison_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), RED),
("BACKGROUND", (0,1), (-1,-1), RED_LIGHT),
("ROWBACKGROUNDS", (0,1), (-1,-1), [RED_LIGHT, WHITE]),
("BOX", (0,0), (-1,-1), 1, RED),
("INNERGRID", (0,0), (-1,-1), 0.3, colors.HexColor("#ef9a9a")),
("TOPPADDING", (0,0),(-1,-1), 4),
("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING",(0,0),(-1,-1), 6),
]))
story.append(poison_tbl)
story.append(SP2)
story.append(key_box("General Management of Poisoning (ABCDE Approach)", [
"A - Airway: ensure it's clear, intubate if needed",
"B - Breathing: give oxygen if required",
"C - Circulation: IV access, fluids, monitor BP & heart",
"D - Disability: check consciousness (GCS score), give glucose",
"E - Exposure & Antidote: identify poison, give specific antidote if available",
"REMEMBER: Remove from exposure. Never induce vomiting for acid/alkali!",
], ORANGE_LIGHT, ORANGE))
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 3 - FOOD AND NUTRITION
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 3: FOOD & NUTRITION [4 Hours]", GREEN))
story.append(SP)
story.append(body("Nutrition is like FUEL for your body. Wrong fuel = body breaks down. Good nutrition = engine runs smoothly!"))
story.append(SP2)
story.append(sub_header("3.1 Nutritional Requirements (Daily Needs)", GREEN))
story.append(SP)
nutr_data = [
[Paragraph("<b><font color='white'>Nutrient</font></b>", ParagraphStyle("nh", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Function</font></b>", ParagraphStyle("nh", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Deficiency Disease</font></b>", ParagraphStyle("nh", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE))],
[body("Carbohydrates"), body("Main energy source"), body("Fatigue, ketosis")],
[body("Proteins"), body("Build & repair tissues"), body("Kwashiorkor, Marasmus")],
[body("Fats"), body("Energy store, hormones"), body("Fat-soluble vitamin deficiency")],
[body("Vitamin A"), body("Vision, immunity"), body("Night blindness, Xerophthalmia")],
[body("Vitamin B12"), body("Nerve function, RBC"), body("Pernicious Anemia")],
[body("Vitamin C"), body("Collagen synthesis"), body("Scurvy (gum bleeding)")],
[body("Vitamin D"), body("Bone health (calcium)"), body("Rickets (children), Osteomalacia")],
[body("Iron"), body("Oxygen transport in RBC"), body("Iron-deficiency Anemia")],
[body("Iodine"), body("Thyroid hormone production"), body("Goitre, Hypothyroidism")],
]
nutr_tbl = Table(nutr_data, colWidths=[4*cm, 5*cm, 6.5*cm])
nutr_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), GREEN),
("ROWBACKGROUNDS", (0,1), (-1,-1), [GREEN_LIGHT, WHITE]),
("BOX", (0,0), (-1,-1), 1, GREEN),
("INNERGRID", (0,0), (-1,-1), 0.3, colors.HexColor("#a5d6a7")),
("TOPPADDING", (0,0),(-1,-1), 4),
("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING",(0,0),(-1,-1), 6),
]))
story.append(nutr_tbl)
story.append(SP2)
story.append(key_box("Protein-Energy Malnutrition (PEM)", [
"MARASMUS = Severe lack of ALL nutrients (protein + calories). Looks like a skeleton!",
" Signs: severe wasting, very low weight, no edema, 'old man' face",
"KWASHIORKOR = Protein deficiency with adequate calories",
" Signs: edema (swollen belly), hair color change, skin lesions, 'pot belly'",
"Treatment: Feed slowly with therapeutic foods (F-75 then F-100 formula)",
], ORANGE_LIGHT, ORANGE))
story.append(SP2)
story.append(key_box("OBESITY - Causes, Effects & Management", [
"Cause: More calories IN than OUT over long time. Also: genetics, hypothyroidism, medications",
"BMI > 25 = Overweight | BMI > 30 = Obese | BMI > 40 = Morbidly Obese",
"Complications: Diabetes, Hypertension, Heart disease, Sleep apnea, Joint problems",
"Management: Diet (reduce 500 kcal/day) + Exercise (150 min/week) + Medications + Surgery (bariatric)",
], RED_LIGHT, RED))
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 4 - ENDOCRINE DISEASES
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 4: ENDOCRINE DISEASES [4 Hours]", ORANGE))
story.append(SP)
story.append(body("Endocrine system = Your body's MESSAGING SYSTEM. Glands release hormones (chemical messengers) that control almost every body function."))
story.append(SP2)
story.append(sub_header("4.1 Key Endocrine Glands & Their Jobs", ORANGE))
story.append(SP)
gland_data = [
[Paragraph("<b><font color='white'>Gland</font></b>", ParagraphStyle("gh", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Hormone</font></b>", ParagraphStyle("gh", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Function</font></b>", ParagraphStyle("gh", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Disorder if wrong</font></b>", ParagraphStyle("gh", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE))],
[body("Thyroid"), body("T3, T4"), body("Controls metabolism"), body("Hypo/Hyperthyroidism, Goitre")],
[body("Pancreas"), body("Insulin, Glucagon"), body("Blood sugar control"), body("Diabetes Mellitus")],
[body("Adrenal"), body("Cortisol, Adrenaline"), body("Stress response"), body("Cushing's, Addison's disease")],
[body("Pituitary"), body("GH, TSH, ACTH..."), body("Controls other glands"), body("Gigantism, Acromegaly, Dwarfism")],
[body("Parathyroid"), body("PTH"), body("Calcium regulation"), body("Hypo/Hyperparathyroidism")],
]
gland_tbl = Table(gland_data, colWidths=[3*cm, 3.5*cm, 4.5*cm, 4.5*cm])
gland_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), ORANGE),
("ROWBACKGROUNDS", (0,1), (-1,-1), [ORANGE_LIGHT, WHITE]),
("BOX", (0,0), (-1,-1), 1, ORANGE),
("INNERGRID", (0,0), (-1,-1), 0.3, YELLOW),
("TOPPADDING", (0,0),(-1,-1), 4),
("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING",(0,0),(-1,-1), 6),
]))
story.append(gland_tbl)
story.append(SP2)
story.append(sub_header("4.2 Diabetes Mellitus - The Most Common Endocrine Disease", ORANGE))
story.append(SP)
story.append(diabetes_diagram())
story.append(SP)
story.append(key_box("Diabetes - Signs & Symptoms (The 3 Ps + more)", [
"Polyuria = Passing lots of urine (excess glucose pulls water out)",
"Polydipsia = Excessive thirst (losing too much water)",
"Polyphagia = Increased hunger (cells can't use glucose, brain thinks starving)",
"Weight loss, fatigue, blurred vision, slow wound healing, frequent infections",
"DKA (Diabetic Ketoacidosis): fruity breath, rapid breathing, vomiting - EMERGENCY!",
], YELLOW_LIGHT, YELLOW))
story.append(SP)
story.append(key_box("Diabetes Management (Simple Steps)", [
"Type 1: Insulin injections (must - pancreas makes ZERO insulin)",
"Type 2: Lifestyle change first, then Metformin, then other pills, then Insulin",
"Diet: Low GI foods, reduce sugar & refined carbs, regular meals",
"Exercise: 150 min moderate exercise per week - improves insulin sensitivity",
"Monitor: Regular HbA1c (target < 7%), blood glucose, BP, kidney function, eye check",
"Complications to watch: Eyes (retinopathy), Kidneys (nephropathy), Nerves (neuropathy), Feet!",
], ORANGE_LIGHT, ORANGE))
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 5 - DISEASES OF THE BLOOD
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 5: DISEASES OF THE BLOOD [4 Hours]", RED))
story.append(SP)
story.append(body("Blood = the body's TRANSPORT SYSTEM. Red cells carry oxygen, white cells fight infection, platelets stop bleeding, plasma carries nutrients."))
story.append(SP2)
story.append(sub_header("5.1 Anemia - Not Enough Oxygen Carriers", RED))
story.append(SP)
anemia_data = [
[Paragraph("<b><font color='white'>Type of Anemia</font></b>", ParagraphStyle("ah", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Cause</font></b>", ParagraphStyle("ah", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Treatment</font></b>", ParagraphStyle("ah", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE))],
[body("Iron Deficiency"), body("Low iron - most common type"), body("Oral iron supplements, dietary iron")],
[body("Vitamin B12 Deficiency"), body("Pernicious anemia, vegan diet"), body("B12 injections or supplements")],
[body("Folate Deficiency"), body("Poor diet, pregnancy, alcohol"), body("Folic acid tablets")],
[body("Sickle Cell"), body("Genetic - abnormal hemoglobin"), body("Hydroxyurea, transfusions, bone marrow transplant")],
[body("Aplastic Anemia"), body("Bone marrow failure"), body("Stem cell transplant, immunosuppression")],
[body("Hemolytic Anemia"), body("RBC destroyed too quickly"), body("Treat cause, steroids, splenectomy")],
]
anemia_tbl = Table(anemia_data, colWidths=[4*cm, 5*cm, 6.5*cm])
anemia_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), RED),
("ROWBACKGROUNDS", (0,1), (-1,-1), [RED_LIGHT, WHITE]),
("BOX", (0,0), (-1,-1), 1, RED),
("INNERGRID", (0,0), (-1,-1), 0.3, colors.HexColor("#ef9a9a")),
("TOPPADDING", (0,0),(-1,-1), 4), ("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING",(0,0),(-1,-1), 6),
]))
story.append(anemia_tbl)
story.append(SP2)
story.append(key_box("Common Signs of Anemia (PALE mnemonic)", [
"P - Pallor (pale skin, pale conjunctiva - look inside lower eyelid!)",
"A - Angina / shortness of breath (heart works harder)",
"L - Lethargy (tiredness, weakness, can't concentrate)",
"E - Exercise intolerance (palpitations on mild exertion)",
"Also: Brittle nails, hair loss, swollen tongue (glossitis) in iron deficiency",
], RED_LIGHT, RED))
story.append(SP2)
story.append(key_box("HEMOPHILIA - When Blood Won't Clot", [
"Cause: Genetic X-linked disorder - missing clotting factor VIII (Hemophilia A) or IX (Hemophilia B)",
"Mostly affects MALES. Females are carriers.",
"Signs: Prolonged bleeding after cuts, joint bleeding (hemarthrosis), deep muscle bleeds",
"Severity: Mild (factor level 5-40%), Moderate (1-5%), Severe (<1%)",
"Management: Factor VIII/IX replacement, DDAVP for mild cases",
"Complications: Joint damage (from repeated bleeds), viral infections from blood products",
], PURPLE_LIGHT, PURPLE))
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 6 - DIGESTIVE SYSTEM
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 6: DISEASES OF THE DIGESTIVE SYSTEM [7 Hours]", TEAL))
story.append(SP)
story.append(body("The GI tract = a 9-metre long tube that processes food. Think of it as a FACTORY ASSEMBLY LINE from mouth to rectum."))
story.append(SP2)
story.append(gi_diagram())
story.append(SP2)
gi_conditions = [
("Peptic Ulcer Disease", "H. pylori infection or NSAID use damages stomach lining", "Burning epigastric pain, worse before meals", "Antacids, PPIs (omeprazole), H. pylori eradication"),
("GERD (Reflux Oesophagitis)", "Stomach acid flows back up into oesophagus", "Heartburn, regurgitation, worse lying down", "Lifestyle changes, PPIs, antacids"),
("Pancreatitis", "Inflammation of pancreas (alcohol, gallstones)", "Severe upper abdominal pain radiating to back", "Nil by mouth, IV fluids, pain relief"),
("Ulcerative Colitis", "Inflammatory bowel disease - colon & rectum", "Bloody diarrhoea, urgency, cramping", "Aminosalicylates, steroids, biologics"),
("Viral Hepatitis", "Liver inflammation by Hepatitis A/B/C/D/E virus", "Jaundice, fatigue, dark urine, pale stools", "Rest, antivirals (Hep B/C), avoid alcohol"),
("Cholecystitis", "Gallbladder inflammation (usually from gallstones)", "RUQ pain after fatty meals, fever, nausea", "Antibiotics, cholecystectomy (surgery)"),
]
for condition, cause, features, treatment in gi_conditions:
story.append(sub_header(f"β’ {condition}", TEAL))
tbl_data = [
[Paragraph("<b>Cause:</b>", ParagraphStyle("cl", fontName="Helvetica-Bold", fontSize=9, textColor=TEAL)),
body(cause)],
[Paragraph("<b>Features:</b>", ParagraphStyle("fl", fontName="Helvetica-Bold", fontSize=9, textColor=RED)),
body(features)],
[Paragraph("<b>Treatment:</b>", ParagraphStyle("tl", fontName="Helvetica-Bold", fontSize=9, textColor=GREEN)),
body(treatment)],
]
mini_tbl = Table(tbl_data, colWidths=[2.5*cm, 13*cm])
mini_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (0,-1), TEAL_LIGHT),
("BACKGROUND", (1,0), (1,-1), WHITE),
("BOX", (0,0), (-1,-1), 0.5, TEAL),
("INNERGRID", (0,0), (-1,-1), 0.2, colors.HexColor("#b2dfdb")),
("TOPPADDING", (0,0),(-1,-1), 3), ("BOTTOMPADDING",(0,0),(-1,-1), 3),
("LEFTPADDING",(0,0),(-1,-1), 5),
]))
story.append(mini_tbl)
story.append(SP)
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 7 - CARDIOVASCULAR
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 7: CARDIOVASCULAR DISEASE [8 Hours]", RED))
story.append(SP)
story.append(body("The heart is a PUMP that beats ~100,000 times/day. Even a slight malfunction can be life-threatening!"))
story.append(SP2)
story.append(heart_diagram())
story.append(SP2)
story.append(sub_header("7.1 Investigations of the Heart", BLUE))
story.append(SP)
story.append(key_box("Key Cardiac Investigations", [
"ECG (Electrocardiogram): Records electrical activity of heart. Detects arrhythmias, MI, hypertrophy",
"Exercise Stress Test (Treadmill): ECG during exercise - detects ischaemia that appears on exertion",
"Echocardiogram: Ultrasound of heart - shows structure, valves, ejection fraction",
"Chest X-ray: Shows heart size, pulmonary oedema, pleural effusion",
"Coronary Angiography: Gold standard for coronary artery disease - dye injected to visualise arteries",
], LIGHT_BLUE, BLUE))
story.append(SP2)
cardio_conditions = [
("Ischaemic Heart Disease (IHD)", "Atherosclerosis (fatty plaques) in coronary arteries", "Chest pain (angina), dyspnoea, pain radiates to arm/jaw", "GTN spray, aspirin, statins, beta-blockers, angioplasty/CABG"),
("Hypertension", "Unknown (essential) or secondary to kidney/hormonal disease", "Usually NO symptoms! Can cause headache, visual changes", "Lifestyle + ACE inhibitors, Calcium channel blockers, Diuretics"),
("Pericarditis", "Viral infection, autoimmune, post-MI", "Sharp chest pain, worse lying flat, better leaning forward", "NSAIDs, colchicine, treat cause"),
("Heart Failure", "Damaged heart muscle (IHD, HTN, valvular disease)", "Dyspnoea on exertion, orthopnoea, ankle swelling, fatigue", "ACE inhibitors, beta-blockers, diuretics, spironolactone"),
("Cardiac Arrest", "VF/VT, massive MI, PE, electrolyte imbalance", "No pulse, no breathing, unconsciousness", "CPR immediately, defibrillation, adrenaline, ABCDE"),
]
for condition, cause, features, treatment in cardio_conditions:
story.append(sub_header(f"β’ {condition}", RED))
tbl_data = [
[Paragraph("<b>Cause:</b>", ParagraphStyle("cl2", fontName="Helvetica-Bold", fontSize=9, textColor=ORANGE)),
body(cause)],
[Paragraph("<b>Features:</b>", ParagraphStyle("fl2", fontName="Helvetica-Bold", fontSize=9, textColor=RED)),
body(features)],
[Paragraph("<b>Treatment:</b>", ParagraphStyle("tl2", fontName="Helvetica-Bold", fontSize=9, textColor=GREEN)),
body(treatment)],
]
mini_tbl = Table(tbl_data, colWidths=[2.5*cm, 13*cm])
mini_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (0,-1), RED_LIGHT),
("BACKGROUND", (1,0), (1,-1), WHITE),
("BOX", (0,0), (-1,-1), 0.5, RED),
("INNERGRID", (0,0), (-1,-1), 0.2, colors.HexColor("#ef9a9a")),
("TOPPADDING", (0,0),(-1,-1), 3), ("BOTTOMPADDING",(0,0),(-1,-1), 3),
("LEFTPADDING",(0,0),(-1,-1), 5),
]))
story.append(mini_tbl)
story.append(SP)
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 8 - RESPIRATORY
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 8: RESPIRATORY DISEASE [9 Hours]", BLUE))
story.append(SP)
story.append(body("Breathing = OXYGEN IN, CO2 OUT. The lungs are like BELLOWS that never stop working. Even a small blockage can cause serious problems."))
story.append(SP2)
story.append(lung_diagram())
story.append(SP2)
story.append(sub_header("8.1 COPD vs Restrictive Lung Disease", BLUE))
story.append(SP)
story.append(two_col_table(
["Obstructive: difficult to BREATHE OUT",
"Air gets trapped in lungs",
"FEV1/FVC ratio < 0.7",
"Causes: Smoking, pollution",
"Examples: Asthma, Emphysema, Chronic Bronchitis"],
["Restrictive: lungs CANNOT expand fully",
"Less air gets in",
"FVC reduced, FEV1/FVC normal",
"Causes: Fibrosis, obesity, scoliosis",
"Examples: Pulmonary fibrosis, Sarcoidosis"],
"OBSTRUCTIVE (COPD)", "RESTRICTIVE",
LIGHT_BLUE, TEAL_LIGHT, BLUE, TEAL
))
story.append(SP2)
resp_conditions = [
("Asthma", "Allergens, cold air, exercise, infections trigger airway inflammation", "Wheeze, cough (esp. night), breathlessness, chest tightness - REVERSIBLE", "SABA inhaler (salbutamol) for acute, ICS for prevention, avoid triggers"),
("Pneumonia", "Bacterial (Strep pneumoniae most common), viral, fungal infection of alveoli", "Fever, cough with purulent sputum, pleuritic chest pain, consolidation on X-ray", "Antibiotics (amoxicillin for CAP), oxygen, fluids, physiotherapy"),
("Tuberculosis (TB)", "Mycobacterium tuberculosis - spread by respiratory droplets", "Chronic cough (>3 weeks), haemoptysis, night sweats, weight loss, fever", "RIPE therapy: Rifampicin, Isoniazid, Pyrazinamide, Ethambutol x 6 months"),
("Pulmonary Embolism", "Blood clot in pulmonary artery (usually from DVT in leg)", "Sudden dyspnoea, pleuritic chest pain, haemoptysis, tachycardia", "Anticoagulation (heparin then warfarin/DOAC), thrombolysis if severe"),
]
for condition, cause, features, treatment in resp_conditions:
story.append(sub_header(f"β’ {condition}", BLUE))
tbl_data = [
[Paragraph("<b>Cause:</b>", ParagraphStyle("cl3", fontName="Helvetica-Bold", fontSize=9, textColor=TEAL)),
body(cause)],
[Paragraph("<b>Features:</b>", ParagraphStyle("fl3", fontName="Helvetica-Bold", fontSize=9, textColor=RED)),
body(features)],
[Paragraph("<b>Treatment:</b>", ParagraphStyle("tl3", fontName="Helvetica-Bold", fontSize=9, textColor=GREEN)),
body(treatment)],
]
mini_tbl = Table(tbl_data, colWidths=[2.5*cm, 13*cm])
mini_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (0,-1), LIGHT_BLUE),
("BACKGROUND", (1,0), (1,-1), WHITE),
("BOX", (0,0), (-1,-1), 0.5, BLUE),
("INNERGRID", (0,0), (-1,-1), 0.2, colors.HexColor("#90caf9")),
("TOPPADDING", (0,0),(-1,-1), 3), ("BOTTOMPADDING",(0,0),(-1,-1), 3),
("LEFTPADDING",(0,0),(-1,-1), 5),
]))
story.append(mini_tbl)
story.append(SP)
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 9 - SKIN
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 9: DISEASES OF THE SKIN [6 Hours]", PURPLE))
story.append(SP)
story.append(body("Skin = Body's FIRST LINE OF DEFENSE. It protects against infection, regulates temperature, and provides sensation. When it breaks down, serious problems follow!"))
story.append(SP2)
skin_data = [
[Paragraph("<b><font color='white'>Condition</font></b>", ParagraphStyle("sk", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Cause</font></b>", ParagraphStyle("sk", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Key Features</font></b>", ParagraphStyle("sk", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Treatment</font></b>", ParagraphStyle("sk", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE))],
[body("Leprosy"), body("Mycobacterium leprae"), body("Loss of sensation in patches, nerve thickening, deformity"), body("MDT: Rifampicin + Dapsone Β± Clofazimine")],
[body("Psoriasis"), body("Autoimmune (T-cell mediated)"), body("Well-defined red scaly plaques on elbows, knees, scalp"), body("Topical steroids, Vitamin D analogues, biologics")],
[body("Eczema / Dermatitis"), body("Allergic, contact, or atopic"), body("Itchy, red, weeping, scaly skin"), body("Emollients, topical steroids, antihistamines")],
[body("Fungal Infections"), body("Candida, Tinea (ringworm)"), body("Ring-shaped rash, itchy, scaling. Oral thrush = white patches"), body("Antifungals: clotrimazole cream, fluconazole")],
[body("Viral (Herpes/Warts)"), body("HSV, HPV, Varicella-Zoster"), body("Painful blisters (herpes), warts, vesicular rash (shingles)"), body("Acyclovir for herpes, cryotherapy for warts")],
]
skin_tbl = Table(skin_data, colWidths=[3*cm, 3.5*cm, 5*cm, 4*cm])
skin_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), PURPLE),
("ROWBACKGROUNDS", (0,1), (-1,-1), [PURPLE_LIGHT, WHITE]),
("BOX", (0,0), (-1,-1), 1, PURPLE),
("INNERGRID", (0,0), (-1,-1), 0.3, colors.HexColor("#ce93d8")),
("TOPPADDING", (0,0),(-1,-1), 4), ("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING",(0,0),(-1,-1), 5),
("FONTSIZE", (0,0), (-1,-1), 8.5),
]))
story.append(skin_tbl)
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 10 - PEDIATRICS
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 10: PEDIATRICS [8 Hours]", colors.HexColor("#0277bd")))
story.append(SP)
story.append(body("Pediatrics = Medical care of children (0-18 years). Children are NOT just small adults - their bodies, diseases, and treatments are different!"))
story.append(SP2)
story.append(key_box("Low Birth Weight (LBW) Infants", [
"LBW = Birth weight < 2500 grams",
"Causes: Prematurity, intrauterine growth restriction (IUGR), infection, maternal malnutrition",
"Problems: Hypothermia (can't regulate temperature), Hypoglycaemia, Respiratory Distress Syndrome",
"Management: Kangaroo Mother Care (skin-to-skin), incubator warmth, early feeding, oxygen if needed",
], LIGHT_BLUE, BLUE))
story.append(SP2)
story.append(key_box("Cerebral Palsy (CP)", [
"Definition: Non-progressive motor disorder due to brain damage before/during/after birth",
"Causes: Prematurity, birth asphyxia, infections (meningitis), jaundice (kernicterus), trauma",
"Types: Spastic (most common - stiff muscles), Athetoid (involuntary movements), Ataxic (balance problems)",
"Features: Delayed milestones, abnormal posture, spasticity, speech difficulties",
"Treatment: Physiotherapy (KEY!), speech therapy, occupational therapy, medications for spasticity, surgery",
], TEAL_LIGHT, TEAL))
story.append(SP2)
story.append(key_box("Epilepsy in Children", [
"Definition: Recurrent unprovoked seizures due to abnormal brain electrical activity",
"Types: Grand mal (tonic-clonic), Absence seizures (blank staring), Febrile seizures",
"Diagnosis: EEG (electroencephalogram), MRI brain, blood tests",
"Treatment: Sodium valproate, Carbamazepine, Phenobarbitone. Status epilepticus = diazepam IV!",
"Key: Most children OUTGROW epilepsy. Education of parents is vital for safety!",
], YELLOW_LIGHT, YELLOW))
story.append(SP2)
story.append(key_box("Developmental Delay - Red Flags", [
"Not smiling by 2 months | Not sitting by 9 months | Not walking by 18 months",
"No speech by 18 months | Losing previously gained skills = REGRESSION (serious sign!)",
"Causes: CP, Down syndrome, Autism, hearing/vision loss, hypothyroidism, abuse/neglect",
"AUTISM: Social communication difficulties, restricted interests, repetitive behaviors",
"Management: Early intervention is KEY - speech therapy, OT, PT, special education",
], ORANGE_LIGHT, ORANGE))
story.append(PageBreak())
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# UNIT 11 - PSYCHIATRY
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(section_header(" UNIT 11: PSYCHIATRIC DISORDERS [5 Hours]", colors.HexColor("#4a148c")))
story.append(SP)
story.append(body("Psychiatry = Diseases of the MIND. Just like any other organ, the brain can malfunction. Mental illness is a medical condition, NOT a character weakness!"))
story.append(SP2)
psych_data = [
[Paragraph("<b><font color='white'>Disorder</font></b>", ParagraphStyle("ps", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Key Features</font></b>", ParagraphStyle("ps", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE)),
Paragraph("<b><font color='white'>Treatment</font></b>", ParagraphStyle("ps", fontName="Helvetica-Bold", fontSize=9, textColor=WHITE))],
[body("Depression"), body("Low mood, loss of interest (anhedonia), sleep disturbance, worthlessness, suicidal thoughts"), body("CBT + SSRIs (Fluoxetine, Sertraline)")],
[body("Anxiety Disorder"), body("Excessive worry, panic attacks, palpitations, sweating, avoidance behaviour"), body("CBT, SSRIs, relaxation techniques")],
[body("Schizophrenia"), body("Hallucinations (hearing voices), delusions, disorganized thinking, negative symptoms"), body("Antipsychotics (Haloperidol, Olanzapine), CBT")],
[body("Bipolar Disorder"), body("Alternating mania (euphoria, no sleep needed) and depression episodes"), body("Mood stabilizers (Lithium, Valproate), antipsychotics")],
[body("OCD"), body("Obsessive thoughts + compulsive behaviours to reduce anxiety (e.g. repeated hand washing)"), body("CBT (ERP therapy), SSRIs (high dose)")],
[body("PTSD"), body("After trauma: flashbacks, nightmares, hypervigilance, avoidance"), body("Trauma-focused CBT, EMDR, SSRIs")],
]
psych_tbl = Table(psych_data, colWidths=[3.5*cm, 6.5*cm, 5.5*cm])
psych_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), PURPLE),
("ROWBACKGROUNDS", (0,1), (-1,-1), [PURPLE_LIGHT, WHITE]),
("BOX", (0,0), (-1,-1), 1, PURPLE),
("INNERGRID", (0,0), (-1,-1), 0.3, colors.HexColor("#ce93d8")),
("TOPPADDING", (0,0),(-1,-1), 4), ("BOTTOMPADDING",(0,0),(-1,-1), 4),
("LEFTPADDING",(0,0),(-1,-1), 5),
]))
story.append(psych_tbl)
story.append(SP2)
story.append(key_box("Classification Systems Used in Psychiatry", [
"ICD-11 (WHO): International Classification of Diseases - used in UK, India, most of world",
"DSM-5 (APA): Diagnostic and Statistical Manual - used primarily in USA",
"Both classify by symptoms and duration, NOT by biological tests (no blood test for depression!)",
"Common treatments: Psychotherapy (talk therapy), Pharmacotherapy (medications), ECT (shock therapy for severe depression)",
], PURPLE_LIGHT, PURPLE))
story.append(SP2)
# ββ Recommended Books ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
story.append(HRFlowable(width="100%", thickness=2, color=NAVY))
story.append(SP)
story.append(section_header(" RECOMMENDED TEXTBOOKS", NAVY))
story.append(SP)
books = [
["1", "Davidson's Principles and Practice of Medicine", "Most comprehensive clinical medicine textbook"],
["2", "Harrison's Internal Medicine", "Gold standard for internal medicine - very detailed"],
["3", "Braunwald's Heart Disease", "Definitive cardiology textbook"],
["4", "Text Book of Cardiology by Hurst", "Practical cardiology reference"],
]
book_tbl = Table(books, colWidths=[1*cm, 7*cm, 7.5*cm])
book_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), LIGHT_BLUE),
("ROWBACKGROUNDS", (0,0), (-1,-1), [LIGHT_BLUE, WHITE]),
("TEXTCOLOR", (0,0), (-1,-1), DARK_TEXT),
("FONTNAME", (0,0), (-1,-1), "Helvetica"),
("FONTSIZE", (0,0), (-1,-1), 9.5),
("BOX", (0,0), (-1,-1), 1, NAVY),
("INNERGRID",(0,0), (-1,-1), 0.3, BLUE),
("TOPPADDING", (0,0),(-1,-1), 6), ("BOTTOMPADDING",(0,0),(-1,-1), 6),
("LEFTPADDING",(0,0),(-1,-1), 8),
]))
story.append(book_tbl)
story.append(SP2)
story.append(Paragraph(
"<i>These notes are a simplified overview for study purposes. Always refer to the recommended textbooks for complete clinical details.</i>",
ParagraphStyle("disc", fontName="Helvetica-Oblique", fontSize=8.5,
textColor=MID_GRAY, alignment=TA_CENTER)
))
# ββ Build ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
doc.build(story)
print(f"PDF created successfully: {output_path}")
cd /tmp/workspace/general-medicine-notes && python create_notes.py 2>&1
ls -lh /tmp/workspace/general-medicine-notes/
General Medicine Notes
PDF Document Β· PDF
| Unit | Topic | Hours |
|---|---|---|
| 1 | Infection - Chain of infection diagram, HIV/AIDS, Vaccinations | 3 hrs |
| 2 | Poisoning - Table of poisons + ABCDE management box | 2 hrs |
| 3 | Food & Nutrition - Nutrient deficiency table, PEM (Kwashiorkor vs Marasmus), Obesity | 4 hrs |
| 4 | Endocrine Diseases - Gland table, Diabetes diagram (4 types), 3 Ps mnemonic | 4 hrs |
| 5 | Blood Diseases - Anemia types table, PALE mnemonic, Hemophilia | 4 hrs |
| 6 | Digestive System - GI diagram, 6 conditions with cause/features/treatment | 7 hrs |
| 7 | Cardiovascular - Heart diagram, ECG/investigations, 5 conditions explained | 8 hrs |
| 8 | Respiratory - Lung diagram, COPD vs Restrictive table, Asthma/Pneumonia/TB/PE | 9 hrs |
| 9 | Skin Diseases - Leprosy, Psoriasis, Eczema, Fungal infections | 6 hrs |
| 10 | Pediatrics - LBW, Cerebral Palsy, Epilepsy, Developmental delay, Autism | 8 hrs |
| 11 | Psychiatry - Depression, Schizophrenia, Bipolar, OCD, PTSD table | 5 hrs |
I don't wants I want brief explanation in easy words hand written note
python3 -c "import matplotlib.font_manager as fm; fonts = [f.name for f in fm.fontManager.ttflist]; hw = [f for f in fonts if any(x in f.lower() for x in ['hand', 'comic', 'cursive', 'chalk', 'indie', 'caveat', 'pacifico', 'shadow', 'patrick', 'kalam', 'dancing'])]; print(hw[:20])"
pip install --user requests --quiet && python3 -c " import urllib.request, os # Download a free handwriting font (Patrick Hand from Google Fonts CDN) url = 'https://fonts.gstatic.com/s/patrickhand/v23/LDI1apSQOAYtSuYWp8ZweqbFnZpA.ttf' out = '/tmp/workspace/general-medicine-notes/PatrickHand.ttf' urllib.request.urlretrieve(url, out) print('Downloaded:', os.path.getsize(out), 'bytes') "
python3 -c " # Check available system fonts import matplotlib.font_manager as fm import os # List all available font files font_dirs = ['/usr/share/fonts', '/usr/local/share/fonts', os.path.expanduser('~/.fonts')] for d in font_dirs: if os.path.exists(d): for root, dirs, files in os.walk(d): for f in files: if f.lower().endswith(('.ttf', '.otf')): print(os.path.join(root, f)) " 2>/dev/null | head -30
~/general-medicine-notes/handwritten_notes.py
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.patches import FancyBboxPatch, FancyArrowPatch
import matplotlib.patheffects as pe
import numpy as np
from matplotlib.backends.backend_pdf import PdfPages
import warnings
warnings.filterwarnings('ignore')
# ββ Colour palette βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
PAPER = "#fffef5"
LINE_C = "#c8d8f0"
MARGIN = "#ffb3b3"
INK = "#1a1a2e"
BLUE = "#1565c0"
RED = "#c62828"
GREEN = "#2e7d32"
ORANGE = "#e65100"
PURPLE = "#6a1b9a"
TEAL = "#00695c"
YELLOW = "#f9a825"
BOX_BG = {
"blue": "#e3f2fd",
"red": "#ffebee",
"green": "#e8f5e9",
"orange": "#fff3e0",
"purple": "#f3e5f5",
"teal": "#e0f2f1",
"yellow": "#fffde7",
}
# ββ Page setup helper ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def new_page():
fig, ax = plt.subplots(figsize=(8.27, 11.69)) # A4
fig.patch.set_facecolor(PAPER)
ax.set_facecolor(PAPER)
ax.set_xlim(0, 8.27)
ax.set_ylim(0, 11.69)
ax.axis('off')
# Horizontal ruled lines
for y in np.arange(0.3, 11.69, 0.38):
ax.axhline(y, color=LINE_C, lw=0.5, zorder=0)
# Red margin line
ax.axvline(0.9, color=MARGIN, lw=1.2, zorder=1)
# Spiral holes
for y in np.arange(10.8, 0.5, -1.5):
circ = plt.Circle((0.25, y), 0.07, color="#d0d0d0", zorder=5)
ax.add_patch(circ)
return fig, ax
def t(ax, x, y, text, size=11, color=INK, weight='normal', style='normal',
ha='left', va='bottom', alpha=1.0, family='DejaVu Sans'):
"""Draw text with slight handwriting-like imperfection."""
ax.text(x, y, text, fontsize=size, color=color, fontweight=weight,
fontstyle=style, ha=ha, va=va, alpha=alpha,
fontfamily=family, zorder=10)
def heading(ax, y, text, color=BLUE, size=14, underline=True):
"""Section heading with underline."""
ax.text(1.05, y, text, fontsize=size, color=color, fontweight='bold',
fontstyle='italic', va='bottom', zorder=10)
if underline:
xlen = len(text) * size * 0.012
ax.plot([1.05, min(1.05 + xlen, 7.9)], [y - 0.02, y - 0.02],
color=color, lw=1.5, zorder=9)
def bullet_line(ax, x, y, text, color=BLUE, size=10.5):
ax.text(x - 0.18, y + 0.06, "β€", fontsize=8, color=color, va='bottom', zorder=10)
ax.text(x, y, text, fontsize=size, color=INK, va='bottom', zorder=10)
def box(ax, x, y, w, h, bg="blue", title="", title_color=None):
"""Coloured sticky-note style box."""
bg_c = BOX_BG.get(bg, "#f5f5f5")
title_c = title_color or {"blue": BLUE, "red": RED, "green": GREEN,
"orange": ORANGE, "purple": PURPLE,
"teal": TEAL, "yellow": YELLOW}.get(bg, BLUE)
rect = FancyBboxPatch((x, y), w, h, boxstyle="round,pad=0.04",
facecolor=bg_c, edgecolor=title_c, linewidth=1.2, zorder=8)
ax.add_patch(rect)
if title:
ax.text(x + 0.12, y + h - 0.04, title, fontsize=9.5, color=title_c,
fontweight='bold', va='top', zorder=11)
return y + h - 0.28 # y position to start writing inside (from top)
def star(ax, x, y, color=YELLOW):
ax.text(x, y, "β
", fontsize=9, color=color, va='bottom', zorder=10)
def arrow_right(ax, x, y, length=0.4, color=BLUE):
ax.annotate("", xy=(x + length, y + 0.1), xytext=(x, y + 0.1),
arrowprops=dict(arrowstyle="->", color=color, lw=1.2), zorder=10)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# PAGE 1 - TITLE + UNIT 1: INFECTION
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def page_title_infection():
fig, ax = new_page()
# Title banner
rect = FancyBboxPatch((0.9, 10.9), 6.8, 0.65, boxstyle="round,pad=0.05",
facecolor=BLUE, edgecolor=BLUE, zorder=8)
ax.add_patch(rect)
ax.text(4.3, 11.27, "π GENERAL MEDICINE β STUDY NOTES",
fontsize=14, color="white", fontweight='bold', ha='center',
va='center', zorder=11)
ax.text(4.3, 10.68, "All 11 Units | Brief & Easy to Understand",
fontsize=9.5, color=BLUE, ha='center', va='bottom',
fontstyle='italic', zorder=10)
# Subject info box
ax.text(1.05, 10.38, "Subject:", fontsize=9, color=TEAL, fontweight='bold')
ax.text(2.2, 10.38, "General Medicine | 60 Hrs | 2 Hrs/Week | Assessment: Written", fontsize=9, color=INK)
# UNIT 1 heading
heading(ax, 9.9, "UNIT 1 β INFECTION (3 hrs)", color=RED)
t(ax, 1.05, 9.55, "π Infection = Harmful germs enter body β cause disease", size=10.5, color=INK)
# Chain of infection - simple arrow diagram
ax.text(1.05, 9.15, "HOW IT SPREADS (Chain of Infection):", fontsize=9.5, color=BLUE, fontweight='bold')
steps = [("SOURCE\n(Germ)", 1.3, RED), ("SPREAD\n(Air/Water/Touch)", 2.7, ORANGE),
("HOST\n(Human Body)", 4.4, BLUE), ("DISEASE\n(Illness)", 5.9, GREEN)]
for label, xc, col in steps:
rect2 = FancyBboxPatch((xc - 0.5, 8.45), 1.0, 0.52,
boxstyle="round,pad=0.04", facecolor=col,
edgecolor=col, alpha=0.85, zorder=8)
ax.add_patch(rect2)
lines = label.split("\n")
ax.text(xc, 8.75 - (0.13 if len(lines) > 1 else 0), lines[0],
fontsize=7.5, color="white", fontweight='bold',
ha='center', va='center', zorder=11)
if len(lines) > 1:
ax.text(xc, 8.56, lines[1], fontsize=6.5, color="white",
ha='center', va='center', zorder=11)
for xarr in [1.8, 3.2, 4.9]:
ax.annotate("", xy=(xarr + 0.4, 8.71), xytext=(xarr, 8.71),
arrowprops=dict(arrowstyle="->", color="#555", lw=1.5), zorder=10)
# Types
ax.text(1.05, 8.2, "Types:", fontsize=9.5, color=BLUE, fontweight='bold')
types_txt = [
"β’ Bacterial (TB, Typhoid) β’ Viral (HIV, Flu) β’ Fungal (Ringworm)",
"β’ Localized (skin boil) vs Generalized (spreads all over body)",
"β’ Food poisoning β’ STDs (sexually transmitted) β’ HIV / AIDS"
]
for i, ln in enumerate(types_txt):
t(ax, 1.05, 7.88 - i * 0.3, ln, size=9.8)
# HIV box
box(ax, 1.05, 6.6, 6.2, 1.0, bg="red", title="β
HIV & AIDS (Remember This!)")
lines_hiv = [
"HIV = virus attacks CD4 cells (immune soldiers) β AIDS = final stage (CD4 < 200)",
"Spread: unprotected sex, sharing needles, blood, motherβchild",
"Tx: ART (antiretroviral therapy) β controls virus, can't cure"
]
for i, ln in enumerate(lines_hiv):
t(ax, 1.2, 7.35 - i * 0.27, f"β€ {ln}", size=9.2, color="#b71c1c")
# Vaccination box
box(ax, 1.05, 5.45, 6.2, 0.95, bg="green", title="β
Vaccinations")
vac = ["Train immune system BEFORE real infection arrives",
"BCG (TB), Polio, MMR (Measles/Mumps/Rubella), Hepatitis B",
"Herd Immunity: 70-80% vaccinated β whole community protected"]
for i, ln in enumerate(vac):
t(ax, 1.2, 6.1 - i * 0.27, f"β€ {ln}", size=9.2, color=GREEN)
# UNIT 2 heading
heading(ax, 5.1, "UNIT 2 β POISONING (2 hrs)", color=RED)
t(ax, 1.05, 4.78, "π Poisoning = harmful substance enters body β disrupts normal function", size=10.5)
ax.text(1.05, 4.5, "ABCDE Management:", fontsize=9.5, color=RED, fontweight='bold')
abcde = ["A β Airway: keep it clear", "B β Breathing: give oxygen",
"C β Circulation: IV line, fluids", "D β Disability: check consciousness",
"E β Exposure: identify poison, give antidote"]
for i, ln in enumerate(abcde):
t(ax, 1.15, 4.22 - i * 0.28, f" {ln}", size=9.5)
ax.text(1.05, 2.88, "Common Poisons:", fontsize=9.5, color=ORANGE, fontweight='bold')
poisons = ["β’ Pharmaceutical (paracetamol, opioids) β liver failure, sedation",
"β’ Pesticides (organophosphates) β sweating, seizures, small pupils",
"β’ Envenomation (snake/scorpion) β swelling, paralysis, bleeding",
"β’ β Never induce vomiting for acid/alkali poisons!"]
for i, ln in enumerate(poisons):
t(ax, 1.1, 2.6 - i * 0.28, ln, size=9.5)
# page number
ax.text(4.1, 0.12, "β Page 1 β General Medicine Notes", fontsize=8,
color="#aaa", ha='center', fontstyle='italic')
return fig
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# PAGE 2 - UNIT 3: NUTRITION + UNIT 4: ENDOCRINE
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def page_nutrition_endocrine():
fig, ax = new_page()
heading(ax, 11.45, "UNIT 3 β FOOD & NUTRITION (4 hrs)", color=GREEN)
t(ax, 1.05, 11.1, "π Food = fuel for body. Wrong fuel = body breaks down!", size=10.5)
ax.text(1.05, 10.82, "Key Deficiency Diseases:", fontsize=9.5, color=GREEN, fontweight='bold')
defs = [
"β’ Vitamin A β Night blindness (can't see in dark)",
"β’ Vitamin C β Scurvy (gum bleeding, wounds won't heal)",
"β’ Vitamin D β Rickets in kids / Osteomalacia in adults (soft bones)",
"β’ Iron β Anemia (pale, tired, breathless)",
"β’ Iodine β Goitre / Hypothyroidism (swollen neck, slow metabolism)",
"β’ Vitamin B12 β Pernicious Anemia (nerve damage + tired)",
]
for i, ln in enumerate(defs):
t(ax, 1.1, 10.54 - i * 0.28, ln, size=9.5)
# PEM box
box(ax, 1.05, 8.55, 6.2, 1.35, bg="orange", title="β
PEM β Protein Energy Malnutrition")
pem = [
"MARASMUS = lacks BOTH protein + calories",
" β Looks like skeleton: very thin, no fat, 'old man' face, no oedema",
"KWASHIORKOR = only protein deficient (has some calories)",
" β Pot belly, swollen legs, hair colour change, skin patches",
"Tx: Therapeutic feeding (F-75 formula first, then F-100)",
]
for i, ln in enumerate(pem):
t(ax, 1.2, 9.6 - i * 0.27, ln, size=9.2, color=ORANGE)
# Obesity
box(ax, 1.05, 7.45, 6.2, 0.87, bg="red", title="Obesity")
ob = ["BMI>25=Overweight BMI>30=Obese BMI>40=Morbid",
"Causes: Excess calories, genetics, hormones (thyroid)",
"Tx: Diet (-500 kcal/day) + Exercise + Meds + Surgery (bariatric)"]
for i, ln in enumerate(ob):
t(ax, 1.2, 8.02 - i * 0.27, f"β€ {ln}", size=9, color=RED)
# UNIT 4
heading(ax, 7.05, "UNIT 4 β ENDOCRINE DISEASES (4 hrs)", color=ORANGE)
t(ax, 1.05, 6.72, "π Endocrine = glands release hormones (chemical messengers)", size=10.5)
ax.text(1.05, 6.44, "Key Glands:", fontsize=9.5, color=ORANGE, fontweight='bold')
glands = [
("Thyroid", "T3/T4 β metabolism", "Hypo/Hyperthyroidism, Goitre"),
("Pancreas", "Insulin β blood sugar", "Diabetes Mellitus"),
("Adrenal", "Cortisol β stress", "Cushing's / Addison's"),
("Pituitary", "Controls all glands", "Gigantism / Dwarfism"),
]
ax.text(1.1, 6.18, "Gland", fontsize=8.5, color=BLUE, fontweight='bold')
ax.text(2.5, 6.18, "Hormone / Job", fontsize=8.5, color=BLUE, fontweight='bold')
ax.text(4.8, 6.18, "Disease if wrong", fontsize=8.5, color=RED, fontweight='bold')
ax.plot([1.05, 7.8], [6.1, 6.1], color="#ccc", lw=0.8)
for i, (g, h, d) in enumerate(glands):
yy = 5.83 - i * 0.3
t(ax, 1.1, yy, g, size=9.5, color=TEAL, weight='bold')
t(ax, 2.5, yy, h, size=9.2)
t(ax, 4.8, yy, d, size=9.2, color=RED)
ax.plot([1.05, 7.8], [yy - 0.06, yy - 0.06], color="#eee", lw=0.5)
# Diabetes
box(ax, 1.05, 3.0, 6.2, 1.55, bg="orange", title="β
DIABETES MELLITUS β Most Important!")
dm = [
"Type 1: Autoimmune β NO insulin made β daily injections needed",
"Type 2: Cells resist insulin β most common (lifestyle related)",
"3 P's β Polyuria (lots of pee) Polydipsia (lots of thirst) Polyphagia (lots of hunger)",
"Plus: weight loss, blurred vision, slow wound healing",
"Tx: Diet + Exercise β Metformin β other pills β Insulin",
"Check: HbA1c (target <7%), eyes, kidneys, feet every year!",
]
for i, ln in enumerate(dm):
t(ax, 1.2, 4.25 - i * 0.28, f"β€ {ln}", size=9.2, color=ORANGE)
ax.text(1.05, 2.78, "Diabetes Complications (6 things to remember):", fontsize=9, color=RED, fontweight='bold')
comp = "Eyes (Retinopathy) | Kidneys (Nephropathy) | Nerves (Neuropathy)"
t(ax, 1.1, 2.5, comp, size=9.5)
comp2 = "Feet (Ulcers) | Heart (IHD) | Brain (Stroke)"
t(ax, 1.1, 2.22, comp2, size=9.5)
ax.text(4.1, 0.12, "β Page 2 β General Medicine Notes", fontsize=8,
color="#aaa", ha='center', fontstyle='italic')
return fig
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# PAGE 3 - UNIT 5: BLOOD + UNIT 6: DIGESTIVE
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def page_blood_digestive():
fig, ax = new_page()
heading(ax, 11.45, "UNIT 5 β DISEASES OF THE BLOOD (4 hrs)", color=RED)
t(ax, 1.05, 11.1, "π Blood = transport system. RBC (O2), WBC (fight infection), Platelets (clotting)", size=10)
ax.text(1.05, 10.82, "ANEMIA β Not enough oxygen carriers:", fontsize=9.5, color=RED, fontweight='bold')
ax.text(1.1, 10.58, "Signs: PALE skin, tiredness, breathlessness, fast heart beat", fontsize=9.5, color=INK)
anemias = [
("Iron Deficiency", "(most common)", "Iron tablets, eat leafy veggies/meat"),
("B12 Deficiency", "(nerve damage)", "B12 injections"),
("Sickle Cell", "(genetic)", "Hydroxyurea, transfusions"),
("Aplastic", "(marrow failure)", "Bone marrow transplant"),
]
ax.text(1.1, 10.32, "Type", fontsize=8.5, color=BLUE, fontweight='bold')
ax.text(3.0, 10.32, "Note", fontsize=8.5, color=MID := "#777", fontweight='bold')
ax.text(4.6, 10.32, "Treatment", fontsize=8.5, color=GREEN, fontweight='bold')
ax.plot([1.05, 7.8], [10.24, 10.24], color="#ccc", lw=0.7)
for i, (tp, note, tx) in enumerate(anemias):
yy = 9.98 - i * 0.3
t(ax, 1.1, yy, tp, size=9.3, color=RED, weight='bold')
t(ax, 3.0, yy, note, size=8.8, color="#777", style='italic')
t(ax, 4.6, yy, tx, size=9.2, color=GREEN)
ax.plot([1.05, 7.8], [yy - 0.06, yy - 0.06], color="#eee", lw=0.5)
box(ax, 1.05, 8.1, 6.2, 0.95, bg="purple", title="β
HEMOPHILIA")
hemo = ["Genetic (X-linked) β missing clotting factor VIII (A) or IX (B)",
"Affects MALES mainly. Females = carriers",
"Signs: prolonged bleeding, joint bleeds (hemarthrosis)",
"Tx: Factor VIII/IX replacement injections"]
for i, ln in enumerate(hemo):
t(ax, 1.2, 8.75 - i * 0.27, f"β€ {ln}", size=9.2, color=PURPLE)
# UNIT 6
heading(ax, 7.7, "UNIT 6 β DIGESTIVE SYSTEM (7 hrs)", color=TEAL)
t(ax, 1.05, 7.38, "π GI tract = 9 m tube from mouth to anus, breaks down food", size=10)
# Mini GI diagram
organs = [("Mouth", 1.4, 7.0), ("Oesophagus", 2.3, 7.0), ("Stomach", 3.4, 7.0),
("Small Bowel", 4.6, 7.0), ("Large Bowel", 5.8, 7.0), ("Liver/GB", 3.4, 6.55)]
colors_gi = [TEAL, BLUE, GREEN, ORANGE, RED, PURPLE]
for j, (org, xc, yc) in enumerate(organs):
rect = FancyBboxPatch((xc - 0.5, yc - 0.17), 1.0, 0.32,
boxstyle="round,pad=0.03", facecolor=colors_gi[j],
edgecolor=colors_gi[j], alpha=0.8, zorder=8)
ax.add_patch(rect)
ax.text(xc, yc, org, fontsize=7, color="white", ha='center',
va='center', fontweight='bold', zorder=11)
for xarr2 in [1.9, 2.8, 3.9, 5.1]:
ax.annotate("", xy=(xarr2 + 0.35, 7.0), xytext=(xarr2, 7.0),
arrowprops=dict(arrowstyle="->", color="#555", lw=1), zorder=10)
ax.annotate("", xy=(3.4, 6.83), xytext=(3.4, 6.17+0.5),
arrowprops=dict(arrowstyle="->", color=PURPLE, lw=1), zorder=10)
ax.text(1.05, 6.35, "Key Conditions:", fontsize=9.5, color=TEAL, fontweight='bold')
gi_conds = [
("Peptic Ulcer", "H.pylori / NSAIDs β burning pain before meals β PPIs + H.pylori eradication"),
("GERD", "Acid reflux up oesophagus β heartburn, worse lying β PPIs, lifestyle"),
("Pancreatitis", "Inflammation (alcohol/gallstones) β severe back pain β nil by mouth + fluids"),
("Ulcerative C", "IBD of colon β bloody diarrhoea β aminosalicylates, steroids"),
("Hepatitis", "Liver inflammation (virus A/B/C) β jaundice, dark urine β antivirals"),
("Cholecystitis","Gallbladder inflamed (gallstones) β RUQ pain after fatty food β surgery"),
]
for i, (name, desc) in enumerate(gi_conds):
yy2 = 6.05 - i * 0.32
t(ax, 1.1, yy2, f"β’ {name}:", size=9.3, color=TEAL, weight='bold')
t(ax, 2.65, yy2, desc, size=9.0)
ax.text(4.1, 0.12, "β Page 3 β General Medicine Notes", fontsize=8,
color="#aaa", ha='center', fontstyle='italic')
return fig
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# PAGE 4 - UNIT 7: CARDIOVASCULAR
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def page_cardiovascular():
fig, ax = new_page()
heading(ax, 11.45, "UNIT 7 β CARDIOVASCULAR DISEASE (8 hrs)", color=RED)
t(ax, 1.05, 11.1, "π Heart = pump, beats 100,000x/day! Small problem = big danger", size=10.5)
# Simple heart diagram
ax.text(1.05, 10.8, "Heart Investigations:", fontsize=9.5, color=BLUE, fontweight='bold')
invx = [("ECG", 1.6, 10.5), ("Echo", 2.9, 10.5), ("Stress Test", 4.25, 10.5),
("Chest X-ray", 5.75, 10.5), ("Angiogram", 7.0, 10.5)]
inv_cols = [BLUE, GREEN, ORANGE, TEAL, PURPLE]
for j, (inv, xc, yc) in enumerate(invx):
rect = FancyBboxPatch((xc - 0.52, yc - 0.18), 1.04, 0.33,
boxstyle="round,pad=0.03", facecolor=inv_cols[j],
alpha=0.85, zorder=8)
ax.add_patch(rect)
ax.text(xc, yc, inv, fontsize=7.5, color="white", ha='center',
va='center', fontweight='bold', zorder=11)
ax.text(1.05, 10.1, "ECG = records electrical activity | Echo = ultrasound of heart | Angiogram = gold standard", fontsize=8.5, color="#555")
ax.text(1.05, 9.82, "Key Heart Conditions:", fontsize=9.5, color=RED, fontweight='bold')
heart_conds = [
("IHD / Angina", "Blocked coronary arteries (fatty plaque)",
"Chest pain β arm/jaw, worse on exertion",
"GTN spray, aspirin, statin, angioplasty"),
("Hypertension", "Unknown cause (essential) or kidney/hormones",
"Silent killer β usually NO symptoms!",
"ACE inhibitor / calcium blocker / diuretic"),
("Heart Failure", "Damaged heart (IHD, HTN, valves)",
"Breathless, ankle swelling, can't lie flat",
"ACE-i, beta-blocker, diuretics"),
("Pericarditis", "Viral infection, autoimmune",
"Sharp chest pain, better leaning forward",
"NSAIDs, colchicine"),
("Cardiac Arrest", "VF / big MI / electrolyte imbalance",
"No pulse, unconscious β EMERGENCY!",
"CPR + defibrillation + adrenaline STAT"),
("Rheumatic Fever", "Group A strep throat β autoimmune attack on heart valves",
"Joint pain, fever, heart murmur",
"Penicillin + aspirin + bed rest"),
]
cols_h = [BLUE, ORANGE, RED, TEAL, RED, PURPLE]
for i, (name, cause, feat, tx) in enumerate(heart_conds):
ybase = 9.48 - i * 1.18
# name banner
rect3 = FancyBboxPatch((1.05, ybase + 0.72), 6.2, 0.28,
boxstyle="round,pad=0.02",
facecolor=cols_h[i], alpha=0.85, zorder=8)
ax.add_patch(rect3)
ax.text(1.15, ybase + 0.88, name, fontsize=9.5, color="white",
fontweight='bold', va='center', zorder=11)
t(ax, 1.15, ybase + 0.56, f"Cause: {cause}", size=9.0, color="#444")
t(ax, 1.15, ybase + 0.28, f"Signs: {feat}", size=9.0, color=RED)
t(ax, 1.15, ybase + 0.02, f"Tx: {tx}", size=9.0, color=GREEN)
ax.text(4.1, 0.12, "β Page 4 β General Medicine Notes", fontsize=8,
color="#aaa", ha='center', fontstyle='italic')
return fig
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# PAGE 5 - UNIT 8: RESPIRATORY
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def page_respiratory():
fig, ax = new_page()
heading(ax, 11.45, "UNIT 8 β RESPIRATORY DISEASE (9 hrs)", color=BLUE)
t(ax, 1.05, 11.1, "π Lungs = bellows that never stop. O2 in, CO2 out β every breath counts!", size=10.5)
# Lung sketch
ax.text(1.05, 10.82, "Investigations:", fontsize=9.5, color=BLUE, fontweight='bold')
ax.text(1.1, 10.55, "Chest X-ray | PFT (Pulmonary Function Tests) | ABG (Arterial Blood Gas) | CT scan | Sputum culture", fontsize=9, color=INK)
# COPD vs Restrictive
box(ax, 1.05, 9.1, 2.9, 1.2, bg="blue", title="OBSTRUCTIVE (COPD)")
ob_txt = ["Hard to BREATHE OUT", "Air gets trapped in lungs",
"FEV1/FVC < 0.7", "Causes: smoking, pollution",
"Types: Asthma, Emphysema,", "Chronic Bronchitis"]
for i, ln in enumerate(ob_txt):
t(ax, 1.15, 9.98 - i * 0.24, ln, size=8.5, color=BLUE)
box(ax, 4.2, 9.1, 2.9, 1.2, bg="teal", title="RESTRICTIVE")
res_txt = ["Lungs can't EXPAND fully",
"Less air gets IN",
"FVC reduced, FEV1/FVC OK",
"Causes: fibrosis, obesity",
"Types: Pulm. Fibrosis,",
"Sarcoidosis, Scoliosis"]
for i, ln in enumerate(res_txt):
t(ax, 4.35, 9.98 - i * 0.24, ln, size=8.5, color=TEAL)
ax.text(1.05, 8.9, "Key Lung Diseases:", fontsize=9.5, color=BLUE, fontweight='bold')
resp_conds = [
("ASTHMA", "Allergens/cold/exercise trigger airway inflammation",
"WHEEZE, cough (night), tight chest β REVERSIBLE",
"SABA inhaler (salbutamol) acute; ICS (steroid inhaler) to prevent"),
("PNEUMONIA", "Bacteria (Strep pneumoniae), virus, fungi infect alveoli",
"Fever, green sputum, chest pain, consolidation on X-ray",
"Antibiotics (amoxicillin), O2, fluids, physio"),
("TB", "Mycobacterium tuberculosis β respiratory droplets",
"Cough >3 weeks, blood in sputum, night sweats, weight loss",
"RIPE Γ 6 months: Rifampicin, Isoniazid, Pyrazinamide, Ethambutol"),
("COPD", "Smoking β chronic damage to airways and alveoli",
"Chronic cough, breathless on exertion, barrel chest (emphysema)",
"Stop smoking! Inhalers (LABA + ICS), pulm rehab, O2"),
("PE", "Blood clot in pulmonary artery (usually from leg DVT)",
"Sudden breathlessness, pleuritic pain, coughing blood, fast heart",
"Anticoagulation (heparin β warfarin/DOAC), thrombolysis if severe"),
]
resp_cols = [BLUE, GREEN, RED, ORANGE, PURPLE]
for i, (name, cause, feat, tx) in enumerate(resp_conds):
ybase = 8.56 - i * 1.08
rect4 = FancyBboxPatch((1.05, ybase + 0.68), 6.2, 0.27,
boxstyle="round,pad=0.02",
facecolor=resp_cols[i], alpha=0.85, zorder=8)
ax.add_patch(rect4)
ax.text(1.15, ybase + 0.83, name, fontsize=9.5, color="white",
fontweight='bold', va='center', zorder=11)
t(ax, 1.15, ybase + 0.52, f"Cause: {cause}", size=8.8, color="#444")
t(ax, 1.15, ybase + 0.26, f"Signs: {feat}", size=8.8, color=RED)
t(ax, 1.15, ybase + 0.02, f"Tx: {tx}", size=8.8, color=GREEN)
ax.text(4.1, 0.12, "β Page 5 β General Medicine Notes", fontsize=8,
color="#aaa", ha='center', fontstyle='italic')
return fig
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# PAGE 6 - UNIT 9: SKIN + UNIT 10: PEDIATRICS + UNIT 11: PSYCHIATRY
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def page_skin_paeds_psych():
fig, ax = new_page()
heading(ax, 11.45, "UNIT 9 β SKIN DISEASES (6 hrs)", color=PURPLE)
t(ax, 1.05, 11.1, "π Skin = first line of defence. Largest organ of the body!", size=10.5)
skin_data = [
("Leprosy", "M. leprae (bacteria)", "Numb skin patches, nerve thickening", "MDT: Rifampicin+Dapsone"),
("Psoriasis", "Autoimmune (T-cells)", "Red, scaly plaques on elbows/knees", "Steroids, Vit D cream, biologics"),
("Eczema", "Allergic/atopic", "Itchy, weeping, red skin", "Emollients, steroid creams"),
("Fungal", "Candida, Tinea", "Ring-shaped itchy rash, white patches","Antifungals (clotrimazole)"),
("Herpes/Warts","HSV/HPV virus", "Painful blisters / warts", "Acyclovir (herpes), cryo (warts)"),
]
ax.text(1.1, 10.82, "Condition", fontsize=8.5, color=PURPLE, fontweight='bold')
ax.text(2.5, 10.82, "Cause", fontsize=8.5, color=BLUE, fontweight='bold')
ax.text(3.95, 10.82, "Key Signs", fontsize=8.5, color=RED, fontweight='bold')
ax.text(5.75, 10.82, "Treatment", fontsize=8.5, color=GREEN, fontweight='bold')
ax.plot([1.05, 7.8], [10.74, 10.74], color="#ccc", lw=0.7)
for i, (cond, cause, signs, tx) in enumerate(skin_data):
yy = 10.48 - i * 0.31
t(ax, 1.1, yy, cond, size=9, color=PURPLE, weight='bold')
t(ax, 2.5, yy, cause, size=8.8)
t(ax, 3.95, yy, signs, size=8.5, color=RED)
t(ax, 5.75, yy, tx, size=8.5, color=GREEN)
ax.plot([1.05, 7.8], [yy - 0.07, yy - 0.07], color="#eee", lw=0.5)
# UNIT 10
heading(ax, 8.85, "UNIT 10 β PEDIATRICS (8 hrs)", color=TEAL)
t(ax, 1.05, 8.52, "π Children are NOT small adults β different diseases, doses, treatment!", size=10.5)
paeds_boxes = [
("LBW Infants\n(Low Birth Weight < 2500g)",
"Causes: prematurity, IUGR\nProblems: cold, low sugar, breathing difficulty\nTx: Kangaroo Mother Care + warmth + early feeds",
"teal"),
("Cerebral Palsy (CP)",
"Brain damage before/during/after birth β permanent motor disorder\nTypes: Spastic (stiff), Athetoid (jerky), Ataxic (balance)\nTx: Physiotherapy KEY! + Speech therapy + medications",
"blue"),
("Epilepsy in Children",
"Seizures = abnormal brain electricity. Types: Grand mal, Absence, Febrile\nDx: EEG + MRI. Tx: Sodium valproate / Carbamazepine\nStatus epilepticus = IV diazepam immediately!",
"orange"),
("Developmental Delay β Red Flags",
"No smile @2m, no sit @9m, no walk @18m, no words @18m\nCauses: CP, Autism, Down syndrome, hypothyroidism, neglect\nAutism: social difficulties + repetitive behaviour\nTx: Early intervention = speech + OT + physio + special school",
"purple"),
]
for i, (title, content, col) in enumerate(paeds_boxes):
n_lines = len(content.split("\n"))
ht = 0.2 + n_lines * 0.27 + 0.25
ybase = 8.12 - i * 1.18
box(ax, 1.05, ybase, 6.2, ht, bg=col, title=title)
for j, ln in enumerate(content.split("\n")):
t(ax, 1.2, ybase + ht - 0.33 - j * 0.27, ln, size=8.8)
# UNIT 11
heading(ax, 3.15, "UNIT 11 β PSYCHIATRIC DISORDERS (5 hrs)", color=PURPLE)
t(ax, 1.05, 2.82, "π Brain can also get sick! Mental illness = medical condition, not weakness", size=10)
psych_data = [
("Depression", "Low mood, no interest, sleep problems, suicidal thoughts", "CBT + SSRIs (fluoxetine)"),
("Anxiety", "Excessive worry, panic attacks, palpitations, avoidance", "CBT + SSRIs + relaxation"),
("Schizophrenia", "Hearing voices, delusions, disorganized thinking", "Antipsychotics (olanzapine)"),
("Bipolar", "Mania (no sleep, euphoria) β Depression swings", "Lithium / Valproate"),
("OCD", "Obsessive thoughts + compulsive acts (e.g. washing hands)", "CBT (ERP) + high dose SSRI"),
]
ax.text(1.1, 2.53, "Disorder", fontsize=8.5, color=PURPLE, fontweight='bold')
ax.text(2.8, 2.53, "Key Features", fontsize=8.5, color=RED, fontweight='bold')
ax.text(5.85, 2.53, "Treatment", fontsize=8.5, color=GREEN, fontweight='bold')
ax.plot([1.05, 7.8], [2.45, 2.45], color="#ccc", lw=0.7)
for i, (dis, feat, tx) in enumerate(psych_data):
yy = 2.2 - i * 0.31
t(ax, 1.1, yy, dis, size=8.8, color=PURPLE, weight='bold')
t(ax, 2.8, yy, feat, size=8.5)
t(ax, 5.85, yy, tx, size=8.5, color=GREEN)
ax.plot([1.05, 7.8], [yy - 0.07, yy - 0.07], color="#eee", lw=0.5)
ax.text(1.05, 0.65, "Recommended Books:", fontsize=9, color=BLUE, fontweight='bold')
ax.text(1.1, 0.4, "1. Davidson's Principles of Medicine 2. Harrison's Internal Medicine 3. Braunwald's Cardiology", fontsize=8.5, color=INK)
ax.text(4.1, 0.12, "β Page 6 β General Medicine Notes", fontsize=8,
color="#aaa", ha='center', fontstyle='italic')
return fig
# ββ Save all pages to PDF ββββββββββββββββββββββββββββββββββββββββββββββββββββ
output = "/tmp/workspace/general-medicine-notes/GM_Handwritten_Notes.pdf"
with PdfPages(output) as pdf:
for page_func in [page_title_infection, page_nutrition_endocrine,
page_blood_digestive, page_cardiovascular,
page_respiratory, page_skin_paeds_psych]:
fig = page_func()
pdf.savefig(fig, bbox_inches='tight', dpi=150)
plt.close(fig)
print(f" β {page_func.__name__}")
import os
print(f"\nDone! File: {output} ({os.path.getsize(output)//1024} KB)")
cd /tmp/workspace/general-medicine-notes && python3 handwritten_notes.py 2>&1
~/general-medicine-notes/handwritten_notes.py
Successfully replaced 1 instance(s) of the string in '/tmp/workspace/general-medicine-notes/handwritten_notes.py'
cd /tmp/workspace/general-medicine-notes && python3 handwritten_notes.py 2>&1
GM Handwritten Notes
PDF Document Β· PDF
| Page | Content |
|---|---|
| Page 1 | Unit 1: Infection (Chain of Infection diagram, HIV/AIDS, Vaccinations) + Unit 2: Poisoning (ABCDE rule) |
| Page 2 | Unit 3: Nutrition (deficiency table, Kwashiorkor vs Marasmus, Obesity) + Unit 4: Endocrine (glands table, Diabetes β 3 P's) |
| Page 3 | Unit 5: Blood (Anemia types, PALE signs, Haemophilia) + Unit 6: Digestive (GI diagram, 6 conditions) |
| Page 4 | Unit 7: Cardiovascular (ECG/investigations, 6 heart conditions with causeβsignsβtreatment) |
| Page 5 | Unit 8: Respiratory (COPD vs Restrictive, Asthma/Pneumonia/TB/COPD/PE) |
| Page 6 | Unit 9: Skin + Unit 10: Pediatrics (LBW, CP, Epilepsy, Autism) + Unit 11: Psychiatry (5 disorders) |