Electrolytes / glucose · LIVE
Karter hypoglycemia risk score
Hypoglycemia risk score
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.
Markdown: /docs/hypoglycemia-risk-score.md · Canonical: https://magentlab.com/docs/hypoglycemia-risk-score
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
- Authors
- Karter AJ, Warton EM, Lipska KJ, Ralston JD, Moffet HH, Jackson GG, Huang ES, Miller DR
- Source
- JAMA Intern Med. 2017;177(10):1461-1470
Worked example
Three prior hypoglycemia-related utilizations, high
Given:
age_lt_77=trueed_visits_12mo=0insulin=falseprior_hypo_ed_hospital_count=3severe_or_esrd=falsesulfonylurea=false
- prior_hypo_ed_hospital_count is 3 (>=3 band)
- Figure 2 option 1 matches regardless of insulin, sulfonylurea, ED visits, kidney disease, or age
- first-match is high (>5% 12-month hypoglycemia-related ED/hospital use)
One or two prior episodes without insulin, intermediate
Given:
age_lt_77=trueed_visits_12mo=0insulin=falseprior_hypo_ed_hospital_count=1severe_or_esrd=falsesulfonylurea=false
- prior_hypo_ed_hospital_count is 1 (1-2 band) and insulin is false
- options 1-2 do not match; Figure 2 option 3 matches
- first-match is intermediate (1-5%)
No prior episodes, no insulin or sulfonylurea, low
Given:
age_lt_77=trueed_visits_12mo=0insulin=falseprior_hypo_ed_hospital_count=0severe_or_esrd=falsesulfonylurea=false
- prior_hypo_ed_hospital_count is 0, insulin and sulfonylurea are false
- options 1-5 do not match; Figure 2 option 6 is the remainder
- 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
Try
Opens the live endpoint. Unpaid browser requests show the paywall; agents should send Accept: application/json.
Full URL: https://api.magentlab.com/api/calc/hypoglycemia_risk_score?prior_hypo_ed_hospital_count=3&ed_visits_12mo=0&insulin=false&sulfonylurea=false&severe_or_esrd=false&age_lt_77=true
Call
Expect HTTP 402 until you retry with PAYMENT-SIGNATURE. Incomplete query params
return HTTP 400 before any quote or charge.
curl -i -H "Accept: application/json" "https://api.magentlab.com/api/calc/hypoglycemia_risk_score?prior_hypo_ed_hospital_count=3&ed_visits_12mo=0&insulin=false&sulfonylurea=false&severe_or_esrd=false&age_lt_77=true"
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
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.
- 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 (fixture)
{
"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"
}
]
}
Opens a two-item fixture on the API host. Unpaid browsers get the same MetaMask paywall as GET; Pay retries POST with those items.
Example 200 (fixture)
{
"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
| Field | Type | Description |
|---|---|---|
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
Machine form of the same example. Frozen fixture. Not a live lookup.
{
"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
}
Client errors (HTTP 400)
Invalid params return 400 without charge. Shared HTTP 402 and 503 meanings: Payments.
| HTTP | Code | When |
|---|---|---|
| 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. |
| 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. |
| 400 | invalid_flag |
boolean clinical flags must be true or false Returned before settlement; you are not charged. |
| 400 | invalid_items |
POST body must be a JSON object with only an items array Returned before settlement; you are not charged. |
| 400 | invalid_item_count |
items must be an array of 1 to 25 objects Returned before settlement; you are not charged. |
| 400 | invalid_item |
each items entry must be a JSON object Returned before settlement; you are not charged. |
Related tools
- Bang diabetes screening — Sum the Bang 2009 Table 2 development screening score for undiagnosed diabetes and return high_risk when the total is ≥5.
- 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. Unpaid valid requests return HTTP 402 with a base64
PAYMENT-REQUIRED
header. HTTP 503 is not a new quote: retry the same PAYMENT-SIGNATURE. Full handshake
and shared payment errors: Payments.
Stdio MCP: /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.