# Eosinophilic oesophagitis endoscopic reference score

EREFS

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

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

## What it computes

Sum five caller-assigned Hirano 2013 modified EREFS descriptors (edema 0-1, rings 0-3, exudates 0-2, furrows 0-1 after collapsing original 0-2, stricture 0-1) and return the total (max 8). Does not return activity bands, inflammatory or fibrostenotic subscores, or later 0-9 furrows 0-2 expansions.

## When to use

When an agent has already assigned Hirano 2013 modified edema, rings, exudates, furrows, and stricture at endoscopy and needs the five-item 0-8 total, not a diagnosis, inflammatory/fibrostenotic subscores, or the later 0-9 expansion that restores furrows 0-2.

## When not to use

- Not a medical device and not a diagnosis of eosinophilic oesophagitis or a treatment order.
- Each descriptor is a caller-assigned Hirano 2013 modified token. magent does not perform endoscopy.
- Furrows use the modified good-agreement collapse (absent 0, present 1). This is not original Hirano 2013 furrows 0-2 and not later 0-9 expansions that restore furrows 0-2.
- Hirano 2013 did not publish mild, moderate, or severe cutoffs for the total score. magent returns score and max_score only and does not apply later EREFS activity bands.
- Crepe-paper mucosa and narrow-calibre oesophagus are not included in the sum. Inflammatory and fibrostenotic subscores are not returned.

## Formula

```
EREFS = edema (absent 0, present 1; loss of vascular markings) + rings (none 0, mild 1, moderate 2, severe 3) + exudates (none 0, mild_lt_10pct 1, severe_gt_10pct 2) + furrows (absent 0, present 1; modified, original 0-2 collapsed) + stricture (absent 0, present 1); Hirano 2013 modified good-agreement version; not later 0-9 furrows 0-2; crepe-paper and narrow-calibre not scored; no published total-score activity bands
```

## Citation

[Endoscopic assessment of the oesophageal features of eosinophilic oesophagitis: validation of a novel classification and grading system.](https://doi.org/10.1136/gutjnl-2011-301817)
Hirano I, Moy N, Heckman MG, Thomas CS, Gonsalves N, Achem SR
Gut. 2013;62(4):489-495
DOI: [10.1136/gutjnl-2011-301817](https://doi.org/10.1136/gutjnl-2011-301817)

## Worked example

### All descriptors absent or none

Given: `edema=absent, exudates=none, furrows=absent, rings=none, stricture=absent`

1. edema absent 0 + rings none 0 + exudates none 0 + furrows absent 0 + stricture absent 0
2. Score = 0 (max 8). No activity band.


### All descriptors maximum

Given: `edema=present, exudates=severe_gt_10pct, furrows=present, rings=severe, stricture=present`

1. edema present 1 + rings severe 3 + exudates severe_gt_10pct 2 + furrows present 1 + stricture present 1
2. Score = 8 (max 8). No activity band.


## Also searched as

- EREFS
- eosinophilic oesophagitis endoscopic reference score
- EoE EREFS
- Hirano EREFS
- EREFS score
- eosinophilic esophagitis endoscopy score
- modified EREFS
- EoE endoscopic reference score
- Hirano 2013 EREFS
- oesophageal EREFS

## Parameters

- `edema` (string, required): Caller-assigned Hirano 2013 modified EREFS edema (oedema; loss of vascular markings): absent (0; vascular markings present) or present (1; decreased or absent vascular markings). magent does not perform endoscopy.
- `rings` (string, required): Caller-assigned Hirano 2013 EREFS rings (fixed rings): none (0), mild (1; subtle circumferential ridges), moderate (2; distinct rings that a diagnostic adult endoscope still passes), or severe (3; cannot pass a diagnostic adult endoscope). magent does not perform endoscopy.
- `exudates` (string, required): Caller-assigned Hirano 2013 EREFS exudates (white plaques): none (0), mild_lt_10pct (1; lesions involving <10% of the oesophageal surface area), or severe_gt_10pct (2; lesions involving >10% of the oesophageal surface area). magent does not perform endoscopy.
- `furrows` (string, required): Caller-assigned Hirano 2013 modified EREFS furrows (vertical lines): absent (0) or present (1). Original Hirano 2013 graded furrows 0-2 (none / mild without depth / severe with indentation); the modified good-agreement version collapses that to absent vs present. Not the later 0-9 expansion that restores furrows 0-2. magent does not perform endoscopy.
- `stricture` (string, required): Caller-assigned Hirano 2013 EREFS stricture: absent (0) or present (1). magent does not perform endoscopy.

## 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/erefs`
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": [
    {
      "edema": "absent",
      "exudates": "none",
      "furrows": "absent",
      "rings": "none",
      "stricture": "absent"
    },
    {
      "edema": "absent",
      "exudates": "none",
      "furrows": "absent",
      "rings": "none",
      "stricture": "absent"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/erefs",
  "items": [
    {
      "components": [
        {
          "value": "absent",
          "factor": "edema",
          "points": 0,
          "present": true
        },
        {
          "value": "none",
          "factor": "rings",
          "points": 0,
          "present": true
        },
        {
          "value": "none",
          "factor": "exudates",
          "points": 0,
          "present": true
        },
        {
          "value": "absent",
          "factor": "furrows",
          "points": 0,
          "present": true
        },
        {
          "value": "absent",
          "factor": "stricture",
          "points": 0,
          "present": true
        }
      ],
      "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": "Hirano I, Moy N, Heckman MG, Thomas CS, Gonsalves N, Achem SR",
        "doi": "10.1136/gutjnl-2011-301817",
        "id": "hirano-2013",
        "pmid": "22619364",
        "source": "Gut. 2013;62(4):489-495",
        "title": "Endoscopic assessment of the oesophageal features of eosinophilic oesophagitis: validation of a novel classification and grading system."
      },
      "formula": "erefs",
      "formula_expression": "EREFS = edema (absent 0, present 1; loss of vascular markings) + rings (none 0, mild 1, moderate 2, severe 3) + exudates (none 0, mild_lt_10pct 1, severe_gt_10pct 2) + furrows (absent 0, present 1; modified, original 0-2 collapsed) + stricture (absent 0, present 1); Hirano 2013 modified good-agreement version; not later 0-9 furrows 0-2; crepe-paper and narrow-calibre not scored; no published total-score activity bands",
      "max_score": 8,
      "score": 0,
      "edema": "absent",
      "exudates": "none",
      "furrows": "absent",
      "rings": "none",
      "stricture": "absent"
    },
    {
      "components": [
        {
          "value": "absent",
          "factor": "edema",
          "points": 0,
          "present": true
        },
        {
          "value": "none",
          "factor": "rings",
          "points": 0,
          "present": true
        },
        {
          "value": "none",
          "factor": "exudates",
          "points": 0,
          "present": true
        },
        {
          "value": "absent",
          "factor": "furrows",
          "points": 0,
          "present": true
        },
        {
          "value": "absent",
          "factor": "stricture",
          "points": 0,
          "present": true
        }
      ],
      "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": "Hirano I, Moy N, Heckman MG, Thomas CS, Gonsalves N, Achem SR",
        "doi": "10.1136/gutjnl-2011-301817",
        "id": "hirano-2013",
        "pmid": "22619364",
        "source": "Gut. 2013;62(4):489-495",
        "title": "Endoscopic assessment of the oesophageal features of eosinophilic oesophagitis: validation of a novel classification and grading system."
      },
      "formula": "erefs",
      "formula_expression": "EREFS = edema (absent 0, present 1; loss of vascular markings) + rings (none 0, mild 1, moderate 2, severe 3) + exudates (none 0, mild_lt_10pct 1, severe_gt_10pct 2) + furrows (absent 0, present 1; modified, original 0-2 collapsed) + stricture (absent 0, present 1); Hirano 2013 modified good-agreement version; not later 0-9 furrows 0-2; crepe-paper and narrow-calibre not scored; no published total-score activity bands",
      "max_score": 8,
      "score": 0,
      "edema": "absent",
      "exudates": "none",
      "furrows": "absent",
      "rings": "none",
      "stricture": "absent"
    }
  ]
}
```

## Response fields

- `formula` (string): erefs
- `formula_expression` (string): Exact expression used
- `score` (integer): Hirano 2013 modified EREFS points 0-8 (furrows collapsed to absent/present; not later 0-9)
- `max_score` (integer): Always 8
- `edema` (string): Caller-assigned token: absent or present
- `rings` (string): Caller-assigned token: none, mild, moderate, or severe
- `exudates` (string): Caller-assigned token: none, mild_lt_10pct, or severe_gt_10pct
- `furrows` (string): Caller-assigned token: absent or present (modified; not original 0-2)
- `stricture` (string): Caller-assigned token: absent or present
- `components` (array): Per-descriptor caller-assigned points
- `citation` (object): Hirano et al. Gut 2013 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": "absent",
      "factor": "edema",
      "points": 0,
      "present": true
    },
    {
      "value": "none",
      "factor": "rings",
      "points": 0,
      "present": true
    },
    {
      "value": "none",
      "factor": "exudates",
      "points": 0,
      "present": true
    },
    {
      "value": "absent",
      "factor": "furrows",
      "points": 0,
      "present": true
    },
    {
      "value": "absent",
      "factor": "stricture",
      "points": 0,
      "present": true
    }
  ],
  "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": "Hirano I, Moy N, Heckman MG, Thomas CS, Gonsalves N, Achem SR",
    "doi": "10.1136/gutjnl-2011-301817",
    "id": "hirano-2013",
    "pmid": "22619364",
    "source": "Gut. 2013;62(4):489-495",
    "title": "Endoscopic assessment of the oesophageal features of eosinophilic oesophagitis: validation of a novel classification and grading system."
  },
  "formula": "erefs",
  "formula_expression": "EREFS = edema (absent 0, present 1; loss of vascular markings) + rings (none 0, mild 1, moderate 2, severe 3) + exudates (none 0, mild_lt_10pct 1, severe_gt_10pct 2) + furrows (absent 0, present 1; modified, original 0-2 collapsed) + stricture (absent 0, present 1); Hirano 2013 modified good-agreement version; not later 0-9 furrows 0-2; crepe-paper and narrow-calibre not scored; no published total-score activity bands",
  "max_score": 8,
  "score": 0,
  "edema": "absent",
  "exudates": "none",
  "furrows": "absent",
  "rings": "none",
  "stricture": "absent"
}
```

## Errors

- HTTP 400 `invalid_erefs`: edema must be absent or present; rings must be none, mild, moderate, or severe; exudates must be none, mild_lt_10pct, or severe_gt_10pct; furrows must be absent or present; stricture must be absent or present (Hirano 2013 modified EREFS). 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

- [UCEIS](https://magentlab.com/docs/uceis) — Sum three caller-assigned Travis 2013 UCEIS descriptors (vascular_pattern 0-2, bleeding 0-3, erosions_ulcers 0-3) scored at the most severely affected flexible-sigmoidoscopy segment and return the total (max 8). Uses the 2013 0-8 recode (normal 0). Does not return activity bands.
- [LA grading](https://magentlab.com/docs/la-grading) — Apply Lundell 1999 Table 1 Los Angeles classification of oesophagitis and return la_grade (none, A, B, C, or D) from four caller-assigned endoscopic flags.

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