### Start, Monitor, and End Running Workout Session Source: https://github.com/crowded-libs/vitality/blob/main/README.md This Kotlin code demonstrates starting a running workout session using the health connector. It shows two methods for starting: a simple version and one with a detailed configuration object. The code also includes observing active workout metrics (distance, calories, duration) and heart rate, pausing and resuming the session, and finally ending it, with error handling and fetching summary data. ```kotlin import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.launch import kotlin.time.Duration.Companion.minutes import kotlin.time.Duration.Companion.seconds // Start a workout session suspend fun startRunningWorkout() { // Method 1: Simple workout start val sessionResult = healthConnector.startWorkoutSession( workoutType = WorkoutType.RUNNING, title = "Morning Run", metadata = mapOf("surface" to "outdoor", "weather" to "sunny") ) // Method 2: With configuration object val config = WorkoutConfiguration( type = WorkoutType.RUNNING, isIndoor = false, enableGpsTracking = true, metadata = mapOf("surface" to "track") ) val result = healthConnector.startWorkoutSession(config) val session = result.getOrElse { println("Failed to start workout: $it") return } val sessionId = session.id val sessionStartTime = Clock.System.now() // Monitor real-time metrics during workout using Flow launch { healthConnector.observeActiveWorkout() .collect { println("Distance: ${it.totalDistance} m") println("Calories: ${it.totalCalories} kcal") println("Duration: ${it.duration}") } } // Monitor heart rate separately launch { val heartRateFlow: Flow = healthConnector.observe( HealthDataType.HeartRate, samplingInterval = 5.seconds ) heartRateFlow.collect { println("Current heart rate: ${it.beatsPerMinute} bpm") } } // Workout control flow delay(5.minutes) // Pause workout healthConnector.pauseWorkoutSession(sessionId) println("Workout paused") delay(30.seconds) // Resume workout healthConnector.resumeWorkoutSession(sessionId) println("Workout resumed") delay(10.minutes) // End workout val endResult = healthConnector.endWorkoutSession(sessionId) endResult.fold( onSuccess = { println("Workout completed!") // Fetch workout data separately if you need summary statistics val workoutResult = healthConnector.readWorkouts( startDate = sessionStartTime, endDate = Clock.System.now() ) workoutResult.getOrNull()?.firstOrNull()?.let { println("Duration: ${it.duration}") println("Total calories: ${it.totalCalories} kcal") println("Total distance: ${it.totalDistance} meters") } }, onFailure = { println("Failed to end workout: $it") // Optionally discard the session healthConnector.discardWorkoutSession(sessionId) } ) } ``` -------------------------------- ### HealthKitConnector iOS Example Source: https://github.com/crowded-libs/vitality/blob/main/README.md Demonstrates the usage of HealthConnector on iOS, specifically with HealthKitConnector. It shows how to retrieve platform capabilities, observe heart rate data in the background, and check for connected wearable devices like the Apple Watch. ```Swift val connector = createHealthConnector() // Automatically creates HealthKitConnector on iOS // Check platform capabilities val capabilities = connector.getPlatformCapabilities() println("Running on: ${capabilities.platformName}") println("Version: ${capabilities.platformVersion}") println("Supports background delivery: ${capabilities.supportsBackgroundDelivery}") println("Supports workout routes: ${capabilities.supportsWorkoutRoutes}") // iOS-specific features - background delivery val heartRateFlow: Flow = connector.observe(HealthDataType.HeartRate) heartRateFlow .collect { heartRate -> // Will deliver updates even when app is in background on iOS println("Background HR update: ${heartRate.bpm}") } // Check for Apple Watch if (capabilities.hasWearableDevice) { println("Apple Watch connected") } ``` -------------------------------- ### Read Today's Health Data (Steps, Heart Rate) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Provides examples for reading today's step count and the latest heart rate data. It utilizes convenience methods provided by the HealthConnector and includes error handling for each read operation. ```kotlin import vitality.* import vitality.models.* import kotlinx.coroutines.* // Read health data - convenience methods suspend fun readTodaysData() { // Read today's steps val stepsResult = healthConnector.readStepsToday() stepsResult.fold( onSuccess = { steps -> println("Steps today: ${steps.count}") }, onFailure = { exception -> println("Failed to read steps: $exception") } ) // Read latest heart rate val heartRateResult = healthConnector.readLatestHeartRate() heartRateResult.fold( onSuccess = { heartRate -> heartRate?.let { println("Latest heart rate: ${it.bpm} bpm") } ?: println("No heart rate data available") }, onFailure = { exception -> println("Failed to read heart rate: $exception") } ) } ``` -------------------------------- ### Read Historical Health Data (Heart Rate) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Demonstrates how to read historical health data, specifically heart rate, within a specified date range (last 7 days). It shows how to define start and end times and process the returned data points. ```kotlin import vitality.* import vitality.models.* import kotlinx.coroutines.* import kotlinx.datetime.Clock import kotlin.time.Duration.Companion.days // Read historical data suspend fun readHistoricalData() { val endTime = Clock.System.now() val startTime = endTime.minus(7.days) val result = healthConnector.readHealthData( dataType = HealthDataType.HeartRate, startDate = startTime, endDate = endTime ) result.fold( onSuccess = { dataPoints -> dataPoints.forEach { dataPoint -> println("Health data: ${dataPoint.value} ${dataPoint.unit} at ${dataPoint.timestamp}") } }, onFailure = { exception -> println("Failed to read health data: $exception") } ) } ``` -------------------------------- ### Get Daily Fitness Statistics Source: https://github.com/crowded-libs/vitality/blob/main/README.md Fetches daily statistics for multiple health data types including Steps, Calories, Distance, and HeartRate. It iterates through a set of data types, calling readStatistics for each. The statistic options are conditionally applied based on the data type, and results are printed accordingly. ```Kotlin suspend fun getDailyFitnessStats() { val today = Clock.System.now() val yesterday = today.minus(1.days) val dataTypes = setOf( HealthDataType.Steps, HealthDataType.Calories, HealthDataType.Distance, HealthDataType.HeartRate ) dataTypes.forEach { dataType -> val result = healthConnector.readStatistics( dataType = dataType, startDate = yesterday, endDate = today, statisticOptions = when (dataType) { HealthDataType.HeartRate -> setOf(StatisticOption.AVERAGE) else -> setOf(StatisticOption.TOTAL) } ) result.fold( onSuccess = { stats -> println("\n$dataType statistics:") when (dataType) { HealthDataType.Steps, HealthDataType.Calories, HealthDataType.Distance -> { println("Total: ${stats.total}") } HealthDataType.HeartRate -> { println("Average: ${stats.average}") } else -> { println("Data: $stats") } } }, onFailure = { exception -> println("Failed to get $dataType stats: $exception") } ) } } ``` -------------------------------- ### Get Weekly Heart Rate Statistics Source: https://github.com/crowded-libs/vitality/blob/main/README.md Retrieves weekly heart rate statistics including average, minimum, and maximum values. It uses the healthConnector to read data within a specified date range and buckets the results by day. Handles success and failure scenarios by printing the results or the exception. ```Kotlin suspend fun getWeeklyHeartRateStats() { val endTime = Clock.System.now() val startTime = endTime.minus(7.days) val result = healthConnector.readStatistics( dataType = HealthDataType.HeartRate, startDate = startTime, endDate = endTime, statisticOptions = setOf( StatisticOption.AVERAGE, StatisticOption.MIN, StatisticOption.MAX ), bucketDuration = 1.days ) result.fold( onSuccess = { stats -> stats.dataPoints.forEach { dataPoint -> println("Date: ${dataPoint.startTime} - ${dataPoint.endTime}") println("Average HR: ${dataPoint.average} bpm") println("Min HR: ${dataPoint.min} bpm") println("Max HR: ${dataPoint.max} bpm") } }, onFailure = { exception -> println("Failed to get statistics: $exception") } ) } ``` -------------------------------- ### Initialize and Observe Health Connect Data (Kotlin) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Demonstrates how to initialize the HealthConnectConnector in Android, retrieve platform capabilities, and observe real-time data streams for Steps and active workouts. It highlights the polling mechanism used for real-time monitoring on Android and the configuration of polling intervals. ```kotlin val connector = createHealthConnector() // Automatically creates HealthConnectConnector on Android // Android requires initialization with context (done in Application.onCreate) // Check platform capabilities val capabilities = connector.getPlatformCapabilities() println("Health Connect version: ${capabilities.platformVersion}") // Real-time monitoring uses polling on Android // Configure polling intervals via platform-specific configuration val stepsFlow: Flow = connector.observe(HealthDataType.Steps) stepsFlow .collect { // Updates based on polling interval (default: 30 seconds) println("Steps update: ${it.count}") } // For workout sessions with more frequent updates connector.observeActiveWorkout() .collect { // More frequent polling during active workouts println("Workout distance: ${it.totalDistance} meters") } ``` -------------------------------- ### Initialize Health Connector and Check Availability Source: https://github.com/crowded-libs/vitality/blob/main/README.md Demonstrates how to create and initialize the HealthConnector, then check for available data types and platform capabilities. It uses Kotlin coroutines for asynchronous operations and `fold` for handling success and failure results. ```kotlin import vitality.* import vitality.models.* import kotlinx.coroutines.* // Create the health connector val healthConnector = createHealthConnector() // Initialize and check availability suspend fun setupHealthAccess() { val result = healthConnector.initialize() result.fold( onSuccess = { println("Health connector initialized successfully") // Check available data types val availableTypes = healthConnector.getAvailableDataTypes() println("Available data types: ${availableTypes.size}") // Check platform capabilities val capabilities = healthConnector.getPlatformCapabilities() println("Platform: ${capabilities.platformName}") }, onFailure = { exception -> println("Initialization failed: $exception") } ) } ``` -------------------------------- ### Monitor Real-time Health Data (Steps, Heart Rate) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Illustrates how to monitor real-time health data streams using Kotlin Flows. It shows how to observe changes in steps with a default interval and heart rate with a custom sampling interval, launching the observation in the GlobalScope. ```kotlin import vitality.* import vitality.models.* import kotlinx.coroutines.* import kotlinx.coroutines.flow.* import kotlin.time.Duration.Companion.seconds // Real-time monitoring with Flow fun monitorHealthData() { // Monitor steps with default update interval val stepsFlow: Flow = healthConnector.observe(HealthDataType.Steps) stepsFlow .onEach { steps -> println("Steps updated: ${steps.count}") } .launchIn(GlobalScope) // Monitor heart rate with custom sampling interval val heartRateFlow: Flow = healthConnector.observe( HealthDataType.HeartRate, samplingInterval = 5.seconds ) heartRateFlow .onEach { heartRate -> println("Heart rate: ${heartRate.bpm} bpm") } .launchIn(GlobalScope) } ``` -------------------------------- ### Initialize HealthConnectorContextProvider (Android Application) Source: https://github.com/crowded-libs/vitality/blob/main/README.md This Kotlin code snippet demonstrates the initialization of HealthConnectorContextProvider within an Android Application class. This is a required step for using Vitality on Android. ```kotlin class MyApplication : Application() { override fun onCreate() { super.onCreate() // Required: Initialize the context provider HealthConnectorContextProvider.initialize(applicationContext) } } ``` -------------------------------- ### HealthKit Usage Descriptions (iOS Info.plist) Source: https://github.com/crowded-libs/vitality/blob/main/README.md This XML snippet shows the required keys and string values to be added to the Info.plist file for iOS applications using HealthKit. These descriptions inform the user why the app needs access to their health data. ```xml NSHealthShareUsageDescription This app reads your health data to provide insights NSHealthUpdateUsageDescription This app updates your health data from workouts ``` -------------------------------- ### Request Health Data Permissions Source: https://github.com/crowded-libs/vitality/blob/main/README.md Shows how to request read and write permissions for specific health data types like HeartRate, Steps, and Calories. The code handles the response, listing granted and denied permissions, and includes error handling. ```kotlin import vitality.* import vitality.models.* import kotlinx.coroutines.* // Request permissions suspend fun requestPermissions() { val permissions = setOf( HealthPermission(HealthDataType.HeartRate, HealthPermission.AccessType.READ), HealthPermission(HealthDataType.Steps, HealthPermission.AccessType.READ), HealthPermission(HealthDataType.Calories, HealthPermission.AccessType.WRITE) ) val result = healthConnector.requestPermissions(permissions) result.fold( onSuccess = { permissionResult -> permissionResult.granted.forEach { println("Granted: ${it.dataType} - ${it.accessType}") } permissionResult.denied.forEach { println("Denied: ${it.dataType} - ${it.accessType}") } }, onFailure = { exception -> println("Permission request failed: $exception") } ) } ``` -------------------------------- ### Read Recent Procedures (Kotlin) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Fetches and displays medical procedures performed within the last six months. It prints the procedure name, status, date of performance, and outcome. Error handling is provided for the procedure data retrieval. ```Kotlin suspend fun getRecentProcedures() { val sixMonthsAgo = Clock.System.now().minus(180.days) val result = healthConnector.readProcedures(startDate = sixMonthsAgo) result.fold( onSuccess = { procedures -> procedures.forEach { procedure -> println("Procedure: ${procedure.code?.text}") println("Status: ${procedure.status}") println("Date: ${procedure.performedDateTime}") println("Outcome: ${procedure.outcome?.text}") } }, onFailure = { exception -> println("Failed to read procedures: $exception") } ) } ``` -------------------------------- ### iOS Background Steps Monitoring Source: https://github.com/crowded-libs/vitality/blob/main/README.md Illustrates the use of background delivery for steps data on iOS. It observes steps updates via a Flow and collects the data to update a widget. This functionality ensures that step counts are continuously received and processed in the background. ```Kotlin // Background delivery works for all Flow-based observers on iOS val stepsFlow: Flow = connector.observe(HealthDataType.Steps) stepsFlow.collect { // Will continue receiving updates in background updateStepWidget(it.count) } ``` -------------------------------- ### Advanced Fitness Metrics - HealthKit and Health Connect Source: https://github.com/crowded-libs/vitality/blob/main/README.md This snippet covers advanced fitness metrics, including Speed, Power, and various running and cycling metrics. It specifies support for HealthKit (iOS) and Health Connect (Android), noting platform-specific availability and version requirements. ```iOS HKQuantityTypeIdentifierRunningStrideLength HKQuantityTypeIdentifierRunningVerticalOscillation HKQuantityTypeIdentifierRunningGroundContactTime HKQuantityTypeIdentifierCyclingCadence HKQuantityTypeIdentifierCyclingPower HKQuantityTypeIdentifierCyclingFunctionalThresholdPower ``` ```Android SpeedRecord PowerRecord CyclingPedalingCadenceRecord PowerRecord ``` -------------------------------- ### Environmental & Audio Data Types - HealthKit Source: https://github.com/crowded-libs/vitality/blob/main/README.md This snippet details environmental and audio exposure data types available through HealthKit on iOS. It includes metrics like EnvironmentalAudioExposure, HeadphoneAudioExposure, UVExposure, and TimeInDaylight, with specific version requirements for TimeInDaylight. ```iOS HKQuantityTypeIdentifierEnvironmentalAudioExposure HKQuantityTypeIdentifierHeadphoneAudioExposure HKQuantityTypeIdentifierUVExposure HKQuantityTypeIdentifierTimeInDaylight ``` -------------------------------- ### HealthConnector Interface Definition Source: https://github.com/crowded-libs/vitality/blob/main/README.md Defines the HealthConnector interface, providing a comprehensive set of methods for health data operations. It covers initialization, data access, permissions, workout management, and clinical record retrieval. ```Kotlin interface HealthConnector { // Initialization and capabilities suspend fun initialize(): Result suspend fun getAvailableDataTypes(): Set suspend fun getPlatformCapabilities(): HealthCapabilities // Permission management suspend fun requestPermissions(permissions: Set): Result suspend fun checkPermissions(permissions: Set): PermissionStatus // Synchronous data reading (one-time fetch) suspend fun readLatestHeartRate(): Result suspend fun readStepsToday(): Result suspend fun readCaloriesToday(): Result suspend fun readLatestWeight(): Result suspend fun readWorkouts(startDate: Instant, endDate: Instant): Result> suspend fun readHealthData( dataType: HealthDataType, startDate: Instant, endDate: Instant ): Result> // Flow-based data streams (continuous monitoring) fun observe( dataType: HealthDataType, samplingInterval: Duration = 30.seconds ): Flow fun observeActiveWorkout(): Flow // Workout session management suspend fun startWorkoutSession( workoutType: WorkoutType, title: String? = null, metadata: Map = emptyMap() ): Result suspend fun startWorkoutSession( configuration: WorkoutConfiguration, title: String? = null ): Result suspend fun pauseWorkoutSession(sessionId: String): Result suspend fun resumeWorkoutSession(sessionId: String): Result suspend fun endWorkoutSession(sessionId: String): Result suspend fun discardWorkoutSession(sessionId: String): Result // Data writing suspend fun writeWeight(weight: Double, unit: WeightUnit, timestamp: Instant = Clock.System.now()): Result suspend fun writeWorkout(workoutData: WorkoutData): Result suspend fun writeHealthData(dataPoint: HealthDataPoint): Result // Statistical queries suspend fun readStatistics( dataType: HealthDataType, startDate: Instant, endDate: Instant, statisticOptions: Set = setOf(StatisticOption.AVERAGE), bucketDuration: Duration? = null ): Result // Clinical Records (FHIR) - Medical data from healthcare providers suspend fun readImmunizations( startDate: Instant? = null, endDate: Instant? = null ): Result> suspend fun readMedications( startDate: Instant? = null, endDate: Instant? = null ): Result> suspend fun readAllergies( includeInactive: Boolean = false ): Result> suspend fun readConditions( includeResolved: Boolean = false ): Result> suspend fun readLabResults( startDate: Instant? = null, endDate: Instant? = null, category: String? = null ): Result> suspend fun readProcedures( startDate: Instant? = null, endDate: Instant? = null ): Result> suspend fun areClinicalRecordsAvailable(): Boolean } ``` -------------------------------- ### Add Vitality Dependency (Gradle Kotlin DSL) Source: https://github.com/crowded-libs/vitality/blob/main/README.md This snippet shows how to add the Vitality library as a dependency in a Gradle project using the Kotlin DSL. Ensure you have the correct version number. ```kotlin dependencies { implementation("io.crowded-libs:vitality:0.1.0") } ``` -------------------------------- ### Read Active Allergies (Kotlin) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Retrieves a list of active allergies for a patient, excluding inactive ones. It prints details for each allergy including the allergen, type, category, criticality, and reactions. Includes error handling for the read operation. ```Kotlin suspend fun getActiveAllergies() { val result = healthConnector.readAllergies(includeInactive = false) result.fold( onSuccess = { allergies -> allergies.forEach { allergy -> println("Allergen: ${allergy.code?.text}") println("Type: ${allergy.type}") println("Category: ${allergy.category.joinToString()}") println("Criticality: ${allergy.criticality}") println("Reactions: ${allergy.reaction.joinToString { it.description ?: "Unknown" }}") } }, onFailure = { exception -> println("Failed to read allergies: $exception") } ) } ``` -------------------------------- ### iOS Background Heart Rate Monitoring Source: https://github.com/crowded-libs/vitality/blob/main/README.md Demonstrates how to enable background delivery for heart rate data on iOS. It checks platform capabilities, observes heart rate updates using a Flow, and processes abnormal heart rates by sending a notification. This allows for continuous monitoring even when the app is suspended. ```Kotlin // iOS supports background delivery for health data val connector = createHealthConnector() // Check platform capabilities val capabilities = connector.getPlatformCapabilities() if (capabilities.supportsBackgroundDelivery) { // Heart rate updates will be delivered even when app is suspended val heartRateFlow: Flow = connector.observe(HealthDataType.HeartRate) heartRateFlow.collect { // Process in background if (it.beatsPerMinute > 100 || it.beatsPerMinute < 50) { sendNotification("Abnormal heart rate: ${it.beatsPerMinute} bpm") } } } ``` -------------------------------- ### Read Medical Conditions (Kotlin) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Fetches and displays a patient's medical conditions, excluding resolved ones. It prints the condition name, clinical status, verification status, onset date, and severity. Error handling is included for the data retrieval process. ```Kotlin suspend fun getMedicalConditions() { val result = healthConnector.readConditions(includeResolved = false) result.fold( onSuccess = { conditions -> conditions.forEach { condition -> println("Condition: ${condition.code.text}") println("Clinical Status: ${condition.clinicalStatus?.text}") println("Verification: ${condition.verificationStatus?.text}") println("Onset: ${condition.onsetDateTime}") println("Severity: ${condition.severity?.text}") } }, onFailure = { exception -> println("Failed to read conditions: $exception") } ) } ``` -------------------------------- ### Health Connect Permissions (Android Manifest) Source: https://github.com/crowded-libs/vitality/blob/main/README.md This XML snippet shows the necessary permissions to be added to the AndroidManifest.xml file for accessing Health Connect data, including reading and writing heart rate. Additional permissions may be required based on the data types used. ```xml ``` -------------------------------- ### Read Vaccination History (Kotlin) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Retrieves and prints a patient's immunization records. It iterates through the list of immunizations, displaying details like vaccine name, date, status, and dosage. Handles potential errors during the read operation. ```Kotlin suspend fun getVaccinationHistory() { val result = healthConnector.readImmunizations() result.fold( onSuccess = { immunizations -> immunizations.forEach { immunization -> println("Vaccine: ${immunization.vaccineCode.text}") println("Date: ${immunization.occurrenceDateTime}") println("Status: ${immunization.status}") println("Dose: ${immunization.doseQuantity?.value} ${immunization.doseQuantity?.unit}") } }, onFailure = { exception -> println("Failed to read immunizations: $exception") } ) } ``` -------------------------------- ### Check Clinical Records Support (Kotlin) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Checks if clinical records are supported and available on the device using the health connector. This function provides a simple boolean check for record availability. ```Kotlin suspend fun checkClinicalRecordsSupport() { if (healthConnector.areClinicalRecordsAvailable()) { println("Clinical records are supported on this device") } else { println("Clinical records not available") } } ``` -------------------------------- ### Read Lab Results with Category Filter (Kotlin) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Retrieves laboratory results, specifically filtering for the 'laboratory' category. It prints details for each observation, including the test name, value, status, date, and reference range. Includes error handling for the data fetching. ```Kotlin suspend fun getLabResults() { val result = healthConnector.readLabResults(category = "laboratory") result.fold( onSuccess = { observations -> observations.forEach { observation -> println("Test: ${observation.code.text}") println("Value: ${observation.valueQuantity?.value} ${observation.valueQuantity?.unit}") println("Status: ${observation.status}") println("Date: ${observation.effectiveDateTime}") println("Reference Range: ${observation.referenceRange.firstOrNull()?.text}") } }, onFailure = { exception -> println("Failed to read lab results: $exception") } ) } ``` -------------------------------- ### Read Current Medications with Date Filter (Kotlin) Source: https://github.com/crowded-libs/vitality/blob/main/README.md Fetches medication records from the last year and prints details for each medication statement or request. It handles different FHIR resource types for medications and reports any read failures. ```Kotlin suspend fun getCurrentMedications() { val oneYearAgo = Clock.System.now().minus(365.days) val result = healthConnector.readMedications(startDate = oneYearAgo) result.fold( onSuccess = { medications -> medications.forEach { resource -> when (resource) { is FHIRMedicationStatement -> { println("Medication: ${resource.medicationCodeableConcept?.text}") println("Status: ${resource.status}") println("Dosage: ${resource.dosage.firstOrNull()?.text}") } is FHIRMedicationRequest -> { println("Prescription: ${resource.medicationCodeableConcept?.text}") println("Status: ${resource.status}") println("Requester: ${resource.requester?.display}") } } } }, onFailure = { exception -> println("Failed to read medications: $exception") } ) } ``` -------------------------------- ### Mindfulness Data Type - HealthKit and Health Connect Source: https://github.com/crowded-libs/vitality/blob/main/README.md This snippet covers the Mindfulness data type, indicating its support on both HealthKit (iOS) via mindful sessions and Health Connect (Android) also via sessions. ```iOS HKCategoryTypeIdentifierMindfulSession ``` ```Android Supported via sessions ``` -------------------------------- ### Reproductive Health Data Types - HealthKit and Health Connect Source: https://github.com/crowded-libs/vitality/blob/main/README.md This snippet lists reproductive health data types, including MenstruationFlow, IntermenstrualBleeding, CervicalMucus, OvulationTest, and SexualActivity. It specifies support for both HealthKit (iOS) and Health Connect (Android), with version requirements noted for iOS. ```iOS HKCategoryTypeIdentifierMenstrualFlow HKCategoryTypeIdentifierIntermenstrualBleeding HKCategoryTypeIdentifierCervicalMucusQuality HKCategoryTypeIdentifierOvulationTestResult HKCategoryTypeIdentifierSexualActivity ``` ```Android MenstruationFlowRecord MenstruationPeriodRecord IntermenstrualBleedingRecord CervicalMucusRecord OvulationTestRecord SexualActivityRecord ``` -------------------------------- ### Mobility & Movement Data Types - HealthKit Source: https://github.com/crowded-libs/vitality/blob/main/README.md This snippet lists mobility and movement-related data types supported by HealthKit on iOS. It highlights that many of these features, such as WalkingAsymmetry and WalkingSpeed, are only available on iOS 14+ or iOS only. ```iOS HKQuantityTypeIdentifierWalkingAsymmetryPercentage HKQuantityTypeIdentifierWalkingDoubleSupportPercentage HKQuantityTypeIdentifierWalkingSpeed HKQuantityTypeIdentifierWalkingStepLength HKQuantityTypeIdentifierStairAscentSpeed HKQuantityTypeIdentifierStairDescentSpeed HKQuantityTypeIdentifierSixMinuteWalkTestDistance HKQuantityTypeIdentifierNumberOfTimesFallen HKCategoryTypeIdentifierAppleStandHour ``` -------------------------------- ### Clinical Data Types - HealthKit Source: https://github.com/crowded-libs/vitality/blob/main/README.md This snippet outlines clinical data types supported by HealthKit on iOS, such as Electrocardiogram and IrregularHeartRhythmEvent. It notes that these are primarily available on iOS, with specific version requirements for Electrocardiogram. ```iOS HKElectrocardiogramType HKCategoryTypeIdentifierIrregularHeartRhythmEvent HKQuantityTypeIdentifierPeripheralPerfusionIndex ``` -------------------------------- ### Kotlin Workout Type Enum Source: https://github.com/crowded-libs/vitality/blob/main/README.md Defines an enumeration for various workout types supported by the Vitality project. This enum covers a wide range of physical activities, from common exercises like running and cycling to more specific ones like yoga and martial arts, as well as general categories like cooldown and other. ```Kotlin enum class WorkoutType { RUNNING, WALKING, CYCLING, SWIMMING, STRENGTH_TRAINING, YOGA, PILATES, DANCE, MARTIAL_ARTS, ROWING, ELLIPTICAL, STAIR_CLIMBING, HIGH_INTENSITY_INTERVAL_TRAINING, FUNCTIONAL_TRAINING, CORE_TRAINING, CROSS_TRAINING, FLEXIBILITY, MIXED_CARDIO, SOCCER, BASKETBALL, TENNIS, GOLF, HIKING, SKIING, SNOWBOARDING, SKATING, SURFING, CLIMBING, EQUESTRIAN, FISHING, HUNTING, PLAY, MEDITATION, COOLDOWN, OTHER } ``` -------------------------------- ### Sleep Data Types - HealthKit and Health Connect Source: https://github.com/crowded-libs/vitality/blob/main/README.md This snippet details the data types for Sleep and Sleep Stages, specifying their identifiers in HealthKit (iOS) and Health Connect (Android). It notes that Sleep Stages are included within the broader sleep analysis on iOS. ```iOS HKCategoryTypeIdentifierSleepAnalysis HKCategoryTypeIdentifierSleepStages ``` ```Android SleepSessionRecord SleepSessionRecord.Stage ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.