-
Notifications
You must be signed in to change notification settings - Fork 38
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
feat(utils): added and updated the bulk-update-patients script #1805
base: develop
Are you sure you want to change the base?
Conversation
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 good to have a notification with the amount of data to be processed/patients updated and main parameters, and a sleep of ~10s so the dev decides whether to move forward with the execution or not.
|
||
main(); | ||
|
||
async function getPatientCqLinks(sequelize: Sequelize, cxId: string): Promise<CqPatientDataResult> { |
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.
nit: put both helper functions at top of file
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.
There's no definition for this, I personally prefer the main function at the top, that's how we read code, from the main logic to the detail anyways.
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.
The main issue is how we update the patient. We need to redesign this script.
totalFacilities++; | ||
const patientsList = await metriportAPI.listPatients(facility.id); | ||
|
||
await displayWarningAndConfirmation(facilities.length); |
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 should be sending the amount of patients here, no?
If we're sending alarm/note for each facility, we prob should state the facility id an index.
And we should prob do this after we filter the ones created after the date filter, right?
} | ||
|
||
patientsWithNoLinks.push(patient); | ||
patientsNoLinks++; |
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.
No need for this, we can just call patientsWithNoLinks.length
at any time
|
||
for (let i = 0; i < facilities.length; i++) { | ||
const facility = facilities[i]; | ||
totalFacilities++; |
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.
ditto: can just call facilities.length
} | ||
|
||
const patientChunks = chunk(patientsWithNoLinks, PATIENT_CHUNK_SIZE); | ||
console.log(`Facility ${facility.id} has ${patientsWithNoLinks.length} patients`); |
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.
...patients with no links - they'll be updated.
const addressObject = Array.isArray(patient.address) | ||
? patient.address[0] | ||
: patient.address; | ||
const address = addressObject as Address; | ||
await updatePatient(patient, address, facility.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.
@thomasyopes is adding multiple addresses, we should take that into account.
Also, this would remove any address that we augmented from links.
We should probably write an internal endpoint to which we could send a list of patient IDs and it would trigger a PD instead of updating the patient using the SDK.
refs. metriport/metriport-internal#1350
Description
Testing
Release Plan