diagcalc
v3.2.3
Published
Diagnostic calculator for the browser, terminal, and plain CLI.
Maintainers
Readme
DIAGCALC
DIAGCALC is a diagnostic test calculator with two interfaces:
- a web app for teaching and interactive use
- a terminal app with both TUI and plain CLI modes
Both interfaces use the same calculation engine.
Repository
- GitHub:
https://github.com/tiagojct/diagcalc - Web app:
https://diagcalc.tiagojct.eu/ - npm package:
https://www.npmjs.com/package/diagcalc
Description
DIAGCALC is designed for a simple job: start from a confusion matrix, calculate the main diagnostic test measures, and show how the test result changes the probability of disease.
It is built for teaching, self-study, and quick practical use. The web app is useful in the classroom and in browser-based demonstrations. The terminal app is useful for keyboard-driven work, SSH sessions, scripting, and lightweight environments.
Operating Model
The app follows the same sequence used in many teaching sessions on diagnostic reasoning:
- define the case or load a reference scenario
- inspect the confusion matrix
- estimate the pre-test probability
- calculate core performance measures
- interpret LR+ and LR-
- update to post-test probability
The web and terminal interfaces both follow that workflow.
Philosophy
- keep the calculator simple enough to use during teaching
- keep the maths explicit and easy to verify
- keep the interfaces lightweight and dependency-light
- keep the same results across web, TUI, and CLI
- support both interactive learning and automation
Features
- confusion matrix input: TP, FP, FN, TN
- pre-test probability input
- sensitivity, specificity, PPV, NPV
- LR+ and LR-
- positive and negative post-test probability
- 95% confidence intervals with the Wilson method
- preset study scenarios
- Fagan nomogram in the web app
- TUI, text CLI, and JSON CLI output in the terminal app
Web App
The web app is static. It does not need a build step.
It is intended for teaching sessions, demonstrations, and direct interactive exploration.
Run locally
Open index.html directly in a browser, or serve the folder locally:
python3 -m http.server 8080Then open:
http://localhost:8080Use
- Load a preset scenario, or leave the selector empty.
- Enter TP, FP, FN, TN.
- Enter pre-test probability.
- Click
Calculate results. - Review the probability bars, result cards, and Fagan nomogram.
Terminal App
The terminal app requires Node.js 18 or newer.
It is intended for keyboard-first use, quick calculations, reproducible terminal workflows, and scripting.
Install locally
npm installTUI mode
node bin/diagcalc.js --tuiIf you want the short command:
npm link
diag --tuiCLI mode
List datasets:
diag --list-datasetsRun a preset case:
diag --dataset hiv_elisaRun an ad hoc case:
diag --tp 42 --fp 8 --fn 3 --tn 120 --pre 15Get JSON output:
diag --dataset ddimer --format jsonThe CLI is useful when you want a one-shot calculation or when you want to integrate the calculator into scripts or other tooling.
TUI controls
Tab/Ctrl-N: next panelShift-Tab/Ctrl-P: previous panel- arrows: move selection
- type digits directly in the input editor
Backspace: delete one character from the selected fieldDeleteorCtrl-U: clear the selected fieldEnter: open the selected field in prompt moden: start a blank ad hoc casex: export current case to plain textm: export current case to Markdownr: reset current caseq: quit
Deployment
GitHub Pages
This repository includes a GitHub Pages workflow at .github/workflows/deploy-pages.yml.
To publish the web app:
- Push to the
mainbranch. - In GitHub, open
Settings -> Pages. - Set the source to
GitHub Actions. - The workflow will publish the static site automatically.
npm
This package is ready for npm publishing.
Publish steps:
npm login
npm publish --access publicAfter publishing, users can install it with:
npm install -g diagcalc
diag --tuiPackage page:
https://www.npmjs.com/package/diagcalc
Project Structure
index.html- web app markupstyles.css- web app stylesscript.js- web app logic and Fagan nomogram renderinglib/diagcalc-core.js- shared calculations and validationlib/diagcalc-datasets.js- shared preset datasetstui/index.js- terminal UIbin/diagcalc.js- CLI and TUI entrypoint.github/workflows/deploy-pages.yml- GitHub Pages deployment workflow
License
MIT
