Post

Replies

Boosts

Views

Activity

The Clinical Health Records - App Crash & Sample JSON Date type details
Hello, With reference to HealthKit - Clinical Health Records, we implemented the following method to fetch the User's clinical records but seems the query is failing and the app is getting crashed every time. We tried the same method with Apple provided sample account and it works fine in the simulator, but it crashes with actual users Can you please help us to identify the issue? func getRecordsForCHRType(type: HKClinicalTypeIdentifier, completion:@escaping ([HKClinicalRecord]?) -> Void) { guard let healthRecordType = HKObjectType.clinicalType(forIdentifier: type) else { return } let startDate = Calendar.current.date(byAdding: DateComponents(day: -365), to: Date())! let endDate = Calendar.current.date(byAdding: DateComponents(day: 0), to: Date())! let predicate = HKQuery.predicateForSamples(withStart: startDate, end: endDate, options: [.strictStartDate]) let sortDescriptor = NSSortDescriptor(key: HKSampleSortIdentifierStartDate, ascending: false) let healthRecordQuery = HKSampleQuery(sampleType: healthRecordType, predicate: predicate, limit: 0, sortDescriptors: [sortDescriptor]) { (query, samples, error) in guard let actualSamples = samples else { completion(nil) return } let healthRecordSamples = actualSamples as? [HKClinicalRecord] completion(healthRecordSamples) } HKHealthStore().execute(healthRecordQuery) } Additionally, please help us to understand the following different types of dates(in detail) available in sample Clinical Health Records JSON, and is it possible to apply a filter using any HealthKitQuery on these dates to narrow down the clinical records response? issued dateRecorded recordDate onset effective Any help would be appreciated!
1
0
764
Nov ’21