Will developers be able to access the AFib History feature coming to WatchOS 9? I work as an Epic Analyst for a local hospital in the digital health department and one of our programs uses the Apple Watch for AFib detection and I just wanted to make sure we would be able to access that info (with permission of course) through our own app.
Will AFib History be an open data source?
I’ve recently started looking at retrieving ECG data in HealthKit, as currently recorded by my Watch (mine’s on 8.7). I already have a database of ECG recordings from my Polar H10 strap and want to incorporate the Watch data (from a different lead position).
i note that HealthKit now has an HKElectrocardiogram sample [https://developer.apple.com/documentation/healthkit/hkelectrocardiogram), which has a property for classification e.g. “atrialFibrillation”. So, we should be able, now, to do an HKQuery to retrieve AFib classifications with or without the voltage data. I haven’t tried yet, but soon will.
I hope this helps.
Regards, Michaela
PS I’ve developed an ECG Viewer with SwiftUI Canvas for the voltage time series ( currently Polar H10 data) and will be adding the capability for plotting the Watch data.
I can confirm that current versions of iOS and Watch OS (14+ and 7+) provide access to ECG classifications (e.g. Atrial Fibrillation). The relevant code is:
let ecgType = HKObjectType.electrocardiogramType()
let ecgPredicate = HKQuery.predicateForElectrocardiograms(classification: .atrialFibrillation)
let ecgQuery = HKSampleQuery(sampleType: ecgType,
predicate: ecgPredicate,
limit: HKObjectQueryNoLimit,
sortDescriptors: nil) { (query, samples, error) in ...............
If you then need to access the actual ECG Voltages (500 measurements per second, I think) for a sample:
let voltageQuery = HKElectrocardiogramQuery(ecgSample) { (query, result) in
switch(result) {
case .measurement(let measurement):
if let voltageQuantity = measurement.quantity(for: .appleWatchSimilarToLeadI) {
// process each voltage measurement
...........
}
// Execute the query.
healthStore.execute(voltageQuery)
Regards, Michaela