Convert Every Supported Health Connect Record Type - #34
Open
PSchmiedmayer wants to merge 37 commits into
Open
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 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. Comment |
PSchmiedmayer
force-pushed
the
feature/health-connect-fhir-v020
branch
from
August 23, 2026 06:12
c43331d to
5ea610d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
♻️ 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
NutritionRecordout 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.pyreproduces all 111 existing constants byte for byte, picks up two code systems the hand-written file had missed, and its--checkruns 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.
UnsupportedHealthConnectRecordescaped 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:
stripTrailingZerosrendered whole multiples of ten in scientific notation, which would have leaked3E+1into 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
clientRecordIdand raises itsclientRecordVersion, and the stored Record then carries a newmetadata.id, so deduplicating onmetadata.idcounted 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, andEventSequencecarries its own numeric ordering.Name the Health Connect types for their subject: the module is
health-fhir, soFhirandR4in 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
:health-fhir:testDebugUnitTest,:health:testDebugUnitTest, and both detekt tasks pass.