-
Notifications
You must be signed in to change notification settings - Fork 9
Cache programme status in database #3272
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
1c1836c
to
a8e70b1
Compare
a8e70b1
to
fb30f06
Compare
fb30f06
to
13adedc
Compare
d851bf4
to
327c9b8
Compare
13adedc
to
63da35a
Compare
327c9b8
to
8b6224c
Compare
63da35a
to
8df5d1f
Compare
8b6224c
to
ef1b470
Compare
8df5d1f
to
90754f0
Compare
90754f0
to
bb40682
Compare
bb40682
to
19bd43b
Compare
ef1b470
to
124128f
Compare
19bd43b
to
54fce39
Compare
124128f
to
2592c40
Compare
54fce39
to
bed9771
Compare
bed9771
to
956d6c8
Compare
16ff865
to
827a407
Compare
956d6c8
to
34c6886
Compare
827a407
to
dbb76a7
Compare
34c6886
to
e086f92
Compare
dbb76a7
to
b815421
Compare
e086f92
to
45ae142
Compare
This removes any usage of the `all` method on the `ProgrammeOutcome` class in preparation for the removal of the `ProgrammeOutcome` class. I think it also simplifies the code by avoiding the need to go through another class to fetch all the triage records.
This creates a new model that will represent the vaccination 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 `VaccinationOutcome` class, although the logic itself should be the same.
This updates the factories to create instances of the new `Patient::VaccinationStatus` model to ensure the tests are running in representative database.
This updates the various parts of the code that relied on the `ProgrammeOutcome` class to determine the consent status of a patient to instead use the new `Patient::VaccinationStatus` model with the status cached.
This can be safely removed as it's no longer being used and has been replaced with the `Patient::VaccinationStatus` model.
This simplifies the next activity generation and moves it to a method on to the `PatientSession` model since it's only used in once place.
45ae142
to
747650e
Compare
|
misaka
approved these changes
Mar 31, 2025
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::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.