# DECAF score

DECAF

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

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

## What it computes

Sum Steer 2012 DECAF points from extended MRC dyspnoea, eosinophils, chest radiograph consolidation, arterial pH, and atrial fibrillation.

## When to use

When an agent needs the published Steer 2012 DECAF total and band and must not invent an early-discharge or escalation decision or a mortality percent.

## When not to use

- Not a medical device. Not an early-discharge or escalation protocol. Bands follow Steer 2012 (0-1 / 2 / 3-6) and do not include mortality percents.
- eMRCD is the caller-assigned extended MRC grade 1-4, 5a, or 5b. magent does not interview the patient.
- Consolidation and atrial fibrillation are caller-assigned flags. magent does not interpret the chest radiograph or ECG.

## Formula

```
DECAF = emrcd_points + eosinopenia + consolidation + acidemia + atrial_fibrillation; eMRCD 1-4 -> 0, 5a -> 1, 5b -> 2; eosinophils_10e9_l < 0.05 -> 1 (0.05 does not score); consolidation true -> 1; arterial_ph < 7.30 -> 1 (7.30 does not score); atrial_fibrillation true -> 1; bands 0-1 / 2 / 3-6; max 6
```

## Citation

[The DECAF Score: predicting hospital mortality in exacerbations of chronic obstructive pulmonary disease](https://doi.org/10.1136/thoraxjnl-2012-202103)
Steer J, Gibson J, Bourke SC
Thorax. 2012;67(11):970-976
DOI: [10.1136/thoraxjnl-2012-202103](https://doi.org/10.1136/thoraxjnl-2012-202103)

## Worked example

### No DECAF points (band 0-1)

Given: `arterial_ph=7.40, atrial_fibrillation=false, consolidation=false, emrcd=1-4, eosinophils_10e9_l=0.10`

1. eMRCD 1-4 → 0; eosinophils 0.10 ≥0.05 → 0; no consolidation → 0; pH 7.40 ≥7.30 → 0; no AF → 0
2. Score = 0; band 0-1


### Maximum points (band 3-6)

Given: `arterial_ph=7.20, atrial_fibrillation=true, consolidation=true, emrcd=5b, eosinophils_10e9_l=0.02`

1. eMRCD 5b → 2; eosinophils 0.02 <0.05 → 1; consolidation → 1; pH 7.20 <7.30 → 1; AF → 1
2. Score = 6; band 3-6


## Also searched as

- DECAF score
- Steer DECAF
- COPD exacerbation DECAF
- eMRCD DECAF
- extended MRC DECAF
- dyspnoea eosinopenia consolidation
- COPD hospital mortality score

## Parameters

- `emrcd` (string, required): Steer 2012 extended MRC dyspnoea as assigned by the caller. 1-4 scores 0; 5a scores 1; 5b scores 2. magent does not interview the patient.
- `eosinophils_10e9_l` (number, required): Blood eosinophil count ×10^9/L (0-5). Steer 2012: <0.05 scores 1; 0.05 does not score.
- `consolidation` (boolean, required): Chest radiograph consolidation as assigned by the caller (Steer 2012 C). true or false. 1 point if true. magent does not interpret radiographs.
- `arterial_ph` (number, required): Arterial pH (6.80-7.80). Steer 2012: <7.30 scores 1; 7.30 does not score.
- `atrial_fibrillation` (boolean, required): Atrial fibrillation as assigned by the caller (Steer 2012 F). true or false. 1 point if true. magent does not interpret the ECG.

## 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/decaf`
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": [
    {
      "arterial_ph": "7.40",
      "atrial_fibrillation": "false",
      "consolidation": "false",
      "emrcd": "1-4",
      "eosinophils_10e9_l": "0.10"
    },
    {
      "arterial_ph": "7.40",
      "atrial_fibrillation": "false",
      "consolidation": "false",
      "emrcd": "1-4",
      "eosinophils_10e9_l": "0.10"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/decaf",
  "items": [
    {
      "components": [
        {
          "value": "1-4",
          "factor": "emrcd",
          "points": 0,
          "present": false
        },
        {
          "value": 0.1,
          "factor": "eosinopenia",
          "points": 0,
          "present": false
        },
        {
          "factor": "consolidation",
          "points": 0,
          "present": false
        },
        {
          "value": 7.4,
          "factor": "acidemia",
          "points": 0,
          "present": false
        },
        {
          "factor": "atrial_fibrillation",
          "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": "Steer J, Gibson J, Bourke SC",
        "doi": "10.1136/thoraxjnl-2012-202103",
        "id": "steer-2012",
        "pmid": "22895999",
        "source": "Thorax. 2012;67(11):970-976",
        "title": "The DECAF Score: predicting hospital mortality in exacerbations of chronic obstructive pulmonary disease"
      },
      "formula": "decaf",
      "formula_expression": "DECAF = emrcd_points + eosinopenia + consolidation + acidemia + atrial_fibrillation; eMRCD 1-4 -> 0, 5a -> 1, 5b -> 2; eosinophils_10e9_l < 0.05 -> 1 (0.05 does not score); consolidation true -> 1; arterial_ph < 7.30 -> 1 (7.30 does not score); atrial_fibrillation true -> 1; bands 0-1 / 2 / 3-6; max 6",
      "max_score": 6,
      "score": 0,
      "atrial_fibrillation": false,
      "arterial_ph": 7.4,
      "consolidation": false,
      "decaf_band": "0-1",
      "emrcd": "1-4",
      "eosinophils_10e9_l": 0.1
    },
    {
      "components": [
        {
          "value": "1-4",
          "factor": "emrcd",
          "points": 0,
          "present": false
        },
        {
          "value": 0.1,
          "factor": "eosinopenia",
          "points": 0,
          "present": false
        },
        {
          "factor": "consolidation",
          "points": 0,
          "present": false
        },
        {
          "value": 7.4,
          "factor": "acidemia",
          "points": 0,
          "present": false
        },
        {
          "factor": "atrial_fibrillation",
          "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": "Steer J, Gibson J, Bourke SC",
        "doi": "10.1136/thoraxjnl-2012-202103",
        "id": "steer-2012",
        "pmid": "22895999",
        "source": "Thorax. 2012;67(11):970-976",
        "title": "The DECAF Score: predicting hospital mortality in exacerbations of chronic obstructive pulmonary disease"
      },
      "formula": "decaf",
      "formula_expression": "DECAF = emrcd_points + eosinopenia + consolidation + acidemia + atrial_fibrillation; eMRCD 1-4 -> 0, 5a -> 1, 5b -> 2; eosinophils_10e9_l < 0.05 -> 1 (0.05 does not score); consolidation true -> 1; arterial_ph < 7.30 -> 1 (7.30 does not score); atrial_fibrillation true -> 1; bands 0-1 / 2 / 3-6; max 6",
      "max_score": 6,
      "score": 0,
      "atrial_fibrillation": false,
      "arterial_ph": 7.4,
      "consolidation": false,
      "decaf_band": "0-1",
      "emrcd": "1-4",
      "eosinophils_10e9_l": 0.1
    }
  ]
}
```

## Response fields

- `formula` (string): decaf
- `formula_expression` (string): Exact Steer 2012 expression
- `score` (integer): DECAF points 0-6
- `max_score` (integer): Always 6
- `decaf_band` (string): Steer 2012 band 0-1 (low), 2 (moderate), or 3-6 (high). A band, not a mortality percent.
- `emrcd` (string): Caller-assigned eMRCD: 1-4, 5a, or 5b
- `eosinophils_10e9_l` (number): Eosinophil count ×10^9/L used
- `consolidation` (boolean): Caller-assigned chest radiograph consolidation
- `arterial_ph` (number): Arterial pH used
- `atrial_fibrillation` (boolean): Caller-assigned atrial fibrillation
- `components` (array): Per-factor points for emrcd, eosinopenia, consolidation, acidemia, and AF
- `citation` (object): Steer et al. Thorax 2012 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": "1-4",
      "factor": "emrcd",
      "points": 0,
      "present": false
    },
    {
      "value": 0.1,
      "factor": "eosinopenia",
      "points": 0,
      "present": false
    },
    {
      "factor": "consolidation",
      "points": 0,
      "present": false
    },
    {
      "value": 7.4,
      "factor": "acidemia",
      "points": 0,
      "present": false
    },
    {
      "factor": "atrial_fibrillation",
      "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": "Steer J, Gibson J, Bourke SC",
    "doi": "10.1136/thoraxjnl-2012-202103",
    "id": "steer-2012",
    "pmid": "22895999",
    "source": "Thorax. 2012;67(11):970-976",
    "title": "The DECAF Score: predicting hospital mortality in exacerbations of chronic obstructive pulmonary disease"
  },
  "formula": "decaf",
  "formula_expression": "DECAF = emrcd_points + eosinopenia + consolidation + acidemia + atrial_fibrillation; eMRCD 1-4 -> 0, 5a -> 1, 5b -> 2; eosinophils_10e9_l < 0.05 -> 1 (0.05 does not score); consolidation true -> 1; arterial_ph < 7.30 -> 1 (7.30 does not score); atrial_fibrillation true -> 1; bands 0-1 / 2 / 3-6; max 6",
  "max_score": 6,
  "score": 0,
  "atrial_fibrillation": false,
  "arterial_ph": 7.4,
  "consolidation": false,
  "decaf_band": "0-1",
  "emrcd": "1-4",
  "eosinophils_10e9_l": 0.1
}
```

## Errors

- HTTP 400 `invalid_emrcd`: emrcd must be 1-4, 5a, or 5b (Steer 2012 extended MRC dyspnoea). Returned before settlement; you are not charged.
- HTTP 400 `invalid_eosinophils`: eosinophils_10e9_l must be a number from 0 to 5 (Steer 2012). Returned before settlement; you are not charged.
- HTTP 400 `invalid_arterial_ph`: arterial_ph must be a number from 6.80 to 7.80. 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

- [BODE](https://magentlab.com/docs/bode) — Sum Celli 2004 BODE points from BMI, FEV1 percent predicted, MMRC dyspnea, and 6-minute walk distance.
- [GAP index](https://magentlab.com/docs/gap-index) — Sum Ley 2012 GAP index points from sex, age, FVC percent predicted, and DLCO percent predicted or cannot-perform.
- [CURB-65](https://magentlab.com/docs/curb65) — Compute the CURB-65 community-acquired pneumonia severity score from age and discrete flags.

## 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 echoing accepted, payload, and extensions when present).
- 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.
- 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.
