← Signal Queue

I had my AI assistant turn 6 months of Apple Watch sleep data into the diary my sleep clinic asked for. The data gotchas were brutal.

new

Post

Posting this because I spent a whole Sunday on it and learned a bunch about how messy "just pull my health data" actually is once you ask an agent to do it for real. Background: my sleep has been garbage for a long time and a friend who works in sleep medicine finally got me to agree to a consult. The clinic intake has a two-week sleep diary section with a very specific layout (bedtime, time in bed, total sleep, awakenings, efficiency, resting HR, HRV, notes, one row per night). I did not want to fill fourteen-plus rows by hand from my phone, so I pointed my assistant at my Apple Health data, my Gmail, and my messages and asked it to build the CSV in exactly the clinic's format. It got there in the end, but only after I caught a pile of mistakes that all looked plausible: Time in bed vs actual sleep. This was the big one. The watch logs an "in bed" window AND separate sleep-stage records (core/deep/REM). The assistant first reported the in-bed window as my sleep, so a night I actually slept 3 hours showed as 7. Total sleep has to be the SUM of the sleep stages, not the time in bed. The clinic literally warns about this on the form and I still almost submitted the wrong numbers. Timezones. The raw export timestamps are in UTC. My bedtimes came out around 7am until I told it to convert to local time. Once you fix that, some nights also jump to a different calendar date, which leads to... Off-by-one dates. The Apple weekly/monthly summary emails date a night by the MORNING you woke up. The clinic form wants the night you went to BED. So "Saturday night" shows up as Sunday in the Apple email. The assistant kept trusting the email's date and half my rows were a day off. Zero-sleep nights vanished. I had a few nights where I basically did not sleep at all. Those have no "asleep" records, so the assistant just skipped them. But my monthly summary explicitly flags them as 0.0 hour nights, and those are exactly the nights the doctor cares about most. Had to tell it to include them at zero. It tried to make up numbers. For nights with no morning HR or HRV reading, it filled in a value anyway (looked like it carried one over from another day). For a medical form that is a hard no. Told it to write N/A and never estimate. The cool part: I had texted my friend things like "watch says 2 hrs 40 min last tuesday" and the assistant matched that comment to the right night and dropped it in the notes column so I could compare what I said vs what the watch measured. The relative dates ("last tuesday") tripped it up at first because it anchored to today instead of the day I sent the text. Conclusion: once it stopped overcounting sleep, fixed the timezone, used bed dates, included the zero nights, and stopped inventing HR values, I had one clean CSV I could actually upload. The reasoning across watch data + email + my own texts is genuinely useful, but you cannot just trust the first pass. You have to know what each source actually means. Curious how other people structure health-data aggregations like this. Anyone found a clean way to handle the in-bed vs asleep distinction automatically?

This signal has not been scored yet.