SteadyState

AI-powered medication timing for transplant patients so life doesn't interrupt your schedule.

Live demo: https://med-tracker-ui-313119639947.us-west1.run.app
GitHub: https://github.com/jamesmu03/steady-state


Inspiration

We all know people who live with the weight of medication schedules that don't bend. A grandparent who had a kidney transplant and has to set numerous alarms every day. A close friend managing a chronic, life-threatening condition who needs to remain on a tight dosage schedule. Carelessness is not the issue here. These are people who are working hard to improve their condition. What strikes us is how preventable most of these issues are with the right tools. Knowledge of when to take a dose is not a problem. The issue is life interrupts: a dinner reservation runs long, a flight gets delayed, a family event rolls over into the evening. It is tedious and challenging to build your calendar around a 12-hour drug interval. So, mundane scheduling conflicts cause clinical events.

Organ transplant patients, in particular, take immunosuppressants like tacrolimus on strict 12-hour intervals. Miss a window by too much, and drug levels fall below the therapeutic range. Taking a dose late in the evening, running over, disrupts sleep, which is itself a physiological trigger for rejection risk. Yet, nothing in the current care stack accounts for the reality of daily life. We wanted to build something that treats the patient as a person with a schedule, not just a compliance checkbox.


What it does

SteadyState is a conversational AI agent that helps transplant patients stay on safe, therapeutic medication schedules when life gets in the way.

  • Proactive conflict detection: SteadyState connects to the patient's Google Calendar. If an upcoming event (a dinner reservation, a flight, a late meeting) conflicts with a scheduled dose, the agent surfaces it in advance and proposes a safe adjustment.
  • Temporal rescheduling engine: When a dose is taken late, the agent doesn't just say "take it now." It runs a pharmacokinetics-aware calculation that finds the next safe dosing window — maintaining optimal drug intervals while protecting a no-dose sleep window (12 AM – 5 AM) to preserve sleep architecture.
  • Dynatrace observability: Every check-in pushes a med.adherence.rate metric to Dynatrace. If a patient misses 2 or more doses in a rolling 7-day window, SteadyState automatically fires a CUSTOM_ALERT event that surfaces as an open Problem in the Dynatrace dashboard — giving care teams a single pane to monitor patient risk without building their own alerting infrastructure.
  • Plain-language responses: The agent always responds in human terms. No raw ISO timestamps, no clinical jargon — just "take your next dose at 8:00 AM on Wednesday" with a clear explanation of why.

How we built it

Layer Technology
AI agent Google Gemini 2.0 Flash with function-calling
Backend FastAPI (Python), deployed to Google Cloud Run
Calendar integration Google Calendar OAuth 2.0
Observability Dynatrace API v2 (metrics ingest + event ingest)
Temporal engine Custom steady-state PK calculator with sleep-window guardrails
State In-memory patient state with seed data (demo-ready, no cold-start)

The agent uses Gemini's native function-calling to orchestrate two tools on every interaction: calculate_steady_state_shift (the PK engine) and update_patient_timeline (state write). The system prompt enforces that both tool calls complete before the agent responds to the patient, so no response is ever based on stale data.

Dynatrace is wired at the check-in layer: every dose event triggers a metric push, and a 24-hour deduplication guard prevents alert flooding when a patient has a bad streak.


Challenges we ran into

OAuth on Cloud Run: Google Calendar OAuth redirect URIs behave differently behind Cloud Run's reverse proxy. url_for generated http:// URLs that Google rejected. Fixed with Werkzeug's ProxyFix middleware to force HTTPS in all redirect generation.

Vertex AI vs. API key instability: We initially used Vertex AI for Gemini access but hit authentication instability in the Cloud Run environment. We switched to direct API key auth, which resolved cold-start failures and simplified the deployment significantly.

Sleep-window edge cases in the PK engine: A dose taken at 2 PM with a 12-hour optimal interval targets 2 AM — inside the sleep window. The minimum 10-hour spacing fallback targets midnight — also inside the sleep window. The engine needed a second guard pass to push both cases past 5 AM without overcorrecting into the following evening.


Accomplishments we're proud of

  • A working end-to-end loop: patient describes a schedule conflict in natural language → agent checks calendar → recalculates dosing → updates timeline → Dynatrace gets the metric — all in a single conversational turn.
  • The PK temporal engine handles the sleep-window edge cases correctly across all the combinations we could construct (late afternoon dose, midnight dose, cross-midnight minimum spacing).
  • Dynatrace Problems surface automatically from real adherence data — no manual webhook configuration needed by the care team.

What we learned

Building for patients with chronic conditions is different from building general productivity tools. Every design decision — when to alert, how to phrase a response, whether to wake someone up — has a clinical consequence. The Dynatrace integration forced us to think carefully about alert fatigue: sending too many notifications is almost as harmful as sending none, which is why the 24-hour dedup logic matters.

We also learned that Gemini's function-calling is well-suited to agentic medical workflows because you can enforce tool-call sequencing in the system prompt and trust the model to respect it consistently.


Long-term impact

Medication non-adherence costs the US healthcare system an estimated $300 billion per year and causes roughly 125,000 preventable deaths annually. SteadyState is built around the idea that most of that is a scheduling and awareness problem — not a willpower problem — and that intelligent agents with real-time observability can meaningfully close that gap.

Transplant patients and their care teams Transplant coordinators manage panels of 50–200 patients. Today, they find out about an adherence problem when a lab result comes back abnormal or a patient calls in distress. SteadyState flips that: the Dynatrace Problems feed gives coordinators a live view of risk across their entire panel, surfaced before a clinical event occurs. A care team that can see "three patients have missed-dose risk alerts open right now" can intervene proactively — a phone call, a refill check, a schedule adjustment — instead of reacting to a rejection episode after the fact.

Families and caregivers Behind almost every transplant patient is a family member or caregiver who carries a parallel anxiety about whether their person took their medication that day. SteadyState gives that layer a channel: adherence data and conflict alerts that can be shared with a designated family member or caregiver, reducing the emotional labor of constant check-ins while keeping the people who care most informed.

Clinical trial sponsors and CROs In Phase II and III trials, dosing adherence is not just a patient health issue — it is a data validity issue. A trial arm with poor adherence introduces noise that can mask efficacy or inflate side-effect rates, potentially killing a viable drug or advancing a harmful one. The same temporal engine and Dynatrace alerting stack that SteadyState uses for transplant patients applies directly to trial protocols: every participant's adherence becomes a trackable, auditable metric stream. Sponsors get per-patient and cohort-level adherence dashboards. Protocol deviations surface in real time instead of at the end of a monitoring visit. That is a direct improvement to trial integrity and a reduction in per-patient monitoring cost.

Health and life insurance Insurers price chronic disease risk largely on static snapshots, including diagnosis codes, lab values at annual checkups. Verified, longitudinal adherence data is a fundamentally different signal: it reflects how well a patient is actually managing their condition day to day. An insurer with access to a patient's SteadyState adherence record (with patient consent) can underwrite chronic disease risk with far greater accuracy, and can offer premium structures that reward demonstrated adherence. For patients, this creates a direct financial incentive to stay on schedule. For insurers, it reduces the unpredictability of a chronically ill member pool. The Dynatrace metric trail provides the tamper-resistant, time-stamped record that makes this actuarially credible.

The bigger picture Transplant patients are the sharpest version of a much broader problem. The same scheduling conflicts that cause a transplant patient to miss tacrolimus cause a diabetic patient to skip insulin, a cardiac patient to delay a beta-blocker, a psychiatric patient to run out of a mood stabilizer before a holiday weekend. SteadyState is built on a generalizable stack: a calendar-aware AI agent, a pharmacokinetics-informed rescheduling engine, and a real-time observability layer. The transplant use case is where we started. The addressable surface is every condition where timing matters.


What's next for SteadyState

  1. Care team dashboard: Surface the Dynatrace Problems feed inside a web portal purpose-built for transplant coordinators, with one-click escalation to the transplant team and configurable severity thresholds per medication class.
  2. Clinical trial module: Extend the adherence tracking stack to support trial protocol schemas — per-participant metric streams, cohort-level compliance reports, and automated protocol-deviation flags for CROs.
  3. Family and caregiver access: Consent-gated sharing so a designated family member receives alerts when a conflict is detected and the patient hasn't confirmed a dose — closing the loop for the people who are already carrying this worry informally.
  4. Insurance partnership integrations: Verified adherence scores exportable to insurer APIs, enabling premium structures tied to demonstrated long-term compliance.
  5. Personalized PK profiles: Replace the fixed optimal-interval guardrails with patient-specific pharmacokinetic parameters derived from lab draws over time, making the rescheduling engine clinically precise rather than conservatively generic.

Built with

google-gemini google-calendar-api fastapi python dynatrace google-cloud-run oauth2


James Mu & Rachel White — Duke University
Google Agents Hackathon 2026 — Dynatrace Track

Built With

Share this project:

Updates