-
Notifications
You must be signed in to change notification settings - Fork 17
7272 ensure patients are visible on oms central #7338
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
7272 ensure patients are visible on oms central #7338
Conversation
INSERT INTO changelog (table_name, record_id, row_action, store_id, name_link_id) | ||
SELECT 'vaccination', id, 'UPSERT', store_id, patient_link_id | ||
FROM vaccination | ||
WHERE patient_link_id <> ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @andreievg - lol sorry we've gone through this a few times, and I know low likelihood of vaccination records existing. But not inserting name_link_id with changelog here meant that if had existing vaccinations were created on OMS Central, they'd never end up with a changelog with name_link_id populated (that was only happening after remote site push).
These would then not sync out if patient visibility added. Best to insert changelog correctly with name_link_id, only where name_link_id does exist. Am I missing an edge case where this could error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm i am not sure tbh, i feel like in this case it's better to just WHERE patient_link_id IN (SELECT id from name_link_id)
, to be safe and reduce use case thinking
server/service/src/apis/api_on_central/patient_name_store_join.rs
Outdated
Show resolved
Hide resolved
Note! patient_link_id is required field, so if <2.7 sites sync vaccination records to 2.7+ OMS Central, they will | ||
fail to integrate. They will re-sync and integrate when remote site upgrades, but records would be lost if | ||
remote site reinitialises before upgrading. Considering this low likelihood, as feature not officially rolled out | ||
before 2.7. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be added to release notes or something
ctx: &ServiceContext, | ||
name_id: &str, | ||
) -> Result<(), CentralApiError> { | ||
let timeout = Duration::from_secs(30); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how long I should set for timeout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've added wait for processors logic, I think that might be better? https://github.com/msupply-foundation/open-msupply/pull/1706/files
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be different for the synchroniser_driver though, the trigger would also get a channel to report on finish, does that sounds like too much work ? (if you think it is, i'll have a good look at what you have here)
Btw for the patient_id thing in trigger I think we could have kept existing trigger and add another one trigger_with_patient_id.
And if we implement the waiting I would do create another trigger_with_await (or something like that)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, created issue - #7435
@@ -20,10 +21,13 @@ use crate::{ | |||
|
|||
use super::PatientSearch; | |||
|
|||
#[derive(Debug)] | |||
#[derive(Error, Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great
// More robust to check patient record has been received | ||
if !sync_status.is_syncing { | ||
// If sync finished but integration of patient failed, will break after timeout | ||
if check_patient_exists(&ctx.connection, &name_id)?.is_some() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's cool
break; | ||
} | ||
} | ||
debug!("Patient not yet found, awaiting sync completion..."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every 500ms ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol ever the optimist
Ok(()) | ||
} | ||
|
||
impl From<GetActiveStoresOnSiteError> for CentralApiError { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point we agreed that ?
make it hard to trace the conversion, so should only convert error for common things. Not requesting change now, but I would do a helper method in CentralApiError (that accept same thing as format_error)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, ended up replacing with map_error in the next PR, adding the processor π
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks @lache-melvin, we can do the await for sync refactor after we get 2.7RC (with this change) build out for testing : )
Fixes #7272
π©π»βπ» What does this PR do?
Adds push of name/name_store_join to OMS Central, and additional "add patient visibility to central" call to the /name-store-join endpoint
Reasoning outlined in a README
π Any notes for the reviewer?
I did test all of the cases below, and it took a hot minute. Given I've done a full manual test and so would QA, maybe is ok for this to be a code review only idk lol
All cases working except "Patient B" below - a patient that is visible in multiple OMS stores already, and that already has vaccination records. Upgrade to 2.7 makes the vax card accessible in all the stores where patient is visible. But remote site is already at latest changelog cursor before upgrading, so OMS central doesn't think there are any new vaccination records that it needs to send out.
Reinitialising the remote site (after upgrading and a sync) would resolve this, as initialisation is from changelog 0. Given low likelihood of vaccination records existing, maybe this is actually an ok solution? Add to release notes/support upgrade info to check for this case and reinitialise if needed?
π§ͺ Testing
Dear QA: I am sorry but you'll need to reinitialise for this one π’
π Documentation
1.
2.
π Reviewer Checklist
The PR Reviewer(s) should fill out this section before approving the PR
Breaking Changes
Issue Review
Tests Pass