End-to-end TypeScript client for the fictional DemoMed Healthcare API:
- Paginates through patients with retry & backoff (429/500/503)
- Parses inconsistent fields (e.g.,
"150/","TEMP_ERROR") - Scores Blood Pressure, Temperature, and Age per spec (uses the higher BP risk when sys/dia differ)
- Builds alert sets: High-Risk, Fever, Data Quality Issues
- Submits results to the assessment endpoint
- ⚙️ Robust HTTP: exponential backoff + jitter for transient failures
- 📦 Pagination: fetches all pages (limit configurable)
- 🧮 Scoring engine: pure functions, strict parsing & validation
- 🧪 Deterministic: stable outputs, deduped alert IDs
npm i
export KSENSE_API_KEY="ak_...your key..."
npx ts-node assessment.tsnpm run start— run via ts-nodenpm run build— compile TypeScriptnpm run submit— alias of start
- Blood Pressure: Normal=1, Elevated=2, Stage1=3, Stage2=4; take higher stage if sys/dia differ; invalid/missing=0
- Temperature: ≤99.5 → 0; 99.6–100.9 → 1; ≥101.0 → 2; invalid/missing → 0
- Age: ≤65 → 1; >65 → 2; invalid/missing → 0
- Total Risk = BP + Temp + Age
- High-Risk: total ≥ 4
- Fever: temp ≥ 99.6°F
- Data Quality: any invalid/missing in BP/Temp/Age
TypeScript, node-fetch, ts-node.
Do not hardcode secrets. Use KSENSE_API_KEY env var.
.gitignore excludes .env, node_modules, dist, logs.
© 2025 Paul Miranda — MIT License.