# Therapy-Disability-Neurology grade

TDN Grade

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

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

## What it computes

Apply the Terrapon 2021 Therapy-Disability-Neurology grade and return tdn_grade 1-5 as the maximum of caller-assigned therapy, mapped mRS disability, and new-deficit neurology grades.

## When to use

When an agent already has a caller-assigned therapy intensity (t1-t5), modified Rankin 0-6, and whether a new neurologic deficit occurred, and needs the published TDN grade. magent does not grade the adverse event.

## When not to use

- Not a medical device and not a diagnosis. magent does not examine the patient and does not grade the adverse event; the caller assigns therapy, modified Rankin, and new deficit.
- Not Clavien-Dindo alone. TDN grades therapy, disability, and neurology together; the overall grade is the maximum of the three dimensions.
- Disability uses modified Rankin 0-6 including death (6). This is not van Swieten 1988 modified Rankin 0-5, which omits death.
- Therapy t5 or disability_mrs 6 is always TDN grade 5 (death).

## Formula

```
tdn_grade = max(T, D, N); T is therapy t1-t5 (t1 no treatment beyond antiemetics, antipyretics, analgesics, diuretics, electrolytes, physiotherapy, bedside wound opening; t2 pharmacologic including transfusion or TPN; t3 invasive procedure; t4 life-threatening ICU; t5 death); D maps disability_mrs 0-1→1, 2-3→2, 4→3, 5→4, 6→5; N is 2 if new_neurologic_deficit else 1; if therapy is t5 or disability_mrs is 6, tdn_grade is 5 (Terrapon 2021)
```

## Citation

[Adverse Events in Neurosurgery: The Novel Therapy-Disability-Neurology Grade](https://doi.org/10.1093/neuros/nyab121)
Terrapon APR, Zattra CM, Voglis S, et al.
Neurosurgery. 2021;89(2):236-245
DOI: [10.1093/neuros/nyab121](https://doi.org/10.1093/neuros/nyab121)

## Worked example

### TDN 1

Given: `disability_mrs=0, new_neurologic_deficit=false, therapy=t1`

1. therapy t1 maps to T=1
2. disability_mrs 0 maps to D=1
3. new_neurologic_deficit false maps to N=1
4. tdn_grade = max(1, 1, 1) = 1


### TDN 2

Given: `disability_mrs=1, new_neurologic_deficit=true, therapy=t2`

1. therapy t2 maps to T=2
2. disability_mrs 1 maps to D=1
3. new_neurologic_deficit true maps to N=2
4. tdn_grade = max(2, 1, 2) = 2


### TDN 3

Given: `disability_mrs=4, new_neurologic_deficit=false, therapy=t3`

1. therapy t3 maps to T=3
2. disability_mrs 4 maps to D=3
3. new_neurologic_deficit false maps to N=1
4. tdn_grade = max(3, 3, 1) = 3


### TDN 4

Given: `disability_mrs=5, new_neurologic_deficit=false, therapy=t2`

1. therapy t2 maps to T=2
2. disability_mrs 5 maps to D=4
3. new_neurologic_deficit false maps to N=1
4. tdn_grade = max(2, 4, 1) = 4


### TDN 5

Given: `disability_mrs=0, new_neurologic_deficit=false, therapy=t5`

1. therapy t5 maps to T=5 (death)
2. disability_mrs 0 maps to D=1
3. new_neurologic_deficit false maps to N=1
4. therapy t5 forces tdn_grade 5


## Also searched as

- TDN grade
- Therapy-Disability-Neurology grade
- Terrapon TDN
- neurosurgical adverse event grade
- TDN classification
- therapy disability neurology
- TDN grade neurosurgery

## Parameters

- `therapy` (string, required): Terrapon 2021 Therapy dimension as assigned by the caller. t1 no treatment or intervention beyond antiemetics, antipyretics, analgesics, diuretics, electrolytes, physiotherapy, or bedside wound opening (T=1). t2 pharmacologic treatment including blood transfusion or TPN (T=2). t3 invasive procedure, surgical, endoscopic, or radiologic (T=3). t4 life-threatening, ICU management (T=4). t5 death (T=5). magent does not grade the adverse event.
- `disability_mrs` (integer, required): Modified Rankin 0-6 as assigned by the caller, including death as 6. Maps to Disability D: 0-1→1, 2-3→2, 4→3, 5→4, 6→5. This is not van Swieten 1988 modified Rankin 0-5, which omits death. magent does not interview the patient.
- `new_neurologic_deficit` (boolean, required): New neurologic deficit as assigned by the caller (Terrapon 2021 Neurology dimension). true or false. false is N=1; true is N=2. magent does not examine the patient.

## 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/tdn_grade`
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": [
    {
      "disability_mrs": "0",
      "new_neurologic_deficit": "false",
      "therapy": "t1"
    },
    {
      "disability_mrs": "0",
      "new_neurologic_deficit": "false",
      "therapy": "t1"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/tdn_grade",
  "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": "Terrapon APR, Zattra CM, Voglis S, et al.",
        "doi": "10.1093/neuros/nyab121",
        "id": "terrapon-2021",
        "pmid": "33887774",
        "source": "Neurosurgery. 2021;89(2):236-245",
        "title": "Adverse Events in Neurosurgery: The Novel Therapy-Disability-Neurology Grade"
      },
      "formula": "tdn_grade",
      "formula_expression": "tdn_grade = max(T, D, N); T is therapy t1-t5 (t1 no treatment beyond antiemetics, antipyretics, analgesics, diuretics, electrolytes, physiotherapy, bedside wound opening; t2 pharmacologic including transfusion or TPN; t3 invasive procedure; t4 life-threatening ICU; t5 death); D maps disability_mrs 0-1→1, 2-3→2, 4→3, 5→4, 6→5; N is 2 if new_neurologic_deficit else 1; if therapy is t5 or disability_mrs is 6, tdn_grade is 5 (Terrapon 2021)",
      "criteria": [
        {
          "value": 1,
          "factor": "therapy",
          "met": true
        },
        {
          "value": 1,
          "factor": "disability",
          "met": true
        },
        {
          "value": 1,
          "factor": "neurology",
          "met": true
        }
      ],
      "disability_grade": 1,
      "neurology_grade": 1,
      "tdn_grade": 1,
      "therapy_grade": 1
    },
    {
      "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": "Terrapon APR, Zattra CM, Voglis S, et al.",
        "doi": "10.1093/neuros/nyab121",
        "id": "terrapon-2021",
        "pmid": "33887774",
        "source": "Neurosurgery. 2021;89(2):236-245",
        "title": "Adverse Events in Neurosurgery: The Novel Therapy-Disability-Neurology Grade"
      },
      "formula": "tdn_grade",
      "formula_expression": "tdn_grade = max(T, D, N); T is therapy t1-t5 (t1 no treatment beyond antiemetics, antipyretics, analgesics, diuretics, electrolytes, physiotherapy, bedside wound opening; t2 pharmacologic including transfusion or TPN; t3 invasive procedure; t4 life-threatening ICU; t5 death); D maps disability_mrs 0-1→1, 2-3→2, 4→3, 5→4, 6→5; N is 2 if new_neurologic_deficit else 1; if therapy is t5 or disability_mrs is 6, tdn_grade is 5 (Terrapon 2021)",
      "criteria": [
        {
          "value": 1,
          "factor": "therapy",
          "met": true
        },
        {
          "value": 1,
          "factor": "disability",
          "met": true
        },
        {
          "value": 1,
          "factor": "neurology",
          "met": true
        }
      ],
      "disability_grade": 1,
      "neurology_grade": 1,
      "tdn_grade": 1,
      "therapy_grade": 1
    }
  ]
}
```

## Response fields

- `formula` (string): tdn_grade
- `formula_expression` (string): Published Terrapon 2021 max(T, D, N) rule
- `tdn_grade` (integer): Overall TDN grade 1-5, the maximum of therapy, disability, and neurology grades. Always 5 when therapy is t5 or disability_mrs is 6. Not a diagnosis.
- `therapy_grade` (integer): Therapy dimension T 1-5 from caller-assigned t1-t5
- `disability_grade` (integer): Disability dimension D 1-5 from caller-assigned mRS 0-6
- `neurology_grade` (integer): Neurology dimension N 1 without a new deficit, 2 with a new deficit
- `criteria` (array): Per-dimension Tree rows for therapy, disability, and neurology with factor, met (true when that dimension equals tdn_grade), and value
- `citation` (object): Terrapon 2021 Neurosurgery 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": "Terrapon APR, Zattra CM, Voglis S, et al.",
    "doi": "10.1093/neuros/nyab121",
    "id": "terrapon-2021",
    "pmid": "33887774",
    "source": "Neurosurgery. 2021;89(2):236-245",
    "title": "Adverse Events in Neurosurgery: The Novel Therapy-Disability-Neurology Grade"
  },
  "formula": "tdn_grade",
  "formula_expression": "tdn_grade = max(T, D, N); T is therapy t1-t5 (t1 no treatment beyond antiemetics, antipyretics, analgesics, diuretics, electrolytes, physiotherapy, bedside wound opening; t2 pharmacologic including transfusion or TPN; t3 invasive procedure; t4 life-threatening ICU; t5 death); D maps disability_mrs 0-1→1, 2-3→2, 4→3, 5→4, 6→5; N is 2 if new_neurologic_deficit else 1; if therapy is t5 or disability_mrs is 6, tdn_grade is 5 (Terrapon 2021)",
  "criteria": [
    {
      "value": 1,
      "factor": "therapy",
      "met": true
    },
    {
      "value": 1,
      "factor": "disability",
      "met": true
    },
    {
      "value": 1,
      "factor": "neurology",
      "met": true
    }
  ],
  "disability_grade": 1,
  "neurology_grade": 1,
  "tdn_grade": 1,
  "therapy_grade": 1
}
```

## Errors

- HTTP 400 `invalid_tdn_therapy`: therapy must be t1, t2, t3, t4, or t5 (Terrapon 2021 Therapy dimension). Returned before settlement; you are not charged.
- HTTP 400 `invalid_tdn_mrs`: disability_mrs must be an integer from 0 to 6 (Terrapon 2021 mRS; 6 is death). 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

- [Modified Rankin](https://magentlab.com/docs/modified-rankin) — Return the van Swieten 1988 modified Rankin handicap grade 0-5 from a caller-assigned integer, with the published grade wording.
- [Glasgow Coma Scale](https://magentlab.com/docs/gcs) — Compute the Glasgow Coma Scale as the sum of caller-assigned eye, verbal, and motor integers. The 1974 or 1976 edition 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.
