How do I access health clinical records?

Asked on 2024-07-30

1 search

To access health clinical records using HealthKit, you need to follow these steps:

  1. Check Health Data Availability: First, ensure that health data is available on the device by using the isHealthDataAvailable function. This is important as availability can vary based on device and OS version.

  2. Request Authorization: You must request authorization from the user to read or write the specific health data types your app is interested in. This is done through the health data access request function, which will prompt the user to grant your app access to the health data.

  3. Handle Guest Users: Be aware that guest users are restricted from authorizing health data access. Any call to health data access request during a guest user session will fail with an error. You should handle this error appropriately by discarding any health data that the guest user has attempted to write.

  4. Read and Write Data: Once authorized, your app can read and write health data, including clinical health records such as immunizations and procedures. You can also register your app to receive updates when data changes.

For more detailed information, you can refer to the session Get started with HealthKit in visionOS from WWDC 2024.

Relevant Sessions

  1. Get started with HealthKit in visionOS
  2. Explore wellbeing APIs in HealthKit