# RAPID score for pleural infection

RAPID

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

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

## What it computes

Sum the Rahman 2014 RAPID points for pleural infection at presentation and return the published low, medium, or high band.

## When to use

When an agent needs the published RAPID total for pleural infection and must not invent a drain, surgery, or fibrinolytic decision.

## When not to use

- Not a medical device. magent does not assay urea or albumin or inspect pleural fluid.
- Not a drain, surgery, or fibrinolytic decision. RAPID is a presentation risk score for pleural infection (Rahman 2014), not Light's criteria.

## Formula

```
RAPID = urea_points + age_points + nonpurulent_points + hospital_acquired_points + albumin_points; urea <5 = 0, 5.0-8.0 = 1, >8 = 2; age <50 = 0, 50-70 = 1, >70 = 2; purulent = 0, non-purulent = 1; community = 0, hospital = 1; albumin >=27 g/L = 0, <27 = 1; max 7
```

## Citation

[A clinical score (RAPID) to identify those at risk for poor outcome at presentation in patients with pleural infection](https://doi.org/10.1378/chest.13-1558)
Rahman NM, Kahan BC, Pendleton RC, et al.
Chest. 2014;145(4):848-855
DOI: [10.1378/chest.13-1558](https://doi.org/10.1378/chest.13-1558)

## Worked example

### Urea 4 mmol/L, age 40, purulent community, albumin 35 g/L

Given: `age=40, albumin_g_l=35, hospital_acquired=false, pleural_purulent=true, urea_mmol_l=4`

1. urea <5 → 0; age <50 → 0; purulent → 0; community → 0; albumin ≥27 → 0
2. score = 0
3. risk_band low


### Urea 9 mmol/L, age 71, non-purulent hospital, albumin 20 g/L

Given: `age=71, albumin_g_l=20, hospital_acquired=true, pleural_purulent=false, urea_mmol_l=9`

1. urea >8 → 2; age >70 → 2; non-purulent → 1; hospital → 1; albumin <27 → 1
2. score = 7
3. risk_band high


## Also searched as

- RAPID score
- RAPID pleural infection
- Rahman RAPID
- pleural infection score
- RAPID urea albumin
- pleural RAPID

## Parameters

- `urea_mmol_l` (number, optional): Serum urea in mmol/L (1-50). Provide this or bun_mg_dl, not both. <5 scores 0; 5.0-8.0 inclusive scores 1; >8 scores 2 (Rahman 2014).
- `bun_mg_dl` (number, optional): BUN in mg/dL (3-140). Converted as urea_mmol_l = bun_mg_dl / 2.8.
- `age` (integer, required): Age in years (18-120). <50 scores 0; 50-70 inclusive scores 1; >70 scores 2.
- `pleural_purulent` (boolean, required): Purulent pleural fluid (Rahman 2014). true scores 0; false (non-purulent) scores 1. magent does not inspect the fluid.
- `hospital_acquired` (boolean, required): Hospital-acquired pleural infection (Rahman 2014). true scores 1; false (community) scores 0.
- `albumin_g_l` (number, optional): Serum albumin in g/L (10-60). Provide this or albumin_g_dl, not both. ≥27 scores 0; <27 scores 1.
- `albumin_g_dl` (number, optional): Serum albumin in g/dL (1-6). Converted as g/L = g/dL × 10. Provide this or albumin_g_l, 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.

Method: `POST /api/calc/rapid`
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",
      "albumin_g_l": "35",
      "hospital_acquired": "false",
      "pleural_purulent": "true",
      "urea_mmol_l": "4"
    },
    {
      "age": "40",
      "albumin_g_l": "35",
      "hospital_acquired": "false",
      "pleural_purulent": "true",
      "urea_mmol_l": "4"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/rapid",
  "items": [
    {
      "components": [
        {
          "value": 4.0,
          "factor": "urea",
          "points": 0,
          "present": false
        },
        {
          "value": 40,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "factor": "nonpurulent",
          "points": 0,
          "present": false
        },
        {
          "factor": "hospital_acquired",
          "points": 0,
          "present": false
        },
        {
          "value": 35.0,
          "factor": "albumin",
          "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": "Rahman NM, Kahan BC, Pendleton RC, et al.",
        "doi": "10.1378/chest.13-1558",
        "id": "rahman-2014",
        "pmid": "24264558",
        "source": "Chest. 2014;145(4):848-855",
        "title": "A clinical score (RAPID) to identify those at risk for poor outcome at presentation in patients with pleural infection"
      },
      "formula": "rapid",
      "formula_expression": "RAPID = urea_points + age_points + nonpurulent_points + hospital_acquired_points + albumin_points; urea <5 = 0, 5.0-8.0 = 1, >8 = 2; age <50 = 0, 50-70 = 1, >70 = 2; purulent = 0, non-purulent = 1; community = 0, hospital = 1; albumin >=27 g/L = 0, <27 = 1; max 7",
      "age_years": 40,
      "max_score": 7,
      "risk_band": "low",
      "score": 0,
      "albumin_g_l": 35.0,
      "urea_mmol_l": 4.0,
      "hospital_acquired": false,
      "pleural_purulent": true
    },
    {
      "components": [
        {
          "value": 4.0,
          "factor": "urea",
          "points": 0,
          "present": false
        },
        {
          "value": 40,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "factor": "nonpurulent",
          "points": 0,
          "present": false
        },
        {
          "factor": "hospital_acquired",
          "points": 0,
          "present": false
        },
        {
          "value": 35.0,
          "factor": "albumin",
          "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": "Rahman NM, Kahan BC, Pendleton RC, et al.",
        "doi": "10.1378/chest.13-1558",
        "id": "rahman-2014",
        "pmid": "24264558",
        "source": "Chest. 2014;145(4):848-855",
        "title": "A clinical score (RAPID) to identify those at risk for poor outcome at presentation in patients with pleural infection"
      },
      "formula": "rapid",
      "formula_expression": "RAPID = urea_points + age_points + nonpurulent_points + hospital_acquired_points + albumin_points; urea <5 = 0, 5.0-8.0 = 1, >8 = 2; age <50 = 0, 50-70 = 1, >70 = 2; purulent = 0, non-purulent = 1; community = 0, hospital = 1; albumin >=27 g/L = 0, <27 = 1; max 7",
      "age_years": 40,
      "max_score": 7,
      "risk_band": "low",
      "score": 0,
      "albumin_g_l": 35.0,
      "urea_mmol_l": 4.0,
      "hospital_acquired": false,
      "pleural_purulent": true
    }
  ]
}
```

## Response fields

- `formula` (string): rapid
- `formula_expression` (string): Exact expression used
- `score` (integer): RAPID points 0-7
- `max_score` (integer): 7
- `risk_band` (string): Rahman 2014 band: low (0-2), medium (3-4), or high (5-7). A band, not a drain or surgery decision.
- `urea_mmol_l` (number): Urea in mmol/L used
- `age_years` (integer): Age used
- `pleural_purulent` (boolean): Purulent pleural fluid flag used
- `hospital_acquired` (boolean): Hospital-acquired infection flag used
- `albumin_g_l` (number): Serum albumin used in g/L (after g/dL conversion when supplied)
- `components` (array): Per-variable points
- `citation` (object): Rahman et al. Chest 2014 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 4.0,
      "factor": "urea",
      "points": 0,
      "present": false
    },
    {
      "value": 40,
      "factor": "age",
      "points": 0,
      "present": false
    },
    {
      "factor": "nonpurulent",
      "points": 0,
      "present": false
    },
    {
      "factor": "hospital_acquired",
      "points": 0,
      "present": false
    },
    {
      "value": 35.0,
      "factor": "albumin",
      "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": "Rahman NM, Kahan BC, Pendleton RC, et al.",
    "doi": "10.1378/chest.13-1558",
    "id": "rahman-2014",
    "pmid": "24264558",
    "source": "Chest. 2014;145(4):848-855",
    "title": "A clinical score (RAPID) to identify those at risk for poor outcome at presentation in patients with pleural infection"
  },
  "formula": "rapid",
  "formula_expression": "RAPID = urea_points + age_points + nonpurulent_points + hospital_acquired_points + albumin_points; urea <5 = 0, 5.0-8.0 = 1, >8 = 2; age <50 = 0, 50-70 = 1, >70 = 2; purulent = 0, non-purulent = 1; community = 0, hospital = 1; albumin >=27 g/L = 0, <27 = 1; max 7",
  "age_years": 40,
  "max_score": 7,
  "risk_band": "low",
  "score": 0,
  "albumin_g_l": 35.0,
  "urea_mmol_l": 4.0,
  "hospital_acquired": false,
  "pleural_purulent": true
}
```

## Errors

- HTTP 400 `invalid_urea`: urea_mmol_l (1-50) or bun_mg_dl (3-140) is required, not both. 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_albumin`: albumin_g_dl (1-6) or albumin_g_l (10-60) is required 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

- [Light's criteria](https://magentlab.com/docs/lights) — Apply Light 1972 pleural fluid criteria from protein ratio, LDH ratio, and pleural LDH versus two-thirds the laboratory LDH upper limit of normal.

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