Skip to content

fix: resolve and extract nested profile answers - #1108

Closed
rob-reynolds wants to merge 6 commits into
feature-definition-based-populationfrom
codex/nested-answer-profile
Closed

rob-reynolds wants to merge 6 commits into
feature-definition-based-populationfrom
codex/nested-answer-profile

Conversation

@rob-reynolds

@rob-reynolds rob-reynolds commented Sep 9, 2026

Copy link
Copy Markdown

Superseded by #1119, which contains only the four-file extraction patch on the current population branch.

Definition-based extraction can drop a Coding answer when the target requires CodeableConcept. Nested Extension answers can also borrow an unrelated root value constraint or be attached at the resource root instead of their declared location.

This resolves the answer type from the item's profile canonical and full element identity before converting in transformAnswer. A converted value is used only when it matches the resolved target type; the original answer remains available to the existing fallback.

Named nested paths now construct the complete resource tree for flat and grouped questionnaire items. Sibling answers share the correct enclosing slice; repeated groups remain separate, including groups without a definition. Named Observation components retain their identity. Absolute child definitions return to the resource root before assignment. QR-only requests use the same root extraction declaration as dispatch. Inline and referenced Extension profiles supply scoped URLs and defaults; defaults initialize containers once and are copied before use. Repeated Coding answers append within their CodeableConcept instead of replacing it. Repeated QR groups keep fields of each record associated while preserving enclosing ancestors, including root-routed child definitions. Separate fields of a repeated record belong in the same QR group; independent answer arrays are not implicitly paired by index.

The tests cover DSTU3/R4/R5, Coding metadata, typed aliases, snapshot defaults, similarly named slices, nested referenced profiles, flat/grouped/repeated forms, named component ancestors, unanswered items, and isolation across extraction calls. Extension URLs may come from profile defaults or answers and are validated after item traversal. A named extraction path that still cannot resolve a required URL reports the path rather than creating an orphan Extension. Unanswered paths remain no-ops. General profile validation and discriminator-based selection of pre-existing repository resources are outside this change.

This PR targets feature-definition-based-population and supersedes #1101.

Validation: 145 passed, one pre-existing disabled test (populateWithLaunchContextResolvesParametersR5) across the affected extraction and questionnaire/response processor suites. Main Checkstyle and Java formatting checks pass.

Checks: ./gradlew spotlessJavaCheck :cqf-fhir-cr:test --tests '*questionnaireresponse.*' --tests '*QuestionnaireProcessorTests' :cqf-fhir-cr:checkstyleMain.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown

Formatting check succeeded!

@rob-reynolds rob-reynolds changed the title fix: resolve profile answer types during definition-based extraction fix: resolve and extract nested profile answers Sep 9, 2026
@sonarqubecloud

sonarqubecloud Bot commented Sep 9, 2026

Copy link
Copy Markdown

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