How to “use” Health Data. Example: Convert heart rate from count/min to beats/min

I am trying to write a shortcut to extract data from my health data. So I started with heart rate. I am using the find action that finds and filters data (see screenshot).

The heart rates that are returned are in counts per minute and that is the only option available when I tap on the unit link (other than Ask each time or Shortcut Input)

While having these shortcut actions to extract my data is great, it seems that everything I do requires me to do a bunch of (not very educated) guessing to figure out how to actually apply these actions. So aside from how to convert to From count to beats, I’d really like to understand where I can go to find a description of the health data so I can figure out how to make use of it.

Thanks, Chip

The most detailed stuff I’ve seen is in the official Health Kit documentation, but I don’t think it is going to be quite the sort of thing you are looking for - just a partial match.

My understanding is that count=beats. It is just a slightly generic term used in the Shortcuts action so that it can also be used for other health samples, like breaths. It is the count of beats or breaths or (insert health sample name) per minute.

1 Like

Thanks for replying but unfortunately that is not true for my case. As an example the screenshot shows the minimum over the past week as 110961.29. Looking in the Health app my minimum HR is shown to be 47 beats/min.

Assuming these are representations of the same data point this means the counts are 0.424 milliseconds apart or the sampling rate is 2360.88 Hz. Of course I am not sure what these numbers really tell me.

There has to be a data field in the HealthData that can be used to perform this conversion. The question is how do I get to it?

I have been looking at that and being written for developers you can at least start to understand how the data are structured. That is perhaps useful to know but how I can access the data from within Shortcuts is still a mystery.

The quest continues

It’s hard to tell exactly what your shortcut is doing from those two screenshots, but in the first there is no sorting applied, no limit, and in the second it looks like you are referencing a maximum value. The name looks like it might be the same. As I say, I can’t tell what your shortcut does exactly, but are you sure you are getting the minimum value for the past week?

If I just use the find sample with the following options, the result seems to be right for me.

I didn’t want to put the actual shortcut out there, bunch of actions to show me data so I can try to figure out what is happening. Here is what I want to do:

  1. Get heart rates for a period of time (7 days in the my original, 1 day now)
    1a. Since the original I have added two filters to ignore heart rate data from a Wahoo fitness heart rate monitor and a BP device I use that also has heart rate.
  2. Set a variable to contain the heart rate data
  3. Compute the minimum, maximum and mean heart rates

I did not apply any limits or sorting because I was simply trying to find max and min and did not think my heart rate would be wildly out of bounds. Eventually I might want to apply those limits but I am just trying to figure this out.
My near term desire is to be able to extract minimum and maximum heart rates to provide to my doctor.

Eventually I’d like to be able to extract what I need in a form I can use.

Has doing that eliminated your >110,000 bpm “minimum”, or “maximum”?

My point above was that I was getting results I expected just by applying some sorting and filtering, whereas you were getting something that in no way looked like the minimum heart rate you were trying to get and that it was not clear what manipulation you were doing to the data, but it looked suspiciously(?) like you were referencing a maximum value in the shortcut while referring to it as the minimum in the post.

That’s where you would typically create a sanitised version of your shortcut. An example to show exactly what is happening that reproduces the issue in the original shortcut. As you can see from my previous post, scattered screenshots isn’t telling the whole story, which makes it much harder to understand what is going on as there are so many unknowns.

Here is a link to the shortcut
The attached screenshot is the result of the first Show Result.

Looking at this screen shot - I had assumed that grouping by day would provide heart rate data for each day. I had assumed the Show result was providing a link to the data and that I could then look at each day by tapping the link and also use each day’s result to find the minimum and maximum heart rate. It appears to me now that it is providing the sum of the heart rates for the entire day which makes no sense to me for heart rate. I can increase the number of samples by reducing this down to grouping by minutes & turning off Fill but then there are times when more than one heart rate sample is taken during a minute and the result provided is a total again.

Is there any way to get the raw data or turn off the grouping?

You can just set the group by to none to stop the grouping.

The raw data value is the default data you get back from a health sample. You can pick it out of the health sample explicitly along with things like the date it was recorded, the units, etc.

For example here’s grouping off with a few elements extracted for a set of health samples.

Hope that helps.

When I was creating my last post “none” was not an option and I had to delete the Find action and then add it back for none to reappear.
Now I have the foundation that I want.

Thanks very much for your advice & patience.