Fix Profile System - Use user_id & Optimize API Calls
Summary Refactored profile system to consistently use user_id for navigation and reduced API calls from multiple fallback strategies to just 2 calls.
Key Changes
- Profile Service (profileService.ts)
- Simplified fetchProfileData to always use user_id
- Reduced from 5 complex strategies to 2 API calls: GET /users/{user_id} - User lookup, GET /patients/search?q={phone} - Patient enrichment
- Enhanced error logging
- Type Updates (api.ts)
- Added user_id field to Patient & Doctor interfaces
- Fixed allergies type from object to string[]
- API Functions (lib/api.ts)
- Added getUserVisitHistory(userId) for visit history
- Updated getPatientById() with better error handling
- Correct endpoints: vitals use book_no, visits use user_id
- Navigation Updates
- All components now use user_id instead of patient.id or doctor.id: PatientSearch, PatientProfilePage, AssignDoctorPage, CounselingPage, ManageDoctorsPage
- UI Improvements (PersonalInfo.tsx)
- Added Book Number & Patient Phone display
- Fixed allergies display (array of badges)
- Shows all patient-specific details
Impact
Testing