# Oakland score (safe discharge after LGIB)

Oakland score

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

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

## What it computes

Sum the Oakland 2017 derivation-table weights for acute lower gastrointestinal bleeding and return safe_discharge (score ≤8) or not_safe (score >8).

## When to use

When an agent needs the published Oakland 2017 point total and must not invent a discharge order, an LGIB diagnosis, or a later validation cutoff.

## When not to use

- Not a medical device and not a discharge order. magent does not examine the rectum or assay hemoglobin.
- Not a diagnosis of lower GI bleeding. This tool returns the published Oakland 2017 point total only.
- dre_blood is blood on digital rectal examination as assigned by the caller. magent does not examine the patient.
- Hemoglobin may be g/dL or g/L (÷ 10). The first published band starts at 3.6 g/dL; values below that after conversion are rejected.
- safe_discharge is score ≤8 from the Oakland 2017 derivation. This is not a later US validation threshold.

## Formula

```
Oakland = age (≤39:0, 40-69:1, ≥70:2) + male 1 + previous_lgib_admission 1 + dre_blood 1 + HR (<70:0, 70-89:1, 90-109:2, ≥110:3) + SBP (50-89:5, 90-119:4, 120-129:3, 130-159:2, ≥160:0) + Hb g/dL (3.6-6.9:22, 7.0-8.9:17, 9.0-10.9:13, 11.0-12.9:8, 13.0-15.9:4, ≥16.0:0); Oakland 2017 derivation; max 35; safe_discharge ≤8
```

## Citation

[Derivation and validation of a novel risk score for safe discharge after acute lower gastrointestinal bleeding: a modelling study](https://doi.org/10.1016/s2468-1253(17)30150-4)
Oakland K, Jairath V, Uberoi R, Guy R, Ayaru L, Mortensen N, Murphy MF, Collins GS
Lancet Gastroenterol Hepatol. 2017;2(9):635-643
DOI: [10.1016/s2468-1253(17)30150-4](https://doi.org/10.1016/s2468-1253(17)30150-4)

## Worked example

### All items in zero bands (score 0, safe_discharge)

Given: `age=35, dre_blood=false, heart_rate_bpm=65, hemoglobin_g_dl=16.5, previous_lgib_admission=false, sex=female, systolic_mm_hg=165`

1. Age 35 ≤39 → 0; female → 0; previous LGIB false → 0; DRE blood false → 0
2. HR 65 <70 → 0; SBP 165 ≥160 → 0; Hb 16.5 g/dL ≥16.0 → 0
3. Score = 0 (max 35); oakland_band = safe_discharge (≤8)


### High-weight bands (score 35, not_safe)

Given: `age=80, dre_blood=true, heart_rate_bpm=110, hemoglobin_g_dl=6.0, previous_lgib_admission=true, sex=male, systolic_mm_hg=80`

1. Age 80 ≥70 → 2; male → 1; previous LGIB → 1; DRE blood → 1
2. HR 110 ≥110 → 3; SBP 80 in 50-89 → 5; Hb 6.0 g/dL in 3.6-6.9 → 22
3. Score = 35 (max 35); oakland_band = not_safe (>8)


## Also searched as

- Oakland score
- Oakland LGIB score
- lower GI bleed discharge score
- Oakland 2017
- acute lower GI bleeding score
- Oakland safe discharge

## Parameters

- `age` (integer, required): Age in years (integer 16-120). Oakland 2017: ≤39 → 0, 40-69 → 1, ≥70 → 2.
- `sex` (string, required): Sex as assigned by the caller. female scores 0; male scores 1.
- `previous_lgib_admission` (boolean, required): Previous admission for lower GI bleeding as assigned by the caller (Oakland 2017). true scores 1.
- `dre_blood` (boolean, required): Blood on digital rectal examination as assigned by the caller (Oakland 2017). true scores 1. magent does not examine the rectum.
- `heart_rate_bpm` (integer, required): Heart rate in beats per minute (integer 30-220). Oakland 2017: <70 → 0, 70-89 → 1, 90-109 → 2, ≥110 → 3.
- `systolic_mm_hg` (number, required): Systolic blood pressure in mm Hg (50-250). Oakland 2017: 50-89 → 5, 90-119 → 4, 120-129 → 3, 130-159 → 2, ≥160 → 0. magent does not read a blood pressure.
- `hemoglobin_g_dl` (number, optional): Hemoglobin in g/dL (3-22). Provide this or hemoglobin_g_l, not both. Oakland 2017 bands start at 3.6 g/dL: 3.6-6.9 → 22, 7.0-8.9 → 17, 9.0-10.9 → 13, 11.0-12.9 → 8, 13.0-15.9 → 4, ≥16.0 → 0. Values <3.6 after conversion are rejected. magent does not assay hemoglobin.
- `hemoglobin_g_l` (number, optional): Hemoglobin in g/L (30-220). Converted as hemoglobin_g_dl = hemoglobin_g_l / 10. Provide this or hemoglobin_g_dl, not both. Values <3.6 g/dL after conversion are rejected.

## 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/oakland`
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": "35",
      "dre_blood": "false",
      "heart_rate_bpm": "65",
      "hemoglobin_g_dl": "16.5",
      "previous_lgib_admission": "false",
      "sex": "female",
      "systolic_mm_hg": "165"
    },
    {
      "age": "35",
      "dre_blood": "false",
      "heart_rate_bpm": "65",
      "hemoglobin_g_dl": "16.5",
      "previous_lgib_admission": "false",
      "sex": "female",
      "systolic_mm_hg": "165"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/oakland",
  "items": [
    {
      "components": [
        {
          "value": 35,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "value": "female",
          "factor": "sex",
          "points": 0,
          "present": false
        },
        {
          "factor": "previous_lgib_admission",
          "points": 0,
          "present": false
        },
        {
          "factor": "dre_blood",
          "points": 0,
          "present": false
        },
        {
          "value": 65,
          "factor": "heart_rate",
          "points": 0,
          "present": false
        },
        {
          "value": 165.0,
          "factor": "systolic",
          "points": 0,
          "present": false
        },
        {
          "value": 16.5,
          "factor": "hemoglobin",
          "points": 0,
          "present": 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": "Oakland K, Jairath V, Uberoi R, Guy R, Ayaru L, Mortensen N, Murphy MF, Collins GS",
        "doi": "10.1016/s2468-1253(17)30150-4",
        "id": "oakland-2017",
        "pmid": "28651935",
        "source": "Lancet Gastroenterol Hepatol. 2017;2(9):635-643",
        "title": "Derivation and validation of a novel risk score for safe discharge after acute lower gastrointestinal bleeding: a modelling study"
      },
      "formula": "oakland",
      "formula_expression": "Oakland = age (≤39:0, 40-69:1, ≥70:2) + male 1 + previous_lgib_admission 1 + dre_blood 1 + HR (<70:0, 70-89:1, 90-109:2, ≥110:3) + SBP (50-89:5, 90-119:4, 120-129:3, 130-159:2, ≥160:0) + Hb g/dL (3.6-6.9:22, 7.0-8.9:17, 9.0-10.9:13, 11.0-12.9:8, 13.0-15.9:4, ≥16.0:0); Oakland 2017 derivation; max 35; safe_discharge ≤8",
      "max_score": 35,
      "score": 0,
      "age_years": 35,
      "systolic_mm_hg": 165.0,
      "sex": "female",
      "heart_rate_bpm": 65,
      "hemoglobin_g_dl": 16.5,
      "dre_blood": false,
      "oakland_band": "safe_discharge",
      "previous_lgib_admission": false
    },
    {
      "components": [
        {
          "value": 35,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "value": "female",
          "factor": "sex",
          "points": 0,
          "present": false
        },
        {
          "factor": "previous_lgib_admission",
          "points": 0,
          "present": false
        },
        {
          "factor": "dre_blood",
          "points": 0,
          "present": false
        },
        {
          "value": 65,
          "factor": "heart_rate",
          "points": 0,
          "present": false
        },
        {
          "value": 165.0,
          "factor": "systolic",
          "points": 0,
          "present": false
        },
        {
          "value": 16.5,
          "factor": "hemoglobin",
          "points": 0,
          "present": 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": "Oakland K, Jairath V, Uberoi R, Guy R, Ayaru L, Mortensen N, Murphy MF, Collins GS",
        "doi": "10.1016/s2468-1253(17)30150-4",
        "id": "oakland-2017",
        "pmid": "28651935",
        "source": "Lancet Gastroenterol Hepatol. 2017;2(9):635-643",
        "title": "Derivation and validation of a novel risk score for safe discharge after acute lower gastrointestinal bleeding: a modelling study"
      },
      "formula": "oakland",
      "formula_expression": "Oakland = age (≤39:0, 40-69:1, ≥70:2) + male 1 + previous_lgib_admission 1 + dre_blood 1 + HR (<70:0, 70-89:1, 90-109:2, ≥110:3) + SBP (50-89:5, 90-119:4, 120-129:3, 130-159:2, ≥160:0) + Hb g/dL (3.6-6.9:22, 7.0-8.9:17, 9.0-10.9:13, 11.0-12.9:8, 13.0-15.9:4, ≥16.0:0); Oakland 2017 derivation; max 35; safe_discharge ≤8",
      "max_score": 35,
      "score": 0,
      "age_years": 35,
      "systolic_mm_hg": 165.0,
      "sex": "female",
      "heart_rate_bpm": 65,
      "hemoglobin_g_dl": 16.5,
      "dre_blood": false,
      "oakland_band": "safe_discharge",
      "previous_lgib_admission": false
    }
  ]
}
```

## Response fields

- `formula` (string): oakland
- `formula_expression` (string): Exact expression used
- `score` (integer): Oakland points 0-35
- `max_score` (integer): Always 35
- `oakland_band` (string): safe_discharge when score ≤8, not_safe when score >8 (Oakland 2017 derivation cutoff). Not a discharge order.
- `age_years` (integer): Age used (years)
- `sex` (string): Sex used: male or female
- `previous_lgib_admission` (boolean): Caller-assigned previous LGIB admission flag used
- `dre_blood` (boolean): Caller-assigned blood on digital rectal examination flag used
- `heart_rate_bpm` (integer): Heart rate used (bpm)
- `systolic_mm_hg` (number): Systolic blood pressure used (mm Hg)
- `hemoglobin_g_dl` (number): Hemoglobin used in g/dL (g/L inputs converted as g/dL = g/L / 10)
- `components` (array): Per-factor points
- `citation` (object): Oakland 2017 Lancet Gastroenterol Hepatol citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "components": [
    {
      "value": 35,
      "factor": "age",
      "points": 0,
      "present": false
    },
    {
      "value": "female",
      "factor": "sex",
      "points": 0,
      "present": false
    },
    {
      "factor": "previous_lgib_admission",
      "points": 0,
      "present": false
    },
    {
      "factor": "dre_blood",
      "points": 0,
      "present": false
    },
    {
      "value": 65,
      "factor": "heart_rate",
      "points": 0,
      "present": false
    },
    {
      "value": 165.0,
      "factor": "systolic",
      "points": 0,
      "present": false
    },
    {
      "value": 16.5,
      "factor": "hemoglobin",
      "points": 0,
      "present": 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": "Oakland K, Jairath V, Uberoi R, Guy R, Ayaru L, Mortensen N, Murphy MF, Collins GS",
    "doi": "10.1016/s2468-1253(17)30150-4",
    "id": "oakland-2017",
    "pmid": "28651935",
    "source": "Lancet Gastroenterol Hepatol. 2017;2(9):635-643",
    "title": "Derivation and validation of a novel risk score for safe discharge after acute lower gastrointestinal bleeding: a modelling study"
  },
  "formula": "oakland",
  "formula_expression": "Oakland = age (≤39:0, 40-69:1, ≥70:2) + male 1 + previous_lgib_admission 1 + dre_blood 1 + HR (<70:0, 70-89:1, 90-109:2, ≥110:3) + SBP (50-89:5, 90-119:4, 120-129:3, 130-159:2, ≥160:0) + Hb g/dL (3.6-6.9:22, 7.0-8.9:17, 9.0-10.9:13, 11.0-12.9:8, 13.0-15.9:4, ≥16.0:0); Oakland 2017 derivation; max 35; safe_discharge ≤8",
  "max_score": 35,
  "score": 0,
  "age_years": 35,
  "systolic_mm_hg": 165.0,
  "sex": "female",
  "heart_rate_bpm": 65,
  "hemoglobin_g_dl": 16.5,
  "dre_blood": false,
  "oakland_band": "safe_discharge",
  "previous_lgib_admission": false
}
```

## Errors

- HTTP 400 `invalid_oakland_age`: age must be an integer from 16 to 120 (Oakland 2017 acute lower GI bleeding). Returned before settlement; you are not charged.
- HTTP 400 `invalid_sex`: sex must be female or male 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_heart_rate`: heart_rate_bpm must be an integer from 30 to 220 Returned before settlement; you are not charged.
- HTTP 400 `invalid_systolic_bp`: systolic_mm_hg or systolic_bp_mm_hg must be a number from 50 to 250. Returned before settlement; you are not charged.
- HTTP 400 `invalid_hemoglobin`: hemoglobin_g_l (30-220) or hemoglobin_g_dl (3-22) is required, not both. 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-Blatchford score](https://magentlab.com/docs/glasgow-blatchford) — Compute the Blatchford 2000 Glasgow-Blatchford score from urea, haemoglobin, systolic BP, heart rate, and four clinical flags.
- [AIMS65](https://magentlab.com/docs/aims65) — Compute the Saltzman 2011 AIMS65 score for in-hospital mortality in acute upper GI bleeding from albumin, INR, caller-assigned altered mental status, systolic blood pressure, and age.
- [Rockall](https://magentlab.com/docs/rockall) — Compute the Rockall 1996 complete (post-endoscopy) score from age, heart rate, systolic blood pressure, caller-assigned comorbidity, diagnosis, and stigmata of recent haemorrhage after acute upper gastrointestinal haemorrhage.

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