Skip to content

BeatHF — Heart failure management iOS app - Stanford CardinalKit Buildathon 2020

License

Notifications You must be signed in to change notification settings

stevederico/beatHF

Repository files navigation

BeatHF - Heart Failure Management iOS App

BeatHF Survey BeatHF Alert BeatHF Warnings

Overview

BeatHF is a heart failure management iOS app developed for the Stanford Biodesign CardinalKit Buildathon 2020. The app helps reduce hospital readmissions for patients with congestive heart failure by monitoring symptoms and providing early intervention alerts.

Problem: Patients with advanced congestive heart failure have some of the highest hospital readmission rates. Many readmissions are preventable if early warning symptoms (particularly weight gain) are identified and treated with oral medications.

Solution: BeatHF provides daily symptom tracking, heart rate monitoring via HealthKit, and a tiered alert system to help patients self-manage their condition and know when to contact their doctor.

Features

Daily Symptom Survey

14-question assessment covering:

  • Medication adherence
  • Shortness of breath (with branching logic for severity)
  • Weight gain monitoring (2-3 lbs overnight / 5 lbs per week)
  • Sleep disturbances
  • Dizziness/syncope
  • Rapid heartbeat
  • Chest pain
  • Swelling

Heart Rate Monitoring

  • Integrates with HealthKit
  • Analyzes last 24 hours of heart rate data
  • Alerts if heart rate is <40 or >120 bpm
  • Visual status indicators (green checkmark / red warning)

Alert System

  • Yellow Alerts: Mild symptoms - monitor closely
  • Orange Alerts: Moderate symptoms - contact doctor today
  • Red Alerts: Severe symptoms - call doctor immediately or 911

Research Framework

  • Built on CardinalKit (Stanford's medical research platform)
  • Secure onboarding and consent flow
  • Data synced to Firebase
  • HIPAA-compliant data handling
  • Profile and progress tracking

Tech Stack

  • Framework: CardinalKit (Stanford)
  • UI: ResearchKit (Apple's research framework)
  • Backend: Firebase (Firestore, Auth, Storage, Analytics)
  • Health Data: HealthKit
  • Language: Swift
  • Dependency Manager: CocoaPods

Prerequisites

  • macOS with Xcode 11+
  • CocoaPods installed (sudo gem install cocoapods)
  • iOS 13.0+ device or simulator
  • Firebase project (free tier is sufficient)
  • Apple Developer account (for HealthKit entitlements)

Setup Instructions

1. Clone the Repository

git clone https://github.com/yourusername/beatHF.git
cd beatHF

2. Configure Firebase

  1. Go to Firebase Console
  2. Create a new project (or use existing)
  3. Add an iOS app to your project
  4. Download the GoogleService-Info.plist file
  5. Copy it to CardinalKit-Example/CardinalKit/Supporting Files/
# The project includes a template file showing the structure
cp CardinalKit-Example/CardinalKit/Supporting\ Files/GoogleService-Info-Template.plist \
   CardinalKit-Example/CardinalKit/Supporting\ Files/GoogleService-Info.plist

# Edit GoogleService-Info.plist with your Firebase credentials
  1. Enable Firestore Database in Firebase Console
  2. Enable Authentication → Email/Password provider
  3. Enable Storage

3. Update Bundle Identifiers

Update the bundle identifier in:

  • CardinalKit-Example/CardinalKit.xcodeproj/project.pbxproj
  • CardinalKit-Example/CardinalKit/Supporting Files/Info.plist
  • CardinalKit-Example/CardinalKit-Example.entitlements

Replace com.yourcompany.yourapp with your actual bundle ID.

4. Configure HealthKit

  1. Open CardinalKit.xcodeproj in Xcode
  2. Select the CardinalKit_Example target
  3. Go to "Signing & Capabilities"
  4. Add your Apple Developer Team
  5. Enable HealthKit capability

5. Update Contact Information

Edit CardinalKit-Example/CardinalKit/Components/Profile/StaticProfileViewController.swift:

// Line 84: Update support email
mailComposeViewController.setToRecipients(["your-support@email.com"])

// Line 68: Update support phone
guard let number = URL(string: "tel://YOUR_PHONE_NUMBER") else { return }

6. Install Dependencies

cd CardinalKit-Example
pod install

7. Open and Run

open CardinalKit.xcworkspace

Build and run on a physical device (HealthKit doesn't work in simulator).

Project Structure

beatHF/
├── CardinalKit/                    # CardinalKit framework source
│   └── Source/
│       ├── Components/             # Core framework modules
│       └── Supporting Files/       # Utilities & extensions
├── CardinalKit-Example/            # BeatHF app implementation
│   └── CardinalKit/
│       ├── Components/
│       │   ├── Study/              # Survey tasks & questions
│       │   ├── Onboarding/         # Consent & registration
│       │   ├── Profile/            # User profile & settings
│       │   └── Networking/         # Firebase integration
│       ├── Supporting Files/
│       │   ├── CKConfiguration.plist   # App configuration
│       │   └── GoogleService-Info.plist # Firebase config (not in repo)
│       └── HeartRateReview.swift   # Heart rate monitoring
└── README.md

Configuration

Consent Form

Edit CardinalKit-Example/CardinalKit/Supporting Files/CKConfiguration.plist to customize:

  • Consent form sections
  • Onboarding text
  • Health permissions requests
  • App colors

Survey Questions

Edit CardinalKit-Example/CardinalKit/Components/Study/StudyTasks.swift to modify:

  • Question text
  • Branching logic
  • Alert thresholds

Heart Rate Thresholds

Edit CardinalKit-Example/HeartRateReview.swift:

// Line 21: Modify heart rate alert thresholds
if heartRate < 40 || heartRate > 120 {
    // Trigger warning
}

Firebase Security Rules

Set up Firestore security rules:

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId}/{document=**} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }
  }
}

Testing

  1. Onboarding Flow: Test consent, registration, and HealthKit permissions
  2. Daily Survey: Complete survey with various answer combinations
  3. Heart Rate Monitoring: Check alert logic with simulated data
  4. Data Sync: Verify data appears in Firebase console
  5. Profile: Test passcode change, contact support, withdrawal

Known Limitations

  • Requires iOS 13.0+ (project from 2020)
  • HealthKit only works on physical devices
  • Firebase Realtime Database deprecated (migrate to Firestore)
  • ResearchKit dependency may need updates for newer iOS versions

Clinical Validation

This app is a prototype developed during a 48-hour buildathon. It should NOT be used for actual patient care without:

  • Clinical validation studies
  • IRB approval
  • FDA clearance (if applicable)
  • Proper medical oversight
  • Updated dependencies and security review

Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Resources

Credits

  • Original Team: Stanford Biodesign CardinalKit Buildathon 2020
  • Framework: CardinalKit by Stanford University
  • Research Tools: ResearchKit by Apple
  • Backend: Firebase by Google

License

MIT License - see LICENSE file for details.

Disclaimer

This software is provided for educational and research purposes only. It is not intended for use in medical diagnosis or treatment. Always consult with qualified healthcare professionals for medical advice.

Support

For questions about:

About

BeatHF — Heart failure management iOS app - Stanford CardinalKit Buildathon 2020

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published