# Crohn's disease activity index (CDAI)

CDAI

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

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

## What it computes

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.

## When to use

When an agent already has Best 1976 seven-day stool, pain, and well-being sums, extra-intestinal count, antidiarrheal flag, abdominal mass (0/2/5), hematocrit, sex, and caller-assigned weight-percent deviation and needs the weighted index, not a Crohn's diagnosis, Harvey-Bradshaw one-day index, or later trial cutoffs.

## When not to use

- Not a medical device and not a Crohn's diagnosis or a treatment order.
- magent does not examine the patient. Seven-day sums, extra-intestinal count, antidiarrheal use, abdominal mass, hematocrit, and weight-percent deviation are caller-assigned.
- Abdominal mass is Best 1976 0 (none), 2 (questionable), or 5 (definite), not 1/3/4. Extra-intestinal count is 0-6; magent does not enumerate the six findings as separate params.
- magent returns the integer index only and does not apply later trial activity bands. Liquid-stool 0-70, hematocrit 10-70, and weight-percent -50 to 80 are magent clamps, not published maxima.

## Formula

```
CDAI = liquid_stool_count_7d*2 + abdominal_pain_sum_7d*5 + wellbeing_sum_7d*7 + extra_intestinal_count*20 + taking_antidiarrheal*30 + abdominal_mass*10 + hematocrit_deficit*6 + weight_percent_deviation; hematocrit_deficit = 47-hematocrit_percent (male) or 42-hematocrit_percent (female); Best 1976; score rounded after the weight term
```

## Citation

[Development of a Crohn's disease activity index. National Cooperative Crohn's Disease Study](https://doi.org/10.1016/S0016-5085(76)80163-1)
Best WR, Becktel JM, Singleton JW, Kern F Jr
Gastroenterology. 1976;70(3):439-444
DOI: [10.1016/S0016-5085(76)80163-1](https://doi.org/10.1016/S0016-5085(76)80163-1)

## Worked example

### Male, clinical zeros, hematocrit 47, weight deviation 0

Given: `abdominal_mass=0, abdominal_pain_sum_7d=0, extra_intestinal_count=0, hematocrit_percent=47, liquid_stool_count_7d=0, sex=male, taking_antidiarrheal=false, weight_percent_deviation=0, wellbeing_sum_7d=0`

1. liquid stools 0×2 + pain 0×5 + well-being 0×7 + extra-intestinal 0×20 + antidiarrheal 0 + mass 0×10 + (47-47)×6 + 0
2. Score = 0. No activity band.


## Also searched as

- Crohn's Disease Activity Index
- CDAI
- Best CDAI
- National Cooperative Crohn's Disease Study
- Crohn's activity index
- Best 1976 CDAI

## Parameters

- `sex` (string, required): male or female. Best 1976 hematocrit standard is 47 (male) or 42 (female). magent does not examine the patient.
- `liquid_stool_count_7d` (integer, required): Sum of liquid or very soft stools over 7 days (Best 1976; ×2). Integer 0-70 is a magent clamp, not a published maximum. magent does not count stools.
- `abdominal_pain_sum_7d` (integer, required): Sum of daily Best 1976 abdominal-pain ratings over 7 days (integer 0-21; each day 0 none, 1 mild, 2 moderate, 3 severe; ×5). magent does not examine the patient.
- `wellbeing_sum_7d` (integer, required): Sum of daily Best 1976 general well-being ratings over 7 days (integer 0-28; each day 0 generally well, 1 slightly below par, 2 poor, 3 very poor, 4 terrible; ×7). magent does not examine the patient.
- `extra_intestinal_count` (integer, required): Caller-assigned count 0-6 of Best 1976 extra-intestinal findings (one each: arthritis/arthralgia; iritis/uveitis; erythema nodosum/pyoderma gangrenosum/aphthous ulcer; anal fissure/fistula/abscess; other fistula; fever >37.8 C in the past week; ×20). magent takes the integer count and does not enumerate those names as separate params.
- `taking_antidiarrheal` (boolean, required): Taking diphenoxylate/atropine (Lomotil) or opiates for diarrhea as in Best 1976. true or false. true scores 30. magent does not examine the patient.
- `abdominal_mass` (integer, required): Caller-assigned Best 1976 abdominal mass (exactly 0 none, 2 questionable, or 5 definite; ×10). Not 1, 3, or 4. magent does not examine the patient.
- `hematocrit_percent` (number, required): Hematocrit in percent (10-70). Best 1976 uses a whole-number hematocrit. Deficit is 47 minus this value (male) or 42 minus this value (female), then ×6; may be negative if above the sex standard. magent does not assay hematocrit.
- `weight_percent_deviation` (number, required): Caller-assigned Best 1976 weight term 100*(1 - current/standard). May be negative if current is above standard. Magent clamp -50 to 80, not a published range. magent does not look up a standard weight.

## 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/cdai`
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": [
    {
      "abdominal_mass": "0",
      "abdominal_pain_sum_7d": "0",
      "extra_intestinal_count": "0",
      "hematocrit_percent": "47",
      "liquid_stool_count_7d": "0",
      "sex": "male",
      "taking_antidiarrheal": "false",
      "weight_percent_deviation": "0",
      "wellbeing_sum_7d": "0"
    },
    {
      "abdominal_mass": "0",
      "abdominal_pain_sum_7d": "0",
      "extra_intestinal_count": "0",
      "hematocrit_percent": "47",
      "liquid_stool_count_7d": "0",
      "sex": "male",
      "taking_antidiarrheal": "false",
      "weight_percent_deviation": "0",
      "wellbeing_sum_7d": "0"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/cdai",
  "items": [
    {
      "components": [
        {
          "value": 0,
          "factor": "liquid_stool_count_7d",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "abdominal_pain_sum_7d",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "wellbeing_sum_7d",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "extra_intestinal_count",
          "points": 0,
          "present": true
        },
        {
          "factor": "taking_antidiarrheal",
          "points": 0,
          "present": false
        },
        {
          "value": 0,
          "factor": "abdominal_mass",
          "points": 0,
          "present": true
        },
        {
          "value": 0.0,
          "factor": "hematocrit_deficit",
          "points": 0.0,
          "present": true
        },
        {
          "value": 0.0,
          "factor": "weight_percent_deviation",
          "points": 0.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": "Best WR, Becktel JM, Singleton JW, Kern F Jr",
        "doi": "10.1016/S0016-5085(76)80163-1",
        "id": "best-1976",
        "pmid": "1248701",
        "source": "Gastroenterology. 1976;70(3):439-444",
        "title": "Development of a Crohn's disease activity index. National Cooperative Crohn's Disease Study"
      },
      "formula": "cdai",
      "formula_expression": "CDAI = liquid_stool_count_7d*2 + abdominal_pain_sum_7d*5 + wellbeing_sum_7d*7 + extra_intestinal_count*20 + taking_antidiarrheal*30 + abdominal_mass*10 + hematocrit_deficit*6 + weight_percent_deviation; hematocrit_deficit = 47-hematocrit_percent (male) or 42-hematocrit_percent (female); Best 1976; score rounded after the weight term",
      "score": 0,
      "sex": "male",
      "hematocrit_percent": 47.0,
      "abdominal_mass": 0,
      "abdominal_pain_sum_7d": 0,
      "extra_intestinal_count": 0,
      "hematocrit_deficit": 0.0,
      "liquid_stool_count_7d": 0,
      "taking_antidiarrheal": false,
      "weight_percent_deviation": 0.0,
      "wellbeing_sum_7d": 0
    },
    {
      "components": [
        {
          "value": 0,
          "factor": "liquid_stool_count_7d",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "abdominal_pain_sum_7d",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "wellbeing_sum_7d",
          "points": 0,
          "present": true
        },
        {
          "value": 0,
          "factor": "extra_intestinal_count",
          "points": 0,
          "present": true
        },
        {
          "factor": "taking_antidiarrheal",
          "points": 0,
          "present": false
        },
        {
          "value": 0,
          "factor": "abdominal_mass",
          "points": 0,
          "present": true
        },
        {
          "value": 0.0,
          "factor": "hematocrit_deficit",
          "points": 0.0,
          "present": true
        },
        {
          "value": 0.0,
          "factor": "weight_percent_deviation",
          "points": 0.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": "Best WR, Becktel JM, Singleton JW, Kern F Jr",
        "doi": "10.1016/S0016-5085(76)80163-1",
        "id": "best-1976",
        "pmid": "1248701",
        "source": "Gastroenterology. 1976;70(3):439-444",
        "title": "Development of a Crohn's disease activity index. National Cooperative Crohn's Disease Study"
      },
      "formula": "cdai",
      "formula_expression": "CDAI = liquid_stool_count_7d*2 + abdominal_pain_sum_7d*5 + wellbeing_sum_7d*7 + extra_intestinal_count*20 + taking_antidiarrheal*30 + abdominal_mass*10 + hematocrit_deficit*6 + weight_percent_deviation; hematocrit_deficit = 47-hematocrit_percent (male) or 42-hematocrit_percent (female); Best 1976; score rounded after the weight term",
      "score": 0,
      "sex": "male",
      "hematocrit_percent": 47.0,
      "abdominal_mass": 0,
      "abdominal_pain_sum_7d": 0,
      "extra_intestinal_count": 0,
      "hematocrit_deficit": 0.0,
      "liquid_stool_count_7d": 0,
      "taking_antidiarrheal": false,
      "weight_percent_deviation": 0.0,
      "wellbeing_sum_7d": 0
    }
  ]
}
```

## Response fields

- `formula` (string): cdai
- `formula_expression` (string): Exact expression used
- `score` (integer): Best 1976 CDAI after rounding the sum (needed when the weight term is not an integer). No activity band.
- `liquid_stool_count_7d` (integer): 7-day liquid/very-soft stool count used (×2)
- `abdominal_pain_sum_7d` (integer): 7-day abdominal-pain rating sum used (×5)
- `wellbeing_sum_7d` (integer): 7-day well-being rating sum used (×7)
- `extra_intestinal_count` (integer): Caller-assigned extra-intestinal count 0-6 used (×20)
- `taking_antidiarrheal` (boolean): Antidiarrheal flag used; 30 points if true
- `abdominal_mass` (integer): Caller-assigned abdominal mass 0, 2, or 5 used (×10)
- `sex` (string): male or female; selects the hematocrit standard
- `hematocrit_percent` (number): Hematocrit percent used
- `hematocrit_deficit` (number): 47-hematocrit_percent (male) or 42-hematocrit_percent (female); ×6
- `weight_percent_deviation` (number): Caller-assigned 100*(1 - current/standard) used (×1)
- `components` (array): Per-variable weighted points
- `citation` (object): Best et al. Gastroenterology 1976 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 0,
      "factor": "liquid_stool_count_7d",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "abdominal_pain_sum_7d",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "wellbeing_sum_7d",
      "points": 0,
      "present": true
    },
    {
      "value": 0,
      "factor": "extra_intestinal_count",
      "points": 0,
      "present": true
    },
    {
      "factor": "taking_antidiarrheal",
      "points": 0,
      "present": false
    },
    {
      "value": 0,
      "factor": "abdominal_mass",
      "points": 0,
      "present": true
    },
    {
      "value": 0.0,
      "factor": "hematocrit_deficit",
      "points": 0.0,
      "present": true
    },
    {
      "value": 0.0,
      "factor": "weight_percent_deviation",
      "points": 0.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": "Best WR, Becktel JM, Singleton JW, Kern F Jr",
    "doi": "10.1016/S0016-5085(76)80163-1",
    "id": "best-1976",
    "pmid": "1248701",
    "source": "Gastroenterology. 1976;70(3):439-444",
    "title": "Development of a Crohn's disease activity index. National Cooperative Crohn's Disease Study"
  },
  "formula": "cdai",
  "formula_expression": "CDAI = liquid_stool_count_7d*2 + abdominal_pain_sum_7d*5 + wellbeing_sum_7d*7 + extra_intestinal_count*20 + taking_antidiarrheal*30 + abdominal_mass*10 + hematocrit_deficit*6 + weight_percent_deviation; hematocrit_deficit = 47-hematocrit_percent (male) or 42-hematocrit_percent (female); Best 1976; score rounded after the weight term",
  "score": 0,
  "sex": "male",
  "hematocrit_percent": 47.0,
  "abdominal_mass": 0,
  "abdominal_pain_sum_7d": 0,
  "extra_intestinal_count": 0,
  "hematocrit_deficit": 0.0,
  "liquid_stool_count_7d": 0,
  "taking_antidiarrheal": false,
  "weight_percent_deviation": 0.0,
  "wellbeing_sum_7d": 0
}
```

## Errors

- HTTP 400 `invalid_sex`: sex must be female or male Returned before settlement; you are not charged.
- HTTP 400 `invalid_cdai_stools`: liquid_stool_count_7d must be an integer from 0 to 70. Returned before settlement; you are not charged.
- HTTP 400 `invalid_cdai_pain`: abdominal_pain_sum_7d must be an integer from 0 to 21. Returned before settlement; you are not charged.
- HTTP 400 `invalid_cdai_wellbeing`: wellbeing_sum_7d must be an integer from 0 to 28. Returned before settlement; you are not charged.
- HTTP 400 `invalid_cdai_complications`: extra_intestinal_count must be an integer from 0 to 6. 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_cdai_mass`: abdominal_mass must be 0, 2, or 5 (Best 1976). Returned before settlement; you are not charged.
- HTTP 400 `invalid_hematocrit`: hematocrit_percent must be a number from 10 to 70. Returned before settlement; you are not charged.
- HTTP 400 `invalid_cdai_weight`: weight_percent_deviation must be a number from -50 to 80. 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

- [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.
- [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.
- [PUCAI](https://magentlab.com/docs/pucai) — Sum six caller-assigned Turner 2007 PUCAI item points and return the published total (max 85) with activity band.

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