mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-18 16:12:11 +00:00
feat(schema): extend MeasurementType with audio-exposure + time-in-daylight (Migration 0052)
Adds three new enum values that close the iOS-17/18 HealthKit coverage
gap before the v1.5 iOS-Swift session locks against Postgres:
- AUDIO_EXPOSURE_ENV (dBA, environmental noise)
- AUDIO_EXPOSURE_HEADPHONE (dBA, AirPods listening)
- TIME_IN_DAYLIGHT (minutes/day, iOS 17+)
Wire-up touches the canonical surfaces:
- prisma/schema.prisma: MeasurementType + comment block
- src/lib/validations/measurement.ts: enum + unitMap + VALUE_RANGES
- src/lib/__tests__/measurement-type-enum-coverage.test.ts: 25 -> 28
expected types; new entries added to PDF_VITAL_EXCLUSIONS under the
existing v1.5 clinical-layout gate
- src/components/measurements/measurement-list-meta.ts: i18n keys,
Volume2 / Headphones / Sun icons, palette assignments
- src/lib/insights/chart-tokens.ts: ALLOWED_CHART_TOKENS allow-list
plus orphan-enum stripper coverage so the LLM cannot leak raw
upper-snake names into rendered prose
- messages/{en,de,fr,es,it,pl}.json: typeAudioExposureEnv,
typeAudioExposureHeadphone, typeTimeInDaylight (en/de translated;
fr/es/it/pl carry English placeholders matching their existing
convention for the W5d additions)
The task brief originally listed a fourth value (WORKOUT_ROUTE) as a
sentinel slot. Dropped here because workouts are first-class entities
landing in Migration 0053 with their own table (Workout + WorkoutRoute);
HealthKit also separates HKWorkout from HKQuantitySample. A reserved
sentinel that no real Measurement row will ever take would be a dead
slot for analytics, doctor-PDF allow-lists, and chart registries.
This commit is contained in:
1 parent
5d5a934774
commit
41ba79b5d5
6 files changed
+105
-1
No files matched your search
@@ -0,0 +1,30 @@
|
||||
-- v1.4.25 W8d — Apple Health server-contract prep. Three new
|
||||
-- MeasurementType enum values close the iOS-17/18 HK coverage gap
|
||||
-- before the v1.5 iOS-Swift session:
|
||||
-- * AUDIO_EXPOSURE_ENV — HK `environmentalAudioExposure`
|
||||
-- (ambient noise; dBA SPL). Watch + iPhone microphone samples.
|
||||
-- * AUDIO_EXPOSURE_HEADPHONE — HK `headphoneAudioExposure`
|
||||
-- (AirPods listening-volume sampling; dBA SPL).
|
||||
-- * TIME_IN_DAYLIGHT — HK `timeInDaylight` (iOS 17+;
|
||||
-- minutes/day). Mood + sleep correlate.
|
||||
--
|
||||
-- The previous task brief listed a fourth value, `WORKOUT_ROUTE`. It
|
||||
-- has been dropped: workouts are first-class entities with their own
|
||||
-- `Workout` table (Migration 0053) and the GPS route geometry lives
|
||||
-- in `WorkoutRoute`. Apple HealthKit also separates `HKWorkout` from
|
||||
-- `HKQuantitySample`. Carrying a sentinel enum value on the
|
||||
-- Measurement table when no real Measurement row will ever be of
|
||||
-- that type would be a dead slot that confuses every downstream
|
||||
-- code path (analytics summariser, doctor-PDF allow-list, chart
|
||||
-- registry). Forward-additive — a future analytics rollup row can
|
||||
-- still be carried on a fresh enum value if the use case ever
|
||||
-- materialises.
|
||||
--
|
||||
-- Additive only, forward-only — every new enum value is unconditional
|
||||
-- and no existing row needs to be backfilled. The Apple Health
|
||||
-- mapping (`src/lib/measurements/apple-health-mapping.ts`) gains the
|
||||
-- corresponding HK identifier rows in the same release.
|
||||
|
||||
ALTER TYPE "measurement_type" ADD VALUE IF NOT EXISTS 'AUDIO_EXPOSURE_ENV';
|
||||
ALTER TYPE "measurement_type" ADD VALUE IF NOT EXISTS 'AUDIO_EXPOSURE_HEADPHONE';
|
||||
ALTER TYPE "measurement_type" ADD VALUE IF NOT EXISTS 'TIME_IN_DAYLIGHT';
|
||||
@@ -263,6 +263,10 @@ enum MeasurementType {
|
||||
PULSE_WAVE_VELOCITY // m/s — Withings meastype 91 (Body Cardio / Body Scan). Indicator of arterial stiffness.
|
||||
VASCULAR_AGE // years — Withings meastype 155 (Body Scan). Composite of PWV + age.
|
||||
VISCERAL_FAT // rating — Withings meastype 170 (Body Comp / Body Scan). Withings' rating scale (1–12); not directly comparable to a percent.
|
||||
// ── v1.4.25 W8d Apple Health server-prep ──
|
||||
AUDIO_EXPOSURE_ENV // dBA — HealthKit `environmentalAudioExposure`; ambient noise sample (e.g. concert, traffic). Watch + iPhone microphone.
|
||||
AUDIO_EXPOSURE_HEADPHONE // dBA — HealthKit `headphoneAudioExposure`; AirPods listening-volume sampling.
|
||||
TIME_IN_DAYLIGHT // minutes — HealthKit `timeInDaylight` (iOS 17+). Sun-exposure daily rollup; mood + sleep correlate.
|
||||
|
||||
@@map("measurement_type")
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user