Skip to content

Commit

Permalink
sort visits for select
Browse files Browse the repository at this point in the history
  • Loading branch information
pbugni committed Nov 20, 2024
1 parent 380c6ac commit 07a6632
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions portal/views/patients.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,15 +184,23 @@ def requested_orgs(user, research_study_id):
options.append({"action_state": [(state[0], _(state[0])) for state in distinct_action]})
distinct_visits = PatientList.query.distinct(PatientList.empro_visit).with_entities(
PatientList.empro_visit)
options.append({"empro_visit": [(visit[0], translate_visit_name(visit[0])) for visit in distinct_visits]})
sorted_visits = sorted(
[v[0] for v in distinct_visits if v[0]],
key=lambda x: (0 if not x.split()[-1].isdigit() else int(x.split()[-1]))
)
options.append({"empro_visit": [(visit, translate_visit_name(visit)) for visit in sorted_visits]})
else:
distinct_status = PatientList.query.distinct(
PatientList.questionnaire_status).with_entities(PatientList.questionnaire_status)
options.append(
{"questionnaire_status": [(status[0], _(status[0])) for status in distinct_status]})
distinct_visits = PatientList.query.distinct(PatientList.visit).with_entities(
PatientList.visit)
options.append({"visit": [(visit[0], translate_visit_name(visit[0])) for visit in distinct_visits]})
sorted_visits = sorted(
[v[0] for v in distinct_visits if v[0]],
key=lambda x: (0 if not x.split()[-1].isdigit() else int(x.split()[-1]))
)
options.append({"visit": [(visit, translate_visit_name(visit)) for visit in sorted_visits]})

viewable_orgs = requested_orgs(user, research_study_id)
query = PatientList.query.filter(PatientList.org_id.in_(viewable_orgs))
Expand Down

0 comments on commit 07a6632

Please sign in to comment.