# Bang diabetes screening score

Bang diabetes screening

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

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

## What it computes

Sum the Bang 2009 Table 2 development screening score for undiagnosed diabetes and return high_risk when the total is ≥5.

## When to use

When an agent needs the published Bang 2009 Table 2 point total (BMI-only, no waist) and must not invent a diabetes diagnosis or a prediabetes cutpoint of 4.

## When not to use

- Not a medical device. magent does not diagnose diabetes or assay glucose.
- Bang 2009 Table 2 development scores only. Not Appendix ARIC/CHS coefficients. Not the ADA questionnaires the paper compared.
- high_risk is score ≥5 from that paper (chosen cutpoint for undiagnosed diabetes). A prediabetes cutpoint of 4 is not implemented.
- Obesity is from caller-supplied BMI only. This tool does not take waist circumference.
- Physically active scores −1; the total may be −1. BMI is caller-supplied kg/m^2; magent does not compute BMI from height and weight.

## Formula

```
score = age + sex + family_history_diabetes + hypertension + obesity + physically_active; age <40 -> 0, 40-49 -> 1, 50-59 -> 2, >=60 -> 3; female 0, male 1; family history yes 1; hypertension yes 1; BMI >=40 -> 3, 30 <= BMI < 40 -> 2, 25 <= BMI < 30 -> 1, else 0; physically_active yes -> -1; high_risk iff score>=5; Bang 2009 Table 2 development scores
```

## Citation

[Development and validation of a patient self-assessment score for diabetes risk](https://doi.org/10.7326/0003-4819-151-11-200912010-00005)
Bang H, Edwards AM, Bomback AS, Ballantyne CM, Brillon D, Callahan MA, Teutsch SM, Mushlin AI, Kern LM
Ann Intern Med. 2009;151(11):775-783
DOI: [10.7326/0003-4819-151-11-200912010-00005](https://doi.org/10.7326/0003-4819-151-11-200912010-00005)

## Worked example

### Age 40, female, BMI 22, active (score 0)

Given: `age=40, bmi_kg_m2=22, family_history_diabetes=false, hypertension=false, physically_active=true, sex=female`

1. Age 40 → 1; female → 0; BMI 22 <25 → 0; no family history → 0; no hypertension → 0; physically active → −1
2. Score = 1 + (−1) = 0; high_risk false (cutpoint ≥5). Not a diagnosis.


### Cutoff ≥5 (age ≥60, male, family history)

Given: `age=60, bmi_kg_m2=22, family_history_diabetes=true, hypertension=false, physically_active=false, sex=male`

1. Age 60 → 3; male → 1; family history → 1; other items 0
2. Score = 5; high_risk true (cutpoint ≥5). Not a diagnosis.


## Also searched as

- Bang diabetes screening score
- Bang 2009 diabetes score
- patient self-assessment diabetes score
- undiagnosed diabetes screening score
- Bang Annals diabetes score
- ADA diabetes screening score

## Parameters

- `age` (integer, required): Age in years (20-120). Bang 2009 Table 2: <40 scores 0; 40-49 scores 1; 50-59 scores 2; ≥60 scores 3. Age 40 and 49 score 1; 50 and 59 score 2; 60 scores 3.
- `sex` (string, required): female or male. Bang 2009 Table 2: female scores 0; male scores 1.
- `bmi_kg_m2` (number, required): Body-mass index in kg/m^2 (10-80). Caller-supplied; magent does not compute BMI from height and weight. Bang 2009 Table 2 obesity from BMI only (no waist): ≥40 extremely obese scores 3; 30 ≤ BMI < 40 obese scores 2; 25 ≤ BMI < 30 overweight scores 1; else 0. 25.0 scores 1; 30.0 scores 2; 40.0 scores 3.
- `family_history_diabetes` (boolean, required): Family history of diabetes (Bang 2009 Table 2). true scores 1; false scores 0.
- `hypertension` (boolean, required): History of hypertension (Bang 2009 Table 2). true scores 1; false scores 0. magent does not read a medication list or measure blood pressure.
- `physically_active` (boolean, required): Physically active (Bang 2009 Table 2). true scores −1; false scores 0. The total may be −1.

## 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/ada_diabetes`
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": "40",
      "bmi_kg_m2": "22",
      "family_history_diabetes": "false",
      "hypertension": "false",
      "physically_active": "true",
      "sex": "female"
    },
    {
      "age": "40",
      "bmi_kg_m2": "22",
      "family_history_diabetes": "false",
      "hypertension": "false",
      "physically_active": "true",
      "sex": "female"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/ada_diabetes",
  "items": [
    {
      "components": [
        {
          "value": 40,
          "factor": "age",
          "points": 1,
          "present": true
        },
        {
          "value": "female",
          "factor": "sex",
          "points": 0,
          "present": false
        },
        {
          "factor": "family_history_diabetes",
          "points": 0,
          "present": false
        },
        {
          "factor": "hypertension",
          "points": 0,
          "present": false
        },
        {
          "value": 22.0,
          "factor": "bmi",
          "points": 0,
          "present": true
        },
        {
          "factor": "physically_active",
          "points": -1,
          "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": "Bang H, Edwards AM, Bomback AS, Ballantyne CM, Brillon D, Callahan MA, Teutsch SM, Mushlin AI, Kern LM",
        "doi": "10.7326/0003-4819-151-11-200912010-00005",
        "id": "bang-2009",
        "pmid": "19949143",
        "source": "Ann Intern Med. 2009;151(11):775-783",
        "title": "Development and validation of a patient self-assessment score for diabetes risk"
      },
      "formula": "ada_diabetes",
      "formula_expression": "score = age + sex + family_history_diabetes + hypertension + obesity + physically_active; age <40 -> 0, 40-49 -> 1, 50-59 -> 2, >=60 -> 3; female 0, male 1; family history yes 1; hypertension yes 1; BMI >=40 -> 3, 30 <= BMI < 40 -> 2, 25 <= BMI < 30 -> 1, else 0; physically_active yes -> -1; high_risk iff score>=5; Bang 2009 Table 2 development scores",
      "age_years": 40,
      "max_score": 9,
      "score": 0,
      "sex": "female",
      "bmi_kg_m2": 22.0,
      "high_risk": false
    },
    {
      "components": [
        {
          "value": 40,
          "factor": "age",
          "points": 1,
          "present": true
        },
        {
          "value": "female",
          "factor": "sex",
          "points": 0,
          "present": false
        },
        {
          "factor": "family_history_diabetes",
          "points": 0,
          "present": false
        },
        {
          "factor": "hypertension",
          "points": 0,
          "present": false
        },
        {
          "value": 22.0,
          "factor": "bmi",
          "points": 0,
          "present": true
        },
        {
          "factor": "physically_active",
          "points": -1,
          "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": "Bang H, Edwards AM, Bomback AS, Ballantyne CM, Brillon D, Callahan MA, Teutsch SM, Mushlin AI, Kern LM",
        "doi": "10.7326/0003-4819-151-11-200912010-00005",
        "id": "bang-2009",
        "pmid": "19949143",
        "source": "Ann Intern Med. 2009;151(11):775-783",
        "title": "Development and validation of a patient self-assessment score for diabetes risk"
      },
      "formula": "ada_diabetes",
      "formula_expression": "score = age + sex + family_history_diabetes + hypertension + obesity + physically_active; age <40 -> 0, 40-49 -> 1, 50-59 -> 2, >=60 -> 3; female 0, male 1; family history yes 1; hypertension yes 1; BMI >=40 -> 3, 30 <= BMI < 40 -> 2, 25 <= BMI < 30 -> 1, else 0; physically_active yes -> -1; high_risk iff score>=5; Bang 2009 Table 2 development scores",
      "age_years": 40,
      "max_score": 9,
      "score": 0,
      "sex": "female",
      "bmi_kg_m2": 22.0,
      "high_risk": false
    }
  ]
}
```

## Response fields

- `formula` (string): ada_diabetes
- `formula_expression` (string): Exact Bang 2009 Table 2 development expression
- `score` (integer): Bang 2009 Table 2 points; published range -1 to 9
- `max_score` (integer): 9 (sum of positive Table 2 maxima)
- `high_risk` (boolean): true iff score ≥5 (Bang 2009 chosen cutpoint for undiagnosed diabetes). Not a diabetes diagnosis. A prediabetes cutpoint of 4 is not implemented.
- `age_years` (integer): Age in years used for the age band
- `bmi_kg_m2` (number): Caller-supplied BMI in kg/m^2 used for the obesity band
- `sex` (string): female or male, used for the sex points
- `components` (array): Per-factor points
- `citation` (object): Bang 2009 Annals of Internal Medicine citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 40,
      "factor": "age",
      "points": 1,
      "present": true
    },
    {
      "value": "female",
      "factor": "sex",
      "points": 0,
      "present": false
    },
    {
      "factor": "family_history_diabetes",
      "points": 0,
      "present": false
    },
    {
      "factor": "hypertension",
      "points": 0,
      "present": false
    },
    {
      "value": 22.0,
      "factor": "bmi",
      "points": 0,
      "present": true
    },
    {
      "factor": "physically_active",
      "points": -1,
      "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": "Bang H, Edwards AM, Bomback AS, Ballantyne CM, Brillon D, Callahan MA, Teutsch SM, Mushlin AI, Kern LM",
    "doi": "10.7326/0003-4819-151-11-200912010-00005",
    "id": "bang-2009",
    "pmid": "19949143",
    "source": "Ann Intern Med. 2009;151(11):775-783",
    "title": "Development and validation of a patient self-assessment score for diabetes risk"
  },
  "formula": "ada_diabetes",
  "formula_expression": "score = age + sex + family_history_diabetes + hypertension + obesity + physically_active; age <40 -> 0, 40-49 -> 1, 50-59 -> 2, >=60 -> 3; female 0, male 1; family history yes 1; hypertension yes 1; BMI >=40 -> 3, 30 <= BMI < 40 -> 2, 25 <= BMI < 30 -> 1, else 0; physically_active yes -> -1; high_risk iff score>=5; Bang 2009 Table 2 development scores",
  "age_years": 40,
  "max_score": 9,
  "score": 0,
  "sex": "female",
  "bmi_kg_m2": 22.0,
  "high_risk": false
}
```

## Errors

- HTTP 400 `invalid_ada_diabetes`: ADA diabetes screening-score inputs must be numeric age 20-120, sex, BMI, and the Bang 2009 family-history, hypertension, and physical-activity flags. Returned before settlement; you are not charged.
- HTTP 400 `invalid_sex`: sex must be female or male 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_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

- [FINDRISC](https://magentlab.com/docs/findrisc) — Sum the original Lindström 2003 seven-item Finnish diabetes risk score (FINDRISC, 0–20) and return at_risk when the total is ≥9.
- [Cambridge diabetes](https://magentlab.com/docs/cambridge-diabetes) — Compute the Griffin 2000 Cambridge logistic probability of undetected type 2 diabetes from age, sex, BMI, prescribed antihypertensive medication, prescribed steroids, first-degree family history, and smoking.

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