What's new in HealthKit

Description: HealthKit is an essential framework that integrates first- and third-party health and fitness data to help people manage their personal health information. Learn about HealthKit’s latest updates, which provide read access to electrocardiograms on Apple Watch and log and track over a dozen new symptoms and their severity. We’ll also go through the latest mobility data types like walking speed and step length to help people monitor and understand their mobility over time.

Tracking Symptoms

30 Symptoms data types have been added to Health Kit this year, they are shown below.

Electrocardiogram (ECG)

ECG samples can now be read as an HKElectrocardiogram:

/// Represents a collection of voltage measurements.
class HKElectrocardiogram: HKSample {
  var classification: HKElectrocardiogram.Classification 
  var symptomsStatus: HKElectrocardiogram.SymptomsStatus 
  var averageHeartRate: HKQuantity? 
  var samplingFrequency: HKQuantity? 
  var number0fVoltageMeasurements: Int 
}

Here's the description and documentation reference for such properties:

If you want individual measurements you have to run the HKElectrocardiogramQuery:

// Query 
class HKElectrocardiogramQuery: HKQuery {
  public enum Result {
    case measurement(HKElectrocardiogram.VoltageMeasurement)
    case error(Error)
    case done 
  }

  public convenience init(
    _ ecg: HKElectrocardiogram, 
    dataHandler: @escaping (HKElectrocardiogramQuery, HKElectrocardiogramQuery.Result) -> Void
  )
}

Mobility

New set of mobility types:

  • walking speed and step length
  • walking asymmetry and double support percentage
  • stair ascent and descent speed
  • six minute walk test

Missing anything? Corrections? Contributions are welcome 😃

Related

Written by

Federico Zanetello

Federico Zanetello

Software engineer with a strong passion for well-written code, thought-out composable architectures, automation, tests, and more.