Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

SMART on FHIR Mobile App

A production-ready React Native mobile application implementing a SMART on FHIR client for accessing medical records on mobile devices. Built with TypeScript and following Clean Architecture principles.

πŸ₯ Features

Authentication & Security

  • OAuth2 SMART on FHIR - Standards-based authentication with healthcare providers
  • PKCE Flow - Proof Key for Code Exchange for enhanced security
  • Two-Factor Authentication - TOTP-based 2FA support
  • Biometric Authentication - Face ID, Touch ID, and Android biometrics
  • Session Management - Automatic token refresh, session timeout warnings
  • E2E Encryption - AES-256-GCM encryption for PHI data

FHIR R4 Compliance

  • Full HL7 FHIR R4 resource support:
    • Patient demographics
    • Observations (vitals, lab results)
    • Diagnostic Reports
    • Encounters
    • Medication Requests
    • Consents
  • Resource validation using Zod schemas
  • Multi-provider data aggregation

Real-Time Features

  • WebSocket Integration - Live EMR updates, new lab results
  • Push Notifications - APNS (iOS) and FCM (Android)
  • Background Sync - Automatic data synchronization
  • Offline Support - View cached data when offline

User Experience

  • Native iOS and Android support
  • Dark/Light theme support
  • Accessibility compliant (WCAG 2.1 AA)
  • Responsive layout design
  • Pull-to-refresh data sync

πŸ—οΈ Architecture

src/
β”œβ”€β”€ domain/           # Business logic layer
β”‚   β”œβ”€β”€ entities/     # FHIR domain models
β”‚   └── usecases/     # Business operations
β”œβ”€β”€ data/             # Data access layer
β”‚   β”œβ”€β”€ auth/         # Authentication service
β”‚   β”œβ”€β”€ fhir/         # FHIR client
β”‚   β”œβ”€β”€ websocket/    # Real-time communication
β”‚   └── notifications/# Push notifications
β”œβ”€β”€ infrastructure/   # External services
β”‚   β”œβ”€β”€ api/          # HTTP client
β”‚   β”œβ”€β”€ encryption/   # E2E encryption
β”‚   β”œβ”€β”€ storage/      # Secure storage
β”‚   └── validators/   # FHIR validation
β”œβ”€β”€ navigation/       # React Navigation setup
β”œβ”€β”€ query/            # React Query hooks
β”œβ”€β”€ screens/          # UI screens
β”œβ”€β”€ store/            # Redux state management
└── utils/            # Utilities

πŸ“‹ Prerequisites

  • Node.js 18+ LTS
  • npm 9+ or yarn 1.22+
  • React Native CLI
  • Xcode 15+ (iOS development)
  • Android Studio (Android development)
  • CocoaPods (iOS dependencies)

πŸš€ Getting Started

1. Clone and Install

# Navigate to project directory
cd smart-fhir-app

# Install dependencies
npm install

# iOS only: Install pods
cd ios && pod install && cd ..

2. Environment Setup

# Copy environment template
cp .env.example .env

# Edit .env with your configuration

Required environment variables:

  • FHIR_BASE_URL - Your FHIR server base URL
  • AUTH_CLIENT_ID - OAuth2 client ID
  • AUTH_REDIRECT_URL - OAuth2 redirect URI
  • ENCRYPTION_KEY - 32-byte encryption key (base64)

3. Run Development Server

# Start Metro bundler
npm start

# iOS (in separate terminal)
npm run ios

# Android (in separate terminal)
npm run android

πŸ”§ Configuration

OAuth2 SMART on FHIR

The app supports SMART on FHIR launch modes:

Standalone Launch:

const authService = new AuthService();
await authService.startSMARTAuth({
  iss: 'https://fhir.provider.com/r4',
  // Patient selects their EHR
});

EHR Launch:

// Deep link: smartfhir://launch?iss=...&launch=...
await authService.handleEHRLaunch(iss, launchToken);

Provider Registration

Add healthcare providers in src/data/fhir/ProviderRegistry.ts:

const provider: Provider = {
  id: 'provider-uuid',
  name: 'Healthcare System',
  fhirBaseUrl: 'https://fhir.example.com/r4',
  smartConfiguration: {
    authorizationEndpoint: 'https://auth.example.com/authorize',
    tokenEndpoint: 'https://auth.example.com/token',
  },
};

πŸ“± Screens

Screen Description
Welcome Landing page with app features
Provider Select Choose healthcare provider
Login Email/password or SMART auth
2FA Verification TOTP code entry
Dashboard Patient summary overview
Vitals Heart rate, BP, weight, etc.
Lab Results Laboratory observations
Medications Active/past medications
Encounters Visit history
Providers Connected EHR systems
Profile User settings

πŸ” Security

Data Protection

  • All PHI encrypted at rest using AES-256-GCM
  • Secure storage via iOS Keychain / Android Keystore
  • Certificate pinning for API calls
  • Automatic session timeout

Compliance

  • HIPAA-compliant data handling
  • HL7 FHIR R4 standard compliance
  • PHI redaction in logs
  • Audit trail support

πŸ§ͺ Testing

# Run unit tests
npm test

# Run with coverage
npm run test:coverage

# Run E2E tests (Detox)
npm run e2e:ios
npm run e2e:android

πŸ“¦ Building for Production

iOS

# Build release
cd ios && xcodebuild -workspace SmartFHIR.xcworkspace \
  -scheme SmartFHIR \
  -configuration Release \
  -archivePath build/SmartFHIR.xcarchive \
  archive

Android

# Build release APK
cd android && ./gradlew assembleRelease

# Build release AAB (for Play Store)
cd android && ./gradlew bundleRelease

πŸ“– API Documentation

FHIR Client

import { FHIRClient } from './data/fhir/FHIRClient';

const client = new FHIRClient(provider, accessToken);

// Fetch patient
const patient = await client.getPatient(patientId);

// Fetch observations
const vitals = await client.getObservations(patientId, {
  category: 'vital-signs',
  dateFrom: '2024-01-01',
});

// Fetch medications
const meds = await client.getMedicationRequests(patientId, {
  status: 'active',
});

State Management

import { useAppSelector, useAppDispatch } from './store';
import { selectCurrentPatient } from './store/slices/authSlice';

// In component
const patient = useAppSelector(selectCurrentPatient);
const dispatch = useAppDispatch();

React Query Hooks

import { useObservations, useVitals } from './query/useFHIRData';

const { data, isLoading, refetch } = useVitals(patientId, providerUrl);

🀝 Contributing

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

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

πŸ“ž Support

For support, email support@smartfhir.app or open an issue on GitHub.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages