You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the FacilityBasicInfoSerializer class in care/facility/api/serializers/facility.py calculates the total number of beds and active patients associated with each facility by querying the Bed and PatientRegistration models every time the serializer is called. This approach may cause an increased load on the database, especially when there are many facilities.
To optimize this calculation, the proposed solution is to use Django signals to update the bed and patient counts for each facility whenever a new Bed or PatientRegistration object is created or deleted. This approach would reduce the load on the database and improve the performance of the application.
It is suggested to create a new signal receiver function in the signals.py file of the care/facility app to update the bed and patient counts for the relevant Facility object whenever a new Bed or PatientRegistration object is created or deleted. We can then connect this signal receiver function to the relevant signals in the ready() method of the apps.py file for the care/facility app.
By implementing this optimization, we can improve the efficiency of the bed and patient count calculation while maintaining accurate and up-to-date data for each facility.
Currently, the
FacilityBasicInfoSerializer
class incare/facility/api/serializers/facility.py
calculates the total number of beds and active patients associated with each facility by querying theBed
andPatientRegistration
models every time the serializer is called. This approach may cause an increased load on the database, especially when there are many facilities.To optimize this calculation, the proposed solution is to use Django signals to update the bed and patient counts for each facility whenever a new
Bed
orPatientRegistration
object is created or deleted. This approach would reduce the load on the database and improve the performance of the application.It is suggested to create a new signal receiver function in the
signals.py
file of thecare/facility
app to update the bed and patient counts for the relevantFacility
object whenever a newBed
orPatientRegistration
object is created or deleted. We can then connect this signal receiver function to the relevant signals in theready()
method of theapps.py
file for thecare/facility
app.By implementing this optimization, we can improve the efficiency of the bed and patient count calculation while maintaining accurate and up-to-date data for each facility.
Reference: #1223 (comment)
The text was updated successfully, but these errors were encountered: