# APACHE II severity of disease classification

APACHE II

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

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

## What it computes

Compute the Knaus 1985 APACHE II integer from 12 Acute Physiology Score items, age points, and chronic-health points.

## When to use

When an agent needs the published Knaus 1985 integer classification and must not invent APACHE III/IV points or a hospital-death percentage.

## When not to use

- Not a medical device. magent does not measure vitals and does not examine the patient.
- Each APS item is the worst value in 24 hours as assigned by the caller. magent does not choose the worst from a time series.
- Not APACHE III or APACHE IV. Table 1 bands only.
- Does not compute predicted death risk. The Knaus 1985 logistic equation needs diagnostic category weights that this tool does not accept.
- Venous HCO3 substitution from Table 1 is not accepted; arterial_ph is required.
- Oxygenation uses A-aDO2 when fio2 ≥ 0.5 and PaO2 when fio2 < 0.5. The unused gas parameter is ignored. magent does not compute A-aDO2.
- chronic_health is the paper's severe organ insufficiency or immunocompromise as assigned by the caller. elective_postop must be false when chronic_health is false.

## Formula

```
APACHE II = APS + age_points + chronic_health_points; APS is the sum of 12 Knaus 1985 Table 1 items (worst values in 24h as assigned by the caller): temperature_c, map_mm_hg, heart_rate, respiratory_rate, oxygenation (A-aDO2 if fio2 >= 0.5, PaO2 if fio2 < 0.5), arterial_ph, sodium_mmol_l, potassium_mmol_l, creatinine_mg_dl (doubled if acute_renal_failure), hematocrit_percent, wbc_k_ul, and 15-gcs; age <=44 → 0, 45-54 → 2, 55-64 → 3, 65-74 → 5, >=75 → 6; chronic health 0 if none, else +5 nonoperative or emergency postoperative or +2 elective postoperative; max 71
```

## Citation

[APACHE II: a severity of disease classification system](https://doi.org/10.1097/00003246-198510000-00009)
Knaus WA, Draper EA, Wagner DP, Zimmerman JE
Crit Care Med. 1985;13(10):818-829
DOI: [10.1097/00003246-198510000-00009](https://doi.org/10.1097/00003246-198510000-00009)

## Worked example

### All-normal APS, age 40, no chronic health

Given: `acute_renal_failure=false, age=40, arterial_ph=7.40, chronic_health=false, creatinine_mg_dl=1.0, elective_postop=false, fio2=0.21, gcs=15, heart_rate=80, hematocrit_percent=40, map_mm_hg=90, pao2_mm_hg=90, potassium_mmol_l=4.0, respiratory_rate=16, sodium_mmol_l=140, temperature_c=37.0, wbc_k_ul=8.0`

1. Each of the 12 APS rows is in a 0-point Table 1 band (PaO2 90 with FiO2 0.21; GCS 15 → 0)
2. Age 40 → 0; no chronic health → 0
3. Score = 0 (max 71)


### Age 50 only

Given: `acute_renal_failure=false, age=50, arterial_ph=7.40, chronic_health=false, creatinine_mg_dl=1.0, elective_postop=false, fio2=0.21, gcs=15, heart_rate=80, hematocrit_percent=40, map_mm_hg=90, pao2_mm_hg=90, potassium_mmol_l=4.0, respiratory_rate=16, sodium_mmol_l=140, temperature_c=37.0, wbc_k_ul=8.0`

1. APS remains 0
2. Age 45-54 → 2; no chronic health → 0
3. Score = 2 (max 71)


## Also searched as

- APACHE II
- Acute Physiology and Chronic Health Evaluation II
- APACHE 2 score
- Knaus APACHE II
- ICU severity of disease score
- acute physiology score APACHE

## Parameters

- `temperature_c` (number, required): Rectal temperature in °C (20-46) as assigned by the caller (Knaus 1985 Table 1). ≥41 → 4; 39-40.9 → 3; 38.5-38.9 → 1; 36-38.4 → 0; 34-35.9 → 1; 32-33.9 → 2; 30-31.9 → 3; ≤29.9 → 4. magent does not measure temperature or convert Fahrenheit.
- `map_mm_hg` (number, required): Mean arterial pressure in mm Hg (20-250). ≥160 → 4; 130-159 → 3; 110-129 → 2; 70-109 → 0; 50-69 → 2; ≤49 → 4. magent does not measure blood pressure.
- `heart_rate` (integer, required): Heart rate, ventricular response, integer 20-250. ≥180 → 4; 140-179 → 3; 110-139 → 2; 70-109 → 0; 55-69 → 2; 40-54 → 3; ≤39 → 4.
- `respiratory_rate` (integer, required): Respiratory rate, non-ventilated or ventilated, integer 0-80. ≥50 → 4; 35-49 → 3; 25-34 → 1; 12-24 → 0; 10-11 → 1; 6-9 → 2; ≤5 → 4.
- `fio2` (number, required): Inspired oxygen as a fraction 0.21-1.00, not a percent. If fio2 ≥ 0.5, oxygenation uses aa_gradient. If fio2 < 0.5, oxygenation uses pao2_mm_hg. The unused gas parameter is ignored.
- `aa_gradient` (number, optional): A-aDO2 in mm Hg (0-800). Required when fio2 ≥ 0.5. ≥500 → 4; 350-499 → 3; 200-349 → 2; <200 → 0. Ignored when fio2 < 0.5. magent does not compute A-aDO2 from PaO2.
- `pao2_mm_hg` (number, optional): Arterial PaO2 in mm Hg (20-700). Required when fio2 < 0.5. >70 → 0; 61-70 → 1; 55-60 → 3; <55 → 4. Ignored when fio2 ≥ 0.5.
- `arterial_ph` (number, required): Arterial pH (6.5-8.0). ≥7.70 → 4; 7.60-7.69 → 3; 7.50-7.59 → 1; 7.33-7.49 → 0; 7.25-7.32 → 2; 7.15-7.24 → 3; <7.15 → 4. Venous HCO3 substitution from Table 1 is not accepted.
- `sodium_mmol_l` (number, required): Serum sodium in mmol/L (90-200). ≥180 → 4; 160-179 → 3; 155-159 → 2; 150-154 → 1; 130-149 → 0; 120-129 → 2; 111-119 → 3; ≤110 → 4.
- `potassium_mmol_l` (number, required): Serum potassium in mmol/L (1-12). ≥7.0 → 4; 6.0-6.9 → 3; 5.5-5.9 → 1; 3.5-5.4 → 0; 3.0-3.4 → 1; 2.5-2.9 → 2; <2.5 → 4.
- `creatinine_mg_dl` (number, required): Serum creatinine in mg/dL (0.1-20). ≥3.5 → 4; 2.0-3.4 → 3; 1.5-1.9 → 2; 0.6-1.4 → 0; <0.6 → 2. Double that row when acute_renal_failure is true.
- `hematocrit_percent` (number, required): Hematocrit percent (5-80). ≥60 → 4; 50-59.9 → 2; 46-49.9 → 1; 30-45.9 → 0; 20-29.9 → 2; <20 → 4.
- `wbc_k_ul` (number, required): White blood count in thousands per mm^3 (0.1-100). ≥40 → 4; 20-39.9 → 2; 15-19.9 → 1; 3-14.9 → 0; 1-2.9 → 2; <1 → 4.
- `gcs` (integer, required): Glasgow Coma Scale total as assigned by the caller (integer 3-15). APS GCS points = 15 minus gcs. magent does not examine the patient.
- `age` (integer, required): Age in years, integer 16-120. ≤44 → 0; 45-54 → 2; 55-64 → 3; 65-74 → 5; ≥75 → 6.
- `chronic_health` (boolean, required): true if the caller assigns severe organ insufficiency or immunocompromise as defined in Knaus 1985. false → 0 chronic-health points and elective_postop must be false.
- `elective_postop` (boolean, required): true only for elective postoperative patients with chronic_health true (+2). false with chronic_health true is nonoperative or emergency postoperative (+5). Must be false when chronic_health is false.
- `acute_renal_failure` (boolean, required): true doubles the creatinine Table 1 points (Knaus 1985). false leaves creatinine points unchanged. magent does not diagnose renal failure.

## 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/apache_ii`
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": [
    {
      "acute_renal_failure": "false",
      "age": "40",
      "arterial_ph": "7.40",
      "chronic_health": "false",
      "creatinine_mg_dl": "1.0",
      "elective_postop": "false",
      "fio2": "0.21",
      "gcs": "15",
      "heart_rate": "80",
      "hematocrit_percent": "40",
      "map_mm_hg": "90",
      "pao2_mm_hg": "90",
      "potassium_mmol_l": "4.0",
      "respiratory_rate": "16",
      "sodium_mmol_l": "140",
      "temperature_c": "37.0",
      "wbc_k_ul": "8.0"
    },
    {
      "acute_renal_failure": "false",
      "age": "40",
      "arterial_ph": "7.40",
      "chronic_health": "false",
      "creatinine_mg_dl": "1.0",
      "elective_postop": "false",
      "fio2": "0.21",
      "gcs": "15",
      "heart_rate": "80",
      "hematocrit_percent": "40",
      "map_mm_hg": "90",
      "pao2_mm_hg": "90",
      "potassium_mmol_l": "4.0",
      "respiratory_rate": "16",
      "sodium_mmol_l": "140",
      "temperature_c": "37.0",
      "wbc_k_ul": "8.0"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/apache_ii",
  "items": [
    {
      "components": [
        {
          "value": 37.0,
          "factor": "temperature_c",
          "points": 0,
          "present": false
        },
        {
          "value": 90.0,
          "factor": "map_mm_hg",
          "points": 0,
          "present": false
        },
        {
          "value": 80,
          "factor": "heart_rate",
          "points": 0,
          "present": false
        },
        {
          "value": 16,
          "factor": "respiratory_rate",
          "points": 0,
          "present": false
        },
        {
          "value": 90.0,
          "factor": "oxygenation",
          "branch": "pao2_mm_hg",
          "points": 0,
          "fio2": 0.21,
          "present": false
        },
        {
          "value": 7.4,
          "factor": "arterial_ph",
          "points": 0,
          "present": false
        },
        {
          "value": 140.0,
          "factor": "sodium_mmol_l",
          "points": 0,
          "present": false
        },
        {
          "value": 4.0,
          "factor": "potassium_mmol_l",
          "points": 0,
          "present": false
        },
        {
          "value": 1.0,
          "factor": "creatinine_mg_dl",
          "points": 0,
          "present": false,
          "acute_renal_failure": false
        },
        {
          "value": 40.0,
          "factor": "hematocrit_percent",
          "points": 0,
          "present": false
        },
        {
          "value": 8.0,
          "factor": "wbc_k_ul",
          "points": 0,
          "present": false
        },
        {
          "value": 15,
          "factor": "gcs",
          "points": 0,
          "present": false
        },
        {
          "value": 40,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "factor": "chronic_health",
          "points": 0,
          "present": false,
          "chronic_health": false,
          "elective_postop": 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": "Knaus WA, Draper EA, Wagner DP, Zimmerman JE",
        "doi": "10.1097/00003246-198510000-00009",
        "id": "knaus-1985",
        "pmid": "3928249",
        "source": "Crit Care Med. 1985;13(10):818-829",
        "title": "APACHE II: a severity of disease classification system"
      },
      "formula": "apache_ii",
      "formula_expression": "APACHE II = APS + age_points + chronic_health_points; APS is the sum of 12 Knaus 1985 Table 1 items (worst values in 24h as assigned by the caller): temperature_c, map_mm_hg, heart_rate, respiratory_rate, oxygenation (A-aDO2 if fio2 >= 0.5, PaO2 if fio2 < 0.5), arterial_ph, sodium_mmol_l, potassium_mmol_l, creatinine_mg_dl (doubled if acute_renal_failure), hematocrit_percent, wbc_k_ul, and 15-gcs; age <=44 → 0, 45-54 → 2, 55-64 → 3, 65-74 → 5, >=75 → 6; chronic health 0 if none, else +5 nonoperative or emergency postoperative or +2 elective postoperative; max 71",
      "max_score": 71,
      "score": 0
    },
    {
      "components": [
        {
          "value": 37.0,
          "factor": "temperature_c",
          "points": 0,
          "present": false
        },
        {
          "value": 90.0,
          "factor": "map_mm_hg",
          "points": 0,
          "present": false
        },
        {
          "value": 80,
          "factor": "heart_rate",
          "points": 0,
          "present": false
        },
        {
          "value": 16,
          "factor": "respiratory_rate",
          "points": 0,
          "present": false
        },
        {
          "value": 90.0,
          "factor": "oxygenation",
          "branch": "pao2_mm_hg",
          "points": 0,
          "fio2": 0.21,
          "present": false
        },
        {
          "value": 7.4,
          "factor": "arterial_ph",
          "points": 0,
          "present": false
        },
        {
          "value": 140.0,
          "factor": "sodium_mmol_l",
          "points": 0,
          "present": false
        },
        {
          "value": 4.0,
          "factor": "potassium_mmol_l",
          "points": 0,
          "present": false
        },
        {
          "value": 1.0,
          "factor": "creatinine_mg_dl",
          "points": 0,
          "present": false,
          "acute_renal_failure": false
        },
        {
          "value": 40.0,
          "factor": "hematocrit_percent",
          "points": 0,
          "present": false
        },
        {
          "value": 8.0,
          "factor": "wbc_k_ul",
          "points": 0,
          "present": false
        },
        {
          "value": 15,
          "factor": "gcs",
          "points": 0,
          "present": false
        },
        {
          "value": 40,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "factor": "chronic_health",
          "points": 0,
          "present": false,
          "chronic_health": false,
          "elective_postop": 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": "Knaus WA, Draper EA, Wagner DP, Zimmerman JE",
        "doi": "10.1097/00003246-198510000-00009",
        "id": "knaus-1985",
        "pmid": "3928249",
        "source": "Crit Care Med. 1985;13(10):818-829",
        "title": "APACHE II: a severity of disease classification system"
      },
      "formula": "apache_ii",
      "formula_expression": "APACHE II = APS + age_points + chronic_health_points; APS is the sum of 12 Knaus 1985 Table 1 items (worst values in 24h as assigned by the caller): temperature_c, map_mm_hg, heart_rate, respiratory_rate, oxygenation (A-aDO2 if fio2 >= 0.5, PaO2 if fio2 < 0.5), arterial_ph, sodium_mmol_l, potassium_mmol_l, creatinine_mg_dl (doubled if acute_renal_failure), hematocrit_percent, wbc_k_ul, and 15-gcs; age <=44 → 0, 45-54 → 2, 55-64 → 3, 65-74 → 5, >=75 → 6; chronic health 0 if none, else +5 nonoperative or emergency postoperative or +2 elective postoperative; max 71",
      "max_score": 71,
      "score": 0
    }
  ]
}
```

## Response fields

- `formula` (string): apache_ii
- `formula_expression` (string): Exact expression used
- `score` (integer): APACHE II integer 0-71
- `max_score` (integer): Always 71
- `components` (array): Twelve APS rows plus age and chronic health
- `citation` (object): Knaus 1985 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 37.0,
      "factor": "temperature_c",
      "points": 0,
      "present": false
    },
    {
      "value": 90.0,
      "factor": "map_mm_hg",
      "points": 0,
      "present": false
    },
    {
      "value": 80,
      "factor": "heart_rate",
      "points": 0,
      "present": false
    },
    {
      "value": 16,
      "factor": "respiratory_rate",
      "points": 0,
      "present": false
    },
    {
      "value": 90.0,
      "factor": "oxygenation",
      "branch": "pao2_mm_hg",
      "points": 0,
      "fio2": 0.21,
      "present": false
    },
    {
      "value": 7.4,
      "factor": "arterial_ph",
      "points": 0,
      "present": false
    },
    {
      "value": 140.0,
      "factor": "sodium_mmol_l",
      "points": 0,
      "present": false
    },
    {
      "value": 4.0,
      "factor": "potassium_mmol_l",
      "points": 0,
      "present": false
    },
    {
      "value": 1.0,
      "factor": "creatinine_mg_dl",
      "points": 0,
      "present": false,
      "acute_renal_failure": false
    },
    {
      "value": 40.0,
      "factor": "hematocrit_percent",
      "points": 0,
      "present": false
    },
    {
      "value": 8.0,
      "factor": "wbc_k_ul",
      "points": 0,
      "present": false
    },
    {
      "value": 15,
      "factor": "gcs",
      "points": 0,
      "present": false
    },
    {
      "value": 40,
      "factor": "age",
      "points": 0,
      "present": false
    },
    {
      "factor": "chronic_health",
      "points": 0,
      "present": false,
      "chronic_health": false,
      "elective_postop": 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": "Knaus WA, Draper EA, Wagner DP, Zimmerman JE",
    "doi": "10.1097/00003246-198510000-00009",
    "id": "knaus-1985",
    "pmid": "3928249",
    "source": "Crit Care Med. 1985;13(10):818-829",
    "title": "APACHE II: a severity of disease classification system"
  },
  "formula": "apache_ii",
  "formula_expression": "APACHE II = APS + age_points + chronic_health_points; APS is the sum of 12 Knaus 1985 Table 1 items (worst values in 24h as assigned by the caller): temperature_c, map_mm_hg, heart_rate, respiratory_rate, oxygenation (A-aDO2 if fio2 >= 0.5, PaO2 if fio2 < 0.5), arterial_ph, sodium_mmol_l, potassium_mmol_l, creatinine_mg_dl (doubled if acute_renal_failure), hematocrit_percent, wbc_k_ul, and 15-gcs; age <=44 → 0, 45-54 → 2, 55-64 → 3, 65-74 → 5, >=75 → 6; chronic health 0 if none, else +5 nonoperative or emergency postoperative or +2 elective postoperative; max 71",
  "max_score": 71,
  "score": 0
}
```

## Errors

- HTTP 400 `invalid_apache_ii`: apache_ii must be an integer from 0 to 71 (Heyland 2011 NUTRIC); APACHE II needs Knaus 1985 physiologic, age, and chronic-health integers in published ranges. 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

- [SOFA](https://magentlab.com/docs/sofa) — Compute the Vincent 1996 SOFA score from PaO2/FiO2, platelets, bilirubin, MAP and adrenergic agents, GCS, and creatinine or urine output.
- [qSOFA](https://magentlab.com/docs/qsofa) — Compute the Sepsis-3 qSOFA score from respiratory rate, caller-assigned altered mentation, and systolic blood pressure.
- [SIRS](https://magentlab.com/docs/sirs) — Compute the Bone 1992 ACCP/SCCM SIRS criteria from temperature, heart rate, respiratory rate, and WBC, with optional PaCO2 and band percent.

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