# Ottawa SAH Rule

Ottawa SAH Rule

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

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

## What it computes

Apply the Perry 2013 Ottawa SAH Rule and return whether investigation is indicated from age and five caller-assigned high-risk findings.

## When to use

When an agent has caller-assigned findings for acute headache and needs the published six-variable investigation rule, not a diagnosis of SAH.

## When not to use

- Not a diagnosis of subarachnoid hemorrhage. magent does not examine the neck.
- Not Hunt-Hess grade and not Fisher grade.
- Inclusion as published is alert, neurologically intact adults with nontraumatic headache peaking within 1 hour. magent does not take GCS or time-to-peak; the caller applies inclusion.
- Limited neck flexion is an examination finding assigned by the caller.
- Thunderclap headache means instantly peaking pain as published.

## Formula

```
Investigation indicated iff age >= 40 or neck_pain_or_stiffness or witnessed_loc or onset_during_exertion or thunderclap_headache or limited_neck_flexion
```

## Citation

[Clinical decision rules to rule out subarachnoid hemorrhage for acute headache](https://doi.org/10.1001/jama.2013.278018)
Perry JJ, Stiell IG, Sivilotti MLA, et al.
JAMA. 2013;310(12):1248-1255
DOI: [10.1001/jama.2013.278018](https://doi.org/10.1001/jama.2013.278018)

## Worked example

### All findings absent

Given: `age=30, limited_neck_flexion=false, neck_pain_or_stiffness=false, onset_during_exertion=false, thunderclap_headache=false, witnessed_loc=false`

1. Age 30 (under 40) and all five clinical flags false
2. Investigation is not indicated


### Age 40 with no other findings

Given: `age=40, limited_neck_flexion=false, neck_pain_or_stiffness=false, onset_during_exertion=false, thunderclap_headache=false, witnessed_loc=false`

1. Age 40 meets the age criterion (39 does not)
2. Investigation is indicated


### Thunderclap headache alone

Given: `age=30, limited_neck_flexion=false, neck_pain_or_stiffness=false, onset_during_exertion=false, thunderclap_headache=true, witnessed_loc=false`

1. Age 30 does not meet the age criterion
2. Thunderclap headache (instantly peaking pain) is present
3. Investigation is indicated


## Also searched as

- Ottawa SAH Rule
- Ottawa subarachnoid hemorrhage rule
- Perry SAH rule
- thunderclap headache rule
- Ottawa SAH
- Perry 2013 JAMA headache
- SAH decision rule
- subarachnoid hemorrhage rule-out

## Parameters

- `age` (integer, required): Age in years (18-120). Age ≥40 meets this criterion; 39 does not.
- `neck_pain_or_stiffness` (boolean, required): Neck pain or stiffness as assigned by the caller. true or false.
- `witnessed_loc` (boolean, required): Witnessed loss of consciousness. true or false as assigned by the caller.
- `onset_during_exertion` (boolean, required): Onset during exertion. true or false as assigned by the caller.
- `thunderclap_headache` (boolean, required): Thunderclap headache (instantly peaking pain as published). true or false as assigned by the caller.
- `limited_neck_flexion` (boolean, required): Limited neck flexion on examination as assigned by the caller. true or false. magent does not examine the neck.

## Bulk (POST)

POST the same path with a JSON items array. Price is n times the GET unit. Invalid items return HTTP 400 before settlement.

Method: `POST /api/calc/ottawa_sah`
Max items: 25
Price: unit_amount * n (unit 5000 atomic)
Status: PREVIEW

- 1 to 25 items. Each item uses the same keys as the GET query parameters.
- 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": "30",
      "limited_neck_flexion": "false",
      "neck_pain_or_stiffness": "false",
      "onset_during_exertion": "false",
      "thunderclap_headache": "false",
      "witnessed_loc": "false"
    },
    {
      "age": "30",
      "limited_neck_flexion": "false",
      "neck_pain_or_stiffness": "false",
      "onset_during_exertion": "false",
      "thunderclap_headache": "false",
      "witnessed_loc": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/ottawa_sah",
  "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": "Perry JJ, Stiell IG, Sivilotti MLA, et al.",
        "doi": "10.1001/jama.2013.278018",
        "id": "perry-2013",
        "source": "JAMA. 2013;310(12):1248-1255",
        "title": "Clinical decision rules to rule out subarachnoid hemorrhage for acute headache"
      },
      "formula": "ottawa_sah",
      "formula_expression": "Investigation indicated iff age >= 40 or neck_pain_or_stiffness or witnessed_loc or onset_during_exertion or thunderclap_headache or limited_neck_flexion",
      "age_years": 30,
      "criteria": [
        {
          "value": 30,
          "factor": "age_ge_40",
          "met": false
        },
        {
          "factor": "neck_pain_or_stiffness",
          "met": false
        },
        {
          "factor": "witnessed_loc",
          "met": false
        },
        {
          "factor": "onset_during_exertion",
          "met": false
        },
        {
          "factor": "thunderclap_headache",
          "met": false
        },
        {
          "factor": "limited_neck_flexion",
          "met": false
        }
      ],
      "investigation_indicated": 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": "Perry JJ, Stiell IG, Sivilotti MLA, et al.",
        "doi": "10.1001/jama.2013.278018",
        "id": "perry-2013",
        "source": "JAMA. 2013;310(12):1248-1255",
        "title": "Clinical decision rules to rule out subarachnoid hemorrhage for acute headache"
      },
      "formula": "ottawa_sah",
      "formula_expression": "Investigation indicated iff age >= 40 or neck_pain_or_stiffness or witnessed_loc or onset_during_exertion or thunderclap_headache or limited_neck_flexion",
      "age_years": 30,
      "criteria": [
        {
          "value": 30,
          "factor": "age_ge_40",
          "met": false
        },
        {
          "factor": "neck_pain_or_stiffness",
          "met": false
        },
        {
          "factor": "witnessed_loc",
          "met": false
        },
        {
          "factor": "onset_during_exertion",
          "met": false
        },
        {
          "factor": "thunderclap_headache",
          "met": false
        },
        {
          "factor": "limited_neck_flexion",
          "met": false
        }
      ],
      "investigation_indicated": false
    }
  ]
}
```

## Response fields

- `formula` (string): ottawa_sah
- `formula_expression` (string): Perry 2013 six-variable investigation rule
- `investigation_indicated` (boolean): true when any published high-risk finding is present. Not a diagnosis of SAH.
- `age_years` (integer): Age used for the ≥40 criterion
- `criteria` (array): Per-factor rows with factor and met; age_ge_40 includes the age value
- `citation` (object): Perry 2013 JAMA 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": "Perry JJ, Stiell IG, Sivilotti MLA, et al.",
    "doi": "10.1001/jama.2013.278018",
    "id": "perry-2013",
    "source": "JAMA. 2013;310(12):1248-1255",
    "title": "Clinical decision rules to rule out subarachnoid hemorrhage for acute headache"
  },
  "formula": "ottawa_sah",
  "formula_expression": "Investigation indicated iff age >= 40 or neck_pain_or_stiffness or witnessed_loc or onset_during_exertion or thunderclap_headache or limited_neck_flexion",
  "age_years": 30,
  "criteria": [
    {
      "value": 30,
      "factor": "age_ge_40",
      "met": false
    },
    {
      "factor": "neck_pain_or_stiffness",
      "met": false
    },
    {
      "factor": "witnessed_loc",
      "met": false
    },
    {
      "factor": "onset_during_exertion",
      "met": false
    },
    {
      "factor": "thunderclap_headache",
      "met": false
    },
    {
      "factor": "limited_neck_flexion",
      "met": false
    }
  ],
  "investigation_indicated": 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_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

- [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.
- [ICH Score](https://magentlab.com/docs/ich-score) — Compute the Hemphill 2001 ICH Score from caller-assigned GCS, age, infratentorial origin, ICH volume, and IVH.

## Payment

Required query parameters must be present and valid. 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 EIP-3009 (scheme exact, assetTransferMethod eip3009) with validBefore = now + accepts[0].maxTimeoutSeconds (600 seconds). That window starts when you sign and must cover wallet confirmation plus CDP verify and settle. Magent retries transient facilitator 429/5xx before answering. Do not send upto or batch-settlement payloads; magent does not offer those schemes.
- Retry the same URL with PAYMENT-SIGNATURE (base64 JSON echoing accepted, payload, and extensions when present).
- Success is HTTP 200 JSON plus PAYMENT-RESPONSE. Settlement happens before the tool runs. HTTP 503 settlement_uncertain or settle_failed: retry the same PAYMENT-SIGNATURE. Mint a new 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.

- 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.
- not offered `batch-settlement`: Not offered. Payment-channel vouchers claimed later in batches. Not the same as POST {items} bulk (that is still exact).

Same-path POST {items} is still scheme exact: one EIP-3009 authorization for n times the GET unit. 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

- Invalid query parameters return HTTP 400 before settlement. You are not charged.
- Settlement finishes before the tool executes (paymentFlow upfront). 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.
