# Shanghai Score System (Antzelevitch 2016)

Shanghai Score System

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

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

## What it computes

Sum Antzelevitch 2016 Table 2 Shanghai Score System points from a caller-assigned ECG finding plus optional clinical, family, and pathogenic-mutation items, and return probable_definite, possible, or nondiagnostic.

## When to use

When an agent already has the Table 2 ECG pattern (and optional clinical, family, and genetic tokens) as assigned by the caller and needs the published Shanghai BrS point total. magent does not read tracings. Not a diagnosis or ICD indication. Not the ERS Table 5 score.

## When not to use

- Not a medical device and not a diagnosis or ICD indication.
- magent does not read tracings. The caller assigns the ECG pattern, clinical item, family item, and pathogenic-mutation flag.
- Table 2 awards points once per category (highest item only) and requires at least one ECG finding. The ECG floor is 2, so nondiagnostic (<2) is published but not reachable from a valid ECG token.
- This is the Antzelevitch 2016 Shanghai Score System for Brugada syndrome (Table 2) only. Not the ERS Table 5 Shanghai score, not Morita 2018, and not the Brugada 1991 wide-QRS algorithm.

## Formula

```
Shanghai Table 2 (Antzelevitch 2016): ECG required, highest only (spontaneous_type1 3.5, fever_type1 3, drug_converted_type2_3 2) + clinical highest only (vf_arrest 3, nocturnal_agonal 2, arrhythmic_syncope 2, unclear_syncope 1, af_under_30 0.5, none 0) + family highest only (relative_definite_brs 2, suspicious_scd 1, unexplained_scd_under_45 0.5, none 0) + pathogenic_mutation 0.5; max 9; probable_definite ≥3.5, possible 2–3, nondiagnostic <2. Not ERS Table 5
```

## Citation

[J-Wave syndromes expert consensus conference report: Emerging concepts and gaps in knowledge](https://doi.org/10.1016/j.hrthm.2016.05.024)
Antzelevitch C, Yan GX, Ackerman MJ, Borggrefe M, Corrado D, Guo J, et al.
Heart Rhythm. 2016;13(10):e295-e324
DOI: [10.1016/j.hrthm.2016.05.024](https://doi.org/10.1016/j.hrthm.2016.05.024)

## Worked example

### Spontaneous type 1 ECG only

Given: `clinical=none, ecg_pattern=spontaneous_type1, family=none, pathogenic_mutation=false`

1. ECG spontaneous_type1 = 3.5 (highest ECG item)
2. clinical none 0, family none 0, pathogenic_mutation false 0
3. score = 3.5; shanghai_band probable_definite


### Drug-converted type 2 or 3 ECG only

Given: `clinical=none, ecg_pattern=drug_converted_type2_3, family=none, pathogenic_mutation=false`

1. ECG drug_converted_type2_3 = 2
2. clinical none 0, family none 0, pathogenic_mutation false 0
3. score = 2; shanghai_band possible


## Also searched as

- Shanghai Score System
- Antzelevitch 2016 Shanghai
- Brugada Shanghai score
- Shanghai BrS diagnostic score
- Proposed Shanghai Score System
- J-wave Shanghai Brugada
- type 1 Brugada ECG Shanghai
- HRS EHRA APHRS Shanghai BrS
- not ERS Shanghai score
- fever type 1 Brugada score

## Parameters

- `ecg_pattern` (string, required): Highest Table 2 ECG finding as assigned by the caller (Antzelevitch 2016). spontaneous_type1 scores 3.5; fever_type1 scores 3; drug_converted_type2_3 scores 2. At least one ECG finding is required. Award once (highest item only). magent does not read tracings.
- `clinical` (string, optional): Highest Table 2 clinical-history item as assigned by the caller (Antzelevitch 2016). vf_arrest 3; nocturnal_agonal 2; arrhythmic_syncope 2; unclear_syncope 1; af_under_30 0.5; none 0. Optional; omitted defaults to none. Award once (highest item only). magent does not take a history.
- `family` (string, optional): Highest Table 2 family-history item as assigned by the caller (Antzelevitch 2016). relative_definite_brs 2; suspicious_scd 1; unexplained_scd_under_45 0.5; none 0. Optional; omitted defaults to none. Award once (highest item only). magent does not take a pedigree.
- `pathogenic_mutation` (boolean, required): Probable pathogenic mutation in a BrS susceptibility gene (Antzelevitch 2016 Table 2 IV). true scores 0.5; false scores 0. magent does not interpret sequencing.

## 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/shanghai`
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": [
    {
      "clinical": "none",
      "ecg_pattern": "spontaneous_type1",
      "family": "none",
      "pathogenic_mutation": "false"
    },
    {
      "clinical": "none",
      "ecg_pattern": "spontaneous_type1",
      "family": "none",
      "pathogenic_mutation": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/shanghai",
  "items": [
    {
      "family": "none",
      "components": [
        {
          "value": "spontaneous_type1",
          "factor": "ecg_pattern",
          "points": 3.5,
          "present": true
        },
        {
          "value": "none",
          "factor": "clinical",
          "points": 0,
          "present": false
        },
        {
          "value": "none",
          "factor": "family",
          "points": 0,
          "present": false
        },
        {
          "value": false,
          "factor": "pathogenic_mutation",
          "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": "Antzelevitch C, Yan GX, Ackerman MJ, Borggrefe M, Corrado D, Guo J, et al.",
        "doi": "10.1016/j.hrthm.2016.05.024",
        "id": "antzelevitch-2016",
        "pmid": "27423412",
        "source": "Heart Rhythm. 2016;13(10):e295-e324",
        "title": "J-Wave syndromes expert consensus conference report: Emerging concepts and gaps in knowledge"
      },
      "formula": "shanghai",
      "formula_expression": "Shanghai Table 2 (Antzelevitch 2016): ECG required, highest only (spontaneous_type1 3.5, fever_type1 3, drug_converted_type2_3 2) + clinical highest only (vf_arrest 3, nocturnal_agonal 2, arrhythmic_syncope 2, unclear_syncope 1, af_under_30 0.5, none 0) + family highest only (relative_definite_brs 2, suspicious_scd 1, unexplained_scd_under_45 0.5, none 0) + pathogenic_mutation 0.5; max 9; probable_definite ≥3.5, possible 2–3, nondiagnostic <2. Not ERS Table 5",
      "max_score": 9,
      "score": 3.5,
      "clinical": "none",
      "ecg_pattern": "spontaneous_type1",
      "pathogenic_mutation": false,
      "shanghai_band": "probable_definite"
    },
    {
      "family": "none",
      "components": [
        {
          "value": "spontaneous_type1",
          "factor": "ecg_pattern",
          "points": 3.5,
          "present": true
        },
        {
          "value": "none",
          "factor": "clinical",
          "points": 0,
          "present": false
        },
        {
          "value": "none",
          "factor": "family",
          "points": 0,
          "present": false
        },
        {
          "value": false,
          "factor": "pathogenic_mutation",
          "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": "Antzelevitch C, Yan GX, Ackerman MJ, Borggrefe M, Corrado D, Guo J, et al.",
        "doi": "10.1016/j.hrthm.2016.05.024",
        "id": "antzelevitch-2016",
        "pmid": "27423412",
        "source": "Heart Rhythm. 2016;13(10):e295-e324",
        "title": "J-Wave syndromes expert consensus conference report: Emerging concepts and gaps in knowledge"
      },
      "formula": "shanghai",
      "formula_expression": "Shanghai Table 2 (Antzelevitch 2016): ECG required, highest only (spontaneous_type1 3.5, fever_type1 3, drug_converted_type2_3 2) + clinical highest only (vf_arrest 3, nocturnal_agonal 2, arrhythmic_syncope 2, unclear_syncope 1, af_under_30 0.5, none 0) + family highest only (relative_definite_brs 2, suspicious_scd 1, unexplained_scd_under_45 0.5, none 0) + pathogenic_mutation 0.5; max 9; probable_definite ≥3.5, possible 2–3, nondiagnostic <2. Not ERS Table 5",
      "max_score": 9,
      "score": 3.5,
      "clinical": "none",
      "ecg_pattern": "spontaneous_type1",
      "pathogenic_mutation": false,
      "shanghai_band": "probable_definite"
    }
  ]
}
```

## Response fields

- `formula` (string): shanghai
- `formula_expression` (string): Antzelevitch 2016 Table 2 Shanghai Score System expression
- `score` (number): Shanghai Table 2 point total (ECG floor 2; max 9)
- `max_score` (integer): 9
- `shanghai_band` (string): probable_definite when score ≥3.5; possible when 2–3; nondiagnostic when <2 (unreachable while an ECG finding is required). Not a diagnosis or ICD indication.
- `ecg_pattern` (string): Echo of the caller-assigned ECG token
- `clinical` (string): Echo of the caller-assigned clinical token (none when omitted)
- `family` (string): Echo of the caller-assigned family token (none when omitted)
- `pathogenic_mutation` (boolean): Echo of the caller-assigned pathogenic-mutation flag
- `components` (array): Per-category Table 2 points
- `citation` (object): Antzelevitch et al. Heart Rhythm 2016 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "family": "none",
  "components": [
    {
      "value": "spontaneous_type1",
      "factor": "ecg_pattern",
      "points": 3.5,
      "present": true
    },
    {
      "value": "none",
      "factor": "clinical",
      "points": 0,
      "present": false
    },
    {
      "value": "none",
      "factor": "family",
      "points": 0,
      "present": false
    },
    {
      "value": false,
      "factor": "pathogenic_mutation",
      "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": "Antzelevitch C, Yan GX, Ackerman MJ, Borggrefe M, Corrado D, Guo J, et al.",
    "doi": "10.1016/j.hrthm.2016.05.024",
    "id": "antzelevitch-2016",
    "pmid": "27423412",
    "source": "Heart Rhythm. 2016;13(10):e295-e324",
    "title": "J-Wave syndromes expert consensus conference report: Emerging concepts and gaps in knowledge"
  },
  "formula": "shanghai",
  "formula_expression": "Shanghai Table 2 (Antzelevitch 2016): ECG required, highest only (spontaneous_type1 3.5, fever_type1 3, drug_converted_type2_3 2) + clinical highest only (vf_arrest 3, nocturnal_agonal 2, arrhythmic_syncope 2, unclear_syncope 1, af_under_30 0.5, none 0) + family highest only (relative_definite_brs 2, suspicious_scd 1, unexplained_scd_under_45 0.5, none 0) + pathogenic_mutation 0.5; max 9; probable_definite ≥3.5, possible 2–3, nondiagnostic <2. Not ERS Table 5",
  "max_score": 9,
  "score": 3.5,
  "clinical": "none",
  "ecg_pattern": "spontaneous_type1",
  "pathogenic_mutation": false,
  "shanghai_band": "probable_definite"
}
```

## Errors

- HTTP 400 `invalid_shanghai_ecg`: ecg_pattern must be spontaneous_type1, fever_type1, or drug_converted_type2_3 (Antzelevitch 2016 Shanghai BrS Table 2; at least one ECG finding is required). 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_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

- [Brugada](https://magentlab.com/docs/brugada) — Apply the Brugada 1991 four-step algorithm for regular wide-QRS tachycardia and return diagnosis vt or svt plus the step that stopped the tree.
- [QTc](https://magentlab.com/docs/qtc) — Compute heart-rate-corrected QT using Bazett or Fridericia. The formula argument is required.

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