Create a one page note on the topic of Puerperal sepsis summarising the images I've uploaded adding flow charts and points highlighting the main points only
ls -la /home/daytona/workspace/ 2>/dev/null && ls /home/daytona/skills/docx/scripts/office/ 2>/dev/null || echo "checking paths"
mkdir -p /home/daytona/workspace/puerperal-sepsis && node -e "require('docx'); console.log('docx ok')"
~/puerperal-sepsis/build.js
const {
Document, Packer, Paragraph, TextRun, Table, TableRow, TableCell,
AlignmentType, HeadingLevel, BorderStyle, WidthType, ShadingType,
VerticalAlign, LevelFormat, TableBorders
} = require('docx');
const fs = require('fs');
// ─── Colour palette ───────────────────────────────────────────────
const TEAL = "1A6B7C";
const ORANGE = "D4550E";
const AMBER = "F5A623";
const LIGHT_BG = "EAF4F7";
const HEADER_BG = "1A6B7C";
const WHITE = "FFFFFF";
const DARK = "1A1A2E";
const LIGHT_ORANGE_BG = "FFF3E8";
const LIGHT_GREEN_BG = "E8F5E9";
const LIGHT_RED_BG = "FDECEA";
// ─── Helper: section heading bar ─────────────────────────────────
function sectionHeading(text, bgColor = HEADER_BG) {
return new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: TableBorders.NONE,
rows: [new TableRow({
children: [new TableCell({
shading: { fill: bgColor, type: ShadingType.CLEAR },
margins: { top: 80, bottom: 80, left: 180, right: 180 },
children: [new Paragraph({
alignment: AlignmentType.LEFT,
children: [new TextRun({ text, bold: true, color: WHITE, size: 22, font: "Arial" })]
})]
})]
})]
});
}
// ─── Helper: coloured box paragraph ──────────────────────────────
function colorBox(text, bgColor, textColor = DARK) {
return new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: TableBorders.NONE,
rows: [new TableRow({
children: [new TableCell({
shading: { fill: bgColor, type: ShadingType.CLEAR },
margins: { top: 60, bottom: 60, left: 160, right: 160 },
children: [new Paragraph({
children: [new TextRun({ text, size: 18, font: "Arial", color: textColor, bold: false })]
})]
})]
})]
});
}
// ─── Helper: bullet ───────────────────────────────────────────────
function bullet(text, bold = false, color = DARK) {
return new Paragraph({
numbering: { reference: "bullets", level: 0 },
spacing: { before: 30, after: 30 },
children: [new TextRun({ text, size: 18, font: "Arial", color, bold })]
});
}
// ─── Helper: sub-bullet ───────────────────────────────────────────
function subBullet(text) {
return new Paragraph({
numbering: { reference: "subbullets", level: 0 },
spacing: { before: 20, after: 20 },
children: [new TextRun({ text, size: 17, font: "Arial", color: "444444" })]
});
}
// ─── Helper: thin spacer ─────────────────────────────────────────
function spacer(pt = 60) {
return new Paragraph({ spacing: { before: pt, after: pt }, children: [new TextRun("")] });
}
// ─── Helper: two-column table ────────────────────────────────────
function twoColTable(leftContent, rightContent) {
return new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: TableBorders.NONE,
rows: [new TableRow({
children: [
new TableCell({
width: { size: 50, type: WidthType.PERCENTAGE },
margins: { top: 0, bottom: 0, left: 0, right: 100 },
children: leftContent
}),
new TableCell({
width: { size: 50, type: WidthType.PERCENTAGE },
margins: { top: 0, bottom: 0, left: 100, right: 0 },
children: rightContent
})
]
})]
});
}
// ─── Flowchart box helper ─────────────────────────────────────────
function flowBox(label, text, bgColor, textColor = WHITE) {
return new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: {
top: { style: BorderStyle.SINGLE, size: 6, color: "AAAAAA" },
bottom: { style: BorderStyle.SINGLE, size: 6, color: "AAAAAA" },
left: { style: BorderStyle.SINGLE, size: 6, color: "AAAAAA" },
right: { style: BorderStyle.SINGLE, size: 6, color: "AAAAAA" },
},
rows: [new TableRow({
children: [
new TableCell({
shading: { fill: bgColor, type: ShadingType.CLEAR },
margins: { top: 60, bottom: 60, left: 120, right: 60 },
width: { size: 28, type: WidthType.PERCENTAGE },
children: [new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text: label, bold: true, size: 18, font: "Arial", color: textColor })]
})]
}),
new TableCell({
shading: { fill: bgColor, type: ShadingType.CLEAR },
margins: { top: 60, bottom: 60, left: 60, right: 120 },
width: { size: 72, type: WidthType.PERCENTAGE },
children: [new Paragraph({
children: [new TextRun({ text, size: 18, font: "Arial", color: textColor })]
})]
})
]
})]
});
}
function arrow() {
return new Paragraph({
alignment: AlignmentType.CENTER,
spacing: { before: 20, after: 20 },
children: [new TextRun({ text: "▼", size: 20, color: "666666", font: "Arial" })]
});
}
// ─── Main label paragraph ─────────────────────────────────────────
function label(text, color = TEAL, sz = 19) {
return new Paragraph({
spacing: { before: 80, after: 30 },
children: [new TextRun({ text, bold: true, size: sz, color, font: "Arial" })]
});
}
// ═══════════════════════════════════════════════════════════════════
// BUILD DOCUMENT
// ═══════════════════════════════════════════════════════════════════
const doc = new Document({
numbering: {
config: [
{
reference: "bullets",
levels: [{
level: 0, format: LevelFormat.BULLET, text: "\u2022",
alignment: AlignmentType.LEFT,
style: { paragraph: { indent: { left: 400, hanging: 240 } } }
}]
},
{
reference: "subbullets",
levels: [{
level: 0, format: LevelFormat.BULLET, text: "\u25E6",
alignment: AlignmentType.LEFT,
style: { paragraph: { indent: { left: 700, hanging: 240 } } }
}]
}
]
},
styles: {
default: { document: { run: { font: "Arial", size: 20 } } }
},
sections: [{
properties: {
page: {
size: { width: 11906, height: 16838 },
margin: { top: 480, bottom: 480, left: 700, right: 700 }
}
},
children: [
// ── TITLE ──────────────────────────────────────────────────
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: TableBorders.NONE,
rows: [new TableRow({
children: [new TableCell({
shading: { fill: TEAL, type: ShadingType.CLEAR },
margins: { top: 120, bottom: 120, left: 240, right: 240 },
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text: "PUERPERAL SEPSIS", bold: true, size: 36, font: "Arial", color: WHITE })]
}),
new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text: "Chapter 30 — Abnormalities of the Puerperium | Quick Reference Note", size: 18, font: "Arial", color: "CCE8EF" })]
})
]
})]
})]
}),
spacer(60),
// ─── ROW 1: Definition + Vaginal Flora ────────────────────
twoColTable(
[
sectionHeading("DEFINITION"),
spacer(40),
new Paragraph({
spacing: { before: 40, after: 40 },
children: [
new TextRun({ text: "Puerperal Pyrexia: ", bold: true, size: 18, font: "Arial", color: ORANGE }),
new TextRun({ text: "Temperature \u2265 100.4\u00B0F (38\u00B0C) on 2 separate occasions, >24 h after delivery, within first 10 days.", size: 18, font: "Arial" })
]
}),
new Paragraph({
spacing: { before: 40, after: 40 },
children: [
new TextRun({ text: "Puerperal Sepsis: ", bold: true, size: 18, font: "Arial", color: ORANGE }),
new TextRun({ text: "Infection of the genital tract occurring as a complication of delivery.", size: 18, font: "Arial" })
]
}),
new Paragraph({
spacing: { before: 40, after: 20 },
children: [new TextRun({ text: "Primary infection sites:", bold: true, size: 18, font: "Arial", color: TEAL })]
}),
bullet("Perineum & vaginal wounds"),
bullet("Cervix"),
bullet("Uterus (endometrium / placental site)"),
],
[
sectionHeading("VAGINAL FLORA AT ONSET OF LABOUR", ORANGE),
spacer(40),
bullet("Doderlein's bacillus (60-70%)"),
bullet("Candida albicans (25%)"),
bullet("Staphylococcus albus / aureus"),
bullet("Streptococcus — anaerobic, beta-haemolytic"),
bullet("E. coli, Clostridium welchii (rare)"),
bullet("Bacteroides group"),
spacer(30),
colorBox("Most infections in the genital tract are POLYMICROBIAL — a mix of aerobic and anaerobic organisms.", LIGHT_BG, TEAL),
]
),
spacer(60),
// ─── PATHOGENESIS FLOWCHART ────────────────────────────────
sectionHeading("PATHOGENESIS FLOWCHART"),
spacer(40),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: TableBorders.NONE,
rows: [new TableRow({
children: [
// Left branch
new TableCell({
width: { size: 33, type: WidthType.PERCENTAGE },
margins: { right: 80 },
children: [
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: { top: { style: BorderStyle.SINGLE, size: 4, color: TEAL }, bottom: { style: BorderStyle.SINGLE, size: 4, color: TEAL }, left: { style: BorderStyle.SINGLE, size: 4, color: TEAL }, right: { style: BorderStyle.SINGLE, size: 4, color: TEAL } },
rows: [new TableRow({ children: [new TableCell({ shading: { fill: TEAL, type: ShadingType.CLEAR }, margins: { top: 60, bottom: 60, left: 100, right: 100 }, children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: "SOURCE OF INFECTION", bold: true, size: 17, font: "Arial", color: WHITE })] })] })] })]
}),
arrow(),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: { top: { style: BorderStyle.SINGLE, size: 4, color: "AAAAAA" }, bottom: { style: BorderStyle.SINGLE, size: 4, color: "AAAAAA" }, left: { style: BorderStyle.SINGLE, size: 4, color: "AAAAAA" }, right: { style: BorderStyle.SINGLE, size: 4, color: "AAAAAA" } },
rows: [
new TableRow({ children: [new TableCell({ shading: { fill: "E3F2FD", type: ShadingType.CLEAR }, margins: { top: 40, bottom: 20, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "Endogenous", bold: true, size: 17, font: "Arial", color: "1565C0" })] }), new Paragraph({ children: [new TextRun({ text: "Flora present in genital tract before delivery", size: 16, font: "Arial" })] })] })] }),
new TableRow({ children: [new TableCell({ shading: { fill: "FFF3E0", type: ShadingType.CLEAR }, margins: { top: 20, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "Autogenous", bold: true, size: 17, font: "Arial", color: ORANGE })] }), new Paragraph({ children: [new TextRun({ text: "Skin/throat flora migrate via bloodstream", size: 16, font: "Arial" })] })] })] }),
new TableRow({ children: [new TableCell({ shading: { fill: "FCE4EC", type: ShadingType.CLEAR }, margins: { top: 20, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "Exogenous", bold: true, size: 17, font: "Arial", color: "C62828" })] }), new Paragraph({ children: [new TextRun({ text: "Hospital staff / attendants (Strep, Staph, E.coli)", size: 16, font: "Arial" })] })] })] }),
]
}),
]
}),
// Middle arrow
new TableCell({
width: { size: 5, type: WidthType.PERCENTAGE },
verticalAlign: VerticalAlign.CENTER,
margins: { left: 40, right: 40 },
children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: "\u25BA", size: 28, color: TEAL, font: "Arial" })] })]
}),
// Right: risk factors
new TableCell({
width: { size: 62, type: WidthType.PERCENTAGE },
margins: { left: 80 },
children: [
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: { top: { style: BorderStyle.SINGLE, size: 4, color: ORANGE }, bottom: { style: BorderStyle.SINGLE, size: 4, color: ORANGE }, left: { style: BorderStyle.SINGLE, size: 4, color: ORANGE }, right: { style: BorderStyle.SINGLE, size: 4, color: ORANGE } },
rows: [new TableRow({ children: [new TableCell({ shading: { fill: ORANGE, type: ShadingType.CLEAR }, margins: { top: 60, bottom: 60, left: 100, right: 100 }, children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: "PREDISPOSING RISK FACTORS", bold: true, size: 17, font: "Arial", color: WHITE })] })] })] })]
}),
twoColTable(
[
new Paragraph({ spacing: { before: 30 }, children: [new TextRun({ text: "Antepartum:", bold: true, size: 17, font: "Arial", color: TEAL })] }),
bullet("Anaemia", false, DARK),
bullet("Preterm labour"),
bullet("Premature rupture of membranes (\u226518 h)"),
bullet("Prolonged rupture of membranes"),
bullet("Immunocompromised (HIV)"),
bullet("Diabetes"),
],
[
new Paragraph({ spacing: { before: 30 }, children: [new TextRun({ text: "Intrapartum:", bold: true, size: 17, font: "Arial", color: TEAL })] }),
bullet("Repeated vaginal examinations"),
bullet("Traumatic vaginal delivery"),
bullet("Retained placenta / PPH"),
bullet("Prolonged labour"),
bullet("Cesarean delivery"),
bullet("Obstructed labour"),
]
)
]
})
]
})]
}),
spacer(60),
// ─── ROW 2: Clinical Features + Spread of Infection ───────
twoColTable(
[
sectionHeading("CLINICAL FEATURES"),
spacer(30),
label("Local (Wound) Infection", TEAL),
bullet("Slight rise of temperature, malaise/headache"),
bullet("Wound red, swollen; pus formation"),
bullet("Acute: high fever, chills and rigors"),
spacer(20),
label("Uterine Infection", TEAL),
new Paragraph({ spacing: { before: 30, after: 10 }, children: [new TextRun({ text: "Mild:", bold: true, size: 17, font: "Arial", color: AMBER })] }),
bullet("Temp >100.4\u00B0F, pulse >90; offensive lochia"),
bullet("Uterus subinvoluted and tender"),
new Paragraph({ spacing: { before: 30, after: 10 }, children: [new TextRun({ text: "Severe:", bold: true, size: 17, font: "Arial", color: "C62828" })] }),
bullet("Acute onset, high fever, chills & rigor"),
bullet("Rapid pulse out of proportion to temperature"),
bullet("Breathlessness, cough, abdominal pain, dysuria"),
bullet("Lochia may be scanty/odourless; uterus tender"),
spacer(20),
label("Spread of Infection (Extrauterine)", ORANGE),
bullet("Pelvic cellulitis (parametritis) — indurated mass, uterus pushed to opposite side"),
bullet("Peritonitis — bowel distension, dynamic ileus"),
bullet("Salpingitis — interstitial or perisalpingitis"),
bullet("Pelvic abscess — rare; 7-10 days to develop"),
bullet("Septic pelvic thrombophlebitis (SPT) — swinging fever; anticoagulate with heparin"),
bullet("Septicaemia / Septic shock — 30% mortality"),
],
[
sectionHeading("INVESTIGATIONS", ORANGE),
spacer(30),
colorBox("All puerperal pyrexia = genital sepsis until proved otherwise", LIGHT_ORANGE_BG, ORANGE),
spacer(30),
label("Principles: locate site, identify organism, assess severity", TEAL, 17),
spacer(20),
bullet("High vaginal + endocervical swabs (C&S — aerobic & anaerobic)"),
bullet("Midstream urine (MSU) — analysis + culture & sensitivity"),
bullet("Full blood count — WBC, Hb, platelets (low = DIC / septicaemia)"),
bullet("Thick blood film — malarial parasites"),
bullet("Blood culture — if fever with chills & rigor"),
bullet("Serum urea, creatinine, electrolytes"),
bullet("Pelvic ultrasound — retained products, abscess, venous thrombosis"),
bullet("CT / MRI — if pelvic vein thrombosis suspected"),
bullet("Chest X-ray — suspected TB or lung atelectasis"),
spacer(40),
sectionHeading("TOXIC SHOCK / SEPTICAEMIA — RED FLAGS", "C62828"),
spacer(20),
bullet("Fever, headache, vomiting, diarrhoea, skin rash"),
bullet("Organ dysfunction: renal failure, hepatic failure, DIC"),
bullet("Staphylococcal exotoxin activates T cells \u2192 cytokine storm"),
bullet("Bacteraemia \u2192 endotoxin \u2192 hypotension + ARDS"),
colorBox("ICU triggers: Hypotension | Oliguria | Creatinine \u2191 | Lactate \u22654 | Thrombocytopenia | ARDS | Hypothermia", LIGHT_RED_BG, "C62828"),
]
),
spacer(60),
// ─── TREATMENT FLOWCHART ──────────────────────────────────
sectionHeading("TREATMENT FLOWCHART"),
spacer(40),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: TableBorders.NONE,
rows: [new TableRow({
children: [
new TableCell({
width: { size: 50, type: WidthType.PERCENTAGE },
margins: { right: 80 },
children: [
label("General Care", TEAL),
flowBox("1", "Isolate patient (esp. if haemolytic Streptococcus)", "1A6B7C"),
arrow(),
flowBox("2", "IV fluids + calories; correct anaemia (iron / transfusion)", "2E7D8A"),
arrow(),
flowBox("3", "Indwelling catheter — monitor urine output", "3A8B9A"),
arrow(),
flowBox("4", "Chart: pulse, temp, lochia, fluid balance", "4699A8"),
arrow(),
flowBox("5", "Empirical antibiotics until C&S results available", "529EB5"),
]
}),
new TableCell({
width: { size: 50, type: WidthType.PERCENTAGE },
margins: { left: 80 },
children: [
label("Antibiotic Regimens", ORANGE),
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: { top: { style: BorderStyle.SINGLE, size: 4, color: "CCCCCC" }, bottom: { style: BorderStyle.SINGLE, size: 4, color: "CCCCCC" }, left: { style: BorderStyle.SINGLE, size: 4, color: "CCCCCC" }, right: { style: BorderStyle.SINGLE, size: 4, color: "CCCCCC" }, insideH: { style: BorderStyle.SINGLE, size: 2, color: "DDDDDD" }, insideV: { style: BorderStyle.SINGLE, size: 2, color: "DDDDDD" } },
rows: [
new TableRow({ children: [
new TableCell({ shading: { fill: ORANGE, type: ShadingType.CLEAR }, margins: { top: 40, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: "Scenario", bold: true, size: 17, font: "Arial", color: WHITE })] })] }),
new TableCell({ shading: { fill: ORANGE, type: ShadingType.CLEAR }, margins: { top: 40, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ alignment: AlignmentType.CENTER, children: [new TextRun({ text: "Regimen", bold: true, size: 17, font: "Arial", color: WHITE })] })] })
]}),
new TableRow({ children: [
new TableCell({ margins: { top: 40, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "Empirical (severe)", size: 17, font: "Arial" })] })] }),
new TableCell({ margins: { top: 40, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "Gentamicin 2 mg/kg IV load \u2192 1.5 mg/kg q8h + Clindamycin 900 mg q8h + Metronidazole 0.5 g q8h", size: 16, font: "Arial" })] })] })
]}),
new TableRow({ children: [
new TableCell({ shading: { fill: "FFF8F5", type: ShadingType.CLEAR }, margins: { top: 40, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "Severe sepsis", size: 17, font: "Arial" })] })] }),
new TableCell({ shading: { fill: "FFF8F5", type: ShadingType.CLEAR }, margins: { top: 40, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "Piperacillin-tazobactam OR carbapenem + clindamycin", size: 16, font: "Arial" })] })] })
]}),
new TableRow({ children: [
new TableCell({ margins: { top: 40, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "MRSA", size: 17, font: "Arial" })] })] }),
new TableCell({ margins: { top: 40, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "Vancomycin or Teicoplanin", size: 16, font: "Arial" })] })] })
]}),
new TableRow({ children: [
new TableCell({ shading: { fill: "FFF8F5", type: ShadingType.CLEAR }, margins: { top: 40, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "SPT", size: 17, font: "Arial" })] })] }),
new TableCell({ shading: { fill: "FFF8F5", type: ShadingType.CLEAR }, margins: { top: 40, bottom: 40, left: 80, right: 80 }, children: [new Paragraph({ children: [new TextRun({ text: "LMWH 1 mg/kg q12h; APTT 1.5-2x normal", size: 16, font: "Arial" })] })] })
]}),
]
}),
spacer(30),
label("Surgical Treatment", TEAL),
bullet("Perineal wound: antibiotics IV, debridement, repeated sitz bath, secondary closure"),
bullet("Retained products (>3 cm): surgical evacuation after 24 h antibiotic cover"),
bullet("Pelvic abscess: colpotomy drainage under USS guidance"),
bullet("Wound dehiscence: debridement + secondary suture"),
bullet("Laparotomy: for unresponsive peritonitis; hysterectomy if rupture/gangrene"),
]
})
]
})]
}),
spacer(60),
// ─── PROPHYLAXIS ──────────────────────────────────────────
sectionHeading("PROPHYLAXIS", "2E7D32"),
spacer(30),
twoColTable(
[
label("Antenatal", "2E7D32"),
bullet("Improve nutritional status (raise Hb)"),
bullet("Eradicate any septic focus (skin, throat, tonsils)"),
label("Intranatal", "2E7D32"),
bullet("Full surgical asepsis during delivery"),
bullet("Screen for Group B Streptococcus in high-risk patients"),
bullet("Prophylactic antibiotic at cesarean section (reduces wound infection, endometritis, UTI)"),
],
[
label("Postpartum", "2E7D32"),
bullet("Aseptic precautions for at least 1 week"),
bullet("Restrict visitors; sterile sanitary pads"),
bullet("Isolate infected mother and baby"),
bullet("Adequate hand hygiene by all attendants"),
label("Necrotising Fasciitis (Rare but Fatal)", ORANGE),
bullet("Polymicrobial; Group A beta-haemolytic Streptococcus"),
bullet("Risk: diabetes, obesity, hypertension"),
bullet("Treatment: rehydration, wide debridement, high-dose broad-spectrum IV antibiotics"),
]
),
spacer(60),
// ─── FOOTER ───────────────────────────────────────────────
new Table({
width: { size: 100, type: WidthType.PERCENTAGE },
borders: TableBorders.NONE,
rows: [new TableRow({
children: [new TableCell({
shading: { fill: "F0F0F0", type: ShadingType.CLEAR },
margins: { top: 60, bottom: 60, left: 200, right: 200 },
children: [new Paragraph({
alignment: AlignmentType.CENTER,
children: [new TextRun({ text: "Source: Abnormalities of the Puerperium — Chapter 30 | Note compiled from uploaded textbook images", size: 16, font: "Arial", color: "888888" })]
})]
})]
})]
}),
]
}]
});
Packer.toBuffer(doc).then(buffer => {
fs.writeFileSync("/home/daytona/workspace/puerperal-sepsis/Puerperal_Sepsis_Note.docx", buffer);
console.log("Done: Puerperal_Sepsis_Note.docx");
}).catch(err => { console.error(err); process.exit(1); });
cd /home/daytona/workspace/puerperal-sepsis && node build.js 2>&1
python /home/daytona/skills/docx/scripts/office/validate.py /home/daytona/workspace/puerperal-sepsis/Puerperal_Sepsis_Note.docx 2>&1
python3 -c "import zipfile, sys; z=zipfile.ZipFile('/home/daytona/workspace/puerperal-sepsis/Puerperal_Sepsis_Note.docx'); print('OK — files:', z.namelist()[:6])"
Puerperal Sepsis Note
Word Document · DOCX
Make it a pdf file
python /home/daytona/skills/docx/scripts/office/soffice.py --headless --convert-to pdf /home/daytona/workspace/puerperal-sepsis/Puerperal_Sepsis_Note.docx --outdir /home/daytona/workspace/puerperal-sepsis/ 2>&1
cp /home/daytona/workspace/puerperal-sepsis/Puerperal_Sepsis_Note.docx /tmp/ps_note.docx && python /home/daytona/skills/docx/scripts/office/soffice.py --headless --convert-to pdf /tmp/ps_note.docx --outdir /tmp/ 2>&1 && cp /tmp/ps_note.pdf /home/daytona/workspace/puerperal-sepsis/Puerperal_Sepsis_Note.pdf && echo "PDF copied OK"
Puerperal Sepsis Note
PDF Document · PDF
But this is not supported
~/puerperal-sepsis/build_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.lib.styles import ParagraphStyle
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, HRFlowable
)
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_RIGHT
from reportlab.pdfbase import pdfmetrics
# ─── Colours ──────────────────────────────────────────────────────
TEAL = colors.HexColor("#1A6B7C")
TEAL_LT = colors.HexColor("#EAF4F7")
ORANGE = colors.HexColor("#D4550E")
ORANGE_LT = colors.HexColor("#FFF3E8")
AMBER = colors.HexColor("#F5A623")
GREEN = colors.HexColor("#2E7D32")
GREEN_LT = colors.HexColor("#E8F5E9")
RED = colors.HexColor("#C62828")
RED_LT = colors.HexColor("#FDECEA")
BLUE_LT = colors.HexColor("#E3F2FD")
BLUE = colors.HexColor("#1565C0")
AMBER_LT = colors.HexColor("#FFF8E1")
GREY_LT = colors.HexColor("#F5F5F5")
WHITE = colors.white
BLACK = colors.HexColor("#1A1A2E")
GREY_TEXT = colors.HexColor("#888888")
W, H = A4 # 595 x 842 pts
# ─── Paragraph styles ─────────────────────────────────────────────
def ps(name, parent=None, **kw):
defaults = dict(fontName="Helvetica", fontSize=8, leading=10,
textColor=BLACK, spaceAfter=2, spaceBefore=2)
defaults.update(kw)
return ParagraphStyle(name, **defaults)
title_st = ps("title", fontName="Helvetica-Bold", fontSize=14,
textColor=WHITE, alignment=TA_CENTER, spaceAfter=0, leading=17)
sub_st = ps("sub", fontName="Helvetica", fontSize=7,
textColor=colors.HexColor("#CCE8EF"), alignment=TA_CENTER, spaceAfter=0, leading=9)
hdr_st = ps("hdr", fontName="Helvetica-Bold", fontSize=8.5,
textColor=WHITE, spaceAfter=0, spaceBefore=0, leading=10)
body_st = ps("body", fontName="Helvetica", fontSize=7.2, leading=9.2)
bold_st = ps("bold", fontName="Helvetica-Bold", fontSize=7.5, leading=9.5)
small_st = ps("small", fontName="Helvetica", fontSize=6.8, leading=8.5, textColor=colors.HexColor("#444444"))
note_st = ps("note", fontName="Helvetica-Oblique", fontSize=6.5, leading=8,
textColor=GREY_TEXT, alignment=TA_CENTER)
label_st = ps("label", fontName="Helvetica-Bold", fontSize=8, leading=10)
red_st = ps("red", fontName="Helvetica-Bold", fontSize=7.5, textColor=RED, leading=9)
orange_st = ps("orng", fontName="Helvetica-Bold", fontSize=7.5, textColor=ORANGE, leading=9)
teal_st = ps("teal", fontName="Helvetica-Bold", fontSize=7.5, textColor=TEAL, leading=9)
green_st = ps("grn", fontName="Helvetica-Bold", fontSize=7.5, textColor=GREEN, leading=9)
blue_st = ps("blue", fontName="Helvetica-Bold", fontSize=7.5, textColor=BLUE, leading=9)
# ─── Helpers ──────────────────────────────────────────────────────
def sp(h=3): return Spacer(1, h)
def section_bar(text, bg=TEAL, col=WHITE):
t = Table([[Paragraph(text, ParagraphStyle("sh", fontName="Helvetica-Bold",
fontSize=8.5, textColor=col, leading=10))]],
colWidths=[W - 2*cm])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 8),
("RIGHTPADDING", (0,0), (-1,-1), 8),
]))
return t
def bullet_p(text, bold=False, color=BLACK, indent=8):
st = ps("bp", fontName="Helvetica-Bold" if bold else "Helvetica",
fontSize=7.2, leading=9.2, textColor=color,
leftIndent=indent, firstLineIndent=-indent)
return Paragraph(f"\u2022 {text}", st)
def color_box(text, bg, tc=BLACK):
t = Table([[Paragraph(text, ps("cb", fontName="Helvetica", fontSize=7,
textColor=tc, leading=8.5))]],
colWidths=[W - 2*cm])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 7),
("RIGHTPADDING", (0,0), (-1,-1), 7),
("BOX", (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
]))
return t
def flow_step(num, text, bg):
t = Table([[
Paragraph(num, ps("fn", fontName="Helvetica-Bold", fontSize=8,
textColor=WHITE, leading=10, alignment=TA_CENTER)),
Paragraph(text, ps("ft", fontName="Helvetica", fontSize=7,
textColor=WHITE, leading=9))
]], colWidths=[14, (W/2 - cm - 14 - 6)])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("BACKGROUND", (0,0), (0,0), colors.HexColor("#00000033")),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("BOX", (0,0), (-1,-1), 0.5, colors.HexColor("#AAAAAA")),
]))
return t
def arrow_p():
return Paragraph("▼", ps("arr", fontSize=8, textColor=TEAL,
alignment=TA_CENTER, leading=10))
# ─── Build story ──────────────────────────────────────────────────
story = []
# ── TITLE BAR ─────────────────────────────────────────────────────
title_tbl = Table([[
Paragraph("PUERPERAL SEPSIS", title_st),
],[
Paragraph("Chapter 30 — Abnormalities of the Puerperium | Quick Reference Note", sub_st),
]], colWidths=[W - 2*cm])
title_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), TEAL),
("TOPPADDING", (0,0), (-1,-1), 7),
("BOTTOMPADDING", (0,0), (-1,-1), 7),
("LEFTPADDING", (0,0), (-1,-1), 10),
("RIGHTPADDING", (0,0), (-1,-1), 10),
]))
story.append(title_tbl)
story.append(sp(5))
# ── ROW 1: Definition | Vaginal Flora ─────────────────────────────
half = (W - 2*cm - 4) / 2
def_content = [
section_bar("DEFINITION"),
sp(3),
Paragraph("<b><font color='#D4550E'>Puerperal Pyrexia:</font></b> Temp ≥100.4°F (38°C) on 2 separate occasions, >24 h after delivery, within the first 10 days postpartum.", body_st),
sp(2),
Paragraph("<b><font color='#D4550E'>Puerperal Sepsis:</font></b> Infection of the genital tract occurring as a complication of delivery.", body_st),
sp(3),
Paragraph("<b><font color='#1A6B7C'>Primary infection sites:</font></b>", body_st),
bullet_p("Perineum & vaginal wounds"),
bullet_p("Cervix"),
bullet_p("Uterus (endometrium / placental site)"),
]
flora_content = [
section_bar("VAGINAL FLORA AT ONSET OF LABOUR", ORANGE),
sp(3),
bullet_p("Doderlein's bacillus (60-70%)"),
bullet_p("Candida albicans (25%)"),
bullet_p("Staphylococcus albus / aureus"),
bullet_p("Streptococcus — anaerobic & beta-haemolytic"),
bullet_p("E. coli, Clostridium welchii (occasional)"),
bullet_p("Bacteroides group"),
sp(3),
color_box("Most infections are POLYMICROBIAL — mix of aerobic and anaerobic organisms.", TEAL_LT, TEAL),
]
row1 = Table([[def_content, flora_content]], colWidths=[half, half],
rowHeights=[None])
row1.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING",(0,0), (-1,-1), 0),
("INNERGRID", (0,0), (-1,-1), 0, WHITE),
("RIGHTPADDING", (0,0), (0,-1), 3),
("LEFTPADDING", (0,0), (1,-1), 3),
]))
story.append(row1)
story.append(sp(5))
# ── PATHOGENESIS FLOWCHART ─────────────────────────────────────────
story.append(section_bar("PATHOGENESIS FLOWCHART"))
story.append(sp(4))
src_box = Table([
[Paragraph("SOURCE OF INFECTION", ps("s", fontName="Helvetica-Bold",
fontSize=7.5, textColor=WHITE, leading=9, alignment=TA_CENTER))],
[Table([
[Paragraph("<b><font color='#1565C0'>Endogenous</font></b>",
ps("e1", fontSize=7, leading=8.5)),
Paragraph("Flora present in genital tract before delivery",
ps("e2", fontSize=7, leading=8.5))],
[Paragraph("<b><font color='#D4550E'>Autogenous</font></b>",
ps("a1", fontSize=7, leading=8.5)),
Paragraph("Skin/throat flora migrate via bloodstream",
ps("a2", fontSize=7, leading=8.5))],
[Paragraph("<b><font color='#C62828'>Exogenous</font></b>",
ps("x1", fontSize=7, leading=8.5)),
Paragraph("Hospital staff/attendants — Strep, Staph, E. coli",
ps("x2", fontSize=7, leading=8.5))],
], colWidths=[None, None],
style=TableStyle([
("BACKGROUND", (0,0), (-1,0), BLUE_LT),
("BACKGROUND", (0,1), (-1,1), ORANGE_LT),
("BACKGROUND", (0,2), (-1,2), RED_LT),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING", (0,0), (-1,-1), 3),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("BOX", (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
("INNERGRID", (0,0), (-1,-1), 0.3, colors.HexColor("#DDDDDD")),
]))],
], colWidths=[(W-2*cm)/3 - 4])
src_box.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), TEAL),
("TOPPADDING", (0,0), (-1,0), 4),
("BOTTOMPADDING", (0,0), (-1,0), 4),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("TOPPADDING", (0,1), (-1,1), 0),
]))
# Risk factors
ante = [
Paragraph("<b><font color='#1A6B7C'>Antepartum:</font></b>", body_st),
bullet_p("Anaemia"),
bullet_p("Preterm labour"),
bullet_p("PROM (\u226518 h)"),
bullet_p("Immunocompromised (HIV)"),
bullet_p("Diabetes"),
]
intra = [
Paragraph("<b><font color='#1A6B7C'>Intrapartum:</font></b>", body_st),
bullet_p("Repeated vaginal exams"),
bullet_p("Traumatic vaginal delivery"),
bullet_p("Retained placenta / PPH"),
bullet_p("Prolonged labour"),
bullet_p("Cesarean section"),
]
rf_inner = Table([[ante, intra]], colWidths=[None, None])
rf_inner.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("TOPPADDING", (0,0), (-1,-1), 2),
("BOTTOMPADDING", (0,0), (-1,-1), 2),
("LEFTPADDING", (0,0), (-1,-1), 4),
("RIGHTPADDING", (0,0), (-1,-1), 4),
]))
rf_box = Table([
[Paragraph("PREDISPOSING RISK FACTORS", ps("rf", fontName="Helvetica-Bold",
fontSize=7.5, textColor=WHITE, alignment=TA_CENTER, leading=9))],
[rf_inner],
], colWidths=[(W-2*cm)*2/3 - 4])
rf_box.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), ORANGE),
("TOPPADDING", (0,0), (-1,0), 4),
("BOTTOMPADDING", (0,0), (-1,0), 4),
("BOX", (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
]))
path_row = Table([[
src_box,
Paragraph("►", ps("arr2", fontSize=12, textColor=TEAL,
alignment=TA_CENTER, leading=14)),
rf_box,
]], colWidths=[(W-2*cm)/3 - 4, 16, (W-2*cm)*2/3 - 4])
path_row.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING", (0,0), (-1,-1), 0),
]))
story.append(path_row)
story.append(sp(5))
# ── ROW 2: Clinical Features | Investigations ─────────────────────
cf_content = [
section_bar("CLINICAL FEATURES"),
sp(2),
Paragraph("<b><font color='#1A6B7C'>Local (Wound) Infection</font></b>", body_st),
bullet_p("Slight rise of temperature, malaise / headache"),
bullet_p("Wound red & swollen; pus formation"),
bullet_p("Acute: high fever with chills and rigors"),
sp(2),
Paragraph("<b><font color='#1A6B7C'>Uterine Infection — Mild</font></b>", body_st),
bullet_p("Temp >100.4\u00b0F, pulse >90; offensive & copious lochia"),
bullet_p("Uterus subinvoluted and tender"),
Paragraph("<b><font color='#C62828'>Severe</font></b>", body_st),
bullet_p("Acute onset, high fever, chills & rigor"),
bullet_p("Rapid pulse out of proportion to temperature"),
bullet_p("Breathlessness, cough, abdominal pain, dysuria"),
bullet_p("Lochia may be scanty / odourless; uterus tender"),
sp(2),
Paragraph("<b><font color='#D4550E'>Spread (Extrauterine)</font></b>", body_st),
bullet_p("Pelvic cellulitis (parametritis) — indurated mass, uterus deviated"),
bullet_p("Peritonitis — bowel distension, dynamic ileus"),
bullet_p("Salpingitis — interstitial or perisalpingitis"),
bullet_p("Pelvic abscess — 7-10 days to develop"),
bullet_p("Septic pelvic thrombophlebitis — swinging fever; treat with LMWH"),
bullet_p("Septicaemia / Septic shock — 30% mortality"),
]
inv_content = [
section_bar("INVESTIGATIONS", ORANGE),
sp(2),
color_box("All puerperal pyrexia = genital sepsis UNTIL proved otherwise", ORANGE_LT, ORANGE),
sp(3),
Paragraph("<b><font color='#1A6B7C'>Principles:</font></b> Locate site | Identify organism | Assess severity", body_st),
sp(2),
bullet_p("HVS + endocervical swabs — aerobic & anaerobic C&S"),
bullet_p("MSU — urinalysis + culture & sensitivity"),
bullet_p("FBC — WBC, Hb, platelets (low = DIC/septicaemia)"),
bullet_p("Thick blood film — malarial parasites"),
bullet_p("Blood culture — if fever + chills/rigor"),
bullet_p("Urea, creatinine & electrolytes"),
bullet_p("Pelvic USS — retained products, abscess, venous thrombosis"),
bullet_p("CT/MRI — if pelvic vein thrombosis suspected"),
bullet_p("Chest X-ray — suspected TB or lung collapse"),
sp(3),
section_bar("ICU RED FLAGS", RED),
sp(2),
bullet_p("Fever, vomiting, diarrhoea, skin rash, organ dysfunction", color=RED),
color_box("Hypotension | Oliguria | Creatinine \u2191 | Lactate \u22654 mmol/L | Thrombocytopenia | ARDS | Hypothermia", RED_LT, RED),
]
row2 = Table([[cf_content, inv_content]], colWidths=[half, half])
row2.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING",(0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (0,-1), 3),
("LEFTPADDING", (0,0), (1,-1), 3),
]))
story.append(row2)
story.append(sp(5))
# ── TREATMENT FLOWCHART ────────────────────────────────────────────
story.append(section_bar("TREATMENT FLOWCHART"))
story.append(sp(4))
steps_col = [
Paragraph("<b><font color='#1A6B7C'>General Care</font></b>", body_st),
sp(2),
flow_step("1", "Isolate patient (esp. if haemolytic Streptococcus cultured)", TEAL),
arrow_p(),
flow_step("2", "IV fluids + calories; correct anaemia (oral iron / transfusion)", colors.HexColor("#2E7D8A")),
arrow_p(),
flow_step("3", "Indwelling catheter — monitor urine output", colors.HexColor("#3A8B9A")),
arrow_p(),
flow_step("4", "Chart pulse, temp, lochia, fluid balance", colors.HexColor("#4699A8")),
arrow_p(),
flow_step("5", "Empirical antibiotics pending C&S — continue 7-10 days", colors.HexColor("#529EB5")),
]
abx_data = [
[Paragraph("Scenario", ps("h", fontName="Helvetica-Bold", fontSize=7, textColor=WHITE, leading=9)),
Paragraph("Regimen", ps("h", fontName="Helvetica-Bold", fontSize=7, textColor=WHITE, leading=9))],
[Paragraph("Empirical severe", small_st),
Paragraph("Gentamicin 2 mg/kg IV load then 1.5 mg/kg q8h + Clindamycin 900 mg q8h + Metronidazole 0.5 g q8h", small_st)],
[Paragraph("Severe sepsis", small_st),
Paragraph("Piperacillin-tazobactam OR carbapenem + clindamycin", small_st)],
[Paragraph("MRSA", small_st),
Paragraph("Vancomycin or Teicoplanin", small_st)],
[Paragraph("SPT", small_st),
Paragraph("LMWH 1 mg/kg q12h; maintain APTT 1.5-2x normal", small_st)],
]
abx_tbl = Table(abx_data, colWidths=[None, None])
abx_tbl.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), ORANGE),
("BACKGROUND", (0,1), (-1,1), WHITE),
("BACKGROUND", (0,2), (-1,2), ORANGE_LT),
("BACKGROUND", (0,3), (-1,3), WHITE),
("BACKGROUND", (0,4), (-1,4), ORANGE_LT),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING", (0,0), (-1,-1), 3),
("LEFTPADDING", (0,0), (-1,-1), 5),
("RIGHTPADDING", (0,0), (-1,-1), 5),
("BOX", (0,0), (-1,-1), 0.5, colors.HexColor("#CCCCCC")),
("INNERGRID", (0,0), (-1,-1), 0.3, colors.HexColor("#DDDDDD")),
]))
surg_col = [
Paragraph("<b><font color='#D4550E'>Antibiotic Regimens</font></b>", body_st),
sp(2),
abx_tbl,
sp(4),
Paragraph("<b><font color='#1A6B7C'>Surgical Treatment</font></b>", body_st),
sp(2),
bullet_p("Perineal wound: IV antibiotics, debridement, sitz bath, secondary closure"),
bullet_p("Retained products (>3 cm): evacuate after 24 h antibiotic cover"),
bullet_p("Pelvic abscess: colpotomy drainage under USS guidance"),
bullet_p("Wound dehiscence: debridement + secondary suture"),
bullet_p("Laparotomy: unresponsive peritonitis; hysterectomy if gangrene/rupture"),
]
tx_row = Table([[steps_col, surg_col]], colWidths=[half, half])
tx_row.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING",(0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (0,-1), 3),
("LEFTPADDING", (0,0), (1,-1), 3),
]))
story.append(tx_row)
story.append(sp(5))
# ── PROPHYLAXIS ────────────────────────────────────────────────────
story.append(section_bar("PROPHYLAXIS", GREEN))
story.append(sp(4))
ante_p = [
Paragraph("<b><font color='#2E7D32'>Antenatal</font></b>", body_st),
bullet_p("Improve nutritional status (raise Hb)"),
bullet_p("Eradicate septic foci (skin, throat, tonsils)"),
sp(2),
Paragraph("<b><font color='#2E7D32'>Intranatal</font></b>", body_st),
bullet_p("Full surgical asepsis during delivery"),
bullet_p("Screen for Group B Streptococcus in high-risk patients"),
bullet_p("Prophylactic antibiotic at CS (reduces wound infection & endometritis)"),
]
post_p = [
Paragraph("<b><font color='#2E7D32'>Postpartum</font></b>", body_st),
bullet_p("Aseptic precautions for at least 1 week"),
bullet_p("Restrict visitors; sterile sanitary pads"),
bullet_p("Isolate infected mother and baby"),
sp(2),
Paragraph("<b><font color='#D4550E'>Necrotising Fasciitis (rare but fatal)</font></b>", body_st),
bullet_p("Polymicrobial; Group A beta-haemolytic Strep"),
bullet_p("Risk factors: diabetes, obesity, hypertension"),
bullet_p("Tx: rehydration, wide debridement, high-dose broad-spectrum IV antibiotics"),
]
proph_row = Table([[ante_p, post_p]], colWidths=[half, half])
proph_row.setStyle(TableStyle([
("VALIGN", (0,0), (-1,-1), "TOP"),
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING",(0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (0,-1), 3),
("LEFTPADDING", (0,0), (1,-1), 3),
]))
story.append(proph_row)
story.append(sp(5))
# ── FOOTER ─────────────────────────────────────────────────────────
story.append(HRFlowable(width="100%", thickness=0.5, color=colors.HexColor("#CCCCCC")))
story.append(sp(2))
story.append(Paragraph(
"Source: Abnormalities of the Puerperium — Chapter 30 | Note compiled from uploaded textbook images",
note_st))
# ─── Build PDF ─────────────────────────────────────────────────────
OUT = "/home/daytona/workspace/puerperal-sepsis/Puerperal_Sepsis_Note.pdf"
doc = SimpleDocTemplate(
OUT,
pagesize=A4,
leftMargin=1*cm, rightMargin=1*cm,
topMargin=1*cm, bottomMargin=1*cm,
)
doc.build(story)
print(f"PDF saved: {OUT}")
cd /home/daytona/workspace/puerperal-sepsis && python3 build_pdf.py 2>&1
python3 -c "from pypdf import PdfReader; r=PdfReader('/home/daytona/workspace/puerperal-sepsis/Puerperal_Sepsis_Note.pdf'); print(f'Pages: {len(r.pages)}, Size: {r.pages[0].mediabox}')"
cd /home/daytona/workspace/puerperal-sepsis && python3 -c " from pypdf import PdfReader r = PdfReader('Puerperal_Sepsis_Note.pdf') for i, p in enumerate(r.pages): print(f'Page {i+1}: {p.extract_text()[:200]}') "
~/puerperal-sepsis/build_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/puerperal-sepsis/build_pdf.py'
~/puerperal-sepsis/build_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/puerperal-sepsis/build_pdf.py'
~/puerperal-sepsis/build_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/puerperal-sepsis/build_pdf.py'
cd /home/daytona/workspace/puerperal-sepsis && sed -i 's/story\.append(sp(5))/story.append(sp(3))/g' build_pdf.py && python3 build_pdf.py 2>&1
"story.append(sp(" in ~/puerperal-sepsis
~/puerperal-sepsis/build_pdf.py
Error: String not found in file: 'story.append(sp(5))
story.append(sp(4))
story.append(section_bar("PATHOGENESIS FLOWCHART"))'~/puerperal-sepsis/build_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/puerperal-sepsis/build_pdf.py'
~/puerperal-sepsis/build_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/puerperal-sepsis/build_pdf.py'
~/puerperal-sepsis/build_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/puerperal-sepsis/build_pdf.py'
~/puerperal-sepsis/build_pdf.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/puerperal-sepsis/build_pdf.py'