Skip to content

yaznzee/MedGuard

Repository files navigation

MedGuard - Personalized Drug Safety Analyzer

Hack@Brown 2026 Winner!

MedGuard Logo iOS Swift

🎯 Project Overview

MedGuard is an iOS app that provides personalized drug safety analysis by combining:

  • Genetic Testing (23andMe) - Analyzes cytochrome P450 enzyme variants
  • Drug Interaction Database - Checks for drug-drug and gene-drug interactions
  • Vital Signs Monitoring - Uses Presage SDK to track heart rate & breathing
  • AI-Powered Insights - Gemini API generates comprehensive safety reports

The Problem We're Solving

When patients start new medications, doctors rely on general clinical evidence, but individual genetic variations can cause unexpected reactions. MedGuard provides a personalized risk assessment before the first dose.

Traffic Light System

  • 🟒 GREEN - No significant interactions β†’ Proceed safely
  • 🟑 YELLOW - Potential interaction β†’ Monitor vitals for 2-4 hours
  • πŸ”΄ RED - High risk β†’ Consult physician immediately

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           iOS App (Swift/SwiftUI)           β”‚
β”‚  - User Interface                           β”‚
β”‚  - Presage SDK Integration (vitals)         β”‚
β”‚  - File handling (23andMe data)             β”‚
β”‚  - Local state management                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β”‚ API Calls
                   β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚       Backend Service (optional)            β”‚
β”‚  - Drug interaction database queries        β”‚
β”‚  - Activity score calculations              β”‚
β”‚  - Gemini API integration                   β”‚
β”‚  - Secure API key management                β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Note: For the hackathon demo, all processing happens client-side in the iOS app for simplicity. The backend is optional and can be added later for production.

πŸ“± Features

1. DNA Profile Upload

  • Import 23andMe raw genetic data
  • Automatically extracts cytochrome P450 genes:
    • CYP2D6 - Affects 25% of drugs (codeine, metoprolol, etc.)
    • CYP2C19 - Metabolizes PPIs, antidepressants
    • CYP2C9 - Processes warfarin, NSAIDs
    • CYP3A4/5 - Metabolizes 50% of medications
    • CYP1A2 - Processes caffeine, antipsychotics

2. Medication Management

  • Add all current and planned medications
  • Track dosage and frequency
  • Easy edit and delete functionality

3. Baseline Vitals Monitoring

  • 30-second camera-based measurement
  • Records heart rate and breathing rate
  • Uses Presage SDK for medical-grade accuracy

4. Interaction Analysis

  • Activity Score Calculation

    • Genetic factors (CYP variants)
    • Demographic factors (age, sex)
    • Lifestyle factors (smoking, alcohol)
  • Drug-Drug Interaction (DDI) Detection

    • Cross-references medication list
    • Identifies known dangerous combinations
  • Gene-Drug Interaction (GDI) Detection

    • Matches medications to genetic profile
    • Identifies poor/ultra-rapid metabolizers
  • AI Report Generation (Gemini)

    • Concise patient summary
    • Detailed clinical explanation
    • Specific actionable recommendations

5. Follow-up Monitoring

  • Track vitals after taking medication
  • Compare to baseline measurements
  • Alert on significant changes (Ξ”HR > 20 BPM or Ξ”BR > 5 BPM)

πŸš€ Getting Started

Prerequisites

  1. macOS with Xcode 15.0 or later
  2. iOS Device (iPhone with camera) - Simulator won't work for Presage SDK
  3. 23andMe Account (for DNA data)
  4. Presage API Key - Get from https://physiology.presagetech.com

Installation Steps

1. Clone and Setup

# Create new Xcode project
# File β†’ New β†’ Project β†’ iOS β†’ App
# Name: MedGuard
# Interface: SwiftUI
# Language: Swift

2. Add Presage SDK

# Download SmartSpectra Swift SDK
# Add to your project as a local Swift Package
# File β†’ Add Package Dependencies β†’ Add Local
# Select the SDK folder from the documentation

3. Add Project Files

Copy these files into your Xcode project:

MedGuard/
β”œβ”€β”€ ContentView.swift           # Main app view
β”œβ”€β”€ AppState.swift              # Data models & API service
β”œβ”€β”€ VitalsMonitorView.swift     # Presage integration
β”œβ”€β”€ MedicationInputView.swift   # Medication management
β”œβ”€β”€ DNAUploadView.swift         # 23andMe upload
β”œβ”€β”€ AnalysisResultsView.swift   # Results display
└── Info.plist                  # Camera permissions

4. Configure Info.plist

Add camera permission:

<key>NSCameraUsageDescription</key>
<string>Required for measuring heart rate and breathing using camera</string>

5. Add API Keys

In ContentView.swift:

// Replace with your Presage API key
let apiKey = "YOUR_PRESAGE_API_KEY"
sdk.setApiKey(apiKey)

Gemini API key is already included in AppState.swift:

private let geminiAPIKey = "AIzaSyAg24n-YWgkJf8aka251yUPEkKTOLFBdiM"

6. Build and Run

  1. Connect your iPhone via USB
  2. Select your device in Xcode
  3. Click Run (⌘R)
  4. Grant camera permission when prompted

πŸ“Š How It Works

Activity Score Formula

score = 1.0 (baseline)

// Genetic factors
if CYP2D6 == "TT": score *= 0.5  // Poor metabolizer
if CYP2C19 == "AA": score *= 0.5
if CYP2C9 != "CC": score *= 0.9

// Demographics
if age > 65: score *= 0.8
if sex == "Female": score *= 0.95

// Lifestyle
if smoking: score *= 1.2 (increased CYP1A2)
if heavy alcohol: score *= 0.85

Risk Level Determination

interactions_count = DDI.count + GDI.count

if interactions >= 3 OR score < 0.5 OR score > 1.5:
    return RED (danger)
else if interactions >= 1 OR score < 0.7 OR score > 1.3:
    return YELLOW (caution)
else if interactions == 0 AND 0.8 <= score <= 1.2:
    return GREEN (safe)
else:
    return GRAY (unknown)

🎨 UI/UX Highlights

  • Gradient Backgrounds - Modern, professional look
  • Step-by-step Workflow - Clear progression through analysis
  • Traffic Light Visual - Instant risk understanding
  • Real-time Vitals - Live heart rate and breathing display
  • Shareable Reports - Export to share with doctors

πŸ§ͺ Testing

Demo Flow

  1. Upload Sample DNA

    • Use provided sample 23andMe file
    • Or create mock data with known CYP variants
  2. Add Test Medications

    • Example: Warfarin + Aspirin (DDI)
    • Example: Codeine + CYP2D6*4/*4 (GDI)
  3. Record Baseline

    • Use camera to measure vitals
    • ~30 seconds for accurate reading
  4. Run Analysis

    • AI generates comprehensive report
    • Risk level displayed as traffic light
  5. Monitor (if yellow/red)

    • Take medication
    • Measure vitals after 2-4 hours
    • Compare to baseline

Expected Results

Safe (Green):

Medication: Acetaminophen
DNA: Normal CYP2E1
Result: No interactions, normal metabolism

Caution (Yellow):

Medications: Warfarin + Ibuprofen
Result: Increased bleeding risk
Action: Monitor for bruising/bleeding

Danger (Red):

Medication: Codeine
DNA: CYP2D6 *4/*4 (poor metabolizer)
Result: Reduced pain relief, risk of side effects
Action: Consult physician for alternative

πŸ“¦ Dependencies

// Package.swift
dependencies: [
    .package(path: "../SmartSpectraSwiftSDK")  // Presage SDK
]

No backend required for demo! Everything runs client-side.

🚧 Future Enhancements

  • Backend API for drug database
  • HealthKit integration (sleep, activity)
  • Push notifications for monitoring reminders
  • Family sharing (monitor elderly relatives)
  • Pharmacy integration (auto-check new prescriptions)
  • Wearable support (Apple Watch vitals)
  • Multilingual support
  • HIPAA compliance for production

🀝 Contributing

This is a hackathon project! Feel free to:

  • Fork and improve
  • Add more drug interactions
  • Enhance UI/UX
  • Integrate additional data sources

πŸ“„ License

MIT License - Build upon this for your own projects!

πŸ† Hack@Brown 2026

Team: ARC
Track: Health Tech / AI
Built with: Swift, SwiftUI, Presage SDK, Gemini API


Made with ❀️ for safer medication use

For questions or demo requests, contact: yaa2076@nyu.edu

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages