Skip to content

Commit 0602046

Browse files
authored
PPHA-714: SQL script to export NHS Numbers of submitted responses from DB to CSV (#439)
# What is the change? Added a new SQL script that will be run to extract NHS numbers of participants that have completed the questionnaire. # Why are we making this change? To share the NHS Numbers with one partner to inform them of participants that have completed the questionnaire
2 parents 81b1ee7 + c9e38e2 commit 0602046

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- SQL script to export a csv file containing NHS numbers of submitted responses to a folder on an AVD.
2+
-- A valid response is defined as a response where the user has submitted the questionnaire.
3+
-- Run script using the psql command line tool on AVD.
4+
-- Update PATH_TO_EXPORT_FILE before running to specify the location and name of the exported file. The file will be created if it does not exist, or overwritten if it does.
5+
6+
\set ON_ERROR_STOP on
7+
\copy (SELECT DISTINCT qu.nhs_number FROM questions_user qu JOIN questions_responseset qrs ON qrs.user_id = qu.id WHERE qrs.submitted_at IS NOT NULL) TO 'PATH_TO_EXPORT_FILE' WITH (FORMAT csv, HEADER true);
8+

0 commit comments

Comments
 (0)