Differentials for pulmonary thromboembolism
| Condition | Key distinguishing features |
|---|---|
| Acute coronary syndrome (ACS) | ECG ST changes in coronary distribution, troponin rise, responds to nitrates; PE may also elevate troponin (RV strain), so CTPA/angiography often needed |
| Aortic dissection | Tearing pain radiating to back, widened mediastinum on CXR, BP differential between arms, D-dimer strongly elevated but CT aortography confirms |
| Decompensated heart failure | Orthopnea, PND, bilateral crackles, raised JVP with bilateral edema; BNP helps, but RV failure from massive PE can mimic this |
| Pericarditis / pericardial effusion | Positional chest pain relieved by leaning forward, pericardial rub, diffuse saddle-shaped ST elevation on ECG, PR depression |
| Acute myocarditis | Often younger patients post-viral illness, global ST changes, elevated troponin, wall motion abnormalities on echo |
| Pulmonary hypertension (primary or secondary) | Gradual onset dyspnea, RV hypertrophy on ECG/echo; may coexist with or result from chronic PE |
| Condition | Key distinguishing features |
|---|---|
| Pneumonia | Productive cough, fever, consolidation on CXR, lobar infiltrate; can coexist with PE |
| Pneumothorax | Sudden pleuritic pain + absent breath sounds unilaterally, hyperresonance, visible on CXR |
| Acute bronchitis / COPD exacerbation | Wheezing, increased sputum, prior COPD history; ECG signs of RV strain may appear in COPD too |
| Asthma exacerbation | Diffuse expiratory wheeze, response to bronchodilators, known history |
| Pleuritis / Pleurisy | Secondary to connective tissue disease (SLE, RA), viral illness; localized rub without embolic features |
| Pulmonary infarction (from PE itself) | Note: PE with infarction causes chest wall tenderness, mimicking musculoskeletal disease - a trap |
| Intrathoracic malignancy | Lung cancer may present with hemoptysis/dyspnea; also a risk factor for PE, so can coexist |
| Condition | Key distinguishing features |
|---|---|
| Costochondritis / Musculoskeletal chest pain | Reproducible on palpation, no hypoxia, no tachycardia; most common diagnosis confused with PE |
| Rib fracture | Trauma history, point tenderness, visible on X-ray or CT |
| Condition | Key distinguishing features |
|---|---|
| Anxiety / Panic disorder | Hyperventilation, low CO2 on ABG, normal SpO2, normal ECG; diagnosis of exclusion |
| Syncope | Massive PE can present with syncope - must exclude structural cardiac, vasovagal, arrhythmic causes |
| Condition | Key distinguishing features |
|---|---|
| Hepatobiliary / splenic pathology | Right-sided or subdiaphragmatic processes (e.g., cholecystitis, splenic infarct) can cause referred pleuritic pain |
| Esophageal perforation | Boerhaave syndrome - retrosternal chest pain after vomiting, surgical emergency; chest X-ray may show mediastinal air |
Acute coronary syndromes, COPD exacerbation, Aortic dissection, Pneumonia, Acute bronchitis, Decompensated heart failure, Pulmonary hypertension, Pericardial disease, Intrathoracic malignancy, Musculoskeletal pain, Pneumothorax, Anxiety, Hepatobiliary or splenic pathology
Treatment of hypertensive emergency according to harrisons medicine
| Drug | Class | Key Points |
|---|---|---|
| Sodium nitroprusside | Potent vasodilator | "Long history of success"; monitor carefully to avoid overshooting and causing hypotension |
| Nicardipine (IV) | Dihydropyridine CCB | "Perhaps the most commonly utilized agent in contemporary practice"; no dose adjustment in elderly; contraindicated in severe aortic stenosis |
| Labetalol (IV) | Alpha + Beta blocker | Effective; contraindicated in obstructive airway disease, COPD, bradycardia, 2nd/3rd-degree heart block |
Make a clinical decision-making flowchart for urgency vs emergency
ls -la /home/daytona/workspace/ 2>/dev/null || echo "workspace empty or missing"
mkdir -p /home/daytona/workspace/htn-flowchart
~/htn-flowchart/flowchart.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Hypertensive Urgency vs Emergency – Clinical Decision Flowchart</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
font-family: 'Segoe UI', Arial, sans-serif;
background: #f0f4f8;
padding: 30px 20px 50px;
color: #1a202c;
}
h1 {
text-align: center;
font-size: 1.5rem;
font-weight: 700;
color: #2d3748;
margin-bottom: 4px;
letter-spacing: 0.02em;
}
.subtitle {
text-align: center;
font-size: 0.82rem;
color: #718096;
margin-bottom: 32px;
}
/* ===== FLOWCHART CONTAINER ===== */
.flow {
display: flex;
flex-direction: column;
align-items: center;
gap: 0;
}
/* Boxes */
.box {
border-radius: 10px;
padding: 14px 22px;
text-align: center;
font-size: 0.88rem;
font-weight: 600;
line-height: 1.5;
position: relative;
box-shadow: 0 2px 8px rgba(0,0,0,0.10);
max-width: 480px;
width: 100%;
}
.box.start {
background: #2b6cb0;
color: #fff;
border-radius: 40px;
font-size: 1rem;
font-weight: 700;
padding: 16px 30px;
}
.box.decision {
background: #fff;
border: 2.5px solid #2b6cb0;
color: #2d3748;
border-radius: 12px;
font-weight: 600;
}
.box.urgency {
background: #f6ad55;
color: #744210;
border-radius: 10px;
font-weight: 700;
font-size: 0.95rem;
}
.box.emergency {
background: #fc8181;
color: #742a2a;
border-radius: 10px;
font-weight: 700;
font-size: 0.95rem;
}
.box.action-urgency {
background: #fffbeb;
border: 2px solid #f6ad55;
color: #744210;
border-radius: 10px;
font-weight: 500;
text-align: left;
}
.box.action-emergency {
background: #fff5f5;
border: 2px solid #fc8181;
color: #742a2a;
border-radius: 10px;
font-weight: 500;
text-align: left;
}
.box.special {
background: #e9d8fd;
border: 2px solid #9b59b6;
color: #44337a;
border-radius: 10px;
font-weight: 600;
font-size: 0.85rem;
}
.box.special-action {
background: #faf5ff;
border: 2px solid #9b59b6;
color: #44337a;
border-radius: 10px;
font-weight: 500;
text-align: left;
font-size: 0.82rem;
}
.box.note {
background: #ebf8ff;
border: 2px dashed #4299e1;
color: #2b6cb0;
border-radius: 8px;
font-size: 0.78rem;
font-weight: 500;
max-width: 480px;
text-align: left;
}
/* Arrows */
.arrow {
display: flex;
flex-direction: column;
align-items: center;
gap: 0;
}
.arrow-line {
width: 2px;
height: 26px;
background: #4a5568;
}
.arrow-head {
width: 0; height: 0;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-top: 10px solid #4a5568;
}
.arrow-label {
font-size: 0.72rem;
font-weight: 700;
color: #4a5568;
background: #e2e8f0;
border-radius: 4px;
padding: 1px 7px;
margin-bottom: 2px;
}
/* Branch layout */
.branch-row {
display: flex;
flex-direction: row;
align-items: flex-start;
justify-content: center;
gap: 36px;
width: 100%;
max-width: 1020px;
}
.branch {
display: flex;
flex-direction: column;
align-items: center;
flex: 1;
max-width: 460px;
gap: 0;
}
/* Horizontal line connecting branches */
.h-line-container {
display: flex;
align-items: flex-start;
justify-content: center;
width: 100%;
max-width: 1020px;
position: relative;
height: 26px;
}
.h-line {
position: absolute;
top: 0;
left: calc(50% - 230px);
right: calc(50% - 230px);
height: 2px;
background: #4a5568;
}
.h-drop-left {
position: absolute;
top: 0;
left: calc(50% - 230px);
width: 2px;
height: 26px;
background: #4a5568;
}
.h-drop-right {
position: absolute;
top: 0;
right: calc(50% - 230px);
width: 2px;
height: 26px;
background: #4a5568;
}
.h-label-left {
position: absolute;
top: 4px;
left: calc(50% - 228px);
font-size: 0.72rem;
font-weight: 700;
color: #f6ad55;
background: #fffbeb;
border-radius: 4px;
padding: 1px 6px;
border: 1px solid #f6ad55;
}
.h-label-right {
position: absolute;
top: 4px;
right: calc(50% - 228px);
font-size: 0.72rem;
font-weight: 700;
color: #e53e3e;
background: #fff5f5;
border-radius: 4px;
padding: 1px 6px;
border: 1px solid #fc8181;
}
ul.drug-list {
list-style: none;
padding: 0;
margin: 6px 0 0;
}
ul.drug-list li {
padding: 3px 0 3px 18px;
position: relative;
font-size: 0.82rem;
line-height: 1.4;
}
ul.drug-list li::before {
content: '▸';
position: absolute;
left: 0;
color: #e53e3e;
}
ul.drug-list.orange li::before { color: #d69e2e; }
.section-label {
font-size: 0.7rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.08em;
margin-top: 8px;
margin-bottom: 2px;
opacity: 0.75;
}
.special-grid {
display: flex;
flex-direction: row;
gap: 14px;
max-width: 1020px;
width: 100%;
flex-wrap: wrap;
justify-content: center;
margin-top: 8px;
}
.special-card {
background: #faf5ff;
border: 2px solid #9b59b6;
border-radius: 10px;
padding: 12px 16px;
flex: 1;
min-width: 200px;
max-width: 310px;
font-size: 0.8rem;
color: #44337a;
}
.special-card h4 {
font-size: 0.85rem;
font-weight: 700;
color: #6b46c1;
margin-bottom: 6px;
border-bottom: 1px solid #d6bcfa;
padding-bottom: 4px;
}
.special-card ul {
list-style: none;
padding: 0;
}
.special-card ul li {
padding: 2px 0 2px 14px;
position: relative;
line-height: 1.4;
}
.special-card ul li::before {
content: '▸';
position: absolute;
left: 0;
color: #9b59b6;
}
.special-card .avoid {
color: #e53e3e;
font-weight: 600;
}
.footer-note {
max-width: 700px;
margin: 30px auto 0;
background: #ebf8ff;
border-left: 4px solid #4299e1;
border-radius: 6px;
padding: 10px 16px;
font-size: 0.78rem;
color: #2b6cb0;
line-height: 1.6;
}
hr.section-div {
border: none;
border-top: 2px dashed #cbd5e0;
margin: 18px 0;
max-width: 1020px;
width: 100%;
}
</style>
</head>
<body>
<h1>Hypertensive Urgency vs Emergency</h1>
<p class="subtitle">Clinical Decision-Making Flowchart | Based on Harrison's Principles of Internal Medicine, 22nd Ed. (2025)</p>
<div class="flow">
<!-- ENTRY BOX -->
<div class="box start">Patient presents with BP ≥180/100 mmHg</div>
<!-- Arrow down -->
<div class="arrow">
<div class="arrow-line"></div>
<div class="arrow-head"></div>
</div>
<!-- FIRST DECISION -->
<div class="box decision">
<b>Is there evidence of active, ongoing end-organ damage?</b><br/>
<span style="font-weight:400;font-size:0.81rem;color:#4a5568;">Assess: neuro symptoms, chest pain, dyspnea, AKI, visual changes, papilledema</span>
</div>
<!-- Branching line -->
<div class="h-line-container">
<div class="h-line"></div>
<div class="h-drop-left"></div>
<div class="h-drop-right"></div>
<span class="h-label-left">NO</span>
<span class="h-label-right">YES</span>
</div>
<!-- Two columns -->
<div class="branch-row">
<!-- LEFT: URGENCY -->
<div class="branch">
<div class="box urgency">⚠ HYPERTENSIVE URGENCY</div>
<div class="arrow"><div class="arrow-line"></div><div class="arrow-head"></div></div>
<div class="box action-urgency">
<div class="section-label">Setting</div>
Outpatient / ED (observation)
<div class="section-label">Goal BP</div>
Gradual reduction over 24–48 hours
<div class="section-label">Treatment</div>
<ul class="drug-list orange">
<li>Initiate or intensify <b>oral antihypertensives</b></li>
<li>Amlodipine, lisinopril/losartan, or chlorthalidone</li>
<li>Address medication non-compliance</li>
<li>Avoid rapid IV reduction (risk of ischemia)</li>
</ul>
<div class="section-label">Follow-up</div>
Arrange outpatient review within 24–48 hrs
</div>
</div>
<!-- RIGHT: EMERGENCY -->
<div class="branch">
<div class="box emergency">🚨 HYPERTENSIVE EMERGENCY</div>
<div class="arrow"><div class="arrow-line"></div><div class="arrow-head"></div></div>
<div class="box decision" style="font-size:0.82rem;">
<b>Identify specific end-organ pattern:</b><br/>
<span style="font-weight:400;">Encephalopathy? AKI? Acute LVF? Dissection? Eclampsia? Pheo crisis?</span>
</div>
<div class="arrow"><div class="arrow-line"></div><div class="arrow-head"></div></div>
<div class="box action-emergency">
<div class="section-label">Setting</div>
ICU / Emergency department with continuous monitoring
<div class="section-label">BP Reduction Goal</div>
<b>Controlled, gradual reduction</b> — not immediate normalization<br/>
<span style="font-size:0.78rem;">Typically 10–20% reduction in first hour, then further over 2–6 hrs</span>
<div class="section-label">IV Agents (General)</div>
<ul class="drug-list">
<li><b>Nicardipine IV</b> — most commonly used; dihydropyridine CCB<br/><span style="font-size:0.77rem;">Contraindicated: severe aortic stenosis</span></li>
<li><b>Sodium nitroprusside IV</b> — potent vasodilator; monitor to avoid overshoot</li>
<li><b>Labetalol IV</b> — alpha + beta blocker<br/><span style="font-size:0.77rem;">Contraindicated: COPD, asthma, bradycardia, 2°/3° AV block</span></li>
</ul>
<div class="section-label">After Stabilization</div>
Transition to oral agents; investigate secondary causes (esp. renovascular disease)
</div>
</div>
</div>
<hr class="section-div"/>
<!-- SPECIAL SITUATIONS HEADER -->
<div class="arrow"><div class="arrow-line" style="background:transparent;"></div></div>
<div class="box special" style="max-width:700px;">
⚡ Special Situations Requiring Particularly Rapid Treatment
<br/><span style="font-weight:400;font-size:0.78rem;">Harrison's flags these three as needing the fastest intervention</span>
</div>
<div class="special-grid">
<!-- AORTIC DISSECTION -->
<div class="special-card">
<h4>🩸 Acute Aortic Dissection</h4>
<b>Goals:</b> HR 60–80 bpm & SBP ≤120 mmHg<br/><br/>
<b>Drugs:</b>
<ul>
<li>IV <b>beta-blocker</b> first (propranolol / metoprolol / esmolol)</li>
<li>Add IV <b>nitroprusside</b> if SBP still elevated</li>
<li><b>Labetalol IV</b> as single-agent alternative</li>
<li>If BB/SNP not tolerated: IV <b>verapamil</b> or <b>diltiazem</b></li>
<li>Parenteral <b>enalaprilat</b> (ACEI) can be added to BB</li>
</ul>
<br/>
<span class="avoid">✗ Avoid isolated hydralazine</span><br/>
<span style="font-size:0.77rem;">Increases shear stress → propagates dissection</span>
</div>
<!-- ECLAMPSIA -->
<div class="special-card">
<h4>🤰 Eclampsia / Severe Preeclampsia</h4>
<b>Drugs:</b>
<ul>
<li>IV / oral <b>Labetalol</b></li>
<li><b>Nifedipine</b> (oral CCB)</li>
<li><b>Hydralazine</b> IV (direct vasodilator — acceptable in pregnancy)</li>
<li><b>Methyldopa</b> (centrally acting α2 agonist)</li>
<li>IV <b>Magnesium sulfate</b> for seizure prophylaxis</li>
</ul>
<br/>
<span class="avoid">✗ Avoid ACEIs & ARBs</span><br/>
<span style="font-size:0.77rem;">Teratogenic — contraindicated in pregnancy</span>
</div>
<!-- PHEO CRISIS -->
<div class="special-card">
<h4>🔬 Pheochromocytoma Crisis</h4>
<b>Drugs:</b>
<ul>
<li><b>Phentolamine</b> (alpha-blocker) — first line</li>
<li>IV <b>Nicardipine</b> or <b>Nitroprusside</b></li>
<li>IV <b>Nitroglycerin</b></li>
<li>IV <b>Magnesium sulfate</b></li>
</ul>
<br/>
<span class="avoid">✗ Avoid beta-blockers first</span><br/>
<span style="font-size:0.77rem;">Without prior alpha-blockade → unopposed alpha stimulation → paradoxical BP surge</span>
</div>
</div>
<!-- FOOTER NOTE -->
<div class="footer-note">
<b>Key principle (Harrison's):</b> The goal of treatment in hypertensive emergency is a <b>controlled, gradual reduction</b> in BP — not immediate normalization. Rapid normalization risks ischemia in organs adapted to high perfusion pressures. After acute control, always <b>investigate secondary causes</b>, especially renovascular disease, which is relatively common in hypertensive emergencies.
</div>
</div>
</body>
</html>
cd /home/daytona/workspace/htn-flowchart && python3 -c " import subprocess, os result = subprocess.run( ['node', '-e', 'console.log(process.version)'], capture_output=True, text=True ) print('Node:', result.stdout.strip()) # Check if puppeteer or similar is available result2 = subprocess.run(['which', 'chromium', 'chromium-browser', 'google-chrome'], capture_output=True, text=True) print('Chrome:', result2.stdout.strip()) result3 = subprocess.run(['which', 'wkhtmltopdf'], capture_output=True, text=True) print('wkhtmltopdf:', result3.stdout.strip()) "
chromium --headless --no-sandbox --disable-gpu --screenshot=/home/daytona/workspace/htn-flowchart/flowchart.png --window-size=1080,1600 "file:///home/daytona/workspace/htn-flowchart/flowchart.html" 2>/dev/null; echo "exit: $?"