Manual Test Plan: Systematic Careplan to Prescription Migration
Overview
This test plan provides a systematic approach to migrate from "careplan" to "prescription" terminology while maintaining system functionality. Each phase can be tested independently, allowing for parallel frontend development and incremental validation.
Prerequisites
Environment Setup
# 1. Backup your database
pg_dump kulcare_development > backup_before_migration.sql
# 2. Ensure you're on the correct branch
git checkout enh-health-record
# 3. Start development servers
# Terminal 1 - Backend
cd backend && rails server
# Terminal 2 - Frontend
cd frontend && pnpm dev
# 3. Have testing tools ready
# Postman/Insomnia for API testing
# Browser dev tools for frontend testing
# Database client (pgAdmin/TablePlus) for data verificationTest Data Setup
# Create test clinic and patient data
cd backend
rails console
# Create test data (run in Rails console)
clinic = Clinic.create!(name: "Test Clinic", phone_number: "+1234567890")
doctor = Doctor.create!(first_name: "Test", last_name: "Doctor", email: "test@doctor.com")
patient = Patient.create!(first_name: "Test", last_name: "Patient", phone_number: "+1234567891")
clinic_patient = ClinicPatient.create!(clinic: clinic, patient: patient)
# Note the IDs for testing
puts "Clinic ID: #{clinic.id}"
puts "Patient ID: #{patient.id}"
puts "Doctor ID: #{doctor.id}"
puts "ClinicPatient ID: #{clinic_patient.id}"Phase 1: Core Prescription Model Testing
Goal
Test that basic prescription model operations work after renaming from Careplan to Prescription.
Backend Changes Required
- Rename
parts/doctor/models/careplan.rb→prescription.rb - Update class name
class Careplan→class Prescription - Keep all existing associations and methods
Manual Test Steps
1.1 Test Model Rename
# In Rails console
rails console
# Test basic model operations
prescription = Prescription.new(
clinic_id: 1, # Use your test clinic ID
patient_id: 1, # Use your test patient ID
doctor_id: 1, # Use your test doctor ID
prescription_date: Date.current
)
# Test save
prescription.save!
puts "✅ Prescription model save works: #{prescription.id}"
# Test find
found = Prescription.find(prescription.id)
puts "✅ Prescription model find works: #{found.id}"
# Test associations (should still work with old table name initially)
puts "✅ Associations work: #{found.clinic.name}" if found.clinic1.2 Test API Endpoints (Before Route Changes)
# Test existing careplan API endpoints still work with renamed model
# GET request
curl -X GET "http://localhost:3000/api/careplans/#{prescription_id}" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json"
# Expected: Should return prescription data (even though route says "careplans")1.3 Test Frontend Integration
- Open browser:
http://localhost:3000/cms/careplan/patient/YOUR_PATIENT_ID - Verify page loads without errors
- Check browser console for any JavaScript errors
- Test creating a new prescription through the UI
- Verify data saves and displays correctly
Success Criteria for Phase 1
- Prescription model can be created, read, updated, deleted
- Existing careplan API endpoints still work
- Frontend careplan pages load without errors
- No broken associations or foreign key errors
Rollback Plan for Phase 1
If issues occur:
# Revert model file name
git checkout HEAD -- parts/doctor/models/prescription.rb
mv parts/doctor/models/prescription.rb parts/doctor/models/careplan.rbPhase 2: Prescription Medicine Module Testing
Goal
Test prescription medicines functionality after model rename and association updates.
Backend Changes Required
- Rename
careplan_medicine.rb→prescription_medicine.rb - Update class name and associations
- Update foreign key references
Manual Test Steps
2.1 Test Medicine Model
# In Rails console
prescription = Prescription.first
medicine = PrescriptionMedicine.new(
prescription: prescription,
medicine_name: "Test Medicine",
dosage: "500mg",
frequency: "BID"
)
medicine.save!
puts "✅ PrescriptionMedicine save works: #{medicine.id}"
# Test associations
puts "✅ Medicine -> Prescription: #{medicine.prescription.id}"
puts "✅ Prescription -> Medicines: #{prescription.prescription_medicines.count}"2.2 Test Medicine API Endpoints
# Test medicine CRUD through careplan API (before route changes)
prescription_id=1 # Use your test prescription ID
# Add medicine to prescription
curl -X POST "http://localhost:3000/api/careplans/#{prescription_id}/medicines" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"medicine": {
"medicine_name": "Aspirin",
"dosage": "100mg",
"frequency": "Once daily"
}
}'
# Get medicines for prescription
curl -X GET "http://localhost:3000/api/careplans/#{prescription_id}/medicines" \
-H "Authorization: Bearer YOUR_TOKEN"2.3 Test Frontend Medicine Management
- Navigate to prescription detail page
- Test adding a new medicine
- Test editing medicine dosage/frequency
- Test removing a medicine
- Verify all changes persist after page reload
Success Criteria for Phase 2
- PrescriptionMedicine model operations work
- Medicine associations with Prescription work
- Medicine API endpoints function correctly
- Frontend medicine management works
Phase 3: API Routes Migration Testing
Goal
Gradually update API routes from /careplans to /prescriptions and ensure frontend integration.
Backend Changes Required
- Update routes in
parts/doctor/routes.rb - Update controller file names
- Update controller class names
Manual Test Steps
3.1 Update Routes File
# In parts/doctor/routes.rb
# Change from:
resources :careplans
# To:
resources :prescriptions3.2 Test New API Endpoints
# Test new prescription routes
curl -X GET "http://localhost:3000/api/prescriptions" \
-H "Authorization: Bearer YOUR_TOKEN"
curl -X GET "http://localhost:3000/api/prescriptions/1" \
-H "Authorization: Bearer YOUR_TOKEN"
# Test POST to new endpoint
curl -X POST "http://localhost:3000/api/prescriptions" \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"prescription": {
"clinic_id": 1,
"patient_id": 1,
"doctor_id": 1,
"prescription_date": "2024-01-15"
}
}'3.3 Update Frontend API Calls (Gradually)
- Update
frontend/apps/cms/src/services/careplanApi.ts - Change API endpoints one by one:
// Change from: const response = await fetch('/api/careplans') // To: const response = await fetch('/api/prescriptions') - Test each API call change immediately
3.4 Test Frontend After Each API Change
- Test the specific feature you just updated
- Verify data loads correctly
- Test CRUD operations for that feature
- Check for console errors
Success Criteria for Phase 3
- New
/api/prescriptionsendpoints work - Frontend API calls updated successfully
- All prescription CRUD operations work through new endpoints
- No regression in existing functionality
Phase 4: Frontend Route Migration Testing
Goal
Update frontend routes from /cms/careplan/ to /cms/prescription/ systematically.
Frontend Changes Required
- Update route definitions
- Update component names
- Update navigation links
- Update TypeScript types
Manual Test Steps
4.1 Update Route Definitions
// In frontend route files
// Change from:
{ path: '/cms/careplan', component: CareplanList }
// To:
{ path: '/cms/prescription', component: PrescriptionList }4.2 Test Route Navigation
-
Navigate to new prescription routes manually:
http://localhost:3000/cms/prescriptionhttp://localhost:3000/cms/prescription/patient/1http://localhost:3000/cms/prescription/new
-
Test navigation links and buttons
-
Test browser back/forward functionality
-
Test deep linking to specific prescriptions
4.3 Update Component Names
// Rename components gradually
CareplanList → PrescriptionList
CareplanDetail → PrescriptionDetail
CareplanForm → PrescriptionForm4.4 Test Each Component Update
- Test component renders correctly
- Test component props and state
- Test component interactions
- Verify no TypeScript errors
Success Criteria for Phase 4
- All frontend routes use prescription terminology
- All components renamed and working
- Navigation between pages works correctly
- No TypeScript compilation errors
Phase 5: Database Migration Testing
Goal
Rename database tables from careplan to prescription and ensure data integrity.
Database Changes Required
-- Core table renames
ALTER TABLE careplans RENAME TO prescriptions;
ALTER TABLE careplan_medicines RENAME TO prescription_medicines;
ALTER TABLE careplan_complaints RENAME TO prescription_complaints;
ALTER TABLE careplan_advices RENAME TO prescription_advices;
ALTER TABLE careplan_diets RENAME TO prescription_diets;
ALTER TABLE careplan_procedures RENAME TO prescription_procedures;
ALTER TABLE careplan_test_lists RENAME TO prescription_test_lists;
-- Template table renames
ALTER TABLE careplan_template_medicines RENAME TO prescription_template_medicines;
ALTER TABLE careplan_template_test_lists RENAME TO prescription_template_test_lists;
ALTER TABLE careplan_template_tests RENAME TO prescription_template_tests;
ALTER TABLE careplan_tests RENAME TO prescription_tests;
ALTER TABLE doctor_careplan_templates RENAME TO doctor_prescription_templates;
-- Foreign key column renames
ALTER TABLE prescription_medicines RENAME COLUMN careplan_id TO prescription_id;
-- (Apply to all tables with careplan_id foreign keys)Manual Test Steps
5.1 Create Migration File
cd backend
rails generate migration RenameCareplanTablesToPrescription5.2 Test Migration on Development
# Run migration
rails db:migrate
# Verify tables renamed
rails dbconsole
\dt prescription*
\dt careplan* # Should show no results
# Test data integrity
SELECT COUNT(*) FROM prescriptions;
SELECT COUNT(*) FROM prescription_medicines;5.3 Test Application After Migration
- Restart Rails server
- Test all prescription CRUD operations
- Test associations and foreign keys
- Run any existing test suite
Success Criteria for Phase 5
- All tables successfully renamed
- All data preserved during migration
- Foreign key relationships maintained
- Application functions normally after migration
Phase 6: LHR Integration Testing
Goal
Test patient-centric Longitudinal Health Record functionality.
API Endpoints to Test
# Main LHR endpoint
curl -X GET "http://localhost:3000/api/patients/1/longitudinal_health_record" \
-H "Authorization: Bearer YOUR_TOKEN"
# Individual FHIR endpoints
curl -X GET "http://localhost:3000/api/patients/1/clinical_observations" \
-H "Authorization: Bearer YOUR_TOKEN"
curl -X GET "http://localhost:3000/api/patients/1/medication_requests" \
-H "Authorization: Bearer YOUR_TOKEN"Manual Test Steps
6.1 Test LHR Data Aggregation
- Create multiple prescriptions for the same patient
- Add different medicines, complaints, and tests
- Call LHR API and verify it aggregates data across all prescriptions
- Check data format matches FHIR R4 standards
6.2 Test Frontend LHR Page
- Navigate to
/cms/prescription/patient/1(updated route) - Verify all 6 tabs load:
- Vitals
- Observations
- Medications
- Investigations
- Advice
- Next Visit
- Test adding data in each tab
- Verify data persists across page reloads
Success Criteria for Phase 6
- LHR API returns patient data across all appointments
- FHIR endpoints work for all 6 resource types
- Frontend LHR page displays aggregated patient data
- All 6 tabs functional for data entry
Comprehensive System Testing
Final Integration Tests
Test Critical User Workflows
-
Doctor creates prescription:
- Login as doctor
- Navigate to patient
- Create new prescription
- Add medicines, complaints, advice
- Finalize prescription
-
View patient history:
- Navigate to patient LHR page
- Verify all historical data shows
- Test each tab functionality
- Verify timeline and trends
-
Update existing prescription:
- Find existing prescription
- Modify medicines/dosages
- Save changes
- Verify updates in patient history
Performance Testing
# Test database performance after migration
# Time these queries:
SELECT COUNT(*) FROM prescriptions;
SELECT * FROM prescriptions WHERE patient_id = 1;
SELECT p.*, pm.* FROM prescriptions p JOIN prescription_medicines pm ON p.id = pm.prescription_id;Error Handling Testing
- Test invalid patient IDs
- Test missing required fields
- Test unauthorized access
- Test network failures
Success Criteria for Complete Migration
- All careplan terminology replaced with prescription
- All database tables renamed successfully
- All API endpoints use prescription routes
- All frontend routes use prescription paths
- LHR functionality works end-to-end
- No regression in existing functionality
- Performance maintained or improved
- All tests passing
Rollback Procedures
If Critical Issues Found
# 1. Database rollback
rails db:rollback
# 2. Code rollback
git checkout develop
# 3. Restore database backup if needed
psql kulcare_development < backup_before_migration.sqlProgressive Rollback
Each phase can be rolled back independently:
- Phase 1: Revert model file names
- Phase 2: Revert association changes
- Phase 3: Revert route changes
- Phase 4: Revert frontend changes
- Phase 5: Rollback database migration
Testing Checklist
Before Starting
- Database backup created
- Test environment set up
- Test data created
- Development servers running
After Each Phase
- All manual tests pass
- No console errors
- No database errors
- Functionality preserved
- Performance acceptable
Before Production
- All phases completed successfully
- Complete system test passed
- Performance testing completed
- Rollback procedures verified
- Documentation updated
Additional Notes
Development Tips
- Work in small commits: Commit after each successful phase
- Test frequently: Don't accumulate untested changes
- Keep notes: Document any issues or unexpected behaviors
- Parallel development: Frontend and backend can be updated simultaneously
- Use feature flags: Consider feature flags for gradual rollout
Monitoring During Migration
- Monitor database connection pool usage
- Watch for increased error rates
- Check application performance metrics
- Monitor user experience for any degradation
This systematic approach ensures each change is validated before proceeding, minimizing risk and enabling quick rollback if issues arise.