Skip to content

fix: correct field mapping in child mode onboarding for phone, country and guardian relation#216

Open
Varadraj75 wants to merge 2 commits into
AOSSIE-Org:mainfrom
Varadraj75:fix/child-onboarding-field-mapping
Open

fix: correct field mapping in child mode onboarding for phone, country and guardian relation#216
Varadraj75 wants to merge 2 commits into
AOSSIE-Org:mainfrom
Varadraj75:fix/child-onboarding-field-mapping

Conversation

@Varadraj75
Copy link
Copy Markdown
Contributor

@Varadraj75 Varadraj75 commented Apr 7, 2026

Closes #215

📝 Description

In child mode on the Personal Details onboarding screen, three fields in the getPersonalInfo getter were incorrectly mapped, causing corrupted data to be saved to Supabase on every child-mode registration. Additionally, the Relation and Patient Gender dropdowns were not part of the form validation pipeline, allowing silent submission with empty required fields.

🔧 Changes Made

  • Fixed phoneNo to read from guardianPhoneController in child mode instead of always reading the adult form's phoneController
  • Fixed guardianRelation to read from selectedRelation (the dropdown value) instead of guardianPhoneController.text
  • Fixed country to read from selectedChildCountry in child mode instead of always reading selectedCountry from the adult form
  • Added pre-submission validation for selectedRelation and selectedChildGender in the onPressed handler since these are DropdownMenu widgets and are skipped by _formKey.currentState?.validate()

📷 Screenshots or Visual Changes (if applicable)

Not applicable. The bug was in data written to Supabase, not visible in the UI.

🤝 Collaboration

Collaborated with: NONE

✅ Checklist

  • I have read the contributing guidelines.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if applicable).
  • Any dependent changes have been merged and published in downstream modules.

Summary by CodeRabbit

  • Bug Fixes
    • Improved form validation for child assessments: require guardian relation before continuing.
    • Require child gender confirmation with clear error feedback preventing submission.
    • Fixed mapping of phone, relation and country fields to use child-specific inputs when assessment is for a child, preserving adult flow otherwise.
    • Enhanced inline error messages to guide correct input for child assessments.

Copilot AI review requested due to automatic review settings April 7, 2026 21:36
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6518af7e-ff39-4e4d-8735-7c0a462c8e6a

📥 Commits

Reviewing files that changed from the base of the PR and between 20dcb38 and 5b78e4a.

📒 Files selected for processing (1)
  • patient/lib/presentation/auth/personal_details_screen.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • patient/lib/presentation/auth/personal_details_screen.dart

📝 Walkthrough

Walkthrough

Updated child-mode mappings and validations in the Personal Details screen: getPersonalInfo now reads guardian phone, selected relation, and child country when isAssessmentForChild is true. The Continue handler now blocks submission and shows errors if relation or child gender are unset.

Changes

Cohort / File(s) Summary
Child Mode Field Mapping & Validation
patient/lib/presentation/auth/personal_details_screen.dart
Fixed getPersonalInfo branching: phoneNo uses guardianPhoneController.text for child assessments; guardianRelation uses selectedRelation; country uses selectedChildCountry?.displayName. Added pre-submit guards in Continue handler to show error snackbars and return early if selectedRelation or selectedChildGender are empty for child mode.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped in code with nimble paws,
Fixed three fields that broke the laws,
Guardian phone and country true,
Relation chosen joins the view,
Child data now saved straight and new.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main fix: correcting field mapping for phone, country, and guardian relation in child mode onboarding.
Linked Issues check ✅ Passed All four objectives from issue #215 are fully addressed: phoneNo uses guardianPhoneController in child mode, guardianRelation uses selectedRelation dropdown, country uses selectedChildCountry in child mode, and pre-submission validation is added for dropdowns.
Out of Scope Changes check ✅ Passed All changes are directly scoped to the PR objectives; the modifications only address the three field mappings and dropdown validation gaps identified in issue #215.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect child-mode field mapping in the Personal Details onboarding flow to prevent corrupt personal info being saved during child registrations (issue #215).

Changes:

  • Corrects phoneNo, guardianRelation, and country mappings in getPersonalInfo for child mode.
  • Adds manual pre-submit checks in the Continue handler for child Relation and Patient Gender dropdown selections.
Comments suppressed due to low confidence (1)

patient/lib/presentation/auth/personal_details_screen.dart:130

  • _validationErrors['country'] is rendered in both adult and child country pickers, but this file never sets _validationErrors['country'] when the user submits with no country selected. Since this handler is where you’re adding extra validation for dropdowns, it’s a good place to also enforce country selection (and set/clear the country validation error) so empty countries can’t be submitted silently.
          onPressed: () {

            if (_formKey.currentState?.validate() ?? false) {
              if (isAssessmentForChild && selectedRelation.isEmpty) {
                setState(() {
                  _validationErrors['relation'] = 'Please select your relation with the patient';
                });
                return;
              }
              if (isAssessmentForChild && (selectedChildGender == null || selectedChildGender!.isEmpty)) {
                setState(() {
                  _validationErrors['gender'] = 'Please select patient gender';
                });
                return;
              }
              final personalInfoModel = getPersonalInfo;
              final authProvider = context.read<AuthProvider>();
              authProvider.storePatientPersonalInfo(personalInfoModel);
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread patient/lib/presentation/auth/personal_details_screen.dart Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@patient/lib/presentation/auth/personal_details_screen.dart`:
- Around line 115-126: The form sets validation entries
_validationErrors['relation'] and _validationErrors['gender'] but the UI only
displays _validationErrors['country'], so users see no feedback when Continue
returns early; update the child-relation dropdown widget and the child-gender
dropdown widget to render their respective error messages from
_validationErrors['relation'] and _validationErrors['gender'] (same style as
country), and in the dropdowns' onSelected/onChanged handlers clear the
corresponding keys from _validationErrors (remove or set to null) and call
setState so the message disappears when the user picks a value; locate
references to selectedRelation, selectedChildGender, and _validationErrors to
apply these changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6ebd823c-c678-4f32-b42b-1a29446fa858

📥 Commits

Reviewing files that changed from the base of the PR and between 051a4f3 and 20dcb38.

📒 Files selected for processing (1)
  • patient/lib/presentation/auth/personal_details_screen.dart

Comment thread patient/lib/presentation/auth/personal_details_screen.dart
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: Child mode onboarding saves wrong data to Supabase for phone, country, and guardian relation fields

2 participants