Repository navigation
Export food correlations with their members - #164
Open
PSchmiedmayer wants to merge 7 commits into
Open
PSchmiedmayer wants to merge 7 commits into
PSchmiedmayer wants to merge 7 commits into
Conversation
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
The guide admits HealthKit's food correlation, but the exporter refused it as not yet convertible. A food correlation now converts to one eating-occasion Observation that references its nutrient members, each exported as a record of its own under the same disclosure options, with its own writer and recording-device facts. An ECG's symptoms and a food correlation's members share one companion mechanism. export gains conversionInstants, the retained conversion instant per HealthKit UUID, so a member keeps its record version whether it is collected alone or through its correlation. The content corpus changes two food vectors: the retraction now targets the food record, and the catalog entry states its food-correlation output.
State for `export(records:at:conversionInstants:receive:)` what each parameter means, including that a member or symptom without its own conversion instant uses `instant` rather than its grouping's entry.
An unsaved food correlation converts like a saved one: the eating occasion and each nutrient member become records, and a member that names no source states the revision HealthKit would stamp on saving the correlation, as HealthKit attributes a saved correlation's members to its source. Before, an unsaved food correlation reached the generic conversion and was refused as an invalid shape.
PSchmiedmayer
force-pushed
the
healthkit-food
branch
from
November 28, 2026 00:17
d8b8500 to
5fcd325
Compare
PSchmiedmayer
changed the base branch from
sensorkit-preparation
to
healthkit-file-recordings
November 28, 2026 00:17
This was referenced Nov 28, 2026
PSchmiedmayer
marked this pull request as ready for review
December 6, 2026 06:24
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
This PR builds on #160.
The Grove FHIR guide defines the
healthkit-food-correlationprofile, but the exporter refused every food correlation, saved or unsaved, withnotYetConvertible(.food).A food correlation groups nutrient samples that are HealthKit samples of their own. A study can collect the same nutrient from its own query and as a member of a correlation. Exporting a sample again at another conversion instant creates a new version of the same source record, so converting members at the correlation's instant would give one nutrient two versions whenever the two queries ran at different times. Trove keeps the conversion instant it first used for each HealthKit UUID, so a nutrient keeps its record version whichever query sees it first.
⚙️ Release Notes
A food correlation converts to one eating-occasion Observation with the
healthkit-food-correlationprofile, a Period effective time and no value. ItshasMemberreferences each member's Observation by its source-output identifier.Each member is exported as a record of its own, equal to the record its own query produces, under every disclosure option, source classification and device token policy. The ECG's symptoms and the food members now share one companion mechanism in the exporter.
receiveis called once for the correlation and once per member, members in UUID order.A correlation converts as a whole. No members, a repeated member or a member that is no dietary quantity sample is refused with
invalidValue(.food, .shapeInvalid), and any member failure yields one refusal for the correlation and no member record.Both
exportmethods take the retained conversion instant per HealthKit UUID. A sample without an entry usesat, also a member or symptom whose grouping has an entry. An instant FHIR cannot state throwsExchangeIdentityError.invalidInstantbefore anything is converted. The parameter defaults to[:].A member also passed as its own record in the same call is exported twice.
An unsaved food correlation converts like a saved one. A member that names no source states the correlation's revision, as HealthKit attributes a saved correlation's members to the correlation's source.
The retraction of a food correlation targets its source record, and the food catalog entry states the
food-correlationoutput.📚 Documentation
GroveHealthKitFHIR.md and ConfiguringTheExporter.md describe food correlations, their members and
conversionInstants. Bothexportmethods gain parameter documentation, and DocC links follow the new signatures.✅ Testing
HealthKitFoodContentTests(new): the eating occasion's profile, value andhasMemberreferences, and members equal to their standalone records; per-UUID conversion instants keep a member's standalone version and a NaN instant throws first; a retry is identical and members keep their own metadata; members follow the non-identifying preset; empty, repeated and non-nutrient members are rejected.HealthKitFHIRExporterUnsavedSampleTests.unsavedFoodStatesTheSavingRevision: an unsaved food correlation exports the same records as the saved one.ContentInvariantTests,HealthKitAggregateConversionTests,HealthKitConverterTestsandHealthKitFHIRExporterTeststreat food as convertible.batchReportsEveryFailureWithoutDroppingRecordsuses a vision prescription as its refused input.Code of Conduct & Contributing Guidelines
By creating and submitting this pull request, you agree to follow our Code of Conduct and Contributing Guidelines: