# Gupta postoperative pneumonia

Gupta pneumonia

Status: LIVE
Price: $0.005 USDC
`GET /api/calc/gupta_pneumonia`
HTML: https://magentlab.com/docs/gupta-pneumonia
Markdown: https://magentlab.com/docs/gupta-pneumonia.md

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

## What it computes

Compute the Gupta 2013 Mayo Clin Proc logistic probability of postoperative pneumonia from age, COPD, ASA class, functional status, preoperative sepsis, smoking in the last year, and surgery type.

## When to use

When an agent needs the published Gupta 2013 Mayo Clin Proc pneumonia probability and must not invent an antibiotic order, a ventilator order, a diagnosis, ARISCAT points, or a low/high cutoff.

## When not to use

- Not a medical device. Not a diagnosis, not an antibiotic order, and not a ventilator order.
- Gupta 2013 Mayo Clin Proc logistic pneumonia model only. This is not ARISCAT and not a surgical clearance.
- Gupta 2013 does not publish a low or high pneumonia cutoff; magent does not invent one.
- Gupta 2013 does not use race. magent does not accept a race input.
- functional_status, sepsis, smoking, COPD, and surgery are caller-assigned published categories. magent does not examine the patient or classify the procedure from a CPT code.

## Formula

```
L = -2.8977 + 0.0144*age + copd + functional_status + asa_class + sepsis + smoking + surgery (Gupta 2013 Mayo Clin Proc logistic table); COPD no -0.4553, yes 0; independent 0, partially_dependent 0.7653, totally_dependent 0.9400; ASA1 -3.0225, ASA2 -1.6057, ASA3 -0.4915, ASA4 0.0123, ASA5 0; sepsis none -0.7641, sirs 0, sepsis -0.0842, septic_shock 0.1048; smoking no -0.4306, yes 0; hernia 0, anorectal -0.8470, aortic 0.7178, bariatric -0.6282, brain 0.6841, breast -2.3318, cardiac 0.1382, ent -0.3665, foregut_hpb 1.0660, gbaas -0.3951, intestinal 0.6169, neck -0.0872, obstetric_gynecologic -0.4101, orthopedic -0.5415, other_abdomen 0.4021, peripheral_vascular -0.4519, skin -0.5075, spine -0.5672, thoracic 0.8901, vein -1.4760, urology 0.1076; estimated_probability_percent = 100 * exp(L) / (1 + exp(L))
```

## Citation

[Development and validation of a risk calculator for predicting postoperative pneumonia](https://doi.org/10.1016/j.mayocp.2013.06.027)
Gupta H, Gupta PK, Schuller D, Fang X, Miller WJ, Modrykamien A, Wichman TO, Morrow LE
Mayo Clin Proc. 2013;88(11):1241-1249
DOI: [10.1016/j.mayocp.2013.06.027](https://doi.org/10.1016/j.mayocp.2013.06.027)

## Worked example

### Age 40, independent, ASA 2, no COPD, no sepsis, non-smoker, hernia

Given: `age=40, asa_class=2, copd=false, functional_status=independent, sepsis=none, smoking=false, surgery=hernia`

1. L = -2.8977 + 0.0144×40 + -0.4553 (no COPD) + 0 (independent) + -1.6057 (ASA 2) + -0.7641 (none) + -0.4306 (non-smoker) + 0 (hernia) = -5.5774
2. estimated_probability_percent = 100 × e^(-5.5774) / (1 + e^(-5.5774))


### Age 70, COPD, independent, ASA 2, no sepsis, non-smoker, hernia

Given: `age=70, asa_class=2, copd=true, functional_status=independent, sepsis=none, smoking=false, surgery=hernia`

1. L = -2.8977 + 0.0144×70 + 0 (COPD) + 0 + -1.6057 (ASA 2) + -0.7641 (none) + -0.4306 (non-smoker) + 0 = -4.6901
2. estimated_probability_percent from the Mayo Clin Proc logistic table, two decimals from the unrounded logit


### Age 40, independent, ASA 4, no COPD, no sepsis, non-smoker, hernia

Given: `age=40, asa_class=4, copd=false, functional_status=independent, sepsis=none, smoking=false, surgery=hernia`

1. L = -2.8977 + 0.0144×40 + -0.4553 (no COPD) + 0 + 0.0123 (ASA 4) + -0.7641 (none) + -0.4306 (non-smoker) + 0 = -3.9594
2. estimated_probability_percent from the Mayo Clin Proc logistic table, two decimals from the unrounded logit


### Age 40, totally dependent, ASA 2, no COPD, no sepsis, non-smoker, hernia

Given: `age=40, asa_class=2, copd=false, functional_status=totally_dependent, sepsis=none, smoking=false, surgery=hernia`

1. L = -2.8977 + 0.0144×40 + -0.4553 (no COPD) + 0.9400 (totally_dependent) + -1.6057 (ASA 2) + -0.7641 (none) + -0.4306 (non-smoker) + 0 = -4.6374
2. estimated_probability_percent from the Mayo Clin Proc logistic table, two decimals from the unrounded logit


### Age 40, independent, ASA 2, no COPD, no sepsis, non-smoker, aortic

Given: `age=40, asa_class=2, copd=false, functional_status=independent, sepsis=none, smoking=false, surgery=aortic`

1. L = -2.8977 + 0.0144×40 + -0.4553 (no COPD) + 0 + -1.6057 (ASA 2) + -0.7641 (none) + -0.4306 (non-smoker) + 0.7178 (aortic) = -4.8596
2. estimated_probability_percent from the Mayo Clin Proc logistic table, two decimals from the unrounded logit


## Also searched as

- Gupta postoperative pneumonia
- NSQIP pneumonia probability
- Gupta 2013 pneumonia
- postoperative pneumonia risk
- preoperative pneumonia probability
- surgical pneumonia probability
- Gupta perioperative pneumonia

## Parameters

- `age` (integer, required): Age in years (18-120). Gupta 2013 Mayo Clin Proc: +0.0144 per year.
- `copd` (boolean, required): Gupta 2013 COPD causing functional disability or hospitalization, or FEV1 <75%, as assigned by the caller: true (reference, 0) or false (-0.4553). magent does not diagnose COPD.
- `functional_status` (string, required): Gupta 2013 Mayo Clin Proc functional status as assigned by the caller: independent (reference, 0), partially_dependent (+0.7653), or totally_dependent (+0.9400). magent does not examine the patient.
- `asa_class` (integer, required): ASA physical status 1-5 (Gupta 2013 Mayo Clin Proc logistic table; class 5 is the reference). class 1 -3.0225, class 2 -1.6057, class 3 -0.4915, class 4 +0.0123, class 5 adds 0. Caller-assigned integer.
- `sepsis` (string, required): Gupta 2013 Mayo Clin Proc preoperative sepsis category as assigned by the caller: none (-0.7641), sirs (reference, 0), sepsis (-0.0842), or septic_shock (+0.1048). magent does not diagnose sepsis.
- `smoking` (boolean, required): Gupta 2013 smoking within the last year as assigned by the caller: true (reference, 0) or false (-0.4306).
- `surgery` (string, required): Gupta 2013 Mayo Clin Proc procedure category as assigned by the caller. hernia (ventral, inguinal, or femoral) is the reference (0). gbaas is gallbladder, appendix, adrenal, or spleen. thoracic is non-esophageal thoracic. orthopedic is orthopedic or non-vascular extremity. ent excludes thyroid/parathyroid (neck). magent does not classify a CPT code.

## 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/gupta_pneumonia`
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",
      "asa_class": "2",
      "copd": "false",
      "functional_status": "independent",
      "sepsis": "none",
      "smoking": "false",
      "surgery": "hernia"
    },
    {
      "age": "40",
      "asa_class": "2",
      "copd": "false",
      "functional_status": "independent",
      "sepsis": "none",
      "smoking": "false",
      "surgery": "hernia"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/gupta_pneumonia",
  "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": "Gupta H, Gupta PK, Schuller D, Fang X, Miller WJ, Modrykamien A, Wichman TO, Morrow LE",
        "doi": "10.1016/j.mayocp.2013.06.027",
        "id": "gupta-2013-pneumonia",
        "pmid": "24182703",
        "source": "Mayo Clin Proc. 2013;88(11):1241-1249",
        "title": "Development and validation of a risk calculator for predicting postoperative pneumonia"
      },
      "formula": "gupta_pneumonia",
      "formula_expression": "L = -2.8977 + 0.0144*age + copd + functional_status + asa_class + sepsis + smoking + surgery (Gupta 2013 Mayo Clin Proc logistic table); COPD no -0.4553, yes 0; independent 0, partially_dependent 0.7653, totally_dependent 0.9400; ASA1 -3.0225, ASA2 -1.6057, ASA3 -0.4915, ASA4 0.0123, ASA5 0; sepsis none -0.7641, sirs 0, sepsis -0.0842, septic_shock 0.1048; smoking no -0.4306, yes 0; hernia 0, anorectal -0.8470, aortic 0.7178, bariatric -0.6282, brain 0.6841, breast -2.3318, cardiac 0.1382, ent -0.3665, foregut_hpb 1.0660, gbaas -0.3951, intestinal 0.6169, neck -0.0872, obstetric_gynecologic -0.4101, orthopedic -0.5415, other_abdomen 0.4021, peripheral_vascular -0.4519, skin -0.5075, spine -0.5672, thoracic 0.8901, vein -1.4760, urology 0.1076; estimated_probability_percent = 100 * exp(L) / (1 + exp(L))",
      "age_years": 40,
      "estimated_probability_percent": 0.38,
      "logit": -5.5774,
      "asa_class": 2,
      "smoking": false,
      "surgery": "hernia",
      "copd": false,
      "functional_status": "independent",
      "sepsis": "none"
    },
    {
      "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": "Gupta H, Gupta PK, Schuller D, Fang X, Miller WJ, Modrykamien A, Wichman TO, Morrow LE",
        "doi": "10.1016/j.mayocp.2013.06.027",
        "id": "gupta-2013-pneumonia",
        "pmid": "24182703",
        "source": "Mayo Clin Proc. 2013;88(11):1241-1249",
        "title": "Development and validation of a risk calculator for predicting postoperative pneumonia"
      },
      "formula": "gupta_pneumonia",
      "formula_expression": "L = -2.8977 + 0.0144*age + copd + functional_status + asa_class + sepsis + smoking + surgery (Gupta 2013 Mayo Clin Proc logistic table); COPD no -0.4553, yes 0; independent 0, partially_dependent 0.7653, totally_dependent 0.9400; ASA1 -3.0225, ASA2 -1.6057, ASA3 -0.4915, ASA4 0.0123, ASA5 0; sepsis none -0.7641, sirs 0, sepsis -0.0842, septic_shock 0.1048; smoking no -0.4306, yes 0; hernia 0, anorectal -0.8470, aortic 0.7178, bariatric -0.6282, brain 0.6841, breast -2.3318, cardiac 0.1382, ent -0.3665, foregut_hpb 1.0660, gbaas -0.3951, intestinal 0.6169, neck -0.0872, obstetric_gynecologic -0.4101, orthopedic -0.5415, other_abdomen 0.4021, peripheral_vascular -0.4519, skin -0.5075, spine -0.5672, thoracic 0.8901, vein -1.4760, urology 0.1076; estimated_probability_percent = 100 * exp(L) / (1 + exp(L))",
      "age_years": 40,
      "estimated_probability_percent": 0.38,
      "logit": -5.5774,
      "asa_class": 2,
      "smoking": false,
      "surgery": "hernia",
      "copd": false,
      "functional_status": "independent",
      "sepsis": "none"
    }
  ]
}
```

## Response fields

- `formula` (string): gupta_pneumonia
- `formula_expression` (string): Gupta 2013 Mayo Clin Proc logistic expression
- `age_years` (integer): Input age in years
- `copd` (boolean): true if Gupta 2013 COPD criterion is present
- `functional_status` (string): independent, partially_dependent, or totally_dependent
- `asa_class` (integer): ASA physical status 1-5
- `sepsis` (string): none, sirs, sepsis, or septic_shock
- `smoking` (boolean): true if the caller assigns smoking within the last year
- `surgery` (string): Gupta 2013 Mayo Clin Proc procedure category
- `logit` (number): Gupta 2013 Mayo Clin Proc linear predictor L, 4 decimal places
- `estimated_probability_percent` (number): 100 * exp(L) / (1 + exp(L)) from the unrounded logit, 2 decimal places. A probability, not an antibiotic order.
- `citation` (object): Gupta et al. Mayo Clin Proc 2013 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "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": "Gupta H, Gupta PK, Schuller D, Fang X, Miller WJ, Modrykamien A, Wichman TO, Morrow LE",
    "doi": "10.1016/j.mayocp.2013.06.027",
    "id": "gupta-2013-pneumonia",
    "pmid": "24182703",
    "source": "Mayo Clin Proc. 2013;88(11):1241-1249",
    "title": "Development and validation of a risk calculator for predicting postoperative pneumonia"
  },
  "formula": "gupta_pneumonia",
  "formula_expression": "L = -2.8977 + 0.0144*age + copd + functional_status + asa_class + sepsis + smoking + surgery (Gupta 2013 Mayo Clin Proc logistic table); COPD no -0.4553, yes 0; independent 0, partially_dependent 0.7653, totally_dependent 0.9400; ASA1 -3.0225, ASA2 -1.6057, ASA3 -0.4915, ASA4 0.0123, ASA5 0; sepsis none -0.7641, sirs 0, sepsis -0.0842, septic_shock 0.1048; smoking no -0.4306, yes 0; hernia 0, anorectal -0.8470, aortic 0.7178, bariatric -0.6282, brain 0.6841, breast -2.3318, cardiac 0.1382, ent -0.3665, foregut_hpb 1.0660, gbaas -0.3951, intestinal 0.6169, neck -0.0872, obstetric_gynecologic -0.4101, orthopedic -0.5415, other_abdomen 0.4021, peripheral_vascular -0.4519, skin -0.5075, spine -0.5672, thoracic 0.8901, vein -1.4760, urology 0.1076; estimated_probability_percent = 100 * exp(L) / (1 + exp(L))",
  "age_years": 40,
  "estimated_probability_percent": 0.38,
  "logit": -5.5774,
  "asa_class": 2,
  "smoking": false,
  "surgery": "hernia",
  "copd": false,
  "functional_status": "independent",
  "sepsis": "none"
}
```

## Errors

- HTTP 400 `invalid_gupta_pneumonia`: Gupta pneumonia needs Gupta 2013 age, COPD, functional status, ASA, sepsis, smoking, and surgery type in published ranges. 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

- [Gupta PRF](https://magentlab.com/docs/gupta-prf) — Compute the Gupta 2011 Chest logistic probability of postoperative respiratory failure (mechanical ventilation >48 h after surgery or unplanned intubation within 30 days) from ASA class, functional status, preoperative sepsis, emergency case, and surgery type.
- [Gupta MICA](https://magentlab.com/docs/gupta-mica) — Compute the Gupta 2011 Table 2 logistic probability of 30-day myocardial infarction or cardiac arrest after surgery from age, ASA class, functional status, creatinine category, and surgery type.

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