# TWIST testicular torsion score

TWIST

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

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

## What it computes

Sum the five Barbosa 2013 TWIST flags for an already-examined acute scrotum and return the 0–7 score and published risk band (low 0–2, intermediate 3–4, high 5–7).

## When to use

When an agent has already assigned the five Barbosa 2013 TWIST flags and needs the published point total and risk band. magent does not examine the patient and does not diagnose torsion or order ultrasound or surgery.

## When not to use

- Not a medical device.
- Not a testicular torsion diagnosis.
- Not an ultrasound order or an operative order.
- magent does not examine the patient.
- Barbosa 2013 derived the score in children with acute scrotum. The score has no age points.
- Risk bands use published cutoffs 2 and 5 (low 0–2, intermediate 3–4, high 5–7).

## Formula

```
TWIST = testicular_swelling (true 2) + hard_testicle (true 2) + absent_cremasteric_reflex (true 1) + nausea_or_vomiting (true 1) + high_riding_testis (true 1); Barbosa 2013; max 7; 0-2 low, 3-4 intermediate, 5-7 high (cutoffs 2 and 5)
```

## Citation

[Development and initial validation of a scoring system to diagnose testicular torsion in children](https://doi.org/10.1016/j.juro.2012.10.056)
Barbosa JA, Tiseo BC, Barayan GA, Rosman BM, Torricelli FC, Passerotti CC, Srougi M, Retik AB, Nguyen HT
J Urol. 2013;189(5):1859-1864
DOI: [10.1016/j.juro.2012.10.056](https://doi.org/10.1016/j.juro.2012.10.056)

## Worked example

### All five flags false

Given: `absent_cremasteric_reflex=false, hard_testicle=false, high_riding_testis=false, nausea_or_vomiting=false, testicular_swelling=false`

1. testicular_swelling false → 0; hard_testicle false → 0; absent_cremasteric_reflex false → 0; nausea_or_vomiting false → 0; high_riding_testis false → 0
2. Score = 0 (max 7); risk = low


### All five flags true

Given: `absent_cremasteric_reflex=true, hard_testicle=true, high_riding_testis=true, nausea_or_vomiting=true, testicular_swelling=true`

1. testicular_swelling true → 2; hard_testicle true → 2; absent_cremasteric_reflex true → 1; nausea_or_vomiting true → 1; high_riding_testis true → 1
2. Score = 7 (max 7); risk = high


## Also searched as

- TWIST
- TWIST score
- testicular torsion
- Testicular Workup for Ischemia and Suspected Torsion
- Barbosa 2013
- acute scrotum
- cremasteric reflex
- high-riding testis

## Parameters

- `testicular_swelling` (boolean, required): Testicular swelling as assigned by the caller (Barbosa 2013). true scores 2. magent does not examine the patient.
- `hard_testicle` (boolean, required): Hard testicle as assigned by the caller (Barbosa 2013). true scores 2. magent does not examine the patient.
- `absent_cremasteric_reflex` (boolean, required): Absent cremasteric reflex as assigned by the caller (Barbosa 2013). true scores 1. magent does not examine the patient.
- `nausea_or_vomiting` (boolean, required): Nausea or vomiting as assigned by the caller (Barbosa 2013). true scores 1. magent does not take a symptom history.
- `high_riding_testis` (boolean, required): High-riding testis as assigned by the caller (Barbosa 2013). true scores 1. 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/twist`
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": [
    {
      "absent_cremasteric_reflex": "false",
      "hard_testicle": "false",
      "high_riding_testis": "false",
      "nausea_or_vomiting": "false",
      "testicular_swelling": "false"
    },
    {
      "absent_cremasteric_reflex": "false",
      "hard_testicle": "false",
      "high_riding_testis": "false",
      "nausea_or_vomiting": "false",
      "testicular_swelling": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/twist",
  "items": [
    {
      "components": [
        {
          "factor": "testicular_swelling",
          "points": 0,
          "present": false
        },
        {
          "factor": "hard_testicle",
          "points": 0,
          "present": false
        },
        {
          "factor": "absent_cremasteric_reflex",
          "points": 0,
          "present": false
        },
        {
          "factor": "nausea_or_vomiting",
          "points": 0,
          "present": false
        },
        {
          "factor": "high_riding_testis",
          "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": "Barbosa JA, Tiseo BC, Barayan GA, Rosman BM, Torricelli FC, Passerotti CC, Srougi M, Retik AB, Nguyen HT",
        "doi": "10.1016/j.juro.2012.10.056",
        "id": "barbosa-2013",
        "pmid": "23103800",
        "source": "J Urol. 2013;189(5):1859-1864",
        "title": "Development and initial validation of a scoring system to diagnose testicular torsion in children"
      },
      "formula": "twist",
      "formula_expression": "TWIST = testicular_swelling (true 2) + hard_testicle (true 2) + absent_cremasteric_reflex (true 1) + nausea_or_vomiting (true 1) + high_riding_testis (true 1); Barbosa 2013; max 7; 0-2 low, 3-4 intermediate, 5-7 high (cutoffs 2 and 5)",
      "max_score": 7,
      "score": 0,
      "risk": "low"
    },
    {
      "components": [
        {
          "factor": "testicular_swelling",
          "points": 0,
          "present": false
        },
        {
          "factor": "hard_testicle",
          "points": 0,
          "present": false
        },
        {
          "factor": "absent_cremasteric_reflex",
          "points": 0,
          "present": false
        },
        {
          "factor": "nausea_or_vomiting",
          "points": 0,
          "present": false
        },
        {
          "factor": "high_riding_testis",
          "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": "Barbosa JA, Tiseo BC, Barayan GA, Rosman BM, Torricelli FC, Passerotti CC, Srougi M, Retik AB, Nguyen HT",
        "doi": "10.1016/j.juro.2012.10.056",
        "id": "barbosa-2013",
        "pmid": "23103800",
        "source": "J Urol. 2013;189(5):1859-1864",
        "title": "Development and initial validation of a scoring system to diagnose testicular torsion in children"
      },
      "formula": "twist",
      "formula_expression": "TWIST = testicular_swelling (true 2) + hard_testicle (true 2) + absent_cremasteric_reflex (true 1) + nausea_or_vomiting (true 1) + high_riding_testis (true 1); Barbosa 2013; max 7; 0-2 low, 3-4 intermediate, 5-7 high (cutoffs 2 and 5)",
      "max_score": 7,
      "score": 0,
      "risk": "low"
    }
  ]
}
```

## Response fields

- `formula` (string): twist
- `formula_expression` (string): Exact expression used
- `score` (integer): TWIST points 0-7
- `max_score` (integer): Always 7
- `risk` (string): Barbosa 2013 risk band: low (0–2), intermediate (3–4), or high (5–7). Cutoffs 2 and 5. Not a torsion diagnosis.
- `components` (array): Per-flag points
- `citation` (object): Barbosa 2013 J Urol citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "factor": "testicular_swelling",
      "points": 0,
      "present": false
    },
    {
      "factor": "hard_testicle",
      "points": 0,
      "present": false
    },
    {
      "factor": "absent_cremasteric_reflex",
      "points": 0,
      "present": false
    },
    {
      "factor": "nausea_or_vomiting",
      "points": 0,
      "present": false
    },
    {
      "factor": "high_riding_testis",
      "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": "Barbosa JA, Tiseo BC, Barayan GA, Rosman BM, Torricelli FC, Passerotti CC, Srougi M, Retik AB, Nguyen HT",
    "doi": "10.1016/j.juro.2012.10.056",
    "id": "barbosa-2013",
    "pmid": "23103800",
    "source": "J Urol. 2013;189(5):1859-1864",
    "title": "Development and initial validation of a scoring system to diagnose testicular torsion in children"
  },
  "formula": "twist",
  "formula_expression": "TWIST = testicular_swelling (true 2) + hard_testicle (true 2) + absent_cremasteric_reflex (true 1) + nausea_or_vomiting (true 1) + high_riding_testis (true 1); Barbosa 2013; max 7; 0-2 low, 3-4 intermediate, 5-7 high (cutoffs 2 and 5)",
  "max_score": 7,
  "score": 0,
  "risk": "low"
}
```

## Errors

- 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

- [PECARN pediatric IAI](https://magentlab.com/docs/pecarn-iai) — Apply the Holmes 2013 PECARN seven-variable prediction rule and return whether the child is at very low risk of intra-abdominal injury requiring acute intervention (all seven caller-assigned findings absent). Does not order a CT.
- [SIPA](https://magentlab.com/docs/sipa) — Compute Acker 2015 SIPA as heart rate in bpm divided by cuff systolic pressure in mm Hg, then compare the ratio with the published age-band cutoff.
- [Kocher criteria](https://magentlab.com/docs/kocher) — Sum the four Kocher 1999 predictors and return the published predicted probability of septic arthritis versus transient synovitis in children with irritable hip.

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