Commit 8288df77 authored by Mathieu Giraud's avatar Mathieu Giraud Committed by Vidjil Team

vidjil_utils.py, anonymization: unicode decoding of patient name

If the patient name has some unicode characters, the manipulated string has to be a python unicode string.
We should one day ensure that all strings are handled as unicode both in the database and in web2py.
parent a500d0a4
......@@ -46,6 +46,12 @@ def anon(patient_id, user_id):
first_name = db.patient[patient_id].first_name
if auth.has_permission("anon", "patient", patient_id, user_id):
return last_name + " " + first_name
name = last_name + " " + first_name
else:
return last_name[:3]
try:
ln = unicode(last_name, 'utf-8')
except UnicodeDecodeError:
ln = last_name
name = ln[:3]
return name
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