# irAE hepatitis

irAE hepatitis

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

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

## What it computes

Apply Brahmer 2018 ASCO Table 2.2 immune-related hepatitis lab folds (AST or ALT × ULN and total bilirubin × ULN) and return grade 0–4 plus ICI action, with caller-assigned decompensation (grade 4) and symptomatic compensated liver dysfunction (grade 3) upgrades.

## When to use

When an agent has caller AST, ALT, total bilirubin, and laboratory ULNs during immune checkpoint inhibitor therapy and needs the published ASCO 2018 hepatitis grade and continue/hold/permanently discontinue band, not a DILI diagnosis, RUCAM score, or R factor.

## When not to use

- Not a medical device. Not a diagnosis. magent does not assay enzymes.
- Total bilirubin is mg/dL only; µmol/L is not accepted.
- Not DILI causality and not RUCAM. Not the CIOMS R factor (r-factor).
- Not a steroid dose or immunosuppression schedule. icpi_action is the published continue / hold / permanently discontinue band only.
- Decompensated liver and symptomatic liver dysfunction are caller-assigned (ascites, encephalopathy, coagulopathy, or coma; symptomatic compensated hepatitis).

## Formula

```
lab_grade = max(transaminase_grade(max(AST/AST_ULN, ALT/ALT_ULN)), bilirubin_grade(TBili/TBili_ULN)); first-match: decompensated_liver -> max(lab_grade, 4); else symptomatic_liver_dysfunction -> max(lab_grade, 3); else lab_grade. Transaminase: <1x -> 0, ULN-3x -> 1, >3-5x -> 2, >5-20x -> 3, >20x -> 4. Bilirubin: <1x -> 0, ULN-1.5x -> 1, >1.5-3x -> 2, >3-10x -> 3, >10x -> 4 (Brahmer 2018 Table 2.2). icpi_action: 0-1 continue, 2 hold, 3-4 permanently_discontinue. mg/dL bilirubin only. Not DILI/RUCAM. Not R factor. magent does not assay enzymes. Not a diagnosis. Not a steroid 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

### AST 80 U/L (ULN 40), ALT 50 U/L (ULN 40), bilirubin 1.0 mg/dL (ULN 1.0)

Given: `alt_u_l=50, alt_uln_u_l=40, ast_u_l=80, ast_uln_u_l=40, bilirubin_mg_dl=1.0, bilirubin_uln_mg_dl=1.0, decompensated_liver=false, symptomatic_liver_dysfunction=false`

1. AST / AST_ULN = 80 / 40 = 2.0; ALT / ALT_ULN = 50 / 40 = 1.25; transaminase_ratio = max = 2.0 → transaminase grade 1
2. bilirubin / ULN = 1.0 / 1.0 = 1.0 → bilirubin grade 1
3. lab_grade = max(1, 1) = 1
4. decompensated_liver false and symptomatic_liver_dysfunction false → grade 1
5. grade 1 → icpi_action continue


## Also searched as

- immune-related hepatitis
- ICI hepatitis
- ASCO irAE hepatitis
- checkpoint inhibitor hepatitis
- Brahmer 2018 hepatitis
- immune checkpoint liver toxicity
- CTCAE hepatitis
- irAE liver grade

## Parameters

- `ast_u_l` (number, required): Aspartate aminotransferase in U/L (1-10000). Used with ast_uln_u_l for the AST fold. magent does not assay enzymes.
- `ast_uln_u_l` (number, required): Laboratory AST upper limit of normal in U/L (5-200). Required; magent does not assume 40.
- `alt_u_l` (number, required): Alanine aminotransferase in U/L (1-10000). Used with alt_uln_u_l for the ALT fold. magent does not assay enzymes.
- `alt_uln_u_l` (number, required): Laboratory ALT upper limit of normal in U/L (5-200). Required; magent does not assume 40.
- `bilirubin_mg_dl` (number, required): Total bilirubin in mg/dL (0.1-40). µmol/L is not accepted. magent does not assay bilirubin.
- `bilirubin_uln_mg_dl` (number, required): Laboratory total-bilirubin upper limit of normal in mg/dL (0.1-5). Required; magent does not assume 1.0.
- `decompensated_liver` (boolean, required): Decompensated liver (ascites, encephalopathy, coagulopathy, or coma) as assigned by the caller (Brahmer 2018). true or false. When true, grade is max(lab_grade, 4). magent does not examine the patient.
- `symptomatic_liver_dysfunction` (boolean, required): Symptomatic compensated hepatitis / liver dysfunction as assigned by the caller (Brahmer 2018). true or false. When true and decompensated_liver is false, grade is max(lab_grade, 3). magent does not examine the patient.

## 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_hepatitis`
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": [
    {
      "alt_u_l": "50",
      "alt_uln_u_l": "40",
      "ast_u_l": "80",
      "ast_uln_u_l": "40",
      "bilirubin_mg_dl": "1.0",
      "bilirubin_uln_mg_dl": "1.0",
      "decompensated_liver": "false",
      "symptomatic_liver_dysfunction": "false"
    },
    {
      "alt_u_l": "50",
      "alt_uln_u_l": "40",
      "ast_u_l": "80",
      "ast_uln_u_l": "40",
      "bilirubin_mg_dl": "1.0",
      "bilirubin_uln_mg_dl": "1.0",
      "decompensated_liver": "false",
      "symptomatic_liver_dysfunction": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/irae_hepatitis",
  "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_hepatitis",
      "formula_expression": "lab_grade = max(transaminase_grade(max(AST/AST_ULN, ALT/ALT_ULN)), bilirubin_grade(TBili/TBili_ULN)); first-match: decompensated_liver -> max(lab_grade, 4); else symptomatic_liver_dysfunction -> max(lab_grade, 3); else lab_grade. Transaminase: <1x -> 0, ULN-3x -> 1, >3-5x -> 2, >5-20x -> 3, >20x -> 4. Bilirubin: <1x -> 0, ULN-1.5x -> 1, >1.5-3x -> 2, >3-10x -> 3, >10x -> 4 (Brahmer 2018 Table 2.2). icpi_action: 0-1 continue, 2 hold, 3-4 permanently_discontinue. mg/dL bilirubin only. Not DILI/RUCAM. Not R factor. magent does not assay enzymes. Not a diagnosis. Not a steroid dose",
      "bilirubin_mg_dl": 1.0,
      "ast_u_l": 80.0,
      "ast_uln_u_l": 40.0,
      "criteria": [
        {
          "factor": "decompensated_liver",
          "met": false
        },
        {
          "factor": "symptomatic_liver_dysfunction",
          "met": false
        }
      ],
      "grade": 1,
      "alt_u_l": 50.0,
      "icpi_action": "continue",
      "alt_uln_u_l": 40.0,
      "bilirubin_ratio": 1.0,
      "bilirubin_uln_mg_dl": 1.0,
      "decompensated_liver": false,
      "symptomatic_liver_dysfunction": false,
      "transaminase_ratio": 2.0
    },
    {
      "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_hepatitis",
      "formula_expression": "lab_grade = max(transaminase_grade(max(AST/AST_ULN, ALT/ALT_ULN)), bilirubin_grade(TBili/TBili_ULN)); first-match: decompensated_liver -> max(lab_grade, 4); else symptomatic_liver_dysfunction -> max(lab_grade, 3); else lab_grade. Transaminase: <1x -> 0, ULN-3x -> 1, >3-5x -> 2, >5-20x -> 3, >20x -> 4. Bilirubin: <1x -> 0, ULN-1.5x -> 1, >1.5-3x -> 2, >3-10x -> 3, >10x -> 4 (Brahmer 2018 Table 2.2). icpi_action: 0-1 continue, 2 hold, 3-4 permanently_discontinue. mg/dL bilirubin only. Not DILI/RUCAM. Not R factor. magent does not assay enzymes. Not a diagnosis. Not a steroid dose",
      "bilirubin_mg_dl": 1.0,
      "ast_u_l": 80.0,
      "ast_uln_u_l": 40.0,
      "criteria": [
        {
          "factor": "decompensated_liver",
          "met": false
        },
        {
          "factor": "symptomatic_liver_dysfunction",
          "met": false
        }
      ],
      "grade": 1,
      "alt_u_l": 50.0,
      "icpi_action": "continue",
      "alt_uln_u_l": 40.0,
      "bilirubin_ratio": 1.0,
      "bilirubin_uln_mg_dl": 1.0,
      "decompensated_liver": false,
      "symptomatic_liver_dysfunction": false,
      "transaminase_ratio": 2.0
    }
  ]
}
```

## Response fields

- `formula` (string): irae_hepatitis
- `formula_expression` (string): Brahmer 2018 Table 2.2 hepatitis lab folds plus clinical upgrades
- `grade` (integer): 0-4. Lab grade is the max of transaminase and bilirubin bands; decompensated_liver upgrades to at least 4; symptomatic_liver_dysfunction upgrades to at least 3. Not a diagnosis.
- `icpi_action` (string): continue (grade 0 or 1), hold (grade 2), or permanently_discontinue (grade 3 or 4). Not a steroid dose.
- `transaminase_ratio` (number): max(AST/AST_ULN, ALT/ALT_ULN), 4 decimal places
- `bilirubin_ratio` (number): total bilirubin / bilirubin ULN (mg/dL), 4 decimal places
- `ast_u_l` (number): AST in U/L
- `ast_uln_u_l` (number): Laboratory AST upper limit of normal in U/L
- `alt_u_l` (number): ALT in U/L
- `alt_uln_u_l` (number): Laboratory ALT upper limit of normal in U/L
- `bilirubin_mg_dl` (number): Total bilirubin in mg/dL
- `bilirubin_uln_mg_dl` (number): Laboratory total-bilirubin ULN in mg/dL
- `decompensated_liver` (boolean): Caller-assigned decompensated-liver flag
- `symptomatic_liver_dysfunction` (boolean): Caller-assigned symptomatic compensated hepatitis / liver dysfunction flag
- `criteria` (array): Per-factor Tree rows with factor and met for decompensated_liver then symptomatic_liver_dysfunction (first-match clinical upgrade)
- `citation` (object): Brahmer 2018 J Clin Oncol 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_hepatitis",
  "formula_expression": "lab_grade = max(transaminase_grade(max(AST/AST_ULN, ALT/ALT_ULN)), bilirubin_grade(TBili/TBili_ULN)); first-match: decompensated_liver -> max(lab_grade, 4); else symptomatic_liver_dysfunction -> max(lab_grade, 3); else lab_grade. Transaminase: <1x -> 0, ULN-3x -> 1, >3-5x -> 2, >5-20x -> 3, >20x -> 4. Bilirubin: <1x -> 0, ULN-1.5x -> 1, >1.5-3x -> 2, >3-10x -> 3, >10x -> 4 (Brahmer 2018 Table 2.2). icpi_action: 0-1 continue, 2 hold, 3-4 permanently_discontinue. mg/dL bilirubin only. Not DILI/RUCAM. Not R factor. magent does not assay enzymes. Not a diagnosis. Not a steroid dose",
  "bilirubin_mg_dl": 1.0,
  "ast_u_l": 80.0,
  "ast_uln_u_l": 40.0,
  "criteria": [
    {
      "factor": "decompensated_liver",
      "met": false
    },
    {
      "factor": "symptomatic_liver_dysfunction",
      "met": false
    }
  ],
  "grade": 1,
  "alt_u_l": 50.0,
  "icpi_action": "continue",
  "alt_uln_u_l": 40.0,
  "bilirubin_ratio": 1.0,
  "bilirubin_uln_mg_dl": 1.0,
  "decompensated_liver": false,
  "symptomatic_liver_dysfunction": false,
  "transaminase_ratio": 2.0
}
```

## Errors

- HTTP 400 `invalid_ast`: ast_u_l must be a number from 1 to 10000 Returned before settlement; you are not charged.
- HTTP 400 `invalid_ast_uln`: ast_uln_u_l must be a number from 5 to 200. Returned before settlement; you are not charged.
- HTTP 400 `invalid_alt`: alt_u_l must be a number from 1 to 10000 Returned before settlement; you are not charged.
- HTTP 400 `invalid_alt_uln`: alt_uln_u_l must be a number from 5 to 200. Returned before settlement; you are not charged.
- HTTP 400 `invalid_bilirubin`: bilirubin_mg_dl (0.1-40) or bilirubin_umol_l (2-684) is required Returned before settlement; you are not charged.
- HTTP 400 `invalid_bilirubin_uln`: bilirubin_uln_mg_dl must be a number from 0.1 to 5 (laboratory total-bilirubin ULN mg/dL). 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

- [irAE colitis](https://magentlab.com/docs/irae-colitis) — Apply Brahmer 2018 ASCO Table 2.1 immune-related colitis grading (CTCAE diarrhea as used in the table) and return grade 1-4 plus icpi_action from stools_over_baseline and four caller-assigned flags.
- [R factor](https://magentlab.com/docs/r-factor) — Compute the Bénichou 1990 / CIOMS R ratio from ALT, ALP, and their laboratory upper limits of normal, then classify hepatocellular (R ≥ 5), cholestatic (R ≤ 2), or mixed (2 < R < 5).

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