Fix: making the medicalcamp_id optional in the analytics routes and adding a...
Title
fix(doctor): allow doctor phone number to return null in API response
Description
This PR allows the doctor API endpoints to safely return null phone numbers instead of failing validation or serialization errors.
Problem
Some doctor records may not have a phone number assigned. The existing schema enforced a mandatory phone number value, causing:
- Response validation failures
- Serialization errors
- Inconsistent API behavior when phone numbers were missing
Solution
- Updated
DoctorBaseschema to makedoctor_phone_nooptional (str | None) - Field now accepts null values with proper validation
- API gracefully returns
"doctor_phone_no": nullwhen no phone is present
Changes
-
app/schemas/doctor.py: Made
doctor_phone_nonullable inDoctorBase - tests/schemas/test_doctor_schema.py: Added null phone validation test + fixed datetime import for Python 3.13
- tests/test_api/test_doctor_routes.py: Added API endpoint null phone test
- tests/test_services/test_doctor_service.py: Added service layer null phone test
Testing
# Schema tests
uv run pytest [test_doctor_schema.py](http://_vscodecontentref_/0) -v
# ✅ 3/3 passed
# API route tests
uv run pytest tests/test_api/test_doctor_routes.py::TestDoctorRoutes::test_get_all_doctors_allows_null_phone_in_response -v
# ✅ 1/1 passed
# Service tests
uv run pytest tests/test_services/test_doctor_service.py::test_get_doctors_consultations_allows_null_phone -v
# ✅ 1/1 passed