# HEAR score

HEAR score

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

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

## What it computes

Compute the HEAR score as age points plus caller-assigned history, ECG, and risk factors (each 0-2). No troponin.

## When to use

When an agent needs the published Smith 2020 HEAR total (HEART without troponin) and must not invent history, ECG, or risk-factor points from a tracing.

## When not to use

- Not a medical device. Not a diagnosis or discharge protocol.
- history, ecg, and risk_factors are caller-assigned integers 0-2. magent does not interpret the history, count risk factors, or read an ECG.
- This is HEAR without troponin (Smith 2020), not the HEART score (Six 2008) and not HEART Pathway. Scores 0 and 1 are the very-low-risk group in that paper (MACE ~0.9%). Do not apply HEART bands 0-3 / 4-6 / 7-10.

## Formula

```
HEAR = history + ECG + age_points + risk_factors; each 0-2; age <45 0, 45-64 1, >=65 2; very_low_risk iff score 0 or 1 (Smith 2020); max 8
```

## Citation

[Identification of very low-risk acute chest pain patients without troponin testing](https://doi.org/10.1136/emermed-2020-209698)
Smith LM, Ashburn NP, Snavely AC, Mahler SA
Emerg Med J. 2020;37(11):690-695
DOI: [10.1136/emermed-2020-209698](https://doi.org/10.1136/emermed-2020-209698)

## Worked example

### Age 40, all components 0

Given: `age=40, ecg=0, history=0, risk_factors=0`

1. Age 40 (<45) → 0; history 0; ECG 0; risk_factors 0
2. Score = 0; max 8; very_low_risk true (Smith 2020 scores 0 and 1)


## Also searched as

- HEAR score
- History ECG Age Risk
- HEAR chest pain score
- Smith 2020 HEAR
- HEAR without troponin
- very low-risk chest pain HEAR
- HEAR score no troponin

## Parameters

- `age` (integer, required): Age in years (18-120). Younger than 45 scores 0; 45-64 scores 1; 65 or older scores 2 (same cuts as Six 2008 HEART).
- `history` (integer, required): Caller-assigned history. 0 nonspecific, 1 moderately suspicious, 2 highly suspicious. magent does not interpret the history.
- `ecg` (integer, required): Caller-assigned ECG. 0 normal; 1 repolarization without significant ST depression (including BBB, LVH, digoxin, or known unchanged); 2 significant ST depression or elevation without those confounders. magent does not read an ECG.
- `risk_factors` (integer, required): Caller-assigned risk-factor points. 0 none, 1 = 1-2 risk factors, 2 = ≥3 or atherosclerotic disease. magent does not count diabetes, smoking, or other factors.

## 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/hear`
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",
      "ecg": "0",
      "history": "0",
      "risk_factors": "0"
    },
    {
      "age": "40",
      "ecg": "0",
      "history": "0",
      "risk_factors": "0"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/hear",
  "items": [
    {
      "components": [
        {
          "value": 0,
          "factor": "history",
          "points": 0,
          "present": false
        },
        {
          "value": 0,
          "factor": "ecg",
          "points": 0,
          "present": false
        },
        {
          "value": 40,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "value": 0,
          "factor": "risk_factors",
          "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": "Smith LM, Ashburn NP, Snavely AC, Mahler SA",
        "doi": "10.1136/emermed-2020-209698",
        "id": "smith-2020",
        "pmid": "32753395",
        "source": "Emerg Med J. 2020;37(11):690-695",
        "title": "Identification of very low-risk acute chest pain patients without troponin testing"
      },
      "formula": "hear",
      "formula_expression": "HEAR = history + ECG + age_points + risk_factors; each 0-2; age <45 0, 45-64 1, >=65 2; very_low_risk iff score 0 or 1 (Smith 2020); max 8",
      "age_years": 40,
      "max_score": 8,
      "score": 0,
      "very_low_risk": true
    },
    {
      "components": [
        {
          "value": 0,
          "factor": "history",
          "points": 0,
          "present": false
        },
        {
          "value": 0,
          "factor": "ecg",
          "points": 0,
          "present": false
        },
        {
          "value": 40,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "value": 0,
          "factor": "risk_factors",
          "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": "Smith LM, Ashburn NP, Snavely AC, Mahler SA",
        "doi": "10.1136/emermed-2020-209698",
        "id": "smith-2020",
        "pmid": "32753395",
        "source": "Emerg Med J. 2020;37(11):690-695",
        "title": "Identification of very low-risk acute chest pain patients without troponin testing"
      },
      "formula": "hear",
      "formula_expression": "HEAR = history + ECG + age_points + risk_factors; each 0-2; age <45 0, 45-64 1, >=65 2; very_low_risk iff score 0 or 1 (Smith 2020); max 8",
      "age_years": 40,
      "max_score": 8,
      "score": 0,
      "very_low_risk": true
    }
  ]
}
```

## Response fields

- `formula` (string): hear
- `formula_expression` (string): Exact expression used
- `score` (integer): Total points 0-8
- `max_score` (integer): Always 8
- `very_low_risk` (boolean): true when score is 0 or 1 (Smith 2020 very-low-risk group; MACE ~0.9% in that paper). false when score is 2-8. Not HEART bands 0-3 / 4-6 / 7-10.
- `age_years` (integer): Age used for the <45 / 45-64 / ≥65 bands
- `components` (array): Per-factor 0-2 points
- `citation` (object): Smith 2020 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 0,
      "factor": "history",
      "points": 0,
      "present": false
    },
    {
      "value": 0,
      "factor": "ecg",
      "points": 0,
      "present": false
    },
    {
      "value": 40,
      "factor": "age",
      "points": 0,
      "present": false
    },
    {
      "value": 0,
      "factor": "risk_factors",
      "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": "Smith LM, Ashburn NP, Snavely AC, Mahler SA",
    "doi": "10.1136/emermed-2020-209698",
    "id": "smith-2020",
    "pmid": "32753395",
    "source": "Emerg Med J. 2020;37(11):690-695",
    "title": "Identification of very low-risk acute chest pain patients without troponin testing"
  },
  "formula": "hear",
  "formula_expression": "HEAR = history + ECG + age_points + risk_factors; each 0-2; age <45 0, 45-64 1, >=65 2; very_low_risk iff score 0 or 1 (Smith 2020); max 8",
  "age_years": 40,
  "max_score": 8,
  "score": 0,
  "very_low_risk": true
}
```

## Errors

- HTTP 400 `invalid_age`: age must be an integer from 18 to 120 Returned before settlement; you are not charged.
- HTTP 400 `invalid_hear`: HEAR inputs must match Smith 2020 history, ECG, age, and risk-factor components from that paper. 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

- [HEART score](https://magentlab.com/docs/heart) — Compute the HEART score as age points plus caller-assigned history, ECG, risk factors, and troponin (each 0-2).
- [HEART Pathway](https://magentlab.com/docs/heart-pathway) — Apply the Mahler 2015 HEART Pathway and return whether a caller-assigned HEART score plus 0-hour and 3-hour troponin flags meet the published early-discharge rule.
- [TIMI risk score for STEMI](https://magentlab.com/docs/timi-stemi) — Compute the TIMI risk score for ST-elevation myocardial infarction from published bedside factors at presentation.

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