Commit 8d413c14 authored by Ryan Herbert's avatar Ryan Herbert

anon functions display sample_set_id

since we are phasing out the use of patient/run/generic ids in favour of
sample_set_ids.

See #2978
parent 91c529c1
......@@ -18,7 +18,7 @@ def info():
if request.vars["config_id"] and request.vars["config_id"] != "-1" and request.vars["config_id"] != "None":
config_id = long(request.vars["config_id"])
patient_name = vidjil_utils.anon_names(patient.id, patient.first_name, patient.last_name)
patient_name = vidjil_utils.anon_names(patient.sample_set_id, patient.first_name, patient.last_name)
config_name = db.config[request.vars["config_id"]].name
fused = db(
......
......@@ -570,7 +570,7 @@ def custom():
]
select = [
db.patient.id, db.patient.info, db.patient.first_name, db.patient.last_name,
db.patient.id, db.patient.sample_set_id, db.patient.info, db.patient.first_name, db.patient.last_name,
db.run.id, db.run.info, db.run.name,
db.generic.id, db.generic.info, db.generic.name,
db.results_file.id, db.results_file.config_id, db.sequence_file.sampling_date,
......@@ -609,7 +609,7 @@ def custom():
if row.patient.id is not None:
#TODO use helper.
row.names = vidjil_utils.display_names(row.patient.id, row.patient.first_name, row.patient.last_name)
row.names = vidjil_utils.display_names(row.patient.sample_set_id, row.patient.first_name, row.patient.last_name)
info = row.patient.info
elif row.run.id is not None:
row.names = row.run.name
......
......@@ -16,10 +16,10 @@ class Patient(SampleSet):
return fields
def get_name(self, data, anon=None):
return vidjil_utils.anon_names(data['id'], data['first_name'], data['last_name'], anon)
return vidjil_utils.anon_names(data['sample_set_id'], data['first_name'], data['last_name'], anon)
def get_display_name(self, data, anon=None):
return vidjil_utils.display_names(data.id, data.first_name, data.last_name, anon)
return vidjil_utils.display_names(data.sample_set_id, data.first_name, data.last_name, anon)
def get_birth(self, data):
return "%s" % str(data['birth']) if data['birth'] is not None else ''
......
......@@ -91,12 +91,11 @@ def anon_ids(patient_id):
db = current.db
auth=current.auth
last_name = db.patient[patient_id].last_name
first_name = db.patient[patient_id].first_name
patient = db.patient[patient_id]
return display_names(patient_id, first_name, last_name)
return display_names(patient.sample_set_id, patient.first_name, patient.last_name)
def anon_names(patient_id, first_name, last_name, can_view=None):
def anon_names(sample_set_id, first_name, last_name, can_view=None):
'''
Anonymize the given names of the patient whose ID is patient_id.
This function performs at most one db call (to know if we can see
......@@ -107,7 +106,7 @@ def anon_names(patient_id, first_name, last_name, can_view=None):
ln = safe_encoding(last_name)
fn = safe_encoding(first_name)
if can_view or (can_view == None and auth.can_view_info('patient', patient_id)):
if can_view or (can_view == None and auth.can_view_info('sample_set', sample_set_id)):
name = ln + " " + fn
else:
ln = safe_encoding(last_name)
......@@ -115,7 +114,7 @@ def anon_names(patient_id, first_name, last_name, can_view=None):
return name
def display_names(patient_id, first_name, last_name, can_view=None):
def display_names(sample_set_id, first_name, last_name, can_view=None):
'''
Return the name as displayed to a user or admin of a patient
whose ID is patient_id.
......@@ -125,11 +124,11 @@ def display_names(patient_id, first_name, last_name, can_view=None):
'''
auth = current.auth
name = anon_names(patient_id, first_name, last_name, can_view)
name = anon_names(sample_set_id, first_name, last_name, can_view)
# Admins also see the patient id
if auth.is_admin():
name += ' (%s)' % patient_id
name += ' (%s)' % sample_set_id
return name
......
......@@ -43,7 +43,7 @@
{{for row in query :}}
<tr class="pointer" onclick="db.call('sample_set/index', {'id' :'{{=row['sample_set_id']}}' , 'config_id' : {{=row['most_used_conf']}} } )" >
<td>
{{ patient_name = vidjil_utils.anon_names(row['id'], row['first_name'], row['last_name'], row['anon_allowed'])}}
{{ patient_name = vidjil_utils.anon_names(row['sample_set_id'], row['first_name'], row['last_name'], row['anon_allowed'])}}
{{= patient_name}}
</td>
<td> {{ if row['birth'] is not None: }} {{=row['birth'] }} {{ pass }} </td>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment