When patients booked appointments through the patient portal, the appointments were not visible in the admin panel. This was because:
- The booking form was collecting patient information (name, age, gender, phone)
- But the booking route was using
current_user.patient(the logged-in user's patient record) - This mismatch meant the form data was ignored and appointments were linked to the wrong patient records
- REMOVED patient information fields (name, age, gender, phone, email)
- ADDED display of logged-in user's information at the top of the form
- Now the form only collects appointment details (department, doctor, date, time, symptoms)
- The booking uses the patient record already linked to the logged-in user
- Already correctly using
current_user.patientto link appointments - Added check to ensure user has a patient record before booking
- Appointments are now properly linked to the logged-in user's patient record
- Added test user account:
test@patient.com/test123 - Test user has a linked patient record for testing the booking flow
- All appointments are properly linked to patient records
- Verifies patient-appointment connections in the database
- Confirms all appointments have valid patient links
- Can be run anytime to check database integrity
When a patient registers:
- A
Patientrecord is created with their information - A
Useraccount is created with login credentials - The
User.patient_idlinks to thePatientrecord - When they book appointments, it uses their linked patient record
- Admin:
admin@hospital.com/admin123 - Test Patient:
test@patient.com/test123
-
Login as Test Patient
Email: test@patient.com Password: test123 -
Book an Appointment
- Go to "Book Appointment"
- Notice: Your name and phone are displayed at the top (no form fields)
- Select department, doctor, date, and time
- Add symptoms (optional)
- Click "Confirm Booking"
-
Verify in Patient Dashboard
- Go to "My Dashboard"
- Your appointment should appear in "Upcoming Appointments"
-
Login as Admin
Email: admin@hospital.com Password: admin123 -
Check Admin Appointments Panel
- Go to "Appointments"
- Filter by today's date
- You should see the appointment with patient name "Test Patient"
-
Verify Connection
- The appointment should show:
- Patient Name: Test Patient
- Phone: +91-8888888888
- All appointment details
- Admin can check-in or cancel the appointment
- The appointment should show:
python test_connection.pyThis will verify:
- Test user exists and has a patient record
- All appointments have valid patient links
- Database integrity is maintained
Patient books appointment → Form collects patient info → Route ignores form data →
Uses current_user.patient → Mismatch → Appointments not visible
Patient logs in → Has linked patient record → Books appointment →
Route uses current_user.patient → Appointment properly linked →
Visible in both patient dashboard and admin panel ✅
User (Authentication)
├── id
├── email
├── password_hash
├── role (admin/user)
└── patient_id (FK) ──┐
│
Patient (Medical Record) │
├── id ←──────────────────┘
├── patient_id (P-YYYYMMDD-XXX)
├── name
├── age
├── gender
├── phone
└── appointments ──┐
│
Appointment │
├── id │
├── patient_id (FK)┘
├── doctor_id
├── department_id
├── appointment_date
├── appointment_time
└── status
app/templates/patient/book.html- Removed patient info fieldsapp/routes/patient_portal.py- Already using current_user.patientseed_data.py- Added test user with patient recordtest_connection.py- New test script
- Patient information is now taken from the logged-in user's account
- No need to re-enter name, phone, etc. when booking
- Appointments are automatically linked to the correct patient
- Admin panel shows all patient details correctly
- SMS confirmations are sent to the phone number in the user's profile
Consider adding:
- Profile page where patients can update their age, gender, medical history
- Ability to book appointments for family members (additional patient records)
- Email confirmations in addition to SMS
- Appointment history with detailed medical notes