feat(backend): automatically update attended patients count on registration
name: Feature Request
about: Suggest a new feature or enhancement for the Corpus Collector Backend.
title: "feat(backend): automatically update attended patients count on registration"
labels: "feature"
assignees: 'Lakshy'
title: "feat(backend): "
🚀 Feature Request
Is your feature request related to a problem? Please describe.
Yes. Currently, when a patient registers for a medical camp via the `POST /api/v1/patients/{book_no}/register` endpoint, the [attended_patients] count in the [MedicalCamp] model is not automatically updated. This leads to inaccurate real-time reporting of camp attendance and requires manual intervention or heavy dynamic calculations to get the correct count.
Describe the solution you'd like
I would like the system to automatically increment the [attended_patients] count in the [MedicalCamp]model whenever a patient is successfully registered for a camp. This logic should be integrated directly into the [register_patient_for_camp] service function to ensure data consistency. Specifically:
1. Upon successful registration, call a service function to recalculate or increment the [attended_patients] count for the target [MedicalCamp].
2. Ensure this update is atomic and handles concurrency appropriately if possible (though database locking might be overkill for now, a simple update is a good start).
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
- **Manual API Call:** Requiring the frontend or camp coordinator to manually trigger a countdown update. This is error-prone and leads to desynchronization.
- **Dynamic Calculation:** Calculating the count on-the-fly whenever [attended_patients] is requested. This is computationally expensive for large datasets and doesn't persist the data for quick access.
Additional context
By automating this, we ensure data integrity and reduce the administrative burden on camp coordinators. The [MedicalCamp] model already has an [attended_patients] field, so this is purely a logic enhancement.