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

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

Optimize bed and patient count calculation #1259

Ashesh3 opened this issue Apr 17, 2023 · 0 comments

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)

@aeswibon aeswibon self-assigned this May 3, 2023
@sainak sainak assigned sainak and unassigned aeswibon Jun 6, 2023
@sainak sainak removed their assignment Aug 20, 2024
@sainak sainak added this to Care Aug 20, 2024
@github-project-automation github-project-automation bot moved this to Triage in Care Aug 20, 2024
@sainak sainak moved this from Triage to Wishlist in Care Aug 20, 2024
@vigneshhari vigneshhari closed this as not planned Won't fix, can't repro, duplicate, stale Jan 5, 2025
@github-project-automation github-project-automation bot moved this from Wishlist to Done in Care Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants