-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsynapse_upload.sql
197 lines (182 loc) · 2.91 KB
/
synapse_upload.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
* prepare the the data for synapse upload, verify the consented patients.
*/
SELECT
s.record_id,
browser_name,
platform_name,
browser_height,
browser_width,
has_js,
is_complete,
segment,
pagelnk,
measure_order,
"Version",
lastpage,
pages,
"Language",
answerforself,
demog1,
demog2,
demog2_other,
demog3,
demog4,
demog5,
demog5a,
demog6,
demog6a,
demog7,
demog8,
demog10,
demog11,
demog11_other,
demog12a,
demog12b,
demog12c,
demog12d,
demog12e,
demog12f,
demog12g,
demog12h,
demog12i,
demog12j,
demog12_other,
demog13,
demog14,
demog14a,
demog15,
demog15a,
demog16a,
demog16b,
demog16c,
demog16d,
demog_16_other,
demog17,
demog18,
demog19,
sdi_dsc38,
sdi_dsc20,
sdi_dsc9,
sdi_dsc32,
sdi_dsc1,
sdi_dsc26,
sdi_dsc14,
sdi_dsc25,
sdi_dsc2,
sdi_dsc39,
sdi_dsc22,
sdi_dsc35,
sdi_dsc10,
sdi_dsc19,
sdi_dsc30,
sdi_dsc12,
sdi_dsc42,
sdi_dsc6,
sdi_dsc18,
sdi_dsc36,
sdi_dsc23,
overall_sdi
FROM
sdi s
JOIN consented c ON c.record_id = s.record_id
WHERE
c.survey_access_agree = 1;
SELECT
*
FROM
ds_connect s
JOIN consented c ON c.record_id = s.col4
WHERE
c.dsconnect_access_agree = 1;
SELECT
d.*
FROM
demographic_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
encounter_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
diagnosis_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
procedures_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
lab_result_cm_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
condition_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
pro_cm_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
prescribing_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
death_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
med_admin_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
obs_clin_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
immunization_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;
SELECT
d.*
FROM
vital_all d
JOIN consented c ON c.record_id = d.patid
WHERE
c.ehr_access_agree = 1;