DEV Community

Hrishikesh Dalal
Hrishikesh Dalal

Posted on AI-assisted

Dawai-Dost: A Private, Local Medicine Companion

Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle Submission 💸

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 2: Side Hustle

What I Built

Dawai-Dost ("medicine friend") is a local-first app for families who look after elderly parents or grandparents. It does three things:

  • Reads the prescription. Photograph a doctor's handwritten or printed prescription. A vision-language model extracts each medicine, dose, timing and duration, and turns it into a simple daily schedule in English, Hindi or Marathi with large, readable text.
  • Remembers the history. Every prescription, refill and reported symptom is stored in a small on-device database, so the app builds a medication timeline for each family member.
  • Predicts and flags, using that history.
    • Refill prediction: "Amlodipine runs out in 4 days. Order now."
    • Missed-dose patterns: "Evening doses are missed 3 days out of 7."
    • Change summaries: "This new prescription adds a medicine that was not in the last 3 visits."
    • Interaction checks: it flags when two medicines from different doctors may clash, and tells you to confirm with a pharmacist.
    • A one-page visit summary to hand to the doctor, so a 10-minute consultation is not spent trying to remember what changed.

Who would pay: families with elderly parents, especially adult children living in a different city, and small pharmacies or clinics that want to offer a "prescription companion" to regular patients. The problem is real. Prescriptions are hard to read, parents take medicines from several doctors, and nobody has a clear view of the whole picture. A family would reasonably pay a small monthly fee, roughly the price of a single doctor consultation per year, for peace of mind.

Safety note: Dawai-Dost is an assistant, not a doctor. Every output carries a "confirm with your doctor or pharmacist" notice, and low-confidence extractions are highlighted for human review instead of being guessed.

Code

Core of the pipeline:

import ollama, json, sqlite3
from datetime import date, timedelta

PROMPT = """Read this prescription image. Return ONLY JSON:
{"medicines":[{"name":"","dose":"","times":["morning|noon|night"],"days":0,"confidence":0.0}]}
If text is unclear, lower the confidence. Never guess."""

def read_prescription(image_path):
    r = ollama.chat(model="qwen2.5vl:7b",
        messages=[{"role": "user", "content": PROMPT, "images": [image_path]}])
    return json.loads(r["message"]["content"])["medicines"]

def save(db, patient, meds):
    for m in meds:
        db.execute("INSERT INTO rx(patient,name,dose,times,start,days) VALUES(?,?,?,?,?,?)",
                   (patient, m["name"], m["dose"], ",".join(m["times"]),
                    date.today().isoformat(), m["days"]))

def refill_alerts(db, patient, within=5):
    rows = db.execute("SELECT name,start,days FROM rx WHERE patient=?", (patient,))
    return [f"{n}: runs out {(date.fromisoformat(s)+timedelta(days=d)).isoformat()}"
            for n, s, d in rows
            if date.fromisoformat(s) + timedelta(days=d) <= date.today() + timedelta(days=within)]

def history_insight(db, patient):
    hist = db.execute("SELECT name,dose,start FROM rx WHERE patient=? ORDER BY start", (patient,)).fetchall()
    q = f"Summarise changes across this medication history and flag possible interactions. Be cautious, advise confirming with a pharmacist: {hist}"
    return ollama.chat(model="llama3.1:8b", messages=[{"role": "user", "content": q}])["message"]["content"]
Enter fullscreen mode Exit fullscreen mode

How I Built It

Everything runs on the user's own machine or a small home server, with no cloud AI calls.

  • Vision model: Qwen2.5-VL (open-weight), served with Ollama. It reads the prescription photo and returns structured JSON. Each medicine gets a confidence score, and anything below a threshold is shown to the user as "please verify" rather than silently accepted.
  • Reasoning model: Llama 3.1 8B (open-weight), also via Ollama. It writes the plain-language schedule in English, Hindi or Marathi, and turns the stored history into summaries and cautious interaction notes.
  • Storage: SQLite. One small file holds every prescription, refill and dose log.
  • Prediction layer: simple, transparent logic. Refill dates come from start date plus days supplied. Missed-dose patterns come from counting skipped reminders by time of day. I kept this rule-based on purpose. Predictions about health should be explainable, and the LLM only turns the numbers into readable language.
  • Interface: a lightweight web UI with large fonts, plus an optional WhatsApp-style reminder flow for parents.

Design choice: the LLM never decides anything medical on its own. It extracts and explains. Dates and alerts come from deterministic code, and risky outputs always point the user back to a doctor or pharmacist.

Why Does Open Innovation Matter?

  • Privacy is the product. Prescriptions and medication history are some of the most sensitive data a family has. With open-weight models running locally, that data never leaves the device. With a closed API, every photo would be uploaded to someone else's servers. For a health tool, "your data stays on your machine" is the main reason people would trust and pay for it.
  • The economics work. A family uploads many prescription photos and gets daily summaries and reminders. Per-image and per-token API pricing would turn that into a recurring cost that grows with every user. Local inference has a flat cost, so a low monthly price still leaves a margin.
  • Niche fine-tuning. Indian prescriptions are messy: abbreviations like "1-0-1", mixed English and Hindi, and doctor handwriting. Open weights can be fine-tuned on these patterns and on regional-language output, which a general-purpose closed API handles inconsistently.
  • No lock-in. If a model is deprecated or a vendor changes its pricing or policy, a health product built on it breaks. With open weights, I can swap in a better model, pin a version that is known to be reliable, and keep the app working for years.
  • Works offline. It still works in areas with poor connectivity, which matters for elderly users and smaller towns.

 

Prize Categories

None

Top comments (0)