-
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
sample summary report expansion #585
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from microsetta_private_api.model.source import Source | ||
from microsetta_private_api.repo.kit_repo import KitRepo | ||
from microsetta_private_api.repo.sample_repo import SampleRepo | ||
from microsetta_private_api.repo.transaction import Transaction | ||
from microsetta_private_api.repo.admin_repo import AdminRepo | ||
|
@@ -7,20 +8,55 @@ | |
from werkzeug.exceptions import NotFound | ||
|
||
|
||
def get_barcodes_for(project_id): | ||
def get_barcodes_by_project_id(project_id): | ||
if project_id is None: | ||
raise ValueError("project_id must be defined.") | ||
|
||
with Transaction() as t: | ||
return AdminRepo(t).get_project_barcodes(project_id) | ||
|
||
|
||
def get_barcodes_by_kit_ids(kit_ids): | ||
if kit_ids is None: | ||
raise ValueError("kit_id must be defined.") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be helpful for the API layer to catch these |
||
|
||
with Transaction() as t: | ||
return AdminRepo(t).get_kit_barcodes(kit_ids) | ||
|
||
|
||
def get_barcodes_by_emails(emails): | ||
if emails is None: | ||
raise ValueError("email must be defined.") | ||
|
||
with Transaction() as t: | ||
return AdminRepo(t).get_email_barcodes(emails) | ||
|
||
|
||
def get_barcodes_by_outbound_tracking_numbers(outbound_tracking_numbers): | ||
if outbound_tracking_numbers is None: | ||
raise ValueError("outbound_tracking_numbers must be defined.") | ||
|
||
with Transaction() as t: | ||
return AdminRepo(t).get_outbound_tracking_barcodes | ||
(outbound_tracking_numbers) | ||
|
||
|
||
def get_barcodes_by_inbound_tracking_numbers(inbound_tracking_numbers): | ||
if inbound_tracking_numbers is None: | ||
raise ValueError("inbound_tracking_numbers must be defined.") | ||
|
||
with Transaction() as t: | ||
return AdminRepo(t).get_inbound_tracking_barcodes | ||
(inbound_tracking_numbers) | ||
|
||
|
||
def per_sample(project, barcodes, strip_sampleid): | ||
summaries = [] | ||
with Transaction() as t: | ||
admin_repo = AdminRepo(t) | ||
sample_repo = SampleRepo(t) | ||
template_repo = SurveyTemplateRepo(t) | ||
kit_repo = KitRepo(t) | ||
vs_repo = VioscreenSessionRepo(t) | ||
|
||
# all associated projects returned for each barcode, | ||
|
@@ -84,6 +120,16 @@ def per_sample(project, barcodes, strip_sampleid): | |
sample.id | ||
) | ||
|
||
kit_id_name = kit_repo.get_kit_id_name_by_barcode(barcode) | ||
outbound_fedex_tracking = \ | ||
admin_repo.get_outbound_tracking_by_barcodes(barcode) | ||
inbound_fedex_tracking = \ | ||
admin_repo.get_inbound_tracking_by_barcodes(barcode) | ||
first_scan_timestamp_status = \ | ||
admin_repo.get_first_scan_timestamp_by_barcodes(barcode) | ||
last_scan_timestamp_status = \ | ||
admin_repo.get_last_scan_timestamp_by_barcodes(barcode) | ||
|
||
Comment on lines
+123
to
+132
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Many of these values are already being exposed here from |
||
summary = { | ||
"sampleid": None if strip_sampleid else barcode, | ||
"project": barcode_project, | ||
|
@@ -96,7 +142,12 @@ def per_sample(project, barcodes, strip_sampleid): | |
"ffq-taken": ffq_taken, | ||
"ffq-complete": ffq_complete, | ||
"sample-status": sample_status, | ||
"sample-received": sample_status is not None | ||
"sample-received": sample_status is not None, | ||
"kit-id": kit_id_name, | ||
"outbound-tracking": outbound_fedex_tracking, | ||
"inbound-tracking": inbound_fedex_tracking, | ||
"first-scan-timestamp-status": first_scan_timestamp_status, | ||
"last-scan-timestamp-status": last_scan_timestamp_status | ||
} | ||
|
||
for status in ["sample-is-valid", | ||
|
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 but one condition set
project_id = None
, it would be more efficient to move that statement to above theif
block and only change it for theproject_id
condition.