Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Track who gets results printed #691

Merged
merged 12 commits into from May 1, 2014
16 changes: 16 additions & 0 deletions database/procedures/ag_get_print_results.sql
@@ -0,0 +1,16 @@
reate or replace procedure ag_get_print_results(
kit_id_ in varchar2,
results_ in out types.ref_cursor
)as
begin
open results_ for
select print_results from ag_handout_kits
where kit_id = kit_id_;
end ag_get_print_results;
Copy link
Member

Choose a reason for hiding this comment

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

Can you add an example call to the end of this file, as we have for other procedure files?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Its in the db, but I didn't want to put kit_ids on github.

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't have to be a real Kit ID, but even if it is, I wouldn't be concerned.



/*
variable user_data_ REFCURSOR;
execute ag_get_print_results('test_kit', :user_data_);
print user_data_;
*/
7 changes: 4 additions & 3 deletions database/procedures/ag_insert_kit.sql
Expand Up @@ -4,14 +4,15 @@ create or replace procedure ag_insert_kit
kit_id_ varchar2,
kit_password_ varchar2,
swabs_per_kit_ varchar2,
kit_verification_code_ varchar2
kit_verification_code_ varchar2,
print_results_ varchar2
)
as
begin

insert into ag_kit
(ag_login_id, supplied_kit_id, kit_password, swabs_per_kit, kit_verification_code)
values (ag_login_id_, kit_id_, kit_password_, swabs_per_kit_, kit_verification_code_);
(ag_login_id, supplied_kit_id, kit_password, swabs_per_kit, kit_verification_code, print_results)
values (ag_login_id_, kit_id_, kit_password_, swabs_per_kit_, kit_verification_code_, print_results_);

commit;

Expand Down
11 changes: 11 additions & 0 deletions database/queries/updateissue675.sql
@@ -0,0 +1,11 @@
alter table ag_kit add print_results varchar(1) default ('n');
alter table ag_handout_kits add print_results varchar(1) default('n');
update ag_handout_kits set print_results = 'y';
update ag_handout_kits set print_results = 'n' where kit_id like 'ts_%';
update ag_handout_kits set print_results = 'n' where kit_id like 'pgp_%';
commit;

update ag_kit set print_results = 'y';
update ag_kit set print_results = 'n' where SUPPLIED_KIT_ID like 'ts_%';
update ag_kit set print_results = 'n' where SUPPLIED_KIT_ID like 'pgp_%';
commit;
Copy link
Member

Choose a reason for hiding this comment

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

I think recording this kind of information in the repo is a great idea. I wish we had started earlier, but better late than never! One thing that this currently lacks, however, is some comments

Copy link
Contributor Author

Choose a reason for hiding this comment

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

based on the last deploy, I thought this was a good idea :)

Copy link
Member

Choose a reason for hiding this comment

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

Not sure how I feel about doing this though :|

Copy link
Member

Choose a reason for hiding this comment

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

@ElDeveloper do you want to voice your concerns here or offline?

Copy link
Member

Choose a reason for hiding this comment

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

If this needs to be merged, then merge we should and we can discuss about this later. In any other case I would much rather discuss this offline, just to make this discussion much more agile, not with any other intent.

Copy link
Member

Choose a reason for hiding this comment

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

Okay -- let's discuss this evening and merge after

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This just needs to be deployed before May 1st. We can have this discussion before the merge.

20 changes: 16 additions & 4 deletions python_code/data_access/ag_data_access.py
Expand Up @@ -230,17 +230,19 @@ def reassignAGBarcode(self, ag_kit_id, barcode):
con = self.getMetadataDatabaseConnection()
con.cursor().callproc('ag_reassign_barcode', [ag_kit_id, barcode])

def addAGKit(self, ag_login_id, kit_id, kit_password, swabs_per_kit, kit_verification_code):
def addAGKit(self, ag_login_id, kit_id, kit_password, swabs_per_kit,
kit_verification_code, printresults='n'):
"""
return values
1: success
-1: insert failed due to IntegrityError
"""
con = self.getMetadataDatabaseConnection()
try:
con.cursor().callproc('ag_insert_kit', [ag_login_id, kit_id,
kit_password, swabs_per_kit,
kit_verification_code])
con.cursor().callproc('ag_insert_kit', [ag_login_id, kit_id,
kit_password, swabs_per_kit,
kit_verification_code,
printresults])
except cx_Oracle.IntegrityError:
return -1
return 1
Expand Down Expand Up @@ -676,6 +678,7 @@ def handoutCheck(self, username, password):

return is_handout.strip()


def checkBarcode(self, barcode):
# return a tuple consists of:
# site_sampled, sample_date, sample_time, participant_name,
Expand Down Expand Up @@ -776,3 +779,12 @@ def getBarcodesByKit(self, kitID):
barcodes = [row[0] for row in results]
return barcodes

def checkPrintResults(self, kit_id):
con = self.getMetadataDatabaseConnection()
results = con.cursor()
con.cursor().callproc('ag_get_print_results', [kit_id, results])
print_results = results.fetchone()
if print_results is None:
return None
else:
return print_results[0].strip()
Copy link
Member

Choose a reason for hiding this comment

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

Just out of curiosity, is the strip necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it has been necessary on there functions when pulling stuff out of the db.
So I added it to this one so I wouldn't get burned again.

On Thu, May 1, 2014 at 4:26 PM, adamrp notifications@github.com wrote:

In python_code/data_access/ag_data_access.py:

@@ -776,3 +779,12 @@ def getBarcodesByKit(self, kitID):
barcodes = [row[0] for row in results]
return barcodes

  • def checkPrintResults(self, kit_id):
  •    con = self.getMetadataDatabaseConnection()
    
  •    results = con.cursor()
    
  •    con.cursor().callproc('ag_get_print_results', [kit_id, results])
    
  •    print_results = results.fetchone()
    
  •    if print_results is None:
    
  •        return None
    
  •    else:
    
  •        return print_results[0].strip()
    

Just out of curiosity, is the strip necessary?


Reply to this email directly or view it on GitHubhttps://github.com//pull/691/files#r12211104
.

Copy link
Member

Choose a reason for hiding this comment

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

Hmm I don't think it's needed, but it's also not hurting. So I'm fine with this 😄

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I remember this, it might seem redundant but some data was/is not sanitized on it's input.

6 changes: 5 additions & 1 deletion www/americangut/add_participant.psp
Expand Up @@ -43,8 +43,12 @@ sql = "select cast(ag_login_id as varchar2(100)) from ag_login where email = '{0
ag_login_id = ag_data_access.dynamicMetadataSelect(sql).fetchone()[0]
sql = "select swabs_per_kit, verification_code from ag_handout_kits where kit_id = '{0}'".format(kit_id)
swabs_per_kit, kit_verification_code = ag_data_access.dynamicMetadataSelect(sql).fetchone()
printresults = ag_data_access.checkPrintResults(kit_id)
if printresults is None:
printresults = 'n'
success = ag_data_access.addAGKit(ag_login_id, kit_id, password,
swabs_per_kit, kit_verification_code)
swabs_per_kit, kit_verification_code,
printresults)
if success == -1:
psp.redirect('db_error.psp?msg=regkit')

Expand Down
1 change: 1 addition & 0 deletions www/americangut/register_user.psp
Expand Up @@ -21,6 +21,7 @@ from qiime.parse import parse_mapping_file
kit_id = form['username']
password = form['password']


tiny_markers = False
portal_type = 'americangut'

Expand Down