-
Notifications
You must be signed in to change notification settings - Fork 9
Cache triage status in database #3268
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ee5b2fe
to
66c5a13
Compare
9f3f489
to
7e59956
Compare
66c5a13
to
1995557
Compare
7e59956
to
5647c6b
Compare
462a6de
to
1013b56
Compare
5647c6b
to
14fec04
Compare
1013b56
to
592ed46
Compare
14fec04
to
1c9a3f0
Compare
592ed46
to
61a6085
Compare
1c9a3f0
to
d851bf4
Compare
5a20b9f
to
8a82523
Compare
d851bf4
to
327c9b8
Compare
2ed3092
to
a6037bf
Compare
misaka
reviewed
Mar 28, 2025
ebb2e85
to
55b5484
Compare
2592c40
to
ad2058b
Compare
ad2058b
to
16ff865
Compare
55b5484
to
921f83b
Compare
16ff865
to
827a407
Compare
921f83b
to
c497667
Compare
827a407
to
dbb76a7
Compare
This removes any usage of the `all` method on the `TriageOutcome` class in preparation for the removal of the `TriageOutcome` class. I think it also simplifies the code by avoiding the need to go through another class to fetch all the triage records.
This removes usage of the `latest` method on the `TriageOutcome` class in preparation for the removal of this class.
This creates a new model that will represent the triage status of a patient/programme pair so the value can be queried in the database directly rather than needing to generate the status on the fly each time.
This adds a method which refreshes the status of a patient-programme pair to be used in various other parts of the service. This is the main logic that replaces the `TriageOutcome` class, although the logic itself should be the same.
This updates the factories to create instances of the new `Patient::TriageStatus` model to ensure the tests are running in representative database.
This updates the various parts of the code that relied on the `TriageOutcome` class to determine the consent status of a patient to instead use the new `Patient::TriageStatus` model with the status cached.
This can be safely removed as it's no longer being used and has been replaced with the `Patient::TriageStatus` model.
This removes the column from the `Patient::ConsentStatus` model as it's no longer being used. Instead, the triage status is calculated using the values from the consent directly meaning the consent status and triage status can be updated independently.
dbb76a7
to
b815421
Compare
|
misaka
approved these changes
Mar 31, 2025
thomasleese
added a commit
that referenced
this pull request
Mar 31, 2025
This introduces a new model, `Patient::VaccinationStatus`, which stores the vaccination status of a patient-programme pair in the database so it can queried and rendered quickly. Locally, I'm seeing the children page on programmes with 50,000 patients load almost instantly even when filtering on statuses. The session overview page has a slight improvement, but that will only load quickly once the other statuses are cached. I've decided not to implement a state machine as had been previously discussed, but this could be built on top of this change to enhancement the functionality. For now, this effectively caches the existing logic that runs on the fly to the database. I've also decided not to implement this using Rails callbacks and instead be explicit where the status is refreshed. This allows us to optimise for bulk refreshes, as is necessary when adding new programmes to sessions, running the seeds, or generally updating the status of an entire session. This follows up from #3268 which applies the same to the triage.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces a new model,
Patient::TriageStatus
, which stores the triage status of a patient-programme pair in the database so it can queried and rendered quickly. Locally, I'm seeing the triage tab on sessions with 50,000 patients load almost instantly even when filtering on statuses. The session overview page has a slight improvement, but that will only load quickly once the other statuses are cached.I've decided not to implement a state machine as had been previously discussed, but this could be built on top of this change to enhancement the functionality. For now, this effectively caches the existing logic that runs on the fly to the database.
I've also decided not to implement this using Rails callbacks and instead be explicit where the status is refreshed. This allows us to optimise for bulk refreshes, as is necessary when adding new programmes to sessions, running the seeds, or generally updating the status of an entire session.
This follows up from #3263 which applies the same to the consents.