-
Notifications
You must be signed in to change notification settings - Fork 2
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
Call Digital Growth Charts API asynchronously #418
Conversation
This weirdly fixed the issue where the save failed because of rounding errors. I have no idea why.
@@ -61,15 +58,7 @@ class Meta: | |||
"hospital_discharge_date", | |||
"hospital_admission_reason", | |||
"dka_additional_therapies", | |||
"hospital_admission_other", | |||
# calculated fields | |||
"height_centile", |
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.
As these are calculated fields it should not be possible to submit them through the form
pass | ||
cleaned_data["weight"] = weight = round_to_one_decimal_place(weight) | ||
|
||
if not getattr(self, "async_validation_results", None): |
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.
This is the same trick we already use for the patient form, allows us to run things asynchronously for the CSV upload but synchronously for the questionnaire form submission
@@ -0,0 +1,46 @@ | |||
from asgiref.sync import async_to_sync |
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.
I wrote this for performance profiling as you can put cProfile in front of it easily (https://stackoverflow.com/questions/582336/how-do-i-profile-a-python-script).
Fixes #399
Fixes #415
Follow on from #388 and #405, moving the calls to the Digital Growth Charts API to be made asynchronously during CSV upload.
Uploading a CSV of 100 patients with 16 visits each (1600 rows):
Also pass through warnings from the API as validation errors. This catches height and weight measurements that are so extreme they are wrong (see rcpch/rcpchgrowth-python#32 for the methodology)