Respiratory · LIVE
STOP-Bang OSA screen
STOP-Bang
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.
Markdown: /docs/stop-bang.md · Canonical: https://magentlab.com/docs/stop-bang
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
- Authors
- Chung F, Yegneswaran B, Liao P, et al.
- Source
- Anesthesiology. 2008;108(5):812-821
Worked example
All STOP false, BMI 30, age 40, neck 38 cm, female
Given:
age=40bmi_kg_m2=30hypertension=falseneck_cm=38observed_apnea=falsesex=femalesnoring=falsetired=false
- STOP all false → 0; BMI 30 is not >35 → 0; age 40 is not >50 → 0; neck 38 is not >40 → 0; female → 0
- Score = 0 (max 8); stop_bang_band 0-2
Three STOP items true
Given:
age=40bmi_kg_m2=30hypertension=falseneck_cm=38observed_apnea=truesex=femalesnoring=truetired=true
- snoring → 1; tired → 1; observed_apnea → 1; remaining items 0
- 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
Try
Opens the live endpoint. Unpaid browser requests show the paywall; agents should send Accept: application/json.
Full URL: https://api.magentlab.com/api/calc/stop_bang?snoring=false&tired=false&observed_apnea=false&hypertension=false&bmi_kg_m2=30&age=40&neck_cm=38&sex=female
Call
Expect HTTP 402 until you retry with PAYMENT-SIGNATURE. Incomplete query params
return HTTP 400 before any quote or charge.
curl -i -H "Accept: application/json" "https://api.magentlab.com/api/calc/stop_bang?snoring=false&tired=false&observed_apnea=false&hypertension=false&bmi_kg_m2=30&age=40&neck_cm=38&sex=female"
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
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, male | 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.
- 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 (fixture)
{
"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"
}
]
}
Opens a two-item fixture on the API host. Unpaid browsers get the same MetaMask paywall as GET; Pay retries POST with those items.
Example 200 (fixture)
{
"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.",
"age_years": 40,
"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,
"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.",
"age_years": 40,
"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,
"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
| Field | Type | Description |
|---|---|---|
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
Machine form of the same example. Frozen fixture. Not a live lookup.
{
"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.",
"age_years": 40,
"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,
"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
}
Client errors (HTTP 400)
Invalid params return 400 without charge. Shared HTTP 402 and 503 meanings: Payments.
| HTTP | Code | When |
|---|---|---|
| 400 | invalid_flag |
boolean clinical flags must be true or false Returned before settlement; you are not charged. |
| 400 | invalid_bmi_kg_m2 |
bmi_kg_m2 must be a number from 10 to 80. Returned before settlement; you are not charged. |
| 400 | invalid_age |
age must be an integer from 18 to 120 Returned before settlement; you are not charged. |
| 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. |
| 400 | invalid_sex |
sex must be female or male Returned before settlement; you are not charged. |
| 400 | invalid_items |
POST body must be a JSON object with only an items array Returned before settlement; you are not charged. |
| 400 | invalid_item_count |
items must be an array of 1 to 25 objects Returned before settlement; you are not charged. |
| 400 | invalid_item |
each items entry must be a JSON object Returned before settlement; you are not charged. |
Related tools
- BODE — Sum Celli 2004 BODE points from BMI, FEV1 percent predicted, MMRC dyspnea, and 6-minute walk distance.
- 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. Unpaid valid requests return HTTP 402 with a base64
PAYMENT-REQUIRED
header. HTTP 503 is not a new quote: retry the same PAYMENT-SIGNATURE. Full handshake
and shared payment errors: Payments.
Stdio MCP: /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.