Skip to content

Commit

Permalink
filter qnr_data in /timeline by research_study_id and add missing com…
Browse files Browse the repository at this point in the history
…ment.
  • Loading branch information
pbugni committed Jan 4, 2024
1 parent 017933a commit 0dbbe80
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions portal/models/questionnaire_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,6 +854,8 @@ def aggregate_responses(
:param celery_task: if defined, send occasional progress updates
:param patient_ids: if defined, limit result set to given patient list
NB: research_study_id not used to filter / restrict query set, but rather
for lookup of visit name. Use instrument_ids to restrict query set.
"""
from .qb_timeline import qb_status_visit_name # avoid cycle

Expand Down
14 changes: 12 additions & 2 deletions portal/views/patient.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
from ..models.questionnaire_response import QuestionnaireResponse
from ..models.reference import Reference
from ..models.reporting import single_patient_adherence_data
from ..models.research_study import EMPRO_RS_ID, ResearchStudy
from ..models.research_study import (
EMPRO_RS_ID,
ResearchStudy,
research_study_id_from_questionnaire
)
from ..models.role import ROLE
from ..models.user import User, current_user, get_user
from ..timeout_lock import ADHERENCE_DATA_KEY, CacheModeration
Expand Down Expand Up @@ -480,11 +484,17 @@ def get_recur_id(qnr):
for row in qnr_responses['entry']:
i = {}
d = row['resource']
i['questionnaire'] = d['questionnaire']['reference'].split('/')[-1]

# qnr_responses return all. filter to requested research_study
study_id = research_study_id_from_questionnaire(i['questionnaire'])
if study_id != research_study_id:
continue

i['auth_method'] = d['encounter']['auth_method']
i['encounter_period'] = d['encounter']['period']
i['document_authored'] = d['authored']
i['ae_session'] = d['identifier']['value']
i['questionnaire'] = d['questionnaire']['reference'].split('/')[-1]
i['status'] = d['status']
i['org'] = d['subject']['careProvider'][0]['display']
i['visit'] = d['timepoint']
Expand Down

0 comments on commit 0dbbe80

Please sign in to comment.