# Glasgow alcoholic hepatitis score

GAHS

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

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

## What it computes

Compute the Forrest 2005 Glasgow alcoholic hepatitis score (5-12) and the published ≥9 band.

## When to use

When an agent needs the published GAHS total and must not invent a corticosteroid decision.

## When not to use

- Not a diagnosis or a steroid/pentoxifylline order. Forrest 2005 associated day-1 GAHS ≥9 with poorer outcome; magent returns lt_9 or ge_9 as a band.
- PT ratio is the paper variable (not INR). Age uses magent's adult 18-120 clamp. Urea may be entered as mmol/L or BUN mg/dL (÷ 2.8).

## Formula

```
GAHS = age_points + wbc_points + urea_points + pt_ratio_points + bilirubin_points; range 5-12
```

## Citation

[Analysis of factors predictive of mortality in alcoholic hepatitis and derivation and validation of the Glasgow alcoholic hepatitis score](https://doi.org/10.1136/gut.2004.050781)
Forrest EH, Evans CD, Stewart S, et al.
Gut. 2005;54(8):1174-1179
DOI: [10.1136/gut.2004.050781](https://doi.org/10.1136/gut.2004.050781)

## Worked example

### Age 40, WBC 8, urea 4, PT ratio 1.2, bilirubin 80 µmol/L

Given: `age=40, bilirubin_umol_l=80, pt_ratio=1.2, urea_mmol_l=4, wbc_k_ul=8`

1. age <50 → 1; WBC <15 → 1; urea <5 → 1; PT ratio <1.5 → 1; bilirubin <125 → 1
2. score = 5
3. band lt_9


### Age 55, WBC 16, urea 8, PT ratio 2.2, bilirubin 300 µmol/L

Given: `age=55, bilirubin_umol_l=300, pt_ratio=2.2, urea_mmol_l=8, wbc_k_ul=16`

1. age ≥50 → 2; WBC ≥15 → 2; urea ≥5 → 2; PT ratio >2.0 → 3; bilirubin >250 → 3
2. score = 12
3. band ge_9


## Also searched as

- Glasgow alcoholic hepatitis score
- GAHS
- Forrest score
- alcoholic hepatitis score
- GAHS ≥9

## Parameters

- `age` (integer, required): Age in years (18-120). <50 scores 1; ≥50 scores 2 (Forrest 2005).
- `wbc_k_ul` (number, optional): WBC in 10^3/µL (same as 10^9/L). Provide wbc_k_ul or wbc_ul. <15 scores 1; ≥15 scores 2.
- `wbc_ul` (number, optional): WBC in cells/µL. Converted as K/µL = cells/µL / 1000.
- `urea_mmol_l` (number, optional): Urea in mmol/L (1-50). Provide this or bun_mg_dl, not both. <5 scores 1; ≥5 scores 2.
- `bun_mg_dl` (number, optional): BUN in mg/dL (3-140). Converted as urea_mmol_l = bun_mg_dl / 2.8.
- `pt_ratio` (number, required): Prothrombin-time ratio (0.8-10). <1.5 scores 1; 1.5-2.0 scores 2; >2.0 scores 3.
- `bilirubin_umol_l` (number, optional): Total bilirubin in µmol/L (2-684). Provide this or bilirubin_mg_dl. <125 scores 1; 125-250 scores 2; >250 scores 3.
- `bilirubin_mg_dl` (number, optional): Total bilirubin in mg/dL (0.1-40). Converted as µmol/L = mg/dL × 17.1.

## 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/gahs`
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": [
    {
      "age": "40",
      "bilirubin_umol_l": "80",
      "pt_ratio": "1.2",
      "urea_mmol_l": "4",
      "wbc_k_ul": "8"
    },
    {
      "age": "40",
      "bilirubin_umol_l": "80",
      "pt_ratio": "1.2",
      "urea_mmol_l": "4",
      "wbc_k_ul": "8"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/gahs",
  "items": [
    {
      "components": [
        {
          "value": 40,
          "factor": "age",
          "points": 1,
          "present": false
        },
        {
          "value": 8.0,
          "factor": "wbc",
          "points": 1,
          "present": false
        },
        {
          "value": 4.0,
          "factor": "urea",
          "points": 1,
          "present": false
        },
        {
          "value": 1.2,
          "factor": "pt_ratio",
          "points": 1,
          "present": false
        },
        {
          "value": 80.0,
          "factor": "bilirubin",
          "points": 1,
          "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": "Forrest EH, Evans CD, Stewart S, et al.",
        "doi": "10.1136/gut.2004.050781",
        "id": "forrest-2005",
        "source": "Gut. 2005;54(8):1174-1179",
        "title": "Analysis of factors predictive of mortality in alcoholic hepatitis and derivation and validation of the Glasgow alcoholic hepatitis score"
      },
      "formula": "gahs",
      "formula_expression": "GAHS = age_points + wbc_points + urea_points + pt_ratio_points + bilirubin_points; range 5-12",
      "max_score": 12,
      "score": 5,
      "age_years": 40,
      "bilirubin_umol_l": 80.0,
      "gahs_band": "lt_9",
      "min_score": 5,
      "pt_ratio": 1.2,
      "urea_mmol_l": 4.0,
      "wbc_k_ul": 8.0
    },
    {
      "components": [
        {
          "value": 40,
          "factor": "age",
          "points": 1,
          "present": false
        },
        {
          "value": 8.0,
          "factor": "wbc",
          "points": 1,
          "present": false
        },
        {
          "value": 4.0,
          "factor": "urea",
          "points": 1,
          "present": false
        },
        {
          "value": 1.2,
          "factor": "pt_ratio",
          "points": 1,
          "present": false
        },
        {
          "value": 80.0,
          "factor": "bilirubin",
          "points": 1,
          "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": "Forrest EH, Evans CD, Stewart S, et al.",
        "doi": "10.1136/gut.2004.050781",
        "id": "forrest-2005",
        "source": "Gut. 2005;54(8):1174-1179",
        "title": "Analysis of factors predictive of mortality in alcoholic hepatitis and derivation and validation of the Glasgow alcoholic hepatitis score"
      },
      "formula": "gahs",
      "formula_expression": "GAHS = age_points + wbc_points + urea_points + pt_ratio_points + bilirubin_points; range 5-12",
      "max_score": 12,
      "score": 5,
      "age_years": 40,
      "bilirubin_umol_l": 80.0,
      "gahs_band": "lt_9",
      "min_score": 5,
      "pt_ratio": 1.2,
      "urea_mmol_l": 4.0,
      "wbc_k_ul": 8.0
    }
  ]
}
```

## Response fields

- `formula` (string): gahs
- `formula_expression` (string): Exact expression used
- `score` (integer): GAHS 5-12
- `max_score` (integer): 12
- `min_score` (integer): 5
- `gahs_band` (string): lt_9 or ge_9 (Forrest 2005 day-1 cutoff). A band, not a steroid order.
- `age_years` (integer): Age used
- `wbc_k_ul` (number): WBC in 10^9/L used
- `urea_mmol_l` (number): Urea in mmol/L used
- `pt_ratio` (number): PT ratio used
- `bilirubin_umol_l` (number): Bilirubin in µmol/L used
- `components` (array): Per-variable points
- `citation` (object): Forrest et al. Gut 2005 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 40,
      "factor": "age",
      "points": 1,
      "present": false
    },
    {
      "value": 8.0,
      "factor": "wbc",
      "points": 1,
      "present": false
    },
    {
      "value": 4.0,
      "factor": "urea",
      "points": 1,
      "present": false
    },
    {
      "value": 1.2,
      "factor": "pt_ratio",
      "points": 1,
      "present": false
    },
    {
      "value": 80.0,
      "factor": "bilirubin",
      "points": 1,
      "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": "Forrest EH, Evans CD, Stewart S, et al.",
    "doi": "10.1136/gut.2004.050781",
    "id": "forrest-2005",
    "source": "Gut. 2005;54(8):1174-1179",
    "title": "Analysis of factors predictive of mortality in alcoholic hepatitis and derivation and validation of the Glasgow alcoholic hepatitis score"
  },
  "formula": "gahs",
  "formula_expression": "GAHS = age_points + wbc_points + urea_points + pt_ratio_points + bilirubin_points; range 5-12",
  "max_score": 12,
  "score": 5,
  "age_years": 40,
  "bilirubin_umol_l": 80.0,
  "gahs_band": "lt_9",
  "min_score": 5,
  "pt_ratio": 1.2,
  "urea_mmol_l": 4.0,
  "wbc_k_ul": 8.0
}
```

## Errors

- HTTP 400 `invalid_age`: age must be an integer from 18 to 120 Returned before settlement; you are not charged.
- HTTP 400 `invalid_wbc`: wbc_k_ul (0.01-500) or wbc_ul (10-500000) is required Returned before settlement; you are not charged.
- HTTP 400 `invalid_urea`: urea_mmol_l (1-50) or bun_mg_dl (3-140) is required, not both. Returned before settlement; you are not charged.
- HTTP 400 `invalid_gahs_pt_ratio`: pt_ratio must be a number from 0.8 to 10. 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_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

- [Maddrey DF](https://magentlab.com/docs/maddrey) — Compute the 1978 Maddrey discriminant function from patient PT, control PT, and bilirubin.
- [Child–Pugh](https://magentlab.com/docs/child-pugh) — Compute the Child–Turcotte–Pugh cirrhosis severity score from bilirubin, albumin, INR, encephalopathy, and ascites.
- [MELD-Na](https://magentlab.com/docs/meld-na) — Compute OPTN/UNOS 2016 MELD and MELD-Na from creatinine, bilirubin, INR, sodium, and dialysis.

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