Chat with your medical records on your iPhone or iPad—an Apple HealthKit App powered by on-device LLM.
Connect to your Health Recrod thru Health App • Sync your data from Prociders EHR
Share your Healthkit record with the App
Chat with your health records • View medications and labs • Track trends over time
📋 Quick Links:
- 👤 For Users:
- User Guide - How to use AgentCare
- User Consent & Health Records Setup - Connecting your health records
- Privacy Policy - Your data stays on your device
- 👨💻 For Developers:
- Developer Setup - Building from source
- Contributing - How to contribute
- Troubleshooting - Common issues
- Natural Language Interface: Ask questions about your health records in plain English
- On-Device AI: Uses MLX Swift with Qwen2.5-3B-Instruct-4bit model for completely private, local inference
- HealthKit Integration: Direct access to clinical records (FHIR R4)
- Trend Visualization: Automatic chart generation for lab results and vital signs over time
- Smart Data Filtering: Intelligently prioritizes relevant information based on your question
- Privacy First: All processing happens on your device - no cloud, no data collection
- 💊 Medications and prescriptions
⚠️ Allergies and intolerances- 🧪 Lab results and tests
- 💉 Immunizations and vaccines
- 🩺 Medical conditions and diagnoses
- 🏥 Procedures and treatments
- ❤️ Vital signs (blood pressure, heart rate, weight, etc.)
- iOS 16.0+
- Xcode 15.0+
- Physical iPhone/iPad with Metal GPU (MLX does not work on simulator)
- ~3GB free storage for model download
- Health records synced to Apple Health app (see setup below)
AgentCare is completely privacy-first:
- ✅ All data stays on your device
- ✅ No cloud uploads or external API calls
- ✅ You control access via iOS permissions
- ✅ HealthKit data never leaves your device
- ✅ Revoke access anytime in iOS Settings
AgentCare reads your health records through Apple Health app. You need to connect your healthcare provider's records to Apple Health first.
- Open Apple Health App on your iPhone
- Tap your profile picture (top right)
- Tap Health Records
- Tap Add Account or Get Started
- Search for your healthcare provider (hospital, clinic, lab)
- Sign in with your patient portal credentials (e.g., MyChart, Epic, Cerner)
- Authorize Apple Health to download your records
Supported Providers: 800+ healthcare organizations in the US support Apple Health Records, including:
- Major hospital systems (Kaiser, Mayo Clinic, Cleveland Clinic)
- Lab services (Quest, LabCorp)
- Urgent care chains (CVS MinuteClinic)
- University health systems
What Gets Synced:
- Medications and prescriptions
- Allergies and reactions
- Lab results (A1C, cholesterol, etc.)
- Immunizations
- Medical conditions/diagnoses
- Procedures
- Vital signs
Data Format: Apple Health uses FHIR R4 (Fast Healthcare Interoperability Resources) - an international standard for health records.
When you first launch AgentCare:
- Permission Dialog Appears: iOS shows HealthKit authorization
- Review Data Types: See exactly what AgentCare wants to read
- Grant or Deny:
- Allow All - Recommended for full functionality
- Select Individual Types - Choose specific data types
- Don't Allow - App won't work without health record access
What AgentCare Requests:
- ✅ Read-only access to clinical records (FHIR data)
- ❌ No write access - AgentCare cannot modify your health data
- ❌ No fitness data - Only clinical records, not steps/workouts
After granting permission:
- Open AgentCare
- Wait for model download (first time only)
- Ask a test question: "What medications am I taking?"
- If you see your actual medications → ✅ Connected!
- If you see "No active medications" → Check permissions
View/Change Permissions:
- iOS Settings → Privacy & Security → Health → agentcare
- Toggle individual data types on/off
- Changes take effect immediately
Revoke All Access:
- iOS Settings → Privacy & Security → Health → agentcare
- Toggle off all permissions OR delete the app
- Right to Access: You control what AgentCare can read
- Right to Revoke: Remove access anytime
- Right to Delete: Uninstall removes all local data
- Right to Know: Code is open-source - verify privacy claims yourself
Q: Does my healthcare provider know I'm using AgentCare? A: No. AgentCare reads data from Apple Health, not directly from your provider.
Q: Can AgentCare see health data I manually entered in Apple Health? A: No. AgentCare only reads clinical records (FHIR data) synced from healthcare providers, not manually-entered data.
Q: What if I don't have health records in Apple Health? A: You won't be able to use AgentCare. You must first connect your healthcare provider to Apple Health (see Step 1 above).
Q: Can AgentCare access health data from other apps (fitness trackers, etc.)? A: No. AgentCare only requests access to clinical records, not fitness/activity data.
Q: Will my health records be used to train AI models? A: No. All processing happens on-device. Your data never leaves your phone.
Here's how your health data flows (all on-device):
┌─────────────────────────────────────────────────────────────────┐
│ YOUR HEALTHCARE PROVIDER │
│ (Hospital, Clinic, Lab, etc.) │
└────────────────────────────┬────────────────────────────────────┘
│
│ FHIR R4 via Patient Portal
│ (You authorize this connection)
▼
┌─────────────────────────────────────────────────────────────────┐
│ APPLE HEALTH APP │
│ (Built into iOS, Apple-managed) │
│ │
│ Stores: Medications, Allergies, Labs, Conditions, etc. │
└────────────────────────────┬────────────────────────────────────┘
│
│ HealthKit API (Read-Only)
│ (You authorize this in iOS Settings)
▼
┌─────────────────────────────────────────────────────────────────┐
│ AGENTCARE │
│ (This App, On-Device) │
│ │
│ 1. Reads health records via HealthKit │
│ 2. Processes with local LLM (MLX/Qwen) │
│ 3. Generates natural language responses │
│ 4. Never sends data off device │
└─────────────────────────────────────────────────────────────────┘
NO CLOUD ❌ | NO SERVERS ❌ | NO API CALLS ❌ | NO DATA COLLECTION ❌
Key Points:
- Your provider → Apple Health: Direct FHIR connection (you authorize)
- Apple Health → AgentCare: iOS HealthKit permission (you control)
- AgentCare → Cloud: Never happens
- All AI processing: On your device using MLX
git clone https://github.com/yourusername/agentcare-ios.git
cd agentcare-ios/agentcareopen agentcare.xcodeprojThe project uses Swift Package Manager for MLX Swift dependencies. These should resolve automatically when you open the project, but if needed:
- In Xcode, go to File → Add Package Dependencies
- Add the following package:
- URL:
https://github.com/ml-explore/mlx-swift-lm - Branch:
main
- URL:
- Select both products:
MLXLLMMLXLMCommon
The packages will be fetched and built automatically. This may take 2-5 minutes on first build.
- Select the agentcare target in Xcode
- Go to Signing & Capabilities tab
- Set your Team and Bundle Identifier
Required Capabilities (already configured in agentcare.entitlements):
- ✅ HealthKit - Read access to clinical records
- ✅ Health Records - FHIR R4 data access
- ✅ Siri - App Intents support (optional)
- ✅ App Groups - For Siri/Shortcuts communication
If you want to use Siri/Shortcuts, update the app group identifier:
- In Signing & Capabilities, click on App Groups
- Change
group.com.xxx.agentcareto your own identifier - Update the same in
AskHealthQuestionIntent.swift:30
IMPORTANT: Must use a physical iPhone/iPad - MLX does not work on simulator.
- Select your physical device in Xcode
- Build and run (⌘R)
- Grant HealthKit permissions when prompted
Prerequisites:
- ✅ Health records synced to Apple Health app (see "User Consent & Health Records Setup" above)
- ✅ Physical iPhone/iPad connected to Xcode
- ✅ At least 3GB free storage
1. HealthKit Permissions (First time only)
- iOS will show permission dialog
- Tap "Allow" to grant access to clinical records
- See "User Consent & Health Records Setup" section for details on what you're authorizing
- Without this permission, the app cannot function
2. Model Download (First time only)
- Automatic: Model downloads on first app launch (~1.9GB)
- Duration: 3-10 minutes depending on WiFi speed
- Location: Cached locally in app container (not in iCloud)
- Progress: Check Xcode console for download progress
3. Shader Compilation (First time only)
- First inference takes 10-30 seconds for one-time Metal shader compilation
- Subsequent responses will be 2-5 seconds
4. Ready to Use
- When you see "🎉 MLX ready for fast inference!" in console
- Ask your first question: "What medications am I taking?"
🔄 Loading MLX model on physical device...
📥 Downloading model: mlx-community/Qwen2.5-3B-Instruct-4bit
📊 Download progress: 25%
✅ Model loaded, initializing ChatSession...
🔥 Warming up Metal shaders...
✅ Metal shaders compiled and cached!
🎉 MLX ready for fast inference!
Basic Questions:
- "What medications am I taking?"
- "Do I have any allergies?"
- "What was my last A1C result?"
Trend Analysis:
- "Show me my A1C trend over time"
- "How has my blood pressure changed?"
- "Track my weight over the past year"
Follow-up Context:
- The app maintains conversation history for contextual follow-ups
- Example: "What about cholesterol?" after asking about lab results
- MLX Swift: Apple's ML framework for local LLM inference
- HealthKit/FHIR: Direct access to iOS clinical records
- SwiftUI: Modern declarative UI
- Charts: Native trend visualization
User Question
↓
ChatViewModel (UI State)
↓
HealthAgent (Orchestrator)
├─→ Keyword Analysis → Tools Selection
├─→ ClinicalRecordsManager → HealthKit/FHIR → Health Records
├─→ Build Context (records + history)
└─→ LLMService
├─→ Fresh ChatSession (stateless)
├─→ MLX Model (Qwen 3B, on-device)
└─→ Generate Response
↓
Natural Language Answer
↓
Chart Generation (if trend question)
↓
ChatView (Display to User)
agentcare/
├── App/ # App entry point
├── Models/ # Data models (ChatMessage, ChartData)
├── Views/ # SwiftUI views (ChatView, PermissionsView)
├── ViewModels/ # View models (ChatViewModel)
├── Services/ # Core services
│ ├── LLMService.swift # MLX model management & generation
│ ├── HealthAgent.swift # Tool calling & orchestration
│ ├── ClinicalRecordsManager.swift # HealthKit/FHIR integration
│ └── SafetyFilter.swift # Safety guardrails (optional)
├── Entities/ # AppIntent entities for Siri
├── Intents/ # Siri Shortcuts support
└── Resources/ # Entitlements, assets
Key Files:
- LLMService.swift: Stateless session management, conversation history
- HealthAgent.swift: Keyword-based tool selection, smart data filtering
- ChatViewModel.swift: Chat state management, message handling
- ChatView.swift: Message bubbles, charts, keyboard handling
Memory Management:
- Stateless generation (fresh session per query)
- Limited conversation history (1 Q&A pair for 3B model)
- Truncated prompts to prevent memory crashes on mobile
- Smart data filtering to reduce context size
Model:
- Qwen2.5-3B-Instruct-4bit (mlx-community)
- Quantized for mobile performance
- ~1.9GB disk space, ~2-3GB RAM during inference
- Alternative models supported: Change
modelIdentifierinLLMService.swift:135- Smaller:
mlx-community/Llama-3.2-1B-Instruct-4bit(~0.5GB, lower quality) - Larger:
mlx-community/Qwen2.5-7B-Instruct-4bit(~4.5GB, better quality, more RAM)
- Smaller:
This app provides educational information only about your documented health records. It does NOT:
- Diagnose medical conditions
- Recommend treatments or medications
- Advise on medication changes
- Replace healthcare providers
Always consult your healthcare provider for medical advice.
Quick Summary:
- ✅ All data processing happens on-device
- ✅ No cloud services or API calls
- ✅ No data collection or telemetry
- ✅ HealthKit data never leaves your device
- ✅ Open source - verify privacy claims yourself
Problem: App shows mock responses instead of real AI Solution: MLX requires Metal GPU. Run on physical iPhone/iPad, not simulator.
Problem: Model download errors or hangs Solutions:
- Ensure stable WiFi connection (model is ~1.9GB)
- Check free storage space (need ~3GB)
- Restart app to retry download
- Check Xcode console for specific error messages
Problem: Memory pressure from 3B model Current Status: Mitigated with stateless sessions and limited history If it still happens:
- Tap the clear/reset button (↻) in header
- Close and reopen the app
- Consider device with more RAM (8GB+ recommended)
Expected: First generation includes one-time Metal shader compilation After First Time: Subsequent generations should be 2-5 seconds If Always Slow: Check console for errors or memory warnings
Problem: Can't access health records Solution:
- Settings → Privacy & Security → Health → agentcare
- Enable "Health Records" permission
- Restart the app
Problem: App says "No medications found" or similar, even after granting permissions Common Causes:
-
No records in Apple Health
- Open Apple Health app → Browse → Health Records
- If empty, you need to connect your healthcare provider first
- See "User Consent & Health Records Setup" section above
-
Records not synced yet
- Apple Health syncs periodically (not real-time)
- Force sync: Open Apple Health → tap provider → pull to refresh
- Can take a few minutes for initial sync
-
Provider doesn't support Apple Health
- Check: https://www.apple.com/healthcare/health-records/
- Not all providers support FHIR integration
-
Wrong permission granted
- AgentCare needs "Clinical Records" access, not just "Health Data"
- Check iOS Settings → Health → agentcare → ensure clinical types are enabled
Problem: Swift Package resolution fails Solutions:
- File → Packages → Reset Package Caches
- File → Packages → Update to Latest Package Versions
- Clean build folder (⌘⇧K) and rebuild
- Check network/firewall isn't blocking GitHub
Problem: "Failed to register bundle identifier" Solution: Change bundle ID to your own unique identifier in project settings
MIT License - see LICENSE file for details
Contributions welcome! Please open an issue or submit a pull request.









