| 125 | |
| 126 | Try a different approach: |
| 127 | |
| 128 | {{{#!sql |
| 129 | |
| 130 | SELECT |
| 131 | p.id AS ParticipantID |
| 132 | , p.barcode AS StudyID |
| 133 | , p.first_name |
| 134 | , p.last_name |
| 135 | , p.birth_date |
| 136 | , p.gender |
| 137 | , p.enrollment_id AS UhlSystemNumber |
| 138 | , consent.q1 |
| 139 | , consent.q2 |
| 140 | , consent.q3 |
| 141 | , consent.q4 |
| 142 | , consent.q5 |
| 143 | FROM participant p |
| 144 | LEFT JOIN ( |
| 145 | SELECT |
| 146 | qp.participant_id |
| 147 | , GROUP_CONCAT(if(qa.question_name = 'consent_q1', category_name, NULL)) AS q1 |
| 148 | , GROUP_CONCAT(if(qa.question_name = 'consent_q1', category_name, NULL)) AS q2 |
| 149 | , GROUP_CONCAT(if(qa.question_name = 'consent_q1', category_name, NULL)) AS q3 |
| 150 | , GROUP_CONCAT(if(qa.question_name = 'consent_q1', category_name, NULL)) AS q4 |
| 151 | , GROUP_CONCAT(if(qa.question_name = 'consent_q1', category_name, NULL)) AS q5 |
| 152 | FROM question_answer qa |
| 153 | JOIN category_answer ca ON ca.question_answer_id = qa.id |
| 154 | JOIN questionnaire_participant qp ON qp.id = qa.questionnaire_participant_id |
| 155 | AND qp.questionnaire_name = 'ManualConsentQuestionnaire' |
| 156 | GROUP BY qp.participant_id |
| 157 | ) consent ON consent.participant_id = p.id |
| 158 | ; |
| 159 | |
| 160 | }}} |