Skip to content

Draft: Resolve "Support optional medical_camp_id query param for analytics and doctors-registered endpoints (default to latest camp)"

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_id as an optional query parameter:
    • GET /api/v1/analytics
    • GET /api/v1/analytics/medicines
    • GET /api/v1/analytics/doctors
    • GET /api/v1/doctors/registered
  • Implemented dynamic medical camp resolution:
    • If medical_camp_id is provided → data is scoped to that camp.
    • If omitted → system defaults to the latest medical camp.
  • 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
  • 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

Merge request reports

Loading