Skip to content

alexgoodell/open-med-calc

Repository files navigation

OpenMedCalc

GitHub issues GitHub pull requests GitHub last commit DOI

About

This is a simple open-source API which allows users to calculate common medical formulas. It is built using FastAPI and follows the OpenAPI specification. It can be integrated into other applications such as OpenAI's new GPTs functionality. For educational use only. Not for patient care.

Full article describing its use integrated into ChatGPT is available in npj Digital Medicine: "Large language model agents can use tools to perform clinical calculations".

(Preprint originally available on Medrxiv).

Interactive live API documentation available here:

To run the app locally

This project uses uv for dependency management.

  1. Clone the repo
  2. Install dependencies: make install (or uv sync)
  3. Run the app: make run (or uv run uvicorn main:app --reload)
  4. Stop the app: make stop

The API will be available at http://127.0.0.1:8000.

Deploy to Cloudflare Workers

This application supports deployment to Cloudflare Workers using Python Workers (currently in beta).

Prerequisites

  • Node.js and npm installed
  • uv installed
  • Cloudflare account

Deployment Steps

  1. Install Pywrangler (Python Workers CLI):
uv tool install workers-py
  1. Authenticate with Cloudflare:
npx wrangler login
  1. Deploy to Cloudflare Workers:
uv run pywrangler deploy

The application will be deployed to Cloudflare's edge network. Pywrangler will automatically:

  • Read dependencies from pyproject.toml
  • Bundle Python packages with your worker
  • Deploy to Cloudflare with the python_workers compatibility flag

Local Development

To test locally before deploying:

uv run pywrangler dev

Configuration

The deployment is configured via wrangler.jsonc:

  • Entry point: worker.py - Cloudflare Workers adapter for the FastAPI app
  • Main app: main.py - The core FastAPI application
  • Compatibility: Requires python_workers flag (beta feature)

Once deployed, the API is available at:

  • https://api.openmedcalc.org
  • https://api.openmedcalc.com

Limitations

Current formulas

  • MELD
  • MELD-Na
  • Caprini VTE
  • Wells DVT score
  • PSI/PORT (BETA)

To do

  • Improve documentation
  • Add more formulas

Similar projects

Legal

Licensed under MIT license.

The tool is intended for use as a research and informational tool only and is not a substitute for professional medical advice, diagnosis, or treatment. ‍The Service is provided "as is" without any warranties of any kind, express or implied, including but not limited to the accuracy, completeness, or reliability of the calculations or results.

Choice of calculation tasks chosen from "most popular" calculators list from website of MDCalc Ltd (New York, NY). Used with permission. Inclusion of these calculators does not constitute endorsement by MDCalc.

About

OpenMedCalc is a free, open-source medical calculation API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published