Changes between Version 9 and Version 10 of Onyx to CiviCRM


Ignore:
Timestamp:
12/12/13 15:51:51 (10 years ago)
Author:
Richard Bramley
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Onyx to CiviCRM

    v9 v10  
    123123
    124124}}}
     125
     126Try a different approach:
     127
     128{{{#!sql
     129
     130SELECT
     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
     143FROM participant p
     144LEFT 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}}}