Skip to content

Make the Questionnaire Swift-First and Conformant to Its Published Profiles - #49

Merged
PSchmiedmayer merged 1 commit into
mainfrom
fhir-conformance
Aug 19, 2026
Merged

Make the Questionnaire Swift-First and Conformant to Its Published Profiles#49
PSchmiedmayer merged 1 commit into
mainfrom
fhir-conformance

Conversation

@PSchmiedmayer

@PSchmiedmayer PSchmiedmayer commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

♻️ Current situation & Problem

Grove questionnaires could only be authored as FHIR JSON, and what the converter emitted did not match the profiles grove-fhir publishes.

This change covers questionnaire authoring, the questionnaire UI, and the questionnaire ↔ FHIR bridge, together with the FHIRPath evaluator the expression features rest on.

⚙️ Release Notes

  • A typed Swift DSL is now the primary way to declare a questionnaire. A declared question doubles as a typed handle, so the same value is used for the body, for typed answers, and for conditions.
let sleep = ChoiceQuestion("sleep", "How well did you sleep?", options: Rating.self)

Questionnaire(url: url, title: "Daily Check-In") {
    Section("s1", title: "Sleep") {
        sleep
        NumberQuestion("hours", "Hours slept").range(0...24)
            .enabledWhen(sleep.answered)
    }
}

let rating = responses[sleep]        // Rating?
  • @Instrument declares a reusable instrument and validates its references, link IDs, and score expressions at compile time.
  • Questionnaires can carry score expressions and evaluate them themselves.
  • Bidirectional FHIR Questionnaire conversion and conformant QuestionnaireResponse export: emitted resources declare the profiles they claim, keep their lifecycle across a round trip, and carry conformant quantity units and answer-option codings.
  • A FHIRPath evaluator supporting the subset SDC questionnaires need, driving enableWhenExpression, calculatedExpression, variable, and targetConstraint. Its three-valued result is modelled explicitly rather than as Bool?.
  • The questionnaire UI is rebuilt around one card per question, with a reworked navigation and completion flow, group captions, and per-page item numbering.
  • Draft responses survive a round trip, including answers nested under a choice option.

📚 Documentation

AuthoringQuestionnaires.md and QuestionKinds.md cover the DSL, the modifiers, scoring, and the extension point for custom question kinds. The DSL's compilation hooks are hidden from DocC and carry inline notes explaining why Swift forces them public.

✅ Testing

  • GroveQuestionnaire on macOS: 19 suites, including FHIR conformance, conversion, expression, scoring, prepopulation, draft-lifecycle, and macro-expansion coverage.
  • FHIRModelsExtensions on macOS: 11 suites, including the FHIRPath parser and evaluator.
  • swiftlint --strict is clean with no baseline file and no new rule suppressions beyond the DSL's underscored protocol requirements, each annotated at its declaration.

Code of Conduct & Contributing Guidelines

By creating and submitting this pull request, you agree to follow our Code of Conduct and Contributing Guidelines:

Copilot AI lite review requested due to automatic review settings August 18, 2026 01:25

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 wasn't able to review this pull request because it exceeds the maximum number of lines (20,000). Try reducing the number of changed lines and requesting a review from Copilot again.

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

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: 60f19bf5-854a-4e34-a40c-e6c2e99d2dff


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 base branch from grove to feature/llm-chat-integration-58421a August 18, 2026 05:59
@PSchmiedmayer
PSchmiedmayer force-pushed the feature/llm-chat-integration-58421a branch from 23ee57e to 933f107 Compare August 18, 2026 17:50
@PSchmiedmayer
PSchmiedmayer force-pushed the feature/llm-chat-integration-58421a branch from 933f107 to 6d69ac0 Compare August 19, 2026 02:05
@PSchmiedmayer
PSchmiedmayer force-pushed the fhir-conformance branch 2 times, most recently from 8c2dbd7 to 6fe6b68 Compare August 19, 2026 03:04
@PSchmiedmayer
PSchmiedmayer force-pushed the feature/llm-chat-integration-58421a branch from 6d69ac0 to 0a2d0df Compare August 19, 2026 04:53
@PSchmiedmayer PSchmiedmayer changed the title Complete Grove FHIR conformance and questionnaire authoring Make the Questionnaire Swift-First and Conformant to Its Published Profiles Aug 19, 2026
@PSchmiedmayer PSchmiedmayer added the enhancement New feature or request label Aug 19, 2026
@github-project-automation github-project-automation Bot moved this to Todo in Grove Aug 19, 2026
@PSchmiedmayer PSchmiedmayer self-assigned this Aug 19, 2026
@PSchmiedmayer PSchmiedmayer added this to the 0.3.0 milestone Aug 19, 2026
@PSchmiedmayer

Copy link
Copy Markdown
Contributor Author

Contract-coordination note for this stack: ResearchStudyAttribution is a real cross-domain My Heart Counts requirement, not Questionnaire-specific cleanup. Please preserve the implementation and tests, but move/extract ownership to the shared FHIR acquisition/research-context layer when the stack is revised for grove-fhir #6.

The accepted model still needs a focused standards decision covering workflow-researchStudy, ResearchStudy/ResearchSubject, consent, exact protocol or study-definition revision, and transformation Provenance. The current custom study-revision extension may be replaced, but it should not disappear until a My Heart Counts legacy fixture and the new writer/reader migration are tested. Questionnaire package/profile work remains coordinated through grove-fhir #7 and Grove #62.

This is a future restacking requirement, not approval to merge this PR and not a runner change.

Base automatically changed from feature/llm-chat-integration-58421a to main August 19, 2026 16:24
@PSchmiedmayer
PSchmiedmayer force-pushed the fhir-conformance branch 2 times, most recently from 8c4acdd to 95f9ca1 Compare August 19, 2026 20:41
@PSchmiedmayer
PSchmiedmayer merged commit e00812f into main Aug 19, 2026
15 of 124 checks passed
@PSchmiedmayer
PSchmiedmayer deleted the fhir-conformance branch August 19, 2026 21:16
@github-project-automation github-project-automation Bot moved this from Todo to Done in Grove Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants