# Denver HIV risk score

Denver HIV

Status: WEDGE
Price: $0.005 USDC
`GET /api/calc/denver_hiv`
HTML: https://magentlab.com/docs/denver-hiv
Markdown: https://magentlab.com/docs/denver-hiv.md

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

## What it computes

Sum the published Haukoos 2012 Table 2 FULL pruned Denver HIV risk score from caller-assigned age, sex, ethnicity, independent sexual-practice flags, injection drug use, and past HIV testing, and return the derivation-cohort HIV prevalence band.

## When to use

When an agent already has those Haukoos 2012 Table 2 inputs as assigned by the caller and needs the published point total and derivation HIV prevalence band. Not a diagnosis, not an HIV test order, and not the abbreviated score that drops sexual-practice items.

## When not to use

- Not a medical device. Not a diagnosis of HIV infection and not an HIV test, PrEP, nPEP, or antiretroviral order.
- Haukoos 2012 Table 2 FULL pruned model only (age, sex, ethnicity, sex with a male, vaginal intercourse, receptive anal intercourse, injection drug use, past HIV testing). Range -14 to +81. Not the later abbreviated score that omits vaginal intercourse and receptive anal intercourse.
- ethnicity is caller-assigned as black, hispanic, white, or other using the paper's terms (other: American Indian or Alaska Native, Native Hawaiian, or non-Hawaiian Pacific Islander). magent does not assign race or ethnicity.
- Sexual-practice items are independent flags, not mutually exclusive partner-gender choices. magent does not take a sexual history or a substance-use history.
- Band names and derivation HIV percents are from the results paragraph after Table 2 (<20 very_low 0.12%; 20-29 low 0.24%; 30-39 moderate 0.67%; 40-49 high 2.28%; >=50 very_high 5.66%). Validation-cohort percents from the abstract are not this response.
- Age is an integer 18-120 (invalid_age outside that range). Haukoos 2012 enrolled consecutive patients 13 years or older; ages 18-21 score 0 as published for <22.

## Formula

```
Denver HIV (Haukoos 2012 Table 2 FULL pruned) = age (<22 or >60 0; 22-25 or 55-60 4; 26-32 or 47-54 10; 33-46 12) + sex (female 0, male 21) + ethnicity (black 9, hispanic 3, white 0, other 0) + sex_with_male 22 + vaginal_intercourse -10 + receptive_anal_intercourse 8 + injection_drug_use 9 + past_hiv_testing -4; flags independent, not mutually exclusive; range -14 to 81; <20 very_low derivation 0.12%, 20-29 low 0.24%, 30-39 moderate 0.67%, 40-49 high 2.28%, >=50 very_high 5.66%
```

## Citation

[Derivation and Validation of the Denver Human Immunodeficiency Virus (HIV) Risk Score for Targeted HIV Screening](https://doi.org/10.1093/aje/kwr389)
Haukoos JS, Lyons MS, Lindsell CJ, Hopkins E, Bender B, Rothman RE, Hsieh YH, MacLaren LA, Thrun MW, Sasson C, Byyny RL
Am J Epidemiol. 2012;175(8):838-846
DOI: [10.1093/aje/kwr389](https://doi.org/10.1093/aje/kwr389)

## Worked example

### Age 20 female white, all flags false

Given: `age=20, ethnicity=white, injection_drug_use=false, past_hiv_testing=false, receptive_anal_intercourse=false, sex=female, sex_with_male=false, vaginal_intercourse=false`

1. Age 20 is <22 → 0; female → 0; ethnicity white → 0
2. sex_with_male false → 0; vaginal_intercourse false → 0; receptive_anal_intercourse false → 0; injection_drug_use false → 0; past_hiv_testing false → 0
3. Score = 0 (range -14 to +81); band very_low; derivation HIV 0.12%. Not a diagnosis.


### Male only (age 20, white, flags false)

Given: `age=20, ethnicity=white, injection_drug_use=false, past_hiv_testing=false, receptive_anal_intercourse=false, sex=male, sex_with_male=false, vaginal_intercourse=false`

1. Age 20 → 0; male → 21; ethnicity white → 0; remaining flags 0
2. Score = 21; band low; derivation HIV 0.24%. Not a diagnosis.


## Also searched as

- Denver HIV Risk Score
- DHRS
- Haukoos 2012 HIV score
- targeted HIV screening score
- Denver HIV screening index
- full Denver HIV model

## Parameters

- `age` (integer, required): Age in years (integer 18-120). Haukoos 2012 Table 2: <22 or >60 scores 0; 22-25 or 55-60 scores 4; 26-32 or 47-54 scores 10; 33-46 scores 12. Caller-assigned.
- `sex` (string, required): female or male as assigned by the caller (Haukoos 2012 Table 2 gender). female scores 0; male scores 21.
- `ethnicity` (string, required): Caller-assigned ethnicity as used in Haukoos 2012 Table 2 (not param race). black scores 9; hispanic scores 3; white scores 0; other scores 0 (paper: American Indian or Alaska Native, Native Hawaiian, or non-Hawaiian Pacific Islander). magent does not assign race or ethnicity.
- `sex_with_male` (boolean, required): Caller-assigned sex with a male (Haukoos 2012 Table 2). Independent of other sexual-practice flags. true or false. +22 if true. magent does not take a sexual history.
- `vaginal_intercourse` (boolean, required): Caller-assigned vaginal intercourse (Haukoos 2012 Table 2). Independent of other sexual-practice flags. true or false. -10 if true. Do not drop this item. magent does not take a sexual history.
- `receptive_anal_intercourse` (boolean, required): Caller-assigned receptive anal intercourse (Haukoos 2012 Table 2). Independent of other sexual-practice flags. true or false. +8 if true. Do not drop this item. magent does not take a sexual history.
- `injection_drug_use` (boolean, required): Caller-assigned injection drug use (Haukoos 2012 Table 2). true or false. +9 if true. magent does not take a substance-use history.
- `past_hiv_testing` (boolean, required): Caller-assigned past HIV testing (Haukoos 2012 Table 2). true or false. -4 if true. magent does not read a testing history.

## 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/denver_hiv`
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": "20",
      "ethnicity": "white",
      "injection_drug_use": "false",
      "past_hiv_testing": "false",
      "receptive_anal_intercourse": "false",
      "sex": "female",
      "sex_with_male": "false",
      "vaginal_intercourse": "false"
    },
    {
      "age": "20",
      "ethnicity": "white",
      "injection_drug_use": "false",
      "past_hiv_testing": "false",
      "receptive_anal_intercourse": "false",
      "sex": "female",
      "sex_with_male": "false",
      "vaginal_intercourse": "false"
    }
  ]
}
```

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

Example 200:

```json
{
  "count": 2,
  "path": "/api/calc/denver_hiv",
  "items": [
    {
      "band": "very_low",
      "components": [
        {
          "value": 20,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "value": "female",
          "factor": "sex",
          "points": 0,
          "present": false
        },
        {
          "value": "white",
          "factor": "ethnicity",
          "points": 0,
          "present": false
        },
        {
          "factor": "sex_with_male",
          "points": 0,
          "present": false
        },
        {
          "factor": "vaginal_intercourse",
          "points": 0,
          "present": false
        },
        {
          "factor": "receptive_anal_intercourse",
          "points": 0,
          "present": false
        },
        {
          "factor": "injection_drug_use",
          "points": 0,
          "present": false
        },
        {
          "factor": "past_hiv_testing",
          "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.",
      "age_years": 20,
      "citation": {
        "authors": "Haukoos JS, Lyons MS, Lindsell CJ, Hopkins E, Bender B, Rothman RE, Hsieh YH, MacLaren LA, Thrun MW, Sasson C, Byyny RL",
        "doi": "10.1093/aje/kwr389",
        "id": "haukoos-2012-denver-hiv",
        "pmid": "22425121",
        "source": "Am J Epidemiol. 2012;175(8):838-846",
        "title": "Derivation and Validation of the Denver Human Immunodeficiency Virus (HIV) Risk Score for Targeted HIV Screening"
      },
      "formula": "denver_hiv",
      "formula_expression": "Denver HIV (Haukoos 2012 Table 2 FULL pruned) = age (<22 or >60 0; 22-25 or 55-60 4; 26-32 or 47-54 10; 33-46 12) + sex (female 0, male 21) + ethnicity (black 9, hispanic 3, white 0, other 0) + sex_with_male 22 + vaginal_intercourse -10 + receptive_anal_intercourse 8 + injection_drug_use 9 + past_hiv_testing -4; flags independent, not mutually exclusive; range -14 to 81; <20 very_low derivation 0.12%, 20-29 low 0.24%, 30-39 moderate 0.67%, 40-49 high 2.28%, >=50 very_high 5.66%",
      "max_score": 81,
      "score": 0,
      "sex": "female",
      "derivation_hiv_percent": 0.12,
      "ethnicity": "white",
      "injection_drug_use": false,
      "min_score": -14,
      "past_hiv_testing": false,
      "receptive_anal_intercourse": false,
      "sex_with_male": false,
      "vaginal_intercourse": false
    },
    {
      "band": "very_low",
      "components": [
        {
          "value": 20,
          "factor": "age",
          "points": 0,
          "present": false
        },
        {
          "value": "female",
          "factor": "sex",
          "points": 0,
          "present": false
        },
        {
          "value": "white",
          "factor": "ethnicity",
          "points": 0,
          "present": false
        },
        {
          "factor": "sex_with_male",
          "points": 0,
          "present": false
        },
        {
          "factor": "vaginal_intercourse",
          "points": 0,
          "present": false
        },
        {
          "factor": "receptive_anal_intercourse",
          "points": 0,
          "present": false
        },
        {
          "factor": "injection_drug_use",
          "points": 0,
          "present": false
        },
        {
          "factor": "past_hiv_testing",
          "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.",
      "age_years": 20,
      "citation": {
        "authors": "Haukoos JS, Lyons MS, Lindsell CJ, Hopkins E, Bender B, Rothman RE, Hsieh YH, MacLaren LA, Thrun MW, Sasson C, Byyny RL",
        "doi": "10.1093/aje/kwr389",
        "id": "haukoos-2012-denver-hiv",
        "pmid": "22425121",
        "source": "Am J Epidemiol. 2012;175(8):838-846",
        "title": "Derivation and Validation of the Denver Human Immunodeficiency Virus (HIV) Risk Score for Targeted HIV Screening"
      },
      "formula": "denver_hiv",
      "formula_expression": "Denver HIV (Haukoos 2012 Table 2 FULL pruned) = age (<22 or >60 0; 22-25 or 55-60 4; 26-32 or 47-54 10; 33-46 12) + sex (female 0, male 21) + ethnicity (black 9, hispanic 3, white 0, other 0) + sex_with_male 22 + vaginal_intercourse -10 + receptive_anal_intercourse 8 + injection_drug_use 9 + past_hiv_testing -4; flags independent, not mutually exclusive; range -14 to 81; <20 very_low derivation 0.12%, 20-29 low 0.24%, 30-39 moderate 0.67%, 40-49 high 2.28%, >=50 very_high 5.66%",
      "max_score": 81,
      "score": 0,
      "sex": "female",
      "derivation_hiv_percent": 0.12,
      "ethnicity": "white",
      "injection_drug_use": false,
      "min_score": -14,
      "past_hiv_testing": false,
      "receptive_anal_intercourse": false,
      "sex_with_male": false,
      "vaginal_intercourse": false
    }
  ]
}
```

## Response fields

- `formula` (string): denver_hiv
- `formula_expression` (string): Exact expression used
- `score` (integer): Haukoos 2012 Table 2 FULL pruned points, -14 to +81
- `min_score` (integer): -14
- `max_score` (integer): 81
- `band` (string): Paper names: very_low (<20), low (20-29), moderate (30-39), high (40-49), very_high (>=50). Not a diagnosis.
- `derivation_hiv_percent` (number): Derivation-cohort HIV prevalence percent after Table 2: 0.12, 0.24, 0.67, 2.28, or 5.66. Not the validation-cohort percents.
- `age_years` (integer): Age in years used for the age band
- `sex` (string): female or male used
- `ethnicity` (string): black, hispanic, white, or other used
- `sex_with_male` (boolean): Caller-assigned sex-with-a-male flag
- `vaginal_intercourse` (boolean): Caller-assigned vaginal intercourse flag
- `receptive_anal_intercourse` (boolean): Caller-assigned receptive anal intercourse flag
- `injection_drug_use` (boolean): Caller-assigned injection drug use flag
- `past_hiv_testing` (boolean): Caller-assigned past HIV testing flag
- `components` (array): Per-item Table 2 points
- `citation` (object): Haukoos et al. Am J Epidemiol 2012 citation
- `disclaimer` (string): Not-a-device notice

## Example JSON

Frozen fixture. Not a live lookup.

```json
{
  "band": "very_low",
  "components": [
    {
      "value": 20,
      "factor": "age",
      "points": 0,
      "present": false
    },
    {
      "value": "female",
      "factor": "sex",
      "points": 0,
      "present": false
    },
    {
      "value": "white",
      "factor": "ethnicity",
      "points": 0,
      "present": false
    },
    {
      "factor": "sex_with_male",
      "points": 0,
      "present": false
    },
    {
      "factor": "vaginal_intercourse",
      "points": 0,
      "present": false
    },
    {
      "factor": "receptive_anal_intercourse",
      "points": 0,
      "present": false
    },
    {
      "factor": "injection_drug_use",
      "points": 0,
      "present": false
    },
    {
      "factor": "past_hiv_testing",
      "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.",
  "age_years": 20,
  "citation": {
    "authors": "Haukoos JS, Lyons MS, Lindsell CJ, Hopkins E, Bender B, Rothman RE, Hsieh YH, MacLaren LA, Thrun MW, Sasson C, Byyny RL",
    "doi": "10.1093/aje/kwr389",
    "id": "haukoos-2012-denver-hiv",
    "pmid": "22425121",
    "source": "Am J Epidemiol. 2012;175(8):838-846",
    "title": "Derivation and Validation of the Denver Human Immunodeficiency Virus (HIV) Risk Score for Targeted HIV Screening"
  },
  "formula": "denver_hiv",
  "formula_expression": "Denver HIV (Haukoos 2012 Table 2 FULL pruned) = age (<22 or >60 0; 22-25 or 55-60 4; 26-32 or 47-54 10; 33-46 12) + sex (female 0, male 21) + ethnicity (black 9, hispanic 3, white 0, other 0) + sex_with_male 22 + vaginal_intercourse -10 + receptive_anal_intercourse 8 + injection_drug_use 9 + past_hiv_testing -4; flags independent, not mutually exclusive; range -14 to 81; <20 very_low derivation 0.12%, 20-29 low 0.24%, 30-39 moderate 0.67%, 40-49 high 2.28%, >=50 very_high 5.66%",
  "max_score": 81,
  "score": 0,
  "sex": "female",
  "derivation_hiv_percent": 0.12,
  "ethnicity": "white",
  "injection_drug_use": false,
  "min_score": -14,
  "past_hiv_testing": false,
  "receptive_anal_intercourse": false,
  "sex_with_male": false,
  "vaginal_intercourse": false
}
```

## Errors

- HTTP 400 `invalid_age`: age must be an integer from 18 to 120 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_denver_hiv`: Denver HIV score inputs must match Haukoos 2012 Table 2 age band, sex, ethnicity, sexual-practice flags, IDU, and prior testing. 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

- [HIRI-MSM](https://magentlab.com/docs/hiri-msm) — Sum the published Smith 2012 seven-item HIV incidence risk index for MSM (age plus six prior-6-month behaviors, 0–47) and return at_or_above_10 when the total is ≥10.
- [VACS 1.0](https://magentlab.com/docs/vacs-1) — Sum the Tate 2013 VACS Index 1.0 points after one year of antiretroviral therapy from age, CD4, HIV-1 RNA, hemoglobin, caller-assigned FIB-4 and eGFR, and hepatitis C.

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