Wearable signals and correlation — scope
Status: Draft scope (not yet approved for build) Date: 2026-07-27
Problem
The record holds what a lab measured and what a clinician wrote. It holds almost nothing about how the person actually lived between those points, so the values sit as isolated dots with no explanation of the movement between them.
The premise here — argued by Mario, and correct — is that continuously captured behavioural physiology is not fitness trivia but the missing explanatory variable for outcomes the record already tracks:
- Activity ↔ test results. Physical activity is among the strongest
modifiable inputs to HbA1c, lipids and blood pressure, all of which are already
in
observations. A clinician sees isolated points months apart; a record that shows the activity trend between them can explain the delta. This correlation is structurally unavailable in a fifteen-minute appointment. - Sleep ↔ symptoms. Sleep is continuous, captured for free, and plausibly drives symptom burden across inflammatory, autoimmune, migraine and mood presentations. Highest yield per unit of effort of anything proposed here.
- Resting heart rate. Trend is a fitness proxy, and an elevated resting HR frequently precedes symptomatic infection by a day or two. HRV is a defensible recovery and stress marker.
- Place-linked arousal. Heart rate contextualised by where a person was — work versus home — as a chronic-stress signal. Real, but the most speculative of the four and by far the most privacy-costly. See below.
The schema already believed this: journal_entries.kind enumerates sleep,
mood, energy, exercise, exposure, and observations.category includes
device. What is missing is any way to get numbers in — journal entries are
free text with no value column.
An earlier position, corrected
A previous assessment in this project held that "step counts and workout minutes don't earn a place in a medical record." That was a category error: it conflated raw fitness-tracker samples with derived behavioural physiology. The distinction that matters is raw sample versus derived daily metric, not clinical versus fitness.
The volume concern behind it survives, but only as a granularity rule, not as an argument for exclusion — see What to import.
Getting the data at all
Neither platform offers a server-to-server API. Both are device-local by design, so this is a device integration problem, not a backend one.
- HealthKit is on-device only; Apple offers no cloud endpoint.
- Google Fit's REST API is deprecated and being turned down. Its successor, Health Connect, is also on-device only — app-to-app, no REST API. (This timeline moved recently and should be re-verified before any work starts.)
There is therefore no "connect an account and sync" option, unlike Fitbit, Withings or Oura, which do have genuine OAuth cloud APIs.
| Path | Cost | Verdict |
|---|---|---|
A. File import — Apple Health → Export All Health Data → export.zip → export.xml |
none: no developer account, no store, no hosted dependency | Start here. Manual and periodic. Apple only — Health Connect has backup/restore, not a portable user export. |
| B. Companion app per platform — HealthKit background delivery / Health Connect reader pushing to the LAN | Apple Developer account or 7-day resigning; two codebases; permanent OS churn | Continuous, but heavy surface for one user. Revisit only if A proves the value. |
| C. Device-vendor APIs — Withings, Oura, Garmin | a hosted dependency the app avoids everywhere else | Viable if the data of interest comes from one such device; weigh against local-first. |
Not a route: Apple Health Records (HKClinicalRecord, provider-sourced FHIR) is
US-institution-centric and will have no Slovak coverage.
What to import
Derived daily metrics, never raw samples. Daily totals, per-night sleep and daily resting HR for a decade are a few hundred thousand rows — trivial. Every five-minute step sample is millions of rows and explains nothing that the daily figure does not.
Proposed allowlist, to be fixed before implementation:
- daily step count, active minutes, distance
- sleep: total, and stages/efficiency where the source provides them
- resting heart rate; HRV where available
- weight, blood pressure, glucose, SpO₂, body temperature — these are clinical
point values and belong in
observationsas they do today, not in the series table
Everything else is not imported. The allowlist is the design, not a detail.
Where it lands
Not in observations. That table is sparse, point-in-time and LOINC-coded.
Daily series are regular-cadence and need rolling windows and lag alignment to be
useful; mixing the two degrades both query patterns.
A separate table — one row per metric per day — with:
- metric key from a closed vocabulary, value, unit, date
- source device/platform, and the import run that produced it
- no raw samples, ever
Clinical point values (BP, weight, glucose) continue to land in observations
with category: 'device' and source naming the device, which the schema
already supports without migration.
Geolocation: derive place, discard the trace
The insight wanted is "elevated heart rate at work versus home". That is semantic place, not coordinates.
Resolve the label during import and store only place: home | work | other.
Never persist a coordinate trace. This yields the chronic-stress signal while
holding no movement history.
This is not a general privacy platitude — it is specific to this codebase.
/export/archive and /export/doctor sweep the record into bundles handed to
other people. A location trace would arrive there silently. Structural
separation is the only reliable defence; remembering to exclude it is not.
Location is also the single re-identifying dataset in the whole application. Everything else leaks embarrassment; this leaks a person's movements.
Two dimensions this scope is missing
Prior art on non-clinical PHR modelling — Sachinopoulou et al., Ontology-Based Approach for Managing Personal Health and Wellness Information (IEEE EMBS 2007, VTT / ITEA2 Nuadu) — decomposes the wellness half of a record into Activity, Nutrition, Sleep, Weight, Stress, Risk, Context, Event and Source. The centralised server and OWL runtime in that paper are not for this project. Two of those domains are, and neither exists here.
Context, and the data that is absent
The paper's point is not that context is nice metadata. It is that context explains missing data: a period of travel accounts for absent activity entries and shifted sleep, and without it the gap reads as a behaviour change that never happened.
This scope already resolves place: home | work | other for the arousal signal.
The same field, widened with travel / away, does double duty: it labels a
correlation window as not comparable rather than letting a holiday register as
a collapse in activity. A correlation engine that treats an unexplained hole as a
zero will produce exactly the spurious findings the Framing section warns
about.
Cost is near zero — one enum widened, resolved at import, still no coordinates stored. Do it with the place work, not after.
Risk factors, which nothing in the record holds
Habits — smoking, alcohol, and the like — appear nowhere in the schema. They are not wearable-derived and strictly they belong to the clinical half, but they are listed here because this is the scope that surfaced the gap and because they are inputs to the same correlations.
The consequence is concrete: /export/emergency and /export/doctor cannot
answer the first question any new physician asks. That is a bigger hole in the
vision's "shareable patient summary" than anything else this scope adds.
Track it as its own small change against conditions or profile, not as a
wearable import. Flagged here so it is not lost.
The prerequisite that reorders the work
Sleep ↔ symptoms needs both sides, and the subjective side is empty. This deployment holds 1 symptom row and 0 journal entries.
Importing sleep is the easy half. The half that needs a human to tap something daily does not exist yet, and no amount of wearable data substitutes for it.
Therefore:
- Activity ↔ labs first. Labs already exist, so this correlation is answerable the moment activity data lands. It also validates the whole approach cheaply.
- A fast symptom/mood capture path is a prerequisite for the sleep work, not
a follow-on. Seconds to record, not a form. Likely a numeric value on
journal_entriesor a widenedsymptoms. - Sleep ↔ symptoms once there is something to correlate against.
Framing, and honest limits
The vision states this is not a diagnostic system, and that constrains how any of this may be presented.
n=1 correlation over self-collected data is genuinely prone to spurious findings: with enough metrics and enough window sizes, something always correlates. Multiple comparisons are not a hypothetical problem here, they are the default outcome.
So the product must surface patterns worth noticing and taking to a clinician, with the underlying data visible and the window/lag stated — never conclusions, and never causal language. This is the same provenance discipline already applied to extracted clinical values, extended to derived ones.
Open questions
- Which metric vocabulary — LOINC has codes for some of this, but daily aggregates are not obviously the same concept as a clinical measurement.
- Re-import idempotency: an export overlapping a previous one must update rather than duplicate. Date plus metric key plus source is the obvious key.
- Time zones and day boundaries, which decide what "daily" means and will silently corrupt correlations if handled inconsistently.
- How place labels are defined and by whom, without that itself becoming a location store.
- Whether sleep stages are comparable across sources, or only totals are. The general form of this question, from the same prior art: entities of different nature routinely measure the same attribute — sleep quality via actigraphy, ECG or EMG — so two rows sharing a metric key are not automatically comparable. Method and device must sit beside the value, not only the unit, and a correlation that silently mixes methods is a defect rather than a nuance.
Not in scope
Raw sample import. Continuous background sync. Any causal claim. Storing coordinates. Correlation UI before there is data on both sides of a correlation.
Relationship to the other inbound path
This and the medextract bridge fill the same hole from opposite ends: that plan brings in what a lab measured, this brings in what the person did. Both want provenance on arrival and a review gate before anything becomes clinical fact. Keep the promotion path uniform rather than building a bespoke one per source.