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.
- 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
- 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
- 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
- Native iOS and Android support
- Dark/Light theme support
- Accessibility compliant (WCAG 2.1 AA)
- Responsive layout design
- Pull-to-refresh data sync
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
- Node.js 18+ LTS
- npm 9+ or yarn 1.22+
- React Native CLI
- Xcode 15+ (iOS development)
- Android Studio (Android development)
- CocoaPods (iOS dependencies)
# Navigate to project directory
cd smart-fhir-app
# Install dependencies
npm install
# iOS only: Install pods
cd ios && pod install && cd ..# Copy environment template
cp .env.example .env
# Edit .env with your configurationRequired environment variables:
FHIR_BASE_URL- Your FHIR server base URLAUTH_CLIENT_ID- OAuth2 client IDAUTH_REDIRECT_URL- OAuth2 redirect URIENCRYPTION_KEY- 32-byte encryption key (base64)
# Start Metro bundler
npm start
# iOS (in separate terminal)
npm run ios
# Android (in separate terminal)
npm run androidThe 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);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',
},
};| 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 |
- All PHI encrypted at rest using AES-256-GCM
- Secure storage via iOS Keychain / Android Keystore
- Certificate pinning for API calls
- Automatic session timeout
- HIPAA-compliant data handling
- HL7 FHIR R4 standard compliance
- PHI redaction in logs
- Audit trail support
# Run unit tests
npm test
# Run with coverage
npm run test:coverage
# Run E2E tests (Detox)
npm run e2e:ios
npm run e2e:android# Build release
cd ios && xcodebuild -workspace SmartFHIR.xcworkspace \
-scheme SmartFHIR \
-configuration Release \
-archivePath build/SmartFHIR.xcarchive \
archive# Build release APK
cd android && ./gradlew assembleRelease
# Build release AAB (for Play Store)
cd android && ./gradlew bundleReleaseimport { 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',
});import { useAppSelector, useAppDispatch } from './store';
import { selectCurrentPatient } from './store/slices/authSlice';
// In component
const patient = useAppSelector(selectCurrentPatient);
const dispatch = useAppDispatch();import { useObservations, useVitals } from './query/useFHIRData';
const { data, isLoading, refetch } = useVitals(patientId, providerUrl);- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- HL7 FHIR - Healthcare interoperability standard
- SMART on FHIR - App authorization framework
- React Native - Cross-platform mobile framework
- React Navigation - Navigation library
- Redux Toolkit - State management
- TanStack Query - Data fetching
For support, email support@smartfhir.app or open an issue on GitHub.