# DKA mortality prediction model (Efstathiou)

DKA-MPM

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

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

## What it computes

Sum the Efstathiou 2002 DKA-MPM flags (max 25) and return the published in-hospital death percents only for scores 0–14 (0.86%) and 19–25 (93.3%).

## When to use

When an agent already has the six Efstathiou 2002 presentation and first-day flags and needs the published point total, not a DKA treatment order, insulin dose, pH or glucose assay, later 72-hour DKA score, or invented percents for scores 15–18.

## When not to use

- Not a medical device and not a DKA treatment, fluid, or insulin-dose order.
- magent does not assay pH or glucose. All six predictors are caller-assigned flags.
- Efstathiou 2002 published in-hospital death of 0.86% for scores 0–14 and 93.3% for scores 19–25. Scores 15–18 return the point total without a percent.
- Does not implement later 72-hour DKA mortality scores. Does not invent Low/High labels or intermediate percents that paper did not publish.

## Formula

```
DKA-MPM = severe_comorbidity 6 + ph_lt_7 4 + insulin_gt_50_12h 4 + glucose_gt_16_7_12h 4 + depressed_mental_24h 4 + fever_24h 3; Efstathiou 2002; max 25; published in-hospital death 0.86% scores 0-14 and 93.3% scores 19-25
```

## Citation

[A mortality prediction model in diabetic ketoacidosis](https://doi.org/10.1046/j.1365-2265.2002.01636.x)
Efstathiou SP, Tsioulos DI, Tsiakou AG, Gratsias YG, Pefanis AV, Mountokalakis TD
Clin Endocrinol (Oxf). 2002;57(5):595-601
DOI: [10.1046/j.1365-2265.2002.01636.x](https://doi.org/10.1046/j.1365-2265.2002.01636.x)

## Worked example

### All flags false (score 0, published 0.86%)

Given: `depressed_mental_24h=false, fever_24h=false, glucose_gt_16_7_12h=false, insulin_gt_50_12h=false, ph_lt_7=false, severe_comorbidity=false`

1. All six Efstathiou 2002 flags false → 0
2. score = 0 (max 25); scores 0-14 publish 0.86% in-hospital death


### Score 18 (no published percent)

Given: `depressed_mental_24h=false, fever_24h=false, glucose_gt_16_7_12h=true, insulin_gt_50_12h=true, ph_lt_7=true, severe_comorbidity=true`

1. severe_comorbidity 6 + ph_lt_7 4 + insulin_gt_50_12h 4 + glucose_gt_16_7_12h 4
2. score = 18 (max 25); scores 15-18 omit observed_mortality_percent


### All flags true (score 25, published 93.3%)

Given: `depressed_mental_24h=true, fever_24h=true, glucose_gt_16_7_12h=true, insulin_gt_50_12h=true, ph_lt_7=true, severe_comorbidity=true`

1. 6 + 4 + 4 + 4 + 4 + 3
2. score = 25 (max 25); scores 19-25 publish 93.3% in-hospital death


## Also searched as

- DKA-MPM
- DKA mortality prediction model
- Efstathiou DKA score
- diabetic ketoacidosis mortality score
- DKA MPM
- Efstathiou 2002
- ketoacidosis mortality prediction

## Parameters

- `severe_comorbidity` (boolean, required): Severe coexisting disease at presentation as assigned by the caller (Efstathiou 2002). true scores 6. true or false. magent does not diagnose comorbidity.
- `ph_lt_7` (boolean, required): Arterial pH < 7.0 at presentation as assigned by the caller (Efstathiou 2002). true scores 4. true or false. magent does not assay pH.
- `insulin_gt_50_12h` (boolean, required): Regular insulin > 50 IU in the first 12 h as assigned by the caller (Efstathiou 2002). true scores 4. true or false. Not an insulin dose. magent does not order insulin.
- `glucose_gt_16_7_12h` (boolean, required): Serum glucose > 16.7 mmol/L after 12 h as assigned by the caller (Efstathiou 2002). true scores 4. true or false. magent does not assay glucose.
- `depressed_mental_24h` (boolean, required): Depressed mental state after 24 h as assigned by the caller (Efstathiou 2002). true scores 4. true or false. magent does not examine the patient.
- `fever_24h` (boolean, required): Fever after 24 h as assigned by the caller (Efstathiou 2002). true scores 3. true or false. magent does not take temperature.

## 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/dka_mpm`
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": [
    {
      "depressed_mental_24h": "false",
      "fever_24h": "false",
      "glucose_gt_16_7_12h": "false",
      "insulin_gt_50_12h": "false",
      "ph_lt_7": "false",
      "severe_comorbidity": "false"
    },
    {
      "depressed_mental_24h": "false",
      "fever_24h": "false",
      "glucose_gt_16_7_12h": "false",
      "insulin_gt_50_12h": "false",
      "ph_lt_7": "false",
      "severe_comorbidity": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/dka_mpm",
  "items": [
    {
      "components": [
        {
          "factor": "severe_comorbidity",
          "points": 0,
          "present": false
        },
        {
          "factor": "ph_lt_7",
          "points": 0,
          "present": false
        },
        {
          "factor": "insulin_gt_50_12h",
          "points": 0,
          "present": false
        },
        {
          "factor": "glucose_gt_16_7_12h",
          "points": 0,
          "present": false
        },
        {
          "factor": "depressed_mental_24h",
          "points": 0,
          "present": false
        },
        {
          "factor": "fever_24h",
          "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": "Efstathiou SP, Tsioulos DI, Tsiakou AG, Gratsias YG, Pefanis AV, Mountokalakis TD",
        "doi": "10.1046/j.1365-2265.2002.01636.x",
        "id": "efstathiou-2002",
        "pmid": "12390332",
        "source": "Clin Endocrinol (Oxf). 2002;57(5):595-601",
        "title": "A mortality prediction model in diabetic ketoacidosis"
      },
      "formula": "dka_mpm",
      "formula_expression": "DKA-MPM = severe_comorbidity 6 + ph_lt_7 4 + insulin_gt_50_12h 4 + glucose_gt_16_7_12h 4 + depressed_mental_24h 4 + fever_24h 3; Efstathiou 2002; max 25; published in-hospital death 0.86% scores 0-14 and 93.3% scores 19-25",
      "max_score": 25,
      "score": 0,
      "observed_mortality_percent": 0.86
    },
    {
      "components": [
        {
          "factor": "severe_comorbidity",
          "points": 0,
          "present": false
        },
        {
          "factor": "ph_lt_7",
          "points": 0,
          "present": false
        },
        {
          "factor": "insulin_gt_50_12h",
          "points": 0,
          "present": false
        },
        {
          "factor": "glucose_gt_16_7_12h",
          "points": 0,
          "present": false
        },
        {
          "factor": "depressed_mental_24h",
          "points": 0,
          "present": false
        },
        {
          "factor": "fever_24h",
          "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": "Efstathiou SP, Tsioulos DI, Tsiakou AG, Gratsias YG, Pefanis AV, Mountokalakis TD",
        "doi": "10.1046/j.1365-2265.2002.01636.x",
        "id": "efstathiou-2002",
        "pmid": "12390332",
        "source": "Clin Endocrinol (Oxf). 2002;57(5):595-601",
        "title": "A mortality prediction model in diabetic ketoacidosis"
      },
      "formula": "dka_mpm",
      "formula_expression": "DKA-MPM = severe_comorbidity 6 + ph_lt_7 4 + insulin_gt_50_12h 4 + glucose_gt_16_7_12h 4 + depressed_mental_24h 4 + fever_24h 3; Efstathiou 2002; max 25; published in-hospital death 0.86% scores 0-14 and 93.3% scores 19-25",
      "max_score": 25,
      "score": 0,
      "observed_mortality_percent": 0.86
    }
  ]
}
```

## Response fields

- `formula` (string): dka_mpm
- `formula_expression` (string): Exact expression used
- `score` (integer): Efstathiou 2002 DKA-MPM points 0-25
- `max_score` (integer): Always 25
- `observed_mortality_percent` (number): Efstathiou 2002 published in-hospital death: 0.86 when score is 0-14, 93.3 when score is 19-25. Omitted for scores 15-18; those scores are not given invented percents.
- `components` (array): Per-factor Efstathiou 2002 points
- `citation` (object): Efstathiou et al. Clin Endocrinol (Oxf) 2002 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "factor": "severe_comorbidity",
      "points": 0,
      "present": false
    },
    {
      "factor": "ph_lt_7",
      "points": 0,
      "present": false
    },
    {
      "factor": "insulin_gt_50_12h",
      "points": 0,
      "present": false
    },
    {
      "factor": "glucose_gt_16_7_12h",
      "points": 0,
      "present": false
    },
    {
      "factor": "depressed_mental_24h",
      "points": 0,
      "present": false
    },
    {
      "factor": "fever_24h",
      "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": "Efstathiou SP, Tsioulos DI, Tsiakou AG, Gratsias YG, Pefanis AV, Mountokalakis TD",
    "doi": "10.1046/j.1365-2265.2002.01636.x",
    "id": "efstathiou-2002",
    "pmid": "12390332",
    "source": "Clin Endocrinol (Oxf). 2002;57(5):595-601",
    "title": "A mortality prediction model in diabetic ketoacidosis"
  },
  "formula": "dka_mpm",
  "formula_expression": "DKA-MPM = severe_comorbidity 6 + ph_lt_7 4 + insulin_gt_50_12h 4 + glucose_gt_16_7_12h 4 + depressed_mental_24h 4 + fever_24h 3; Efstathiou 2002; max 25; published in-hospital death 0.86% scores 0-14 and 93.3% scores 19-25",
  "max_score": 25,
  "score": 0,
  "observed_mortality_percent": 0.86
}
```

## Errors

- HTTP 400 `invalid_dka_mpm`: DKA-MPM inputs must match Efstathiou 2002 presentation and first-day binary predictors from that paper. 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

- [Anion gap](https://magentlab.com/docs/anion-gap) — Compute the serum anion gap from sodium, chloride, and bicarbonate, with or without potassium, using the Emmett–Narins 1977 formulas. formula is required.

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