Skip to content

Latest commit

 

History

88 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

MedQuick

Cross-platform AI-powered healthcare assistance and medicine delivery system.

MedQuick connects five actors — patients, doctors, pharmacies, riders and admins — in a single Flutter application backed by a FastAPI service, Firebase, and a locally trained clinical NLP stack. A patient describes their symptoms in a guided chat; an AI intake assistant gathers the clinical details, a fine-tuned BioBERT pipeline proposes candidate conditions and medicines, a licensed doctor reviews and approves the prescription, a pharmacy prepares the order, and a rider delivers it with live navigation.

Highlights

  • Guided AI consultation — one question at a time, emergency-symptom detection, attachment upload (lab reports/images), and automatic PDF prescription generation from the conversation.
  • Doctor-in-the-loop by design — no AI suggestion reaches a patient without an approval, edit, or decline from a real doctor.
  • Real-time everywhere — Firestore streams drive every portal, so order queues, rider positions and delivery states update without a refresh.
  • Live delivery tracking — Google Directions routing, polylines, ETA text, and rider GPS synced to Firestore for the pharmacy and patient to follow.
  • Offline-capable AI fallbacks — local Ollama first, then Gemini → Grok → Groq, then a built-in scripted intake flow, so the chat never hard-fails.

Portals

Role Capabilities
Patient Consultation chat, symptom intake, prescription & order history, notifications inbox, profile completion
Doctor Pending-approval queue, prescription detail with medication editing, approve/decline with reason, PDF export, history
Pharmacy Incoming prescriptions, order status pipeline, inventory overview, rider assignment (nearest-rider pick), order transfer to another pharmacy, store location pin
Rider Nearby delivery pool, accept/pickup/deliver flow, in-app map navigation for both legs, availability toggle, delivery history
Admin Dashboard stats, recent activity feed, user management (create/edit/disable non-patient accounts)

AI & ML pipeline

Two fine-tuned dmis-lab/biobert-base-cased-v1.2 sequence classifiers power clinical inference:

  1. Symptom extraction against a generated symptom lexicon.
  2. Disease classification — top-k conditions with confidence scores.
  3. Chained medicine inference — predicted diseases are mapped through a curated disease → medicine table, with the direct medicine classifier filling remaining slots.
  4. Safety validation — allergy conflicts and pregnancy flags raise graded alerts.

The service auto-selects its device (MPS → CUDA → CPU) and falls back to scikit-learn/XGBoost joblib artifacts when BioBERT weights are absent. Models are warmed at application startup so the first chat request is fast.

Conversational intake runs on a local Ollama model through the backend, constrained by a system prompt that forbids naming diseases or medicines and enforces one question per reply.

Tech stack

Frontend — Flutter 3 / Dart (sdk ^3.10.1), Material 3, Firebase Auth (email + Google Sign-In), Cloud Firestore, Firebase Storage, Firebase Messaging + local notifications, Google Maps, Geolocator, pdf, share_plus, flutter_dotenv. Targets Android, iOS, Web, macOS, Windows and Linux.

Backend — FastAPI, Uvicorn, Pydantic v2 + pydantic-settings, Firebase Admin SDK, google-cloud-firestore, SMTP email OTP, Docker. ML — PyTorch, HuggingFace Transformers & Datasets, scikit-learn, XGBoost, pandas, joblib.

Repository layout

MedQuick/
├── firestore.rules              # Role-aware Firestore security rules
├── firebase.json
├── backend/
│   ├── app/
│   │   ├── main.py              # App factory, Firebase init, model warm-up, CORS, logging
│   │   ├── core/config.py       # Pydantic settings (.env driven)
│   │   ├── routers/             # health, auth, patients, doctors, pharmacies, riders, admin, ai
│   │   ├── schemas/             # Request/response models
│   │   └── services/            # Firestore, notifications, Ollama, clinical AI
│   ├── ml/scripts/              # prepare_data, train_*, evaluate_models (artifacts gitignored)
│   ├── scripts/                 # Firestore setup, admin bootstrap, demo data helpers
│   └── Dockerfile, requirements*.txt
└── medquick_frontend/
    ├── lib/core/                # AppConfig, env loader
    ├── lib/screens/             # admin | auth | doctor | patient | pharmacy | rider | settings
    ├── lib/services/            # One service per domain + AI/maps/notification clients
    ├── lib/utils/  lib/widgets/
    └── assets/env/env.example

Getting started

Prerequisites

  • Flutter SDK 3.10+ and Dart
  • Python 3.11+
  • A Firebase project with Authentication, Firestore, Storage and Cloud Messaging enabled
  • Optional: Ollama for local conversational intake; a Google Maps API key

1. Backend

cd MedQuick/backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

# Place your Firebase service account at credentials/firebase-service-account.json
# Create backend/.env with the keys listed below

uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

Windows helpers: start_server.bat / start_server.ps1. Docker: docker build -t medquick-api .

Interactive API docs live at http://localhost:8000/docs. .env keys: FIREBASE_PROJECT_ID, FIREBASE_CREDENTIALS_PATH, SMTP_HOST, SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD, SMTP_FROM, SMTP_USE_TLS, OTP_DEV_BYPASS.

2. Train the clinical models (optional)

cd MedQuick/backend
pip install -r requirements-ml.txt

# Drop the raw CSVs into ml/data/raw/ first — see ml/README.md
python -m ml.scripts.prepare_data
python -m ml.scripts.train_biobert          # or train_disease_classifier + train_medicine_ranker
python -m ml.scripts.evaluate_models

Verify with GET /api/ai/health; without artifacts the AI endpoints report degraded.

3. Frontend

cd MedQuick/medquick_frontend
cp assets/env/env.example assets/env/.env    # fill in your keys
flutter pub get
flutter run

Add your platform Firebase config files (android/app/google-services.json, ios/Runner/GoogleService-Info.plist). .env keys: GEMINI_API_KEY, GROK_API_KEY, GROK_MODEL, GROQ_API_KEY, GOOGLE_MAPS_API_KEY, BACKEND_BASE_URL. Every value can be overridden at build time with --dart-define. When BACKEND_BASE_URL is unset, AppConfig picks a sensible default per platform (10.0.2.2 for the Android emulator, localhost for iOS/desktop/web).

4. Firebase

cd MedQuick
firebase deploy --only firestore:rules
python backend/scripts/setup_firestore.py
python backend/scripts/create_admin_user.py

API surface

Prefix Purpose
/api/health Liveness and connectivity checks
/api/auth Login, email OTP send/verify, username availability
/api/patients Profile, symptom submission, prescriptions, orders
/api/doctors Pending prescriptions, approve, reject
/api/pharmacies Available riders, pending orders, order status updates
/api/riders Assigned and nearby deliveries, delivery status updates
/api/admin Dashboard stats, activity feed, user CRUD, account status
/api/ai health, analyze-chat, chat, intake

Data model

Firestore collections: users (role-scoped profiles), prescriptions, deliveries, chats + chats/{id}/messages, consultations, notifications, inventory.

Order lifecycle: pending → doctor approved / declined → pharmacy preparing → rider assigned → picked_up → in_transit / out_for_delivery → delivered, with cancelled reachable from the active states. Each transition writes a notification to the affected user and pushes through FCM.

Disclaimer

MedQuick is a final-year academic project. All AI output is advisory only, is explicitly labelled as such in the UI, and is gated behind licensed-doctor approval before any medicine is dispensed. It is not a substitute for professional medical advice, diagnosis or treatment.

About

Cross-platform AI-powered healthcare assistance and medicine delivery system

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages