# King's College criteria

King's College criteria

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

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

## What it computes

Apply the O'Grady 1989 King's College poor-prognosis criteria for fulminant hepatic failure, with separate acetaminophen and non-acetaminophen trees using prothrombin time in seconds.

## When to use

When an agent has caller-assigned labs and encephalopathy grade in fulminant hepatic failure and needs the 1989 King's College criteria, not later INR restatements or a transplant-allocation score.

## When not to use

- Not a medical device. magent does not examine the patient.
- Not a transplant listing, organ-allocation order, or UNOS/MELD substitute.
- Uses prothrombin time in seconds as published in 1989. Does not accept, convert, or restate INR (no INR>6.5 / INR>3.5).
- This is the O'Grady 1989 Gastroenterology paper only. Later reviews and age <10 restatements are not this tool. Age cutoffs are <11 or >40 as in the 1989 abstract.
- The acetaminophen arterial pH <7.30 rule is independent of encephalopathy. The PT>100 s plus creatinine >300 umol/L plus grade III/IV package is the 1989 selection model.

## Formula

```
acetaminophen: arterial_ph < 7.30, or (pt_sec > 100 and creatinine_umol_l > 300 and encephalopathy_grade >= 3); non_acetaminophen: pt_sec > 100, or at least 3 of (age_years < 11 or > 40; unfavorable_etiology; jaundice_to_encephalopathy_days > 7; bilirubin_umol_l > 300; pt_sec > 50)
```

## Citation

[Early indicators of prognosis in fulminant hepatic failure](https://doi.org/10.1016/0016-5085(89)90081-4)
O'Grady JG, Alexander GJ, Hayllar KM, Williams R
Gastroenterology. 1989;97(2):439-445
DOI: [10.1016/0016-5085(89)90081-4](https://doi.org/10.1016/0016-5085(89)90081-4)

## Worked example

### Acetaminophen, labs not meeting either rule

Given: `age_years=30, arterial_ph=7.40, bilirubin_umol_l=50, creatinine_umol_l=80, encephalopathy_grade=1, etiology=acetaminophen, jaundice_to_encephalopathy_days=2, pt_sec=20, unfavorable_etiology=false`

1. Acetaminophen tree: arterial pH 7.40 is not < 7.30
2. PT 20 s is not > 100, creatinine 80 umol/L is not > 300, grade 1 is not >= 3
3. criteria_met is false


### Acetaminophen arterial pH < 7.30

Given: `age_years=30, arterial_ph=7.20, bilirubin_umol_l=50, creatinine_umol_l=80, encephalopathy_grade=1, etiology=acetaminophen, jaundice_to_encephalopathy_days=2, pt_sec=20, unfavorable_etiology=false`

1. Acetaminophen tree: arterial pH 7.20 < 7.30
2. pH rule is independent of encephalopathy
3. criteria_met is true


### Non-acetaminophen any three of five

Given: `age_years=10, arterial_ph=7.40, bilirubin_umol_l=50, creatinine_umol_l=80, encephalopathy_grade=1, etiology=non_acetaminophen, jaundice_to_encephalopathy_days=8, pt_sec=20, unfavorable_etiology=true`

1. Non-acetaminophen tree: PT 20 s is not > 100
2. Age 10 < 11, unfavorable etiology, jaundice-to-encephalopathy 8 > 7 (three of five)
3. criteria_met is true


## Also searched as

- kings college
- acetaminophen
- fulminant hepatic failure
- King's College criteria
- O'Grady 1989
- paracetamol hepatotoxicity criteria
- King's College Hospital criteria
- non-acetaminophen FHF

## Parameters

- `etiology` (string, required): acetaminophen or non_acetaminophen (O'Grady 1989). Selects the paracetamol or non-paracetamol poor-prognosis tree. Required on every request.
- `arterial_ph` (number, required): Arterial pH (6.80-7.80). Acetaminophen criterion met when pH < 7.30, independent of encephalopathy. Required even on the non-acetaminophen tree; not scored there.
- `pt_sec` (number, required): Prothrombin time in seconds (8-120) as published in 1989. INR is not accepted. Acetaminophen combo uses PT > 100; non-acetaminophen uses PT > 100 alone or PT > 50 as one of five factors.
- `creatinine_umol_l` (number, required): Serum creatinine in umol/L (9-1768). Acetaminophen combo criterion met when > 300. Required even on the non-acetaminophen tree; not scored there.
- `encephalopathy_grade` (integer, required): Hepatic encephalopathy grade 0-4 as assigned by the caller (Conn 1977 / West Haven). Acetaminophen combo uses grade >= 3 (grade III/IV). Required even on the non-acetaminophen tree; not scored there. magent does not examine the patient.
- `age_years` (integer, required): Age in years (0-120). Non-acetaminophen factor met when age < 11 or age > 40 (1989 abstract, not a later <10 restatement). Required even on the acetaminophen tree; not scored there.
- `unfavorable_etiology` (boolean, required): Unfavorable etiology as assigned by the caller (paper: non-A non-B hepatitis or drug reaction). true or false. Non-acetaminophen any-3 factor. Required even on the acetaminophen tree; not scored there.
- `jaundice_to_encephalopathy_days` (integer, required): Days from jaundice to encephalopathy (integer 0-90). Non-acetaminophen factor met when > 7. Required even on the acetaminophen tree; not scored there.
- `bilirubin_umol_l` (number, required): Serum bilirubin in umol/L (2-684). Non-acetaminophen factor met when > 300. Required even on the acetaminophen tree; not scored there.

## 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/kings_college`
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_years": "30",
      "arterial_ph": "7.40",
      "bilirubin_umol_l": "50",
      "creatinine_umol_l": "80",
      "encephalopathy_grade": "1",
      "etiology": "acetaminophen",
      "jaundice_to_encephalopathy_days": "2",
      "pt_sec": "20",
      "unfavorable_etiology": "false"
    },
    {
      "age_years": "30",
      "arterial_ph": "7.40",
      "bilirubin_umol_l": "50",
      "creatinine_umol_l": "80",
      "encephalopathy_grade": "1",
      "etiology": "acetaminophen",
      "jaundice_to_encephalopathy_days": "2",
      "pt_sec": "20",
      "unfavorable_etiology": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/kings_college",
  "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": "O'Grady JG, Alexander GJ, Hayllar KM, Williams R",
        "doi": "10.1016/0016-5085(89)90081-4",
        "id": "ogrady-1989",
        "pmid": "2490426",
        "source": "Gastroenterology. 1989;97(2):439-445",
        "title": "Early indicators of prognosis in fulminant hepatic failure"
      },
      "formula": "kings_college",
      "formula_expression": "acetaminophen: arterial_ph < 7.30, or (pt_sec > 100 and creatinine_umol_l > 300 and encephalopathy_grade >= 3); non_acetaminophen: pt_sec > 100, or at least 3 of (age_years < 11 or > 40; unfavorable_etiology; jaundice_to_encephalopathy_days > 7; bilirubin_umol_l > 300; pt_sec > 50)",
      "criteria": [
        {
          "value": 7.4,
          "factor": "arterial_ph_lt_7_30",
          "met": false
        },
        {
          "value": 20.0,
          "factor": "pt_sec_gt_100",
          "met": false
        },
        {
          "value": 80.0,
          "factor": "creatinine_umol_l_gt_300",
          "met": false
        },
        {
          "value": 1,
          "factor": "encephalopathy_grade_ge_3",
          "met": false
        }
      ],
      "criteria_met": false,
      "etiology": "acetaminophen"
    },
    {
      "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": "O'Grady JG, Alexander GJ, Hayllar KM, Williams R",
        "doi": "10.1016/0016-5085(89)90081-4",
        "id": "ogrady-1989",
        "pmid": "2490426",
        "source": "Gastroenterology. 1989;97(2):439-445",
        "title": "Early indicators of prognosis in fulminant hepatic failure"
      },
      "formula": "kings_college",
      "formula_expression": "acetaminophen: arterial_ph < 7.30, or (pt_sec > 100 and creatinine_umol_l > 300 and encephalopathy_grade >= 3); non_acetaminophen: pt_sec > 100, or at least 3 of (age_years < 11 or > 40; unfavorable_etiology; jaundice_to_encephalopathy_days > 7; bilirubin_umol_l > 300; pt_sec > 50)",
      "criteria": [
        {
          "value": 7.4,
          "factor": "arterial_ph_lt_7_30",
          "met": false
        },
        {
          "value": 20.0,
          "factor": "pt_sec_gt_100",
          "met": false
        },
        {
          "value": 80.0,
          "factor": "creatinine_umol_l_gt_300",
          "met": false
        },
        {
          "value": 1,
          "factor": "encephalopathy_grade_ge_3",
          "met": false
        }
      ],
      "criteria_met": false,
      "etiology": "acetaminophen"
    }
  ]
}
```

## Response fields

- `formula` (string): kings_college
- `formula_expression` (string): O'Grady 1989 acetaminophen and non-acetaminophen poor-prognosis trees
- `criteria_met` (boolean): true when the selected 1989 tree indicates poor prognosis. Not a transplant listing or organ-allocation order.
- `etiology` (string): acetaminophen or non_acetaminophen tree used
- `criteria` (array): Selected-tree factors only, each with factor, met, and value when numeric
- `citation` (object): O'Grady 1989 Gastroenterology 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": "O'Grady JG, Alexander GJ, Hayllar KM, Williams R",
    "doi": "10.1016/0016-5085(89)90081-4",
    "id": "ogrady-1989",
    "pmid": "2490426",
    "source": "Gastroenterology. 1989;97(2):439-445",
    "title": "Early indicators of prognosis in fulminant hepatic failure"
  },
  "formula": "kings_college",
  "formula_expression": "acetaminophen: arterial_ph < 7.30, or (pt_sec > 100 and creatinine_umol_l > 300 and encephalopathy_grade >= 3); non_acetaminophen: pt_sec > 100, or at least 3 of (age_years < 11 or > 40; unfavorable_etiology; jaundice_to_encephalopathy_days > 7; bilirubin_umol_l > 300; pt_sec > 50)",
  "criteria": [
    {
      "value": 7.4,
      "factor": "arterial_ph_lt_7_30",
      "met": false
    },
    {
      "value": 20.0,
      "factor": "pt_sec_gt_100",
      "met": false
    },
    {
      "value": 80.0,
      "factor": "creatinine_umol_l_gt_300",
      "met": false
    },
    {
      "value": 1,
      "factor": "encephalopathy_grade_ge_3",
      "met": false
    }
  ],
  "criteria_met": false,
  "etiology": "acetaminophen"
}
```

## Errors

- HTTP 400 `invalid_kings_etiology`: etiology must be acetaminophen or non_acetaminophen (O'Grady 1989). Returned before settlement; you are not charged.
- HTTP 400 `invalid_arterial_ph`: arterial_ph must be a number from 6.80 to 7.80. Returned before settlement; you are not charged.
- HTTP 400 `invalid_prothrombin_time`: pt_sec (8-120) is required, or pt_patient_sec (8-120) and pt_control_sec (8-20) are required. Returned before settlement; you are not charged.
- HTTP 400 `invalid_creatinine`: creatinine_mg_dl (0.1-20) or creatinine_umol_l (9-1768) is required Returned before settlement; you are not charged.
- HTTP 400 `invalid_west_haven_grade`: grade must be an integer from 0 to 4 (Conn 1977). Returned before settlement; you are not charged.
- HTTP 400 `invalid_kings_age`: age_years must be a number from 0 to 120 (O'Grady 1989 includes children). 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_jaundice_days`: jaundice_to_encephalopathy_days must be an integer from 0 to 90. 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

- [Lille score](https://magentlab.com/docs/lille) — Compute the Louvet 2007 Lille score from age, day-0 albumin, bilirubin on day 0 and day 7, creatinine, and PT seconds or INR. formula is required.
- [Maddrey DF](https://magentlab.com/docs/maddrey) — Compute the 1978 Maddrey discriminant function from patient PT, control PT, and bilirubin.
- [MELD-Na](https://magentlab.com/docs/meld-na) — Compute OPTN/UNOS 2016 MELD and MELD-Na from creatinine, bilirubin, INR, sodium, and dialysis.
- [West Haven](https://magentlab.com/docs/west-haven) — Return the Conn 1977 (West Haven / Conn score) hepatic encephalopathy grade 0-4 from a caller-assigned integer.

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