# Gupta postoperative respiratory failure

Gupta PRF

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

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

## What it computes

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.

## When to use

When an agent needs the published Gupta 2011 Chest PRF probability and must not invent a ventilator order, a diagnosis, ARISCAT points, or a low/high cutoff.

## When not to use

- Not a medical device. Not a diagnosis and not a ventilator order.
- Gupta 2011 Chest logistic PRF model only. This is not ARISCAT and not a surgical clearance.
- Gupta 2011 does not publish a low or high PRF cutoff; magent does not invent one.
- Age and laboratory values are not in the published table.
- functional_status, sepsis, emergency, and surgery are caller-assigned published categories. magent does not examine the patient or classify the procedure from a CPT code.

## Formula

```
L = -1.7397 + functional_status + asa_class + sepsis + emergency + surgery (Gupta 2011 Chest logistic table); independent 0, partially_dependent 0.7678, totally_dependent 1.4046; ASA1 -3.5265, ASA2 -2.0008, ASA3 -0.6201, ASA4 0.2441, ASA5 0; sepsis none -0.7840, sirs 0, sepsis 0.2752, septic_shock 0.9035; elective -0.5739, emergency 0; hernia 0, anorectal -1.3530, aortic 1.0781, bariatric -1.0112, brain 0.7336, breast -2.6462, cardiac 0.2744, ent 0.1060, foregut_hpb 0.9694, gbaas -0.5668, intestinal 0.5737, neck -0.5271, obstetric_gynecologic -1.2431, orthopedic -0.8577, other_abdomen 0.2416, peripheral_vascular -0.2389, skin -0.3206, spine -0.5220, thoracic 0.6715, vein -2.0080, urology 0.3093; estimated_probability_percent = 100 * exp(L) / (1 + exp(L))
```

## Citation

[Development and validation of a risk calculator predicting postoperative respiratory failure](https://doi.org/10.1378/chest.11-0466)
Gupta H, Gupta PK, Fang X, Miller WJ, Cemaj S, Forse RA, Morrow LE
Chest. 2011;140(5):1207-1215
DOI: [10.1378/chest.11-0466](https://doi.org/10.1378/chest.11-0466)

## Worked example

### Independent, ASA 2, no sepsis, elective hernia

Given: `asa_class=2, emergency=false, functional_status=independent, sepsis=none, surgery=hernia`

1. L = -1.7397 + 0 (independent) + -2.0008 (ASA 2) + -0.7840 (none) + -0.5739 (elective) + 0 (hernia) = -5.0984
2. estimated_probability_percent = 100 × e^(-5.0984) / (1 + e^(-5.0984))


### Independent, ASA 4, no sepsis, elective hernia

Given: `asa_class=4, emergency=false, functional_status=independent, sepsis=none, surgery=hernia`

1. L = -1.7397 + 0 + 0.2441 (ASA 4) + -0.7840 (none) + -0.5739 (elective) + 0 = -2.8535
2. estimated_probability_percent from the Chest logistic table, two decimals from the unrounded logit


### Independent, ASA 2, no sepsis, emergency hernia

Given: `asa_class=2, emergency=true, functional_status=independent, sepsis=none, surgery=hernia`

1. L = -1.7397 + 0 + -2.0008 (ASA 2) + -0.7840 (none) + 0 (emergency) + 0 = -4.5245
2. estimated_probability_percent from the Chest logistic table, two decimals from the unrounded logit


### Independent, ASA 2, preoperative sepsis, elective hernia

Given: `asa_class=2, emergency=false, functional_status=independent, sepsis=sepsis, surgery=hernia`

1. L = -1.7397 + 0 + -2.0008 (ASA 2) + 0.2752 (sepsis) + -0.5739 (elective) + 0 = -4.0392
2. estimated_probability_percent from the Chest logistic table, two decimals from the unrounded logit


### Totally dependent, ASA 2, no sepsis, elective hernia

Given: `asa_class=2, emergency=false, functional_status=totally_dependent, sepsis=none, surgery=hernia`

1. L = -1.7397 + 1.4046 (totally_dependent) + -2.0008 (ASA 2) + -0.7840 (none) + -0.5739 (elective) + 0 = -3.6938
2. estimated_probability_percent from the Chest logistic table, two decimals from the unrounded logit


### Independent, ASA 2, no sepsis, elective aortic

Given: `asa_class=2, emergency=false, functional_status=independent, sepsis=none, surgery=aortic`

1. L = -1.7397 + 0 + -2.0008 (ASA 2) + -0.7840 (none) + -0.5739 (elective) + 1.0781 (aortic) = -4.0203
2. estimated_probability_percent from the Chest logistic table, two decimals from the unrounded logit


## Also searched as

- Gupta PRF
- postoperative respiratory failure
- Gupta 2011 Chest respiratory failure
- unplanned intubation after surgery
- mechanical ventilation after surgery
- NSQIP respiratory failure probability
- Gupta perioperative pulmonary risk
- postoperative reintubation probability

## Parameters

- `functional_status` (string, required): Gupta 2011 Chest functional status as assigned by the caller: independent (reference, 0), partially_dependent (+0.7678), or totally_dependent (+1.4046). magent does not examine the patient.
- `asa_class` (integer, required): ASA physical status 1-5 (Gupta 2011 Chest logistic table; class 5 is the reference). class 1 -3.5265, class 2 -2.0008, class 3 -0.6201, class 4 +0.2441, class 5 adds 0. Caller-assigned integer.
- `sepsis` (string, required): Gupta 2011 Chest preoperative sepsis category as assigned by the caller: none (-0.7840), sirs (reference, 0), sepsis (+0.2752), or septic_shock (+0.9035). magent does not diagnose sepsis.
- `emergency` (boolean, required): Gupta 2011 Chest emergency case as assigned by the caller: true (reference, 0) or false (elective, -0.5739).
- `surgery` (string, required): Gupta 2011 Chest 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_prf`
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": [
    {
      "asa_class": "2",
      "emergency": "false",
      "functional_status": "independent",
      "sepsis": "none",
      "surgery": "hernia"
    },
    {
      "asa_class": "2",
      "emergency": "false",
      "functional_status": "independent",
      "sepsis": "none",
      "surgery": "hernia"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/gupta_prf",
  "items": [
    {
      "emergency": 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": "Gupta H, Gupta PK, Fang X, Miller WJ, Cemaj S, Forse RA, Morrow LE",
        "doi": "10.1378/chest.11-0466",
        "id": "gupta-2011-prf",
        "pmid": "21757571",
        "source": "Chest. 2011;140(5):1207-1215",
        "title": "Development and validation of a risk calculator predicting postoperative respiratory failure"
      },
      "formula": "gupta_prf",
      "formula_expression": "L = -1.7397 + functional_status + asa_class + sepsis + emergency + surgery (Gupta 2011 Chest logistic table); independent 0, partially_dependent 0.7678, totally_dependent 1.4046; ASA1 -3.5265, ASA2 -2.0008, ASA3 -0.6201, ASA4 0.2441, ASA5 0; sepsis none -0.7840, sirs 0, sepsis 0.2752, septic_shock 0.9035; elective -0.5739, emergency 0; hernia 0, anorectal -1.3530, aortic 1.0781, bariatric -1.0112, brain 0.7336, breast -2.6462, cardiac 0.2744, ent 0.1060, foregut_hpb 0.9694, gbaas -0.5668, intestinal 0.5737, neck -0.5271, obstetric_gynecologic -1.2431, orthopedic -0.8577, other_abdomen 0.2416, peripheral_vascular -0.2389, skin -0.3206, spine -0.5220, thoracic 0.6715, vein -2.0080, urology 0.3093; estimated_probability_percent = 100 * exp(L) / (1 + exp(L))",
      "estimated_probability_percent": 0.61,
      "logit": -5.0984,
      "asa_class": 2,
      "surgery": "hernia",
      "functional_status": "independent",
      "sepsis": "none"
    },
    {
      "emergency": 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": "Gupta H, Gupta PK, Fang X, Miller WJ, Cemaj S, Forse RA, Morrow LE",
        "doi": "10.1378/chest.11-0466",
        "id": "gupta-2011-prf",
        "pmid": "21757571",
        "source": "Chest. 2011;140(5):1207-1215",
        "title": "Development and validation of a risk calculator predicting postoperative respiratory failure"
      },
      "formula": "gupta_prf",
      "formula_expression": "L = -1.7397 + functional_status + asa_class + sepsis + emergency + surgery (Gupta 2011 Chest logistic table); independent 0, partially_dependent 0.7678, totally_dependent 1.4046; ASA1 -3.5265, ASA2 -2.0008, ASA3 -0.6201, ASA4 0.2441, ASA5 0; sepsis none -0.7840, sirs 0, sepsis 0.2752, septic_shock 0.9035; elective -0.5739, emergency 0; hernia 0, anorectal -1.3530, aortic 1.0781, bariatric -1.0112, brain 0.7336, breast -2.6462, cardiac 0.2744, ent 0.1060, foregut_hpb 0.9694, gbaas -0.5668, intestinal 0.5737, neck -0.5271, obstetric_gynecologic -1.2431, orthopedic -0.8577, other_abdomen 0.2416, peripheral_vascular -0.2389, skin -0.3206, spine -0.5220, thoracic 0.6715, vein -2.0080, urology 0.3093; estimated_probability_percent = 100 * exp(L) / (1 + exp(L))",
      "estimated_probability_percent": 0.61,
      "logit": -5.0984,
      "asa_class": 2,
      "surgery": "hernia",
      "functional_status": "independent",
      "sepsis": "none"
    }
  ]
}
```

## Response fields

- `formula` (string): gupta_prf
- `formula_expression` (string): Gupta 2011 Chest logistic expression
- `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
- `emergency` (boolean): true if the case is an emergency
- `surgery` (string): Gupta 2011 Chest procedure category
- `logit` (number): Gupta 2011 Chest 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 a ventilator order.
- `citation` (object): Gupta et al. Chest 2011 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "emergency": 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": "Gupta H, Gupta PK, Fang X, Miller WJ, Cemaj S, Forse RA, Morrow LE",
    "doi": "10.1378/chest.11-0466",
    "id": "gupta-2011-prf",
    "pmid": "21757571",
    "source": "Chest. 2011;140(5):1207-1215",
    "title": "Development and validation of a risk calculator predicting postoperative respiratory failure"
  },
  "formula": "gupta_prf",
  "formula_expression": "L = -1.7397 + functional_status + asa_class + sepsis + emergency + surgery (Gupta 2011 Chest logistic table); independent 0, partially_dependent 0.7678, totally_dependent 1.4046; ASA1 -3.5265, ASA2 -2.0008, ASA3 -0.6201, ASA4 0.2441, ASA5 0; sepsis none -0.7840, sirs 0, sepsis 0.2752, septic_shock 0.9035; elective -0.5739, emergency 0; hernia 0, anorectal -1.3530, aortic 1.0781, bariatric -1.0112, brain 0.7336, breast -2.6462, cardiac 0.2744, ent 0.1060, foregut_hpb 0.9694, gbaas -0.5668, intestinal 0.5737, neck -0.5271, obstetric_gynecologic -1.2431, orthopedic -0.8577, other_abdomen 0.2416, peripheral_vascular -0.2389, skin -0.3206, spine -0.5220, thoracic 0.6715, vein -2.0080, urology 0.3093; estimated_probability_percent = 100 * exp(L) / (1 + exp(L))",
  "estimated_probability_percent": 0.61,
  "logit": -5.0984,
  "asa_class": 2,
  "surgery": "hernia",
  "functional_status": "independent",
  "sepsis": "none"
}
```

## Errors

- HTTP 400 `invalid_gupta_prf`: Gupta postoperative respiratory failure needs the published NSQIP predictors in range. 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 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.
- [ARISCAT](https://magentlab.com/docs/ariscat) — Sum Canet 2010 Table 6 simplified ARISCAT points (β×10 rounded) from age, preoperative SpO2, respiratory infection, anemia flag, incision, duration of surgery, and emergency, and return the published low / intermediate / high band.

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