# PESI

PESI

## Also searched as

- PESI
- Pulmonary Embolism Severity Index
- Aujesky PESI
- PESI score
- original PESI
- PE severity index
- Aujesky 2005 PESI

Status: LIVE
Price: $0.005 USDC
`GET /api/calc/pesi`
HTML: https://magentlab.com/docs/pesi
Markdown: https://magentlab.com/docs/pesi.md

Not a medical device. Not a diagnosis, dose, or listing recommendation.

## What it computes

Compute the Aujesky 2005 Pulmonary Embolism Severity Index (PESI) from age, sex, comorbidities, vital signs, and altered mental status.

## When to use

When an agent already has a diagnosis of pulmonary embolism, as in the paper, and needs the published 11-variable PESI total and class I-V.

## When not to use

- Not a diagnosis or outpatient-treatment protocol. magent does not diagnose PE.
- Only for patients with already diagnosed pulmonary embolism, as in Aujesky 2005.
- This tool is original PESI (Aujesky 2005), not sPESI. Heart failure and chronic lung disease are separate items.
- This is the 11-variable point score, not the 17-variable laboratory model.
- The caller assigns age, sex, comorbidities, vital signs, and altered mental status. magent does not examine the patient.

## Formula

```
PESI = age_in_years + 10*male + 30*cancer + 10*heart_failure + 10*chronic_lung_disease + 20*(HR>=110) + 30*(SBP<100) + 20*(RR>=30) + 20*(temp<36) + 60*altered_mentation + 20*(SpO2<90); classes I <=65, II 66-85, III 86-105, IV 106-125, V >125
```

## Citation

[Derivation and validation of a prognostic model for pulmonary embolism](https://doi.org/10.1164/rccm.200506-862OC)
Aujesky D, Obrosky DS, Stone RA, et al.
Am J Respir Crit Care Med. 2005;172(8):1041-1046
DOI: [10.1164/rccm.200506-862OC](https://doi.org/10.1164/rccm.200506-862OC)

## Worked example

### Age 50, female, all other items absent

Given: `age=50, altered_mentation=false, cancer=false, chronic_lung_disease=false, heart_failure=false, heart_rate_bpm=80, respiratory_rate=16, sex=female, spo2_percent=96, systolic_mm_hg=120, temperature_c=37.0`

1. Age 50 → 50; female → 0; cancer, heart failure, chronic lung disease false → 0
2. HR 80 is not ≥110 → 0; SBP 120 is not <100 → 0; RR 16 is not ≥30 → 0
3. Temp 37.0 is not <36 → 0; altered mentation false → 0; SpO2 96 is not <90 → 0
4. Score = 50; pesi_class I


### Age 80, male, cancer, altered mentation (class V)

Given: `age=80, altered_mentation=true, cancer=true, chronic_lung_disease=false, heart_failure=false, heart_rate_bpm=80, respiratory_rate=16, sex=male, spo2_percent=96, systolic_mm_hg=120, temperature_c=37.0`

1. Age 80 → 80; male → 10; cancer → 30; altered mentation → 60
2. Remaining items absent
3. Score = 180; pesi_class V


## Parameters

- `age` (integer, required): Age in years (18-120). Adds 1 point per year (the age integer itself).
- `sex` (string, required): Sex (female or male). Male scores +10.
- `cancer` (boolean, required): Cancer as assigned by the caller. true or false. +30 if true.
- `heart_failure` (boolean, required): Heart failure as assigned by the caller (separate from chronic lung disease). true or false. +10 if true.
- `chronic_lung_disease` (boolean, required): Chronic lung disease as assigned by the caller (separate from heart failure). true or false. +10 if true.
- `heart_rate_bpm` (integer, required): Heart rate in beats per minute (integer 30-220). Scores +20 when ≥110; 109 does not score.
- `systolic_mm_hg` (number, required): Systolic blood pressure in mm Hg (50-250). Scores +30 when <100; 100 does not score.
- `respiratory_rate` (integer, required): Respiratory rate in breaths/min (integer 4-80). Scores +20 when ≥30; 29 does not score.
- `temperature_c` (number, required): Temperature in °C (30-45). Scores +20 when <36; 36.0 does not score.
- `altered_mentation` (boolean, required): Altered mental status as assigned by the caller. true or false. +60 if true.
- `spo2_percent` (number, required): Arterial oxygen saturation percent (50-100). Scores +20 when <90; 90 does not score.

## Bulk (POST)

POST the same path with a JSON items array. Price is n times the GET unit. Invalid items return HTTP 400 before settlement.

Method: `POST /api/calc/pesi`
Max items: 25
Price: unit_amount * n (unit 5000 atomic)
Status: PREVIEW

- 1 to 25 items. Each item uses the same keys as the GET query parameters.
- The first invalid item fails the whole request (index in the 400 JSON). You are not charged.
- HTTP 200 is {count, path, items}. Each items[i] is the GET 200 body for that row.
- Catalog misses (empty matches, found=false) stay paid 200s inside that slot.
- x402 resource URL is this path plus n and body_sha256. Browsers that prefer text/html get the same paywall as GET; Pay retries POST with the same items.

Example request:

```json
{
  "items": [
    {
      "age": "50",
      "altered_mentation": "false",
      "cancer": "false",
      "chronic_lung_disease": "false",
      "heart_failure": "false",
      "heart_rate_bpm": "80",
      "respiratory_rate": "16",
      "sex": "female",
      "spo2_percent": "96",
      "systolic_mm_hg": "120",
      "temperature_c": "37.0"
    },
    {
      "age": "50",
      "altered_mentation": "false",
      "cancer": "false",
      "chronic_lung_disease": "false",
      "heart_failure": "false",
      "heart_rate_bpm": "80",
      "respiratory_rate": "16",
      "sex": "female",
      "spo2_percent": "96",
      "systolic_mm_hg": "120",
      "temperature_c": "37.0"
    }
  ]
}
```

Human paywall (two-item fixture): https://api.magentlab.com/paywall/bulk/pesi

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/pesi",
  "items": [
    {
      "components": [
        {
          "value": 50,
          "factor": "age",
          "points": 50,
          "present": true
        },
        {
          "value": "female",
          "factor": "male_sex",
          "points": 0,
          "present": false
        },
        {
          "factor": "cancer",
          "points": 0,
          "present": false
        },
        {
          "factor": "heart_failure",
          "points": 0,
          "present": false
        },
        {
          "factor": "chronic_lung_disease",
          "points": 0,
          "present": false
        },
        {
          "value": 80,
          "factor": "heart_rate_ge_110",
          "points": 0,
          "present": false
        },
        {
          "value": 120.0,
          "factor": "systolic_mm_hg_lt_100",
          "points": 0,
          "present": false
        },
        {
          "value": 16,
          "factor": "respiratory_rate_ge_30",
          "points": 0,
          "present": false
        },
        {
          "value": 37.0,
          "factor": "temperature_lt_36",
          "points": 0,
          "present": false
        },
        {
          "factor": "altered_mentation",
          "points": 0,
          "present": false
        },
        {
          "value": 96.0,
          "factor": "spo2_lt_90",
          "points": 0,
          "present": false
        }
      ],
      "disclaimer": "Not a medical device. Deterministic published-formula or published-code output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
      "citation": {
        "authors": "Aujesky D, Obrosky DS, Stone RA, et al.",
        "doi": "10.1164/rccm.200506-862OC",
        "id": "aujesky-2005",
        "source": "Am J Respir Crit Care Med. 2005;172(8):1041-1046",
        "title": "Derivation and validation of a prognostic model for pulmonary embolism"
      },
      "formula": "pesi",
      "formula_expression": "PESI = age_in_years + 10*male + 30*cancer + 10*heart_failure + 10*chronic_lung_disease + 20*(HR>=110) + 30*(SBP<100) + 20*(RR>=30) + 20*(temp<36) + 60*altered_mentation + 20*(SpO2<90); classes I <=65, II 66-85, III 86-105, IV 106-125, V >125",
      "score": 50,
      "age_years": 50,
      "pesi_class": "I"
    },
    {
      "components": [
        {
          "value": 50,
          "factor": "age",
          "points": 50,
          "present": true
        },
        {
          "value": "female",
          "factor": "male_sex",
          "points": 0,
          "present": false
        },
        {
          "factor": "cancer",
          "points": 0,
          "present": false
        },
        {
          "factor": "heart_failure",
          "points": 0,
          "present": false
        },
        {
          "factor": "chronic_lung_disease",
          "points": 0,
          "present": false
        },
        {
          "value": 80,
          "factor": "heart_rate_ge_110",
          "points": 0,
          "present": false
        },
        {
          "value": 120.0,
          "factor": "systolic_mm_hg_lt_100",
          "points": 0,
          "present": false
        },
        {
          "value": 16,
          "factor": "respiratory_rate_ge_30",
          "points": 0,
          "present": false
        },
        {
          "value": 37.0,
          "factor": "temperature_lt_36",
          "points": 0,
          "present": false
        },
        {
          "factor": "altered_mentation",
          "points": 0,
          "present": false
        },
        {
          "value": 96.0,
          "factor": "spo2_lt_90",
          "points": 0,
          "present": false
        }
      ],
      "disclaimer": "Not a medical device. Deterministic published-formula or published-code output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
      "citation": {
        "authors": "Aujesky D, Obrosky DS, Stone RA, et al.",
        "doi": "10.1164/rccm.200506-862OC",
        "id": "aujesky-2005",
        "source": "Am J Respir Crit Care Med. 2005;172(8):1041-1046",
        "title": "Derivation and validation of a prognostic model for pulmonary embolism"
      },
      "formula": "pesi",
      "formula_expression": "PESI = age_in_years + 10*male + 30*cancer + 10*heart_failure + 10*chronic_lung_disease + 20*(HR>=110) + 30*(SBP<100) + 20*(RR>=30) + 20*(temp<36) + 60*altered_mentation + 20*(SpO2<90); classes I <=65, II 66-85, III 86-105, IV 106-125, V >125",
      "score": 50,
      "age_years": 50,
      "pesi_class": "I"
    }
  ]
}
```

## Response fields

- `formula` (string): pesi
- `formula_expression` (string): Exact expression used
- `score` (integer): Total points (age in years plus weights)
- `pesi_class` (string): I if score ≤65; II 66-85; III 86-105; IV 106-125; V if >125
- `age_years` (integer): Age added as points
- `components` (array): Per-factor points
- `citation` (object): Aujesky 2005 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 50,
      "factor": "age",
      "points": 50,
      "present": true
    },
    {
      "value": "female",
      "factor": "male_sex",
      "points": 0,
      "present": false
    },
    {
      "factor": "cancer",
      "points": 0,
      "present": false
    },
    {
      "factor": "heart_failure",
      "points": 0,
      "present": false
    },
    {
      "factor": "chronic_lung_disease",
      "points": 0,
      "present": false
    },
    {
      "value": 80,
      "factor": "heart_rate_ge_110",
      "points": 0,
      "present": false
    },
    {
      "value": 120.0,
      "factor": "systolic_mm_hg_lt_100",
      "points": 0,
      "present": false
    },
    {
      "value": 16,
      "factor": "respiratory_rate_ge_30",
      "points": 0,
      "present": false
    },
    {
      "value": 37.0,
      "factor": "temperature_lt_36",
      "points": 0,
      "present": false
    },
    {
      "factor": "altered_mentation",
      "points": 0,
      "present": false
    },
    {
      "value": 96.0,
      "factor": "spo2_lt_90",
      "points": 0,
      "present": false
    }
  ],
  "disclaimer": "Not a medical device. Deterministic published-formula or published-code output for autonomous agents. A licensed clinician remains responsible for patient care and billing submissions.",
  "citation": {
    "authors": "Aujesky D, Obrosky DS, Stone RA, et al.",
    "doi": "10.1164/rccm.200506-862OC",
    "id": "aujesky-2005",
    "source": "Am J Respir Crit Care Med. 2005;172(8):1041-1046",
    "title": "Derivation and validation of a prognostic model for pulmonary embolism"
  },
  "formula": "pesi",
  "formula_expression": "PESI = age_in_years + 10*male + 30*cancer + 10*heart_failure + 10*chronic_lung_disease + 20*(HR>=110) + 30*(SBP<100) + 20*(RR>=30) + 20*(temp<36) + 60*altered_mentation + 20*(SpO2<90); classes I <=65, II 66-85, III 86-105, IV 106-125, V >125",
  "score": 50,
  "age_years": 50,
  "pesi_class": "I"
}
```

## Errors

- HTTP 400 `invalid_age`: age must be an integer from 18 to 120 Returned before settlement; you are not charged.
- HTTP 400 `invalid_sex`: sex must be female or male Returned before settlement; you are not charged.
- HTTP 400 `invalid_flag`: boolean clinical flags must be true or false Returned before settlement; you are not charged.
- HTTP 400 `invalid_heart_rate`: heart_rate_bpm must be an integer from 30 to 220 Returned before settlement; you are not charged.
- HTTP 400 `invalid_systolic_bp`: systolic_mm_hg or systolic_bp_mm_hg must be a number from 50 to 250. Returned before settlement; you are not charged.
- HTTP 400 `invalid_respiratory_rate`: respiratory_rate must be an integer from 4 to 80. Returned before settlement; you are not charged.
- HTTP 400 `invalid_temperature`: temperature_c must be a number from 30.0 to 45.0. Returned before settlement; you are not charged.
- HTTP 400 `invalid_spo2`: spo2_percent must be a number from 50 to 100. Returned before settlement; you are not charged.
- HTTP 400 `invalid_items`: POST body must be a JSON object with only an items array Returned before settlement; you are not charged.
- HTTP 400 `invalid_item_count`: items must be an array of 1 to 25 objects Returned before settlement; you are not charged.
- HTTP 400 `invalid_item`: each items entry must be a JSON object Returned before settlement; you are not charged.

Shared HTTP 402 and 503: https://magentlab.com/docs/payments

## Related tools

- [sPESI](https://magentlab.com/docs/spesi) — Compute the Jiménez 2010 simplified Pulmonary Embolism Severity Index (sPESI) from age and five caller-assigned findings.
- [PERC rule](https://magentlab.com/docs/perc) — Apply the Kline 2004 eight-factor pulmonary embolism rule-out criteria and return whether all eight are met (PERC-negative).

## Payment

Required query parameters must be present and valid. Invalid params return HTTP 400 JSON before settlement. magent does not charge. Fix the params, then request a new 402 quote for that complete URL. Catalog misses (empty matches, found=false) are valid paid 200s.

- GET the tool with Accept: application/json (do not send Accept: text/html unless you want the human paywall).
- HTTP 402 means you have not paid. Decode the base64 PAYMENT-REQUIRED header. HTTP 503 is not a new quote.
- Sign EIP-3009 (scheme exact, assetTransferMethod eip3009) with validBefore = now + accepts[0].maxTimeoutSeconds (600 seconds). That window starts when you sign and must cover wallet confirmation plus CDP verify and settle. Magent retries transient facilitator 429/5xx before answering. Do not send upto or batch-settlement payloads; magent does not offer those schemes.
- Retry the same URL with PAYMENT-SIGNATURE (base64 JSON echoing accepted, payload, and extensions when present).
- Success is HTTP 200 JSON plus PAYMENT-RESPONSE. Settlement happens before the tool runs. HTTP 503 settlement_uncertain or settle_failed: retry the same PAYMENT-SIGNATURE. Mint a new nonce only after a new HTTP 402.

- offered `exact` on eip155:8453: Fixed-price USDC on Base. The buyer authorizes the advertised amount (EIP-3009). magent settles before the tool runs (paymentFlow upfront). extra.assetTransferMethod=eip3009 extra.paymentFlow=upfront.

- not offered `upto`: Not offered. Usage-based: buyer authorizes a ceiling, seller settles the actual amount after work. Reserved for a future metered tool. Not for current calculators or code search.
- not offered `batch-settlement`: Not offered. Payment-channel vouchers claimed later in batches. Not the same as POST {items} bulk (that is still exact).

Same-path POST {items} is still scheme exact: one EIP-3009 authorization for n times the GET unit. That is not x402 batch-settlement (payment channels / vouchers).

Shared HTTP 402 and 503 table: https://magentlab.com/docs/payments

Stdio MCP (one process per host): https://magentlab.com/docs/mcp

## Guarantees

- Invalid query parameters return HTTP 400 before settlement. You are not charged.
- Settlement finishes before the tool executes (paymentFlow upfront). Uncertain or failed settlement fails closed (HTTP 503). Retry the same PAYMENT-SIGNATURE.
- HTTP 402 is unpaid only. Do not sign a second authorization because of a 503.
- Execution is timeout-bounded and concurrency-capped.
- Calculator inputs are stored encrypted for allowlisted operators (Magent Console). They are not in public logs, SSH lookups, catalog, or rollups. Request logs store path without query.
