Give me tricks to learn this I have exam tmrw
cd /home/daytona/workspace/attachments/fc64e48e-c914-4965-9ebc-4a634b3ea6a9/ && python3 -c " import pdfplumber with pdfplumber.open('Surgery Skin.pdf') as pdf: print(f'Total pages: {len(pdf.pages)}') for i, page in enumerate(pdf.pages): text = page.extract_text() if text: print(f'--- PAGE {i+1} ---') print(text[:3000]) "
| Feature | Abscess | Cellulitis | Necrotizing Fasciitis |
|---|---|---|---|
| Pus? | YES (fluctuation) | NO | NO (but gas/bullae) |
| Treatment | I&D | Antibiotics | SURGERY NOW |
| Urgency | Semi-urgent | Ward | EMERGENCY |
"4 × kg × %TBSA" - Half in first 8 hrs, half over next 16 hrs
"Dilute, don't neutralize" - Irrigation only, never try to neutralize acid with base.
"ECG + CK + Urine" - Arrhythmias, muscle damage, myoglobinuria (dark urine). Aim urine >1 mL/kg/hr.
"Soot, Hoarse, Facial burns" = secure airway EARLY before swelling closes it.
"SPLIT for LARGE, FULL for SMALL/FACE"
"A = Ascending = Always surgery" "B = Below = Beta-blockers first"
"PROVE" - Pulmonary stenosis, RVH, Overriding aorta, VSD + Examine CXR for boot shape
"P = Pneumo = Ping (hyperresonant)" "H = Hemo = Hollow dull"
"Needle decompression NOW, then chest tube" - 2nd intercostal space, midclavicular line
Pain, Pallor, Pulselessness, Paresthesia, Paralysis, Poikilothermia (cold)
Face, Arm, Speech, Time → carotid endarterectomy if >70% symptomatic stenosis
"SHE" - Stasis, Hypercoagulability, Endothelial injury
"Non-pitting" = lymphoedema (vs pitting = venous/cardiac)
GERD → Barrett's → Adenocarcinoma - surveillance endoscopy mandatory
Manometry = GOLD standard. Treatment: Balloon → Botox → Heller myotomy
"PPA" = PPI + Amoxicillin + Clarithromycin (C sneaks in but remember 2 antibiotics)
Vomiting → Hypokalemia + Metabolic alkalosis (losing HCl in vomit)
"Free air under diaphragm on erect CXR" = perforation until proven otherwise
| SBO | LBO | |
|---|---|---|
| Cause | Adhesions #1 | Cancer #1 |
| Vomiting | Early | Late |
| Distension | Central (small bowel loops) | Peripheral (frame-like) |
| X-ray | Air-fluid levels centrally | Peripheral distension |
Sigmoid volvulus = "Coffee-bean sign" on AXR
Pain + peritonism + fever + shock = laparotomy NOW, no delay
| "Pain out of proportion" | → Necrotizing fasciitis OR Ischemic bowel |
|---|---|
| "Boot-shaped heart" | → Tetralogy of Fallot |
| "Bird-beak" on barium | → Achalasia |
| "Free air under diaphragm" | → Perforation |
| "Coffee-bean sign" | → Sigmoid volvulus |
| "Fixed split S2" | → ASD |
| "Harsh pansystolic murmur LLSB" | → VSD |
| "Sudden chest/back pain + pulse deficit" | → Aortic dissection |
| "Non-pitting edema" | → Lymphoedema |
| Fluctuation on exam | → Abscess (needs I&D) |
Make a 1-page exam cheat sheet of the blue 'MANAGEMENT' boxes
mkdir -p /home/daytona/workspace/cheatsheet && cat > /home/daytona/workspace/cheatsheet/make_cheatsheet.py << 'PYEOF' from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.units import mm from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer from reportlab.lib.styles import ParagraphStyle from reportlab.lib.enums import TA_LEFT, TA_CENTER PAGE_W, PAGE_H = A4 # 210 x 297 mm doc = SimpleDocTemplate( "/home/daytona/workspace/cheatsheet/Surgery_Management_CheatSheet.pdf", pagesize=A4, leftMargin=6*mm, rightMargin=6*mm, topMargin=6*mm, bottomMargin=4*mm ) # --- Styles --- title_style = ParagraphStyle("title", fontSize=11, fontName="Helvetica-Bold", textColor=colors.white, alignment=TA_CENTER, leading=13) hdr_style = ParagraphStyle("hdr", fontSize=6.5, fontName="Helvetica-Bold", textColor=colors.white, alignment=TA_CENTER, leading=8) body_style = ParagraphStyle("body", fontSize=5.5, fontName="Helvetica", textColor=colors.black, leading=7, alignment=TA_LEFT) bold_body = ParagraphStyle("bold_body", fontSize=5.5, fontName="Helvetica-Bold", textColor=colors.HexColor("#003366"), leading=7) BLUE = colors.HexColor("#1565C0") LBLUE = colors.HexColor("#BBDEFB") DBLUE = colors.HexColor("#0D47A1") WHITE = colors.white LGREY = colors.HexColor("#F5F5F5") def H(text): return Paragraph(text, hdr_style) def B(text): return Paragraph(f"<b>{text}</b>", bold_body) def P(text): return Paragraph(text, body_style) def cell(items): """Build a cell with list of Paragraphs""" return items # Each entry: (header_text, [step lines]) sections = [ ("ABSCESS", [ "1. Handwash, intro, vitals", "2. Assess systemic infection (fever, tachy)", "3. Analgesia", "4. Incision & Drainage (definitive)", "5. Antibiotics if: fever, extensive cellulitis,\n immunosuppression, DM, recurrent", "6. Irrigate, pack, dress", "7. Follow-up / wound review", ]), ("CELLULITIS", [ "1. Vitals, assess for sepsis", "2. Mark erythema margins", "3. Systemic antibiotics", "4. Elevate limb + analgesia", "5. Reassess 24-48h", "6. Worsen → reassess dx or admit", ]), ("NECROTIZING FASCIITIS ⚠", [ "1. SURGICAL EMERGENCY", "2. ABCDE + IV fluids", "3. Broad-spectrum IV antibiotics NOW", "4. Urgent surgical debridement", "5. ICU care", "6. Re-look surgery (repeat debridements)", ]), ("BURNS (THERMAL)", [ "1. Primary survey ABCDE", "2. Airway: assess inhalation injury", "3. O2: high-flow oxygen", "4. IV access: 2 large-bore cannulas", "5. Fluids: Parkland = 4×kg×%TBSA\n (½ in 1st 8h, ½ next 16h)", "6. Foley catheter (urine ≥0.5 mL/kg/hr)", "7. Wound care: clean, sterile dressings,\n topical antimicrobials", "8. IV analgesia", "9. Tetanus prophylaxis", "10. Refer to burns unit if criteria met", ]), ("CHEMICAL BURNS ⚠", [ "1. Remove contaminated clothing NOW", "2. Irrigate with copious water/saline", "3. Do NOT neutralize", "4. ABCDE", "5. Analgesia", "6. Early burns team involvement", ]), ("ELECTRICAL BURNS ⚠", [ "1. ABCDE - airway + circulation priority", "2. Continuous ECG monitoring", "3. Aggressive IV fluids (prevent renal failure)", "4. Urine output >1 mL/kg/hr", "5. Early surgical assessment", ]), ("INHALATION INJURY", [ "1. Secure airway EARLY", "2. 100% oxygen", "3. Continuous respiratory monitoring", "4. ICU if severe", ]), ("NON-HEALING WOUNDS", [ "1. Handwash, intro, vitals, wound assess", "2. Debridement of necrotic tissue", "3. Antibiotics (culture-guided)", "4. Optimize nutrition + control DM", "5. Skin graft/flap if large/chronic", "6. Regular wound assessment", ]), ("POST-BURN CONTRACTURE", [ "1. Assess joint mobility & contracture extent", "2. Mild: physiotherapy + splinting", "3. Severe: Z-plasty or skin graft release", "4. Post-op: dressings, splints, physio", ]), ("SKIN GRAFT", [ "1. Handwash, intro, assess patient", "2. Debride wound bed", "3. Split-thickness = large area;\n Full-thickness = small/delicate area", "4. Immobilize graft", "5. Monitor: infection, necrosis, rejection", ]), ("CABG", [ "1. Full cardiac hx, exam, risk factors", "2. ECG, echo, coronary angiography", "3. Optimize BP, DM, antiplatelets", "4. Plan grafts from angiography", "5. Post-op: ICU, pain, inotropes if needed,\n early mobilization", "6. Monitor: arrhythmias, bleeding, infection", ]), ("VALVULAR HEART SURGERY", [ "1. Assess severity + surgical risk", "2. Control HF, treat infections", "3. Repair preferred; replace if needed", "4. Post-op ICU, anticoagulate if\n mechanical valve, infection prophylaxis", "5. Follow-up echo", ]), ("AORTIC DISSECTION ⚠", [ "TYPE A (ascending) - EMERGENCY:", "→ IV beta-blockers + pain control", "→ Emergency surgical repair", "TYPE B (descending) - STABLE:", "→ IV beta-blockers + nitroprusside", "→ Surgery only if complications", "Post-op: ICU, strict BP, serial imaging", ]), ("AORTIC ANEURYSM", [ "<5.5cm: beta-blockers, statins,\n regular imaging", ">5.5cm or symptomatic: elective repair\n (open or endovascular)", "Rupture: immediate resuscitation,\n ICU, emergency surgery", "Post-op: ICU, BP control, pain,\n monitor bleeding/stroke/paraplegia", ]), ("ASD", [ "Small: observe if asymptomatic", "Large: percutaneous device closure\n or surgical closure", "Post-op: ECG, pain, early mobilization", ]), ("VSD", [ "Small: observe (may close spontaneously)", "Moderate/Large:", "→ Medical: diuretics, ACE inhibitors", "→ Surgical: patch closure if symptomatic\n or pulmonary HTN develops", "Post-op: monitor heart function,\n infection prophylaxis", ]), ("TETRALOGY OF FALLOT (TOF)", [ "1. O2 if hypoxic; beta-blockers\n for hypercyanotic spells", "2. Complete repair in infancy:\n VSD closure + relieve pulm stenosis", "3. Post-op ICU, pain, monitor arrhythmias", ]), ("RHEUMATIC HEART DISEASE", [ "1. Penicillin + anti-inflammatories\n (acute RF)", "2. Balloon valvotomy (stenosis) or\n valve replacement (severe)", "3. HF: diuretics, beta-blockers, ACEi", "4. Secondary prophylaxis: penicillin", "5. Anticoagulate if mechanical valve", ]), ("INFECTIVE ENDOCARDITIS", [ "1. IV antibiotics 4-6 weeks\n (culture-targeted)", "Surgical if: valve destruction,\n HF, recurrent emboli", "3. Monitor renal function + electrolytes", "4. HF management", ]), ("PNEUMOTHORAX", [ "Small/stable: O2 + observe;\n repeat CXR 24-48h", "Large/symptomatic:\n needle aspiration or chest tube", "Tension ⚠: needle decompress NOW\n (2nd ICS MCL) → chest tube", "Recurrent: VATS or pleurodesis", ]), ("HEMOTHORAX", [ "1. ABCDE, IV access + fluids", "2. Chest tube insertion", "3. Thoracotomy if:\n initial >1500 mL or >200 mL/hr", "4. Monitor vitals, urine, Hb", ]), ("PLEURAL EFFUSION", [ "Small/asymptomatic:\n observe + treat cause", "Symptomatic/large:\n therapeutic thoracentesis", "Recurrent: chest tube +\n chemical pleurodesis or decortication", ]), ("EMPYEMA", [ "1. IV fluids, analgesia, O2", "2. Broad-spectrum IV antibiotics\n (tailor by culture)", "3. Chest tube (± US guidance)", "4. Loculated/persistent:\n VATS or thoracotomy decortication", ]), ("LUNG CANCER (THORACIC)", [ "Early: lobectomy/pneumonectomy +\n mediastinal LN dissection", "Advanced: chemo, radio, palliative\n surgery if obstruction/hemorrhage", "Post-op: ICU, pain, chest tube mgmt", ]), ("PAD (PERIPHERAL)", [ "1. Lifestyle: smoking cessation,\n supervised walking", "2. Medical: antiplatelets, statins,\n cilostazol for claudication", "3. Endovascular: angioplasty/stenting", "4. Surgical: bypass for critical ischemia", "5. Monitor ABI; foot care", ]), ("ACUTE LIMB ISCHEMIA ⚠", [ "1. ABCDE, analgesia, IV access", "2. IV heparin (prevent propagation)", "3. Embolectomy (surgical) OR\n thrombolysis if appropriate", "4. Bypass if chronic occlusion", "5. Post-op: pulses, anticoagulation", ]), ("CAROTID ARTERY DISEASE", [ "1. Antiplatelets + statins + BP control", "2. Carotid endarterectomy:\n symptomatic >70% stenosis", "3. Stenting: high surgical risk patients", "4. Monitor BP + cardiovascular risk", ]), ("VARICOSE VEINS", [ "1. Conservative: compression, elevation,\n exercise, weight loss", "2. Venoactive drugs (symptom relief)", "3. Endovenous laser/RFA,\n or foam sclerotherapy,\n or saphenofemoral ligation+strip", "4. Post-proc: compression + mobilize", ]), ("DVT", [ "1. Anticoagulation:\n Immediate: LMWH or UFH\n Long-term: warfarin/DOAC 3-6 months", "2. Compression stockings\n (post-thrombotic syndrome prevention)", "3. Thrombectomy: limb-threatening", "4. IVC filter: anticoag contraindicated", ]), ("LYMPHOEDEMA", [ "1. Manual lymphatic drainage", "2. Compression bandaging + skin care", "3. Diuretics rarely helpful", "4. Treat infections promptly", "5. Surgery: lymphatic bypass/debulking\n (refractory cases)", ]), ("GERD", [ "1. Lifestyle: weight loss, head-of-bed\n elevation, avoid triggers", "2. Antacids → H2 blockers → PPI (mainstay)", "3. Surgery: Nissen fundoplication\n (refractory)", "4. Monitor: endoscopy for Barrett's", ]), ("ACHALASIA", [ "1. Medical: nitrates/CCB (short-term)", "2. Endoscopic: pneumatic balloon dilation\n or Botulinum toxin", "3. Surgery: Heller myotomy +\n fundoplication", "4. Monitor symptom + esophageal function", ]), ("ESOPHAGEAL CANCER", [ "Early: endoscopic mucosal resection\n or esophagectomy", "Locally advanced: neoadjuvant\n chemoradio + surgery", "Palliative: stenting, chemo/radio", "Post-op: ICU, nutrition, pain", ]), ("ESOPHAGEAL PERFORATION ⚠", [ "1. ABCDE, IV fluids,\n broad-spectrum IV antibiotics", "2. Large/symptomatic: surgical repair", "3. Small/contained: endoscopic stent", "4. Post-op: ICU, NGT/parenteral nutrition", ]), ("PEPTIC ULCER DISEASE", [ "1. H. pylori: Triple therapy\n PPI + amoxicillin + clarithromycin", "2. PPI for ulcer healing; stop NSAIDs", "Complications:", "→ GI bleed: fluids, transfuse, endoscopic\n hemostasis", "→ Perforation: emergency surgery", "3. Follow-up endoscopy", ]), ("GASTRIC CANCER", [ "Early: endoscopic mucosal resection", "Locally advanced: gastrectomy\n (subtotal/total) + lymphadenectomy\n + adjuvant chemoradio", "Palliative: stenting/chemo", "Post-op: ICU, nutrition, pain", ]), ("GASTRIC OUTLET OBSTRUCTION", [ "1. IV fluids + electrolyte correction", "2. NG tube decompression", "3. PPI (ulcer-related)", "4. Pyloroplasty/gastrojejunostomy\n (persistent obstruction)", "5. Resection if malignant", ]), ("GI PERFORATION ⚠", [ "1. ABCDE, IV fluids, analgesia, O2", "2. Broad-spectrum IV antibiotics", "3. Emergency laparotomy +\n Graham patch repair", "4. H. pylori eradication post-op", "5. Post-op: ICU, pain, nutrition", ]), ("SMALL BOWEL OBSTRUCTION", [ "1. ABCDE, IV fluids,\n electrolyte correction", "2. NG tube decompression", "3. Analgesia; monitor partial SBO", "4. Surgery if: complete obstruction,\n strangulation, fail conservative", "→ Lysis adhesions, resect necrotic\n bowel, hernia repair", ]), ("CROHN'S DISEASE", [ "1. Corticosteroids (acute flare)", "2. Immunosuppressants:\n azathioprine, methotrexate", "3. Biologics: infliximab, adalimumab", "Surgery if: strictures, obstruction,\n perforation, fistulas", "→ Resection of affected segment", "5. Nutrition support", ]), ("ISCHEMIC BOWEL ⚠", [ "1. ABCDE, IV fluids, O2, correct shock", "2. Anticoagulation if embolic", "3. Broad-spectrum IV antibiotics", "4. Surgery: resect necrotic bowel,\n embolectomy/bypass if indicated", "5. Post-op: ICU, fluids, nutrition", ]), ("COLORECTAL CANCER", [ "1. Segmental colectomy +\n lymphadenectomy (curative)", "2. Colostomy if needed", "3. Adjuvant chemo: stage II-III", "4. Radiotherapy: rectal tumors", "5. Follow-up: colonoscopy + CEA", ]), ("DIVERTICULAR DISEASE", [ "Uncomplicated:\n oral antibiotics + liquid diet", "Complicated (abscess/perforation):\n IV antibiotics + percutaneous drain;\n surgery if peritonitis", "Elective: segmental colectomy\n (recurrent/complicated)", ]), ("HEMORRHOIDS", [ "1. Conservative: high-fiber, sitz baths,\n topical creams", "2. Rubber band ligation (internal)", "3. Excision (thrombosed/severe)", ]), ("ANAL FISSURE", [ "1. High-fiber diet + sitz baths", "2. Topical anesthetics or\n topical nitroglycerin", "3. Surgery: lateral internal\n sphincterotomy (chronic)", ]), ("ANAL ABSCESS & FISTULA", [ "Abscess: Incision & Drainage\n + antibiotics if cellulitis", "Fistula: fistulotomy or\n seton placement\n (avoid sphincter damage)", ]), ("ACUTE APPENDICITIS", [ "Uncomplicated:", "→ Laparoscopic appendectomy (early)", "→ IV fluids, analgesia, antibiotics pre-op", "Complicated (perforation/abscess):", "→ IV broad-spectrum antibiotics", "→ Percutaneous drain if localized", "→ Interval appendectomy if needed", "Post-op: pain, mobilize, wound care", ]), ("LARGE BOWEL OBSTRUCTION", [ "1. IV fluids + electrolytes", "2. NG decompression if vomiting", "3. Analgesia", "Cancer: colectomy", "Volvulus: sigmoidoscopy decompression\n (sigmoid) or surgery (cecal)", "Stricture: segmental resection", "Post-op: bowel function, fluids, pain", ]), ("STRANGULATED BOWEL ⚠", [ "1. ABCDE, IV fluids, O2", "2. Broad-spectrum IV antibiotics", "3. Emergency laparotomy", "4. Resect necrotic bowel;\n anastomosis or stoma", "5. Post-op ICU, fluids, nutrition", ]), ] # Build 3-column table layout # We'll organize into 3 columns side by side from reportlab.platypus import KeepTogether def make_box(title, steps): # Title row title_para = Paragraph(f"<b>{title}</b>", ParagraphStyle("th", fontSize=5.8, fontName="Helvetica-Bold", textColor=WHITE, alignment=TA_CENTER, leading=7.5)) step_lines = [Paragraph(f"• {s}" if not s.startswith("→") and not s.startswith("TYPE") and not s.endswith(":") and not s[0].isdigit() else s, ParagraphStyle("bp", fontSize=5.0, fontName="Helvetica", textColor=colors.black, leading=6.3, leftIndent=2)) for s in steps] inner = Table( [[sp] for sp in step_lines], colWidths=[59*mm], style=TableStyle([ ('TOPPADDING', (0,0), (-1,-1), 0.5), ('BOTTOMPADDING', (0,0), (-1,-1), 0.5), ('LEFTPADDING', (0,0), (-1,-1), 2), ('RIGHTPADDING', (0,0), (-1,-1), 1), ]) ) box = Table( [[title_para], [inner]], colWidths=[61*mm], style=TableStyle([ ('BACKGROUND', (0,0), (0,0), BLUE), ('BACKGROUND', (0,1), (0,1), LGREY), ('BOX', (0,0), (-1,-1), 0.5, DBLUE), ('LINEBELOW', (0,0), (0,0), 0.5, DBLUE), ('TOPPADDING', (0,0), (0,0), 2), ('BOTTOMPADDING', (0,0), (0,0), 2), ('TOPPADDING', (0,1), (0,1), 1), ('BOTTOMPADDING', (0,1), (0,1), 1), ('LEFTPADDING', (0,0), (-1,-1), 2), ('RIGHTPADDING', (0,0), (-1,-1), 1), ]) ) return box boxes = [make_box(title, steps) for title, steps in sections] # Divide into 3 columns n = len(boxes) col_size = (n + 2) // 3 col1 = boxes[:col_size] col2 = boxes[col_size:2*col_size] col3 = boxes[2*col_size:] # Pad shorter columns max_len = max(len(col1), len(col2), len(col3)) spacer_box = Paragraph("", body_style) while len(col1) < max_len: col1.append(spacer_box) while len(col2) < max_len: col2.append(spacer_box) while len(col3) < max_len: col3.append(spacer_box) # Stack each column into a sub-table def col_table(col_boxes, w): rows = [[b] for b in col_boxes] return Table(rows, colWidths=[w], style=TableStyle([ ('TOPPADDING', (0,0), (-1,-1), 1), ('BOTTOMPADDING', (0,0), (-1,-1), 1), ('LEFTPADDING', (0,0), (-1,-1), 0), ('RIGHTPADDING', (0,0), (-1,-1), 0), ])) CW = 63*mm c1t = col_table(col1, CW) c2t = col_table(col2, CW) c3t = col_table(col3, CW) main_table = Table([[c1t, c2t, c3t]], colWidths=[CW, CW, CW], style=TableStyle([ ('VALIGN', (0,0), (-1,-1), 'TOP'), ('LEFTPADDING', (0,0), (-1,-1), 1), ('RIGHTPADDING', (0,0), (-1,-1), 1), ('TOPPADDING', (0,0), (-1,-1), 0), ('BOTTOMPADDING', (0,0), (-1,-1), 0), ])) # Header header_style = ParagraphStyle("main_title", fontSize=10, fontName="Helvetica-Bold", textColor=WHITE, alignment=TA_CENTER, leading=13) header_table = Table( [[Paragraph("SURGERY SKIN — MANAGEMENT PLANS CHEAT SHEET", header_style)]], colWidths=[198*mm], style=TableStyle([ ('BACKGROUND', (0,0), (-1,-1), DBLUE), ('TOPPADDING', (0,0), (-1,-1), 3), ('BOTTOMPADDING', (0,0), (-1,-1), 3), ('LEFTPADDING', (0,0), (-1,-1), 4), ('BOX', (0,0), (-1,-1), 0.5, colors.HexColor("#0A2472")), ]) ) story = [header_table, Spacer(1, 2*mm), main_table] doc.build(story) print("Done!") PYEOF python3 /home/daytona/workspace/cheatsheet/make_cheatsheet.py
cat > /home/daytona/workspace/cheatsheet/make_cheatsheet.py << 'PYEOF' from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.units import mm from reportlab.pdfbase import pdfmetrics W, H = A4 # 595.28 x 841.89 BLUE_DARK = colors.HexColor("#0D47A1") BLUE_MED = colors.HexColor("#1565C0") BLUE_LIGHT = colors.HexColor("#BBDEFB") WHITE = colors.white BLACK = colors.black GREY_BG = colors.HexColor("#F0F4FF") sections = [ ("ABSCESS", [ "1 Handwash, intro, vitals", "2 Assess systemic infection", "3 Analgesia", "4 Incision & Drainage (definitive)", "5 Antibiotics if: fever, cellulitis, DM,", " immunosuppression, recurrent", "6 Irrigate, pack, dress; follow-up", ]), ("CELLULITIS", [ "1 Vitals, assess for sepsis", "2 Mark erythema margins", "3 Systemic antibiotics", "4 Elevate limb + analgesia", "5 Reassess 24-48h; admit if worsening", ]), ("NECROTIZING FASCIITIS \u26a0", [ "1 SURGICAL EMERGENCY", "2 ABCDE + IV fluids", "3 Broad-spectrum IV antibiotics NOW", "4 Urgent surgical debridement", "5 ICU; re-look surgery repeatedly", ]), ("BURNS \u2014 THERMAL", [ "1 Primary survey ABCDE", "2 Airway: assess inhalation injury", "3 High-flow O2", "4 2 large-bore IV cannulas", "5 Parkland: 4xkgx%TBSA", " (1/2 in 1st 8h, 1/2 next 16h)", "6 Foley: urine >=0.5 mL/kg/hr", "7 Clean, sterile dressing, topical abx", "8 IV analgesia; tetanus prophylaxis", "9 Refer to burns unit if criteria met", ]), ("CHEMICAL BURNS \u26a0", [ "1 Remove clothing NOW", "2 Irrigate copiously (water/saline)", "3 Do NOT neutralize", "4 ABCDE + analgesia", "5 Early burns team involvement", ]), ("ELECTRICAL BURNS \u26a0", [ "1 ABCDE - airway + circulation", "2 Continuous ECG monitoring", "3 Aggressive IV fluids", "4 Urine >1 mL/kg/hr", "5 Early surgical assessment", ]), ("INHALATION INJURY", [ "1 Secure airway EARLY", "2 100% oxygen", "3 Continuous resp monitoring", "4 ICU if severe", ]), ("NON-HEALING WOUNDS", [ "1 Handwash, intro, vitals, wound assess", "2 Debridement of necrotic tissue", "3 Antibiotics (culture-guided)", "4 Optimize nutrition, control DM", "5 Skin graft/flap if large/chronic", "6 Regular wound assessment", ]), ("POST-BURN CONTRACTURE", [ "1 Assess joint mobility + extent", "2 Mild: physiotherapy + splinting", "3 Severe: Z-plasty or skin graft", "4 Post-op: dressings, splints, physio", ]), ("SKIN GRAFT", [ "1 Handwash, intro, assess", "2 Debride wound bed", "3 Split-thickness=large area;", " Full-thickness=small/delicate", "4 Immobilize graft", "5 Monitor: infection, necrosis", ]), ("CABG", [ "1 Full cardiac hx, exam, risk factors", "2 ECG, echo, coronary angiography", "3 Optimise BP, DM, antiplatelets", "4 Plan grafts (IMA/saphenous vein)", "5 Post-op: ICU, pain, inotropes,", " monitor arrhythmias/bleeding", ]), ("VALVULAR HEART SURGERY", [ "1 Assess severity + surgical risk", "2 Control HF, treat infections", "3 Repair preferred; replace if needed", "4 Post-op: ICU, anticoagulate if", " mechanical valve; follow-up echo", ]), ("AORTIC DISSECTION \u26a0", [ "Type A (ascending) = EMERGENCY:", " IV beta-blockers + pain control", " Emergency surgical repair", "Type B (descending) = STABLE:", " IV BB + nitroprusside", " Surgery only if complications", "Post-op: ICU, strict BP, serial imaging", ]), ("AORTIC ANEURYSM", [ "<5.5cm: BB, statins, regular imaging", ">5.5cm/symptomatic: elective repair", " (open or endovascular)", "Rupture: resuscitate, ICU, surgery", "Post-op: ICU, BP control, pain", ]), ("ASD", [ "Small: observe if asymptomatic", "Large: percutaneous device closure", " or surgical closure", "Post-op: ECG monitoring, early mobil", ]), ("VSD", [ "Small: observe (may close spontan.)", "Mod/Large:", " Medical: diuretics, ACE inhibitors", " Surgical: patch closure if symptomatic", " or pulmonary HTN develops", ]), ("TETRALOGY OF FALLOT", [ "1 O2; BB for hypercyanotic spells", "2 Complete repair in infancy:", " VSD closure + relieve PS", "3 Post-op: ICU, pain, arrhythmias", ]), ("RHEUMATIC HEART DISEASE", [ "1 Penicillin + anti-inflammatories", "2 Balloon valvotomy (stenosis) or", " valve replacement (severe)", "3 HF: diuretics, BB, ACEi", "4 2ry prophylaxis: long-term penicillin", "5 Anticoagulate if mechanical valve", ]), ("INFECTIVE ENDOCARDITIS", [ "1 IV antibiotics 4-6wk (culture-guided)", "Surgery if: valve destruction,", " HF, recurrent emboli", "3 Monitor renal function, electrolytes", ]), ("PNEUMOTHORAX", [ "Small/stable: O2 + observe; CXR 24-48h", "Large/symptomatic:", " Needle aspiration or chest tube", "Tension \u26a0: needle decompress (2nd ICS", " MCL) FIRST, then chest tube", "Recurrent: VATS or pleurodesis", ]), ("HEMOTHORAX", [ "1 ABCDE, IV access + fluids", "2 Chest tube insertion", "3 Thoracotomy if >1500mL initial", " or >200 mL/hr persistent", "4 Monitor vitals, urine, Hb", ]), ("PLEURAL EFFUSION", [ "Small/asymp: observe + treat cause", "Symptomatic/large:", " Therapeutic thoracentesis", "Recurrent: chest tube +", " chemical pleurodesis/decortication", ]), ("EMPYEMA", [ "1 IV fluids, analgesia, O2", "2 Broad-spectrum IV abx (taper by cx)", "3 Chest tube (US-guided preferred)", "4 VATS or thoracotomy if loculated", ]), ("LUNG CANCER (SURGERY)", [ "Early: lobectomy/pneumonectomy", " + mediastinal LN dissection", "Advanced: chemo/radio, palliative", " surgery if obstruction/hemorrhage", "Post-op: ICU, pain, chest tube mgmt", ]), ("PAD", [ "1 Smoking cessation; supervised walk", "2 Antiplatelets + statins", " Cilostazol for claudication", "3 Endovascular: angioplasty/stent", "4 Bypass graft for critical ischemia", "5 Monitor ABI + foot care", ]), ("ACUTE LIMB ISCHEMIA \u26a0", [ "1 ABCDE, analgesia, IV access", "2 IV heparin (prevent propagation)", "3 Embolectomy OR thrombolysis", "4 Bypass if chronic occlusion", "5 Post-op: pulse checks, anticoagulate", ]), ("CAROTID ARTERY DISEASE", [ "1 Antiplatelets + statins + BP control", "2 CEA: symptomatic >70% stenosis", "3 Stenting: high surgical risk", "4 Monitor BP + CVS risk ongoing", ]), ("VARICOSE VEINS", [ "1 Compression, elevation, exercise", "2 Venoactive drugs (symptom relief)", "3 Endovenous laser/RFA or", " foam sclerotherapy or", " saphenofemoral ligation+strip", "4 Post-proc: compression + mobilize", ]), ("DVT", [ "1 LMWH or UFH (immediate)", " Warfarin/DOAC long-term 3-6 months", "2 Compression stockings", "3 Thrombectomy: limb-threatening", "4 IVC filter: anticoag contraindicated", ]), ("LYMPHOEDEMA", [ "1 Manual lymphatic drainage", "2 Compression bandaging + skin care", "3 Treat infections promptly", "4 Surgery (refractory): lymphatic", " bypass or debulking", ]), ("GERD", [ "1 Lifestyle: weight loss, HOB elevation", "2 Antacids > H2 blockers > PPI (mainstay)", "3 Nissen fundoplication (refractory)", "4 Endoscopy for Barrett's surveillance", ]), ("ACHALASIA", [ "1 Nitrates/CCB (short-term)", "2 Pneumatic balloon dilation", " or Botulinum toxin", "3 Heller myotomy + fundoplication", "4 Monitor symptoms + esoph function", ]), ("ESOPHAGEAL CANCER", [ "Early: EMR or esophagectomy", "Locally adv: neoadjuvant chemoradio", " + surgery", "Palliative: stenting, chemo/radio", "Post-op: ICU, nutrition, pain", ]), ("ESOPHAGEAL PERFORATION \u26a0", [ "1 ABCDE + broad-spectrum IV abx", "2 Large/symptomatic: surgical repair", "3 Small/contained: endoscopic stent", "4 Post-op: ICU, NGT/parenteral nutrition", ]), ("PEPTIC ULCER DISEASE", [ "1 H.pylori: PPI + amoxicillin +", " clarithromycin (triple therapy)", "2 PPI for healing; stop NSAIDs", "GI bleed: fluids, transfuse,", " endoscopic hemostasis", "Perforation: emergency laparotomy", "3 Follow-up endoscopy", ]), ("GASTRIC CANCER", [ "Early: endoscopic mucosal resection", "Locally adv: gastrectomy (subtotal/", " total) + lymphadenectomy + adjuvant", " chemoradio", "Palliative: stenting/chemo", ]), ("GASTRIC OUTLET OBSTRUCTION", [ "1 IV fluids + electrolyte correction", "2 NG tube decompression", "3 PPI (ulcer-related)", "4 Pyloroplasty/gastrojejunostomy", " (persistent); resection if malignant", ]), ("GASTRIC/DUODENAL PERFORATION \u26a0", [ "1 ABCDE, IV fluids, analgesia, O2", "2 Broad-spectrum IV antibiotics", "3 Emergency laparotomy + Graham patch", "4 H.pylori eradication post-op", "5 Post-op: ICU, pain, nutrition", ]), ("SMALL BOWEL OBSTRUCTION", [ "1 ABCDE + IV fluids + electrolytes", "2 NG tube decompression", "3 Analgesia; monitor partial SBO", "Surgery if: complete, strangulation,", " fail conservative", " -> Lyse adhesions, resect necrotic", " bowel, hernia repair", ]), ("CROHN'S DISEASE", [ "1 Corticosteroids (acute flare)", "2 Immunosuppressants:", " azathioprine, methotrexate", "3 Biologics: infliximab, adalimumab", "Surgery: strictures, obstruction,", " perforation, fistulas", " -> Resect affected segment", ]), ("ISCHEMIC BOWEL \u26a0", [ "1 ABCDE, IV fluids, O2, correct shock", "2 Anticoagulation if embolic", "3 Broad-spectrum IV abx", "4 Surgery: resect necrotic bowel;", " embolectomy/bypass", "5 Post-op: ICU, fluids, nutrition", ]), ("COLORECTAL CANCER", [ "1 Segmental colectomy +", " lymphadenectomy (curative)", "2 Colostomy if needed", "3 Adjuvant chemo: stage II-III", "4 Radiotherapy: rectal tumors", "5 Follow-up: colonoscopy + CEA", ]), ("DIVERTICULAR DISEASE", [ "Uncomplicated: oral abx + liquid diet", "Complicated (abscess/perforation):", " IV abx + percutaneous drain;", " surgery if peritonitis", "Elective: segmental colectomy", ]), ("HEMORRHOIDS", [ "1 High-fiber diet + sitz baths +", " topical creams", "2 Rubber band ligation (internal)", "3 Excision (thrombosed/severe)", ]), ("ANAL FISSURE", [ "1 High-fiber + sitz baths", "2 Topical anesthetics or nitroglycerine", "3 Lateral internal sphincterotomy", " (chronic fissure)", ]), ("ANAL ABSCESS & FISTULA", [ "Abscess: I&D + abx if cellulitis", "Fistula: fistulotomy or seton", " placement; avoid sphincter damage", ]), ("ACUTE APPENDICITIS", [ "Uncomplicated:", " Laparoscopic appendectomy (early)", " IV fluids, analgesia, abx pre-op", "Complicated (perforation/abscess):", " IV broad-spectrum abx", " Percutaneous drain if localized", " Interval appendectomy if needed", "Post-op: pain, mobilize, wound care", ]), ("LARGE BOWEL OBSTRUCTION", [ "1 IV fluids + electrolytes", "2 NG decomp if vomiting; analgesia", "Cancer: colectomy", "Volvulus: sigmoidoscopy (sigmoid)", " or surgery (cecal)", "Stricture: segmental resection", "Post-op: bowel function, fluids, pain", ]), ("STRANGULATED BOWEL \u26a0", [ "1 ABCDE, IV fluids, O2", "2 Broad-spectrum IV abx", "3 Emergency laparotomy", "4 Resect necrotic bowel;", " anastomosis or stoma", "5 Post-op: ICU, fluids, nutrition", ]), ] c = canvas.Canvas("/home/daytona/workspace/cheatsheet/Surgery_Management_CheatSheet.pdf", pagesize=A4) # ---------- layout constants ---------- MARGIN_L = 5*mm MARGIN_T = 5*mm MARGIN_B = 4*mm HEADER_H = 9*mm COLS = 5 GAP = 1.5*mm usable_w = W - 2*MARGIN_L usable_h = H - MARGIN_T - MARGIN_B - HEADER_H - 2*mm # space below header col_w = (usable_w - (COLS-1)*GAP) / COLS TITLE_H = 7.5 # pts (box header height) BODY_FS = 4.7 # body font size TITLE_FS = 5.5 # title font size LINE_H = 5.8 # pts per body line PAD_X = 2 # horizontal padding inside box PAD_Y_TOP = 1 # padding inside title PAD_Y_BOD = 1 # padding top of body CORNER = 1 # corner radius # ---------- draw page header ---------- c.setFillColor(BLUE_DARK) c.roundRect(MARGIN_L, H - MARGIN_T - HEADER_H, usable_w, HEADER_H, 2, fill=1, stroke=0) c.setFillColor(WHITE) c.setFont("Helvetica-Bold", 9) c.drawCentredString(W/2, H - MARGIN_T - HEADER_H + 3.5, "SURGERY SKIN \u2014 MANAGEMENT PLANS CHEAT SHEET") c.setFont("Helvetica", 6) c.drawCentredString(W/2, H - MARGIN_T - HEADER_H + 0.5 - 1, "All Blue Management Boxes | Exam Quick Reference") # ---------- helper: measure box height ---------- def box_height(steps): return TITLE_H + PAD_Y_BOD + len(steps)*LINE_H + PAD_Y_BOD # ---------- helper: draw one box ---------- def draw_box(cx, cy, bw, title, steps): """cx, cy = top-left corner. cy is y from bottom of page.""" bh = box_height(steps) # background c.setFillColor(GREY_BG) c.roundRect(cx, cy - bh, bw, bh, CORNER, fill=1, stroke=0) # title bar c.setFillColor(BLUE_MED) c.roundRect(cx, cy - TITLE_H, bw, TITLE_H, CORNER, fill=1, stroke=0) # cover bottom-rounded corners of title bar c.rect(cx, cy - TITLE_H, bw, CORNER, fill=1, stroke=0) # border c.setStrokeColor(BLUE_DARK) c.setLineWidth(0.4) c.roundRect(cx, cy - bh, bw, bh, CORNER, fill=0, stroke=1) # title text c.setFillColor(WHITE) c.setFont("Helvetica-Bold", TITLE_FS) c.drawCentredString(cx + bw/2, cy - TITLE_H + PAD_Y_TOP + 1.2, title) # body lines c.setFillColor(BLACK) c.setFont("Helvetica", BODY_FS) y_text = cy - TITLE_H - PAD_Y_BOD - LINE_H + 1.5 for line in steps: c.drawString(cx + PAD_X, y_text, line) y_text -= LINE_H # ---------- distribute sections across columns greedily ---------- # First measure all boxes heights = [box_height(s[1]) for s in sections] total_h = sum(heights) + len(heights)*1.5 # 1.5pt gap between boxes # Target: fill COLS columns as evenly as possible target_col_h = usable_h col_assignments = [[] for _ in range(COLS)] col_used = [0.0]*COLS # Greedy: assign each section to the column with most remaining space that can fit it idx = 0 col_idx = 0 for i, (title, steps) in enumerate(sections): bh = heights[i] + 1.5 # try current col first, then overflow to next if col_used[col_idx] + bh > target_col_h + 5 and col_idx < COLS-1: col_idx += 1 col_assignments[col_idx].append(i) col_used[col_idx] += bh # ---------- draw all boxes ---------- start_y = H - MARGIN_T - HEADER_H - 2*mm # top of content area (y from bottom) BOX_GAP = 1.5 for ci, col in enumerate(col_assignments): cx = MARGIN_L + ci*(col_w + GAP) cy = start_y for idx in col: title, steps = sections[idx] bh = box_height(steps) draw_box(cx, cy, col_w, title, steps) cy -= (bh + BOX_GAP) c.save() print("PDF created successfully!") PYEOF python3 /home/daytona/workspace/cheatsheet/make_cheatsheet.py
python3 -c " from pypdf import PdfReader r = PdfReader('/home/daytona/workspace/cheatsheet/Surgery_Management_CheatSheet.pdf') print(f'Pages: {len(r.pages)}') print(f'Size: {r.pages[0].mediabox}') "
Surgery Management CheatSheet
PDF Document · PDF
Can you give differential diagnosis for each disease also
How would you like the differentials delivered?
cat > /home/daytona/workspace/cheatsheet/make_ddx.py << 'PYEOF' from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.units import mm W, H = A4 BLUE_DARK = colors.HexColor("#0D47A1") BLUE_MED = colors.HexColor("#1565C0") TEAL = colors.HexColor("#00695C") TEAL_LIGHT = colors.HexColor("#E0F2F1") RED_DARK = colors.HexColor("#B71C1C") RED_LIGHT = colors.HexColor("#FFEBEE") PURPLE = colors.HexColor("#4A148C") PURPLE_L = colors.HexColor("#F3E5F5") ORANGE = colors.HexColor("#E65100") ORANGE_L = colors.HexColor("#FFF3E0") GREY_BG = colors.HexColor("#F0F4FF") WHITE = colors.white BLACK = colors.black # category -> (header_color, bg_color) CAT_COLORS = { "skin": (BLUE_MED, GREY_BG), "burns": (RED_DARK, RED_LIGHT), "plastic": (TEAL, TEAL_LIGHT), "cardiac": (PURPLE, PURPLE_L), "thorax": (ORANGE, ORANGE_L), "arterial":(colors.HexColor("#1B5E20"), colors.HexColor("#E8F5E9")), "venous": (colors.HexColor("#006064"), colors.HexColor("#E0F7FA")), "esoph": (colors.HexColor("#4E342E"), colors.HexColor("#EFEBE9")), "stomach": (colors.HexColor("#880E4F"), colors.HexColor("#FCE4EC")), "small": (colors.HexColor("#1A237E"), colors.HexColor("#E8EAF6")), "colon": (colors.HexColor("#33691E"), colors.HexColor("#F1F8E9")), "appendix":(colors.HexColor("#37474F"), colors.HexColor("#ECEFF1")), } sections = [ # (title, category, [differentials]) ("ABSCESS", "skin", [ "Cellulitis (no fluctuation)", "Furuncle / Carbuncle", "Sebaceous cyst (non-infected)", "Lymphadenitis (node, not skin)", "Hidradenitis suppurativa", "Necrotizing fasciitis (deep, severe)", ]), ("CELLULITIS", "skin", [ "Abscess (has fluctuation)", "Deep vein thrombosis (DVT)", "Necrotizing fasciitis (pain out of proportion)", "Erysipelas (sharp demarcated edge)", "Contact dermatitis (no fever)", "Lipodermatosclerosis (chronic, hard)", ]), ("NECROTIZING FASCIITIS", "skin", [ "Severe cellulitis", "Deep abscess", "Myonecrosis (gas gangrene - Clostridium)", "Pyoderma gangrenosum", "Erysipelas", ]), ("SEBACEOUS CYST", "skin", [ "Lipoma (soft, no punctum)", "Abscess (tender, fluctuant)", "Lymph node (deeper, rubbery)", "Dermoid cyst", "Pilonidal sinus (natal cleft)", ]), ("LIPOMA", "skin", [ "Sebaceous cyst (has punctum)", "Lymphadenopathy", "Soft tissue sarcoma (hard, fixed)", "Abscess (tender, warm)", "Dermoid cyst", ]), ("PILONIDAL SINUS", "skin", [ "Perianal fistula", "Sacrococcygeal teratoma", "Anal fistula (higher up)", "Abscess (natal cleft)", "Hidradenitis suppurativa", ]), ("HIDRADENITIS SUPPURATIVA", "skin", [ "Furunculosis", "Cellulitis", "Lymphadenitis", "Crohn's disease (perianal fistulas)", "Abscess (recurrent)", ]), ("THERMAL BURNS", "burns", [ "Chemical burns (ongoing damage)", "Steven-Johnson syndrome", "Toxic epidermal necrolysis (TEN)", "Scalded skin syndrome (Staph)", "Purpura fulminans", ]), ("CHEMICAL BURNS", "burns", [ "Thermal burns", "Allergic contact dermatitis", "Steven-Johnson syndrome", "Caustic ingestion injury", "Irritant contact dermatitis", ]), ("ELECTRICAL BURNS", "burns", [ "Thermal burns (surface only)", "Rhabdomyolysis (other cause)", "Myocardial infarction (arrhythmia)", "Blast injury", "Lightning injury", ]), ("INHALATION INJURY", "burns", [ "Thermal airway burns", "Carbon monoxide poisoning", "Acute epiglottitis", "Anaphylaxis (airway edema)", "Foreign body inhalation", "Chemical pneumonitis", ]), ("NON-HEALING WOUNDS", "plastic", [ "Diabetic ulcer", "Venous ulcer (medial malleolus)", "Arterial ulcer (lateral, punched-out)", "Pressure ulcer", "Malignant ulcer (Marjolin's)", "Vasculitic ulcer", ]), ("POST-BURN CONTRACTURE", "plastic", [ "Keloid/hypertrophic scar", "Scleroderma (systemic sclerosis)", "Dupuytren's contracture (hand)", "Joint ankylosis (bony)", "Volkmann's ischemic contracture", ]), ("SKIN GRAFT (SKIN LOSS)", "plastic", [ "Skin defect from trauma", "Post-excision cancer defect", "Burn wound", "Decubitus / pressure ulcer", "Degloving injury", ]), ("CHRONIC ULCER", "plastic", [ "Venous stasis ulcer", "Diabetic/neuropathic ulcer", "Arterial insufficiency ulcer", "Pressure ulcer", "Malignant (Marjolin's) ulcer", "Vasculitic ulcer", ]), ("CABG", "cardiac", [ "Percutaneous coronary intervention (PCI)", "Medical management (stable CAD)", "Valvular disease mimicking angina", "Hypertrophic cardiomyopathy", "Aortic stenosis (exertional angina)", ]), ("VALVULAR HEART SURGERY", "cardiac", [ "Cardiomyopathy (dilated)", "Heart failure (non-valvular)", "Infective endocarditis", "Rheumatic heart disease", "Congenital valve defect", "Mitral valve prolapse", ]), ("AORTIC ANEURYSM", "cardiac", [ "Aortic dissection (acute pain)", "Retroperitoneal mass", "Pancreatitis (epigastric pain)", "Mesenteric ischemia", "Renal colic (back pain)", "Musculoskeletal back pain", ]), ("AORTIC DISSECTION", "cardiac", [ "Acute MI (also severe chest pain)", "Aortic aneurysm rupture", "Pulmonary embolism", "Pericarditis", "Esophageal rupture (Boerhaave)", "Pancreatitis (epigastric radiation)", ]), ("ASD", "cardiac", [ "VSD (pansystolic murmur)", "Pulmonary stenosis", "Innocent flow murmur", "Patent foramen ovale", "Partial anomalous pulm venous return", ]), ("VSD", "cardiac", [ "ASD (fixed split S2)", "Patent ductus arteriosus", "Mitral regurgitation (MR)", "Aortic stenosis", "Hypertrophic cardiomyopathy", ]), ("TETRALOGY OF FALLOT", "cardiac", [ "Transposition of great arteries", "Pulmonary atresia", "Tricuspid atresia", "Eisenmenger syndrome (late VSD/ASD)", "Total anomalous pulm venous return", ]), ("RHEUMATIC HEART DISEASE", "cardiac", [ "Infective endocarditis", "Congenital valve disease", "Degenerative valve disease", "Mitral valve prolapse", "Cardiomyopathy", ]), ("INFECTIVE ENDOCARDITIS", "cardiac", [ "Rheumatic fever (acute)", "Septicemia (no valve involvement)", "Atrial myxoma", "Marantic endocarditis (non-infectious)", "Vasculitis (embolic features)", ]), ("PNEUMOTHORAX", "thorax", [ "Pulmonary embolism", "Acute MI (pleuritic pain)", "Hemothorax", "Pleural effusion", "Pericarditis", "Musculoskeletal chest pain", ]), ("HEMOTHORAX", "thorax", [ "Pleural effusion (non-blood)", "Empyema", "Pneumothorax", "Chylothorax", "Pulmonary contusion", ]), ("PLEURAL EFFUSION", "thorax", [ "Pneumothorax", "Hemothorax", "Empyema", "Pulmonary collapse/consolidation", "Elevated hemidiaphragm", "Pleural thickening", ]), ("EMPYEMA", "thorax", [ "Complicated parapneumonic effusion", "Hemothorax", "Malignant effusion", "Chylothorax", "Subphrenic abscess", ]), ("LUNG CANCER", "thorax", [ "Pulmonary tuberculosis", "Lung abscess", "Pneumonia (consolidation on CXR)", "Pulmonary metastases", "Carcinoid tumor", "Mesothelioma (pleural)", ]), ("THORACIC AORTIC ANEURYSM", "thorax", [ "Aortic dissection", "Mediastinal mass (lymphoma)", "Esophageal mass", "Pericardial cyst", "Diaphragmatic hernia", ]), ("PAD", "arterial", [ "Venous claudication", "Spinal stenosis (neurogenic claudication)", "Musculoskeletal pain", "DVT (acute)", "Diabetic neuropathy", "Compartment syndrome (acute)", ]), ("ACUTE LIMB ISCHEMIA", "arterial", [ "DVT (venous, not arterial)", "Compartment syndrome", "Severe PAD (chronic)", "Phlegmasia cerulea dolens", "Aortic dissection (limb ischemia)", ]), ("CAROTID ARTERY DISEASE", "arterial", [ "Intracranial bleed (stroke)", "Cardiac embolism (AF)", "Small vessel disease", "Vertebrobasilar insufficiency", "Migraine with aura", "Todd's paresis (post-seizure)", ]), ("VARICOSE VEINS", "venous", [ "Chronic venous insufficiency", "DVT", "Lymphoedema", "Superficial thrombophlebitis", "Venous malformation", ]), ("DVT", "venous", [ "Cellulitis (superficial red leg)", "Muscle strain/tear", "Lymphoedema", "Ruptured Baker's cyst", "Acute limb ischemia (arterial)", "Superficial thrombophlebitis", ]), ("CHRONIC VENOUS INSUFFICIENCY", "venous", [ "Lymphoedema (non-pitting)", "Cardiac edema (bilateral, pitting)", "Renal edema (bilateral)", "Hypoalbuminemia", "Lipedema", "DVT (acute unilateral)", ]), ("LYMPHOEDEMA", "venous", [ "Chronic venous insufficiency", "Cardiac/renal/hepatic edema", "Hypoalbuminemia", "Lipedema (bilateral, painful)", "Filariasis (tropical)", "Myxedema (hypothyroidism)", ]), ("GERD", "esoph", [ "Peptic ulcer disease", "Esophageal cancer (dysphagia)", "Achalasia", "Cardiac chest pain (MI)", "Esophagitis (eosinophilic)", "Functional dyspepsia", ]), ("ACHALASIA", "esoph", [ "Esophageal cancer (secondary achalasia)", "GERD with stricture", "Diffuse esophageal spasm", "Chagas disease", "Hiatal hernia", "Eosinophilic esophagitis", ]), ("ESOPHAGEAL CANCER", "esoph", [ "Benign stricture (peptic)", "Achalasia", "Esophageal web (Plummer-Vinson)", "Extrinsic compression", "Eosinophilic esophagitis", "Diffuse esophageal spasm", ]), ("ESOPHAGEAL PERFORATION", "esoph", [ "Aortic dissection", "Acute MI", "Pulmonary embolism", "Perforated peptic ulcer", "Pancreatitis", "Spontaneous pneumomediastinum", ]), ("PEPTIC ULCER DISEASE", "stomach", [ "Gastric cancer", "GERD", "Functional dyspepsia", "Pancreatitis (epigastric pain)", "Biliary colic", "Gastric outlet obstruction", ]), ("GASTRIC CANCER", "stomach", [ "Peptic ulcer disease", "GERD / Barrett's esophagus", "Lymphoma of stomach", "GIST (gastrointestinal stromal tumor)", "Gastritis", "Pancreatic cancer (epigastric mass)", ]), ("GASTRIC OUTLET OBSTRUCTION", "stomach", [ "Peptic ulcer (chronic scarring)", "Gastric cancer", "Pyloric stenosis (infantile)", "Pancreatic cancer (extrinsic)", "Crohn's disease (duodenal)", "Bezoar", ]), ("GI PERFORATION", "stomach", [ "Acute pancreatitis", "Aortic dissection / rupture", "Mesenteric ischemia", "Ruptured ectopic pregnancy", "Acute cholecystitis", "Strangulated hernia", ]), ("SMALL BOWEL OBSTRUCTION", "small", [ "Large bowel obstruction", "Ileus (functional, no mechanical cause)", "Acute mesenteric ischemia", "Colonic pseudo-obstruction (Ogilvie's)", "Inflammatory bowel disease", "Perforated viscus", ]), ("CROHN'S DISEASE", "small", [ "Appendicitis (RLQ pain)", "Ulcerative colitis (UC)", "Irritable bowel syndrome (no bleeding)", "Intestinal TB", "Yersinia enteritis", "Lymphoma (intestinal)", ]), ("MECKEL'S DIVERTICULUM", "small", [ "Appendicitis (RLQ pain)", "Intussusception", "Juvenile polyp (rectal bleeding)", "Meckel's diverticulitis vs appendicitis", "Intestinal duplication", ]), ("ISCHEMIC BOWEL", "small", [ "Acute pancreatitis", "Small bowel obstruction", "Perforated viscus", "Aortic dissection", "Ruptured AAA", "Strangulated hernia", ]), ("COLORECTAL CANCER", "colon", [ "Diverticular disease (bleeding)", "Inflammatory bowel disease", "Hemorrhoids (rectal bleeding)", "Ischemic colitis", "Anal fissure", "Polyp (benign, but precancerous)", ]), ("DIVERTICULAR DISEASE", "colon", [ "Colorectal cancer (LLQ mass/bleeding)", "Irritable bowel syndrome", "Ischemic colitis", "Crohn's colitis", "Ovarian pathology (LLQ in females)", "Appendicitis (atypical/right-sided)", ]), ("HEMORRHOIDS", "colon", [ "Colorectal cancer (always exclude)", "Anal fissure (pain + bleeding)", "Anal fistula (discharge)", "Rectal prolapse", "IBD (proctitis)", "Condyloma acuminata", ]), ("ANAL FISSURE", "colon", [ "Hemorrhoids (painless in early stages)", "Anal cancer", "Crohn's disease (multiple/atypical fissures)", "Sexually transmitted infections", "Anal fistula", "Perianal abscess", ]), ("ANAL ABSCESS & FISTULA", "colon", [ "Hemorrhoids", "Pilonidal sinus", "Hidradenitis suppurativa", "Crohn's perianal disease", "Anal cancer", "Bartholin's cyst (females)", ]), ("ACUTE APPENDICITIS", "appendix", [ "Mesenteric adenitis (children)", "Ovarian cyst/torsion (females)", "Ectopic pregnancy (females)", "Meckel's diverticulitis", "Crohn's disease (terminal ileum)", "Right-sided ureteric colic", "Psoas abscess", ]), ("LARGE BOWEL OBSTRUCTION", "appendix", [ "Small bowel obstruction", "Colonic pseudo-obstruction (Ogilvie's)", "Toxic megacolon (IBD)", "Paralytic ileus", "Ischemic colitis", ]), ("STRANGULATED BOWEL", "appendix", [ "Perforated viscus", "Acute mesenteric ischemia", "Acute pancreatitis", "Closed-loop SBO", "Volvulus with ischemia", ]), ] # ---- LAYOUT ---- c = canvas.Canvas("/home/daytona/workspace/cheatsheet/Surgery_DDx_CheatSheet.pdf", pagesize=A4) MARGIN_L = 5*mm MARGIN_T = 5*mm MARGIN_B = 4*mm HEADER_H = 9*mm COLS = 5 GAP = 1.5*mm usable_w = W - 2*MARGIN_L usable_h = H - MARGIN_T - MARGIN_B - HEADER_H - 2*mm col_w = (usable_w - (COLS-1)*GAP) / COLS TITLE_H = 7.5 BODY_FS = 4.6 TITLE_FS = 5.4 LINE_H = 5.6 PAD_X = 2 PAD_Y = 1 CORNER = 1 BOX_GAP = 1.5 def box_height(ddx): return TITLE_H + PAD_Y + len(ddx)*LINE_H + PAD_Y def draw_box(cx, cy, bw, title, ddx, hdr_col, bg_col): bh = box_height(ddx) # background c.setFillColor(bg_col) c.roundRect(cx, cy - bh, bw, bh, CORNER, fill=1, stroke=0) # title bar c.setFillColor(hdr_col) c.roundRect(cx, cy - TITLE_H, bw, TITLE_H, CORNER, fill=1, stroke=0) c.rect(cx, cy - TITLE_H, bw, CORNER, fill=1, stroke=0) # border c.setStrokeColor(hdr_col) c.setLineWidth(0.4) c.roundRect(cx, cy - bh, bw, bh, CORNER, fill=0, stroke=1) # title c.setFillColor(WHITE) c.setFont("Helvetica-Bold", TITLE_FS) c.drawCentredString(cx + bw/2, cy - TITLE_H + PAD_Y + 1.2, title) # ddx lines c.setFillColor(BLACK) c.setFont("Helvetica", BODY_FS) y_text = cy - TITLE_H - PAD_Y - LINE_H + 1.5 for line in ddx: c.drawString(cx + PAD_X, y_text, f"\u2022 {line}") y_text -= LINE_H # page header c.setFillColor(BLUE_DARK) c.roundRect(MARGIN_L, H - MARGIN_T - HEADER_H, usable_w, HEADER_H, 2, fill=1, stroke=0) c.setFillColor(WHITE) c.setFont("Helvetica-Bold", 9) c.drawCentredString(W/2, H - MARGIN_T - HEADER_H + 3.5, "SURGERY SKIN \u2014 DIFFERENTIAL DIAGNOSES CHEAT SHEET") c.setFont("Helvetica", 6) c.drawCentredString(W/2, H - MARGIN_T - HEADER_H + 0.5 - 1, "All 50 Conditions with Key Differentials | Exam Quick Reference") # assign to columns heights = [box_height(s[2]) for s in sections] target_col_h = usable_h col_assignments = [[] for _ in range(COLS)] col_used = [0.0]*COLS col_idx = 0 for i, (title, cat, ddx) in enumerate(sections): bh = heights[i] + BOX_GAP if col_used[col_idx] + bh > target_col_h + 5 and col_idx < COLS-1: col_idx += 1 col_assignments[col_idx].append(i) col_used[col_idx] += bh start_y = H - MARGIN_T - HEADER_H - 2*mm for ci, col in enumerate(col_assignments): cx = MARGIN_L + ci*(col_w + GAP) cy = start_y for idx in col: title, cat, ddx = sections[idx] hdr_col, bg_col = CAT_COLORS[cat] bh = box_height(ddx) draw_box(cx, cy, col_w, title, ddx, hdr_col, bg_col) cy -= (bh + BOX_GAP) # category legend legend_items = [ ("Skin/Soft Tissue", CAT_COLORS["skin"][0]), ("Burns", CAT_COLORS["burns"][0]), ("Plastic/Recon", CAT_COLORS["plastic"][0]), ("Cardiac", CAT_COLORS["cardiac"][0]), ("Thorax", CAT_COLORS["thorax"][0]), ("Arterial", CAT_COLORS["arterial"][0]), ("Venous/Lymph", CAT_COLORS["venous"][0]), ("Esophagus", CAT_COLORS["esoph"][0]), ("Stomach/Duod", CAT_COLORS["stomach"][0]), ("Small Bowel", CAT_COLORS["small"][0]), ("Colon/Rectum", CAT_COLORS["colon"][0]), ("Appendix/Bowel", CAT_COLORS["appendix"][0]), ] lx = MARGIN_L ly = MARGIN_B + 0.5*mm c.setFont("Helvetica-Bold", 4.2) c.setFillColor(colors.HexColor("#333333")) c.drawString(lx, ly + 2, "COLOR KEY:") lx += 18*mm for label, col in legend_items: c.setFillColor(col) c.rect(lx, ly, 4, 5, fill=1, stroke=0) c.setFillColor(BLACK) c.setFont("Helvetica", 4.0) c.drawString(lx + 5, ly + 1, label) lx += len(label)*2.5 + 10 c.save() print("DDx PDF created!") PYEOF python3 /home/daytona/workspace/cheatsheet/make_ddx.py
python3 -c " from pypdf import PdfReader r = PdfReader('/home/daytona/workspace/cheatsheet/Surgery_DDx_CheatSheet.pdf') print(f'Pages: {len(r.pages)}') "
Surgery DDx CheatSheet
PDF Document · PDF
Any tricks for differential diagnosis
"Same symptom, different mechanism" - Always think: Infection? Vascular? Neoplasm? Congenital? Autoimmune? Trauma?
| Condition | The ONE differentiator |
|---|---|
| Abscess | FLUCTUATION (pus) |
| Cellulitis | Diffuse, no pus, no sharp edge |
| Erysipelas | SHARP raised demarcated edge |
| NF | Pain OUT OF PROPORTION + crepitus |
| DVT | No warmth/redness at skin, limb swollen |
Pain out of proportion to exam findings = VASCULAR until proven otherwise
| Pattern | Likely diagnosis |
|---|---|
| Solids THEN liquids (progressive) | Mechanical = Cancer |
| Solids AND liquids from start | Motility = Achalasia |
| Intermittent, heartburn | GERD / stricture |
| Young + iron deficiency | Plummer-Vinson (web) |
| Feature | Diagnosis |
|---|---|
| Bright red, PAINLESS | Hemorrhoids #1 |
| Bright red + SEVERE PAIN on defecation | Anal fissure |
| Dark/mixed + weight loss + age >50 | Colorectal cancer |
| Bloody diarrhea + crampy pain | IBD (Crohn's/UC) |
| Painless in child | Meckel's diverticulum |
| Massive fresh bleeding + LLQ pain | Diverticular bleed |
| SBO | LBO | |
|---|---|---|
| Cause #1 | Adhesions | Cancer |
| Vomiting | Early + bilious | Late |
| Distension | Central | Peripheral/frame |
| X-ray sign | Air-fluid levels centrally | Coffee-bean (volvulus) |
| Murmur | Condition |
|---|---|
| Fixed split S2 | ASD |
| Pansystolic at LLSB | VSD |
| Ejection systolic at LUSB | Pulmonary stenosis or ASD |
| Continuous "machinery" murmur | Patent ductus arteriosus (PDA) |
| Diastolic, opening snap | Mitral stenosis (rheumatic) |
| Boot-shaped heart on CXR | Tetralogy of Fallot |
| Feature | Acute Arterial (ALI) | DVT (Venous) | PAD (Chronic) |
|---|---|---|---|
| Speed | Sudden (minutes) | Hours-days | Weeks-months |
| Pulses | ABSENT | Present | Reduced |
| Skin | White/pale | Red/blue, warm | Pale, cold |
| Pain | Severe at rest | Aching/heaviness | Only on walking |
| Key test | Doppler (no flow) | Doppler (thrombus) | ABI <0.9 |
| One leg | Both legs | |
|---|---|---|
| Pitting | DVT | Cardiac / Renal / Hepatic / Hypoalbuminemia |
| Non-pitting | Lymphoedema | Bilateral lymphoedema / Myxedema |
| Varicose veins | Dilated tortuous visible veins | - |
"Common things commonly, dangerous things always"
Can you make 1 page cheat sheet for disease definition and patient Education
cat > /home/daytona/workspace/cheatsheet/make_def_edu.py << 'PYEOF' from reportlab.pdfgen import canvas from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.units import mm W, H = A4 # Color palette - two-tone per system BLUE_DARK = colors.HexColor("#0D47A1") BLUE_MED = colors.HexColor("#1565C0") BLUE_LIGHT = colors.HexColor("#E3F2FD") # System header colors (same as DDx sheet for consistency) CAT_COLORS = { "skin": (colors.HexColor("#1565C0"), colors.HexColor("#E3F2FD")), "burns": (colors.HexColor("#B71C1C"), colors.HexColor("#FFEBEE")), "plastic": (colors.HexColor("#00695C"), colors.HexColor("#E0F2F1")), "cardiac": (colors.HexColor("#4A148C"), colors.HexColor("#F3E5F5")), "thorax": (colors.HexColor("#E65100"), colors.HexColor("#FFF3E0")), "arterial":(colors.HexColor("#1B5E20"), colors.HexColor("#E8F5E9")), "venous": (colors.HexColor("#006064"), colors.HexColor("#E0F7FA")), "esoph": (colors.HexColor("#4E342E"), colors.HexColor("#EFEBE9")), "stomach": (colors.HexColor("#880E4F"), colors.HexColor("#FCE4EC")), "small": (colors.HexColor("#1A237E"), colors.HexColor("#E8EAF6")), "colon": (colors.HexColor("#33691E"), colors.HexColor("#F1F8E9")), "appendix":(colors.HexColor("#37474F"), colors.HexColor("#ECEFF1")), } EDU_COLOR = colors.HexColor("#F9A825") # amber for patient ed label WHITE = colors.white BLACK = colors.black DARK_GREY = colors.HexColor("#212121") # Each entry: (title, category, definition_1_liner, [patient_ed_bullets]) sections = [ ("ABSCESS", "skin", "Localized pus collection in skin/subcutaneous tissue (Staph aureus #1).", ["Wound needs drainage to heal", "Keep wound clean & dry", "Return if: fever, worsening redness"]), ("CELLULITIS", "skin", "Diffuse bacterial skin/SC infection WITHOUT pus (Strep pyogenes, Staph aureus).", ["Complete full antibiotic course", "Elevate affected limb", "Return if spreading redness or fever"]), ("NECROTIZING FASCIITIS", "skin", "Rapidly progressive life-threatening fascia/SC infection. SURGICAL EMERGENCY.", ["Life-threatening - surgery is urgent", "Multiple operations may be needed", "Long ICU & rehab recovery expected"]), ("SEBACEOUS CYST", "skin", "Benign cyst from blocked sebaceous gland; contains keratin.", ["Benign - no treatment if asymptomatic", "Do NOT squeeze - risk of infection", "See doctor if red, painful or growing"]), ("LIPOMA", "skin", "Benign tumor of adipose tissue; soft, mobile, non-tender.", ["Harmless fatty lump", "Excision only if painful/cosmetic", "No risk of cancer"]), ("PILONIDAL SINUS", "skin", "Chronic sinus in natal cleft containing hair; recurrent infection.", ["Keep area clean; remove hair", "High risk of recurrence", "Surgery may be needed for cure"]), ("HIDRADENITIS SUPPURATIVA", "skin", "Chronic inflammatory disease of apocrine sweat glands (axilla, groin).", ["Chronic condition - long-term mgmt", "Avoid tight clothing; lose weight", "Early treatment prevents scarring"]), ("THERMAL BURNS", "burns", "Tissue injury from heat (flame, scalds, contact). Classified by depth & %TBSA.", ["Long healing time; scarring possible", "Keep wound clean; watch for infection", "Parkland fluids critical in first 24h"]), ("CHEMICAL BURNS", "burns", "Burns from acids/alkalis; alkalis more dangerous (liquefactive necrosis).", ["Wash with water immediately at scene", "Do NOT try to neutralize chemical", "Delayed complications possible"]), ("ELECTRICAL BURNS", "burns", "Burns with small skin entry/exit but deep internal muscle/nerve damage.", ["Internal injury worse than surface", "Heart monitoring needed (arrhythmias)", "Muscle damage can cause kidney failure"]), ("INHALATION INJURY", "burns", "Airway/lung damage from smoke or superheated air in enclosed fire.", ["Airway can swell hours after injury", "Report worsening hoarseness/breathing", "Close monitoring in hospital needed"]), ("NON-HEALING WOUNDS", "plastic", "Wound failing to progress through normal healing stages over 4-6 weeks.", ["Clean wound daily as instructed", "Watch for: pus, redness, smell", "Control blood sugar & nutrition"]), ("POST-BURN CONTRACTURE", "plastic", "Skin tightening after burns causing restricted joint movement.", ["Physiotherapy is essential daily", "Risk of recurrence after surgery", "Splints/compression garments help"]), ("SKIN GRAFT", "plastic", "Surgical transfer of skin to cover wound (STSG=large area; FTSG=delicate area).", ["Protect graft site from trauma", "Both donor & recipient sites need care", "Report signs of infection early"]), ("CHRONIC ULCER", "plastic", "Ulcer >6 weeks unresponsive to standard care; venous/diabetic/pressure causes.", ["Daily wound hygiene mandatory", "Offload pressure; control blood sugar", "Regular follow-up for healing check"]), ("CABG", "cardiac", "Bypass of blocked coronary arteries using IMA/saphenous vein grafts.", ["Surgery improves blood flow to heart", "Recovery: ICU then ward then home", "Lifestyle change: diet, exercise, no smoking"]), ("VALVULAR SURGERY", "cardiac", "Repair or replacement of diseased heart valve (rheumatic/degenerative).", ["Mechanical valve = lifelong warfarin", "Report fever, swelling, breathlessness", "Dental prophylaxis before procedures"]), ("AORTIC ANEURYSM", "cardiac", "Localized aortic dilation >50% normal diameter; rupture = life-threatening.", ["Strict BP control at home", "No strenuous activity until cleared", "Sudden chest/back pain = call emergency"]), ("AORTIC DISSECTION", "cardiac", "Tear in aortic intima creating false lumen. Type A=ascending=surgery; Type B=medical.", ["Sudden severe chest/back pain = 999", "BP medication must not be missed", "Long-term imaging follow-up needed"]), ("ASD", "cardiac", "Hole in interatrial septum causing left-to-right shunt; fixed split S2.", ["Explain defect & closure procedure", "Recovery timeline: days-weeks", "Follow-up echo to confirm closure"]), ("VSD", "cardiac", "Hole in interventricular septum; harsh pansystolic murmur at LLSB.", ["Small VSDs may close on their own", "Watch for: poor feeding, breathlessness", "Medication adherence important"]), ("TETRALOGY OF FALLOT", "cardiac", "4 defects: VSD + pulmonary stenosis + overriding aorta + RVH. Cyanotic CHD.", ["Squatting relieves cyanotic spells", "Surgery in infancy is curative", "Lifelong cardiology follow-up needed"]), ("RHEUMATIC HEART DISEASE", "cardiac", "Valve damage from autoimmune response to Group A Strep throat infection.", ["Penicillin prophylaxis for years", "Recognise breathlessness/palpitations", "Dental hygiene prevents endocarditis"]), ("INFECTIVE ENDOCARDITIS", "cardiac", "Infection of endocardium/valves; vegetations. Staph aureus, Strep viridans.", ["Complete full IV then oral antibiotics", "Report: fever, joint pain, dark spots", "Avoid IV drug use; dental hygiene"]), ("PNEUMOTHORAX", "thorax", "Air in pleural space causing lung collapse; spontaneous or traumatic.", ["Avoid smoking - main risk factor", "Recognise: sudden chest pain + breathlessness", "Avoid flying until fully resolved"]), ("HEMOTHORAX", "thorax", "Blood in pleural space, usually from trauma; chest drain required.", ["Report: breathlessness, dizziness", "Follow-up imaging after discharge", "Avoid contact sport until cleared"]), ("PLEURAL EFFUSION", "thorax", "Fluid in pleural space; transudate (HF) vs exudate (infection/malignancy).", ["Treat underlying disease (HF, infection)", "Report: worsening breathlessness", "Follow-up appointment essential"]), ("EMPYEMA", "thorax", "Pus in pleural space; complication of pneumonia or thoracic surgery.", ["Complete antibiotics course fully", "Monitor wound / drain site", "Follow-up CXR after treatment"]), ("LUNG CANCER", "thorax", "Malignant lung tumor; SCC (smoking) or adenocarcinoma. Cough + hemoptysis.", ["Smoking cessation is critical", "Follow-up imaging & rehab needed", "Pulmonary rehab improves recovery"]), ("THORACIC AORTIC ANEURYSM", "thorax", "Dilation of thoracic aorta >50% normal; widened mediastinum on CXR.", ["Strict BP control essential", "Sudden chest/back pain = emergency", "Lifestyle: stop smoking, light exercise"]), ("PAD", "arterial", "Chronic arterial obstruction (atherosclerosis) reducing blood flow to limbs. ABI <0.9.", ["Supervised walking program helps", "Foot care daily - check for ulcers", "Antiplatelets & statins every day"]), ("ACUTE LIMB ISCHEMIA", "arterial", "Sudden arterial occlusion; 6Ps: Pain, Pallor, Pulseless, Paresthesia, Paralysis, Poikilothermia.", ["Recognise 6Ps - present IMMEDIATELY", "Delay causes permanent limb loss", "Anticoagulation after procedure"]), ("CAROTID ARTERY DISEASE", "arterial", "Atherosclerotic carotid narrowing; TIA/stroke risk. Carotid bruit may be heard.", ["FAST symptoms = call emergency", "Never stop antiplatelets suddenly", "Control BP, diabetes, cholesterol"]), ("VARICOSE VEINS", "venous", "Dilated tortuous superficial veins; venous valve incompetence, saphenofemoral junction.", ["Avoid prolonged standing/sitting", "Wear compression stockings daily", "Recognise DVT signs after procedure"]), ("DVT", "venous", "Thrombus in deep veins (Virchow's triad: stasis, hypercoagulability, endothelial injury).", ["Take anticoagulants as prescribed", "Mobilise early; stay hydrated", "Sudden breathlessness = PE - call 999"]), ("CHRONIC VENOUS INSUFFICIENCY", "venous", "Venous valve failure causing hypertension, stasis, skin changes, venous ulcers.", ["Elevate legs daily", "Wear compression stockings", "Wound care for ulcers; report infection"]), ("LYMPHOEDEMA", "venous", "Chronic limb swelling from impaired lymphatic drainage; non-pitting edema.", ["Daily limb hygiene & skin care", "Compression therapy every day", "Report cellulitis immediately"]), ("GERD", "esoph", "Retrograde gastric contents into esophagus; LES incompetence/hiatal hernia.", ["Avoid late meals, caffeine, alcohol", "Elevate head of bed", "Alarm symptoms: dysphagia, weight loss"]), ("ACHALASIA", "esoph", "Failed LES relaxation + absent peristalsis; 'bird-beak' on barium swallow.", ["Small frequent meals; sit upright after", "Report weight loss or aspiration", "May need repeat procedures"]), ("ESOPHAGEAL CANCER", "esoph", "Malignant esophageal tumor; SCC (smoking/alcohol) or adenocarcinoma (Barrett's/GERD).", ["Early dysphagia reporting saves lives", "Nutritional support post-surgery", "Stop smoking & alcohol completely"]), ("ESOPHAGEAL PERFORATION", "esoph", "Full-thickness esophageal tear -> mediastinitis. Boerhaave = post-vomiting rupture.", ["Severe chest pain after vomiting = ER", "Nil by mouth until instructed", "Complete antibiotics & follow-up"]), ("PEPTIC ULCER DISEASE", "stomach", "Mucosal defect in stomach/duodenum; H.pylori #1 cause, then NSAIDs.", ["Complete H.pylori triple therapy", "Avoid NSAIDs, alcohol, smoking", "Return if: black stools, vomiting blood"]), ("GASTRIC CANCER", "stomach", "Gastric adenocarcinoma #1; H.pylori, chronic gastritis, smoked/salty foods.", ["Early: weight loss + pain = see doctor", "Nutrition advice post-gastrectomy", "Regular follow-up for recurrence"]), ("GASTRIC OUTLET OBSTRUCTION", "stomach", "Pyloric/duodenal obstruction; vomiting of undigested food, metabolic alkalosis.", ["Report persistent vomiting urgently", "Dietary modifications post-surgery", "Rehydration & electrolyte correction"]), ("GI PERFORATION", "stomach", "Full-thickness stomach/duodenum defect -> peritonitis. Free air under diaphragm.", ["Sudden severe epigastric pain = emergency", "Avoid NSAIDs and smoking", "Medication adherence after surgery"]), ("SMALL BOWEL OBSTRUCTION", "small", "Mechanical/functional SBO; adhesions #1. Dilated loops + air-fluid levels on AXR.", ["Recognise: vomiting + distension + no stool", "Present early to avoid strangulation", "Report recurrent symptoms after surgery"]), ("CROHN'S DISEASE", "small", "Chronic transmural IBD; any GI segment, skip lesions, granulomas. Terminal ileum #1.", ["Medication adherence prevents flares", "Smoking worsens Crohn's - must stop", "Nutritional support & monitoring"]), ("MECKEL'S DIVERTICULUM", "small", "Congenital true diverticulum distal ileum (vitelline duct remnant). Rule of 2s.", ["Painless rectal bleeding in child = ER", "Surgery is curative", "Follow-up after bowel surgery"]), ("ISCHEMIC BOWEL", "small", "Reduced SMA/SMV blood flow -> infarction. Pain OUT OF PROPORTION to exam.", ["Severe sudden abdominal pain = 999", "Anticoagulation if AF-related embolism", "Long recovery; nutritional support"]), ("COLORECTAL CANCER", "colon", "Adenocarcinoma of colon/rectum; FAP, Lynch syndrome. CEA as tumor marker.", ["Change in bowel habit/bleeding = see GP", "High-fiber diet; regular exercise", "Colonoscopy surveillance lifelong"]), ("DIVERTICULAR DISEASE", "colon", "Colonic wall outpouchings; low fiber diet, age >50. Diverticulitis = inflamed.", ["High-fiber diet prevents recurrence", "Fever + LLQ pain = present to hospital", "Follow-up colonoscopy after acute episode"]), ("HEMORRHOIDS", "colon", "Dilated rectal/anal veins; internal (above dentate) or external (below dentate).", ["High-fiber diet + hydration", "Avoid straining on toilet", "Rectal bleeding always needs evaluation"]), ("ANAL FISSURE", "colon", "Linear tear in anoderm distal to dentate line; hard stools, sphincter spasm.", ["Soft stools: drink water, eat fiber", "Avoid straining", "Persistent pain = see doctor"]), ("ANAL ABSCESS & FISTULA", "colon", "Abscess: pus in anal gland. Fistula: chronic tract to perianal skin.", ["Keep area clean; sitz baths", "Present early for recurrent abscess", "Post-op wound care is essential"]), ("ACUTE APPENDICITIS", "appendix", "Appendix lumen obstruction -> inflammation -> perforation. Fecalith #1. McBurney point.", ["Periumbilical -> RLQ pain = hospital now", "Nil by mouth if surgery likely", "Wound care + mobilise post-op"]), ("LARGE BOWEL OBSTRUCTION", "appendix", "Mechanical LBO; colorectal cancer #1 in adults. Coffee-bean sign = volvulus.", ["Severe distension + no stool = ER", "Post-op bowel and stoma care", "Follow-up colonoscopy for cancer"]), ("STRANGULATED BOWEL", "appendix", "Bowel obstruction + compromised blood supply -> necrosis -> peritonitis/sepsis.", ["Severe abdominal pain + vomiting = 999", "May need stoma post-surgery", "Long recovery; nutritional support"]), ] # ---- LAYOUT ---- c = canvas.Canvas("/home/daytona/workspace/cheatsheet/Surgery_Def_PatientEd_CheatSheet.pdf", pagesize=A4) MARGIN_L = 5*mm MARGIN_T = 5*mm MARGIN_B = 5*mm HEADER_H = 9*mm COLS = 5 GAP = 1.5*mm usable_w = W - 2*MARGIN_L usable_h = H - MARGIN_T - MARGIN_B - HEADER_H - 2*mm col_w = (usable_w - (COLS-1)*GAP) / COLS TITLE_H = 7.0 # title bar DEF_FS = 4.5 # definition font EDU_FS = 4.3 # patient ed font TITLE_FS = 5.3 LINE_H = 5.4 DEF_LABEL_H = 5.2 # height for "DEF" label line EDU_LABEL_H = 5.2 PAD_X = 2 PAD_T = 1.0 CORNER = 1 BOX_GAP = 1.5 def box_height(defn, edu_items): # Title + def line + separator + edu items def_lines = len(wrap_text(defn, col_w - PAD_X*2 - 2, DEF_FS)) return TITLE_H + PAD_T + DEF_LABEL_H + def_lines*LINE_H + 2 + EDU_LABEL_H + len(edu_items)*LINE_H + PAD_T def wrap_text(text, max_w, fs): """Rough word-wrap: estimate chars per line.""" chars_per_line = int(max_w / (fs * 0.52)) words = text.split() lines = [] current = "" for w in words: if len(current) + len(w) + 1 <= chars_per_line: current = (current + " " + w).strip() else: if current: lines.append(current) current = w if current: lines.append(current) return lines if lines else [""] def draw_box(cx, cy, bw, title, cat, defn, edu_items): hdr_col, bg_col = CAT_COLORS[cat] bh = box_height(defn, edu_items) # Background c.setFillColor(bg_col) c.roundRect(cx, cy - bh, bw, bh, CORNER, fill=1, stroke=0) # Title bar c.setFillColor(hdr_col) c.roundRect(cx, cy - TITLE_H, bw, TITLE_H, CORNER, fill=1, stroke=0) c.rect(cx, cy - TITLE_H, bw, CORNER, fill=1, stroke=0) # cover bottom curve # Border c.setStrokeColor(hdr_col) c.setLineWidth(0.4) c.roundRect(cx, cy - bh, bw, bh, CORNER, fill=0, stroke=1) # Title text c.setFillColor(WHITE) c.setFont("Helvetica-Bold", TITLE_FS) c.drawCentredString(cx + bw/2, cy - TITLE_H + PAD_T + 1.0, title) y = cy - TITLE_H - PAD_T # "DEF" label c.setFillColor(hdr_col) c.setFont("Helvetica-Bold", 4.0) c.drawString(cx + PAD_X, y - DEF_LABEL_H + 2.2, "DEF:") c.setFillColor(BLACK) c.setFont("Helvetica", DEF_FS) y -= DEF_LABEL_H def_lines = wrap_text(defn, bw - PAD_X*2 - 10, DEF_FS) for line in def_lines: c.drawString(cx + PAD_X + 9, y, line) y -= LINE_H # Separator line y -= 1 c.setStrokeColor(hdr_col) c.setLineWidth(0.3) c.line(cx + PAD_X, y, cx + bw - PAD_X, y) y -= 1.5 # "PT ED" label c.setFillColor(EDU_COLOR) c.setFont("Helvetica-Bold", 4.0) c.drawString(cx + PAD_X, y - EDU_LABEL_H + 2.2, "PT ED:") c.setFillColor(DARK_GREY) c.setFont("Helvetica", EDU_FS) y -= EDU_LABEL_H for item in edu_items: c.drawString(cx + PAD_X + 10, y, f"\u2022 {item}") y -= LINE_H # ---- Page header ---- c.setFillColor(BLUE_DARK) c.roundRect(MARGIN_L, H - MARGIN_T - HEADER_H, usable_w, HEADER_H, 2, fill=1, stroke=0) c.setFillColor(WHITE) c.setFont("Helvetica-Bold", 9) c.drawCentredString(W/2, H - MARGIN_T - HEADER_H + 3.5, "SURGERY SKIN \u2014 DEFINITIONS & PATIENT EDUCATION CHEAT SHEET") c.setFont("Helvetica", 5.8) c.drawCentredString(W/2, H - MARGIN_T - HEADER_H - 0.5, "DEF = one-line definition | PT ED = key points to tell the patient | All 50 conditions") # ---- Measure & assign to columns ---- heights = [box_height(s[3], s[4]) for s in sections] target_col_h = usable_h col_assignments = [[] for _ in range(COLS)] col_used = [0.0]*COLS col_idx = 0 for i, entry in enumerate(sections): bh = heights[i] + BOX_GAP if col_used[col_idx] + bh > target_col_h + 6 and col_idx < COLS-1: col_idx += 1 col_assignments[col_idx].append(i) col_used[col_idx] += bh # ---- Draw boxes ---- start_y = H - MARGIN_T - HEADER_H - 2*mm for ci, col in enumerate(col_assignments): cx = MARGIN_L + ci*(col_w + GAP) cy = start_y for idx in col: title, cat, defn, edu_items = sections[idx] bh = box_height(defn, edu_items) draw_box(cx, cy, col_w, title, cat, defn, edu_items) cy -= (bh + BOX_GAP) # ---- Legend ---- legend_items = [ ("Skin/ST", CAT_COLORS["skin"][0]), ("Burns", CAT_COLORS["burns"][0]), ("Plastic", CAT_COLORS["plastic"][0]), ("Cardiac", CAT_COLORS["cardiac"][0]), ("Thorax", CAT_COLORS["thorax"][0]), ("Arterial", CAT_COLORS["arterial"][0]), ("Venous/Lymph", CAT_COLORS["venous"][0]), ("Esophagus", CAT_COLORS["esoph"][0]), ("Stomach", CAT_COLORS["stomach"][0]), ("Small Bowel", CAT_COLORS["small"][0]), ("Colon/Rectum", CAT_COLORS["colon"][0]), ("Appendix/Bowel", CAT_COLORS["appendix"][0]), ] lx = MARGIN_L ly = MARGIN_B - 2 c.setFont("Helvetica-Bold", 4.0) c.setFillColor(colors.HexColor("#333333")) c.drawString(lx, ly + 2, "COLORS:") lx += 14*mm for label, col in legend_items: c.setFillColor(col) c.rect(lx, ly, 4, 4.5, fill=1, stroke=0) c.setFillColor(BLACK) c.setFont("Helvetica", 3.8) c.drawString(lx + 5.5, ly + 0.8, label) lx += len(label)*2.35 + 9 c.save() print("Done!") PYEOF python3 /home/daytona/workspace/cheatsheet/make_def_edu.py
cd /home/daytona/workspace/cheatsheet && python3 -c " import ast, sys with open('make_def_edu.py') as f: src = f.read() # find sections list and count items start = src.index('sections = [') # check a few entries quickly lines = src.split('\n') # find lines with tuple entries that might be 3-element vs 4-element for i,l in enumerate(lines): if l.strip().startswith('(\"') and '\"skin\"' not in l and '\"burns\"' not in l and '\"plastic\"' not in l and '\"cardiac\"' not in l and '\"thorax\"' not in l and '\"arterial\"' not in l and '\"venous\"' not in l and '\"esoph\"' not in l and '\"stomach\"' not in l and '\"small\"' not in l and '\"colon\"' not in l and '\"appendix\"' not in l: print(i+1, repr(l[:80])) " 2>&1 | head -30
cd /home/daytona/workspace/cheatsheet && python3 -c " with open('make_def_edu.py') as f: src = f.read() # Extract sections list as text and eval it safely import re # find sections block m = re.search(r'sections = \[(.+?)\]\n\n', src, re.DOTALL) if m: try: sections = eval('[' + m.group(1) + ']') print(f'Total sections: {len(sections)}') for i,s in enumerate(sections): print(f'{i}: len={len(s)} title={s[0]}') except Exception as e: print('eval error:', e) else: print('no match') " 2>&1 | head -60
s[4] but the list only goes to s[3]. The sections are correct. The bug is in the draw/height call. Let me fix it:cd /home/daytona/workspace/cheatsheet && sed -i 's/heights = \[box_height(s\[3\], s\[4\]) for s in sections\]/heights = [box_height(s[2], s[3]) for s in sections]/' make_def_edu.py sed -i 's/title, cat, defn, edu_items = sections\[idx\]/title, cat, defn, edu_items = sections[idx]/' make_def_edu.py # also fix the other unpacking line grep -n "s\[3\]\|s\[4\]" make_def_edu.py
~/cheatsheet/make_def_edu.py
Successfully replaced 1 instance(s) of the string in '/home/daytona/workspace/cheatsheet/make_def_edu.py'
python3 /home/daytona/workspace/cheatsheet/make_def_edu.py && python3 -c " from pypdf import PdfReader r = PdfReader('/home/daytona/workspace/cheatsheet/Surgery_Def_PatientEd_CheatSheet.pdf') print(f'Pages: {len(r.pages)}') "
Surgery Def PatientEd CheatSheet
PDF Document · PDF