MediDose
The Alchemist's Grand Grimoire
The problem MediDose solves
MediDose: The Alchemist's Grand Grimoire
Your hackathon project, MediDose, is a comprehensive medication adherence tracker designed to solve the critical problem of poor medication adherence, which is a major factor in treatment failure and increased healthcare costs.
The Problem It Solves
The core problem MediDose solves is the difficulty users face in consistently managing complex, multi-dose medication schedules. It tackles the challenge of simply remembering to take medication on time and provides tools to understand why adherence might be failing.
What People Can Use It For
People can use MediDose as a centralized digital tool for all aspects of their medication management, transforming it from a passive tracker into an intelligent, proactive assistant.
Key Use Cases & Features
Dose Management & Scheduling: Users can easily add, edit, and delete their medications (Elixirs) and set up complex dosing schedules (e.g., dosage, frequency, specific time slots). They use the dashboard to view their dynamic daily schedule and mark doses as Taken or Missed.
Intelligent Reminders:
• Receive automatic Staggered Email and SMS Reminders (via Twilio) at 0, 15, 30, and 45 minutes after a scheduled dose is missed, providing multiple chances to stay on track.
• Get a floating reminder nudge directly on the screen with a snooze option.
AI-Powered Insights: Use the Mystic AI Chatbot (powered by Groq) to ask natural language questions about their schedule, performance, or medication information (e.g., "What pills did I miss yesterday?" or "What is my overall adherence rate?").
Performance Monitoring: Access detailed analytics, including their Today's Wellness Rate, an Overall Adherence Summary, and a 30-Day Trend Chart to monitor consistency over time.
External Integration:
• Google Calendar Sync: Sync their medication schedule directly to their Google Calendar for reliable external reminders.
• Consultation: Quickly navigate to a healthcare platform (via the Consult tab) to book appointments with medical professionals.
Challenges we ran into
Challenges I Ran Into
The Specific Bug/Hurdle: The Timezone Paradox
The most significant and frustrating hurdle in building a scheduling application was handling timezones and recurring dose generation.
The Challenge
When a user sets a medication (Elixir) to be taken at "9:00 AM Daily":
• The backend server (typically running in UTC) receives this request.
• The initial logic converts this 9:00 AM time directly into a UTC timestamp for storage in the DoseLog model.
The Bug:
• If the user is in a timezone like IST (UTC+5:30), the server saves 9:00 AM IST as 3:30 AM UTC.
• When the cron job (cron.js) checks for upcoming doses, it sees a dose due at 3:30 AM UTC and may:
o Send reminders in the middle of the night (server time), or
o Generate the next day’s dose incorrectly.
Impact:
This breaks the fundamental user expectation:
The dose should always occur at the intended local time, regardless of the server’s timezone.
How It Was Overcome: The Time Alchemist's Solution
The solution involved shifting how time was stored and calculated, using robust timezone-aware libraries.
1. Capturing the Context
• Action: Store the user's specific timezone (e.g., Asia/Kolkata or America/New_York) in the User model.
• Reason: This context is essential when generating future doses in services like meds.js and controllers like elixirController.js.
2. Storing Time as Local
• Action: Instead of storing a single UTC timestamp, store:
o The time of day (e.g., 09:00) as a simple string or time object.
o The user’s timezone ID (e.g., Asia/Kolkata).
• Key Insight:
Store the intent (9 AM in Kolkata), not the absolute UTC moment (3:30 AM UTC).
3. Recalculating with Timezone Awareness
• Action: Use libraries like moment-timezone or date-fns-tz in the dose generation logic.
• Implementation:
When creating a new DoseLog entry:
- Take the current date (e.g., Oct 10, 2025).
- Combine it with the Elixir's local time (9:00 AM).
- Apply the user's timezone (e.g., Asia/Kolkata).
- Convert the local moment into a standardized UTC ISO string for storage in the database.
• Outcome: Cron jobs (cron.js) now reliably check and trigger reminders exactly at the user’s local time, regardless of the server timezone.
Result
• Users receive reminders at the correct local time.
• Recurring doses are generated accurately.
• The system handles multiple timezones seamlessly.
Tracks Applied (1)
Ethereum Track
ETHIndia
Technologies used