# Karter hypoglycemia risk score

Hypoglycemia risk score

Status: LIVE
Price: $0.005 USDC
`GET /api/calc/hypoglycemia_risk_score`
HTML: https://magentlab.com/docs/hypoglycemia-risk-score
Markdown: https://magentlab.com/docs/hypoglycemia-risk-score.md

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

## What it computes

Apply Karter 2017 Figure 2 first-match checklist to six EMR inputs and return high, intermediate, or low 12-month risk of hypoglycemia-related ED or hospital use in type 2 diabetes.

## When to use

When an agent already has prior hypoglycemia-related ED/hospital count, prior-year all-cause ED visits, insulin, sulfonylurea, severe or ESRD kidney disease, and age <77 and needs the published T2D utilization-risk band. magent does not assay glucose.

## When not to use

- Not a medical device.
- Not a diagnosis. Not an insulin dose.
- Type 2 diabetes population only (Karter 2017 derivation and validation).
- Predicts hypoglycemia-related ED or hospital use, not all severe hypoglycemia treated outside the health system.
- magent does not assay glucose, compute eGFR, or count visits.
- prior_hypo_ed_hospital_count, ed_visits_12mo, insulin, sulfonylurea, severe_or_esrd, and age_lt_77 are caller-assigned (Karter 2017 Figure 2).

## Formula

```
hypoglycemia_risk_score first-match Karter 2017 Figure 2 (6 mutually exclusive options; eTable 2 source): (1) prior_hypo_ed_hospital_count >= 3 -> high; (2) prior 1-2 and insulin -> high; (3) prior 1-2 and not insulin -> intermediate; (4) prior 0 and insulin and (ed_visits_12mo >= 2 or severe_or_esrd or not age_lt_77) -> intermediate; (5) prior 0 and not insulin and sulfonylurea and (ed_visits_12mo >= 2 or severe_or_esrd) -> intermediate; (6) else -> low. high >5%, intermediate 1-5%, low <1% 12-month hypoglycemia-related ED/hospital use. T2D only. Not a points sum. magent does not assay glucose. Not a diagnosis. Not an insulin dose
```

## Citation

[Development and Validation of a Tool to Identify Patients With Type 2 Diabetes at High Risk of Hypoglycemia-Related Emergency Department or Hospital Use](https://doi.org/10.1001/jamainternmed.2017.3844)
Karter AJ, Warton EM, Lipska KJ, Ralston JD, Moffet HH, Jackson GG, Huang ES, Miller DR
JAMA Intern Med. 2017;177(10):1461-1470
DOI: [10.1001/jamainternmed.2017.3844](https://doi.org/10.1001/jamainternmed.2017.3844)

## Worked example

### Three prior hypoglycemia-related utilizations, high

Given: `age_lt_77=true, ed_visits_12mo=0, insulin=false, prior_hypo_ed_hospital_count=3, severe_or_esrd=false, sulfonylurea=false`

1. prior_hypo_ed_hospital_count is 3 (>=3 band)
2. Figure 2 option 1 matches regardless of insulin, sulfonylurea, ED visits, kidney disease, or age
3. first-match is high (>5% 12-month hypoglycemia-related ED/hospital use)


### One or two prior episodes without insulin, intermediate

Given: `age_lt_77=true, ed_visits_12mo=0, insulin=false, prior_hypo_ed_hospital_count=1, severe_or_esrd=false, sulfonylurea=false`

1. prior_hypo_ed_hospital_count is 1 (1-2 band) and insulin is false
2. options 1-2 do not match; Figure 2 option 3 matches
3. first-match is intermediate (1-5%)


### No prior episodes, no insulin or sulfonylurea, low

Given: `age_lt_77=true, ed_visits_12mo=0, insulin=false, prior_hypo_ed_hospital_count=0, severe_or_esrd=false, sulfonylurea=false`

1. prior_hypo_ed_hospital_count is 0, insulin and sulfonylurea are false
2. options 1-5 do not match; Figure 2 option 6 is the remainder
3. first-match is low (<1%)


## Also searched as

- Karter hypoglycemia risk
- hypoglycemia risk stratification
- T2D hypoglycemia ED risk
- hypoglycemia-related utilization
- type 2 diabetes hypoglycemia hospital use
- severe hypoglycemia risk T2D
- hypoglycemia ED hospital tool
- Karter 2017 Figure 2

## Parameters

- `prior_hypo_ed_hospital_count` (integer, required): Count of prior hypoglycemia-related ED visits or hospitalizations (integer 0-20). Karter 2017 Figure 2 bands: 0, 1-2, or >=3. >=3 is high regardless of other inputs. magent does not read claims.
- `ed_visits_12mo` (integer, required): ED encounters for any reason in the prior 12 months (integer 0-50). Karter 2017 Figure 2 bands: <2 vs >=2. magent does not count visits.
- `insulin` (boolean, required): Current insulin use as assigned by the caller (Karter 2017 Figure 2). true or false. With 1-2 prior hypoglycemia-related ED or hospital episodes, insulin is high; with 0 prior episodes, insulin plus ED visits >=2, severe_or_esrd, or age not <77 is intermediate. Not an insulin dose.
- `sulfonylurea` (boolean, required): Current sulfonylurea use as assigned by the caller (Karter 2017 Figure 2). true or false. With 0 prior episodes and no insulin, sulfonylurea plus ED visits >=2 or severe_or_esrd is intermediate. magent does not dispense medication.
- `severe_or_esrd` (boolean, required): Severe or end-stage kidney disease as assigned by the caller (Karter 2017: dialysis or CKD stage 4-5, eGFR <=29 mL/min/1.73 m2). true or false. magent does not compute eGFR.
- `age_lt_77` (boolean, required): Age younger than 77 years as assigned by the caller (Karter 2017 Figure 2). true or false. When prior episodes are 0 and insulin is true, age not <77 (with ED visits <2 and severe_or_esrd false) is intermediate. magent does not compute age.

## 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/hypoglycemia_risk_score`
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_lt_77": "true",
      "ed_visits_12mo": "0",
      "insulin": "false",
      "prior_hypo_ed_hospital_count": "3",
      "severe_or_esrd": "false",
      "sulfonylurea": "false"
    },
    {
      "age_lt_77": "true",
      "ed_visits_12mo": "0",
      "insulin": "false",
      "prior_hypo_ed_hospital_count": "3",
      "severe_or_esrd": "false",
      "sulfonylurea": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/hypoglycemia_risk_score",
  "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": "Karter AJ, Warton EM, Lipska KJ, Ralston JD, Moffet HH, Jackson GG, Huang ES, Miller DR",
        "doi": "10.1001/jamainternmed.2017.3844",
        "id": "karter-2017",
        "pmid": "28828479",
        "source": "JAMA Intern Med. 2017;177(10):1461-1470",
        "title": "Development and Validation of a Tool to Identify Patients With Type 2 Diabetes at High Risk of Hypoglycemia-Related Emergency Department or Hospital Use"
      },
      "formula": "hypoglycemia_risk_score",
      "formula_expression": "hypoglycemia_risk_score first-match Karter 2017 Figure 2 (6 mutually exclusive options; eTable 2 source): (1) prior_hypo_ed_hospital_count >= 3 -> high; (2) prior 1-2 and insulin -> high; (3) prior 1-2 and not insulin -> intermediate; (4) prior 0 and insulin and (ed_visits_12mo >= 2 or severe_or_esrd or not age_lt_77) -> intermediate; (5) prior 0 and not insulin and sulfonylurea and (ed_visits_12mo >= 2 or severe_or_esrd) -> intermediate; (6) else -> low. high >5%, intermediate 1-5%, low <1% 12-month hypoglycemia-related ED/hospital use. T2D only. Not a points sum. magent does not assay glucose. Not a diagnosis. Not an insulin dose",
      "criteria": [
        {
          "value": 3,
          "factor": "prior_hypo_ge_3",
          "met": true
        },
        {
          "value": 3,
          "factor": "prior_hypo_1_or_2",
          "met": false
        },
        {
          "factor": "insulin",
          "met": false
        },
        {
          "factor": "sulfonylurea",
          "met": false
        },
        {
          "value": 0,
          "factor": "ed_visits_ge_2",
          "met": false
        },
        {
          "factor": "severe_or_esrd",
          "met": false
        },
        {
          "factor": "age_lt_77",
          "met": true
        }
      ],
      "risk": "high",
      "age_lt_77": true,
      "ed_visits_12mo": 0,
      "ed_visits_band": "lt_2",
      "figure2_option": 1,
      "insulin": false,
      "prior_hypo_band": "ge_3",
      "prior_hypo_ed_hospital_count": 3,
      "rate_band": ">5%",
      "severe_or_esrd": false,
      "sulfonylurea": 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": "Karter AJ, Warton EM, Lipska KJ, Ralston JD, Moffet HH, Jackson GG, Huang ES, Miller DR",
        "doi": "10.1001/jamainternmed.2017.3844",
        "id": "karter-2017",
        "pmid": "28828479",
        "source": "JAMA Intern Med. 2017;177(10):1461-1470",
        "title": "Development and Validation of a Tool to Identify Patients With Type 2 Diabetes at High Risk of Hypoglycemia-Related Emergency Department or Hospital Use"
      },
      "formula": "hypoglycemia_risk_score",
      "formula_expression": "hypoglycemia_risk_score first-match Karter 2017 Figure 2 (6 mutually exclusive options; eTable 2 source): (1) prior_hypo_ed_hospital_count >= 3 -> high; (2) prior 1-2 and insulin -> high; (3) prior 1-2 and not insulin -> intermediate; (4) prior 0 and insulin and (ed_visits_12mo >= 2 or severe_or_esrd or not age_lt_77) -> intermediate; (5) prior 0 and not insulin and sulfonylurea and (ed_visits_12mo >= 2 or severe_or_esrd) -> intermediate; (6) else -> low. high >5%, intermediate 1-5%, low <1% 12-month hypoglycemia-related ED/hospital use. T2D only. Not a points sum. magent does not assay glucose. Not a diagnosis. Not an insulin dose",
      "criteria": [
        {
          "value": 3,
          "factor": "prior_hypo_ge_3",
          "met": true
        },
        {
          "value": 3,
          "factor": "prior_hypo_1_or_2",
          "met": false
        },
        {
          "factor": "insulin",
          "met": false
        },
        {
          "factor": "sulfonylurea",
          "met": false
        },
        {
          "value": 0,
          "factor": "ed_visits_ge_2",
          "met": false
        },
        {
          "factor": "severe_or_esrd",
          "met": false
        },
        {
          "factor": "age_lt_77",
          "met": true
        }
      ],
      "risk": "high",
      "age_lt_77": true,
      "ed_visits_12mo": 0,
      "ed_visits_band": "lt_2",
      "figure2_option": 1,
      "insulin": false,
      "prior_hypo_band": "ge_3",
      "prior_hypo_ed_hospital_count": 3,
      "rate_band": ">5%",
      "severe_or_esrd": false,
      "sulfonylurea": false
    }
  ]
}
```

## Response fields

- `formula` (string): hypoglycemia_risk_score
- `formula_expression` (string): Karter 2017 Figure 2 first-match six-option hypoglycemia risk rule
- `risk` (string): high, intermediate, or low 12-month hypoglycemia-related ED/hospital use (Karter 2017 Figure 2). Not a diagnosis.
- `rate_band` (string): >5% (high), 1-5% (intermediate), or <1% (low) as published
- `figure2_option` (integer): 1-6. First-match Figure 2 row: 1-5 unique combinations, 6 after ruling out the others
- `prior_hypo_ed_hospital_count` (integer): Echo of prior hypoglycemia-related ED or hospital episode count
- `prior_hypo_band` (string): 0, 1-2, or ge_3 (Karter 2017 prior-utilization bands)
- `ed_visits_12mo` (integer): Echo of prior-12-month all-cause ED encounter count
- `ed_visits_band` (string): lt_2 or ge_2 (Karter 2017 ED-visit bands)
- `insulin` (boolean): Echo of caller-assigned insulin use
- `sulfonylurea` (boolean): Echo of caller-assigned sulfonylurea use
- `severe_or_esrd` (boolean): Echo of caller-assigned severe or end-stage kidney disease
- `age_lt_77` (boolean): Echo of caller-assigned age younger than 77 years
- `criteria` (array): Per-factor Tree rows with factor and met for prior_hypo_ge_3, prior_hypo_1_or_2, insulin, sulfonylurea, ed_visits_ge_2, severe_or_esrd, and age_lt_77; count rows include value
- `citation` (object): Karter 2017 JAMA Intern Med hypoglycemia risk tool 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": "Karter AJ, Warton EM, Lipska KJ, Ralston JD, Moffet HH, Jackson GG, Huang ES, Miller DR",
    "doi": "10.1001/jamainternmed.2017.3844",
    "id": "karter-2017",
    "pmid": "28828479",
    "source": "JAMA Intern Med. 2017;177(10):1461-1470",
    "title": "Development and Validation of a Tool to Identify Patients With Type 2 Diabetes at High Risk of Hypoglycemia-Related Emergency Department or Hospital Use"
  },
  "formula": "hypoglycemia_risk_score",
  "formula_expression": "hypoglycemia_risk_score first-match Karter 2017 Figure 2 (6 mutually exclusive options; eTable 2 source): (1) prior_hypo_ed_hospital_count >= 3 -> high; (2) prior 1-2 and insulin -> high; (3) prior 1-2 and not insulin -> intermediate; (4) prior 0 and insulin and (ed_visits_12mo >= 2 or severe_or_esrd or not age_lt_77) -> intermediate; (5) prior 0 and not insulin and sulfonylurea and (ed_visits_12mo >= 2 or severe_or_esrd) -> intermediate; (6) else -> low. high >5%, intermediate 1-5%, low <1% 12-month hypoglycemia-related ED/hospital use. T2D only. Not a points sum. magent does not assay glucose. Not a diagnosis. Not an insulin dose",
  "criteria": [
    {
      "value": 3,
      "factor": "prior_hypo_ge_3",
      "met": true
    },
    {
      "value": 3,
      "factor": "prior_hypo_1_or_2",
      "met": false
    },
    {
      "factor": "insulin",
      "met": false
    },
    {
      "factor": "sulfonylurea",
      "met": false
    },
    {
      "value": 0,
      "factor": "ed_visits_ge_2",
      "met": false
    },
    {
      "factor": "severe_or_esrd",
      "met": false
    },
    {
      "factor": "age_lt_77",
      "met": true
    }
  ],
  "risk": "high",
  "age_lt_77": true,
  "ed_visits_12mo": 0,
  "ed_visits_band": "lt_2",
  "figure2_option": 1,
  "insulin": false,
  "prior_hypo_band": "ge_3",
  "prior_hypo_ed_hospital_count": 3,
  "rate_band": ">5%",
  "severe_or_esrd": false,
  "sulfonylurea": false
}
```

## Errors

- HTTP 400 `invalid_prior_hypo_count`: prior_hypo_ed_hospital_count must be an integer from 0 to 20 (Karter 2017 prior hypoglycemia-related ED or hospital episodes). Returned before settlement; you are not charged.
- HTTP 400 `invalid_ed_visits_12mo`: ed_visits_12mo must be an integer from 0 to 50 (Karter 2017 ED encounters for any reason in the prior 12 months). 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

- [Bang diabetes screening](https://magentlab.com/docs/ada-diabetes) — Sum the Bang 2009 Table 2 development screening score for undiagnosed diabetes and return high_risk when the total is ≥5.
- [DKA-MPM](https://magentlab.com/docs/dka-mpm) — Sum the Efstathiou 2002 DKA-MPM flags (max 25) and return the published in-hospital death percents only for scores 0–14 (0.86%) and 19–25 (93.3%).

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