# Montreal IBD classification

Montreal IBD

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

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

## What it computes

Apply the Satsangi 2006 Montreal revision of the Vienna IBD classification and return the compact phenotype string for Crohn (age, location, behaviour, optional +L4 and p) or ulcerative colitis (extent and severity).

## When to use

When an agent already has caller-assigned Montreal tokens (Crohn A1-A3, L1-L4, B1-B3, upper GI and perianal modifiers, or UC E1-E3 and S0-S3) and needs the published phenotype notation. magent does not perform endoscopy, take vitals, or assign the S token from labs. Not a disease-activity index.

## When not to use

- Not a medical device.
- Not a diagnosis. magent does not diagnose Crohn disease or ulcerative colitis.
- Not a disease-activity index. This tool is phenotype notation only, not CDAI, Harvey-Bradshaw, or Mayo DAI.
- Not the Paris pediatric classification.
- IBDU and indeterminate colitis are not encoded; disease must be crohn or uc.
- The caller assigns all tokens, including UC severity S0-S3. magent does not perform endoscopy or take vitals.

## Formula

```
Crohn phenotype = age_at_diagnosis (A1 ≤16 y, A2 17-40 y, A3 >40 y) + location (L1 ileal, L2 colonic, L3 ileocolonic, L4 isolated upper GI) + optional +L4 when concomitant upper GI with L1-L3 (forbidden when location is isolated L4) + behaviour (B1 non-stricturing non-penetrating, B2 stricturing, B3 penetrating) + optional p when concomitant perianal disease; UC phenotype = extent (E1 ulcerative proctitis distal to the rectosigmoid junction, E2 left-sided distal to the splenic flexure, E3 extensive proximal to the splenic flexure) + severity (S0 clinical remission, S1 mild, S2 moderate, S3 severe as assigned) (Satsangi 2006 Montreal revision of Vienna). Compact string, no spaces. Not a disease-activity score. magent does not perform endoscopy. Not Paris pediatric classification.
```

## Citation

[The Montreal classification of inflammatory bowel disease: controversies, consensus, and implications](https://doi.org/10.1136/gut.2005.082909)
Satsangi J, Silverberg MS, Vermeire S, Colombel JF
Gut. 2006;55(6):749-753
DOI: [10.1136/gut.2005.082909](https://doi.org/10.1136/gut.2005.082909)

## Worked example

### Crohn A2 ileocolonic non-stricturing non-penetrating

Given: `age_at_diagnosis=A2, behaviour=B1, disease=crohn, location=L3, perianal=false, upper_gi=false`

1. disease crohn
2. age_at_diagnosis A2 (17-40 y)
3. location L3 ileocolonic
4. upper_gi false (no +L4)
5. behaviour B1 non-stricturing non-penetrating
6. perianal false (no p)
7. phenotype A2L3B1


### UC ulcerative proctitis in clinical remission

Given: `disease=uc, extent=E1, severity=S0`

1. disease uc
2. extent E1 ulcerative proctitis
3. severity S0 clinical remission as assigned
4. phenotype E1S0


## Also searched as

- Montreal classification
- Montreal IBD
- Satsangi 2006
- Crohn phenotype A L B
- ulcerative colitis extent E1 E2 E3
- Montreal UC severity
- Vienna Montreal revision
- IBD phenotype notation
- Montreal L4 p modifier

## Parameters

- `disease` (string, required): Satsangi 2006 Montreal disease as assigned: crohn or uc. IBDU and indeterminate colitis are not encoded. magent does not diagnose IBD.
- `age_at_diagnosis` (string, optional): Montreal Crohn age at diagnosis as assigned (Satsangi 2006): A1 ≤16 years, A2 17-40 years, A3 >40 years. Required when disease=crohn. Omit when disease=uc. magent does not assign the A token from a chart.
- `location` (string, optional): Montreal Crohn location as assigned (Satsangi 2006): L1 ileal, L2 colonic, L3 ileocolonic, L4 isolated upper GI. Required when disease=crohn. Omit when disease=uc. magent does not perform endoscopy.
- `upper_gi` (boolean, optional): Concomitant upper GI disease as assigned (Satsangi 2006 L4 modifier). true adds +L4 after L1, L2, or L3. Must be false when location is isolated L4. Required when disease=crohn. Omit when disease=uc. magent does not perform endoscopy.
- `behaviour` (string, optional): Montreal Crohn behaviour as assigned (Satsangi 2006): B1 non-stricturing non-penetrating, B2 stricturing, B3 penetrating. Required when disease=crohn. Omit when disease=uc. magent does not perform endoscopy.
- `perianal` (boolean, optional): Concomitant perianal disease as assigned (Satsangi 2006 p modifier). true appends p after B1, B2, or B3. Required when disease=crohn. Omit when disease=uc. magent does not examine the patient.
- `extent` (string, optional): Montreal UC extent as assigned (Satsangi 2006): E1 ulcerative proctitis (distal to the rectosigmoid junction), E2 left-sided (distal to the splenic flexure), E3 extensive (proximal to the splenic flexure). Required when disease=uc. Omit when disease=crohn. magent does not perform endoscopy.
- `severity` (string, optional): Montreal UC severity as assigned (Satsangi 2006): S0 clinical remission; S1 mild (≤4 stools/day with or without blood, no systemic illness, normal ESR); S2 moderate (>4 stools/day, minimal systemic toxicity); S3 severe (≥6 bloody stools/day AND pulse ≥90 AND temperature ≥37.5°C AND haemoglobin <10.5 g/100 ml AND ESR ≥30 mm/h). The caller assigns the S token. Required when disease=uc. Omit when disease=crohn. magent does not take vitals.

## 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/montreal_ibd`
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_at_diagnosis": "A2",
      "behaviour": "B1",
      "disease": "crohn",
      "location": "L3",
      "perianal": "false",
      "upper_gi": "false"
    },
    {
      "age_at_diagnosis": "A2",
      "behaviour": "B1",
      "disease": "crohn",
      "location": "L3",
      "perianal": "false",
      "upper_gi": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/montreal_ibd",
  "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": "Satsangi J, Silverberg MS, Vermeire S, Colombel JF",
        "doi": "10.1136/gut.2005.082909",
        "id": "satsangi-2006",
        "pmid": "16698746",
        "source": "Gut. 2006;55(6):749-753",
        "title": "The Montreal classification of inflammatory bowel disease: controversies, consensus, and implications"
      },
      "formula": "montreal_ibd",
      "formula_expression": "Crohn phenotype = age_at_diagnosis (A1 ≤16 y, A2 17-40 y, A3 >40 y) + location (L1 ileal, L2 colonic, L3 ileocolonic, L4 isolated upper GI) + optional +L4 when concomitant upper GI with L1-L3 (forbidden when location is isolated L4) + behaviour (B1 non-stricturing non-penetrating, B2 stricturing, B3 penetrating) + optional p when concomitant perianal disease; UC phenotype = extent (E1 ulcerative proctitis distal to the rectosigmoid junction, E2 left-sided distal to the splenic flexure, E3 extensive proximal to the splenic flexure) + severity (S0 clinical remission, S1 mild, S2 moderate, S3 severe as assigned) (Satsangi 2006 Montreal revision of Vienna). Compact string, no spaces. Not a disease-activity score. magent does not perform endoscopy. Not Paris pediatric classification.",
      "criteria": [
        {
          "factor": "disease_crohn",
          "met": true
        },
        {
          "factor": "disease_uc",
          "met": false
        },
        {
          "factor": "A1",
          "met": false
        },
        {
          "factor": "A2",
          "met": true
        },
        {
          "factor": "A3",
          "met": false
        },
        {
          "factor": "L1",
          "met": false
        },
        {
          "factor": "L2",
          "met": false
        },
        {
          "factor": "L3",
          "met": true
        },
        {
          "factor": "L4",
          "met": false
        },
        {
          "factor": "upper_gi",
          "met": false
        },
        {
          "factor": "B1",
          "met": true
        },
        {
          "factor": "B2",
          "met": false
        },
        {
          "factor": "B3",
          "met": false
        },
        {
          "factor": "perianal",
          "met": false
        }
      ],
      "phenotype": "A2L3B1",
      "disease": "crohn"
    },
    {
      "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": "Satsangi J, Silverberg MS, Vermeire S, Colombel JF",
        "doi": "10.1136/gut.2005.082909",
        "id": "satsangi-2006",
        "pmid": "16698746",
        "source": "Gut. 2006;55(6):749-753",
        "title": "The Montreal classification of inflammatory bowel disease: controversies, consensus, and implications"
      },
      "formula": "montreal_ibd",
      "formula_expression": "Crohn phenotype = age_at_diagnosis (A1 ≤16 y, A2 17-40 y, A3 >40 y) + location (L1 ileal, L2 colonic, L3 ileocolonic, L4 isolated upper GI) + optional +L4 when concomitant upper GI with L1-L3 (forbidden when location is isolated L4) + behaviour (B1 non-stricturing non-penetrating, B2 stricturing, B3 penetrating) + optional p when concomitant perianal disease; UC phenotype = extent (E1 ulcerative proctitis distal to the rectosigmoid junction, E2 left-sided distal to the splenic flexure, E3 extensive proximal to the splenic flexure) + severity (S0 clinical remission, S1 mild, S2 moderate, S3 severe as assigned) (Satsangi 2006 Montreal revision of Vienna). Compact string, no spaces. Not a disease-activity score. magent does not perform endoscopy. Not Paris pediatric classification.",
      "criteria": [
        {
          "factor": "disease_crohn",
          "met": true
        },
        {
          "factor": "disease_uc",
          "met": false
        },
        {
          "factor": "A1",
          "met": false
        },
        {
          "factor": "A2",
          "met": true
        },
        {
          "factor": "A3",
          "met": false
        },
        {
          "factor": "L1",
          "met": false
        },
        {
          "factor": "L2",
          "met": false
        },
        {
          "factor": "L3",
          "met": true
        },
        {
          "factor": "L4",
          "met": false
        },
        {
          "factor": "upper_gi",
          "met": false
        },
        {
          "factor": "B1",
          "met": true
        },
        {
          "factor": "B2",
          "met": false
        },
        {
          "factor": "B3",
          "met": false
        },
        {
          "factor": "perianal",
          "met": false
        }
      ],
      "phenotype": "A2L3B1",
      "disease": "crohn"
    }
  ]
}
```

## Response fields

- `formula` (string): montreal_ibd
- `formula_expression` (string): Published Satsangi 2006 Montreal phenotype notation
- `disease` (string): crohn or uc as assigned. IBDU is not encoded.
- `phenotype` (string): Compact Montreal phenotype with no spaces. Crohn examples: A2L3B1, A2L3+L4B1, A2L3B1p, A1L4B2, A3L1+L4B3p. UC examples: E1S0, E2S1, E3S3. Not a disease-activity score.
- `criteria` (array): Tree rows with factor and met for disease plus the exclusive Montreal tokens and Crohn modifiers used on that request
- `citation` (object): Satsangi 2006 Gut 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": "Satsangi J, Silverberg MS, Vermeire S, Colombel JF",
    "doi": "10.1136/gut.2005.082909",
    "id": "satsangi-2006",
    "pmid": "16698746",
    "source": "Gut. 2006;55(6):749-753",
    "title": "The Montreal classification of inflammatory bowel disease: controversies, consensus, and implications"
  },
  "formula": "montreal_ibd",
  "formula_expression": "Crohn phenotype = age_at_diagnosis (A1 ≤16 y, A2 17-40 y, A3 >40 y) + location (L1 ileal, L2 colonic, L3 ileocolonic, L4 isolated upper GI) + optional +L4 when concomitant upper GI with L1-L3 (forbidden when location is isolated L4) + behaviour (B1 non-stricturing non-penetrating, B2 stricturing, B3 penetrating) + optional p when concomitant perianal disease; UC phenotype = extent (E1 ulcerative proctitis distal to the rectosigmoid junction, E2 left-sided distal to the splenic flexure, E3 extensive proximal to the splenic flexure) + severity (S0 clinical remission, S1 mild, S2 moderate, S3 severe as assigned) (Satsangi 2006 Montreal revision of Vienna). Compact string, no spaces. Not a disease-activity score. magent does not perform endoscopy. Not Paris pediatric classification.",
  "criteria": [
    {
      "factor": "disease_crohn",
      "met": true
    },
    {
      "factor": "disease_uc",
      "met": false
    },
    {
      "factor": "A1",
      "met": false
    },
    {
      "factor": "A2",
      "met": true
    },
    {
      "factor": "A3",
      "met": false
    },
    {
      "factor": "L1",
      "met": false
    },
    {
      "factor": "L2",
      "met": false
    },
    {
      "factor": "L3",
      "met": true
    },
    {
      "factor": "L4",
      "met": false
    },
    {
      "factor": "upper_gi",
      "met": false
    },
    {
      "factor": "B1",
      "met": true
    },
    {
      "factor": "B2",
      "met": false
    },
    {
      "factor": "B3",
      "met": false
    },
    {
      "factor": "perianal",
      "met": false
    }
  ],
  "phenotype": "A2L3B1",
  "disease": "crohn"
}
```

## Errors

- HTTP 400 `invalid_montreal_ibd`: Montreal IBD needs disease crohn or uc with the Satsangi 2006 phenotype tokens. 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

- [Mayo DAI](https://magentlab.com/docs/mayo-uc) — Sum four caller-assigned Schroeder 1987 ulcerative colitis disease-activity index items (each integer 0-3) and return the total (max 12). Does not return later remission or activity bands.
- [HBI](https://magentlab.com/docs/harvey-bradshaw) — Sum Harvey 1980 simple-index items (previous-day well-being, abdominal pain, liquid stools, abdominal mass, and one point per listed complication) and return the total. Does not return later remission or activity bands.
- [CDAI](https://magentlab.com/docs/cdai) — Compute the Best 1976 Crohn's disease activity index from eight caller-assigned variables and return the rounded integer score. Does not return later trial activity bands.

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