fix: fixing visit record
Overview
This MR updates frontend components to align with the new PatientVisit schema by removing deprecated fields and ensuring safe rendering.
What does this MR do and why?
fix(frontend): update visit references and align with PatientVisit schema
- Replace deprecated
visit.idusage withcamp_visit_id - Remove usage of non-existent
visit_date - Add null safety checks to prevent runtime crashes
- Update test data to match new interface structure
These changes were required after backend schema updates where id and visit_date fields were removed.
Changes Made
Files Updated
VisitHistory.tsxAttendanceGrid.tsxConsultations.tsxAttendanceGrid.test.tsx
Technical Details
VisitHistory.tsx
- Updated React
mapkey:visit.camp_visit_id || index - Added null safety check:
{selectedVisit && selectedVisit.camp_visit_id && (...)} - Prevents rendering issues when
camp_visit_idis null
AttendanceGrid.tsx
- Updated
getVisitDate():visit.camp_date - Removed fallback to
visit_date(no longer exists)
Consultations.tsx
- Updated React
mapkey:visit.camp_visit_id || String(visit.camp_id) - Ensures stable rendering key
AttendanceGrid.test.tsx
- Updated
makeVisit()helper - Now matches updated
PatientVisitinterface structure
Type of Change
-
🐛 Bug fix (non-breaking change that fixes an issue) -
✨ New feature (non-breaking change that adds functionality) -
💥 Breaking change (fix or feature that would cause existing functionality to change) -
📝 Documentation update -
🎨 UI/UX improvement -
♻ ️ Refactor (no functional changes) -
⚡ Performance improvement -
🧪 Test update -
🔧 Configuration change -
🚨 Security fix
Related Issues / References
- Related to backend schema update for
PatientVisit
Screenshots or Screen Recordings
Before:
After:
How to Set Up and Validate Locally
-
Pull this branch:
git checkout visit-record -
Install dependencies:
npm install -
Run development server:
npm run dev -
Test flows:
- Visit history page
- Attendance grid
- Consultations page
-
Expected behavior:
- No console errors
- Visits render correctly
- No crashes when
camp_visit_idis null
Testing Done
-
Manual testing completed -
Unit tests updated
Test Cases Covered:
| Scenario | Expected Result | Status |
|---|---|---|
| Visit list rendering | No key errors | |
Null camp_visit_id
|
No crash | |
| Attendance date display | Uses camp_date correctly |
|
| Test data generation | Matches new schema |
Code Quality Checklist
Code Standards
-
Code follows project conventions -
No console.log() left -
No unused imports -
No duplicate code -
TypeScript types properly defined -
ESLint and Prettier pass
React Best Practices
-
Proper component structure -
Hooks follow rules -
No unnecessary re-renders -
Clean event handling
Error Handling
-
Null safety added -
Runtime errors prevented
Documentation
-
CHANGELOG.md updated
Known Limitations / Technical Debt
- Fallback keys (
index,camp_id) are used wherecamp_visit_idis unavailable - Ideally, backend should always provide unique
camp_visit_id
Additional Notes
- This MR is tightly coupled with backend schema changes
- Ensure backend is updated before testing frontend
Edited by Aravind swamy Majjuri

