Skip to content

[WIP] fix: allergy manifestation not pre-populated in Aboriginal Health Check (issue #1975)#1976

Draft
MaryamMehd wants to merge 4 commits into
mainfrom
issue/allergy-population-bug
Draft

[WIP] fix: allergy manifestation not pre-populated in Aboriginal Health Check (issue #1975)#1976
MaryamMehd wants to merge 4 commits into
mainfrom
issue/allergy-population-bug

Conversation

@MaryamMehd

Copy link
Copy Markdown
Collaborator

Related issue

Closes #1975

Status

Work in progress - investigation not yet complete. Opening as a draft PR to link the branch to the issue and share progress with the team.

The Patient with no fixed address test is now passing. The Allergies manifestation test is still failing.


What has been done

sdc-populate fixes

evaluateExpressions.ts - Added stampFhirpathMetadata() helper:
FHIRPath v4 requires an internal __path__ property on resources used as context variables for nested BackboneElement navigation (e.g. reaction.manifestation.coding). This helper does a JSON round-trip (to strip any stale __path__ inherited from Bundle navigation) then calls fhirpath.evaluate(resource, '$this', {}, r4model) to re-stamp the correct path.

populate.ts - Upfront stamping of all root FHIR resources in fhirPathContext before any FHIRPath evaluation begins.

readPopulationExpressions.ts - Fixed childrenUnderContext logic so that children of non-repeating itemPopulationContext groups are not incorrectly excluded from global evaluation. This fixed the Patient with no fixed address regression.

smart-forms-renderer fix

OpenChoiceAutocompleteField.tsx - Removed value={input} prop that was being passed to StandardTextField inside MUI Autocomplete. This prop was overriding Autocomplete's internal inputValue management and preventing populated values from displaying.

Diagnostic tests added

sdc-populate/test/populate.test.ts - New unit tests that prove __path__ stamping works and the full select() expression with async: true returns Rash after Bundle extraction and stamping (using the exact integration test allergy data).

Investigation document

docs/investigation-allergy-rash-population-failure.md - Full investigation log with confirmed facts, decision table, and next steps.


Still failing - open question

Debug logging in OpenChoiceAutocompleteItem shows the renderer receives an answer with only a random ID and no valueCoding for the SNOMED allergy manifestation. The random ID confirms the manifestation QR item is absent from the populated QR for allergy 1.

Yet the Jest unit test of the exact same FHIRPath expression passes. The gap between Jest and the Playwright integration test environment is not yet understood. See issue #1975 for the full question to the team.

MARYAMMEHDIZ and others added 2 commits June 9, 2026 15:26
FHIRPath v4 requires internal __path__ metadata on resources when navigating
nested BackboneElements (e.g. reaction.manifestation.select(...)). Without it,
evaluate() throws silently, leaving fields like Allergies > Manifestation empty.

Add stampFhirpathMetadata() in evaluateExpressions.ts and apply it when storing
itemPopulationContext values and contextMap entries. Update populate.test.ts to
use the same helper and add diagnostic tests proving the __path__ requirement.

Fixes the Allergies population failure in the Aboriginal/Torres Strait Islander
Health Check integration tests (Vitest Questionnaire 715 Behaviour Tests).

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@MaryamMehd MaryamMehd requested a review from leoniedickson June 18, 2026 03:25
@MaryamMehd MaryamMehd self-assigned this Jun 18, 2026
MARYAMMEHDIZ and others added 2 commits June 18, 2026 11:27
…s and OpenChoiceAutocompleteItem

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
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.

[Bug] Allergy Manifestation (Rash) not pre-populated in Aboriginal Health Check form

2 participants