Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
vidjil
vidjil
Commits
a4a1a5ba
Commit
a4a1a5ba
authored
Oct 12, 2018
by
Mikaël Salson
Browse files
modules/vidjil_utils: anon_ids now take a list of sample set IDs
This allows to speed up queries when we have many sample sets
parent
c8168b0e
Changes
4
Hide whitespace changes
Inline
Side-by-side
server/web2py/applications/vidjil/controllers/default.py
View file @
a4a1a5ba
...
...
@@ -260,7 +260,7 @@ def get_data():
if
(
sample_set
.
sample_type
==
defs
.
SET_TYPE_PATIENT
):
for
row
in
db
(
db
.
patient
.
sample_set_id
==
request
.
vars
[
"sample_set_id"
]
).
select
()
:
log_reference_id
=
row
.
id
patient_name
=
vidjil_utils
.
anon_ids
(
row
.
id
)
patient_name
=
vidjil_utils
.
anon_ids
(
[
row
.
id
])[
0
]
data
[
"dataFileName"
]
=
patient_name
+
" ("
+
config_name
+
")"
data
[
"info"
]
=
db
.
patient
[
row
.
id
].
info
data
[
"patient_id"
]
=
row
.
id
...
...
@@ -401,7 +401,7 @@ def get_custom_data():
patient_run
=
db
(
db
[
sample_set
.
sample_type
].
sample_set_id
==
sample_set
.
id
).
select
().
first
()
config_id
=
db
.
results_file
[
id
].
config_id
name
=
vidjil_utils
.
anon_ids
(
patient_run
.
id
)
if
sample_set
.
sample_type
==
defs
.
SET_TYPE_PATIENT
else
patient_run
.
name
name
=
vidjil_utils
.
anon_ids
(
[
patient_run
.
id
])[
0
]
if
sample_set
.
sample_type
==
defs
.
SET_TYPE_PATIENT
else
patient_run
.
name
filename
=
db
.
sequence_file
[
sequence_file_id
].
filename
data
[
"samples"
][
"original_names"
].
append
(
name
+
"_"
+
filename
)
data
[
"samples"
][
"timestamp"
].
append
(
str
(
db
.
sequence_file
[
sequence_file_id
].
sampling_date
))
...
...
server/web2py/applications/vidjil/controllers/log.py
View file @
a4a1a5ba
...
...
@@ -13,7 +13,7 @@ if request.env.http_origin:
def
anon_names
(
data
):
for
row
in
data
:
# TODO use helper ?
row
.
name
=
vidjil_utils
.
anon_ids
(
row
.
id
)
row
.
name
=
vidjil_utils
.
anon_ids
(
[
row
.
id
])[
0
]
return
data
def
get_data_list
(
table
):
...
...
@@ -72,7 +72,7 @@ def index():
orderby
=~
db
.
user_log
.
created
)
for
row
in
query
:
if
row
.
patient
.
first_name
is
not
None
:
row
.
names
=
vidjil_utils
.
anon_ids
(
row
.
user_log
.
record_id
)
row
.
names
=
vidjil_utils
.
anon_ids
(
[
row
.
user_log
.
record_id
])[
0
]
else
:
row
.
names
=
row
.
run
.
name
return
dict
(
query
=
query
,
...
...
server/web2py/applications/vidjil/models/SampleSet.py
View file @
a4a1a5ba
...
...
@@ -162,7 +162,7 @@ def get_sample_name(sample_set_id):
if
patient_or_run
is
None
:
return
None
if
sample
.
sample_type
==
defs
.
SET_TYPE_PATIENT
:
return
vidjil_utils
.
anon_ids
(
patient_or_run
.
id
)
return
vidjil_utils
.
anon_ids
(
[
patient_or_run
.
id
])[
0
]
return
patient_or_run
.
name
def
get_set_group
(
sid
):
...
...
server/web2py/applications/vidjil/modules/vidjil_utils.py
View file @
a4a1a5ba
...
...
@@ -87,14 +87,18 @@ def anon_birth(patient_id, user_id):
else
:
return
age
def
anon_ids
(
patient_id
):
'''Anonymize patient name. Only the 'anon' access see the full patient name.'''
def
anon_ids
(
patient_ids
,
can_view
=
None
):
'''Anonymize patient name. Only the 'anon' access see the full patient name.
patient_ids is a list of patient IDs
'''
db
=
current
.
db
auth
=
current
.
auth
patient
=
db
.
patient
[
patient_id
]
patients
=
db
(
db
.
patient
.
id
.
belongs
(
patient_ids
)).
select
(
db
.
patient
.
sample_set_id
,
db
.
patient
.
first_name
,
db
.
patient
.
last_name
)
return
display_names
(
p
atient
.
sample_set_id
,
p
atient
.
first_name
,
p
atient
.
last_name
)
return
[
display_names
(
p
.
sample_set_id
,
p
.
first_name
,
p
.
last_name
,
can_view
)
for
p
in
patients
]
def
anon_names
(
sample_set_id
,
first_name
,
last_name
,
can_view
=
None
):
'''
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment