Infection / VTE · LIVE
COVID-GRAM critical illness
COVID-GRAM
Compute the Liang 2020 COVID-GRAM logistic probability of critical illness (ICU admission, invasive ventilation, or death) among hospitalized COVID-19 from age, a caller-assigned chest radiograph abnormality, hemoptysis, dyspnea, unconsciousness, comorbidity count, cancer history, neutrophil-to-lymphocyte ratio, LDH, and direct bilirubin.
Markdown: /docs/covid-gram.md · Canonical: https://magentlab.com/docs/covid-gram
Not a medical device. Not a diagnosis, dose, or listing recommendation.
What it computes
Compute the Liang 2020 COVID-GRAM logistic probability of critical illness (ICU admission, invasive ventilation, or death) among hospitalized COVID-19 from age, a caller-assigned chest radiograph abnormality, hemoptysis, dyspnea, unconsciousness, comorbidity count, cancer history, neutrophil-to-lymphocyte ratio, LDH, and direct bilirubin.
When to use
When an agent already has admission-time age, a caller-assigned chest radiograph flag, symptoms, comorbidity count, cancer history, NLR, LDH in U/L, and direct bilirubin in umol/L, and needs the published Liang 2020 Table 3 probability, not 4C, PRIEST, CHOSEN, or VACO.
When not to use
- Not a medical device and not a diagnosis. Not an ICU-allocation, triage, ventilation, or treatment order.
- magent does not read the chest radiograph or count comorbidities. chest_xray_abnormal and number_of_comorbidities are caller-assigned.
- Liang 2020 comorbidity count is COPD, diabetes, hypertension, cardiovascular disease, cerebrovascular disease, hepatitis B, cancer, chronic kidney disease, and immunodeficiency. Cancer history is a separate Table 3 term.
- Liang 2020 Table 3 prints odds ratios (constant 0.001). magent uses the matching logistic coefficients. The paper deliberately did not categorize low-, moderate-, and high-risk groups.
- Derivation used early-pandemic hospitalized patients in China. Liang 2020 publishes no later-wave recalibration.
Formula
lp = 1.2205*chest_xray_abnormal + 0.0276*age + 1.5116*hemoptysis + 0.632*dyspnea + 1.5494*unconsciousness + 0.4668*number_of_comorbidities + 1.4037*cancer_history + 0.0562*nlr + 0.0024*ldh_u_l + 0.1376*direct_bilirubin_umol_l - 6.6127; probability = exp(lp)/(1+exp(lp)); Liang 2020 Table 3 logistic (printed ORs; intercept -6.6127 matches constant 0.001); critical illness = ICU, invasive ventilation, or death; LDH U/L; direct bilirubin umol/L; magent does not read the chest film or count comorbidities; Liang 2020 did not publish low/medium/high cutoffs
Citation
- Authors
- Liang W, Liang H, Ou L, Chen B, Chen A, Li C, et al.
- Source
- JAMA Intern Med. 2020;180(8):1081-1089
Worked example
Age 30, no flags, NLR 2.0, LDH 150, direct bilirubin 3.0
Given:
age=30cancer_history=falsechest_xray_abnormal=falsedirect_bilirubin_umol_l=3.0dyspnea=falsehemoptysis=falseldh_u_l=150nlr=2.0number_of_comorbidities=0unconsciousness=false
- all flags false; comorbidities 0; age 30; nlr 2.0; ldh 150 U/L; direct bilirubin 3.0 umol/L
- lp = 0.0276*30 + 0.0562*2.0 + 0.0024*150 + 0.1376*3.0 - 6.6127 = -4.8995
- estimated_probability_percent = 100 * exp(lp)/(1+exp(lp)), 1 decimal
Age 70, otherwise the age-30 example
Given:
age=70cancer_history=falsechest_xray_abnormal=falsedirect_bilirubin_umol_l=3.0dyspnea=falsehemoptysis=falseldh_u_l=150nlr=2.0number_of_comorbidities=0unconsciousness=false
- same flags and labs as the age-30 example; age term 0.0276*70
- lp = 0.0276*70 + 0.0562*2.0 + 0.0024*150 + 0.1376*3.0 - 6.6127 = -3.7955
- estimated_probability_percent from the unrounded logit, 1 decimal
Also searched as
- COVID-GRAM
- Liang COVID-19 risk score
- COVID critical illness score
- hospitalized COVID-19 GRAM
- Liang 2020 critical illness
- COVID-GRAM logistic
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/cgram?age=30&chest_xray_abnormal=false&hemoptysis=false&dyspnea=false&unconsciousness=false&number_of_comorbidities=0&cancer_history=false&nlr=2.0&ldh_u_l=150&direct_bilirubin_umol_l=3.0
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/cgram?age=30&chest_xray_abnormal=false&hemoptysis=false&dyspnea=false&unconsciousness=false&number_of_comorbidities=0&cancer_history=false&nlr=2.0&ldh_u_l=150&direct_bilirubin_umol_l=3.0"
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
age |
integer | required | Age in years (integer 1-120). Liang 2020 Table 3: +0.0276 per year (OR 1.03 per year). Development cohort ages 1-95. |
chest_xray_abnormal |
boolean | required | Chest radiograph abnormality as assigned by the caller (true or false). Liang 2020 Table 3: true adds 1.2205 (OR 3.39). magent does not read the film. |
hemoptysis |
boolean | required | Hemoptysis as assigned by the caller (true or false). Liang 2020 Table 3: true adds 1.5116 (OR 4.53). |
dyspnea |
boolean | required | Dyspnea (shortness of breath) as assigned by the caller (true or false). Liang 2020 Table 3: true adds 0.632 (OR 1.88). |
unconsciousness |
boolean | required | Unconsciousness as assigned by the caller (true or false). Liang 2020 Table 3: true adds 1.5494 (OR 4.71). |
number_of_comorbidities |
integer | required | Caller-assigned count of comorbidities as Liang 2020 defined (integer 0-10): COPD, diabetes, hypertension, cardiovascular disease, cerebrovascular disease, hepatitis B, cancer, chronic kidney disease, immunodeficiency. Table 3: +0.4668 per comorbidity (OR 1.60). magent does not count diagnoses. |
cancer_history |
boolean | required | Cancer history as assigned by the caller (true or false). Liang 2020 Table 3: true adds 1.4037 (OR 4.07), separate from the comorbidity count. |
nlr |
number | required | Neutrophil-to-lymphocyte ratio (0.01-200). Liang 2020 Table 3: +0.0562 per unit (OR 1.06). Caller assigns the ratio; magent does not compute it from counts. |
ldh_u_l |
number | required | Lactate dehydrogenase in U/L (1-5000). Liang 2020 Table 3: +0.0024 per U/L (OR 1.002). magent does not convert other LDH units. |
direct_bilirubin_umol_l |
number | required | Direct bilirubin in umol/L (0-200). Liang 2020 Table 3: +0.1376 per umol/L (OR 1.15). magent does not convert mg/dL. |
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": "30",
"cancer_history": "false",
"chest_xray_abnormal": "false",
"direct_bilirubin_umol_l": "3.0",
"dyspnea": "false",
"hemoptysis": "false",
"ldh_u_l": "150",
"nlr": "2.0",
"number_of_comorbidities": "0",
"unconsciousness": "false"
},
{
"age": "30",
"cancer_history": "false",
"chest_xray_abnormal": "false",
"direct_bilirubin_umol_l": "3.0",
"dyspnea": "false",
"hemoptysis": "false",
"ldh_u_l": "150",
"nlr": "2.0",
"number_of_comorbidities": "0",
"unconsciousness": "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/cgram",
"items": [
{
"age": 30,
"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": "Liang W, Liang H, Ou L, Chen B, Chen A, Li C, et al.",
"doi": "10.1001/jamainternmed.2020.2033",
"id": "liang-2020-covid-gram",
"pmid": "32396163",
"source": "JAMA Intern Med. 2020;180(8):1081-1089",
"title": "Development and Validation of a Clinical Risk Score to Predict the Occurrence of Critical Illness in Hospitalized Patients With COVID-19"
},
"formula": "covid_gram",
"formula_expression": "lp = 1.2205*chest_xray_abnormal + 0.0276*age + 1.5116*hemoptysis + 0.632*dyspnea + 1.5494*unconsciousness + 0.4668*number_of_comorbidities + 1.4037*cancer_history + 0.0562*nlr + 0.0024*ldh_u_l + 0.1376*direct_bilirubin_umol_l - 6.6127; probability = exp(lp)/(1+exp(lp)); Liang 2020 Table 3 logistic (printed ORs; intercept -6.6127 matches constant 0.001); critical illness = ICU, invasive ventilation, or death; LDH U/L; direct bilirubin umol/L; magent does not read the chest film or count comorbidities; Liang 2020 did not publish low/medium/high cutoffs",
"estimated_probability_percent": 0.7,
"logit": -4.8995,
"cancer_history": false,
"chest_xray_abnormal": false,
"direct_bilirubin_umol_l": 3.0,
"dyspnea": false,
"hemoptysis": false,
"ldh_u_l": 150.0,
"nlr": 2.0,
"number_of_comorbidities": 0,
"unconsciousness": false
},
{
"age": 30,
"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": "Liang W, Liang H, Ou L, Chen B, Chen A, Li C, et al.",
"doi": "10.1001/jamainternmed.2020.2033",
"id": "liang-2020-covid-gram",
"pmid": "32396163",
"source": "JAMA Intern Med. 2020;180(8):1081-1089",
"title": "Development and Validation of a Clinical Risk Score to Predict the Occurrence of Critical Illness in Hospitalized Patients With COVID-19"
},
"formula": "covid_gram",
"formula_expression": "lp = 1.2205*chest_xray_abnormal + 0.0276*age + 1.5116*hemoptysis + 0.632*dyspnea + 1.5494*unconsciousness + 0.4668*number_of_comorbidities + 1.4037*cancer_history + 0.0562*nlr + 0.0024*ldh_u_l + 0.1376*direct_bilirubin_umol_l - 6.6127; probability = exp(lp)/(1+exp(lp)); Liang 2020 Table 3 logistic (printed ORs; intercept -6.6127 matches constant 0.001); critical illness = ICU, invasive ventilation, or death; LDH U/L; direct bilirubin umol/L; magent does not read the chest film or count comorbidities; Liang 2020 did not publish low/medium/high cutoffs",
"estimated_probability_percent": 0.7,
"logit": -4.8995,
"cancer_history": false,
"chest_xray_abnormal": false,
"direct_bilirubin_umol_l": 3.0,
"dyspnea": false,
"hemoptysis": false,
"ldh_u_l": 150.0,
"nlr": 2.0,
"number_of_comorbidities": 0,
"unconsciousness": false
}
]
}
Response
| Field | Type | Description |
|---|---|---|
formula |
string | covid_gram |
formula_expression |
string | Liang 2020 Table 3 logistic linear predictor and probability |
age |
integer | Input age in years |
chest_xray_abnormal |
boolean | Caller-assigned chest radiograph abnormality |
hemoptysis |
boolean | Caller-assigned hemoptysis |
dyspnea |
boolean | Caller-assigned dyspnea |
unconsciousness |
boolean | Caller-assigned unconsciousness |
number_of_comorbidities |
integer | Caller-assigned Liang 2020 comorbidity count |
cancer_history |
boolean | Caller-assigned cancer history |
nlr |
number | Input neutrophil-to-lymphocyte ratio |
ldh_u_l |
number | Input LDH in U/L |
direct_bilirubin_umol_l |
number | Input direct bilirubin in umol/L |
logit |
number | Unrounded linear predictor, 4 decimals |
estimated_probability_percent |
number | Critical-illness percent from the unrounded logit, 1 decimal. A probability, not an ICU order. |
citation |
object | Liang 2020 COVID-GRAM citation |
disclaimer |
string | Not-a-device notice |
Example JSON
Machine form of the same example. Frozen fixture. Not a live lookup.
{
"age": 30,
"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": "Liang W, Liang H, Ou L, Chen B, Chen A, Li C, et al.",
"doi": "10.1001/jamainternmed.2020.2033",
"id": "liang-2020-covid-gram",
"pmid": "32396163",
"source": "JAMA Intern Med. 2020;180(8):1081-1089",
"title": "Development and Validation of a Clinical Risk Score to Predict the Occurrence of Critical Illness in Hospitalized Patients With COVID-19"
},
"formula": "covid_gram",
"formula_expression": "lp = 1.2205*chest_xray_abnormal + 0.0276*age + 1.5116*hemoptysis + 0.632*dyspnea + 1.5494*unconsciousness + 0.4668*number_of_comorbidities + 1.4037*cancer_history + 0.0562*nlr + 0.0024*ldh_u_l + 0.1376*direct_bilirubin_umol_l - 6.6127; probability = exp(lp)/(1+exp(lp)); Liang 2020 Table 3 logistic (printed ORs; intercept -6.6127 matches constant 0.001); critical illness = ICU, invasive ventilation, or death; LDH U/L; direct bilirubin umol/L; magent does not read the chest film or count comorbidities; Liang 2020 did not publish low/medium/high cutoffs",
"estimated_probability_percent": 0.7,
"logit": -4.8995,
"cancer_history": false,
"chest_xray_abnormal": false,
"direct_bilirubin_umol_l": 3.0,
"dyspnea": false,
"hemoptysis": false,
"ldh_u_l": 150.0,
"nlr": 2.0,
"number_of_comorbidities": 0,
"unconsciousness": false
}
Client errors (HTTP 400)
Invalid params return 400 without charge. Shared HTTP 402 and 503 meanings: Payments.
| HTTP | Code | When |
|---|---|---|
| 400 | invalid_covid_gram |
COVID-GRAM inputs must match Liang 2020 age, radiographic abnormality, symptoms, comorbidities, neutrophil-to-lymphocyte ratio, LDH, and direct bilirubin. 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
- 4C — Sum the Knight 2020 ISARIC 4C Mortality Score items and return the published Table 5 band (low, intermediate, high, or very high).
- PRIEST — Sum the Goodacre 2021 PRIEST points from NEWS2 Chart 1 Scale 1 vitals, alertness, inspired oxygen, age, sex, and performance status, and return whether the total is ≤4.
- CHOSEN — Sum the Levine 2020 CHOSEN (COVID Home Safely Now) Figure 2 points from age, oxygen saturation, and serum albumin in g/dL, and return whether the total is at or above the printed cutpoint of 30.
- VACO Index — Compute the King 2020 VACO Index 30-day all-cause mortality probability from age, sex, a caller-assigned unadjusted Charlson comorbidity index, and history of myocardial infarction or peripheral vascular disease using Supplement S3 coefficients.
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.