Skip to content
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

Merged
merged 78 commits into from
Nov 11, 2022

Conversation

raginirai553
Copy link
Contributor

No description provided.

microsetta_private_api/repo/consent_repo.py Show resolved Hide resolved
microsetta_private_api/api/_consent.py Outdated Show resolved Hide resolved
"USING (consent_id) "
"WHERE consent_audit.source_id = %s and "
"consent_documents.consent_type "
"LIKE %s ORDER BY sign_date DESC",
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

Copy link
Collaborator

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?

Copy link
Contributor Author

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

microsetta_private_api/api/_consent.py Outdated Show resolved Hide resolved
microsetta_private_api/api/_consent.py Outdated Show resolved Hide resolved

INSERT INTO ag.account
("id", "email", "account_type", "first_name", "last_name",
"street", "city", "post_code", "country_code", "preferred_language",
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed!

microsetta_private_api/db/patches/0106.sql Outdated Show resolved Hide resolved
microsetta_private_api/model/consent.py Show resolved Hide resolved
microsetta_private_api/model/consent.py Outdated Show resolved Hide resolved
microsetta_private_api/repo/consent_repo.py Show resolved Hide resolved
Comment on lines 35 to 41
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
Copy link
Collaborator

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

@cassidysymons cassidysymons merged commit 256be57 into biocore:master-overhaul Nov 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants