# Liver decompensation after HCC resection

HCC-LD

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

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

## What it computes

Apply the Citterio 2016 JAMA Surgery hierarchic three-class rule to caller-assigned portal hypertension, planned major hepatectomy, and MELD, and return risk low, intermediate, or high with the published liver-decompensation and liver-related mortality percents.

## When to use

When an agent already has caller-assigned portal hypertension, planned resection extent, and a MELD score, and needs the published Citterio 2016 HCC-resection decompensation class. magent does not compute MELD or HVPG.

## When not to use

- Not a medical device and not a diagnosis of hepatocellular carcinoma or liver decompensation.
- Not a surgical indication and not a transplant listing protocol.
- Citterio 2016 JAMA Surgery published classes only. High is portal hypertension plus major hepatectomy. Low is no portal hypertension, minor resection, and MELD ≤ 9. All other combinations are intermediate.
- portal_hypertension, major_hepatectomy, and meld are caller-assigned. magent does not measure HVPG, choose extent of resection, or compute MELD.
- Not ALBI. This tool does not implement Johnson 2015 albumin-bilirubin grade.

## Formula

```
Citterio 2016 JAMA Surgery: high if portal_hypertension and major_hepatectomy; low if not portal_hypertension and not major_hepatectomy and meld ≤ 9; else intermediate. Published LD 4.9 / 28.6 / 60.0 and liver-related mortality 4.4 / 9.0 / 25.0. Caller-assigned PHT, planned extent, and MELD. magent does not compute MELD or HVPG.
```

## Citation

[Hierarchic Interaction of Factors Associated With Liver Decompensation After Resection for Hepatocellular Carcinoma](https://doi.org/10.1001/jamasurg.2016.1121)
Citterio D, Facciorusso A, Sposito C, Rota R, Bhoori S, Mazzaferro V
JAMA Surg. 2016;151(9):846-853
DOI: [10.1001/jamasurg.2016.1121](https://doi.org/10.1001/jamasurg.2016.1121)

## Worked example

### No PHT, minor resection, MELD 8 is low

Given: `major_hepatectomy=false, meld=8, portal_hypertension=false`

1. portal_hypertension false, major_hepatectomy false, meld 8
2. Not portal hypertension plus major hepatectomy
3. No PHT, minor resection, and MELD ≤ 9 → risk low (LD 4.9%, liver-related mortality 4.4%)


### PHT plus major hepatectomy is high

Given: `major_hepatectomy=true, meld=8, portal_hypertension=true`

1. portal_hypertension true, major_hepatectomy true, meld 8
2. Portal hypertension and major hepatectomy is high regardless of MELD (LD 60.0%, liver-related mortality 25.0%)


### No PHT plus major hepatectomy is intermediate

Given: `major_hepatectomy=true, meld=8, portal_hypertension=false`

1. portal_hypertension false, major_hepatectomy true, meld 8
2. Not the high node and not the low node → risk intermediate (LD 28.6%, liver-related mortality 9.0%)


## Also searched as

- Citterio HCC-LD
- liver decompensation after HCC resection
- HCC resection decompensation
- Citterio 2016
- post-hepatectomy liver decompensation
- hepatocellular carcinoma resection risk
- Citterio JAMA Surgery

## Parameters

- `portal_hypertension` (boolean, required): Clinically significant portal hypertension as assigned by the caller (Citterio 2016). true or false. magent does not measure HVPG or assign portal hypertension.
- `major_hepatectomy` (boolean, required): Planned major hepatectomy as assigned by the caller (Citterio 2016). true or false. magent does not choose extent of resection.
- `meld` (integer, required): Caller-assigned MELD integer 6-40 (Citterio 2016). Low requires meld ≤ 9 when portal hypertension and major hepatectomy are both false. magent does not compute MELD.

## 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/hcc_ld`
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": [
    {
      "major_hepatectomy": "false",
      "meld": "8",
      "portal_hypertension": "false"
    },
    {
      "major_hepatectomy": "false",
      "meld": "8",
      "portal_hypertension": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/hcc_ld",
  "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": "Citterio D, Facciorusso A, Sposito C, Rota R, Bhoori S, Mazzaferro V",
        "doi": "10.1001/jamasurg.2016.1121",
        "id": "citterio-2016",
        "pmid": "27248425",
        "source": "JAMA Surg. 2016;151(9):846-853",
        "title": "Hierarchic Interaction of Factors Associated With Liver Decompensation After Resection for Hepatocellular Carcinoma"
      },
      "formula": "hcc_ld",
      "formula_expression": "Citterio 2016 JAMA Surgery: high if portal_hypertension and major_hepatectomy; low if not portal_hypertension and not major_hepatectomy and meld ≤ 9; else intermediate. Published LD 4.9 / 28.6 / 60.0 and liver-related mortality 4.4 / 9.0 / 25.0. Caller-assigned PHT, planned extent, and MELD. magent does not compute MELD or HVPG.",
      "criteria": [
        {
          "factor": "portal_hypertension",
          "met": false
        },
        {
          "factor": "major_hepatectomy",
          "met": false
        },
        {
          "value": 8,
          "factor": "meld_le_9",
          "met": true
        },
        {
          "factor": "low",
          "met": true
        },
        {
          "factor": "intermediate",
          "met": false
        },
        {
          "factor": "high",
          "met": false
        }
      ],
      "risk": "low",
      "ld_rate_percent": 4.9,
      "liver_related_mortality_percent": 4.4,
      "major_hepatectomy": false,
      "meld": 8,
      "portal_hypertension": 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": "Citterio D, Facciorusso A, Sposito C, Rota R, Bhoori S, Mazzaferro V",
        "doi": "10.1001/jamasurg.2016.1121",
        "id": "citterio-2016",
        "pmid": "27248425",
        "source": "JAMA Surg. 2016;151(9):846-853",
        "title": "Hierarchic Interaction of Factors Associated With Liver Decompensation After Resection for Hepatocellular Carcinoma"
      },
      "formula": "hcc_ld",
      "formula_expression": "Citterio 2016 JAMA Surgery: high if portal_hypertension and major_hepatectomy; low if not portal_hypertension and not major_hepatectomy and meld ≤ 9; else intermediate. Published LD 4.9 / 28.6 / 60.0 and liver-related mortality 4.4 / 9.0 / 25.0. Caller-assigned PHT, planned extent, and MELD. magent does not compute MELD or HVPG.",
      "criteria": [
        {
          "factor": "portal_hypertension",
          "met": false
        },
        {
          "factor": "major_hepatectomy",
          "met": false
        },
        {
          "value": 8,
          "factor": "meld_le_9",
          "met": true
        },
        {
          "factor": "low",
          "met": true
        },
        {
          "factor": "intermediate",
          "met": false
        },
        {
          "factor": "high",
          "met": false
        }
      ],
      "risk": "low",
      "ld_rate_percent": 4.9,
      "liver_related_mortality_percent": 4.4,
      "major_hepatectomy": false,
      "meld": 8,
      "portal_hypertension": false
    }
  ]
}
```

## Response fields

- `formula` (string): hcc_ld
- `formula_expression` (string): Published Citterio 2016 JAMA Surgery three-class hierarchic rule
- `portal_hypertension` (boolean): Caller-assigned clinically significant portal hypertension used
- `major_hepatectomy` (boolean): Caller-assigned planned major hepatectomy used
- `meld` (integer): Caller-assigned MELD integer 6-40 echoed. magent does not recompute MELD.
- `risk` (string): low, intermediate, or high (Citterio 2016). High if portal hypertension and major hepatectomy. Low if neither and meld ≤ 9. Else intermediate. Not a surgical indication or transplant listing.
- `ld_rate_percent` (number): Published liver-decompensation percent: 4.9 low, 28.6 intermediate, 60.0 high
- `liver_related_mortality_percent` (number): Published liver-related mortality percent: 4.4 low, 9.0 intermediate, 25.0 high
- `criteria` (array): Tree rows for portal_hypertension, major_hepatectomy, meld_le_9, and exclusive low, intermediate, high with factor and met
- `citation` (object): Citterio 2016 JAMA Surgery 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": "Citterio D, Facciorusso A, Sposito C, Rota R, Bhoori S, Mazzaferro V",
    "doi": "10.1001/jamasurg.2016.1121",
    "id": "citterio-2016",
    "pmid": "27248425",
    "source": "JAMA Surg. 2016;151(9):846-853",
    "title": "Hierarchic Interaction of Factors Associated With Liver Decompensation After Resection for Hepatocellular Carcinoma"
  },
  "formula": "hcc_ld",
  "formula_expression": "Citterio 2016 JAMA Surgery: high if portal_hypertension and major_hepatectomy; low if not portal_hypertension and not major_hepatectomy and meld ≤ 9; else intermediate. Published LD 4.9 / 28.6 / 60.0 and liver-related mortality 4.4 / 9.0 / 25.0. Caller-assigned PHT, planned extent, and MELD. magent does not compute MELD or HVPG.",
  "criteria": [
    {
      "factor": "portal_hypertension",
      "met": false
    },
    {
      "factor": "major_hepatectomy",
      "met": false
    },
    {
      "value": 8,
      "factor": "meld_le_9",
      "met": true
    },
    {
      "factor": "low",
      "met": true
    },
    {
      "factor": "intermediate",
      "met": false
    },
    {
      "factor": "high",
      "met": false
    }
  ],
  "risk": "low",
  "ld_rate_percent": 4.9,
  "liver_related_mortality_percent": 4.4,
  "major_hepatectomy": false,
  "meld": 8,
  "portal_hypertension": false
}
```

## Errors

- HTTP 400 `invalid_meld_score`: meld must be an integer from 6 to 40 (Citterio 2016 caller-assigned MELD; magent does not recompute MELD). 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

- [MELD](https://magentlab.com/docs/meld) — Compute the Kamath 2001 model for end-stage liver disease (MELD) integer from creatinine, bilirubin, INR, and cholestatic or alcoholic etiology.
- [Child–Pugh](https://magentlab.com/docs/child-pugh) — Compute the Child–Turcotte–Pugh cirrhosis severity score from bilirubin, albumin, INR, encephalopathy, and ascites.

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