I'm trying to query HealthKit for all of users medications, including prescribed medications and user-entered medications.
Using a HKSampleQuery
with type HKClinicalTypeIdentifierMedicationRecord
, I'm able to fetch medications that have been prescribed by a healthcare provider (eg medications associated with clinical FHIR records):
let type = HKClinicalType(.medicationRecord)
let predicate = HKQuery.predicateForClinicalRecords(withFHIRResourceType: .medicationStatement)
let query = HKSampleQuery(sampleType: type,
predicate: predicate,
limit: kRecordLimit,
sortDescriptors: nil) { q, samples, error in
// this returns only -clinical- records
// it doesnt include manually entered meds
}
However, medications which I have manually entered into the Health app with a user-defined schedule and dosing do NOT appear in the results of this query.
is it possible to fetch medications which have been manually entered by the user?