Respiratory · LIVE
BAP-65
Apply Tabak 2009 BAP-65 and return class I–V from three caller-assigned main factors, using age >65 only to split class I from II when zero main factors are present.
Markdown: /docs/bap-65.md · Canonical: https://magentlab.com/docs/bap-65
Not a medical device. Not a diagnosis, dose, or listing recommendation.
What it computes
Apply Tabak 2009 BAP-65 and return class I–V from three caller-assigned main factors, using age >65 only to split class I from II when zero main factors are present.
When to use
When an agent already has BUN, mental status, pulse, and age assigned as Tabak 2009 flags for an adult with acute exacerbation of COPD and needs the published BAP-65 class. magent does not compute GCS, BUN, or pulse.
When not to use
- Not a medical device.
- Not a mechanical-ventilation, ICU-admission, or early-discharge order. magent does not diagnose COPD exacerbation.
- The caller assigns bun_gt_25, altered_mental_status, pulse_gt_109, and age_gt_65 as already determined. magent does not compute GCS, BUN, or pulse.
- Age >65 is not a fourth additive point. It splits class I from class II only when zero of the three main factors are present. Classes III–V ignore age.
- In-hospital mortality figures in Tabak 2009 are 0.3% for no factors and age ≤65 versus 13.1% (derivation) / 14.6% (validation) when all three main factors are present. Per-class percents for II–IV are not attached.
Formula
class I = 0 main factors and age ≤65; II = 0 main factors and age >65; III = 1 main factor; IV = 2 main factors; V = 3 main factors (BUN >25 mg/dL, GCS <14 or disoriented/stupor/coma, pulse >109/min); age is not a 4th additive point
Citation
- Authors
- Tabak YP, Sun X, Johannes RS, Gupta V, Shorr AF
- Source
- Arch Intern Med. 2009;169(17):1595-1602
Worked example
No main factors, age ≤65 (class I)
Given:
age_gt_65=falsealtered_mental_status=falsebun_gt_25=falsepulse_gt_109=false
- All three main factors false; age_gt_65 false
- main_factor_count = 0 and age ≤65 → class I
All three main factors present (class V)
Given:
age_gt_65=falsealtered_mental_status=truebun_gt_25=truepulse_gt_109=true
- BUN >25, altered mental status, and pulse >109 all true
- main_factor_count = 3; age ignored → class V
Also searched as
- BAP-65
- BAP65
- Tabak BAP-65
- COPD exacerbation BAP-65
- BUN altered mental status pulse 65
- BAP 65 score
- acute exacerbation COPD BAP-65
Try
Opens the live endpoint. Unpaid browser requests show the paywall; agents should send Accept: application/json.
/api/calc/bap_65?bun_gt_25=false&altered_mental_status=false&pulse_gt_109=false&age_gt_65=false
Full URL: https://api.magentlab.com/api/calc/bap_65?bun_gt_25=false&altered_mental_status=false&pulse_gt_109=false&age_gt_65=false
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/bap_65?bun_gt_25=false&altered_mental_status=false&pulse_gt_109=false&age_gt_65=false"
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
bun_gt_25 |
boolean | required | BUN >25 mg/dL (strict greater than; 25 does not meet). true or false as assigned by the caller. magent does not compute BUN. |
altered_mental_status |
boolean | required | GCS <14 or physician designation of disoriented, stupor, or coma (Tabak 2009). true or false as assigned by the caller. magent does not compute GCS. |
pulse_gt_109 |
boolean | required | Pulse >109/min (strict greater than; 109 does not meet). true or false as assigned by the caller. magent does not compute pulse. |
age_gt_65 |
boolean | required | Age >65 years (strict greater than). Used only when zero of the three main factors are present, to split class I from II. true or false as assigned by the caller. magent does not compute age. |
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_gt_65": "false",
"altered_mental_status": "false",
"bun_gt_25": "false",
"pulse_gt_109": "false"
},
{
"age_gt_65": "false",
"altered_mental_status": "false",
"bun_gt_25": "false",
"pulse_gt_109": "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/bap_65",
"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": "Tabak YP, Sun X, Johannes RS, Gupta V, Shorr AF",
"doi": "10.1001/archinternmed.2009.270",
"id": "tabak-2009",
"pmid": "19786679",
"source": "Arch Intern Med. 2009;169(17):1595-1602",
"title": "Mortality and need for mechanical ventilation in acute exacerbations of chronic obstructive pulmonary disease: development and validation of a simple risk score"
},
"formula": "bap_65",
"formula_expression": "class I = 0 main factors and age ≤65; II = 0 main factors and age >65; III = 1 main factor; IV = 2 main factors; V = 3 main factors (BUN >25 mg/dL, GCS <14 or disoriented/stupor/coma, pulse >109/min); age is not a 4th additive point",
"criteria": [
{
"factor": "bun_gt_25",
"met": false
},
{
"factor": "altered_mental_status",
"met": false
},
{
"factor": "pulse_gt_109",
"met": false
},
{
"factor": "age_gt_65",
"met": false
}
],
"bap65_class": "I",
"main_factor_count": 0
},
{
"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": "Tabak YP, Sun X, Johannes RS, Gupta V, Shorr AF",
"doi": "10.1001/archinternmed.2009.270",
"id": "tabak-2009",
"pmid": "19786679",
"source": "Arch Intern Med. 2009;169(17):1595-1602",
"title": "Mortality and need for mechanical ventilation in acute exacerbations of chronic obstructive pulmonary disease: development and validation of a simple risk score"
},
"formula": "bap_65",
"formula_expression": "class I = 0 main factors and age ≤65; II = 0 main factors and age >65; III = 1 main factor; IV = 2 main factors; V = 3 main factors (BUN >25 mg/dL, GCS <14 or disoriented/stupor/coma, pulse >109/min); age is not a 4th additive point",
"criteria": [
{
"factor": "bun_gt_25",
"met": false
},
{
"factor": "altered_mental_status",
"met": false
},
{
"factor": "pulse_gt_109",
"met": false
},
{
"factor": "age_gt_65",
"met": false
}
],
"bap65_class": "I",
"main_factor_count": 0
}
]
}
Response
| Field | Type | Description |
|---|---|---|
formula |
string | bap_65 |
formula_expression |
string | Tabak 2009: class I/II from zero main factors plus age; III/IV/V from 1/2/3 main factors |
bap65_class |
string | Tabak 2009 class I, II, III, IV, or V. A class, not a ventilation or ICU-admission order. |
main_factor_count |
integer | Count of the three main factors (BUN >25, altered mental status, pulse >109). 0-3. Age is not counted. |
criteria |
array | Per-factor rows with factor and met for bun_gt_25, altered_mental_status, pulse_gt_109, and age_gt_65 |
citation |
object | Tabak 2009 Arch Intern Med citation |
disclaimer |
string | Not-a-device notice |
Example JSON
Machine form of the same example. Frozen fixture. Not a live lookup.
{
"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": "Tabak YP, Sun X, Johannes RS, Gupta V, Shorr AF",
"doi": "10.1001/archinternmed.2009.270",
"id": "tabak-2009",
"pmid": "19786679",
"source": "Arch Intern Med. 2009;169(17):1595-1602",
"title": "Mortality and need for mechanical ventilation in acute exacerbations of chronic obstructive pulmonary disease: development and validation of a simple risk score"
},
"formula": "bap_65",
"formula_expression": "class I = 0 main factors and age ≤65; II = 0 main factors and age >65; III = 1 main factor; IV = 2 main factors; V = 3 main factors (BUN >25 mg/dL, GCS <14 or disoriented/stupor/coma, pulse >109/min); age is not a 4th additive point",
"criteria": [
{
"factor": "bun_gt_25",
"met": false
},
{
"factor": "altered_mental_status",
"met": false
},
{
"factor": "pulse_gt_109",
"met": false
},
{
"factor": "age_gt_65",
"met": false
}
],
"bap65_class": "I",
"main_factor_count": 0
}
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_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
- DECAF — Sum Steer 2012 DECAF points from extended MRC dyspnoea, eosinophils, chest radiograph consolidation, arterial pH, and atrial fibrillation.
- NEWS — Compute the RCP 2012 National Early Warning Score from respiratory rate, SpO2, supplemental oxygen, temperature, systolic BP, heart rate, and caller-assigned AVPU.
- MEWS — Compute the Subbe 2001 modified Early Warning Score from systolic BP, heart rate, respiratory rate, temperature, and caller-assigned AVPU.
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.