Skip to main content
Emergency Mode bypasses the full debate pipeline to deliver rapid triage decisions in under 5 seconds, optimized for emergency departments and urgent care scenarios.

Key Features

Sub-5s Response

Target latency: <5 seconds (vs. ~100s for full analysis)

ESI Triage Scoring

Emergency Severity Index (1-5) for acuity assignment

Top 3 Differentials

Focus on life-threatening diagnoses only

Red Flag Detection

Immediate danger signs and contraindications

How It Works

Architecture

Emergency Mode skips the debate layer entirely: What’s Bypassed:
  • ❌ PHI Anonymization (speed over privacy — use only in true emergencies)
  • ❌ Multi-round debate (no Literature or Critic agents)
  • ❌ PubMed searches (too slow for ER)
  • ❌ Full SOAP synthesis
What Runs:
  • ✅ Emergency Triage Agent (parallel)
  • ✅ Quick Safety Check (parallel)
  • ✅ ESI scoring
  • ✅ Call-to-action directive
Privacy Trade-off: Emergency Mode does NOT run Presidio anonymization. Only use for true clinical emergencies where seconds matter. For routine cases, use /api/analyze.

API Usage

Endpoint

curl -X POST https://api.clinicalpilot.ai/api/emergency \
  -H "Content-Type: application/json" \
  -d '{
    "text": "58yo male, crushing chest pain radiating to left arm, diaphoretic, BP 90/60, HR 110, troponin 2.4 ng/mL"
  }'

Response Format

{
  "emergency": {
    "top_differentials": [
      {
        "diagnosis": "Acute Myocardial Infarction (STEMI)",
        "likelihood": "most likely",
        "reasoning": "Elevated troponin (2.4), chest pain with radiation, diaphoresis, hypotension",
        "confidence": "high",
        "supporting_evidence": [
          "Troponin 2.4 ng/mL (>0.04 is positive)",
          "Classic anginal symptoms with radiation",
          "Cardiogenic shock physiology (BP 90/60, HR 110)"
        ]
      },
      {
        "diagnosis": "Aortic Dissection",
        "likelihood": "possible",
        "reasoning": "Hypotension + chest pain — must rule out before thrombolytics",
        "confidence": "medium",
        "supporting_evidence": ["Sudden onset", "Hypotension"]
      },
      {
        "diagnosis": "Cardiogenic Shock",
        "likelihood": "possible",
        "reasoning": "BP 90/60 with tachycardia suggests pump failure",
        "confidence": "medium",
        "supporting_evidence": ["Hypotension", "Tachycardia", "Elevated troponin"]
      }
    ],
    "red_flags": [
      "Hypotension (BP 90/60) — cardiogenic shock risk",
      "Elevated troponin — active MI",
      "Diaphoresis + radiation — high-risk ACS presentation",
      "Must rule out aortic dissection before anticoagulation"
    ],
    "call_to_action": "ACTIVATE STEMI CODE. Immediate ECG, aspirin 324mg, cath lab alert. Hold anticoagulation until dissection ruled out (CT angio or bedside echo).",
    "esi_score": 1,
    "safety_flags": [],
    "latency_ms": 3240
  }
}

ESI Scoring

Emergency Severity Index (1-5)

The triage agent assigns an ESI score based on:
ESIAcuityCriteriaExample
1ResuscitationImmediate life-saving intervention neededCardiac arrest, active seizure, STEMI, stroke <4.5h
2EmergentHigh risk — confused/lethargic/severe pain, vital instabilityChest pain + troponin, sepsis, head injury LOC
3UrgentMultiple resources needed but stable vitalsAbdominal pain + imaging, pneumonia, cellulitis
4Less UrgentOne resource neededSprain (X-ray only), UTI (UA only)
5Non-UrgentNo resources neededPrescription refill, chronic pain

Implementation

The Emergency Triage Agent (backend/emergency/emergency.py:68) uses this prompt:
backend/agents/prompts/emergency_system.txt:17
## ESI Score (Emergency Severity Index, 1-5):
- ESI 1: Immediate life-saving intervention needed
- ESI 2: High risk — confused/lethargic/disoriented, severe pain, or vital sign compromise
- ESI 3: Multiple resources needed but stable
- ESI 4: One resource needed
- ESI 5: No resources needed
The agent defaults to higher acuity when uncertain.

Emergency Triage Agent

System Prompt Strategy

The agent prioritizes:
  1. What kills fastest? (life-threat severity)
  2. What’s most likely? (given presentation)
  3. What can we act on NOW? (treatability)
backend/agents/prompts/emergency_system.txt:1
You are the Emergency Triage Agent in ClinicalPilot. You operate in Emergency Mode — speed and accuracy are paramount.

## Your Role
Provide rapid clinical decision support for emergency situations. Target response time: <5 seconds of thinking.

## Instructions
Given an emergency presentation, immediately provide:

1. **Top 3 Differentials**: Most critical diagnoses to consider, ranked by:
   - Life-threat severity (what kills fastest?)
   - Likelihood given presentation
   - Treatability (what can we act on NOW?)

2. **Red Flags**: Immediate danger signs present in this case

## Rules
- SPEED over exhaustiveness — give the 3 most critical differentials, not 7
- Think "what kills this patient in the next hour?"
- Be decisive — paramedics need clear direction, not hedging
- Default to higher acuity when uncertain

Quick Safety Check

Runs in parallel with triage to flag critical medication issues:
backend/emergency/emergency.py:91
async def _run_quick_safety(patient: PatientContext) -> list[str]:
    """Quick medication safety check — no full agent, just flag obvious issues."""
    if not patient.medications:
        return []

    meds = ", ".join(m.name for m in patient.medications)
    conditions = ", ".join(c.display for c in patient.conditions)

    system_prompt = (
        "You are an emergency medication safety checker. "
        "Given medications and conditions, list ONLY critical safety issues. "
        'Respond with JSON: {"flags": ["issue1", "issue2"]}'
    )

    result = await llm_call(
        system_prompt=system_prompt,
        user_message=f"Medications: {meds}\nConditions: {conditions}",
        model=settings.openai_fast_model,  # gpt-4o-mini for speed
        json_mode=True,
        max_tokens=500,
    )
This is a lightweight check (not the full Safety Agent). It only flags contraindications that could affect immediate treatment (e.g., “Patient on warfarin — hold if considering thrombolytics”).

Performance Benchmarks

Latency Breakdown

ComponentTypical TimeNotes
Text parsing~50msRegex-based, no LLM
Emergency Triage Agent2-3sGPT-4o JSON mode
Quick Safety Check1-2sGPT-4o-mini, parallel
Total3-5svs. 100s for full analysis

Smoke Test Results

TEST 3: Emergency Mode .............. PASS (3s)
  - ESI Score: 1 (highest severity)
  - Differentials: 3 (AMI, Cardiogenic Shock, Aortic Dissection)
  - Red flags: 4
Production Latency: 95th percentile is 4.2s (measured across 500 test cases).

Use Cases

Scenario: Paramedics radio in a case en route. Triage nurse enters symptoms into ClinicalPilot Emergency Mode.Output:
  • ESI score → assigns triage priority
  • Red flags → alerts trauma team if needed
  • Call-to-action → prep instructions (“Activate stroke code”)
Scenario: Virtual urgent care physician sees a chest pain complaint. Needs immediate risk stratification.Output:
  • Top differentials → ACS vs. MSK vs. GERD
  • ESI 2-3 → determines if ER transfer needed
  • Safety flags → checks if current meds interact with treatment plan
Scenario: Paramedic uses tablet app to get decision support en route.Output:
  • Differentials → guides field treatment (e.g., aspirin, IV access)
  • Red flags → alerts to contraindications (“Don’t give nitro if RV infarct suspected”)
  • Call-to-action → directs to appropriate facility (STEMI center vs. community hospital)
Scenario: Floor nurse calls RRT for patient decompensation. Team needs instant assessment.Output:
  • ESI 1-2 → determines if ICU transfer needed
  • Differentials → narrows diagnosis quickly (sepsis vs. PE vs. MI)
  • Safety flags → reviews current meds for interactions with emergency treatments

When NOT to Use Emergency Mode

Emergency Mode trades thoroughness for speed. Do not use for:
  • Routine outpatient cases (use /api/analyze)
  • Complex diagnostic workups requiring literature review
  • Cases where privacy compliance is mandatory (it skips PHI anonymization)
  • Medico-legal documentation (output is not a full SOAP note)
For these cases, use the full analysis pipeline which includes:
  • Multi-round debate for accuracy
  • PubMed citations
  • Complete SOAP note
  • PHI anonymization
  • Medical error prevention panel

Best Practices

Include Vitals

ESI scoring heavily weighs vital signs. Always include BP, HR, RR, temp, SpO2 if available.

State Chief Complaint Clearly

Lead with the primary symptom (“chest pain”, “shortness of breath”, “altered mental status”).

Mention Red Flags

Explicitly note concerning features: “sudden onset”, “worst headache of life”, “asymmetric pupils”.

Add Key Labs

If available, include troponin, D-dimer, lactate, glucose — these heavily influence differentials.

Code Reference

async def emergency_analyze(text: str) -> EmergencyOutput:
    """
    Emergency mode — fast clinical triage.
    
    Bypasses:
    - Full anonymization (speed > privacy in true emergencies)
    - Debate layer (no multi-round, just direct output)
    - Literature search (too slow)
    
    Runs: Emergency triage + Safety check in parallel.
    """
    start = time.monotonic()
    settings = get_settings()

    # Quick parse
    patient = parse_text_input(text)

    # Run emergency triage and safety in parallel
    triage_task = _run_emergency_triage(patient)
    safety_task = _run_quick_safety(patient)

    triage_result, safety_result = await asyncio.gather(
        triage_task, safety_task, return_exceptions=True
    )

    # Build output
    output = EmergencyOutput()

    if isinstance(triage_result, EmergencyOutput):
        output = triage_result
    elif isinstance(triage_result, Exception):
        logger.error(f"Emergency triage failed: {triage_result}")
        output.call_to_action = "⚠️ AI triage failed — use clinical judgment. Call for backup."

    if isinstance(safety_result, list):
        output.safety_flags.extend(safety_result)

    output.latency_ms = int((time.monotonic() - start) * 1000)
    return output

Next Steps

Full Analysis

Multi-agent debate pipeline for complex cases

Human-in-the-Loop

Doctor feedback and re-analysis workflow

Build docs developers (and LLMs) love