fix: added optional medicalcamp_id in analytics and doctors/registered
requested to merge 36-support-optional-medical_camp_id-query-param-for-analytics-and-doctors-registered-endpoints into develop
Title (semantic)
feat(analytics): add optional medical_camp_id query param to analytics and doctors-registered endpoints
Description
This merge request introduces support for an optional medical_camp_id query parameter across analytics and doctors-registered endpoints. The goal is to allow flexible reporting and historical data access while maintaining backward compatibility with existing behavior.
Backend Changes
- Updated endpoints to accept
medical_camp_idas an optional query parameter:GET /api/v1/analyticsGET /api/v1/analytics/medicinesGET /api/v1/analytics/doctorsGET /api/v1/doctors/registered
- Implemented dynamic medical camp resolution:
- If
medical_camp_idis provided → data is scoped to that camp. - If omitted → system defaults to the latest medical camp.
- If
- Ensured endpoints rely only on query params (no GET request bodies).
- Refactored service layer logic to support camp-based filtering.
- Added validation for invalid or non-existent camp IDs.
Testing & Documentation
- Added unit tests covering:
- Requests with
medical_camp_id - Requests without parameter (latest camp fallback)
- Invalid camp handling
- Requests with
- Updated API docs to include new optional query parameter.
This enhancement improves analytics flexibility and enables querying historical camp data without introducing new endpoints.
Checklist
- Optional query param added to supported endpoints
-
Default latest camp fallback implemented -
Service layer updated for dynamic camp resolution -
Unit tests added and passing -
API documentation updated
-
Related Issue(s)
Closes #36 (closed)
Edited by Lakshy Yarlagadda