# STOP-Bang OSA screen

STOP-Bang

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

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

## What it computes

Compute Chung 2008 Appendix 2 STOP-Bang from four STOP flags and computed BANG (BMI >35, age >50, neck >40 cm, male) and return the published 0-2 / >=3 OSA-risk band.

## When to use

When an agent needs the published Chung 2008 STOP-Bang total and two-tier band and must not invent a sleep-study order or the Chung 2012 three-tier scheme.

## When not to use

- Not a medical device. magent does not diagnose obstructive sleep apnea.
- Not a sleep-study (polysomnography) order and not an airway-management protocol.
- This is Chung 2008 Appendix 2 STOP-Bang with two bands (yes to fewer than three items = 0-2; yes to three or more = >=3). It is not the Chung 2012 three-tier 0-2 / 3-4 / 5-8 scheme.
- BANG items are computed from bmi_kg_m2, age, neck_cm, and sex. magent does not accept BANG as caller flags.
- BMI 35, age 50, and neck 40 cm do not score (strict greater-than). Percents and AHI sensitivities are not returned.

## Formula

```
STOP-Bang = snoring + tired + observed_apnea + hypertension + (bmi_kg_m2>35) + (age>50) + (neck_cm>40) + male; each 1 if true; max 8; bands 0-2 / >=3
```

## Citation

[STOP questionnaire: a tool to screen patients for obstructive sleep apnea](https://doi.org/10.1097/ALN.0b013e31816d83e4)
Chung F, Yegneswaran B, Liao P, et al.
Anesthesiology. 2008;108(5):812-821
DOI: [10.1097/ALN.0b013e31816d83e4](https://doi.org/10.1097/ALN.0b013e31816d83e4)

## Worked example

### All STOP false, BMI 30, age 40, neck 38 cm, female

Given: `age=40, bmi_kg_m2=30, hypertension=false, neck_cm=38, observed_apnea=false, sex=female, snoring=false, tired=false`

1. STOP all false → 0; BMI 30 is not >35 → 0; age 40 is not >50 → 0; neck 38 is not >40 → 0; female → 0
2. Score = 0 (max 8); stop_bang_band 0-2


### Three STOP items true

Given: `age=40, bmi_kg_m2=30, hypertension=false, neck_cm=38, observed_apnea=true, sex=female, snoring=true, tired=true`

1. snoring → 1; tired → 1; observed_apnea → 1; remaining items 0
2. Score = 3 (max 8); stop_bang_band >=3


## Also searched as

- STOP-Bang
- STOP Bang
- Chung STOP-Bang
- OSA screening STOP-Bang
- obstructive sleep apnea STOP-Bang
- STOP questionnaire Bang

## Parameters

- `snoring` (boolean, required): Loud snoring heard through closed doors (Chung 2008 Appendix 2 STOP). true or false. Caller-assigned. 1 point if true.
- `tired` (boolean, required): Daytime tiredness, fatigue, or sleepiness (Chung 2008 Appendix 2 STOP). true or false. Caller-assigned. 1 point if true.
- `observed_apnea` (boolean, required): Anyone observed the patient stop breathing during sleep (Chung 2008 Appendix 2 STOP). true or false. Caller-assigned. 1 point if true.
- `hypertension` (boolean, required): Has or is being treated for high blood pressure (Chung 2008 Appendix 2 STOP). true or false. Caller-assigned. 1 point if true.
- `bmi_kg_m2` (number, required): Body-mass index in kg/m^2 (10-80). Chung 2008 Appendix 2 BANG: scores 1 when >35. BMI 35 does not score. Caller-supplied; magent does not compute BMI from height and weight.
- `age` (integer, required): Age in years (18-120). Chung 2008 Appendix 2 BANG: scores 1 when >50. Age 50 does not score.
- `neck_cm` (number, required): Neck circumference in cm (20-80). Chung 2008 Appendix 2 BANG: scores 1 when >40. Neck 40 does not score.
- `sex` (string, required): female or male. Chung 2008 Appendix 2 BANG: male scores 1. Female scores 0.

## 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/stop_bang`
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": "30",
      "hypertension": "false",
      "neck_cm": "38",
      "observed_apnea": "false",
      "sex": "female",
      "snoring": "false",
      "tired": "false"
    },
    {
      "age": "40",
      "bmi_kg_m2": "30",
      "hypertension": "false",
      "neck_cm": "38",
      "observed_apnea": "false",
      "sex": "female",
      "snoring": "false",
      "tired": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/stop_bang",
  "items": [
    {
      "components": [
        {
          "factor": "snoring",
          "points": 0,
          "present": false
        },
        {
          "factor": "tired",
          "points": 0,
          "present": false
        },
        {
          "factor": "observed_apnea",
          "points": 0,
          "present": false
        },
        {
          "factor": "hypertension",
          "points": 0,
          "present": false
        },
        {
          "value": 30.0,
          "factor": "bmi_gt_35",
          "points": 0,
          "present": false
        },
        {
          "value": 40,
          "factor": "age_gt_50",
          "points": 0,
          "present": false
        },
        {
          "value": 38.0,
          "factor": "neck_gt_40",
          "points": 0,
          "present": false
        },
        {
          "factor": "male",
          "points": 0,
          "present": false
        }
      ],
      "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": "Chung F, Yegneswaran B, Liao P, et al.",
        "doi": "10.1097/ALN.0b013e31816d83e4",
        "id": "chung-2008",
        "pmid": "18431116",
        "source": "Anesthesiology. 2008;108(5):812-821",
        "title": "STOP questionnaire: a tool to screen patients for obstructive sleep apnea"
      },
      "formula": "stop_bang",
      "formula_expression": "STOP-Bang = snoring + tired + observed_apnea + hypertension + (bmi_kg_m2>35) + (age>50) + (neck_cm>40) + male; each 1 if true; max 8; bands 0-2 / >=3",
      "max_score": 8,
      "score": 0,
      "age_years": 40,
      "sex": "female",
      "bmi_kg_m2": 30.0,
      "hypertension": false,
      "neck_cm": 38.0,
      "observed_apnea": false,
      "snoring": false,
      "stop_bang_band": "0-2",
      "tired": false
    },
    {
      "components": [
        {
          "factor": "snoring",
          "points": 0,
          "present": false
        },
        {
          "factor": "tired",
          "points": 0,
          "present": false
        },
        {
          "factor": "observed_apnea",
          "points": 0,
          "present": false
        },
        {
          "factor": "hypertension",
          "points": 0,
          "present": false
        },
        {
          "value": 30.0,
          "factor": "bmi_gt_35",
          "points": 0,
          "present": false
        },
        {
          "value": 40,
          "factor": "age_gt_50",
          "points": 0,
          "present": false
        },
        {
          "value": 38.0,
          "factor": "neck_gt_40",
          "points": 0,
          "present": false
        },
        {
          "factor": "male",
          "points": 0,
          "present": false
        }
      ],
      "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": "Chung F, Yegneswaran B, Liao P, et al.",
        "doi": "10.1097/ALN.0b013e31816d83e4",
        "id": "chung-2008",
        "pmid": "18431116",
        "source": "Anesthesiology. 2008;108(5):812-821",
        "title": "STOP questionnaire: a tool to screen patients for obstructive sleep apnea"
      },
      "formula": "stop_bang",
      "formula_expression": "STOP-Bang = snoring + tired + observed_apnea + hypertension + (bmi_kg_m2>35) + (age>50) + (neck_cm>40) + male; each 1 if true; max 8; bands 0-2 / >=3",
      "max_score": 8,
      "score": 0,
      "age_years": 40,
      "sex": "female",
      "bmi_kg_m2": 30.0,
      "hypertension": false,
      "neck_cm": 38.0,
      "observed_apnea": false,
      "snoring": false,
      "stop_bang_band": "0-2",
      "tired": false
    }
  ]
}
```

## Response fields

- `formula` (string): stop_bang
- `formula_expression` (string): Exact expression used
- `score` (integer): STOP-Bang points 0-8
- `max_score` (integer): 8
- `stop_bang_band` (string): Chung 2008 Appendix 2 OSA-risk band: 0-2 (yes to fewer than three items) or >=3 (yes to three or more). Not Chung 2012 0-2/3-4/5-8. Percents are not returned.
- `snoring` (boolean): STOP snoring flag used
- `tired` (boolean): STOP tired flag used
- `observed_apnea` (boolean): STOP observed-apnea flag used
- `hypertension` (boolean): STOP hypertension flag used
- `bmi_kg_m2` (number): BMI used for the >35 criterion
- `age_years` (integer): Age used for the >50 criterion
- `neck_cm` (number): Neck circumference used for the >40 criterion
- `sex` (string): female or male
- `components` (array): Per-item points
- `citation` (object): Chung 2008 Anesthesiology citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "factor": "snoring",
      "points": 0,
      "present": false
    },
    {
      "factor": "tired",
      "points": 0,
      "present": false
    },
    {
      "factor": "observed_apnea",
      "points": 0,
      "present": false
    },
    {
      "factor": "hypertension",
      "points": 0,
      "present": false
    },
    {
      "value": 30.0,
      "factor": "bmi_gt_35",
      "points": 0,
      "present": false
    },
    {
      "value": 40,
      "factor": "age_gt_50",
      "points": 0,
      "present": false
    },
    {
      "value": 38.0,
      "factor": "neck_gt_40",
      "points": 0,
      "present": false
    },
    {
      "factor": "male",
      "points": 0,
      "present": false
    }
  ],
  "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": "Chung F, Yegneswaran B, Liao P, et al.",
    "doi": "10.1097/ALN.0b013e31816d83e4",
    "id": "chung-2008",
    "pmid": "18431116",
    "source": "Anesthesiology. 2008;108(5):812-821",
    "title": "STOP questionnaire: a tool to screen patients for obstructive sleep apnea"
  },
  "formula": "stop_bang",
  "formula_expression": "STOP-Bang = snoring + tired + observed_apnea + hypertension + (bmi_kg_m2>35) + (age>50) + (neck_cm>40) + male; each 1 if true; max 8; bands 0-2 / >=3",
  "max_score": 8,
  "score": 0,
  "age_years": 40,
  "sex": "female",
  "bmi_kg_m2": 30.0,
  "hypertension": false,
  "neck_cm": 38.0,
  "observed_apnea": false,
  "snoring": false,
  "stop_bang_band": "0-2",
  "tired": false
}
```

## Errors

- HTTP 400 `invalid_flag`: boolean clinical flags must be true or false 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_age`: age must be an integer from 18 to 120 Returned before settlement; you are not charged.
- HTTP 400 `invalid_neck_cm`: neck_cm must be a number from 20 to 80 (Chung 2008 STOP-Bang). 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_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

- [BODE](https://magentlab.com/docs/bode) — Sum Celli 2004 BODE points from BMI, FEV1 percent predicted, MMRC dyspnea, and 6-minute walk distance.
- [DECAF](https://magentlab.com/docs/decaf) — Sum Steer 2012 DECAF points from extended MRC dyspnoea, eosinophils, chest radiograph consolidation, arterial pH, and atrial fibrillation.

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