Skip to content

BUG: Child mode onboarding saves wrong data to Supabase for phone, country, and guardian relation fields #215

@Varadraj75

Description

@Varadraj75

Is there an existing issue for this?

  • I have searched the existing issues

What happened?

📌 Issue Overview

In the Patient App's Personal Details screen, selecting "For my child" mode causes three fields to be incorrectly mapped in the getPersonalInfo getter, silently corrupting every child-mode registration saved to Supabase.

  • guardianRelation is assigned guardianPhoneController.text instead of selectedRelation. The dropdown value is captured but never read.
  • phoneNo is hardcoded to phoneController.text (the adult controller), which is always empty in child mode.
  • country always reads selectedCountry (adult picker). selectedChildCountry is set correctly by the child form but ignored in the getter.

Additionally, the Relation and Patient Gender dropdowns are plain DropdownMenu widgets, so _formKey.currentState?.validate() skips them entirely. A user can submit with no relation or gender selected and it passes silently.

🔍 Steps to Reproduce

  1. Open the Patient App and sign in
  2. On the Personal Details screen, select For my child from the "Assessment is for?" dropdown
  3. Fill in child name, child age, select relation "Guardian", select gender "Male", enter guardian phone +911234567890, and pick a country e.g. India
  4. Tap Continue
  5. Check the patient table row in Supabase

🎯 Expected Behavior

Field Expected
guardian_relation "Guardian"
phone "+911234567890"
country "India"
gender "Male"

🚨 Actual Behavior

Field Actual
guardian_relation "+911234567890" (phone stored as relation)
phone "" (always empty in child mode)
country "" (always empty, child picker ignored)
gender "" (dropdown bypasses form validation)

Root cause in patient/lib/presentation/auth/personal_details_screen.dart:

// guardianRelation gets the phone number, selectedRelation is never read
guardianRelation: isAssessmentForChild ? guardianPhoneController.text : phoneController.text,

// phoneNo always reads the adult controller, empty in child mode
phoneNo: phoneController.text,

// always reads adult country picker, selectedChildCountry is ignored
country: selectedCountry?.displayName ?? '',

📷 Screenshot

Not applicable. The corruption is in the data written to Supabase, not visible in the UI.

💡 Suggested Improvements

Fix the getPersonalInfo getter to branch correctly on isAssessmentForChild:

phoneNo: isAssessmentForChild ? guardianPhoneController.text : phoneController.text,
guardianRelation: isAssessmentForChild ? selectedRelation : '',
country: isAssessmentForChild
    ? selectedChildCountry?.displayName ?? ''
    : selectedCountry?.displayName ?? '',

Add pre-submission checks for selectedRelation and selectedChildGender in the onPressed handler since they are DropdownMenu widgets and are skipped by _formKey.currentState?.validate().

Record

  • I agree to follow this project's Code of Conduct
  • I want to work on this issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions