# GI-GPA

GI-GPA

Status: LIVE
Price: $0.005 USDC
`GET /api/calc/gi_gpa`
HTML: https://magentlab.com/docs/gi-gpa
Markdown: https://magentlab.com/docs/gi-gpa.md

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

## What it computes

Compute the Sperduto 2019 updated GI-GPA (graded prognostic assessment for gastrointestinal cancers with brain metastases) from caller-assigned KPS, age, extracranial metastases, and number of brain metastases, and report the published GPA group and median survival.

## When to use

When an agent already has Karnofsky Performance Status (decades 10-100), age, presence or absence of extracranial metastases, and brain-metastasis count, and must not invent GI-GPA points, assign KPS, or treat the score as a treatment order or lung-molGPA.

## When not to use

- Not a medical device and not a treatment order.
- Sperduto 2019 Table 4 footnote lists median survival 3, 9, 12, 17 months; magent uses the abstract/Kaplan-Meier figures 3, 7, 11, 17 months for GPA groups 0-1.0, 1.5-2.0, 2.5-3.0, and 3.5-4.0.
- Not lung-molGPA. This is the updated GI-GPA for gastrointestinal cancers with brain metastases (Sperduto 2019), not the lung-molGPA index.
- The caller assigns KPS 10-100 by tens. magent does not assign KPS or examine the patient.

## Formula

```
GI-GPA = kps_pts + age_pts + extracranial_pts + brain_met_pts; KPS <80 (10-70) 0, 80 1.0, 90-100 2.0; age >=60 0, <60 0.5; extracranial mets present 0, absent 0.5; brain mets >3 0, 2-3 0.5, 1 1.0; groups 0-1.0 / 1.5-2.0 / 2.5-3.0 / 3.5-4.0; max 4.0 (Sperduto 2019 Table 4; median survival from abstract/KM 3, 7, 11, 17 months)
```

## Citation

[Estimating survival in patients with gastrointestinal cancers and brain metastases: An update of the graded prognostic assessment for gastrointestinal cancers (GI-GPA)](https://doi.org/10.1016/j.ctro.2019.06.007)
Sperduto PW, Fang P, Li J, et al.
Clin Transl Radiat Oncol. 2019;18:39-45
DOI: [10.1016/j.ctro.2019.06.007](https://doi.org/10.1016/j.ctro.2019.06.007)

## Worked example

### KPS 100, age 50, no extracranial mets, one brain met

Given: `age=50, brain_metastasis_count=1, extracranial_metastases=false, kps=100`

1. KPS 100 is 90-100 → 2.0; age 50 is <60 → 0.5; extracranial mets absent → 0.5; one brain met → 1.0
2. Score = 4.0 (max 4.0); gpa_group 3.5-4.0; median survival 17 months (abstract/KM)


### KPS 70, age 70, extracranial mets, five brain mets

Given: `age=70, brain_metastasis_count=5, extracranial_metastases=true, kps=70`

1. KPS 70 is <80 → 0; age 70 is >=60 → 0; extracranial mets present → 0; five brain mets >3 → 0
2. Score = 0 (max 4.0); gpa_group 0-1.0; median survival 3 months (abstract/KM)


### KPS 80, age 55, no extracranial mets, two brain mets

Given: `age=55, brain_metastasis_count=2, extracranial_metastases=false, kps=80`

1. KPS 80 → 1.0; age 55 is <60 → 0.5; extracranial mets absent → 0.5; two brain mets → 0.5
2. Score = 2.5 (max 4.0); gpa_group 2.5-3.0; median survival 11 months (abstract/KM)


### KPS 80, age 70, extracranial mets, one brain met

Given: `age=70, brain_metastasis_count=1, extracranial_metastases=true, kps=80`

1. KPS 80 → 1.0; age 70 is >=60 → 0; extracranial mets present → 0; one brain met → 1.0
2. Score = 2.0 (max 4.0); gpa_group 1.5-2.0; median survival 7 months (abstract/KM)


## Also searched as

- GI-GPA
- gastrointestinal GPA
- Sperduto GI-GPA
- graded prognostic assessment GI
- GI cancer brain metastases GPA
- updated GI-GPA
- Sperduto 2019 GI-GPA
- GI GPA median survival

## Parameters

- `kps` (integer, required): Caller-assigned Karnofsky Performance Status decade 10, 20, 30, 40, 50, 60, 70, 80, 90, or 100. Sperduto 2019 Table 4: <80 (10-70) scores 0; 80 scores 1.0; 90-100 scores 2.0. Grade 0 (dead) is not scored. magent does not assign KPS.
- `age` (integer, required): Age in years (18-120). Sperduto 2019 Table 4: >=60 scores 0; <60 scores 0.5.
- `extracranial_metastases` (boolean, required): Extracranial metastases (ECM). true (present) scores 0; false (absent) scores 0.5 (Sperduto 2019 Table 4). magent does not stage extracranial disease.
- `brain_metastasis_count` (integer, required): Number of brain metastases (integer 1-50). Sperduto 2019 Table 4: >3 scores 0; 2-3 scores 0.5; 1 scores 1.0. magent does not count metastases on imaging.

## 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/gi_gpa`
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": "50",
      "brain_metastasis_count": "1",
      "extracranial_metastases": "false",
      "kps": "100"
    },
    {
      "age": "50",
      "brain_metastasis_count": "1",
      "extracranial_metastases": "false",
      "kps": "100"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/gi_gpa",
  "items": [
    {
      "components": [
        {
          "value": 100,
          "factor": "kps",
          "points": 2.0,
          "present": true
        },
        {
          "value": 50,
          "factor": "age",
          "points": 0.5,
          "present": true
        },
        {
          "value": false,
          "factor": "extracranial_metastases",
          "points": 0.5,
          "present": true
        },
        {
          "value": 1,
          "factor": "brain_metastasis_count",
          "points": 1.0,
          "present": true
        }
      ],
      "age": 50,
      "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": "Sperduto PW, Fang P, Li J, et al.",
        "doi": "10.1016/j.ctro.2019.06.007",
        "id": "sperduto-2019-gi-gpa",
        "pmid": "31341974",
        "source": "Clin Transl Radiat Oncol. 2019;18:39-45",
        "title": "Estimating survival in patients with gastrointestinal cancers and brain metastases: An update of the graded prognostic assessment for gastrointestinal cancers (GI-GPA)"
      },
      "formula": "gi_gpa",
      "formula_expression": "GI-GPA = kps_pts + age_pts + extracranial_pts + brain_met_pts; KPS <80 (10-70) 0, 80 1.0, 90-100 2.0; age >=60 0, <60 0.5; extracranial mets present 0, absent 0.5; brain mets >3 0, 2-3 0.5, 1 1.0; groups 0-1.0 / 1.5-2.0 / 2.5-3.0 / 3.5-4.0; max 4.0 (Sperduto 2019 Table 4; median survival from abstract/KM 3, 7, 11, 17 months)",
      "max_score": 4.0,
      "score": 4.0,
      "brain_metastasis_count": 1,
      "extracranial_metastases": false,
      "gpa_group": "3.5-4.0",
      "kps": 100,
      "median_survival_months": 17
    },
    {
      "components": [
        {
          "value": 100,
          "factor": "kps",
          "points": 2.0,
          "present": true
        },
        {
          "value": 50,
          "factor": "age",
          "points": 0.5,
          "present": true
        },
        {
          "value": false,
          "factor": "extracranial_metastases",
          "points": 0.5,
          "present": true
        },
        {
          "value": 1,
          "factor": "brain_metastasis_count",
          "points": 1.0,
          "present": true
        }
      ],
      "age": 50,
      "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": "Sperduto PW, Fang P, Li J, et al.",
        "doi": "10.1016/j.ctro.2019.06.007",
        "id": "sperduto-2019-gi-gpa",
        "pmid": "31341974",
        "source": "Clin Transl Radiat Oncol. 2019;18:39-45",
        "title": "Estimating survival in patients with gastrointestinal cancers and brain metastases: An update of the graded prognostic assessment for gastrointestinal cancers (GI-GPA)"
      },
      "formula": "gi_gpa",
      "formula_expression": "GI-GPA = kps_pts + age_pts + extracranial_pts + brain_met_pts; KPS <80 (10-70) 0, 80 1.0, 90-100 2.0; age >=60 0, <60 0.5; extracranial mets present 0, absent 0.5; brain mets >3 0, 2-3 0.5, 1 1.0; groups 0-1.0 / 1.5-2.0 / 2.5-3.0 / 3.5-4.0; max 4.0 (Sperduto 2019 Table 4; median survival from abstract/KM 3, 7, 11, 17 months)",
      "max_score": 4.0,
      "score": 4.0,
      "brain_metastasis_count": 1,
      "extracranial_metastases": false,
      "gpa_group": "3.5-4.0",
      "kps": 100,
      "median_survival_months": 17
    }
  ]
}
```

## Response fields

- `formula` (string): gi_gpa
- `formula_expression` (string): Exact expression used
- `score` (number): Total GI-GPA points 0-4.0 in 0.5 steps
- `max_score` (number): Always 4.0
- `gpa_group` (string): 0-1.0, 1.5-2.0, 2.5-3.0, or 3.5-4.0 from Sperduto 2019
- `median_survival_months` (integer): Published median survival in months for that GPA group from the Sperduto 2019 abstract/Kaplan-Meier figures (3, 7, 11, 17), not the Table 4 footnote
- `kps` (integer): Caller-assigned Karnofsky decade used for points
- `age` (integer): Age in years used for points
- `extracranial_metastases` (boolean): true if extracranial metastases are present
- `brain_metastasis_count` (integer): Number of brain metastases used for points
- `components` (array): Per-factor points
- `citation` (object): Sperduto 2019 Clin Transl Radiat Oncol citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 100,
      "factor": "kps",
      "points": 2.0,
      "present": true
    },
    {
      "value": 50,
      "factor": "age",
      "points": 0.5,
      "present": true
    },
    {
      "value": false,
      "factor": "extracranial_metastases",
      "points": 0.5,
      "present": true
    },
    {
      "value": 1,
      "factor": "brain_metastasis_count",
      "points": 1.0,
      "present": true
    }
  ],
  "age": 50,
  "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": "Sperduto PW, Fang P, Li J, et al.",
    "doi": "10.1016/j.ctro.2019.06.007",
    "id": "sperduto-2019-gi-gpa",
    "pmid": "31341974",
    "source": "Clin Transl Radiat Oncol. 2019;18:39-45",
    "title": "Estimating survival in patients with gastrointestinal cancers and brain metastases: An update of the graded prognostic assessment for gastrointestinal cancers (GI-GPA)"
  },
  "formula": "gi_gpa",
  "formula_expression": "GI-GPA = kps_pts + age_pts + extracranial_pts + brain_met_pts; KPS <80 (10-70) 0, 80 1.0, 90-100 2.0; age >=60 0, <60 0.5; extracranial mets present 0, absent 0.5; brain mets >3 0, 2-3 0.5, 1 1.0; groups 0-1.0 / 1.5-2.0 / 2.5-3.0 / 3.5-4.0; max 4.0 (Sperduto 2019 Table 4; median survival from abstract/KM 3, 7, 11, 17 months)",
  "max_score": 4.0,
  "score": 4.0,
  "brain_metastasis_count": 1,
  "extracranial_metastases": false,
  "gpa_group": "3.5-4.0",
  "kps": 100,
  "median_survival_months": 17
}
```

## Errors

- HTTP 400 `invalid_karnofsky`: kps must be 10, 20, 30, 40, 50, 60, 70, 80, 90, or 100 (Karnofsky 1949). Grade 0 (dead) is not scored. 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_flag`: boolean clinical flags must be true or false Returned before settlement; you are not charged.
- HTTP 400 `invalid_brain_metastasis_count`: brain_metastasis_count must be an integer from 1 to 50 (Sperduto 2019 number of brain metastases). 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

- [Brain metastasis velocity](https://magentlab.com/docs/bmv) — Compute Farris 2017 brain metastasis velocity as new_brain_metastases / years_since_first_srs and report the published low, intermediate, or high group plus that group's median overall survival after initial distant brain failure.
- [THRIVE](https://magentlab.com/docs/thrive) — Compute the Flint 2010 THRIVE (Totaled Health Risks in Vascular Events) score from trichotomized age, trichotomized NIHSS, and the chronic disease scale (hypertension, diabetes mellitus, atrial fibrillation).
- [Karnofsky](https://magentlab.com/docs/karnofsky) — Return the Karnofsky 1949 Performance Status 10-100 from a caller-assigned integer, with a stable label.

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