# BCLC stage (Reig 2022)

BCLC

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

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

## What it computes

Apply Reig 2022 BCLC staging and return bclc_stage (0, A, B, C, or D) with the published expected median survival. Stage only. Not a treatment recommendation.

## When to use

When an agent already has cancer-related ECOG PS, caller-assigned preserved liver function, transplant option, vascular invasion, extrahepatic disease, tumor count, and largest diameter as in Reig 2022, and needs the published BCLC stage. magent does not assign ECOG, compute Child-Pugh, or interpret imaging.

## When not to use

- Not a medical device.
- Not a treatment recommendation. This tool returns Reig 2022 BCLC stage and expected median survival only. 2022 treatment-stage-migration is out of scope.
- magent does not read imaging or compute Child-Pugh or ALBI. preserved_liver_function, transplant_option, ECOG, vascular_invasion, extrahepatic, tumor_count, and largest_cm are caller-assigned.
- Not UCSF or Milan listing (see related milan).

## Formula

```
bclc_stage D iff ecog > 2 or (not preserved_liver_function and not transplant_option); else C iff preserved_liver_function and ecog <= 2 and (vascular_invasion or extrahepatic or ecog >= 1); else 0 iff ecog == 0 and not vascular_invasion and not extrahepatic and (preserved_liver_function or transplant_option) and tumor_count == 1 and largest_cm <= 2; else A iff same eligibility and ((tumor_count == 1 and largest_cm > 2) or (tumor_count in 2..3 and largest_cm <= 3)); else B iff same eligibility and (tumor_count >= 4 or (tumor_count in 2..3 and largest_cm > 3)); else invalid_bclc_profile (Reig 2022)
```

## Citation

[BCLC strategy for prognosis prediction and treatment recommendation: The 2022 update](https://doi.org/10.1016/j.jhep.2021.11.018)
Reig M, Forner A, Rimola J, Ferrer-Fàbrega J, Burrel M, Garcia-Criado Á, Kelley RK, Galle PR, Mazzaferro V, Salem R, Sangro B, Singal AG, Vogel A, Fuster J, Ayuso C, Bruix J
J Hepatol. 2022;76(3):681-693
DOI: [10.1016/j.jhep.2021.11.018](https://doi.org/10.1016/j.jhep.2021.11.018)

## Worked example

### Single 1.5 cm tumor, PS 0, preserved liver function (stage 0)

Given: `ecog=0, extrahepatic=false, largest_cm=1.5, preserved_liver_function=true, transplant_option=false, tumor_count=1, vascular_invasion=false`

1. ecog 0 is not > 2 and preserved_liver_function is true, so not D
2. no vascular_invasion, no extrahepatic, ecog 0, so not C
3. tumor_count 1 and largest_cm 1.5 <= 2 → stage 0; expected median survival >5 years


## Also searched as

- BCLC staging
- Barcelona Clinic Liver Cancer
- BCLC 2022
- Reig 2022 BCLC
- HCC BCLC stage
- BCLC 0 A B C D
- BCLC very early stage
- hepatocellular carcinoma BCLC

## Parameters

- `ecog` (integer, required): Cancer-related ECOG performance status 0-4 as assigned by the caller (Reig 2022: do not count baseline comorbidity PS). Integer 0-4. magent does not assign ECOG.
- `preserved_liver_function` (boolean, required): Preserved liver function as assigned by the caller (Reig 2022 abandoned Child-Pugh class for this assignment). true or false. magent does not compute Child-Pugh or ALBI.
- `transplant_option` (boolean, required): Option of liver transplantation when liver function is not preserved, as assigned by the caller (Reig 2022). true or false. magent does not list for transplant.
- `vascular_invasion` (boolean, required): Vascular (vessel) invasion as assigned by the caller. true or false. magent does not interpret imaging.
- `extrahepatic` (boolean, required): Extrahepatic spread as assigned by the caller. true or false. magent does not interpret imaging.
- `tumor_count` (integer, required): Number of HCC nodules (integer 1-20) as assigned by the caller. Stage 0 is a single tumor <=2 cm; stage A allows a solitary tumor of any size or 2-3 nodules none >3 cm; four or more nodules are stage B when otherwise 0/A/B-eligible. magent does not interpret imaging.
- `largest_cm` (number, required): Largest tumor diameter in centimetres (0.1-30). Stage 0 meets at 2.0 cm and is A at 2.1 when solitary. Two or three nodules meet A at 3.0 cm and are B at 3.1. magent does not interpret imaging.

## 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/bclc`
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": [
    {
      "ecog": "0",
      "extrahepatic": "false",
      "largest_cm": "1.5",
      "preserved_liver_function": "true",
      "transplant_option": "false",
      "tumor_count": "1",
      "vascular_invasion": "false"
    },
    {
      "ecog": "0",
      "extrahepatic": "false",
      "largest_cm": "1.5",
      "preserved_liver_function": "true",
      "transplant_option": "false",
      "tumor_count": "1",
      "vascular_invasion": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/bclc",
  "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": "Reig M, Forner A, Rimola J, Ferrer-Fàbrega J, Burrel M, Garcia-Criado Á, Kelley RK, Galle PR, Mazzaferro V, Salem R, Sangro B, Singal AG, Vogel A, Fuster J, Ayuso C, Bruix J",
        "doi": "10.1016/j.jhep.2021.11.018",
        "id": "reig-2022",
        "pmid": "34801630",
        "source": "J Hepatol. 2022;76(3):681-693",
        "title": "BCLC strategy for prognosis prediction and treatment recommendation: The 2022 update"
      },
      "formula": "bclc",
      "formula_expression": "bclc_stage D iff ecog > 2 or (not preserved_liver_function and not transplant_option); else C iff preserved_liver_function and ecog <= 2 and (vascular_invasion or extrahepatic or ecog >= 1); else 0 iff ecog == 0 and not vascular_invasion and not extrahepatic and (preserved_liver_function or transplant_option) and tumor_count == 1 and largest_cm <= 2; else A iff same eligibility and ((tumor_count == 1 and largest_cm > 2) or (tumor_count in 2..3 and largest_cm <= 3)); else B iff same eligibility and (tumor_count >= 4 or (tumor_count in 2..3 and largest_cm > 3)); else invalid_bclc_profile (Reig 2022)",
      "criteria": [
        {
          "factor": "ps_gt_2",
          "met": false
        },
        {
          "factor": "impaired_liver_without_lt",
          "met": false
        },
        {
          "factor": "preserved_liver_function",
          "met": true
        },
        {
          "factor": "vascular_invasion",
          "met": false
        },
        {
          "factor": "extrahepatic",
          "met": false
        },
        {
          "factor": "cancer_related_symptoms",
          "met": false
        },
        {
          "factor": "single_leq_2cm",
          "met": true
        },
        {
          "factor": "early_solitary_or_upto_3",
          "met": false
        },
        {
          "factor": "multifocal_beyond_a",
          "met": false
        }
      ],
      "bclc_stage": "0",
      "ecog": 0,
      "expected_median_survival": ">5 years",
      "extrahepatic": false,
      "largest_cm": 1.5,
      "preserved_liver_function": true,
      "transplant_option": false,
      "tumor_count": 1,
      "vascular_invasion": 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": "Reig M, Forner A, Rimola J, Ferrer-Fàbrega J, Burrel M, Garcia-Criado Á, Kelley RK, Galle PR, Mazzaferro V, Salem R, Sangro B, Singal AG, Vogel A, Fuster J, Ayuso C, Bruix J",
        "doi": "10.1016/j.jhep.2021.11.018",
        "id": "reig-2022",
        "pmid": "34801630",
        "source": "J Hepatol. 2022;76(3):681-693",
        "title": "BCLC strategy for prognosis prediction and treatment recommendation: The 2022 update"
      },
      "formula": "bclc",
      "formula_expression": "bclc_stage D iff ecog > 2 or (not preserved_liver_function and not transplant_option); else C iff preserved_liver_function and ecog <= 2 and (vascular_invasion or extrahepatic or ecog >= 1); else 0 iff ecog == 0 and not vascular_invasion and not extrahepatic and (preserved_liver_function or transplant_option) and tumor_count == 1 and largest_cm <= 2; else A iff same eligibility and ((tumor_count == 1 and largest_cm > 2) or (tumor_count in 2..3 and largest_cm <= 3)); else B iff same eligibility and (tumor_count >= 4 or (tumor_count in 2..3 and largest_cm > 3)); else invalid_bclc_profile (Reig 2022)",
      "criteria": [
        {
          "factor": "ps_gt_2",
          "met": false
        },
        {
          "factor": "impaired_liver_without_lt",
          "met": false
        },
        {
          "factor": "preserved_liver_function",
          "met": true
        },
        {
          "factor": "vascular_invasion",
          "met": false
        },
        {
          "factor": "extrahepatic",
          "met": false
        },
        {
          "factor": "cancer_related_symptoms",
          "met": false
        },
        {
          "factor": "single_leq_2cm",
          "met": true
        },
        {
          "factor": "early_solitary_or_upto_3",
          "met": false
        },
        {
          "factor": "multifocal_beyond_a",
          "met": false
        }
      ],
      "bclc_stage": "0",
      "ecog": 0,
      "expected_median_survival": ">5 years",
      "extrahepatic": false,
      "largest_cm": 1.5,
      "preserved_liver_function": true,
      "transplant_option": false,
      "tumor_count": 1,
      "vascular_invasion": false
    }
  ]
}
```

## Response fields

- `formula` (string): bclc
- `formula_expression` (string): Reig 2022 first-match BCLC stage 0/A/B/C/D (stage only)
- `bclc_stage` (string): Reig 2022 BCLC stage 0, A, B, C, or D. Not a treatment recommendation.
- `expected_median_survival` (string): Published expected median survival: >5 years (0 and A), >2.5 years (B), >2 years (C), 3 months (D)
- `ecog` (integer): Echo of the caller-assigned cancer-related ECOG PS (0-4)
- `preserved_liver_function` (boolean): Echo of the caller-assigned preserved-liver-function flag
- `transplant_option` (boolean): Echo of the caller-assigned transplant-option flag
- `vascular_invasion` (boolean): Echo of the caller-assigned vascular-invasion flag
- `extrahepatic` (boolean): Echo of the caller-assigned extrahepatic-spread flag
- `tumor_count` (integer): Echo of the caller-assigned nodule count (1-20)
- `largest_cm` (number): Echo of the caller-assigned largest diameter in centimetres
- `criteria` (array): Per-factor Tree rows with factor and met for the Reig 2022 first-match predicates
- `citation` (object): Reig 2022 J Hepatol 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": "Reig M, Forner A, Rimola J, Ferrer-Fàbrega J, Burrel M, Garcia-Criado Á, Kelley RK, Galle PR, Mazzaferro V, Salem R, Sangro B, Singal AG, Vogel A, Fuster J, Ayuso C, Bruix J",
    "doi": "10.1016/j.jhep.2021.11.018",
    "id": "reig-2022",
    "pmid": "34801630",
    "source": "J Hepatol. 2022;76(3):681-693",
    "title": "BCLC strategy for prognosis prediction and treatment recommendation: The 2022 update"
  },
  "formula": "bclc",
  "formula_expression": "bclc_stage D iff ecog > 2 or (not preserved_liver_function and not transplant_option); else C iff preserved_liver_function and ecog <= 2 and (vascular_invasion or extrahepatic or ecog >= 1); else 0 iff ecog == 0 and not vascular_invasion and not extrahepatic and (preserved_liver_function or transplant_option) and tumor_count == 1 and largest_cm <= 2; else A iff same eligibility and ((tumor_count == 1 and largest_cm > 2) or (tumor_count in 2..3 and largest_cm <= 3)); else B iff same eligibility and (tumor_count >= 4 or (tumor_count in 2..3 and largest_cm > 3)); else invalid_bclc_profile (Reig 2022)",
  "criteria": [
    {
      "factor": "ps_gt_2",
      "met": false
    },
    {
      "factor": "impaired_liver_without_lt",
      "met": false
    },
    {
      "factor": "preserved_liver_function",
      "met": true
    },
    {
      "factor": "vascular_invasion",
      "met": false
    },
    {
      "factor": "extrahepatic",
      "met": false
    },
    {
      "factor": "cancer_related_symptoms",
      "met": false
    },
    {
      "factor": "single_leq_2cm",
      "met": true
    },
    {
      "factor": "early_solitary_or_upto_3",
      "met": false
    },
    {
      "factor": "multifocal_beyond_a",
      "met": false
    }
  ],
  "bclc_stage": "0",
  "ecog": 0,
  "expected_median_survival": ">5 years",
  "extrahepatic": false,
  "largest_cm": 1.5,
  "preserved_liver_function": true,
  "transplant_option": false,
  "tumor_count": 1,
  "vascular_invasion": false
}
```

## Errors

- HTTP 400 `invalid_ecog_ps`: ecog must be an integer from 0 to 4 (Oken 1982). Grade 5 (dead) is not scored. 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_tumor_count`: tumor_count must be an integer from 1 to 20 (Mazzaferro 1996). Returned before settlement; you are not charged.
- HTTP 400 `invalid_largest_cm`: largest_cm must be a number from 0.1 to 30 (Mazzaferro 1996). Returned before settlement; you are not charged.
- HTTP 400 `invalid_bclc_profile`: ecog, preserved_liver_function, transplant_option, vascular_invasion, extrahepatic, and tumor burden do not match a Reig 2022 BCLC stage (0, A, B, C, or D). 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

- [Child–Pugh](https://magentlab.com/docs/child-pugh) — Compute the Child–Turcotte–Pugh cirrhosis severity score from bilirubin, albumin, INR, encephalopathy, and ascites.
- [Milan](https://magentlab.com/docs/milan) — Apply Mazzaferro 1996 Milan criteria and return whether the published size, count, vascular-invasion, and extrahepatic rules all hold (meets_milan).
- [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.

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