# 4PEPS pretest probability (Roy 2021)

4PEPS

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

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

## What it computes

Sum the Roy 2021 Table 3 4-level clinical pretest probability (4PEPS) items and return score and cpp (very_low, low, moderate, or high).

## When to use

When an agent already has the published Table 3 findings assigned and needs the 4PEPS total and clinical probability band, not an imaging or D-dimer order.

## When not to use

- Not a medical device and not an imaging or D-dimer order. magent does not examine the patient or decide “PE most likely”.
- Age 65–80 and >80 were not independently associated in Table 3; ages ≥65 score 0 for the age item. Heart rate 80–100 was not independently associated; this tool does not add tachycardia points.
- Immobility is the Table 3 footnote: surgery, lower limb plaster cast, or bedridden more than 3 days for an acute medical condition within the last 4 weeks, as assigned by the caller.
- Clinical probability cutoffs are Table 3: very_low <0, low 0–5, moderate 6–12, high ≥13. Score may be negative. max_score is 22 when age ≥65 and all positive items fire.

## Formula

```
4PEPS = age (<50 -2, 50-64 -1, ≥65 0) + chronic_respiratory_disease (-1) + heart_rate_bpm (<80 -1) + chest_pain_and_acute_dyspnea (1) + male (2) + hormonal_estrogenic_treatment (2) + personal_history_vte (2) + syncope (2) + immobility_4w (2) + spo2_percent (<95 3) + calf_pain_or_unilateral_edema (3) + pe_most_likely (5); Roy 2021 Table 3; cpp very_low <0, low 0-5, moderate 6-12, high ≥13; max 22 (age ≥65 plus all positive items; score may be negative)
```

## Citation

[Derivation and Validation of a 4-Level Clinical Pretest Probability Score for Suspected Pulmonary Embolism to Safely Decrease Imaging Testing](https://doi.org/10.1001/jamacardio.2021.0064)
Roy PM, Friou E, Germeau B, et al.
JAMA Cardiol. 2021;6(6):669-677
DOI: [10.1001/jamacardio.2021.0064](https://doi.org/10.1001/jamacardio.2021.0064)

## Worked example

### Age 40 female, no other Table 3 items

Given: `age=40, calf_pain_or_unilateral_edema=false, chest_pain_and_acute_dyspnea=false, chronic_respiratory_disease=false, heart_rate_bpm=90, hormonal_estrogenic_treatment=false, immobility_4w=false, pe_most_likely=false, personal_history_vte=false, sex=female, spo2_percent=98, syncope=false`

1. age 40 <50 → −2; heart_rate_bpm 90 is not <80 → 0; spo2_percent 98 is not <95 → 0; female → 0; all flags false
2. Score = −2 (max 22); cpp = very_low


### Age ≥65, male, SpO2 <95, calf finding, PE most likely

Given: `age=65, calf_pain_or_unilateral_edema=true, chest_pain_and_acute_dyspnea=false, chronic_respiratory_disease=false, heart_rate_bpm=90, hormonal_estrogenic_treatment=false, immobility_4w=false, pe_most_likely=true, personal_history_vte=false, sex=male, spo2_percent=90, syncope=false`

1. age ≥65 → 0; male → +2; spo2_percent 90 <95 → +3; calf_pain_or_unilateral_edema → +3; pe_most_likely → +5
2. Score = 13 (max 22); cpp = high


## Also searched as

- 4PEPS
- 4-level PE pretest probability
- Roy 4PEPS
- four-level clinical pretest probability
- 4PEPS pulmonary embolism
- clinical pretest probability PE
- 4-level CPP PE

## Parameters

- `age` (integer, required): Age in years (integer 18-120). Roy 2021 Table 3: <50 scores −2; 50-64 scores −1; ≥65 scores 0 (65-80 and >80 were not independently associated).
- `chronic_respiratory_disease` (boolean, required): Chronic respiratory disease (Roy 2021 Table 3). true scores −1. Assigned by the caller. magent does not examine the patient.
- `heart_rate_bpm` (integer, required): Heart rate in beats per minute (integer 30-220). Table 3: <80 scores −1. 80-100 was not independently associated; this tool does not add tachycardia points.
- `chest_pain_and_acute_dyspnea` (boolean, required): Both chest pain and acute dyspnea present as assigned by the caller (Roy 2021 Table 3). true scores +1. magent does not examine the patient.
- `sex` (string, required): female or male (Roy 2021 Table 3). Male scores +2. Female scores 0. Assigned by the caller.
- `hormonal_estrogenic_treatment` (boolean, required): Hormonal estrogenic treatment as assigned by the caller (Roy 2021 Table 3). true scores +2.
- `personal_history_vte` (boolean, required): Personal history of VTE as assigned by the caller (Roy 2021 Table 3). true scores +2.
- `syncope` (boolean, required): Syncope as assigned by the caller (Roy 2021 Table 3). true scores +2. magent does not examine the patient.
- `immobility_4w` (boolean, required): Immobility within 4 weeks (Roy 2021 Table 3 footnote a): surgery, lower limb plaster cast, or bedridden more than 3 days for an acute medical condition. true scores +2. Assigned by the caller. magent does not examine the patient.
- `spo2_percent` (number, required): Oxygen saturation percent (50-100). Roy 2021 Table 3: <95 scores +3; 95 and above score 0.
- `calf_pain_or_unilateral_edema` (boolean, required): Calf pain and/or unilateral lower-limb edema as assigned by the caller (Roy 2021 Table 3). true scores +3. magent does not examine the patient.
- `pe_most_likely` (boolean, required): PE is the most likely diagnosis as assigned by the caller (Roy 2021 Table 3). true scores +5. magent does not examine the patient or decide PE most likely.

## Bulk (POST)

POST the same path with a JSON items array. The first item is the GET unit; each additional item is $0.002. Invalid items return HTTP 400 before settlement.

Method: `POST /api/calc/4peps`
Max items: 25
Price: unit_amount + extra_item_amount * (n - 1) (unit 5000 atomic, extra 2000 atomic)
Status: PREVIEW

- 1 to 25 items. Each item uses the same keys as the GET query parameters.
- POST of 1 item costs the same as GET. Lists longer than 25: chunk into multiple POSTs. Extra items still execute; do not pad dummy rows.
- 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": "40",
      "calf_pain_or_unilateral_edema": "false",
      "chest_pain_and_acute_dyspnea": "false",
      "chronic_respiratory_disease": "false",
      "heart_rate_bpm": "90",
      "hormonal_estrogenic_treatment": "false",
      "immobility_4w": "false",
      "pe_most_likely": "false",
      "personal_history_vte": "false",
      "sex": "female",
      "spo2_percent": "98",
      "syncope": "false"
    },
    {
      "age": "40",
      "calf_pain_or_unilateral_edema": "false",
      "chest_pain_and_acute_dyspnea": "false",
      "chronic_respiratory_disease": "false",
      "heart_rate_bpm": "90",
      "hormonal_estrogenic_treatment": "false",
      "immobility_4w": "false",
      "pe_most_likely": "false",
      "personal_history_vte": "false",
      "sex": "female",
      "spo2_percent": "98",
      "syncope": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/4peps",
  "items": [
    {
      "components": [
        {
          "value": 40,
          "factor": "age",
          "points": -2,
          "present": true
        },
        {
          "factor": "chronic_respiratory_disease",
          "points": 0,
          "present": false
        },
        {
          "value": 90,
          "factor": "heart_rate_bpm",
          "points": 0,
          "present": false
        },
        {
          "factor": "chest_pain_and_acute_dyspnea",
          "points": 0,
          "present": false
        },
        {
          "value": "female",
          "factor": "sex",
          "points": 0,
          "present": false
        },
        {
          "factor": "hormonal_estrogenic_treatment",
          "points": 0,
          "present": false
        },
        {
          "factor": "personal_history_vte",
          "points": 0,
          "present": false
        },
        {
          "factor": "syncope",
          "points": 0,
          "present": false
        },
        {
          "factor": "immobility_4w",
          "points": 0,
          "present": false
        },
        {
          "value": 98.0,
          "factor": "spo2_percent",
          "points": 0,
          "present": false
        },
        {
          "factor": "calf_pain_or_unilateral_edema",
          "points": 0,
          "present": false
        },
        {
          "factor": "pe_most_likely",
          "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": "Roy PM, Friou E, Germeau B, et al.",
        "doi": "10.1001/jamacardio.2021.0064",
        "id": "roy-2021",
        "pmid": "33656522",
        "source": "JAMA Cardiol. 2021;6(6):669-677",
        "title": "Derivation and Validation of a 4-Level Clinical Pretest Probability Score for Suspected Pulmonary Embolism to Safely Decrease Imaging Testing"
      },
      "formula": "4peps",
      "formula_expression": "4PEPS = age (<50 -2, 50-64 -1, ≥65 0) + chronic_respiratory_disease (-1) + heart_rate_bpm (<80 -1) + chest_pain_and_acute_dyspnea (1) + male (2) + hormonal_estrogenic_treatment (2) + personal_history_vte (2) + syncope (2) + immobility_4w (2) + spo2_percent (<95 3) + calf_pain_or_unilateral_edema (3) + pe_most_likely (5); Roy 2021 Table 3; cpp very_low <0, low 0-5, moderate 6-12, high ≥13; max 22 (age ≥65 plus all positive items; score may be negative)",
      "max_score": 22,
      "score": -2,
      "cpp": "very_low"
    },
    {
      "components": [
        {
          "value": 40,
          "factor": "age",
          "points": -2,
          "present": true
        },
        {
          "factor": "chronic_respiratory_disease",
          "points": 0,
          "present": false
        },
        {
          "value": 90,
          "factor": "heart_rate_bpm",
          "points": 0,
          "present": false
        },
        {
          "factor": "chest_pain_and_acute_dyspnea",
          "points": 0,
          "present": false
        },
        {
          "value": "female",
          "factor": "sex",
          "points": 0,
          "present": false
        },
        {
          "factor": "hormonal_estrogenic_treatment",
          "points": 0,
          "present": false
        },
        {
          "factor": "personal_history_vte",
          "points": 0,
          "present": false
        },
        {
          "factor": "syncope",
          "points": 0,
          "present": false
        },
        {
          "factor": "immobility_4w",
          "points": 0,
          "present": false
        },
        {
          "value": 98.0,
          "factor": "spo2_percent",
          "points": 0,
          "present": false
        },
        {
          "factor": "calf_pain_or_unilateral_edema",
          "points": 0,
          "present": false
        },
        {
          "factor": "pe_most_likely",
          "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": "Roy PM, Friou E, Germeau B, et al.",
        "doi": "10.1001/jamacardio.2021.0064",
        "id": "roy-2021",
        "pmid": "33656522",
        "source": "JAMA Cardiol. 2021;6(6):669-677",
        "title": "Derivation and Validation of a 4-Level Clinical Pretest Probability Score for Suspected Pulmonary Embolism to Safely Decrease Imaging Testing"
      },
      "formula": "4peps",
      "formula_expression": "4PEPS = age (<50 -2, 50-64 -1, ≥65 0) + chronic_respiratory_disease (-1) + heart_rate_bpm (<80 -1) + chest_pain_and_acute_dyspnea (1) + male (2) + hormonal_estrogenic_treatment (2) + personal_history_vte (2) + syncope (2) + immobility_4w (2) + spo2_percent (<95 3) + calf_pain_or_unilateral_edema (3) + pe_most_likely (5); Roy 2021 Table 3; cpp very_low <0, low 0-5, moderate 6-12, high ≥13; max 22 (age ≥65 plus all positive items; score may be negative)",
      "max_score": 22,
      "score": -2,
      "cpp": "very_low"
    }
  ]
}
```

## Response fields

- `formula` (string): 4peps
- `formula_expression` (string): Exact expression used
- `score` (integer): 4PEPS points. May be negative. Theoretical maximum 22 when age ≥65 and all positive items fire.
- `max_score` (integer): Always 22 (age ≥65 plus all positive Table 3 items; score may be negative)
- `cpp` (string): Roy 2021 Table 3 clinical probability: very_low when score <0, low when 0-5, moderate when 6-12, high when ≥13. Not a diagnosis.
- `components` (array): Per-item points
- `citation` (object): Roy 2021 JAMA Cardiology citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 40,
      "factor": "age",
      "points": -2,
      "present": true
    },
    {
      "factor": "chronic_respiratory_disease",
      "points": 0,
      "present": false
    },
    {
      "value": 90,
      "factor": "heart_rate_bpm",
      "points": 0,
      "present": false
    },
    {
      "factor": "chest_pain_and_acute_dyspnea",
      "points": 0,
      "present": false
    },
    {
      "value": "female",
      "factor": "sex",
      "points": 0,
      "present": false
    },
    {
      "factor": "hormonal_estrogenic_treatment",
      "points": 0,
      "present": false
    },
    {
      "factor": "personal_history_vte",
      "points": 0,
      "present": false
    },
    {
      "factor": "syncope",
      "points": 0,
      "present": false
    },
    {
      "factor": "immobility_4w",
      "points": 0,
      "present": false
    },
    {
      "value": 98.0,
      "factor": "spo2_percent",
      "points": 0,
      "present": false
    },
    {
      "factor": "calf_pain_or_unilateral_edema",
      "points": 0,
      "present": false
    },
    {
      "factor": "pe_most_likely",
      "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": "Roy PM, Friou E, Germeau B, et al.",
    "doi": "10.1001/jamacardio.2021.0064",
    "id": "roy-2021",
    "pmid": "33656522",
    "source": "JAMA Cardiol. 2021;6(6):669-677",
    "title": "Derivation and Validation of a 4-Level Clinical Pretest Probability Score for Suspected Pulmonary Embolism to Safely Decrease Imaging Testing"
  },
  "formula": "4peps",
  "formula_expression": "4PEPS = age (<50 -2, 50-64 -1, ≥65 0) + chronic_respiratory_disease (-1) + heart_rate_bpm (<80 -1) + chest_pain_and_acute_dyspnea (1) + male (2) + hormonal_estrogenic_treatment (2) + personal_history_vte (2) + syncope (2) + immobility_4w (2) + spo2_percent (<95 3) + calf_pain_or_unilateral_edema (3) + pe_most_likely (5); Roy 2021 Table 3; cpp very_low <0, low 0-5, moderate 6-12, high ≥13; max 22 (age ≥65 plus all positive items; score may be negative)",
  "max_score": 22,
  "score": -2,
  "cpp": "very_low"
}
```

## 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_heart_rate`: heart_rate_bpm must be an integer from 30 to 220 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_flag`: boolean clinical flags must be true or false 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

- [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).
- [YEARS algorithm](https://magentlab.com/docs/years) — Apply the van der Hulle 2017 YEARS algorithm: count three caller-assigned items and return whether PE is excluded at the published D-dimer threshold.
- [Wells PE](https://magentlab.com/docs/wells-pe) — Compute the Wells pulmonary-embolism probability score and return three-tier and two-tier bands.
- [Revised Geneva score](https://magentlab.com/docs/revised-geneva) — Compute the Le Gal 2006 revised Geneva score for suspected pulmonary embolism in the emergency department from age, heart rate, and six caller-assigned findings.

## Payment

Unpaid requests return HTTP 402 even if query parameters or POST items are missing or invalid, so CDP and agents can index the path. After a PAYMENT-SIGNATURE, 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 accepts[0] (exact, EIP-3009) with validBefore = now + maxTimeoutSeconds (600 seconds), or accepts[1] (batch-settlement deposit/voucher) on product GET. Ping and POST {items} stay exact. Magent retries transient facilitator 429/5xx before answering.
- Retry the same URL with PAYMENT-SIGNATURE (base64 JSON of accepted and payload). Magent attaches canonical extensions.bazaar on CDP verify/settle; echoing 402 bazaar is optional.
- Success is HTTP 200 JSON plus PAYMENT-RESPONSE. exact settles before the tool. batch-settlement verifies (and deposit-settles) before the tool and commits the charge after HTTP 2xx. HTTP 503: retry the same PAYMENT-SIGNATURE. Mint a new exact 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.
- offered `batch-settlement` on eip155:8453: Payment-channel vouchers claimed later in batches. Exact stays accepts[0]. Same-path POST {items} is still exact. extra.assetTransferMethod=eip3009 extra.paymentFlow=authorization.

- 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.

Same-path POST {items} is still scheme exact: one EIP-3009 authorization for GET unit plus $0.002 per extra item. 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

- HTTP 402 is unpaid, including a missing query. After PAYMENT-SIGNATURE, invalid parameters return HTTP 400 before settlement. You are not charged. HTTP 402 never includes the tool JSON.
- exact: settlement finishes before the tool (paymentFlow upfront). batch-settlement: verify/deposit before the tool; chargedCumulativeAmount commits after HTTP 2xx. 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.
