Inspiration

When older adults take five or more medications at the same time, it often leads to hidden health risks because different drugs clash inside the body. For instance, an antibiotic can block the liver from clearing a statin or blood thinner, while poor kidney function or low potassium makes things even worse. Traditional drug warning tools only give simple, flat warnings without looking at real patient details like kidney health or mineral levels. On top of that, the US National Library of Medicine recently shut down its public drug interaction tool. We wanted to solve this by building PharmacoTwin, a smart digital twin that turns simple warnings into personalized, clear simulations using real medical science and live data.

What it does

PharmacoTwin takes basic patient details like age, weight, sex, kidney function, potassium levels, and baseline heart rhythm along with up to 12 medications, and runs four powerful checks at once. First, it calculates kidney clearance and heart rhythm risks. Second, it runs a 10-day mathematical simulation to show how drug levels build up in the body over time. Third, it connects to live FDA safety databases to check real-world adverse event reports. Finally, it uses machine learning to flag uncertain cases and suggest safer alternative drug swaps.

How we built it

We built PharmacoTwin using Python 3.11, FastAPI, SciPy, NumPy, and scikit-learn for the backend logic and data calculations. For data, our app securely fetches real drug labels and safety reports from openFDA and active NIH RxNorm directories, caching responses locally in SQLite. The frontend is built using clean, responsive HTML5, CSS3, and JavaScript with interactive SVG charts. Everything is packaged neatly inside a Docker container so it runs smoothly and reliably on the cloud.

Challenges we ran into

The biggest hurdle was discovering that the legacy NIH drug interaction lookup service had been retired, alongside handling tricky 404 errors when openFDA queries returned zero matches. We solved this by creating a resilient asynchronous fetcher with fallback logic that keeps the app running smoothly offline. We also worked hard to avoid black-box AI guessing by relying entirely on strict mathematical formulas, mathematical uncertainty sets, and clear data source tracking.

Accomplishments that we're proud of

We are especially proud of engineering a production-ready, quantitative polypharmacy digital twin in under 72 hours that bridges the gap between static drug warnings and rigorous clinical pharmacology. By pairing a robust SciPy pharmacokinetic differential equation solver with live U.S. FDA pharmacovigilance data, active NIH RxNorm/RxClass ontologies, and uncertainty-aware Split Conformal machine learning, PharmacoTwin successfully avoids black-box generative AI guessing in healthcare software. Achieving sub-second execution speeds, high calibration accuracy, and fully automated DSH Hacks V2 submission PDF generation demonstrates that rigorous scientific modeling and transparent uncertainty sets provide a vastly more trustworthy foundation for patient safety than generic chatbots.

What we learned

We learned that combining hard mathematical equations and safety uncertainty checks is far more reliable and trustworthy in healthcare software than relying on generic AI chatbots.

What's next for PharmacoTwin

Next, we plan to test our model against real hospital patient data records, expand our single-drug simulation into a multi-organ system model, and add genetic metabolizer testing support.

Share this project:

Updates

Submission history