BUG: Appointment booking ignores selected time slot, every appointment saved at midnight to Supabase

Open
#219 0 comments 0 reactions 0 assignees View on GitHub

@Varadraj75 is already working on this.

Since Apr 14, 2026.

  • #220 by @Varadraj75 — open

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
55/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
dart, supabase
Domain
backend, databases

Research direction

Start in appointments_provider.dart at createAppointment() and trace how the selected date, time slot, and therapist are obtained. Then read patient_schedule_appointment_model.dart and patient_schedule_appointment_entity.dart to follow the timestamp into the consultation request. Done means Supabase receives the selected time and therapist ID, the booked slot becomes unavailable, and duplicate submission is prevented.

Written by the indexing model from the issue text.

Description

Is there an existing issue for this?
  • I have searched the existing issues
What happened?

📌 Issue Overview

The appointment booking flow silently discards the time slot the patient selects. Every appointment is written to the Supabase session table with a timestamp of midnight (T00:00:00) on the selected date, regardless of which slot was chosen.

The slot field is captured in PatientScheduleAppointmentModel but toEntity() builds the timestamp using only DateTime.parse(date) - the date-only ISO string from _selectedDate!.toIso8601String(). The slot string is never parsed or merged into the timestamp. PatientScheduleAppointmentEntity has no slot field at all.

Additionally, therapistId is hardcoded to '' in createAppointment() at line 180 of appointments_provider.dart, meaning every booking is inserted with an empty therapist ID.

As a result, the slot availability check which compares booked appointment hours against available slots never matches the midnight row, so the same slot can be booked unlimited times.

🔍 Steps to Reproduce

  1. Log in as a patient who has an assigned therapist
  2. Navigate to Appointments → Schedule an Appointment
  3. Select a service type, a date, and a specific time slot e.g. 10:00 AM
  4. Tap Schedule It
  5. Check the session table in Supabase

🎯 Expected Behavior

The inserted row should have timestamp = 2025-04-15T10:00:00.000 reflecting the
selected slot. The slot should then appear as unavailable for the same date.

🚨 Actual Behavior

The inserted row has timestamp = 2025-04-15T00:00:00.000 regardless of the
selected slot. therapist_id is empty string. The same slot remains bookable
indefinitely since the availability check never matches a midnight timestamp.

Root cause in appointments_provider.dart line 180-183:

therapistId: '',                          // hardcoded empty string
date: _selectedDate!.toIso8601String(),   // midnight date only
slot: _selectedTimeSlot,                  // captured but never used downstream

Root cause in patient_schedule_appointment_model.dart line 34:

timestamp: DateTime.parse(date),  // slot string never parsed or merged

📷 Screenshot

Not applicable. The corruption is in data written to Supabase.

💡 Suggested Improvements

  1. In appointments_provider.dart, parse _selectedTimeSlot (e.g. "10:00 AM")
    into hour and minute, then combine with _selectedDate to produce a full DateTime
    before passing to the model. Also pass the resolved therapistId from the
    availability fetch instead of hardcoding ''.
  2. In patient_schedule_appointment_model.dart, update toEntity() to accept
    and use the time-resolved DateTime rather than parsing the date-only string.
  3. In patient_schedule_appointment_entity.dart, ensure the full timestamp flows
    through to toConsultationRequestEntity() unchanged.
  4. Add an _isSubmitting guard on the Schedule It button to prevent duplicate
    inserts on double tap.
Record
  • I agree to follow this project's Code of Conduct
  • I want to work on this issue
Dominant language
Dart
Stars
30
Forks
49
PR merge metrics
No merged PRs in 30d

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/NeuroTrack

All issues in AOSSIE-Org/NeuroTrack

Similar issues

More Dart issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.