MAGENT

Infection / VTE · WEDGE

Denver HIV risk score

Denver HIV

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.

WEDGE $0.005 USDC GET /api/calc/denver_hiv

Markdown: /docs/denver-hiv.md · Canonical: https://magentlab.com/docs/denver-hiv

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

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

Worked example

Age 20 female white, all flags false

Given: age=20ethnicity=whiteinjection_drug_use=falsepast_hiv_testing=falsereceptive_anal_intercourse=falsesex=femalesex_with_male=falsevaginal_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=20ethnicity=whiteinjection_drug_use=falsepast_hiv_testing=falsereceptive_anal_intercourse=falsesex=malesex_with_male=falsevaginal_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

Try

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

/api/calc/denver_hiv?age=20&sex=female&ethnicity=white&sex_with_male=false&vaginal_intercourse=false&receptive_anal_intercourse=false&injection_drug_use=false&past_hiv_testing=false

Full URL: https://api.magentlab.com/api/calc/denver_hiv?age=20&sex=female&ethnicity=white&sex_with_male=false&vaginal_intercourse=false&receptive_anal_intercourse=false&injection_drug_use=false&past_hiv_testing=false

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/denver_hiv?age=20&sex=female&ethnicity=white&sex_with_male=false&vaginal_intercourse=false&receptive_anal_intercourse=false&injection_drug_use=false&past_hiv_testing=false"

Parameters

Name Type Required Description
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, male female or male as assigned by the caller (Haukoos 2012 Table 2 gender). female scores 0; male scores 21.
ethnicity string required · black, hispanic, white, other 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.

POST /api/calc/denver_hiv 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": [
    {
      "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"
    }
  ]
}

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/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.",
      "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,
      "age_years": 20,
      "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.",
      "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,
      "age_years": 20,
      "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

Field Type Description
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

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

{
  "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.",
  "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,
  "age_years": 20,
  "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
}

Client errors (HTTP 400)

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

HTTP Code When
400 invalid_age age must be an integer from 18 to 120 Returned before settlement; you are not charged.
400 invalid_sex sex must be female or male 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_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.
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

  • 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 — 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. 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.