Querying HealthKit for Manually-Entered Medication

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?

Post not yet marked as solved Up vote post of cdstamper Down vote post of cdstamper
894 views

Replies

I have the same issue. I've tried using the apple watch and manual input directly on the phone, and I'm seeing no reported medications.

It seems that medicationStatement is a record about when a prescription was assigned by your clinic, and NOT for medication intake.

User entered medications in Health app are not available via HealthKit APIs. Please file a feedback with details of your use case and how your app would use the data. Thanks!