Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize bed and patient count calculation #1259

Open
Ashesh3 opened this issue Apr 17, 2023 · 0 comments
Open

Optimize bed and patient count calculation #1259

Ashesh3 opened this issue Apr 17, 2023 · 0 comments
Assignees

Comments

@Ashesh3
Copy link
Member

Ashesh3 commented Apr 17, 2023

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.

Reference: #1223 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants