hemorrhage
| Type | Size | Features |
|---|---|---|
| Petechiae | 1-2 mm | Minute skin/mucosal/serosal hemorrhages; causes: thrombocytopenia, platelet dysfunction, vitamin C deficiency (scurvy) |
| Purpura | 3-5 mm | Slightly larger; causes: same as petechiae, plus trauma, vasculitis, vascular fragility |
| Ecchymoses | 1-2 cm | Subcutaneous hematomas ("bruises"); color shifts from red-blue (hemoglobin) → blue-green (bilirubin) → golden-brown (hemosiderin) |
| Hematoma | Variable | Localized accumulation of blood within tissue; can be trivial (bruise) or fatal (retroperitoneal hematoma from aortic dissection) |


| Parameter | Class I | Class II | Class III | Class IV |
|---|---|---|---|---|
| Blood loss (mL) | Up to 750 | 750-1500 | 1500-2000 | >2000 |
| % Blood volume | Up to 15% | 15-30% | 30-40% | >40% |
| Heart rate | <100 | >100 | >120 | >140 |
| Blood pressure | Normal | Normal | Decreased | Decreased |
| Pulse pressure | Normal/increased | Decreased | Decreased | Decreased |
| Respiratory rate | 14-20 | 20-30 | 30-40 | >35 |
| Urine output (mL/hr) | >30 | 20-30 | 5-15 | Negligible |
| Mental status | Slightly anxious | Mildly anxious | Anxious, confused | Confused, lethargic |
| Fluid replacement | Crystalloid | Crystalloid | Crystalloid + blood | Crystalloid + blood |
30-year-female in her first trimester of pregnancy presented with spontaneous bleeding per vaginum with passage of occasional vesicles associated with excessive vomiting. Her serum β-HCG level was markedlv elevated. (2+4+4=10) [19P] a. What is the most likely diagnosis? Explain with reason. b. Discuss the cvtogenetic abnormalities found in this case. c. Tabulate the differentiating features between the two morphological subtypes with diagrams
| Clinical Feature | Significance |
|---|---|
| First trimester bleeding per vaginum | Trophoblastic tissue eroding uterine vessels |
| Passage of vesicles (grape-like structures) | Pathognomonic - these are the hydropic, cystically swollen chorionic villi |
| Excessive vomiting (hyperemesis) | Due to markedly elevated β-HCG stimulating the vomiting center |
| Markedly elevated serum β-HCG | Massive trophoblastic proliferation produces far more HCG than a normal pregnancy of the same gestational age; complete moles can exceed 100,000 IU/L |
| First trimester presentation | Average detection at ~9 weeks gestation |

Key point: No 46,XX complete mole ever has maternal nuclear chromosomes. This is exploited diagnostically - complete moles are p57 negative (p57 is a paternally imprinted, maternally expressed gene product; absent when there are no maternal chromosomes).
Key point: The extra haploid set is always of paternal origin - the mole still has a preponderance of paternal genes, which drives trophoblastic proliferation. Partial moles are p57 positive (maternal chromosomes present).
| Complete Mole | Partial Mole | |
|---|---|---|
| Ploidy | Diploid | Triploid (occasionally tetraploid) |
| Karyotype | 46,XX (90%) or 46,XY (10%) | 69,XXX / 69,XXY / 69,XYY |
| Mechanism | Monospermy + endoreduplication, or dispermy into empty ovum | Dispermy into normal ovum |
| Origin of chromosomes | Entirely paternal | 2 paternal sets + 1 maternal set |
| p57 immunostaining | Negative | Positive |
| Feature | Complete Mole | Partial Mole |
|---|---|---|
| Karyotype | Diploid - 46,XX or 46,XY | Triploid - 69,XXX, 69,XXY, 69,XYY |
| Gross appearance | Uterine cavity distended by mass of grape-like vesicles; NO fetal parts | Smaller vesicles mixed with normal-looking villi; fetal/embryonic parts may be present |
| Villous edema | Affects all villi (diffuse, global) | Affects only some villi (focal) |
| Villous outline | Smooth, round, regular | Irregular/scalloped outline |
| Trophoblastic hyperplasia | Diffuse, circumferential - both cytotrophoblast AND syncytiotrophoblast | Focal, slight - only syncytiotrophoblast is hyperplastic |
| Cistern formation | Prominent central cisternae in villi | Present but less prominent |
| Trophoblastic inclusions | Absent | Prominent stromal trophoblastic inclusions |
| Embryo/fetal tissue | Absent (not compatible with embryogenesis) | May be present (growth-restricted, with anomalies: syndactyly, hydrocephaly) |
| Serum β-HCG | Markedly elevated (often >100,000 IU/L) | Less elevated or near-normal for gestational age |
| Tissue β-HCG | ++++ (intense) | + (weak) |
| Uterine size | Larger than dates | Usually normal or small for dates |
| Clinical presentation | Classic: bleeding + vesicle passage + hyperemesis + high HCG | Often presents as missed/incomplete abortion |
| Risk of invasive mole | ~15% | Low |
| Risk of choriocarcinoma | 2.5% | Rare (not typically associated) |
| p57 immunostaining | Negative | Positive |


COMPLETE MOLE PARTIAL MOLE
___ _~_
/ \ smooth / _ \ scalloped/
| CIS | ← round outline → | . .| ← irregular
\___/ \___/
Cistern in Trophoblastic
all villi inclusion bodies
Trophoblast: Trophoblast:
[Cyto + Syncytio] [Syncytio only]
DIFFUSE / CIRCUMFERENTIAL FOCAL / MILD
compile both the questions in a single pdf
ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace does not exist"
mkdir -p /home/daytona/workspace/medical-notes
~/medical-notes/generate_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, PageBreak, KeepTogether
)
from reportlab.platypus.flowables import HRFlowable
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
import urllib.request
import io
from reportlab.platypus import Image as RLImage
import os
OUTPUT = "/home/daytona/workspace/medical-notes/Medical_Notes_Hemorrhage_HydatidiformMole.pdf"
# ── page geometry ──────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=2*cm, rightMargin=2*cm,
topMargin=2.2*cm, bottomMargin=2.2*cm,
title="Medical Notes: Hemorrhage & Hydatidiform Mole",
author="Orris Medical Assistant"
)
W = A4[0] - 4*cm # usable width
# ── colour palette ─────────────────────────────────────────────────────────
DARK_BLUE = colors.HexColor("#1a3a5c")
MED_BLUE = colors.HexColor("#2563a8")
LIGHT_BLUE = colors.HexColor("#dbeafe")
ACCENT = colors.HexColor("#dc2626")
SOFT_GRAY = colors.HexColor("#f3f4f6")
MED_GRAY = colors.HexColor("#6b7280")
TABLE_HDR = colors.HexColor("#1e3a5f")
TABLE_ALT = colors.HexColor("#eef4fb")
# ── styles ─────────────────────────────────────────────────────────────────
base = getSampleStyleSheet()
def S(name, parent="Normal", **kw):
return ParagraphStyle(name, parent=base[parent], **kw)
TITLE = S("TITLE", "Title", fontSize=22, textColor=DARK_BLUE,
spaceAfter=4, alignment=TA_CENTER, fontName="Helvetica-Bold")
SUBTITLE= S("SUBTITLE","Normal", fontSize=11, textColor=MED_GRAY,
spaceAfter=2, alignment=TA_CENTER)
H1 = S("H1", "Heading1",fontSize=15, textColor=colors.white,
spaceBefore=10, spaceAfter=4, fontName="Helvetica-Bold",
backColor=DARK_BLUE, leftIndent=-2, rightIndent=-2,
borderPad=5)
H2 = S("H2", "Heading2",fontSize=12, textColor=DARK_BLUE,
spaceBefore=8, spaceAfter=3, fontName="Helvetica-Bold",
borderPad=3)
H3 = S("H3", "Heading3",fontSize=11, textColor=MED_BLUE,
spaceBefore=6, spaceAfter=2, fontName="Helvetica-BoldOblique")
BODY = S("BODY", "Normal", fontSize=10, leading=15,
spaceAfter=5, alignment=TA_JUSTIFY)
BULLET = S("BULLET", "Normal", fontSize=10, leading=14,
spaceAfter=3, leftIndent=14, bulletIndent=4)
CAPTION = S("CAPTION", "Normal", fontSize=8.5, textColor=MED_GRAY,
alignment=TA_CENTER, spaceAfter=6, fontName="Helvetica-Oblique")
NOTE = S("NOTE", "Normal", fontSize=9, textColor=MED_GRAY,
spaceAfter=4, fontName="Helvetica-Oblique")
QBOX = S("QBOX", "Normal", fontSize=10, textColor=DARK_BLUE,
spaceAfter=2, fontName="Helvetica-BoldOblique",
backColor=LIGHT_BLUE, borderPad=8, leftIndent=6)
# ── helpers ────────────────────────────────────────────────────────────────
def hr(color=MED_BLUE, thickness=0.8):
return HRFlowable(width="100%", thickness=thickness,
color=color, spaceAfter=4, spaceBefore=2)
def sp(h=6):
return Spacer(1, h)
def bullet(text):
return Paragraph(f"• {text}", BULLET)
def body(text):
return Paragraph(text, BODY)
def h1(text):
return Paragraph(text, H1)
def h2(text):
return Paragraph(text, H2)
def h3(text):
return Paragraph(text, H3)
def note(text):
return Paragraph(f"<i>{text}</i>", NOTE)
def qbox(text):
return Paragraph(text, QBOX)
def make_table(headers, rows, col_widths=None, alt=True):
"""Build a styled table."""
data = [headers] + rows
if col_widths is None:
n = len(headers)
col_widths = [W / n] * n
style = TableStyle([
# header
("BACKGROUND", (0,0), (-1,0), TABLE_HDR),
("TEXTCOLOR", (0,0), (-1,0), colors.white),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,0), 9.5),
("ALIGN", (0,0), (-1,0), "CENTER"),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
# body
("FONTNAME", (0,1), (-1,-1), "Helvetica"),
("FONTSIZE", (0,1), (-1,-1), 9),
("ALIGN", (0,1), (0,-1), "LEFT"),
("ALIGN", (1,1), (-1,-1), "CENTER"),
("LEADING", (0,1), (-1,-1), 13),
# grid
("GRID", (0,0), (-1,-1), 0.4, colors.HexColor("#cbd5e1")),
("LINEBELOW", (0,0), (-1,0), 1.2, MED_BLUE),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING",(0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("ROWBACKGROUNDS",(0,1),(-1,-1), [colors.white, TABLE_ALT] if alt else [colors.white]),
])
return Table(data, colWidths=col_widths, style=style, repeatRows=1)
def fetch_img(url, width, caption=None):
"""Download image and return [RLImage, caption_para] or []."""
try:
req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"})
data = urllib.request.urlopen(req, timeout=10).read()
img = RLImage(io.BytesIO(data), width=width)
img.hAlign = "CENTER"
result = [sp(4), img]
if caption:
result.append(Paragraph(caption, CAPTION))
result.append(sp(4))
return result
except Exception as e:
print(f" [img skip] {url[:60]}… → {e}")
return []
# ══════════════════════════════════════════════════════════════════════════
# BUILD STORY
# ══════════════════════════════════════════════════════════════════════════
story = []
# ── COVER ──────────────────────────────────────────────────────────────────
story += [
sp(60),
Paragraph("Medical Pathology Notes", TITLE),
hr(DARK_BLUE, 2),
sp(6),
Paragraph("Hemorrhage — Overview & Classification", SUBTITLE),
Paragraph("Hydatidiform Mole — Diagnosis, Cytogenetics & Morphology", SUBTITLE),
sp(8),
hr(MED_GRAY, 0.5),
sp(4),
Paragraph("Source: Robbins & Kumar Basic Pathology · Robbins, Cotran & Kumar PBD · Berek & Novak's Gynecology · Goldman-Cecil Medicine", NOTE),
Paragraph("Compiled by Orris Medical Assistant · June 2026", NOTE),
PageBreak(),
]
# ══════════════════════════════════════════════════════════════════════════
# QUESTION 1 — HEMORRHAGE
# ══════════════════════════════════════════════════════════════════════════
story += [
h1("QUESTION 1 | Hemorrhage — Overview & Classification"),
sp(4),
]
# Definition
story += [
h2("Definition"),
body("Hemorrhage is defined as the <b>extravasation (escape) of blood from vessels</b>. "
"It results from vessel wall damage and may be worsened by defects in coagulation. "
"Capillary bleeding can occur in chronically congested tissues; trauma, atherosclerosis, "
"or inflammatory/neoplastic erosion of a vessel wall can also lead to hemorrhage, which "
"may be massive if the affected vessel is a large vein or artery."),
sp(4),
]
# Causes
story += [
h2("Causes"),
bullet("Trauma (most common)"),
bullet("Atherosclerosis — vessel wall weakening"),
bullet("Inflammatory or neoplastic erosion of vessel wall"),
bullet("Chronic congestion — capillary bleeding"),
bullet("<b>Hemorrhagic diatheses</b> — inherited/acquired defects in vessel walls, "
"platelets, or coagulation factors (increased risk after even trivial injury)"),
sp(6),
]
# Morphological classification
story += [
h2("Morphological Classification (by Size and Location)"),
sp(4),
]
morph_headers = [
Paragraph("<b>Type</b>", CAPTION),
Paragraph("<b>Size</b>", CAPTION),
Paragraph("<b>Features & Causes</b>", CAPTION),
]
morph_rows = [
[Paragraph("<b>Petechiae</b>", BODY),
"1–2 mm",
"Minute skin/mucosal/serosal bleeds; causes: thrombocytopenia, platelet dysfunction, scurvy"],
[Paragraph("<b>Purpura</b>", BODY),
"3–5 mm",
"Slightly larger; causes: same as petechiae + trauma, vasculitis, vascular fragility"],
[Paragraph("<b>Ecchymoses</b>", BODY),
"1–2 cm",
"Subcutaneous hematomas (bruises); colour: red-blue → blue-green (bilirubin) → golden-brown (hemosiderin)"],
[Paragraph("<b>Hematoma</b>", BODY),
"Variable",
"Localised blood accumulation in tissue; trivial (bruise) to fatal (retroperitoneal hematoma from aortic dissection)"],
]
story.append(make_table(morph_headers, morph_rows, col_widths=[3.2*cm, 2*cm, W-5.2*cm]))
story.append(sp(4))
# Body cavity locations
story += [
h3("Hemorrhage by Body Cavity Location"),
bullet("<b>Hemothorax</b> — blood in pleural space"),
bullet("<b>Hemopericardium</b> — blood in pericardial sac"),
bullet("<b>Hemoperitoneum</b> — blood in peritoneal cavity"),
bullet("<b>Hemarthrosis</b> — blood in a joint"),
sp(6),
]
# Images
story += fetch_img(
"https://cdn.orris.care/cdss_images/e976d793a8221880bbc57745cd7fe84eb05cd52d1e5b7e2b9d553a5533fa867f.png",
12*cm,
"Fig 1A. Punctate petechial hemorrhages of the colonic mucosa (thrombocytopenia). "
"[Robbins & Kumar Basic Pathology, Fig. 3.4A]"
)
story += fetch_img(
"https://cdn.orris.care/cdss_images/1791cf07ee5ff6fd0fe73838de40edd1e6eadd474289feca54396e812547a802.png",
12*cm,
"Fig 1B. Fatal intracerebral hemorrhage — large hematoma in right hemisphere with surrounding oedema. "
"[Robbins & Kumar Basic Pathology, Fig. 3.4B]"
)
# ATLS Hemorrhagic Shock Classification
story += [
h2("Hemorrhagic Shock Classification (ATLS — American College of Surgeons)"),
body("When blood loss is large enough to cause hemodynamic instability, it produces "
"<b>hemorrhagic shock</b>. The ATLS system classifies it into 4 classes "
"(estimates for a 70-kg patient):"),
sp(4),
]
shock_headers = [
Paragraph("<b>Parameter</b>", CAPTION),
Paragraph("<b>Class I</b>", CAPTION),
Paragraph("<b>Class II</b>", CAPTION),
Paragraph("<b>Class III</b>", CAPTION),
Paragraph("<b>Class IV</b>", CAPTION),
]
shock_rows = [
["Blood loss (mL)", "Up to 750", "750–1500", "1500–2000", ">2000"],
["% Blood volume", "Up to 15%", "15–30%", "30–40%", ">40%"],
["Heart rate (bpm)", "<100", ">100", ">120", ">140"],
["Blood pressure", "Normal", "Normal", "Decreased", "Decreased"],
["Pulse pressure", "Normal/↑", "Decreased", "Decreased", "Decreased"],
["Resp. rate (per min)", "14–20", "20–30", "30–40", ">35"],
["Urine output (mL/hr)", ">30", "20–30", "5–15", "Negligible"],
["Mental status", "Sl. anxious", "Mildly anxious", "Anxious, confused", "Confused, lethargic"],
["Fluid replacement", "Crystalloid", "Crystalloid","Crystalloid + blood","Crystalloid + blood"],
]
cw_s = [4.2*cm, 2.5*cm, 2.5*cm, 2.5*cm, 2.8*cm]
story.append(make_table(shock_headers, shock_rows, col_widths=cw_s))
story += [
sp(4),
note("Source: Goldman-Cecil Medicine; ATLS, American College of Surgeons (estimates based on a 70-kg patient)."),
sp(6),
]
# Clinical impact
story += [
h2("Clinical Impact — Key Determinants"),
body("The severity of hemorrhage depends on four factors:"),
bullet("<b>Volume of blood lost</b> — loss of >20% of blood volume causes hemodynamic compromise"),
bullet("<b>Rate of bleeding</b> — rapid losses are less tolerated than slow, gradual losses"),
bullet("<b>Location of the bleed</b> — bleeding into a confined space (skull, pericardium) "
"can be fatal even at small volumes"),
bullet("<b>Patient's baseline status</b> — pre-existing anaemia, cardiovascular disease, and "
"advanced age worsen tolerance"),
sp(4),
]
story += [
h2("Consequences"),
bullet("Large hemorrhages may cause <b>jaundice</b> — red cells broken down by macrophages release bilirubin"),
bullet("Chronic slow bleeding → <b>iron-deficiency anaemia</b>"),
bullet("Acute large-volume loss → <b>hypovolemic/hemorrhagic shock</b> and end-organ ischaemia"),
bullet("Intracerebral or pericardial hemorrhage can be fatal at relatively small volumes due to "
"space constraints"),
sp(4),
note("Sources: Robbins & Kumar Basic Pathology; Goldman-Cecil Medicine, 2-Volume Set."),
PageBreak(),
]
# ══════════════════════════════════════════════════════════════════════════
# QUESTION 2 — HYDATIDIFORM MOLE
# ══════════════════════════════════════════════════════════════════════════
story += [
h1("QUESTION 2 | Hydatidiform Mole — GTD"),
sp(4),
qbox("30-year-old female · First trimester · Spontaneous bleeding PV + passage of vesicles · "
"Excessive vomiting · Serum β-HCG markedly elevated"),
sp(8),
]
# Part a
story += [
h2("(a) Most Likely Diagnosis with Reasons [2 marks]"),
body("<b>Diagnosis: Complete Hydatidiform Mole</b> (Gestational Trophoblastic Disease)"),
sp(4),
]
diag_headers = [
Paragraph("<b>Clinical Feature</b>", CAPTION),
Paragraph("<b>Significance / Reason</b>", CAPTION),
]
diag_rows = [
["First-trimester bleeding PV",
"Trophoblastic tissue erodes uterine vessels"],
["Passage of vesicles (grape-like structures)",
"Pathognomonic — hydropic, cystically swollen chorionic villi"],
["Excessive vomiting (hyperemesis)",
"Markedly elevated β-HCG stimulates the vomiting centre"],
["Markedly elevated serum β-HCG",
"Massive trophoblastic proliferation; complete moles can exceed 100,000 IU/L — "
"far higher than a normal pregnancy of the same gestational age"],
["First-trimester presentation",
"Average detection at ~9 weeks gestation"],
]
story.append(make_table(diag_headers, diag_rows,
col_widths=[5.5*cm, W-5.5*cm]))
story += [
sp(6),
body("The combination of these findings points specifically to a <b>complete mole</b> rather "
"than a partial mole because: (i) partial moles present more like a missed abortion with "
"less dramatic vesicle passage; (ii) β-HCG is only modestly elevated in partial moles; "
"(iii) hyperemesis is characteristic of the extreme HCG elevation seen in complete moles."),
sp(8),
]
# Part b
story += [
h2("(b) Cytogenetic Abnormalities [4 marks]"),
sp(4),
]
story += fetch_img(
"https://cdn.orris.care/cdss_images/5b100d661f3d0a955a5efdead149e770a2a2bcb7b996b33f86b90506cf37df1b.png",
13*cm,
"Fig 2. Origin of complete and partial hydatidiform moles — cytogenetic diagram. "
"(A) Monospermic complete mole — endoreduplication. "
"(B) Dispermic complete mole — empty ovum + two sperm. "
"(C) Partial mole — dispermy into normal ovum producing triploid karyotype. "
"[Robbins, Cotran & Kumar Pathologic Basis of Disease, Fig. 22.53]"
)
story += [
h3("Complete Mole — Cytogenetics"),
body("Key concept: <b>all nuclear genetic material is of paternal origin (androgenesis)</b>. "
"The ovum's nuclear DNA is absent or inactivated; mitochondrial DNA remains maternal."),
sp(4),
bullet("<b>Mechanism 1 — Monospermic (90% of cases):</b> An empty ovum (enucleated/inactive "
"egg) fertilised by a <i>single haploid sperm (23X)</i>. The sperm undergoes "
"<b>endoreduplication</b> (chromosome duplication) within the egg. Result: "
"<b>46,XX</b> — homozygous, entirely paternal."),
bullet("<b>Mechanism 2 — Dispermic (10% of cases):</b> Empty ovum fertilised by two separate "
"sperm simultaneously. Produces <b>46,XX</b> (two X sperm) or <b>46,XY</b> (X + Y). "
"Note: 46,YY is non-viable and never found. Result: heterozygous complete mole."),
sp(4),
note("Diagnostic key: Complete moles are p57-NEGATIVE (p57 is a paternally imprinted, "
"maternally expressed gene product — absent when there are no maternal chromosomes)."),
sp(6),
h3("Partial Mole — Cytogenetics"),
body("Mechanism: <b>dispermic fertilisation of a normal ovum.</b>"),
bullet("A normal ovum (23X) is fertilised by two sperm (two X, or X + Y)"),
bullet("Result: <b>triploid</b> (69 chromosomes) — two paternal haploid sets + one maternal set"),
bullet("Possible karyotypes: <b>69,XXX</b> · <b>69,XXY</b> (most common) · <b>69,XYY</b> (rare)"),
bullet("Occasional tetraploid forms (92,XXXY) have been reported"),
sp(4),
note("Diagnostic key: Partial moles are p57-POSITIVE (maternal chromosomes present). "
"The extra paternal set still drives trophoblastic proliferation."),
sp(6),
]
cyto_headers = [
Paragraph("<b>Feature</b>", CAPTION),
Paragraph("<b>Complete Mole</b>", CAPTION),
Paragraph("<b>Partial Mole</b>", CAPTION),
]
cyto_rows = [
["Ploidy", "Diploid", "Triploid (occasionally tetraploid)"],
["Karyotype", "46,XX (90%) · 46,XY (10%)", "69,XXX · 69,XXY · 69,XYY"],
["Mechanism", "Monospermy + endoreduplication\nor dispermy → empty ovum",
"Dispermy → normal ovum"],
["Chromosome origin", "Entirely paternal (androgenesis)","2 paternal + 1 maternal set"],
["p57 immunostaining", "Negative", "Positive"],
]
story.append(make_table(cyto_headers, cyto_rows,
col_widths=[4.5*cm, 6*cm, 6*cm]))
story += [sp(8)]
# Part c
story += [
h2("(c) Differentiating Features — Complete vs Partial Mole [4 marks]"),
sp(4),
]
diff_headers = [
Paragraph("<b>Feature</b>", CAPTION),
Paragraph("<b>Complete Mole</b>", CAPTION),
Paragraph("<b>Partial Mole</b>", CAPTION),
]
diff_rows = [
["Karyotype", "46,XX or 46,XY (diploid)",
"69,XXX / 69,XXY / 69,XYY (triploid)"],
["Gross appearance", "Uterus distended by grape-like vesicles; NO fetal parts",
"Smaller vesicles mixed with normal villi; fetal parts may be present"],
["Villous oedema", "ALL villi affected (diffuse/global)",
"Only SOME villi affected (focal)"],
["Villous outline", "Smooth, round, regular",
"Irregular / scalloped outline"],
["Trophoblast hyperplasia","Diffuse, circumferential\n(cyto + syncytiotrophoblast)",
"Focal, slight\n(syncytiotrophoblast only)"],
["Cistern formation", "Prominent central cisternae",
"Present but less prominent"],
["Trophoblastic inclusions","Absent",
"Prominent stromal inclusions"],
["Embryo / fetal tissue", "ABSENT",
"May be present (growth-restricted; syndactyly, hydrocephaly)"],
["Serum β-HCG", "Markedly elevated (>100,000 IU/L)",
"Less elevated or near-normal for dates"],
["Tissue β-HCG", "++++",
"+"],
["Uterine size", "Larger than dates",
"Normal or small for dates"],
["Clinical presentation", "Bleeding + vesicle passage + hyperemesis + high HCG",
"Often presents as missed/incomplete abortion"],
["Risk: invasive mole", "~15%",
"Low"],
["Risk: choriocarcinoma", "~2.5%",
"Rare (not typically associated)"],
["p57 immunostaining", "Negative",
"Positive"],
]
story.append(make_table(diff_headers, diff_rows,
col_widths=[4.5*cm, 6.2*cm, 5.8*cm]))
story += [sp(6)]
# Gross + Histology images
story += fetch_img(
"https://cdn.orris.care/cdss_images/8ad2ac1dd8c114feff8d1111cbcd6822388a702aeceebadb995a1dc39ee05aec.png",
14*cm,
"Fig 3. Complete hydatidiform mole. (A) Gross — uterine cavity distended by grape-like vesicular villi. "
"(B) Histology — diffuse villous oedema, prominent central cisternae, and circumferential "
"trophoblastic proliferation involving both cyto- and syncytiotrophoblast. "
"[Robbins, Cotran & Kumar PBD, Fig. 22.54]"
)
story += fetch_img(
"https://cdn.orris.care/cdss_images/943a8773800f1e01bcffd0109f904156a0841d7fbd06cc35d5d1dc03c680847d.png",
12*cm,
"Fig 4. Partial hydatidiform mole — histology. Mixture of large and small villi; large villi have "
"irregular/scalloped outlines and prominent syncytiotrophoblastic inclusions; trophoblastic "
"hyperplasia is focal and involves only syncytiotrophoblasts. This mole was triploid. "
"[Robbins, Cotran & Kumar PBD, Fig. 22.55]"
)
# Follow-up
story += [
h2("Follow-up After Mole Evacuation"),
bullet("Serial serum β-HCG monitoring for <b>6–12 months</b> after uterine evacuation"),
bullet("Persistent or rising HCG → invasive mole or choriocarcinoma → chemotherapy "
"(methotrexate or actinomycin-D)"),
bullet("Lung metastases occur in ~5% of complete moles; lesions <2 cm usually regress "
"spontaneously"),
sp(6),
hr(MED_GRAY, 0.5),
note("Sources: Robbins, Cotran & Kumar Pathologic Basis of Disease · "
"Robbins & Kumar Basic Pathology · Berek & Novak's Gynecology · "
"Goldman-Cecil Medicine, 2-Volume Set."),
]
# ── BUILD ──────────────────────────────────────────────────────────────────
doc.build(story)
print(f"PDF written → {OUTPUT}")
cd /home/daytona/workspace/medical-notes && python generate_pdf.py 2>&1
~/medical-notes/generate_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/medical-notes/generate_pdf.py'
cd /home/daytona/workspace/medical-notes && python generate_pdf.py 2>&1
~/medical-notes/generate_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/medical-notes/generate_pdf.py'
cd /home/daytona/workspace/medical-notes && python generate_pdf.py 2>&1
grep -n "fetch_img(" /home/daytona/workspace/medical-notes/generate_pdf.py
cd /home/daytona/workspace/medical-notes && python3 -c " import re with open('generate_pdf.py', 'r') as f: content = f.read() # Fix all fetch_img calls: replace 3-arg calls (url, width, string_caption) with keyword caption= # Pattern: fetch_img(\n url,\n width,\n 'caption string'\n) # We need to add caption= before the caption string argument # Simple approach: replace the pattern where 3rd arg is a string literal import re # Match fetch_img calls where 3rd positional arg starts with a quote fixed = re.sub( r'(fetch_img\(\s*\"[^\"]+\",\s*[\d\*\.cm]+,\s*)(\")', r'\1caption=\"', content ) with open('generate_pdf.py', 'w') as f: f.write(fixed) print('Done') "
cd /home/daytona/workspace/medical-notes && python generate_pdf.py 2>&1
ls -lh /home/daytona/workspace/medical-notes/Medical_Notes_Hemorrhage_HydatidiformMole.pdf
Medical Notes Hemorrhage HydatidiformMole
PDF Document · PDF
Solve the entire paper
You are a medical pathology expert. Research ALL of the following topics from the medical library database and compile comprehensive answers. Then generate a well-formatted PDF at /home/daytona/workspace/medical-notes/Cardiology_Pathology_FullPaper.pdf TOPICS TO RESEARCH (search ALL of these): 1. Cardiac vegetations - causes, types, differences between them 2. Infective endocarditis (acute vs subacute) - characteristic features of vegetations 3. Rheumatic fever / rheumatic heart disease - acute and chronic morphology, Aschoff bodies, pathogenesis 4. Acute myocardial infarction - gross and microscopic changes at 15 days, sequential morphological changes, biomarkers (troponin, CK-MB, LDH timeline diagram) 5. Atherosclerosis - risk factors and pathogenesis 6. Infarction definition + sequential morphological changes in AMI 7. Vegetative endocarditis - types and causes (NBTE, infective, Libman-Sacks, rheumatic) 8. Alcoholic hepatitis - morphological patterns 9. Splenomegaly - causes + morphological features in right heart failure 10. Caplan syndrome - definition and key pathological feature 11. Rheumatoid arthritis - pathogenesis flowchart + histopathological features 12. Hypertrophic cardiomyopathy - definition and features INSTRUCTIONS: 1. Use query_library_db with headings_fts and paragraphs_fts to find relevant sections 2. Read the actual textbook content with read_file 3. Fetch key images with fetch_image where relevant (vegetations, AMI, rheumatic fever, atherosclerosis) 4. Compile everything into a detailed answer for each question For EACH topic, return: - Full detailed answer text - Any image URLs found in the textbook content - Sources (book title, page) Use these SQL patterns: - Headings: SELECT title, book_title, '/textbooks/' || block_file_path AS file_path, line_number, para_line_ranges FROM headings_fts WHERE headings_fts MATCH 'topic' ORDER BY rank LIMIT 5 - Paragraphs: SELECT book_title, section_heading, '/textbooks/' || block_file_path AS file_path, line_start, line_end, snippet(paragraphs_fts, 0, '>>>', '<<<', '...', 40) AS snippet FROM paragraphs_fts WHERE paragraphs_fts MATCH 'topic' ORDER BY rank LIMIT 5 After researching, write a Python script using reportlab to generate the PDF. The PDF should: - Have a professional cover page - Answer ALL questions from the paper: SECTION II (Short answer, 5 marks each): Q1. Causes of vegetation in heart + tabulate differences Q2. Tabulate characteristic features of different types of cardiac vegetations in different conditions Q3. 65-year-old AMI 15 days - gross and microscopic pathology at autopsy Q4. Four major forms of vegetative endocarditis - gross and microscopic differentiating features between any two Q5. Rheumatic fever - definition + morphological spectrum of acute and chronic rheumatic heart disease Q6. Risk factors of atherosclerosis and its pathogenesis Q7. Define infarction + sequential morphological changes in acute MI Q8. Aetiology, pathogenesis and key morphological changes of acute rheumatic heart disease SECTION II continued: Q9. Conditions where vegetations are found + 3 important features of each Q10. Labelled diagram showing different types of vegetative endocarditis Q11. Morphological patterns in alcoholic hepatitis SECTION III (Very short, 3 marks each): Q1. Gross and microscopic pathology in acute rheumatic fever with diagrams Q2. Four causes of splenomegaly + morphological features in right heart failure Q3. Caplan syndrome - definition + most important pathological feature SECTION IV (Very short, 2 marks each): Q1. Pathogenesis of rheumatoid arthritis - flow chart SECTION V (Very short, 1 mark each): Q1. Labelled diagram of biomarkers in acute MI Q2. Important biomarkers of myocardial infarction Q3. Histopathological features of rheumatoid arthritis Q4. Different types of vegetative endocarditis and causes Q5. Hypertrophic cardiomyopathy The PDF should be saved to: /home/daytona/workspace/medical-notes/Cardiology_Pathology_FullPaper.pdf Return: 1. Confirmation that PDF was generated successfully 2. The file path 3. Key content compiled for each major topic (brief summary) 4. Any image URLs that were included
mkdir -p /home/daytona/workspace/medical-notes && ls /home/daytona/workspace/medical-notes/