# EHMRG 7-day ED mortality score

EHMRG

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

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

## What it computes

Compute the Lee 2012 Emergency Heart Failure Mortality Risk Grade 7-day emergency-department integer score from age, EMS transport, initial systolic BP, heart rate, oxygen saturation, creatinine, potassium, troponin above ULN, active cancer, and home metolazone.

## When to use

When an agent has caller-supplied ED presentation values and needs the published Lee 2012 Table 3 7-day ED model total and derivation risk_group 1/2/3/4/5a/5b, not EHMRG30-ST, not ADHERE CART, and not a discharge or admission order.

## When not to use

- Not a medical device. magent does not examine the patient and does not measure vitals or laboratories.
- Not a discharge or admission order. This is the Lee 2012 7-day ED integer score only.
- This is not EHMRG30-ST and not ADHERE CART.
- Dialysis-dependent patients are excluded (Lee 2012 Methods and Table 3 footnote). dialysis_dependent must be false to score.
- Unpublished potassium gaps 3.91-3.99 mmol/L pin with the <=3.9 band (+5). Gaps 4.51-4.59 mmol/L pin with the >=4.6 band (+30). magent does not invent extra named potassium classes.
- The caller assigns EMS transport, troponin above ULN, active cancer, home metolazone, and dialysis status. magent does not interpret assays or medication lists.

## Formula

```
ehmrg_score = 2*age_years + 60*(ems_transport) - min(systolic_mm_hg, 160) + clamp(heart_rate_bpm, 80, 120) - 2*min(spo2_percent, 92) + 20*creatinine_mg_dl + K(<=3.9:5, 4.0-4.5:0, >=4.6:30) + 60*(troponin_gt_uln) + 45*(active_cancer) + 60*(metolazone) + 12; Lee 2012 Table 3 7-day ED model; dialysis-dependent excluded; risk_group 1 (score <= -49.1), 2 (-49.0 to -15.9), 3 (-15.8 to 17.9), 4 (18.0 to 56.5), 5a (56.6 to 89.3), 5b (>= 89.4)
```

## Citation

[Prediction of heart failure mortality in emergent care: a cohort study](https://doi.org/10.7326/0003-4819-156-11-201206050-00003)
Lee DS, Stitt A, Austin PC, Stukel TA, Schull MJ, Chong A, Newton GE, Lee JS, Tu JV
Ann Intern Med. 2012;156(11):767-775
DOI: [10.7326/0003-4819-156-11-201206050-00003](https://doi.org/10.7326/0003-4819-156-11-201206050-00003)

## Worked example

### Age 70, no EMS, SBP 160, HR 80, SpO2 92, creatinine 1.0 (group 1)

Given: `active_cancer=false, age=70, creatinine_mg_dl=1.0, dialysis_dependent=false, ems_transport=false, heart_rate_bpm=80, metolazone=false, potassium_mmol_l=4.2, spo2_percent=92, systolic_mm_hg=160, troponin_gt_uln=false`

1. Age 70 → +140; EMS false → 0; SBP 160 (at cap) → -160; HR 80 (at floor) → +80
2. SpO2 92 (at cap) → -184; creatinine 1.0 → +20; potassium 4.2 → 0
3. Troponin, cancer, and metolazone false → 0; adjustment +12
4. ehmrg_score = 140 - 160 + 80 - 184 + 20 + 12 = -92; risk_group 1


### Age 85, EMS, SBP 120, HR 110, SpO2 90, creatinine 1.8, troponin above ULN (group 5b)

Given: `active_cancer=false, age=85, creatinine_mg_dl=1.8, dialysis_dependent=false, ems_transport=true, heart_rate_bpm=110, metolazone=false, potassium_mmol_l=4.2, spo2_percent=90, systolic_mm_hg=120, troponin_gt_uln=true`

1. Age 85 → +170; EMS true → +60; SBP 120 → -120; HR 110 → +110; SpO2 90 → -180
2. Creatinine 1.8 → +36; potassium 4.2 → 0; troponin above ULN → +60; adjustment +12
3. ehmrg_score = 170 + 60 - 120 + 110 - 180 + 36 + 60 + 12 = 148; risk_group 5b


## Also searched as

- EHMRG
- Emergency Heart Failure Mortality Risk Grade
- Lee 2012 EHMRG
- 7-day ED heart failure mortality
- EHMRG integer score
- heart failure emergency department score

## Parameters

- `age` (integer, required): Age in years (integer 18-120). Lee 2012 Table 3 adds +2 per year. magent does not assign age.
- `ems_transport` (boolean, required): Transported by EMS as assigned by the caller (true or false). Lee 2012 Table 3: +60 if true.
- `systolic_mm_hg` (integer, required): Initial/triage systolic blood pressure in mm Hg (integer 50-250). Lee 2012 Table 3 scores -1 * min(SBP, 160); values above 160 mm Hg are capped. magent does not measure blood pressure.
- `heart_rate_bpm` (integer, required): Heart rate in beats/min (integer 30-220). Lee 2012 Table 3 scores +1 * clamp(HR, 80, 120): floor 80, ceiling 120. magent does not measure heart rate.
- `spo2_percent` (number, required): Lowest initial/triage oxygen saturation percent (50-100). Lee 2012 Table 3 scores -2 * min(SpO2, 92); values above 92% are capped. magent does not measure saturation.
- `creatinine_mg_dl` (number, optional): Serum creatinine in mg/dL (0.1-20). Provide this or creatinine_umol_l, not both. Lee 2012 Table 3 adds +20 per mg/dL. magent does not measure creatinine.
- `creatinine_umol_l` (number, optional): Serum creatinine in µmol/L (9-1768). Converted as mg/dL = µmol/L / 88.42. Provide this or creatinine_mg_dl, not both.
- `potassium_mmol_l` (number, required): Serum potassium in mmol/L (1.5-8.0). Lee 2012 Table 3: 4.0-4.5 inclusive → 0; >=4.6 → +30; <=3.9 → +5. Unpublished 3.91-3.99 pin with <=3.9; 4.51-4.59 pin with >=4.6. magent does not measure potassium.
- `troponin_gt_uln` (boolean, required): Troponin above the local upper limit of normal as assigned by the caller (true or false). Lee 2012 Table 3: +60 if true.
- `active_cancer` (boolean, required): Active cancer as assigned by the caller (true or false). Lee 2012 Table 3: +45 if true.
- `metolazone` (boolean, required): Metolazone at home as assigned by the caller (true or false). Lee 2012 Table 3: +60 if true.
- `dialysis_dependent` (boolean, required): Dialysis dependence as assigned by the caller (true or false). Lee 2012 excludes dialysis-dependent patients; true returns HTTP 400. magent does not determine dialysis status.

## 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/ehmrg`
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": [
    {
      "active_cancer": "false",
      "age": "70",
      "creatinine_mg_dl": "1.0",
      "dialysis_dependent": "false",
      "ems_transport": "false",
      "heart_rate_bpm": "80",
      "metolazone": "false",
      "potassium_mmol_l": "4.2",
      "spo2_percent": "92",
      "systolic_mm_hg": "160",
      "troponin_gt_uln": "false"
    },
    {
      "active_cancer": "false",
      "age": "70",
      "creatinine_mg_dl": "1.0",
      "dialysis_dependent": "false",
      "ems_transport": "false",
      "heart_rate_bpm": "80",
      "metolazone": "false",
      "potassium_mmol_l": "4.2",
      "spo2_percent": "92",
      "systolic_mm_hg": "160",
      "troponin_gt_uln": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/ehmrg",
  "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": "Lee DS, Stitt A, Austin PC, Stukel TA, Schull MJ, Chong A, Newton GE, Lee JS, Tu JV",
        "doi": "10.7326/0003-4819-156-11-201206050-00003",
        "id": "lee-2012",
        "pmid": "22665814",
        "source": "Ann Intern Med. 2012;156(11):767-775",
        "title": "Prediction of heart failure mortality in emergent care: a cohort study"
      },
      "formula": "ehmrg",
      "formula_expression": "ehmrg_score = 2*age_years + 60*(ems_transport) - min(systolic_mm_hg, 160) + clamp(heart_rate_bpm, 80, 120) - 2*min(spo2_percent, 92) + 20*creatinine_mg_dl + K(<=3.9:5, 4.0-4.5:0, >=4.6:30) + 60*(troponin_gt_uln) + 45*(active_cancer) + 60*(metolazone) + 12; Lee 2012 Table 3 7-day ED model; dialysis-dependent excluded; risk_group 1 (score <= -49.1), 2 (-49.0 to -15.9), 3 (-15.8 to 17.9), 4 (18.0 to 56.5), 5a (56.6 to 89.3), 5b (>= 89.4)",
      "age_years": 70,
      "systolic_mm_hg": 160,
      "creatinine_mg_dl": 1.0,
      "heart_rate_bpm": 80,
      "potassium_mmol_l": 4.2,
      "active_cancer": false,
      "dialysis_dependent": false,
      "ehmrg_score": -92.0,
      "ems_transport": false,
      "metolazone": false,
      "risk_group": "1",
      "spo2_percent": 92.0,
      "troponin_gt_uln": 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": "Lee DS, Stitt A, Austin PC, Stukel TA, Schull MJ, Chong A, Newton GE, Lee JS, Tu JV",
        "doi": "10.7326/0003-4819-156-11-201206050-00003",
        "id": "lee-2012",
        "pmid": "22665814",
        "source": "Ann Intern Med. 2012;156(11):767-775",
        "title": "Prediction of heart failure mortality in emergent care: a cohort study"
      },
      "formula": "ehmrg",
      "formula_expression": "ehmrg_score = 2*age_years + 60*(ems_transport) - min(systolic_mm_hg, 160) + clamp(heart_rate_bpm, 80, 120) - 2*min(spo2_percent, 92) + 20*creatinine_mg_dl + K(<=3.9:5, 4.0-4.5:0, >=4.6:30) + 60*(troponin_gt_uln) + 45*(active_cancer) + 60*(metolazone) + 12; Lee 2012 Table 3 7-day ED model; dialysis-dependent excluded; risk_group 1 (score <= -49.1), 2 (-49.0 to -15.9), 3 (-15.8 to 17.9), 4 (18.0 to 56.5), 5a (56.6 to 89.3), 5b (>= 89.4)",
      "age_years": 70,
      "systolic_mm_hg": 160,
      "creatinine_mg_dl": 1.0,
      "heart_rate_bpm": 80,
      "potassium_mmol_l": 4.2,
      "active_cancer": false,
      "dialysis_dependent": false,
      "ehmrg_score": -92.0,
      "ems_transport": false,
      "metolazone": false,
      "risk_group": "1",
      "spo2_percent": 92.0,
      "troponin_gt_uln": false
    }
  ]
}
```

## Response fields

- `formula` (string): ehmrg
- `formula_expression` (string): Exact expression used
- `ehmrg_score` (number): Lee 2012 Table 3 7-day ED integer-score sum. Exact arithmetic; may be a float when creatinine is a float.
- `risk_group` (string): Lee 2012 derivation cutpoints: 1 if score <= -49.1; 2 if -49.0 to -15.9; 3 if -15.8 to 17.9; 4 if 18.0 to 56.5; 5a if 56.6 to 89.3; 5b if >= 89.4
- `age_years` (integer): Age used, years
- `ems_transport` (boolean): EMS transport flag used
- `systolic_mm_hg` (integer): Initial/triage systolic BP used, mm Hg (capped at 160 for scoring)
- `heart_rate_bpm` (integer): Heart rate used, bpm (scored after clamp 80-120)
- `spo2_percent` (number): Oxygen saturation used, percent (capped at 92 for scoring)
- `creatinine_mg_dl` (number): Serum creatinine used in mg/dL (after µmol/L conversion when supplied)
- `potassium_mmol_l` (number): Serum potassium used, mmol/L
- `troponin_gt_uln` (boolean): Troponin above ULN flag used
- `active_cancer` (boolean): Active cancer flag used
- `metolazone` (boolean): Home metolazone flag used
- `dialysis_dependent` (boolean): Always false on HTTP 200; true is excluded
- `citation` (object): Lee 2012 Annals 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": "Lee DS, Stitt A, Austin PC, Stukel TA, Schull MJ, Chong A, Newton GE, Lee JS, Tu JV",
    "doi": "10.7326/0003-4819-156-11-201206050-00003",
    "id": "lee-2012",
    "pmid": "22665814",
    "source": "Ann Intern Med. 2012;156(11):767-775",
    "title": "Prediction of heart failure mortality in emergent care: a cohort study"
  },
  "formula": "ehmrg",
  "formula_expression": "ehmrg_score = 2*age_years + 60*(ems_transport) - min(systolic_mm_hg, 160) + clamp(heart_rate_bpm, 80, 120) - 2*min(spo2_percent, 92) + 20*creatinine_mg_dl + K(<=3.9:5, 4.0-4.5:0, >=4.6:30) + 60*(troponin_gt_uln) + 45*(active_cancer) + 60*(metolazone) + 12; Lee 2012 Table 3 7-day ED model; dialysis-dependent excluded; risk_group 1 (score <= -49.1), 2 (-49.0 to -15.9), 3 (-15.8 to 17.9), 4 (18.0 to 56.5), 5a (56.6 to 89.3), 5b (>= 89.4)",
  "age_years": 70,
  "systolic_mm_hg": 160,
  "creatinine_mg_dl": 1.0,
  "heart_rate_bpm": 80,
  "potassium_mmol_l": 4.2,
  "active_cancer": false,
  "dialysis_dependent": false,
  "ehmrg_score": -92.0,
  "ems_transport": false,
  "metolazone": false,
  "risk_group": "1",
  "spo2_percent": 92.0,
  "troponin_gt_uln": false
}
```

## Errors

- 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_systolic_bp`: systolic_mm_hg or systolic_bp_mm_hg must be a number from 50 to 250. Returned before settlement; you are not charged.
- HTTP 400 `invalid_heart_rate`: heart_rate_bpm must be an integer from 30 to 220 Returned before settlement; you are not charged.
- HTTP 400 `invalid_spo2`: spo2_percent must be a number from 50 to 100. Returned before settlement; you are not charged.
- HTTP 400 `invalid_creatinine`: creatinine_mg_dl (0.1-20) or creatinine_umol_l (9-1768) is required Returned before settlement; you are not charged.
- HTTP 400 `invalid_potassium`: potassium_mmol_l must be a number from 1.5 to 8.0. Returned before settlement; you are not charged.
- HTTP 400 `invalid_ehmrg_dialysis`: EHMRG is not for dialysis-dependent patients (Lee 2012). dialysis_dependent must be false to score. 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

- [LACE](https://magentlab.com/docs/lace) — Sum van Walraven 2010 Table 3 LACE points from length of stay, acute (emergent) admission, a caller-supplied Charlson integer, and ED visits in the previous 6 months.
- [ADHERE](https://magentlab.com/docs/adhere) — Apply the Fonarow 2005 ADHERE classification and regression tree for in-hospital mortality risk in acutely decompensated heart failure from admission BUN, systolic blood pressure, and serum creatinine.

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