MAGENT

GI · LIVE

Early diagnosis of acute pancreatitis (Jin)

Jin AP prediction

Sum the Jin 2018 integer-point items for ED patients with lipase ≥3× ULN and return the published ≥8 high-PPV cut and the Jin 2024 ≥6 accuracy cut.

LIVE $0.005 USDC GET /api/calc/ap_prediction

Markdown: /docs/ap-prediction.md · Canonical: https://magentlab.com/docs/ap-prediction

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

What it computes

Sum the Jin 2018 integer-point items for ED patients with lipase ≥3× ULN and return the published ≥8 high-PPV cut and the Jin 2024 ≥6 accuracy cut.

When to use

When an agent already has lipase ≥3× ULN plus the published history and pain tokens and needs the Jin 2018 point total, not Ranson, BISAP, Glasgow-Imrie, a diagnosis, or an imaging order.

When not to use

  • Not a medical device. Not a diagnosis of acute pancreatitis. Not an imaging order. magent does not diagnose pancreatitis.
  • Population is ED patients with serum lipase ≥3× ULN (Jin 2018). Lipase below 3× ULN is rejected.
  • Not Ranson, not BISAP, and not Glasgow-Imrie. This tool is the Jin 2018 integer point score only.
  • jin2018_high_ppv is the Jin 2018 diagnostic-risk cut (score ≥8; ≥99% estimated AP risk in that paper). jin2024_accuracy_cut is the Jin 2024 prospective-validation accuracy cut of that same score (score ≥6). magent does not invent other named bands.
  • Caller assigns prior-episode, pain, surgery, and cholelithiasis tokens. magent does not take a history or examine the patient.

Formula

AP prediction = prior_ap_episodes (0→0, 1→1, 2→2, 3→3, 4_or_more→4) + cholelithiasis (true +2) + abdominal_surgery_2mo (true -2) + epigastric_pain (true +2) + worsening_pain (true +1) + pain_duration_days (lt_5 0, gte_5 -1) + pain_severity (mild_0_3 0, moderate_4_6 +2, severe_7_10 +3) + lipase_uln_fold (≥3 and <10 → 0, ≥10 and <20 → +1, ≥20 → +2); Jin 2018; max 14; jin2018_high_ppv iff score ≥ 8; jin2024_accuracy_cut iff score ≥ 6

Citation

Title
A Clinical Model for the Early Diagnosis of Acute Pancreatitis in the Emergency Department
Authors
Jin DX, McNabb-Baltar J, Suleiman SL, Wu BU, Khorasani R, Bollen TL, et al.
Source
Pancreas. 2018;47(7):871-879
DOI
10.1097/MPA.0000000000001102

Worked example

All lowest tokens and lipase 4× ULN

Given: abdominal_surgery_2mo=falsecholelithiasis=falseepigastric_pain=falselipase_uln_fold=4pain_duration_days=lt_5pain_severity=mild_0_3prior_ap_episodes=0worsening_pain=false

  1. prior 0, no stones, no surgery, no epigastric, not worsening, duration lt_5, mild_0_3, lipase 4× ULN
  2. Score = 0 (max 14); jin2018_high_ppv false; jin2024_accuracy_cut false

Prior 1 and cholelithiasis

Given: abdominal_surgery_2mo=falsecholelithiasis=trueepigastric_pain=falselipase_uln_fold=4pain_duration_days=lt_5pain_severity=mild_0_3prior_ap_episodes=1worsening_pain=false

  1. prior_ap_episodes 1 → +1; cholelithiasis true → +2; remaining items 0
  2. Score = 3 (max 14); jin2018_high_ppv false; jin2024_accuracy_cut false

Jin 2018 high-PPV cut

Given: abdominal_surgery_2mo=falsecholelithiasis=trueepigastric_pain=truelipase_uln_fold=4pain_duration_days=lt_5pain_severity=mild_0_3prior_ap_episodes=4_or_moreworsening_pain=false

  1. prior 4_or_more → +4; cholelithiasis → +2; epigastric_pain → +2
  2. Score = 8 (max 14); jin2018_high_ppv true; jin2024_accuracy_cut true

Also searched as

  • Jin pancreatitis score
  • acute pancreatitis prediction
  • ED lipase pancreatitis score
  • Jin 2018 acute pancreatitis
  • early diagnosis pancreatitis ED
  • lipase 3 times ULN

Try

Opens the live endpoint. Unpaid browser requests show the paywall; agents should send Accept: application/json.

/api/calc/ap_prediction?prior_ap_episodes=0&cholelithiasis=false&abdominal_surgery_2mo=false&epigastric_pain=false&worsening_pain=false&pain_duration_days=lt_5&pain_severity=mild_0_3&lipase_uln_fold=4

Full URL: https://api.magentlab.com/api/calc/ap_prediction?prior_ap_episodes=0&cholelithiasis=false&abdominal_surgery_2mo=false&epigastric_pain=false&worsening_pain=false&pain_duration_days=lt_5&pain_severity=mild_0_3&lipase_uln_fold=4

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/ap_prediction?prior_ap_episodes=0&cholelithiasis=false&abdominal_surgery_2mo=false&epigastric_pain=false&worsening_pain=false&pain_duration_days=lt_5&pain_severity=mild_0_3&lipase_uln_fold=4"

Parameters

Name Type Required Description
prior_ap_episodes string required · 0, 1, 2, 3, 4_or_more Caller-assigned prior acute-pancreatitis episode token (Jin 2018). 0 scores 0; 1 scores 1; 2 scores 2; 3 scores 3; 4_or_more scores 4. magent does not take a history.
cholelithiasis boolean required Caller-assigned cholelithiasis (Jin 2018). true scores +2; false scores 0. magent does not read imaging.
abdominal_surgery_2mo boolean required Caller-assigned abdominal surgery within 2 months (Jin 2018). true scores -2; false scores 0.
epigastric_pain boolean required Caller-assigned epigastric pain (Jin 2018). true scores +2; false scores 0. magent does not examine the patient.
worsening_pain boolean required Caller-assigned worsening pain (Jin 2018). true scores +1; false scores 0.
pain_duration_days string required · lt_5, gte_5 Caller-assigned pain-duration token (Jin 2018). lt_5 (<5 days) scores 0; gte_5 (≥5 days) scores -1. magent does not take a history.
pain_severity string required · mild_0_3, moderate_4_6, severe_7_10 Caller-assigned pain-severity token (Jin 2018). mild_0_3 (0-3) scores 0; moderate_4_6 (4-6) scores +2; severe_7_10 (7-10) scores +3. magent does not assign a pain scale.
lipase_uln_fold number required Serum lipase as a fold of the laboratory ULN. Population is lipase ≥3× ULN (Jin 2018). ≥3 and <10 scores 0; ≥10 and <20 scores +1; ≥20 scores +2. Below 3 is invalid_ap_prediction.

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.

POST /api/calc/ap_prediction Max 25 unit_amount + extra_item_amount * (n - 1) extra $0.002 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 (fixture)

{
  "items": [
    {
      "abdominal_surgery_2mo": "false",
      "cholelithiasis": "false",
      "epigastric_pain": "false",
      "lipase_uln_fold": "4",
      "pain_duration_days": "lt_5",
      "pain_severity": "mild_0_3",
      "prior_ap_episodes": "0",
      "worsening_pain": "false"
    },
    {
      "abdominal_surgery_2mo": "false",
      "cholelithiasis": "false",
      "epigastric_pain": "false",
      "lipase_uln_fold": "4",
      "pain_duration_days": "lt_5",
      "pain_severity": "mild_0_3",
      "prior_ap_episodes": "0",
      "worsening_pain": "false"
    }
  ]
}

Open bulk paywall →

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/ap_prediction",
  "items": [
    {
      "components": [
        {
          "value": "0",
          "factor": "prior_ap_episodes",
          "points": 0,
          "present": true
        },
        {
          "factor": "cholelithiasis",
          "points": 0,
          "present": false
        },
        {
          "factor": "abdominal_surgery_2mo",
          "points": 0,
          "present": false
        },
        {
          "factor": "epigastric_pain",
          "points": 0,
          "present": false
        },
        {
          "factor": "worsening_pain",
          "points": 0,
          "present": false
        },
        {
          "value": "lt_5",
          "factor": "pain_duration_days",
          "points": 0,
          "present": true
        },
        {
          "value": "mild_0_3",
          "factor": "pain_severity",
          "points": 0,
          "present": true
        },
        {
          "value": 4.0,
          "factor": "lipase_uln_fold",
          "points": 0,
          "present": true
        }
      ],
      "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": "Jin DX, McNabb-Baltar J, Suleiman SL, Wu BU, Khorasani R, Bollen TL, et al.",
        "doi": "10.1097/MPA.0000000000001102",
        "id": "jin-2018",
        "pmid": "29975351",
        "source": "Pancreas. 2018;47(7):871-879",
        "title": "A Clinical Model for the Early Diagnosis of Acute Pancreatitis in the Emergency Department"
      },
      "formula": "ap_prediction",
      "formula_expression": "AP prediction = prior_ap_episodes (0→0, 1→1, 2→2, 3→3, 4_or_more→4) + cholelithiasis (true +2) + abdominal_surgery_2mo (true -2) + epigastric_pain (true +2) + worsening_pain (true +1) + pain_duration_days (lt_5 0, gte_5 -1) + pain_severity (mild_0_3 0, moderate_4_6 +2, severe_7_10 +3) + lipase_uln_fold (≥3 and <10 → 0, ≥10 and <20 → +1, ≥20 → +2); Jin 2018; max 14; jin2018_high_ppv iff score ≥ 8; jin2024_accuracy_cut iff score ≥ 6",
      "max_score": 14,
      "score": 0,
      "jin2018_high_ppv": false,
      "jin2024_accuracy_cut": false
    },
    {
      "components": [
        {
          "value": "0",
          "factor": "prior_ap_episodes",
          "points": 0,
          "present": true
        },
        {
          "factor": "cholelithiasis",
          "points": 0,
          "present": false
        },
        {
          "factor": "abdominal_surgery_2mo",
          "points": 0,
          "present": false
        },
        {
          "factor": "epigastric_pain",
          "points": 0,
          "present": false
        },
        {
          "factor": "worsening_pain",
          "points": 0,
          "present": false
        },
        {
          "value": "lt_5",
          "factor": "pain_duration_days",
          "points": 0,
          "present": true
        },
        {
          "value": "mild_0_3",
          "factor": "pain_severity",
          "points": 0,
          "present": true
        },
        {
          "value": 4.0,
          "factor": "lipase_uln_fold",
          "points": 0,
          "present": true
        }
      ],
      "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": "Jin DX, McNabb-Baltar J, Suleiman SL, Wu BU, Khorasani R, Bollen TL, et al.",
        "doi": "10.1097/MPA.0000000000001102",
        "id": "jin-2018",
        "pmid": "29975351",
        "source": "Pancreas. 2018;47(7):871-879",
        "title": "A Clinical Model for the Early Diagnosis of Acute Pancreatitis in the Emergency Department"
      },
      "formula": "ap_prediction",
      "formula_expression": "AP prediction = prior_ap_episodes (0→0, 1→1, 2→2, 3→3, 4_or_more→4) + cholelithiasis (true +2) + abdominal_surgery_2mo (true -2) + epigastric_pain (true +2) + worsening_pain (true +1) + pain_duration_days (lt_5 0, gte_5 -1) + pain_severity (mild_0_3 0, moderate_4_6 +2, severe_7_10 +3) + lipase_uln_fold (≥3 and <10 → 0, ≥10 and <20 → +1, ≥20 → +2); Jin 2018; max 14; jin2018_high_ppv iff score ≥ 8; jin2024_accuracy_cut iff score ≥ 6",
      "max_score": 14,
      "score": 0,
      "jin2018_high_ppv": false,
      "jin2024_accuracy_cut": false
    }
  ]
}

Response

Field Type Description
formula string ap_prediction
formula_expression string Exact expression used
score integer Jin 2018 integer points (max 14)
max_score integer 14
jin2018_high_ppv boolean True when score ≥ 8 (Jin 2018 diagnostic-risk cut; ≥99% estimated AP risk in that paper). Not a diagnosis.
jin2024_accuracy_cut boolean True when score ≥ 6 (Jin 2024 prospective validation highest-accuracy cut of this same score). Not a diagnosis.
components array Per-item Jin 2018 points
citation object Jin et al. Pancreas 2018 citation
disclaimer string Not-a-device notice

Example JSON

Machine form of the same example. Frozen fixture. Not a live lookup.

{
  "components": [
    {
      "value": "0",
      "factor": "prior_ap_episodes",
      "points": 0,
      "present": true
    },
    {
      "factor": "cholelithiasis",
      "points": 0,
      "present": false
    },
    {
      "factor": "abdominal_surgery_2mo",
      "points": 0,
      "present": false
    },
    {
      "factor": "epigastric_pain",
      "points": 0,
      "present": false
    },
    {
      "factor": "worsening_pain",
      "points": 0,
      "present": false
    },
    {
      "value": "lt_5",
      "factor": "pain_duration_days",
      "points": 0,
      "present": true
    },
    {
      "value": "mild_0_3",
      "factor": "pain_severity",
      "points": 0,
      "present": true
    },
    {
      "value": 4.0,
      "factor": "lipase_uln_fold",
      "points": 0,
      "present": true
    }
  ],
  "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": "Jin DX, McNabb-Baltar J, Suleiman SL, Wu BU, Khorasani R, Bollen TL, et al.",
    "doi": "10.1097/MPA.0000000000001102",
    "id": "jin-2018",
    "pmid": "29975351",
    "source": "Pancreas. 2018;47(7):871-879",
    "title": "A Clinical Model for the Early Diagnosis of Acute Pancreatitis in the Emergency Department"
  },
  "formula": "ap_prediction",
  "formula_expression": "AP prediction = prior_ap_episodes (0→0, 1→1, 2→2, 3→3, 4_or_more→4) + cholelithiasis (true +2) + abdominal_surgery_2mo (true -2) + epigastric_pain (true +2) + worsening_pain (true +1) + pain_duration_days (lt_5 0, gte_5 -1) + pain_severity (mild_0_3 0, moderate_4_6 +2, severe_7_10 +3) + lipase_uln_fold (≥3 and <10 → 0, ≥10 and <20 → +1, ≥20 → +2); Jin 2018; max 14; jin2018_high_ppv iff score ≥ 8; jin2024_accuracy_cut iff score ≥ 6",
  "max_score": 14,
  "score": 0,
  "jin2018_high_ppv": false,
  "jin2024_accuracy_cut": false
}

Client errors (HTTP 400)

Invalid params return 400 without charge. Shared HTTP 402 and 503 meanings: Payments.

HTTP Code When
400 invalid_ap_prediction Acute-pancreatitis prediction inputs must match Jin 2018 prior-episode, surgery, pain, and lipase-fold categories from that paper. 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

  • Ranson — Sum the eleven Ranson 1974 prognostic signs (five at admission, six during the first 48 hours) and return the published mortality band.
  • BISAP — Compute the Wu 2008 BISAP score for early prediction of mortality in acute pancreatitis from BUN, caller-assigned impaired mental status, caller-assigned SIRS, age, and caller-assigned pleural effusion.
  • Glasgow-Imrie — Sum the eight Blamey 1984 Glasgow-Imrie factors and return whether severe pancreatitis is predicted (three or more factors).

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.