-
Notifications
You must be signed in to change notification settings - Fork 19
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
Adding Data and Bio Consent through DB #476
Conversation
Master overhaul merge to my fork
Please enter the commit message for your changes. Lines starting
"USING (consent_id) " | ||
"WHERE consent_audit.source_id = %s and " | ||
"consent_documents.consent_type " | ||
"LIKE %s ORDER BY sign_date DESC", |
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.
Why are you using LIKE rather than = here?
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 are using like query instead of equals becasue the exact consent type is not known at this instance. There are broadly two classifications of consent i.e., data and biospecimen. While checking the consent status for any source, the age range for the source is not known at the interface end. Therefore, one cannot make any exact calls for particular consent from the interface. However, the broader category i.e., data or biospecimen is known. Although there are workarounds including extraction of age_range from the source table given source id, programattically create string for exact consent_document type and look for the said document in the query. However, to avoid the workaround, accurate match can be found on basis of consent_type LIKE and source_id, since source_id is a foreign key in consent_audit table.
Further, there may exist multiple consents provided by a source but we intend to find the consent from one of the broader categories, that too latest signed.
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.
Gotcha. Does this need to be updated at all with the changes in all of the consent_type strings?
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, its all working as expected
|
||
INSERT INTO ag.account | ||
("id", "email", "account_type", "first_name", "last_name", | ||
"street", "city", "post_code", "country_code", "preferred_language", |
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 reason to insert street, city, post_code, country_code, preferred_language, address_verified, or cannot_geocode for the consent dummy account.
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.
Since all these fields have NOT NULL constraints applied in the database, it was necessary to include these in the DB Patch.
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.
Ah, for some reason I thought those fields were nullable. Please just change address_verified to false.
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.
Changed!
document = consent_repo.get_consent_document(consent_id) | ||
data = document.to_api() | ||
|
||
if len(data) == 0: | ||
return jsonify(code=404, message=CONSENT_DOC_NOT_FOUND_MSG) , 404 | ||
|
||
return jsonify(data), 200 |
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 can be more concise:
document = consent_repo.get_consent_document(consent_id)
if document:
data = document.to_api()
return jsonify(data), 200
else:
return jsonify(code=404, message=CONSENT_DOC_NOT_FOUND_MSG) , 404
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.
Updated!
No description provided.