# ASCO irAE diabetes

irAE diabetes

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

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

## What it computes

Apply Brahmer 2018 ASCO Table 4.4 immune-related diabetes fasting-glucose bands and return grade 0–4 plus icpi_action from glucose_mg_dl and caller-assigned ketosis, t1dm, severe_unable_adl, and life_threatening flags.

## When to use

When an agent already has a fasting glucose in mg/dL and those caller-assigned flags during immune checkpoint inhibitor therapy and needs the published ASCO 2018 diabetes grade and continue / hold-until-control / hold-admit band. magent does not assay glucose.

## When not to use

- Not a medical device.
- Not a diagnosis. Not an insulin dose.
- mg/dL only; mmol/L is not accepted. magent does not assay glucose.
- Not DKA diagnostic criteria as a separate instrument.
- ketosis, t1dm, severe_unable_adl, and life_threatening are caller-assigned (Brahmer 2018 Table 4.4).

## Formula

```
irae_diabetes first-match worst-wins (Brahmer 2018 Table 4.4 fasting glucose mg/dL): grade 4 if life_threatening or glucose_mg_dl > 500; else grade 3 if severe_unable_adl or glucose_mg_dl > 250; else grade 2 if ketosis or t1dm or glucose_mg_dl > 160; else grade 1 if glucose_mg_dl > 99; else grade 0. icpi_action continue (0-1), hold_until_control (2), hold_admit (3-4). mg/dL only. Not DKA diagnostic criteria as a separate instrument. magent does not assay glucose. Not a diagnosis. Not an insulin dose
```

## Citation

[Management of Immune-Related Adverse Events in Patients Treated With Immune Checkpoint Inhibitor Therapy: American Society of Clinical Oncology Clinical Practice Guideline](https://doi.org/10.1200/JCO.2017.77.6385)
Brahmer JR, Lacchetti C, Schneider BJ, Atkins MB, Brassil KJ, Caterino JM, Chau I, Ernstoff MS, Gardner JM, Ginex P, Hallmeyer S, Holter Chakrabarty J, Leighl NB, Mammen JS, McDermott DF, Naing A, Nastoupil LJ, Phillips T, Porter LD, Puzanov I, Reichner CA, Santomasso BD, Seigel C, Spira A, Suarez-Almazor ME, Wang Y, Weber JS, Wolchok JD, Thompson JA
J Clin Oncol. 2018;36(17):1714-1768
DOI: [10.1200/JCO.2017.77.6385](https://doi.org/10.1200/JCO.2017.77.6385)

## Worked example

### Glucose 140 mg/dL, all flags false, grade 1 continue

Given: `glucose_mg_dl=140, ketosis=false, life_threatening=false, severe_unable_adl=false, t1dm=false`

1. glucose_mg_dl is 140 (fasting; above typical ULN and not >160)
2. ketosis, t1dm, severe_unable_adl, and life_threatening are false
3. first-match is grade 1 (glucose > 99); icpi_action is continue


## Also searched as

- irAE diabetes
- immune checkpoint diabetes
- ASCO 2018 diabetes
- Brahmer diabetes grade
- ICI hyperglycemia
- immune-related diabetes
- checkpoint inhibitor diabetes
- CTCAE hyperglycemia grade

## Parameters

- `glucose_mg_dl` (number, required): Fasting glucose in mg/dL (50-1000). Brahmer 2018 Table 4.4 bands: >500 grade 4; >250 grade 3; >160 grade 2; >99 grade 1; else grade 0 unless a flag upgrades. mmol/L is not accepted. magent does not assay glucose.
- `ketosis` (boolean, required): Ketosis as assigned by the caller (Brahmer 2018 Table 4.4 grade 2; ketosis at any glucose). true or false. When true and grade 4/3 criteria are not met, grade is 2. magent does not assay ketones.
- `t1dm` (boolean, required): Evidence of type 1 diabetes as assigned by the caller (Brahmer 2018 Table 4.4 grade 2; T1DM at any glucose). true or false. When true and grade 4/3 criteria are not met, grade is 2. magent does not diagnose diabetes.
- `life_threatening` (boolean, required): Life-threatening consequences as assigned by the caller (Brahmer 2018 Table 4.4 grade 4). true or false. When true, grade is 4 regardless of glucose. magent does not examine the patient.
- `severe_unable_adl` (boolean, required): Severe symptoms limiting self-care ADL as assigned by the caller (Brahmer 2018 Table 4.4 grade 3). true or false. When true and life_threatening is false and glucose is not >500, grade is 3. magent does not assess ADL.

## 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/irae_diabetes`
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": [
    {
      "glucose_mg_dl": "140",
      "ketosis": "false",
      "life_threatening": "false",
      "severe_unable_adl": "false",
      "t1dm": "false"
    },
    {
      "glucose_mg_dl": "140",
      "ketosis": "false",
      "life_threatening": "false",
      "severe_unable_adl": "false",
      "t1dm": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/irae_diabetes",
  "items": [
    {
      "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": "Brahmer JR, Lacchetti C, Schneider BJ, Atkins MB, Brassil KJ, Caterino JM, Chau I, Ernstoff MS, Gardner JM, Ginex P, Hallmeyer S, Holter Chakrabarty J, Leighl NB, Mammen JS, McDermott DF, Naing A, Nastoupil LJ, Phillips T, Porter LD, Puzanov I, Reichner CA, Santomasso BD, Seigel C, Spira A, Suarez-Almazor ME, Wang Y, Weber JS, Wolchok JD, Thompson JA",
        "doi": "10.1200/JCO.2017.77.6385",
        "id": "brahmer-2018",
        "pmid": "29442540",
        "source": "J Clin Oncol. 2018;36(17):1714-1768",
        "title": "Management of Immune-Related Adverse Events in Patients Treated With Immune Checkpoint Inhibitor Therapy: American Society of Clinical Oncology Clinical Practice Guideline"
      },
      "formula": "irae_diabetes",
      "formula_expression": "irae_diabetes first-match worst-wins (Brahmer 2018 Table 4.4 fasting glucose mg/dL): grade 4 if life_threatening or glucose_mg_dl > 500; else grade 3 if severe_unable_adl or glucose_mg_dl > 250; else grade 2 if ketosis or t1dm or glucose_mg_dl > 160; else grade 1 if glucose_mg_dl > 99; else grade 0. icpi_action continue (0-1), hold_until_control (2), hold_admit (3-4). mg/dL only. Not DKA diagnostic criteria as a separate instrument. magent does not assay glucose. Not a diagnosis. Not an insulin dose",
      "criteria": [
        {
          "factor": "life_threatening",
          "met": false
        },
        {
          "value": 140.0,
          "factor": "glucose_gt_500",
          "met": false
        },
        {
          "factor": "severe_unable_adl",
          "met": false
        },
        {
          "value": 140.0,
          "factor": "glucose_gt_250",
          "met": false
        },
        {
          "factor": "ketosis",
          "met": false
        },
        {
          "factor": "t1dm",
          "met": false
        },
        {
          "value": 140.0,
          "factor": "glucose_gt_160",
          "met": false
        },
        {
          "value": 140.0,
          "factor": "glucose_gt_99",
          "met": true
        }
      ],
      "grade": 1,
      "glucose_mg_dl": 140.0,
      "icpi_action": "continue",
      "life_threatening": false,
      "ketosis": false,
      "severe_unable_adl": false,
      "t1dm": 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": "Brahmer JR, Lacchetti C, Schneider BJ, Atkins MB, Brassil KJ, Caterino JM, Chau I, Ernstoff MS, Gardner JM, Ginex P, Hallmeyer S, Holter Chakrabarty J, Leighl NB, Mammen JS, McDermott DF, Naing A, Nastoupil LJ, Phillips T, Porter LD, Puzanov I, Reichner CA, Santomasso BD, Seigel C, Spira A, Suarez-Almazor ME, Wang Y, Weber JS, Wolchok JD, Thompson JA",
        "doi": "10.1200/JCO.2017.77.6385",
        "id": "brahmer-2018",
        "pmid": "29442540",
        "source": "J Clin Oncol. 2018;36(17):1714-1768",
        "title": "Management of Immune-Related Adverse Events in Patients Treated With Immune Checkpoint Inhibitor Therapy: American Society of Clinical Oncology Clinical Practice Guideline"
      },
      "formula": "irae_diabetes",
      "formula_expression": "irae_diabetes first-match worst-wins (Brahmer 2018 Table 4.4 fasting glucose mg/dL): grade 4 if life_threatening or glucose_mg_dl > 500; else grade 3 if severe_unable_adl or glucose_mg_dl > 250; else grade 2 if ketosis or t1dm or glucose_mg_dl > 160; else grade 1 if glucose_mg_dl > 99; else grade 0. icpi_action continue (0-1), hold_until_control (2), hold_admit (3-4). mg/dL only. Not DKA diagnostic criteria as a separate instrument. magent does not assay glucose. Not a diagnosis. Not an insulin dose",
      "criteria": [
        {
          "factor": "life_threatening",
          "met": false
        },
        {
          "value": 140.0,
          "factor": "glucose_gt_500",
          "met": false
        },
        {
          "factor": "severe_unable_adl",
          "met": false
        },
        {
          "value": 140.0,
          "factor": "glucose_gt_250",
          "met": false
        },
        {
          "factor": "ketosis",
          "met": false
        },
        {
          "factor": "t1dm",
          "met": false
        },
        {
          "value": 140.0,
          "factor": "glucose_gt_160",
          "met": false
        },
        {
          "value": 140.0,
          "factor": "glucose_gt_99",
          "met": true
        }
      ],
      "grade": 1,
      "glucose_mg_dl": 140.0,
      "icpi_action": "continue",
      "life_threatening": false,
      "ketosis": false,
      "severe_unable_adl": false,
      "t1dm": false
    }
  ]
}
```

## Response fields

- `formula` (string): irae_diabetes
- `formula_expression` (string): Brahmer 2018 Table 4.4 first-match diabetes grade and icpi_action rule
- `grade` (integer): 0-4. First-match worst-wins on fasting glucose_mg_dl and caller-assigned ketosis, t1dm, severe_unable_adl, and life_threatening (Brahmer 2018 Table 4.4). Not a diagnosis.
- `icpi_action` (string): continue (grade 0 or 1), hold_until_control (grade 2), or hold_admit (grade 3 or 4). Not an insulin dose.
- `glucose_mg_dl` (number): Echo of fasting glucose in mg/dL
- `ketosis` (boolean): Echo of caller-assigned ketosis (grade 2 when true unless a worse match)
- `t1dm` (boolean): Echo of caller-assigned evidence of type 1 diabetes (grade 2 when true unless a worse match)
- `life_threatening` (boolean): Echo of caller-assigned life-threatening flag (grade 4 when true)
- `severe_unable_adl` (boolean): Echo of caller-assigned severe symptoms limiting self-care ADL (grade 3 when true unless a worse match)
- `criteria` (array): Per-factor Tree rows with factor and met for life_threatening, glucose_gt_500, severe_unable_adl, glucose_gt_250, ketosis, t1dm, glucose_gt_160, and glucose_gt_99; glucose rows include value
- `citation` (object): Brahmer 2018 J Clin Oncol ASCO irAE guideline citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "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": "Brahmer JR, Lacchetti C, Schneider BJ, Atkins MB, Brassil KJ, Caterino JM, Chau I, Ernstoff MS, Gardner JM, Ginex P, Hallmeyer S, Holter Chakrabarty J, Leighl NB, Mammen JS, McDermott DF, Naing A, Nastoupil LJ, Phillips T, Porter LD, Puzanov I, Reichner CA, Santomasso BD, Seigel C, Spira A, Suarez-Almazor ME, Wang Y, Weber JS, Wolchok JD, Thompson JA",
    "doi": "10.1200/JCO.2017.77.6385",
    "id": "brahmer-2018",
    "pmid": "29442540",
    "source": "J Clin Oncol. 2018;36(17):1714-1768",
    "title": "Management of Immune-Related Adverse Events in Patients Treated With Immune Checkpoint Inhibitor Therapy: American Society of Clinical Oncology Clinical Practice Guideline"
  },
  "formula": "irae_diabetes",
  "formula_expression": "irae_diabetes first-match worst-wins (Brahmer 2018 Table 4.4 fasting glucose mg/dL): grade 4 if life_threatening or glucose_mg_dl > 500; else grade 3 if severe_unable_adl or glucose_mg_dl > 250; else grade 2 if ketosis or t1dm or glucose_mg_dl > 160; else grade 1 if glucose_mg_dl > 99; else grade 0. icpi_action continue (0-1), hold_until_control (2), hold_admit (3-4). mg/dL only. Not DKA diagnostic criteria as a separate instrument. magent does not assay glucose. Not a diagnosis. Not an insulin dose",
  "criteria": [
    {
      "factor": "life_threatening",
      "met": false
    },
    {
      "value": 140.0,
      "factor": "glucose_gt_500",
      "met": false
    },
    {
      "factor": "severe_unable_adl",
      "met": false
    },
    {
      "value": 140.0,
      "factor": "glucose_gt_250",
      "met": false
    },
    {
      "factor": "ketosis",
      "met": false
    },
    {
      "factor": "t1dm",
      "met": false
    },
    {
      "value": 140.0,
      "factor": "glucose_gt_160",
      "met": false
    },
    {
      "value": 140.0,
      "factor": "glucose_gt_99",
      "met": true
    }
  ],
  "grade": 1,
  "glucose_mg_dl": 140.0,
  "icpi_action": "continue",
  "life_threatening": false,
  "ketosis": false,
  "severe_unable_adl": false,
  "t1dm": false
}
```

## Errors

- HTTP 400 `invalid_glucose`: glucose_mg_dl (50-1000) or glucose_mmol_l (2.8-55.5) is required 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

- [Bang diabetes screening](https://magentlab.com/docs/ada-diabetes) — Sum the Bang 2009 Table 2 development screening score for undiagnosed diabetes and return high_risk when the total is ≥5.
- [DKA-MPM](https://magentlab.com/docs/dka-mpm) — 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%).

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