Skip to content

Convert Every Supported Health Connect Record Type - #34

Open
PSchmiedmayer wants to merge 37 commits into
mainfrom
feature/health-connect-fhir-v020
Open

Convert Every Supported Health Connect Record Type#34
PSchmiedmayer wants to merge 37 commits into
mainfrom
feature/health-connect-fhir-v020

Conversation

@PSchmiedmayer

@PSchmiedmayer PSchmiedmayer commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

♻️ Current situation & Problem

The Health Connect producer converted 18 of 41 record types. The remaining 23 were deferred against a catalog that had no output contract for them; the v0.3.0 guide publishes one for all but two, so the deferrals became stale rather than principled.

⚙️ Release Notes

  • Convert 40 of 41 record types, up from 18: body composition, hydration, elevation, floors, wheelchair pushes, total energy, VO2 max, HRV, the sample series (power, speed, both cadences, skin temperature), and resting heart rate with its daily-mean method coding.

  • Fan NutritionRecord out into one Observation per present nutrient across all 42 catalog outputs; absent fields emit nothing.

  • Generate the canonical contract from the shared catalogs. The Swift and TypeScript contracts have always been projected; this one was written by hand, so a catalog change could reach two languages and miss the third with nothing failing. Scripts/generate-grove-fhir-kotlin-contract.py reproduces all 111 existing constants byte for byte, picks up two code systems the hand-written file had missed, and its --check runs in the conformance script ahead of the expensive stages.

  • Make every silent path in that generator loud: a dietary canonical comes from the catalog rather than being rebuilt from the measurement id, an owner outside the two packages this contract names is refused, and a guide whose FSH cannot be read stops the run instead of emitting a contract with no code systems.

  • Catch every record rejection on the fail-closed path. UnsupportedHealthConnectRecord escaped the coordinator's catch and crashed the export loop; both refusals now share a sealed base, which also states which failures deliberately stay outside it.

  • Split the converter by domain: its specification tables, nutrient projection, and the two coding families move to files named for what they hold.

  • Absorb the coded reproductive and mindfulness records into their shared measurements, retaining the exact Health Connect constant as a secondary coding, with cervical mucus carrying appearance as the value and sensation as an optional component.

  • Convert skin temperature's delta-plus-baseline form to absolute Celsius, and fail closed with a precise reason when deltas arrive without a baseline.

  • Fix a latent wire-format defect: stripTrailingZeros rendered whole multiples of ten in scientific notation, which would have leaked 3E+1 into a payload. This also corrects sleep duration, which had the same bug.

  • Code the resting heart rate in the Grove measurement system and drop its vital-signs category. R4 treats LOINC 40443-4 as a heart-rate vital sign, and a derived daily estimate must not reach clinical consumers as a measured one.

  • Re-pin to the v0.3.0 guide cut.

  • Carry the client record identity. A writer that re-imports a measurement reuses its clientRecordId and raises its clientRecordVersion, and the stored Record then carries a new metadata.id, so deduplicating on metadata.id counted a revised measurement twice. The converter now emits the client record id as a second Observation identifier and the version as an extension, matching the HealthKit adapter's sync identity so a receiver applies one supersession rule to both platforms.

  • Express scope keys and event sequences as value classes rather than validated strings. isOpaqueScopeKey() was checked in five places and the event-sequence pattern in three, and the two spellings disagreed: the outbox permitted "0" by regex and then rejected it on the next line, while the coordinator forbade it in one. Nine validation blocks are gone, and EventSequence carries its own numeric ordering.

  • Name the Health Connect types for their subject: the module is health-fhir, so Fhir and R4 in a type name repeated what the module already said. This also aligns the surface with Swift — HealthConnectConverter, HealthConnectConversionContext, HealthConnectContract, HealthConnectCatalog.

  • Track the current Grove FHIR contract.

📚 Documentation

The module README's supported-record table is now generated from the producer's own support catalog rather than maintained by hand.

✅ Testing

  • Converter tests grew from 39 to 54, covering each new record kind, series identity stability across replay and reorder, the skin-temperature baseline arithmetic and its refusal path, the nutrition fan-out and its all-absent case, and every coded absorption.
  • :health-fhir:testDebugUnitTest, :health:testDebugUnitTest, and both detekt tasks pass.

Copilot AI lite review requested due to automatic review settings August 20, 2026 22:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f7f4b1b7-c12b-423b-b4e1-735838887a2c


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@PSchmiedmayer PSchmiedmayer changed the title Align the Health Connect Producer with the Grove FHIR 0.2 Source-Neutral Contracts Convert Every Supported Health Connect Record Type Aug 22, 2026
@PSchmiedmayer
PSchmiedmayer force-pushed the feature/health-connect-fhir-v020 branch from c43331d to 5ea610d Compare August 23, 2026 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants