Inspiration## 💡 Inspiration

70% of healthcare leaders cite data silos as their #1 challenge. Patients arrive unconscious with no records. Clinicians make critical decisions without real-time evidence. Drug-nutrient conflicts go undetected. I built MediGuard-AI to solve these life-threatening gaps using AI agents.

I live in Pakistan, where healthcare is both deeply human and deeply broken.

Every day, patients arrive at hospitals already exhausted — drained by their illness, then drained further by the process. They sit in queues, fill forms, and when they finally reach a doctor, they spend the first 8 minutes narrating their entire medical history from childhood. The doctor listens, then gives a one-line answer. The patient leaves unsatisfied. The doctor moves to the next patient, frustrated.

And then there are the accident cases.

In Pakistan, road accidents happen daily. A critical patient arrives unconscious. No ID. No family. No medical history. Doctors treat blindly — guessing allergies, guessing medications, guessing blood type. Sometimes the family finds out hours later. Sometimes they never do. Sometimes the patient is declared an unknown body — and that trauma follows a family for years.

These are not edge cases. These are Tuesday afternoons in Karachi.

MediGuard-AI was built to fix this — not as a replacement for doctors, but as the intelligent assistant that gives them back their most valuable resource: time. And gives patients back their dignity.


🏗️ What I Built

MediGuard-AI is a live, 8-agent clinical intelligence system deployed on Google Cloud Run — powered by Gemini 3.1 Flash Lite and fully observable via Arize Phoenix MCP.

🚨 Emergency Agent — The Feature Born From Crisis

The Emergency Agent was designed specifically for unconscious or unidentified patients in critical care.

Privacy-first biometric identification:

  • Patient fingerprints are never stored raw — only an irreversible cryptographic hash (ISO/IEC 19794-2 compliant)
  • The hash cannot be decoded back to the original biometric — privacy by design
  • In an emergency, the hash is matched against a secure registry to retrieve the patient MRN

When ID cards are missing or misplaced — which happens in every serious accident — the system falls back to national ID databases:

  • 🇵🇰 Pakistan NADRA CNIC
  • 🇦🇪 UAE Emirates ID
  • 🇸🇦 Saudi Arabia Iqama
  • 🌍 International Passport (ISO 3166)

The moment a patient is identified:

  1. Critical allergies surface instantly
  2. Active medications are retrieved
  3. Family emergency contact is automatically alerted in real time
  4. Full audit log created — HIPAA §164.512 emergency exception

This feature exists because unknown bodies should not be a statistic. Families deserve to know.


🤖 The 8-Agent System

Agent Role
MD Agent RED/AMBER/GREEN triage + differential diagnosis
Clinician Agent Unified patient history + drug interaction alerts
Nutritionist Agent Drug-nutrient conflicts + personalised meal plans
Researcher Agent Live evidence synthesis — ACC/AHA, ESC, KDIGO guidelines
Patient Agent Procedure cost transparency + insurance estimates
Intake Agent Walk-in onboarding — FHIR R4 patient creation
Sentiment Agent Patient review analysis — hospital quality intelligence
Emergency Agent Biometric ID + family alert — critical care response

🔭 Arize Phoenix — Why Observability Changes Everything

Arize Phoenix is not just a logging tool — it is the nervous system of MediGuard-AI.

Every single Gemini API call across all 8 agents is automatically traced via OpenInference auto-instrumentation — zero manual span creation. Each trace captures:

  • Input prompt
  • Model response
  • Latency
  • Cost per call

What this gives me in production:

  • I can see exactly which agent is slow
  • I can see exactly what prompt produced a hallucinated response
  • I can catch regressions before they reach patients

LLM-as-a-Judge Evaluations run automatically on every span — scoring:

  • Sentiment Accuracy — is the label correct?
  • Hallucination Guard — did the model fabricate facts?
  • Response Relevance — is the answer on-topic?

Self-Introspection Loop — MediGuard-AI queries its own Phoenix traces at runtime, feeds them to Gemini, and generates self-improvement recommendations. The system literally learns from its own mistakes.

In my live deployment: Eval Score 1.0, Confidence 0.95, $0 cost per call.


⚕️ Medical Disclaimer

MediGuard-AI is designed to assist qualified healthcare professionals — not replace them.

Every AI-generated output carries a mandatory disclaimer:

This report is for informational purposes only and does NOT constitute medical advice, diagnosis, or treatment recommendation. ALL output MUST be reviewed and approved by a licensed medical practitioner before any clinical application.

The system is a decision support tool. The doctor checks, approves, and attests every recommendation. MediGuard-AI saves the doctor time — the doctor saves the patient's life.


🧠 What I Learned

  • Observability is not optional in medical AI — it is the difference between a demo and a deployable system
  • Biometric privacy requires irreversible hashing at the architecture level — not as an afterthought
  • The real problem in Pakistani healthcare is not lack of knowledge — it is lack of connected, real-time information at point of care
  • LLM-as-a-Judge is powerful but requires careful calibration — hallucination scoring needs domain-specific rubrics for clinical text

⚙️ How I Built It

  • Gemini 3.1 Flash Lite — all agent reasoning, evidence synthesis, self-introspection
  • FastAPI — agent orchestration layer
  • Google Cloud Run — live deployment, asia-southeast1
  • Arize Phoenix MCP — self-hosted observability server on Cloud Run
  • OpenInference — auto-instrumentation for all Gemini calls
  • HL7 FHIR R4 — patient resource creation in Intake Agent
  • HIPAA §164.512 + PDPA Section 17 — emergency data access compliance
  • SQLite (demo) → Cloud SQL (production roadmap)

🏆 Built With

Gemini 3.1 Flash Lite Arize Phoenix MCP OpenInference Google Cloud Run FastAPI Python 3.11 HL7 FHIR R4 HIPAA SQLite Docker

Built With

Share this project:

Updates