# REACH-B HCC risk

REACH-B

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

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

## What it computes

Sum the Yang 2011 REACH-B 17-point score (sex, age 30-65, ALT, HBeAg, HBV DNA copies/mL) and return the published 3-, 5-, and 10-year HCC risk percents.

## When to use

When an agent has caller-assigned sex, age 30-65, ALT, HBeAg, and HBV DNA in copies/mL as in Yang 2011, and needs the published non-cirrhotic REVEAL-HBV score and table risks, not an IU/mL conversion and not a cirrhosis instrument.

## When not to use

- Not a medical device.
- Not a diagnosis of HCC and not a biopsy order.
- Yang 2011 derivation excluded cirrhosis. Not for patients with cirrhosis. Not the later modified REACH-B that scores age >=65 as 7.
- Age must be 30-65 as in the derivation cohort. magent does not assay ALT or HBV DNA. HBV DNA is copies/mL as published; this tool does not convert IU/mL.
- HBV DNA >=1000000 copies/mL scores 4; 100000-999999 scores 5 (Yang 2011 table, non-monotonic).

## Formula

```
REACH-B = sex + age + ALT + HBeAg + HBV DNA copies/mL; female 0, male 2; age 30-34 -> 0, 35-39 -> 1, 40-44 -> 2, 45-49 -> 3, 50-54 -> 4, 55-59 -> 5, 60-65 -> 6; ALT <15 -> 0, 15-44 -> 1, >=45 -> 2; HBeAg positive 2; HBV DNA copies/mL <300 -> 0, 300-9999 -> 0, 10000-99999 -> 3, 100000-999999 -> 5, >=1000000 -> 4; max 17; 3/5/10-year HCC percent from Yang 2011 score table
```

## Citation

[Risk estimation for hepatocellular carcinoma in chronic hepatitis B (REACH-B): development and validation of a predictive score](https://doi.org/10.1016/S1470-2045(11)70077-8)
Yang HI, Yuen MF, Chan HL, et al
Lancet Oncol. 2011;12(6):568-574
DOI: [10.1016/S1470-2045(11)70077-8](https://doi.org/10.1016/S1470-2045(11)70077-8)

## Worked example

### Female age 30, ALT 14, HBeAg negative, HBV DNA 200 copies/mL

Given: `age=30, alt_u_l=14, hbeag_positive=false, hbv_dna_copies_per_ml=200, sex=female`

1. Female -> 0; age 30 (30-34) -> 0; ALT 14 (<15) -> 0; HBeAg false -> 0; HBV DNA 200 (<300) -> 0
2. Score = 0 (max 17); 3/5/10-year HCC risks 0.0 / 0.0 / 0.0. Not a diagnosis.


## Also searched as

- REACH-B
- REACH-B score
- Yang HCC risk score
- REVEAL-HBV HCC score
- hepatitis B HCC risk
- REACH B
- Yang 2011 REACH-B
- chronic hepatitis B hepatocellular carcinoma risk

## Parameters

- `sex` (string, required): female or male. Yang 2011: female scores 0; male scores 2.
- `age` (integer, required): Age in years. Yang 2011 derivation 30-65 only: 30-34 scores 0; 35-39 scores 1; 40-44 scores 2; 45-49 scores 3; 50-54 scores 4; 55-59 scores 5; 60-65 scores 6. Age 34 scores 0; 35 scores 1; 65 scores 6. Age outside 30-65 is rejected. This tool does not score age >=65 as 7.
- `alt_u_l` (number, required): Alanine aminotransferase in U/L (1-10000). Caller-assigned; magent does not assay ALT. Yang 2011: <15 scores 0; 15-44 scores 1; >=45 scores 2. ALT 14 scores 0; 15 and 44 score 1; 45 scores 2.
- `hbeag_positive` (boolean, required): HBeAg positive as assigned by the caller (Yang 2011). true scores 2; false scores 0. magent does not assay HBeAg.
- `hbv_dna_copies_per_ml` (integer, required): HBV DNA in copies/mL (integer 0-10000000000). Yang 2011 uses copies/mL, not IU/mL. magent does not assay HBV DNA and does not convert units. <300 scores 0; 300-9999 scores 0; 10000-99999 scores 3; 100000-999999 scores 5; >=1000000 scores 4 (non-monotonic: 10^6 scores 4, 10^5 to 10^6-1 scores 5).

## 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/reach_b`
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": "30",
      "alt_u_l": "14",
      "hbeag_positive": "false",
      "hbv_dna_copies_per_ml": "200",
      "sex": "female"
    },
    {
      "age": "30",
      "alt_u_l": "14",
      "hbeag_positive": "false",
      "hbv_dna_copies_per_ml": "200",
      "sex": "female"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/reach_b",
  "items": [
    {
      "components": [
        {
          "value": "female",
          "factor": "sex",
          "points": 0,
          "present": false
        },
        {
          "value": 30,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "value": 14.0,
          "factor": "alt",
          "points": 0,
          "present": false
        },
        {
          "factor": "hbeag",
          "points": 0,
          "present": false
        },
        {
          "value": 200,
          "factor": "hbv_dna",
          "points": 0,
          "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": "Yang HI, Yuen MF, Chan HL, et al",
        "doi": "10.1016/S1470-2045(11)70077-8",
        "id": "yang-2011",
        "pmid": "21497551",
        "source": "Lancet Oncol. 2011;12(6):568-574",
        "title": "Risk estimation for hepatocellular carcinoma in chronic hepatitis B (REACH-B): development and validation of a predictive score"
      },
      "formula": "reach_b",
      "formula_expression": "REACH-B = sex + age + ALT + HBeAg + HBV DNA copies/mL; female 0, male 2; age 30-34 -> 0, 35-39 -> 1, 40-44 -> 2, 45-49 -> 3, 50-54 -> 4, 55-59 -> 5, 60-65 -> 6; ALT <15 -> 0, 15-44 -> 1, >=45 -> 2; HBeAg positive 2; HBV DNA copies/mL <300 -> 0, 300-9999 -> 0, 10000-99999 -> 3, 100000-999999 -> 5, >=1000000 -> 4; max 17; 3/5/10-year HCC percent from Yang 2011 score table",
      "age_years": 30,
      "max_score": 17,
      "score": 0,
      "sex": "female",
      "alt_u_l": 14.0,
      "hbeag_positive": false,
      "hbv_dna_copies_per_ml": 200,
      "risk_10y_percent": 0.0,
      "risk_3y_percent": 0.0,
      "risk_5y_percent": 0.0
    },
    {
      "components": [
        {
          "value": "female",
          "factor": "sex",
          "points": 0,
          "present": false
        },
        {
          "value": 30,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "value": 14.0,
          "factor": "alt",
          "points": 0,
          "present": false
        },
        {
          "factor": "hbeag",
          "points": 0,
          "present": false
        },
        {
          "value": 200,
          "factor": "hbv_dna",
          "points": 0,
          "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": "Yang HI, Yuen MF, Chan HL, et al",
        "doi": "10.1016/S1470-2045(11)70077-8",
        "id": "yang-2011",
        "pmid": "21497551",
        "source": "Lancet Oncol. 2011;12(6):568-574",
        "title": "Risk estimation for hepatocellular carcinoma in chronic hepatitis B (REACH-B): development and validation of a predictive score"
      },
      "formula": "reach_b",
      "formula_expression": "REACH-B = sex + age + ALT + HBeAg + HBV DNA copies/mL; female 0, male 2; age 30-34 -> 0, 35-39 -> 1, 40-44 -> 2, 45-49 -> 3, 50-54 -> 4, 55-59 -> 5, 60-65 -> 6; ALT <15 -> 0, 15-44 -> 1, >=45 -> 2; HBeAg positive 2; HBV DNA copies/mL <300 -> 0, 300-9999 -> 0, 10000-99999 -> 3, 100000-999999 -> 5, >=1000000 -> 4; max 17; 3/5/10-year HCC percent from Yang 2011 score table",
      "age_years": 30,
      "max_score": 17,
      "score": 0,
      "sex": "female",
      "alt_u_l": 14.0,
      "hbeag_positive": false,
      "hbv_dna_copies_per_ml": 200,
      "risk_10y_percent": 0.0,
      "risk_3y_percent": 0.0,
      "risk_5y_percent": 0.0
    }
  ]
}
```

## Response fields

- `formula` (string): reach_b
- `formula_expression` (string): Exact Yang 2011 17-point expression
- `score` (integer): REACH-B points; published range 0-17
- `max_score` (integer): 17 (2+6+2+2+5; DNA max is 5, not 4)
- `risk_3y_percent` (number): Published 3-year HCC percent for this score (Yang 2011 table). Not a diagnosis.
- `risk_5y_percent` (number): Published 5-year HCC percent for this score (Yang 2011 table). Not a diagnosis.
- `risk_10y_percent` (number): Published 10-year HCC percent for this score (Yang 2011 table). Not a diagnosis.
- `sex` (string): female or male used for the sex points
- `age_years` (integer): Age in years used for the age band
- `alt_u_l` (number): Caller-assigned ALT in U/L used
- `hbeag_positive` (boolean): Caller-assigned HBeAg flag used
- `hbv_dna_copies_per_ml` (integer): Caller-assigned HBV DNA in copies/mL used
- `components` (array): Per-factor Yang 2011 points
- `citation` (object): Yang 2011 Lancet Oncol citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": "female",
      "factor": "sex",
      "points": 0,
      "present": false
    },
    {
      "value": 30,
      "factor": "age",
      "points": 0,
      "present": false
    },
    {
      "value": 14.0,
      "factor": "alt",
      "points": 0,
      "present": false
    },
    {
      "factor": "hbeag",
      "points": 0,
      "present": false
    },
    {
      "value": 200,
      "factor": "hbv_dna",
      "points": 0,
      "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": "Yang HI, Yuen MF, Chan HL, et al",
    "doi": "10.1016/S1470-2045(11)70077-8",
    "id": "yang-2011",
    "pmid": "21497551",
    "source": "Lancet Oncol. 2011;12(6):568-574",
    "title": "Risk estimation for hepatocellular carcinoma in chronic hepatitis B (REACH-B): development and validation of a predictive score"
  },
  "formula": "reach_b",
  "formula_expression": "REACH-B = sex + age + ALT + HBeAg + HBV DNA copies/mL; female 0, male 2; age 30-34 -> 0, 35-39 -> 1, 40-44 -> 2, 45-49 -> 3, 50-54 -> 4, 55-59 -> 5, 60-65 -> 6; ALT <15 -> 0, 15-44 -> 1, >=45 -> 2; HBeAg positive 2; HBV DNA copies/mL <300 -> 0, 300-9999 -> 0, 10000-99999 -> 3, 100000-999999 -> 5, >=1000000 -> 4; max 17; 3/5/10-year HCC percent from Yang 2011 score table",
  "age_years": 30,
  "max_score": 17,
  "score": 0,
  "sex": "female",
  "alt_u_l": 14.0,
  "hbeag_positive": false,
  "hbv_dna_copies_per_ml": 200,
  "risk_10y_percent": 0.0,
  "risk_3y_percent": 0.0,
  "risk_5y_percent": 0.0
}
```

## Errors

- HTTP 400 `invalid_sex`: sex must be female or male Returned before settlement; you are not charged.
- HTTP 400 `invalid_age`: age must be an integer from 18 to 120 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_flag`: boolean clinical flags must be true or false Returned before settlement; you are not charged.
- HTTP 400 `invalid_hbv_dna`: hbv_dna_copies_per_ml must be an integer from 0 to 10000000000 (Yang 2011 copies/mL). Returned before settlement; you are not charged.
- HTTP 400 `invalid_reach_b`: age must be 30-65, and each other REACH-B 2011 item must be a published category. 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

- [FIB-4](https://magentlab.com/docs/fib4) — Compute the FIB-4 fibrosis index from age, AST, ALT, and platelets.

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