Respiratory · LIVE
GAP index
Sum Ley 2012 GAP index points from sex, age, FVC percent predicted, and DLCO percent predicted or cannot-perform.
Markdown: /docs/gap-index.md · Canonical: https://magentlab.com/docs/gap-index
Not a medical device. Not a diagnosis, dose, or listing recommendation.
What it computes
Sum Ley 2012 GAP index points from sex, age, FVC percent predicted, and DLCO percent predicted or cannot-perform.
When to use
When an agent needs the published Ley 2012 GAP index total and stage and must not invent a transplant listing or a continuous GAP value.
When not to use
- Not a medical device and not a transplant listing protocol. Stages follow Ley 2012 GAP index points (I 0-3 / II 4-5 / III 6-8).
- Ley 2012 reported 1-, 2-, and 3-year mortality by GAP stage in derivation and validation cohorts; those cohort proportions are not returned in the JSON body.
- Provide exactly one of dlco_percent_predicted or dlco_cannot_perform=true. FVC and DLCO percent predicted are caller-supplied; magent does not compute percent predicted from raw spirometry.
Formula
GAP = sex_points + age_points + fvc_points + dlco_points; female 0 male 1; age <=60 -> 0, 61-65 -> 1, >65 -> 2; FVC% >75 -> 0, 50-75 -> 1, <50 -> 2; DLCO% >55 -> 0, 36-55 -> 1, <=35 -> 2, cannot perform -> 3; stages I 0-3 / II 4-5 / III 6-8; max 8
Citation
- Authors
- Ley B, Ryerson CJ, Vittinghoff E, et al.
- Source
- Ann Intern Med. 2012;156(10):684-691
Worked example
All 0-point bands (stage I)
Given:
age=55dlco_percent_predicted=60fvc_percent_predicted=80sex=female
- Female → 0; age 55 ≤60 → 0; FVC 80% >75 → 0; DLCO 60% >55 → 0
- Score = 0; stage 1
Maximum points (stage III)
Given:
age=70dlco_cannot_perform=truefvc_percent_predicted=40sex=male
- Male → 1; age 70 >65 → 2; FVC 40% <50 → 2; DLCO cannot perform → 3
- Score = 8; stage 3
Also searched as
- GAP index
- GAP score
- Ley GAP
- IPF GAP
- gender age physiology
- idiopathic pulmonary fibrosis staging
- GAP stage
Try
Opens the live endpoint. Unpaid browser requests show the paywall; agents should send Accept: application/json.
/api/calc/gap_index?sex=female&age=55&fvc_percent_predicted=80&dlco_percent_predicted=60
Full URL: https://api.magentlab.com/api/calc/gap_index?sex=female&age=55&fvc_percent_predicted=80&dlco_percent_predicted=60
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/gap_index?sex=female&age=55&fvc_percent_predicted=80&dlco_percent_predicted=60"
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
sex |
string | required · female, male | Sex (female or male). Ley 2012: female scores 0; male scores 1. |
age |
integer | required | Age in years (integer 18-120). Ley 2012: <=60 scores 0; 61-65 scores 1; >65 scores 2. |
fvc_percent_predicted |
number | required | FVC percent predicted (10-150). Ley 2012: >75 scores 0; 50-75 scores 1; <50 scores 2. 75.0 scores 1. |
dlco_percent_predicted |
number | optional | DLCO percent predicted (1-150). Provide this or dlco_cannot_perform=true, not both. Ley 2012: >55 scores 0; 36-55 scores 1; <=35 scores 2. |
dlco_cannot_perform |
boolean | optional | true when DLCO cannot be performed (Ley 2012 scores 3). Provide this or dlco_percent_predicted, not both. |
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": "55",
"dlco_percent_predicted": "60",
"fvc_percent_predicted": "80",
"sex": "female"
},
{
"age": "55",
"dlco_percent_predicted": "60",
"fvc_percent_predicted": "80",
"sex": "female"
}
]
}
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/gap_index",
"items": [
{
"components": [
{
"value": "female",
"factor": "sex",
"points": 0,
"present": false
},
{
"value": 55,
"factor": "age",
"points": 0,
"present": false
},
{
"value": 80.0,
"factor": "fvc",
"points": 0,
"present": false
},
{
"value": 60.0,
"factor": "dlco",
"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": "Ley B, Ryerson CJ, Vittinghoff E, et al.",
"doi": "10.7326/0003-4819-156-10-201205150-00004",
"id": "ley-2012",
"pmid": "22586007",
"source": "Ann Intern Med. 2012;156(10):684-691",
"title": "A multidimensional index and staging system for idiopathic pulmonary fibrosis"
},
"formula": "gap_index",
"formula_expression": "GAP = sex_points + age_points + fvc_points + dlco_points; female 0 male 1; age <=60 -> 0, 61-65 -> 1, >65 -> 2; FVC% >75 -> 0, 50-75 -> 1, <50 -> 2; DLCO% >55 -> 0, 36-55 -> 1, <=35 -> 2, cannot perform -> 3; stages I 0-3 / II 4-5 / III 6-8; max 8",
"max_score": 8,
"score": 0,
"age_years": 55,
"sex": "female",
"dlco_cannot_perform": false,
"dlco_percent_predicted": 60.0,
"fvc_percent_predicted": 80.0,
"gap_stage": 1
},
{
"components": [
{
"value": "female",
"factor": "sex",
"points": 0,
"present": false
},
{
"value": 55,
"factor": "age",
"points": 0,
"present": false
},
{
"value": 80.0,
"factor": "fvc",
"points": 0,
"present": false
},
{
"value": 60.0,
"factor": "dlco",
"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": "Ley B, Ryerson CJ, Vittinghoff E, et al.",
"doi": "10.7326/0003-4819-156-10-201205150-00004",
"id": "ley-2012",
"pmid": "22586007",
"source": "Ann Intern Med. 2012;156(10):684-691",
"title": "A multidimensional index and staging system for idiopathic pulmonary fibrosis"
},
"formula": "gap_index",
"formula_expression": "GAP = sex_points + age_points + fvc_points + dlco_points; female 0 male 1; age <=60 -> 0, 61-65 -> 1, >65 -> 2; FVC% >75 -> 0, 50-75 -> 1, <50 -> 2; DLCO% >55 -> 0, 36-55 -> 1, <=35 -> 2, cannot perform -> 3; stages I 0-3 / II 4-5 / III 6-8; max 8",
"max_score": 8,
"score": 0,
"age_years": 55,
"sex": "female",
"dlco_cannot_perform": false,
"dlco_percent_predicted": 60.0,
"fvc_percent_predicted": 80.0,
"gap_stage": 1
}
]
}
Response
| Field | Type | Description |
|---|---|---|
formula |
string | gap_index |
formula_expression |
string | Exact Ley 2012 GAP index expression |
score |
integer | GAP index points 0-8 |
max_score |
integer | Always 8 |
gap_stage |
integer | Ley 2012 stage 1 (0-3), 2 (4-5), or 3 (6-8). Not a transplant listing. |
sex |
string | female or male used |
age_years |
integer | Age in years used |
fvc_percent_predicted |
number | FVC percent predicted used |
dlco_percent_predicted |
number | DLCO percent predicted used, or null when cannot perform |
dlco_cannot_perform |
boolean | true when Ley 2012 cannot-perform DLCO (3 points) was used |
components |
array | Per-factor points for sex, age, fvc, and dlco |
citation |
object | Ley et al. Ann Intern Med 2012 citation |
disclaimer |
string | Not-a-device notice |
Example JSON
Machine form of the same example. Frozen fixture. Not a live lookup.
{
"components": [
{
"value": "female",
"factor": "sex",
"points": 0,
"present": false
},
{
"value": 55,
"factor": "age",
"points": 0,
"present": false
},
{
"value": 80.0,
"factor": "fvc",
"points": 0,
"present": false
},
{
"value": 60.0,
"factor": "dlco",
"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": "Ley B, Ryerson CJ, Vittinghoff E, et al.",
"doi": "10.7326/0003-4819-156-10-201205150-00004",
"id": "ley-2012",
"pmid": "22586007",
"source": "Ann Intern Med. 2012;156(10):684-691",
"title": "A multidimensional index and staging system for idiopathic pulmonary fibrosis"
},
"formula": "gap_index",
"formula_expression": "GAP = sex_points + age_points + fvc_points + dlco_points; female 0 male 1; age <=60 -> 0, 61-65 -> 1, >65 -> 2; FVC% >75 -> 0, 50-75 -> 1, <50 -> 2; DLCO% >55 -> 0, 36-55 -> 1, <=35 -> 2, cannot perform -> 3; stages I 0-3 / II 4-5 / III 6-8; max 8",
"max_score": 8,
"score": 0,
"age_years": 55,
"sex": "female",
"dlco_cannot_perform": false,
"dlco_percent_predicted": 60.0,
"fvc_percent_predicted": 80.0,
"gap_stage": 1
}
Client errors (HTTP 400)
Invalid params return 400 without charge. Shared HTTP 402 and 503 meanings: Payments.
| HTTP | Code | When |
|---|---|---|
| 400 | invalid_age |
age must be an integer from 18 to 120 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_fvc_percent |
fvc_percent_predicted must be a number from 10 to 150. Returned before settlement; you are not charged. |
| 400 | invalid_dlco_percent |
dlco_percent_predicted must be a number from 1 to 150. Returned before settlement; you are not charged. |
| 400 | invalid_gap_dlco |
provide dlco_percent_predicted or dlco_cannot_perform=true, not both (Ley 2012). 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.
- PaO2/FiO2 ratio — Compute the PaO2/FiO2 ratio as arterial PO2 in mm Hg divided by inspired oxygen fraction.
- Peak expiratory flow — Compute Nunn and Gregg 1989 predicted peak expiratory flow in L/min from age, sex, and height.
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.