@@ -0,0 +1,2177 @@
+%22%22%22questionnaire list sp%0A%0ARevision ID: 0a7052e0253f%0ARevises: e968d868a097%0ACreate Date: 2020-02-05 15:56:20.552056%0A%0A%22%22%22%0Afrom alembic import op%0A%0Afrom rdr_service.dao.alembic_utils import ReplaceableObject%0A%0A%0A# revision identifiers, used by Alembic.%0Arevision = '0a7052e0253f'%0Adown_revision = 'e968d868a097'%0Abranch_labels = None%0Adepends_on = None%0A%0A%0Asp_questionnaire_list = ReplaceableObject(%0A    %22sp_get_questionnaire_list%22, %22%22%22%0A        (IN participant_id int)%0A    SELECT%0A          qr.participant_id,%0A          c.value as questionnaire_name,          %0A          qr.created,%0A          qr.authored,          %0A          q.semantic_version,%0A          q.version,%0A          qr.language,%0A          qr.questionnaire_id,%0A          qr.questionnaire_response_id,%0A          c.code_id%0A    FROM questionnaire_response qr%0A      INNER JOIN questionnaire_concept qc%0A                 ON qr.questionnaire_id = qc.questionnaire_id%0A      INNER JOIN questionnaire q on q.questionnaire_id = qc.questionnaire_id and q.version = qc.questionnaire_version%0A      INNER JOIN code c on qc.code_id = c.code_id%0A    WHERE qr.participant_id = participant_id%0A    ORDER BY qr.authored;%0A%22%22%22)%0A%0Adef upgrade(engine_name):%0A    globals()%5B%22upgrade_%25s%22 %25 engine_name%5D()%0A%0A%0Adef downgrade(engine_name):%0A    globals()%5B%22downgrade_%25s%22 %25 engine_name%5D()%0A%0A%0A%0Adef upgrade_rdr():%0A    # ### commands auto generated by Alembic - please adjust! ###%0A    op.create_sp(sp_questionnaire_list)%0A    # ### end Alembic commands ###%0A%0A%0Adef downgrade_rdr():%0A    # ### commands auto generated by Alembic - please adjust! ###%0A    op.drop_sp(sp_questionnaire_list)%0A    # ### end Alembic commands ###%0A%0A%0Adef upgrade_metrics():%0A    # ### commands auto generated by Alembic - please adjust! ###%0A    pass%0A    # ### end Alembic commands ###%0A%0A%0Adef downgrade_metrics():%0A    # ### commands auto generated by Alembic - please adjust! ###%0A    pass%0A    # ### end Alembic commands ###%0A%0Adef unittest_schemas():%0A    schemas = list()%0A%0A    schemas.append(%22DROP PROCEDURE IF EXISTS %60%7B0%7D%60%22.format(sp_questionnaire_list.name))%0A    schemas.append(%0A        %22CREATE PROCEDURE %60%7B0%7D%60 %7B1%7D%22.format(sp_questionnaire_list.name, sp_questionnaire_list.sqltext)%0A    )%0A%0A    return schemas

Create a stored proc to get the list of submitted questionnaires (#1568)