Make a one-page PDF for clinical features and management of anaphylactic shock. Referring from Harrison's Textbook of Medicine.
anaphylaxis AND management
2023 anaphylaxis practice parameter update management epinephrine emergency guidelines
~/
https://www.aaaai.org/Aaaai/media/Media-Library-PDFs/Allergi…
mkdir -p "/tmp/workspace/anaphylactic-shock-pdf/src" "/tmp/workspace/anaphylactic-shock-pdf/output" && python - <<'PY' from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.enums import TA_CENTER, TA_LEFT from reportlab.lib.units import mm from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle, KeepTogether from reportlab.pdfbase.ttfonts import TTFont from reportlab.pdfbase import pdfmetrics from reportlab.lib.colors import HexColor from pypdf import PdfReader from pathlib import Path out=Path('/tmp/workspace/anaphylactic-shock-pdf/output/anaphylactic_shock_one_page.pdf') # Fonts font='/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf' bold='/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf' pdfmetrics.registerFont(TTFont('DejaVu',font)) pdfmetrics.registerFont(TTFont('DejaVu-Bold',bold)) PAGE_W, PAGE_H=A4 margin=13*mm doc=SimpleDocTemplate(str(out), pagesize=A4, rightMargin=margin, leftMargin=margin, topMargin=11*mm, bottomMargin=10*mm) navy=HexColor('#17324D'); blue=HexColor('#2574A9'); pale=HexColor('#EAF4FA'); red=HexColor('#B42318'); pale_red=HexColor('#FDECEC'); text=HexColor('#202A33'); grey=HexColor('#54616E'); line=HexColor('#BDD2E2') styles=getSampleStyleSheet() title=ParagraphStyle('title', fontName='DejaVu-Bold', fontSize=19, leading=22, textColor=navy, alignment=TA_CENTER, spaceAfter=2) subtitle=ParagraphStyle('subtitle', fontName='DejaVu', fontSize=8.4, leading=10, textColor=grey, alignment=TA_CENTER, spaceAfter=7) section=ParagraphStyle('section', fontName='DejaVu-Bold', fontSize=10, leading=12, textColor=navy, spaceAfter=3, spaceBefore=1) body=ParagraphStyle('body', fontName='DejaVu', fontSize=7.55, leading=9.25, textColor=text) small=ParagraphStyle('small', fontName='DejaVu', fontSize=6.9, leading=8.2, textColor=text) callout=ParagraphStyle('callout', fontName='DejaVu-Bold', fontSize=8.2, leading=10.2, textColor=red) footer=ParagraphStyle('footer', fontName='DejaVu', fontSize=6.4, leading=7.5, textColor=grey, alignment=TA_CENTER) story=[] story.append(Paragraph('ANAPHYLACTIC SHOCK',title)) story.append(Paragraph('Clinical features and emergency management | Adult-focused bedside summary',subtitle)) alert=Table([[Paragraph('<b>MEDICAL EMERGENCY:</b> Treat suspected anaphylaxis immediately. Do not delay intramuscular epinephrine while seeking confirmation or waiting for other medications.',callout)]], colWidths=[184*mm]) alert.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,-1),pale_red),('BOX',(0,0),(-1,-1),0.7,red),('LEFTPADDING',(0,0),(-1,-1),6),('RIGHTPADDING',(0,0),(-1,-1),6),('TOPPADDING',(0,0),(-1,-1),5),('BOTTOMPADDING',(0,0),(-1,-1),5)])) story += [alert, Spacer(1,5)] features = [ '<b>When to suspect:</b> acute, rapidly progressive systemic reaction, commonly after a drug, food, or Hymenoptera sting. Anaphylaxis may cause cardiovascular collapse and/or respiratory failure.', '<b>Skin/mucosa:</b> flushing, warmth, generalized pruritus, urticaria, angioedema. Skin signs are common but their absence does not exclude a severe reaction.', '<b>Airway:</b> throat tightness or “lump,” hoarseness, stridor, tongue/laryngeal edema.', '<b>Breathing:</b> chest tightness, wheeze/bronchospasm, hypoxemia, respiratory distress. Asthma increases risk of severe lower-airway involvement.', '<b>Circulation:</b> tachycardia, hypotension, dizziness/syncope, shock from vasodilation, capillary leak, and reduced intravascular volume.', '<b>Gastrointestinal/neurologic:</b> crampy abdominal pain, nausea, vomiting, diarrhea or fecal incontinence; anxiety, altered consciousness in severe hypoxia/shock.', '<b>Course:</b> usually uniphasic; symptoms can recur after initial resolution (biphasic reaction).' ] feature_paras='<br/>'.join(['• '+x for x in features]) initial = [ '<b>1. Call for help, remove trigger if feasible.</b> Position supine with legs elevated if hypotensive; avoid standing/walking. Use lateral position if vomiting or unconscious. Assess ABCs and continuous monitoring.', '<b>2. Epinephrine first-line:</b> adult IM 0.3-0.5 mg of 1 mg/mL (1:1000) into the mid-anterolateral thigh. Repeat every 5-20 min if persistent or worsening symptoms. There are no absolute contraindications in anaphylaxis.', '<b>3. Airway and oxygen:</b> high-flow oxygen; early advanced airway support if progressive edema, stridor, or hypoxia. Do not wait for complete obstruction.', '<b>4. Shock:</b> establish IV access; rapid isotonic crystalloid boluses. If hypotension persists after IM doses, fluids, and oxygen, manage in a monitored critical-care setting with IV epinephrine infusion/vasopressor support. Avoid IV epinephrine bolus except by experienced resuscitation clinicians.', '<b>5. Refractory shock on beta-blocker:</b> consider glucagon in a monitored setting, alongside vasopressor management.', ] initial_paras='<br/>'.join(['• '+x for x in initial]) adjunct = [ '<b>Bronchospasm:</b> nebulized albuterol as adjunct.', '<b>Hives/itch:</b> H1 antihistamine only after epinephrine. It does not treat airway edema or shock.', '<b>Corticosteroids:</b> may be used after stabilization for selected patients, but do not replace epinephrine and should not delay it. Their benefit in preventing biphasic reactions is uncertain.', '<b>Investigations:</b> diagnosis is clinical. If useful, acute serum tryptase peaks roughly 60-90 min after onset and may remain measurable up to 5 h; obtain a later baseline for comparison. Do not delay resuscitation for testing.' ] post = [ '<b>Observe until symptoms fully resolve.</b> Longer observation/admission if hypotension, airway involvement, protracted symptoms, unknown trigger, IV epinephrine, repeated IM epinephrine, or inadequate home support.', '<b>At discharge:</b> prescribe and teach use of self-injectable epinephrine, provide a written emergency action plan, advise trigger avoidance, and arrange allergy/immunology assessment. Prescribe at least two devices for those needing repeated doses or with biphasic reactions.' ] left = [Paragraph('CLINICAL FEATURES',section), Paragraph(feature_paras,body)] right_top=[Paragraph('IMMEDIATE MANAGEMENT',section), Paragraph(initial_paras,body)] right_bot=[Paragraph('ADJUNCTS AND AFTERCARE',section), Paragraph('<br/>'.join(['• '+x for x in adjunct]),small), Spacer(1,3), Paragraph('<br/>'.join(['• '+x for x in post]),small)] right=[right_top, right_bot] # Use nested tables to control alignment left_tbl=Table([[left[0]],[left[1]]], colWidths=[88.5*mm]) left_tbl.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,0),pale),('BOX',(0,0),(-1,-1),0.6,line),('LINEBELOW',(0,0),(-1,0),0.6,line),('LEFTPADDING',(0,0),(-1,-1),5),('RIGHTPADDING',(0,0),(-1,-1),5),('TOPPADDING',(0,0),(-1,0),4),('BOTTOMPADDING',(0,0),(-1,0),3),('TOPPADDING',(0,1),(-1,1),4),('BOTTOMPADDING',(0,1),(-1,1),5)])) rt_tbl=Table([[right_top[0]],[right_top[1]]], colWidths=[88.5*mm]) rt_tbl.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,0),pale),('BOX',(0,0),(-1,-1),0.6,line),('LINEBELOW',(0,0),(-1,0),0.6,line),('LEFTPADDING',(0,0),(-1,-1),5),('RIGHTPADDING',(0,0),(-1,-1),5),('TOPPADDING',(0,0),(-1,0),4),('BOTTOMPADDING',(0,0),(-1,0),3),('TOPPADDING',(0,1),(-1,1),4),('BOTTOMPADDING',(0,1),(-1,1),5)])) rb_tbl=Table([[right_bot[0]],[right_bot[1]],[right_bot[2]],[right_bot[3]]], colWidths=[88.5*mm]) rb_tbl.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,0),pale),('BOX',(0,0),(-1,-1),0.6,line),('LINEBELOW',(0,0),(-1,0),0.6,line),('LEFTPADDING',(0,0),(-1,-1),5),('RIGHTPADDING',(0,0),(-1,-1),5),('TOPPADDING',(0,0),(-1,0),4),('BOTTOMPADDING',(0,0),(-1,0),3),('TOPPADDING',(0,1),(-1,-1),4),('BOTTOMPADDING',(0,1),(-1,-1),4)])) cols=Table([[left_tbl, [rt_tbl, Spacer(1,5), rb_tbl]]], colWidths=[88.5*mm,88.5*mm], hAlign='CENTER') cols.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)])) story += [cols, Spacer(1,6)] source_text='<b>Primary reference:</b> Harrison’s Principles of Internal Medicine, 22nd ed. (2025), “Anaphylaxis,” pp. 2855-2857. <b>Practice update used to clarify acute-care details:</b> 2023 Joint Task Force Practice Parameter Update, summarized by AAAAI (2024). This sheet is for trained clinical use and local emergency protocols take precedence.' story.append(Paragraph(source_text,footer)) def page(canvas, doc): canvas.saveState() canvas.setStrokeColor(line); canvas.setLineWidth(.35) canvas.line(margin, PAGE_H-8*mm, PAGE_W-margin, PAGE_H-8*mm) canvas.setFont('DejaVu',6.2); canvas.setFillColor(grey) canvas.drawRightString(PAGE_W-margin, 6*mm, 'Prepared 02 Oct 2026') canvas.restoreState() doc.build(story,onFirstPage=page) r=PdfReader(str(out)) assert len(r.pages)==1, f'Expected 1 page, got {len(r.pages)}' text=r.pages[0].extract_text() assert 'ANAPHYLACTIC SHOCK' in text and 'IMMEDIATE MANAGEMENT' in text print(out, len(r.pages), len(text)) PY
python - <<'PY' from reportlab.lib.pagesizes import A4 from reportlab.lib import colors from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle from reportlab.lib.enums import TA_CENTER from reportlab.lib.units import mm from reportlab.platypus import SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle from reportlab.lib.colors import HexColor from pypdf import PdfReader from pathlib import Path out=Path('/tmp/workspace/anaphylactic-shock-pdf/output/anaphylactic_shock_one_page.pdf') P=A4; W,H=P; m=13*mm doc=SimpleDocTemplate(str(out),pagesize=P,rightMargin=m,leftMargin=m,topMargin=11*mm,bottomMargin=10*mm) navy=HexColor('#17324D'); pale=HexColor('#EAF4FA'); red=HexColor('#B42318'); pale_red=HexColor('#FDECEC'); text=HexColor('#202A33'); grey=HexColor('#54616E'); line=HexColor('#BDD2E2') title=ParagraphStyle('title',fontName='Helvetica-Bold',fontSize=19,leading=22,textColor=navy,alignment=TA_CENTER,spaceAfter=2) subtitle=ParagraphStyle('sub',fontName='Helvetica',fontSize=8.4,leading=10,textColor=grey,alignment=TA_CENTER,spaceAfter=7) section=ParagraphStyle('sec',fontName='Helvetica-Bold',fontSize=10,leading=12,textColor=navy,spaceAfter=3) body=ParagraphStyle('body',fontName='Helvetica',fontSize=7.55,leading=9.25,textColor=text) small=ParagraphStyle('small',fontName='Helvetica',fontSize=6.9,leading=8.2,textColor=text) callout=ParagraphStyle('call',fontName='Helvetica-Bold',fontSize=8.2,leading=10.2,textColor=red) foot=ParagraphStyle('foot',fontName='Helvetica',fontSize=6.4,leading=7.5,textColor=grey,alignment=TA_CENTER) S=[Paragraph('ANAPHYLACTIC SHOCK',title),Paragraph('Clinical features and emergency management | Adult-focused bedside summary',subtitle)] A=Table([[Paragraph('<b>MEDICAL EMERGENCY:</b> Treat suspected anaphylaxis immediately. Do not delay intramuscular epinephrine while seeking confirmation or waiting for other medications.',callout)]],colWidths=[184*mm]) A.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,-1),pale_red),('BOX',(0,0),(-1,-1),.7,red),('LEFTPADDING',(0,0),(-1,-1),6),('RIGHTPADDING',(0,0),(-1,-1),6),('TOPPADDING',(0,0),(-1,-1),5),('BOTTOMPADDING',(0,0),(-1,-1),5)])); S += [A,Spacer(1,5)] def bullets(a): return '<br/>'.join(['• '+x for x in a]) features=['<b>When to suspect:</b> acute, rapidly progressive systemic reaction, commonly after a drug, food, or Hymenoptera sting. It may cause cardiovascular collapse and/or respiratory failure.','<b>Skin/mucosa:</b> flushing, warmth, generalized pruritus, urticaria, angioedema. Skin signs are common but may be absent.','<b>Airway:</b> throat tightness or a lump, hoarseness, stridor, tongue/laryngeal edema.','<b>Breathing:</b> chest tightness, wheeze/bronchospasm, hypoxemia, respiratory distress. Asthma increases risk of severe lower-airway involvement.','<b>Circulation:</b> tachycardia, hypotension, dizziness/syncope, shock from vasodilation, capillary leak, and reduced intravascular volume.','<b>GI/neurologic:</b> crampy abdominal pain, nausea, vomiting, diarrhea or fecal incontinence; anxiety or altered consciousness in severe shock/hypoxia.','<b>Course:</b> usually uniphasic; symptoms can recur after initial resolution (biphasic reaction).'] initial=['<b>1. Call for help and remove trigger if feasible.</b> Position supine with legs elevated if hypotensive; do not let the patient stand or walk. Use lateral position if vomiting/unconscious. Assess ABCs and monitor.','<b>2. Epinephrine first-line:</b> adult IM 0.3-0.5 mg of 1 mg/mL (1:1000) into the mid-anterolateral thigh. Repeat every 5-20 min if persistent/worsening. No absolute contraindications in anaphylaxis.','<b>3. Airway and oxygen:</b> high-flow oxygen; early advanced airway support if progressive edema, stridor, or hypoxia. Do not wait for complete obstruction.','<b>4. Shock:</b> IV access and rapid isotonic crystalloid boluses. Persistent hypotension after IM doses, fluids, and oxygen requires monitored critical-care management with IV epinephrine infusion/vasopressor support. Avoid IV epinephrine bolus except by experienced resuscitation clinicians.','<b>5. Refractory shock on beta-blocker:</b> consider glucagon in a monitored setting, alongside vasopressor management.'] adj=['<b>Bronchospasm:</b> nebulized albuterol as adjunct.','<b>Hives/itch:</b> H1 antihistamine only after epinephrine. It does not treat airway edema or shock.','<b>Corticosteroids:</b> may be used after stabilization for selected patients, but do not replace epinephrine or delay it. Benefit in preventing biphasic reactions is uncertain.','<b>Investigations:</b> diagnosis is clinical. If useful, acute serum tryptase peaks about 60-90 min after onset and may remain measurable up to 5 h; obtain a later baseline. Never delay resuscitation for testing.'] post=['<b>Observe until symptoms fully resolve.</b> Longer observation/admission if hypotension, airway involvement, protracted symptoms, unknown trigger, IV epinephrine, repeated IM epinephrine, or inadequate home support.','<b>At discharge:</b> prescribe and teach self-injectable epinephrine, provide a written action plan, advise trigger avoidance, and arrange allergy/immunology assessment. Consider at least two devices after repeated-dose or biphasic reactions.'] def panel(head,content,sty): t=Table([[Paragraph(head,section)],[Paragraph(content,sty)]],colWidths=[88.5*mm]);t.setStyle(TableStyle([('BACKGROUND',(0,0),(-1,0),pale),('BOX',(0,0),(-1,-1),.6,line),('LINEBELOW',(0,0),(-1,0),.6,line),('LEFTPADDING',(0,0),(-1,-1),5),('RIGHTPADDING',(0,0),(-1,-1),5),('TOPPADDING',(0,0),(-1,0),4),('BOTTOMPADDING',(0,0),(-1,0),3),('TOPPADDING',(0,1),(-1,1),4),('BOTTOMPADDING',(0,1),(-1,1),5)]));return t L=panel('CLINICAL FEATURES',bullets(features),body); RT=panel('IMMEDIATE MANAGEMENT',bullets(initial),body); RB=panel('ADJUNCTS AND AFTERCARE',bullets(adj)+'<br/><br/>'+bullets(post),small) cols=Table([[L,[RT,Spacer(1,5),RB]]],colWidths=[88.5*mm,88.5*mm]);cols.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)]));S += [cols,Spacer(1,6)] S.append(Paragraph('<b>Primary reference:</b> Harrison\'s Principles of Internal Medicine, 22nd ed. (2025), Anaphylaxis, pp. 2855-2857. <b>Acute-care clarification:</b> 2023 Joint Task Force Practice Parameter Update, summarized by AAAAI (2024). For trained clinical use; local emergency protocols take precedence.',foot)) def pg(c,d): c.saveState();c.setStrokeColor(line);c.setLineWidth(.35);c.line(m,H-8*mm,W-m,H-8*mm);c.setFont('Helvetica',6.2);c.setFillColor(grey);c.drawRightString(W-m,6*mm,'Prepared 02 Oct 2026');c.restoreState() doc.build(S,onFirstPage=pg) r=PdfReader(str(out)); assert len(r.pages)==1, len(r.pages); tx=r.pages[0].extract_text();assert 'ANAPHYLACTIC SHOCK' in tx and 'IMMEDIATE MANAGEMENT' in tx;print(f'OK {out} pages={len(r.pages)} chars={len(tx)}') PY
anaphylactic shock one page
PDF Document · PDF