Bug Fix: Fix Doctor Age Persistence
name: Bug Report
about: Report a bug in the Doctor Creation flow.
title: "fix(backend): Doctor age not saved during creation:"
labels: "bug"
assignees: 'Lakshy'
title: "fix(backend): "
🐛 Bug Report
Describe the bug
When creating a new doctor using the POST /api/v1/doctors/ endpoint, the doctor_age field provided in the request body is not saved to the database. The response returns doctor_age: null even when a valid integer is provided.
To Reproduce
Steps to reproduce the behavior:
-
Make a POST request to
/api/v1/doctors/with the following payload:{
"doctor_name": "Dr. Test",
"doctor_age": 45,
"doctor_sex": "male",
"specialization": "General",
"doctor_email": "[email protected]",
"doctor_phone_no": "1234567890",
"doctor_availability": true,
"license_number": "LIC123"
}
-
See error: JSON response shows
"doctor_age": null.
Expected behavior
The doctor_age should be saved to the database and returned in the response as 45.
Screenshots
Environment
- OS: Linux
- Browser: HTTP Client
- Version: Current
Additional context
The issue is located in app/services/doctor_service.py. The create_doctor function creates a User instance but fails to include the user_age field from the doctor_age input.
