# NAFLD fibrosis score

NAFLD fibrosis score

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

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

## What it computes

Compute the Angulo 2007 NAFLD fibrosis score from age, BMI, IFG/diabetes, AST, ALT, platelets, and albumin.

## When to use

When an agent needs published NAFLD fibrosis-score arithmetic and must not invent FIB-4 cutoffs or a biopsy result.

## When not to use

- Not a diagnosis and not a biopsy. Angulo bands are published cut-points, not histology.
- BMI is caller-supplied. magent does not compute BMI from height and weight in this tool.
- Angulo 2007 only. Not FIB-4, not APRI, and not the BARD score.

## Formula

```
NFS = -1.675 + 0.037*age + 0.094*BMI + 1.13*IFG/diabetes + 0.99*(AST/ALT) - 0.013*platelets - 0.66*albumin
```

## Citation

[The NAFLD fibrosis score: a noninvasive system that identifies liver fibrosis in patients with NAFLD](https://doi.org/10.1002/hep.21496)
Angulo P, Hui JM, Marchesini G, et al.
Hepatology. 2007;45(4):846-854
DOI: [10.1002/hep.21496](https://doi.org/10.1002/hep.21496)

## Worked example

### Age 50, BMI 30, IFG, AST/ALT 1, platelets 200, albumin 4

Given: `age=50, albumin_g_dl=4, alt_u_l=40, ast_u_l=40, bmi_kg_m2=30, ifg_or_diabetes=true, platelets_10e9_l=200`

1. IFG/diabetes = 1; AST/ALT = 40/40 = 1
2. NFS = -1.675 + 0.037*50 + 0.094*30 + 1.13*1 + 0.99*1 - 0.013*200 - 0.66*4 = -0.125
3. Band indeterminate (-1.455 to 0.676)


## Also searched as

- NAFLD fibrosis score
- NFS Angulo
- nonalcoholic fatty liver fibrosis
- Angulo 2007
- NAFLD score
- liver fibrosis NAFLD

## Parameters

- `age` (integer, required): Age in years (18-120).
- `bmi_kg_m2` (number, required): Body-mass index in kg/m^2 (10-80). Caller-supplied; magent does not compute BMI.
- `ifg_or_diabetes` (boolean, required): Impaired fasting glucose or diabetes as assigned by the caller (Angulo 2007 IFG/diabetes term). true or false.
- `ast_u_l` (number, required): Aspartate aminotransferase in U/L (1-10000).
- `alt_u_l` (number, required): Alanine aminotransferase in U/L (1-10000).
- `platelets_10e9_l` (number, required): Platelet count in 10^9/L (1-2000).
- `albumin_g_dl` (number, optional): Albumin in g/dL (1-6). Provide albumin_g_dl or albumin_g_l, not both.
- `albumin_g_l` (number, optional): Albumin in g/L (10-60). Converted as g/dL = g/L / 10.

## 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/nafld_fibrosis`
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": "50",
      "albumin_g_dl": "4",
      "alt_u_l": "40",
      "ast_u_l": "40",
      "bmi_kg_m2": "30",
      "ifg_or_diabetes": "true",
      "platelets_10e9_l": "200"
    },
    {
      "age": "50",
      "albumin_g_dl": "4",
      "alt_u_l": "40",
      "ast_u_l": "40",
      "bmi_kg_m2": "30",
      "ifg_or_diabetes": "true",
      "platelets_10e9_l": "200"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/nafld_fibrosis",
  "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": "Angulo P, Hui JM, Marchesini G, et al.",
        "doi": "10.1002/hep.21496",
        "id": "angulo-2007",
        "source": "Hepatology. 2007;45(4):846-854",
        "title": "The NAFLD fibrosis score: a noninvasive system that identifies liver fibrosis in patients with NAFLD"
      },
      "formula": "nafld_fibrosis",
      "formula_expression": "NFS = -1.675 + 0.037*age + 0.094*BMI + 1.13*IFG/diabetes + 0.99*(AST/ALT) - 0.013*platelets - 0.66*albumin",
      "age_years": 50,
      "albumin_g_dl": 4.0,
      "ast_u_l": 40.0,
      "platelets_10e9_l": 200.0,
      "alt_u_l": 40.0,
      "angulo_band": "indeterminate",
      "ast_alt_ratio": 1.0,
      "bmi_kg_m2": 30.0,
      "ifg_or_diabetes": true,
      "nfs": -0.125
    },
    {
      "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": "Angulo P, Hui JM, Marchesini G, et al.",
        "doi": "10.1002/hep.21496",
        "id": "angulo-2007",
        "source": "Hepatology. 2007;45(4):846-854",
        "title": "The NAFLD fibrosis score: a noninvasive system that identifies liver fibrosis in patients with NAFLD"
      },
      "formula": "nafld_fibrosis",
      "formula_expression": "NFS = -1.675 + 0.037*age + 0.094*BMI + 1.13*IFG/diabetes + 0.99*(AST/ALT) - 0.013*platelets - 0.66*albumin",
      "age_years": 50,
      "albumin_g_dl": 4.0,
      "ast_u_l": 40.0,
      "platelets_10e9_l": 200.0,
      "alt_u_l": 40.0,
      "angulo_band": "indeterminate",
      "ast_alt_ratio": 1.0,
      "bmi_kg_m2": 30.0,
      "ifg_or_diabetes": true,
      "nfs": -0.125
    }
  ]
}
```

## Response fields

- `formula` (string): nafld_fibrosis
- `formula_expression` (string): Exact Angulo 2007 expression
- `age_years` (integer): Age in years used
- `bmi_kg_m2` (number): Caller-supplied BMI in kg/m^2
- `ifg_or_diabetes` (boolean): IFG or diabetes flag used
- `ast_u_l` (number): AST in U/L
- `alt_u_l` (number): ALT in U/L
- `ast_alt_ratio` (number): AST/ALT ratio, 4 decimals
- `platelets_10e9_l` (number): Platelets in 10^9/L
- `albumin_g_dl` (number): Albumin in g/dL
- `nfs` (number): NAFLD fibrosis score, 3 decimals
- `angulo_band` (string): Published Angulo 2007 cut-points: low (<-1.455), indeterminate (-1.455 to 0.676), high (>0.676). Not a diagnosis.
- `citation` (object): Angulo Hepatology 2007 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": "Angulo P, Hui JM, Marchesini G, et al.",
    "doi": "10.1002/hep.21496",
    "id": "angulo-2007",
    "source": "Hepatology. 2007;45(4):846-854",
    "title": "The NAFLD fibrosis score: a noninvasive system that identifies liver fibrosis in patients with NAFLD"
  },
  "formula": "nafld_fibrosis",
  "formula_expression": "NFS = -1.675 + 0.037*age + 0.094*BMI + 1.13*IFG/diabetes + 0.99*(AST/ALT) - 0.013*platelets - 0.66*albumin",
  "age_years": 50,
  "albumin_g_dl": 4.0,
  "ast_u_l": 40.0,
  "platelets_10e9_l": 200.0,
  "alt_u_l": 40.0,
  "angulo_band": "indeterminate",
  "ast_alt_ratio": 1.0,
  "bmi_kg_m2": 30.0,
  "ifg_or_diabetes": true,
  "nfs": -0.125
}
```

## Errors

- HTTP 400 `invalid_age`: age must be an integer from 18 to 120 Returned before settlement; you are not charged.
- HTTP 400 `invalid_bmi_kg_m2`: bmi_kg_m2 must be a number from 10 to 80. 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_ast`: ast_u_l must be a number from 1 to 10000 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_platelets`: platelets_10e9_l must be a number from 1 to 2000 Returned before settlement; you are not charged.
- HTTP 400 `invalid_albumin`: albumin_g_dl (1-6) or albumin_g_l (10-60) 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

- [FIB-4](https://magentlab.com/docs/fib4) — Compute the FIB-4 fibrosis index from age, AST, ALT, and platelets.
- [APRI](https://magentlab.com/docs/apri) — Compute the AST to platelet ratio index (APRI) from AST, laboratory AST ULN, and platelet count.

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