-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.py
executable file
·404 lines (397 loc) · 18.1 KB
/
query.py
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 29 10:52:37 2017
filename: query.py
description: This file contains the query to fetch data from the I-ELCAP database
author: Timo Klingler
"""
def run_query(query_dict):
"""
The output of the function is a list of strings
seperated by logical operators of the database.
"""
qlist = []
[qlist.append(query_dict[key] + str(' = * OR ') + query_dict[key] + str(' != * AND ')) for key in query_dict]
query = ''.join(qlist)
return query[:-5]
query_dict = {
'Date of First Contact' : 'sidfc',
'Date of Baseline CT' : 'sidoe',
'Research Protocol' : 'sirp',
'Cancellation' : 'sica',
'Special Attention' : 'sisa',
'How did you hear about our program?' : 'sihap',
'Specify' : 'sihapo',
'Patient Information' : 'siadcomna',
'Patient Street Address' : 'sipsa',
'Apt' : 'sipan',
'County' : 'sipcn',
'City' : 'sipc',
'State' : 'sips',
'Zip' : 'sipz',
'Country' : 'sipcr',
'Phone (Work)' : 'sipw',
'Phone (Home)' : 'siph',
'Email Address' : 'sipem',
'Physician Name' : 'simdn',
'Physician Street Address' : 'simdsa',
'Physician County' : 'simdcn',
'Physician City' : 'simdc',
'Physician State' : 'simds',
'Physician Zip' : 'simdz',
'Physician Country' : 'simdcr',
'Physician Phone' : 'simdp',
'Physician Fax' : 'simdf',
'Date of Birth' : 'sidob',
'SSN' : 'sissn',
'First Name (Mother)' : 'sifnm',
'First Name (Father)' : 'sifnf',
'Emergency Contact (1) Name' : 'sikn',
'Emergency Contact (1) Relation' : 'sikr',
'Emergency Contact (1) Address' : 'sika',
'Emergency Contact (1) Phone' : 'sikp',
'Emergency Contact (2) Name' : 'siknb',
'Emergency Contact (2) Relation' : 'sikrb',
'Emergency Contact (2) Address' : 'sikab',
'Emergency Contact (2) Phone' : 'sikpb',
'Phone Calls' : 'sicnc',
'Letters' : 'sicnl',
'Patient Status' : 'sies',
'Specify (Status)' : 'sieso',
'Date of Exit' : 'sixdate',
'DOD' : 'sidod',
'COD' : 'sicod',
'Correspondence Date' : 'sircd',
'Date of Exam' : 'sired',
'Recipient' : 'sirr',
'Physician Name (Recipient)' : 'sirmd',
'Nature' : 'sirn',
'Coordinator' : 'sirc',
'Study Date' : 'cedos',
'Exam Number' : 'ceen',
'Radiologist' : 'cerad',
'Final Reading' : 'cecon',
'CT Scan Performed at Outside Institution' : 'ceofr',
'Type of Exam' : 'cetex',
'CT Protocol' : 'cectp',
'Date of Most Recent Comparative Study' : 'cedcs',
'Time Since Baseline (Months)' : 'cetsb',
'Normal Shortcut' : 'censb',
'Total Number of Non-Calcified Nodules' : 'cenncn',
'Total Number of Nodules' : 'cennod',
'Is it new? (Nodule 1)' : 'cect1ch',
'Is it new? (Nodule 2)' : 'cect2ch',
'Is it new? (Nodule 3)' : 'cect3ch',
'Is it new? (Nodule 4)' : 'cect4ch',
'Is it new? (Nodule 5)' : 'cect5ch',
'Is it new? (Additional Nodule)' : 'cect0ch',
'Endobronchial? (Nodule 1)' : 'cect1en',
'Endobronchial? (Nodule 2)' : 'cect2en',
'Endobronchial? (Nodule 3)' : 'cect3en',
'Endobronchial? (Nodule 4)' : 'cect4en',
'Endobronchial? (Nodule 5)' : 'cect5en',
'Endobronchial? (Additional Nodule)' : 'cect0en',
'Most Likely Location (Nodule 1)' : 'cect1ll',
'Most Likely Location (Nodule 2)' : 'cect2ll',
'Most Likely Location (Nodule 3)' : 'cect3ll',
'Most Likely Location (Nodule 4)' : 'cect4ll',
'Most Likely Location (Nodule 5)' : 'cect5ll',
'Most Likely Location (Additional Nodule)' : 'cect0ll',
'Distance from the costal pleura in mm (Nodule 1)' : 'cect1pld',
'Distance from the costal pleura in mm (Nodule 2)' : 'cect2pld',
'Distance from the costal pleura in mm (Nodule 3)' : 'cect3pld',
'Distance from the costal pleura in mm (Nodule 4)' : 'cect4pld',
'Distance from the costal pleura in mm (Nodule 5)' : 'cect5pld',
'Distance from the costal pleura in mm (Additional Nodule)' : 'cect0pld',
'Length in mm (Nodule 1)' : 'cect1sl',
'Length in mm (Nodule 2)' : 'cect2sl',
'Length in mm (Nodule 3)' : 'cect3sl',
'Length in mm (Nodule 4)' : 'cect4sl',
'Length in mm (Nodule 5)' : 'cect5sl',
'Length in mm (Additional Nodule)' : 'cect0sl',
'Maximum Width in mm (Nodule 1)' : 'cect1sw',
'Maximum Width in mm (Nodule 2)' : 'cect2sw',
'Maximum Width in mm (Nodule 3)' : 'cect3sw',
'Maximum Width in mm (Nodule 4)' : 'cect4sw',
'Maximum Width in mm (Nodule 5)' : 'cect5sw',
'Maximum Width in mm (Additional Nodule)' : 'cect0sw',
'Nodule Consistency (Nodule 1)' : 'cect1nt',
'Nodule Consistency (Nodule 2)' : 'cect2nt',
'Nodule Consistency (Nodule 3)' : 'cect3nt',
'Nodule Consistency (Nodule 4)' : 'cect4nt',
'Nodule Consistency (Nodule 5)' : 'cect5nt',
'Nodule Consistency (Additional Nodule)' : 'cect0nt',
'Solid Comp. Length (Nodule 1)' : 'cect1ssl',
'Solid Comp. Length (Nodule 2)' : 'cect2ssl',
'Solid Comp. Length (Nodule 3)' : 'cect3ssl',
'Solid Comp. Length (Nodule 4)' : 'cect4ssl',
'Solid Comp. Length (Nodule 5)' : 'cect5ssl',
'Solid Comp. Length (Additional Nodule)' : 'cect0ssl',
'Solid Comp. Width (Nodule 1)' : 'cect1ssw',
'Solid Comp. Width (Nodule 2)' : 'cect2ssw',
'Solid Comp. Width (Nodule 3)' : 'cect3ssw',
'Solid Comp. Width (Nodule 4)' : 'cect4ssw',
'Solid Comp. Width (Nodule 5)' : 'cect5ssw',
'Solid Comp. Width (Additional Nodule)' : 'cect0ssw',
'Smooth Edges (Nodule 1)' : 'cect1se',
'Smooth Edges (Nodule 2)' : 'cect2se',
'Smooth Edges (Nodule 3)' : 'cect3se',
'Smooth Edges (Nodule 4)' : 'cect4se',
'Smooth Edges (Nodule 5)' : 'cect5se',
'Smooth Edges (Additional Nodule)' : 'cect0se',
'Calcifications c/w Benignity (Nodule 1)' : 'cect1ca',
'Calcifications c/w Benignity (Nodule 2)' : 'cect2ca',
'Calcifications c/w Benignity (Nodule 3)' : 'cect3ca',
'Calcifications c/w Benignity (Nodule 4)' : 'cect4ca',
'Calcifications c/w Benignity (Nodule 5)' : 'cect5ca',
'Calcifications c/w Benignity (Additional Nodule)' : 'cect0ca',
'Spiculations /Pleural Tags (Nodule 1)' : 'cect1sp',
'Spiculations /Pleural Tags (Nodule 2)' : 'cect2sp',
'Spiculations /Pleural Tags (Nodule 3)' : 'cect3sp',
'Spiculations /Pleural Tags (Nodule 4)' : 'cect4sp',
'Spiculations /Pleural Tags (Nodule 5)' : 'cect5sp',
'Spiculations /Pleural Tags (Additional Nodule)' : 'cect0sp',
'Parenchymal Abnormality within 1 cm (Nodule 1)' : 'cect1pa',
'Parenchymal Abnormality within 1 cm (Nodule 2)' : 'cect2pa',
'Parenchymal Abnormality within 1 cm (Nodule 3)' : 'cect3pa',
'Parenchymal Abnormality within 1 cm (Nodule 4)' : 'cect4pa',
'Parenchymal Abnormality within 1 cm (Nodule 5)' : 'cect5pa',
'Parenchymal Abnormality within 1 cm (Additional Nodule)' : 'cect0pa',
'Nodule seen in series (Nodule 1)' : 'cect1sn',
'Nodule seen in series (Nodule 2)' : 'cect2sn',
'Nodule seen in series (Nodule 3)' : 'cect3sn',
'Nodule seen in series (Nodule 4)' : 'cect4sn',
'Nodule seen in series (Nodule 5)' : 'cect5sn',
'Nodule seen in series (Additional Nodule)' : 'cect0sn',
'Nodule seen in images left (Nodule 1)' : 'cect1inl',
'Nodule seen in images left (Nodule 2)' : 'cect2inl',
'Nodule seen in images left (Nodule 3)' : 'cect3inl',
'Nodule seen in images left (Nodule 4)' : 'cect4inl',
'Nodule seen in images left (Nodule 5)' : 'cect5inl',
'Nodule seen in images left (Additional Nodule)' : 'cect0inl',
'Nodule seen in images right (Nodule 1)' : 'cect1inh',
'Nodule seen in images right (Nodule 2)' : 'cect2inh',
'Nodule seen in images right (Nodule 3)' : 'cect3inh',
'Nodule seen in images right (Nodule 4)' : 'cect4inh',
'Nodule seen in images right (Nodule 5)' : 'cect5inh',
'Nodule seen in images right (Additional Nodule)' : 'cect0inh',
'Nodule Status (Nodule 1)' : 'cect1st',
'Nodule Status (Nodule 2)' : 'cect2st',
'Nodule Status (Nodule 3)' : 'cect3st',
'Nodule Status (Nodule 4)' : 'cect4st',
'Nodule Status (Nodule 5)' : 'cect5st',
'Nodule Status (Additional Nodule)' : 'cect0st',
'Action (Nodule 1)' : 'cect1ac',
'Action (Nodule 2)' : 'cect2ac',
'Action (Nodule 3)' : 'cect3ac',
'Action (Nodule 4)' : 'cect4ac',
'Action (Nodule 5)' : 'cect5ac',
'Action (Additional Nodule)' : 'cect0ac',
'Comment (Nodule 1)' : 'cect1co',
'Comment (Nodule 2)' : 'cect2co',
'Comment (Nodule 3)' : 'cect3co',
'Comment (Nodule 4)' : 'cect4co',
'Comment (Nodule 5)' : 'cect5co',
'Comment (Additional Nodule)' : 'cect0co',
'Pathologic Diagnosis (Nodule 1)' : 'cect1pd',
'Pathologic Diagnosis (Nodule 2)' : 'cect2pd',
'Pathologic Diagnosis (Nodule 3)' : 'cect3pd',
'Pathologic Diagnosis (Nodule 4)' : 'cect4pd',
'Pathologic Diagnosis (Nodule 5)' : 'cect5pd',
'Pathologic Diagnosis (Additional Nodule)' : 'cect0pd',
'Other Parenchymal Abnormalities' : 'ceopp',
'Emphysema n/v' : 'ceemv',
'Emphysema' : 'ceem',
'Cysts/Blebs/Bullae' : 'cecbb',
'Cysts/Blebs/Bullae RUL' : 'cecbbl1',
'Cysts/Blebs/Bullae RML' : 'cecbbl2',
'Cysts/Blebs/Bullae RLL' : 'cecbbl3',
'Cysts/Blebs/Bullae LUL' : 'cecbbl4',
'Cysts/Blebs/Bullae LLL' : 'cecbbl5',
'Small Airways Disease/Bronchiolectasis' : 'cebrss',
'Small Airways Disease/Bronchiolectasis RUL' : 'cebrssl1',
'Small Airways Disease/Bronchiolectasis RML' : 'cebrssl2',
'Small Airways Disease/Bronchiolectasis RLL' : 'cebrssl3',
'Small Airways Disease/Bronchiolectasis LUL' : 'cebrssl4',
'Small Airways Disease/Bronchiolectasis LLL' : 'cebrssl5',
'Bronchiectasis' : 'cebrsb',
'Bronchiectasis RUL' : 'cebrsbl1',
'Bronchiectasis RML' : 'cebrsbl2',
'Bronchiectasis RLL' : 'cebrsbl3',
'Bronchiectasis LUL' : 'cebrsbl4',
'Bronchiectasis LLL' : 'cebrsbl5',
'Interstitial lung disease' : 'ceild',
'Interstitial lung disease RUL' : 'ceildl1',
'Interstitial lung disease RML' : 'ceildl2',
'Interstitial lung disease RLL' : 'ceildl3',
'Interstitial lung disease LUL' : 'ceildl4',
'Interstitial lung disease LLL' : 'ceildl5',
'Honeycombing' : 'cephc',
'Honeycombing RUL' : 'cephcl1',
'Honeycombing RML' : 'cephcl2',
'Honeycombing RLL' : 'cephcl3',
'Honeycombing LUL' : 'cephcl4',
'Honeycombing LLL' : 'cephcl5',
'Regional or Diffuse Consolidation' : 'cerdc',
'Regional or Diffuse Consolidation RUL' : 'cerdcl1',
'Regional or Diffuse Consolidation RML' : 'cerdcl2',
'Regional or Diffuse Consolidation RLL' : 'cerdcl3',
'Regional or Diffuse Consolidation LUL' : 'cerdcl4',
'Regional or Diffuse Consolidation LLL' : 'cerdcl5',
'Scarring' : 'cescr',
'Scarring RUL' : 'cescrl1',
'Scarring RML' : 'cescrl2',
'Scarring RLL' : 'cescrl3',
'Scarring LUL' : 'cescrl4',
'Scarring LLL' : 'cescrl5',
'Scarring unilateral' : 'cescrl6',
'Scarring bilateral' : 'cescrl7',
'Rounded Atelectasis' : 'cebatr',
'Rounded Atelectasis RUL' : 'cebatrl1',
'Rounded Atelectasis RML' : 'cebatrl2',
'Rounded Atelectasis RLL' : 'cebatrl3',
'Rounded Atelectasis LUL' : 'cebatrl4',
'Rounded Atelectasis LLL' : 'cebatrl5',
'Other Atelectasis' : 'cebat',
'Other Atelectasis RUL' : 'cebatl1',
'Other Atelectasis RML' : 'cebatl2',
'Other Atelectasis RLL' : 'cebatl3',
'Other Atelectasis LUL' : 'cebatl4',
'Other Atelectasis LLL' : 'cebatl5',
'Bronchial Resection Margin' : 'cebs',
'Bronchial Resection Margin Right' : 'cebsrt',
'Bronchial Resection Margin Left' : 'cebslt',
'Pleural Effusion' : 'cepev',
'Pleural Effusion Right' : 'ceper',
'Pleural Effusion Left' : 'cepel',
'Pleural Thickening/Fissural Plaques' : 'cept',
'Pleural Thickening/Fissural Plaques Right' : 'ceptrt',
'Pleural Thickening/Fissural Plaques Left' : 'ceptlt',
'Pleural Thickening/Fissural Plaques Calcification' : 'ceptca',
'Pleural Tumor' : 'cepu',
'Pleural Tumor Describe' : 'cepus',
'Additional Comments on Parenchymal or Pleural Abnormalities' : 'ceoppa',
'Cardiac Abnormalities' : 'ceca',
'Coronary Calcification' : 'ceccv',
'Coronary Calcification Left Main' : 'cecclm',
'Coronary Calcification LAD' : 'ceccld',
'Coronary Calcification Circumflex' : 'ceccct',
'Coronary Calcification RCA' : 'ceccrc',
'Visual CAC Score' : 'cecccac',
'Pericardial Effusion' : 'ceprev',
'Pericardial Effusion Severity' : 'ceprevm',
'Neck and Mediastinal Abnormalities' : 'ceoma',
'Thyroid' : 'ceoma',
'Thyroid Calcification' : 'ceatc',
'Thyroid Cyst' : 'ceaty',
'Thyroid Mass' : 'ceatm',
'Thyroid Other' : 'ceato',
'Thyroid Specify' : 'ceatos',
'Thymus' : 'ceaya',
'Thymus Calcification' : 'ceayc',
'Thymus Cyst' : 'ceaycc',
'Thymus Mass' : 'ceaym',
'Thymus Other' : 'ceayo',
'Thymus Specify' : 'ceayos',
'Lymph Nodes Enlarged' : 'cemln',
'Lymph Nodes Enlarged N1' : 'cemln1',
'Lymph Nodes Enlarged N2R' : 'cemlnl2r',
'Lymph Nodes Enlarged N2L' : 'cemlnl2l',
'Lymph Nodes Enlarged N3' : 'cemlnl3',
'Lymph Nodes Enlarged N4R' : 'cemlnl4r',
'Lymph Nodes Enlarged N4L' : 'cemlnl4l',
'Lymph Nodes Enlarged N5' : 'cemlnl5',
'Lymph Nodes Enlarged N6' : 'cemlnl6',
'Lymph Nodes Enlarged N7' : 'celmnl7',
'Lymph Nodes Enlarged N8' : 'celmnl8',
'Lymph Nodes Enlarged N9' : 'celmnl9',
'Lymph Nodes Enlarged N10R' : 'cemlnl10r',
'Lymph Nodes Enlarged N10L' : 'cemlnl10l',
'Lymph Nodes Calcified' : 'cemlncab',
'Axillary lymph nodes' : 'ceagaln',
'Axillary lymph nodes Right' : 'ceagalnrt',
'Axillary lymph nodes Left' : 'ceagalnlt',
'Axillary lymph nodes Specify' : 'ceagalns',
'Other Vascular Abnormalities' : 'cemva',
'Other Vascular Abnormalities Aorta' : 'cemvaa',
'Other Vascular Abnormalities Pulmonary Arteries' : 'cemvap',
'Other Vascular Abnormalities Other' : 'cemvao',
'Other Vascular Abnormalities Specify' : 'cemvaos',
'Esophageal' : 'cemeln',
'Esophageal Air-fluid level' : 'cemelna',
'Esophageal Wall thickening' : 'cemelnw',
'Esophageal Mass' : 'cemelnm',
'Esophageal Other' : 'cemelno',
'Esophageal Specify' : 'cemelnos',
'Hiatal Hernia' : 'cehhn',
'Hiatal Hernia Specify' : 'cehhnos',
'Other Mediastinal Masses' : 'ceomm',
'Other Mediastinal Masses Calcification' : 'ceamc',
'Other Mediastinal Masses Cyst' : 'ceamy',
'Other Mediastinal Masses Mass' : 'ceamm',
'Other Mediastinal Masses Other' : 'ceamo',
'Other Mediastinal Masses Specify' : 'ceommos',
'Additional Comments on Neck and Mediastinal Abnormalities' : 'ceotabnm',
'Breast Abnormalities' : 'ceoba',
'Right Breast Abnormalities' : 'ceara',
'Right Breast Calcification' : 'ceobarc',
'Right Breast Cyst' : 'ceobary',
'Right Breast Mass' : 'ceobarm',
'Right Breast Other' : 'ceobaro',
'Right Breast Specify' : 'ceobaros',
'Left Breast Abnormalities' : 'ceafa',
'Left Breast Calcification' : 'ceobafc',
'Left Breast Cyst' : 'ceobafy',
'Left Breast Mass' : 'ceobafm',
'Left Breast Other' : 'ceobafo',
'Left Breast Specify' : 'ceobafos',
'Additional Comments on Breast Abnormalities' : 'ceobrc',
'Abdominal Abnormalities' : 'ceoaa',
'Gall Bladder Abnormalities' : 'ceaga',
'Gall Bladder Cholecystectomy' : 'ceagh',
'Gall Bladder Stones' : 'ceags',
'Gall Bladder Sludge' : 'ceagl',
'Gall Bladder Other' : 'ceago',
'Gall Bladder Specify' : 'ceagos',
'Spleen Abnormalities' : 'ceasa',
'Spleen Calcification' : 'ceasc',
'Spleen Cyst' : 'ceasy',
'Spleen Mass' : 'ceasm',
'Spleen Other' : 'ceaso',
'Spleen Specify' : 'ceasos',
'Liver Abnormalities' : 'ceala',
'Liver Calcification' : 'cealc',
'Liver Cyst' : 'cealy',
'Liver Mass' : 'cealm',
'Liver Other' : 'cealo',
'Liver Specify' : 'cealos',
'Pancreas Abnormalities' : 'ceapa',
'Pancreas Calcification' : 'ceapc',
'Pancreas Cyst' : 'ceapy',
'Pancreas Mass' : 'ceapm',
'Pancreas Other' : 'ceapo',
'Pancreas Specify' : 'ceapos',
'Adrenals Abnormalities' : 'ceaaa',
'Adrenals Calcification' : 'ceaac',
'Adrenals Cyst' : 'ceaay',
'Adrenals Mass' : 'ceaam',
'Adrenals Other' : 'ceaao',
'Adrenals Specify' : 'ceaaos',
'Kidneys Abnormalities' : 'ceaka',
'Kidneys Calcification' : 'ceakc',
'Kidneys Cyst' : 'ceaky',
'Kidneys Mass' : 'ceakm',
'Kidneys Other' : 'ceako',
'Kidneys Specify' : 'ceakos',
'Additional Comments on Abdominal Abnormalities' : 'ceaoab',
'Bone Abnormalities' : 'ceaba',
'Specify Bone Abnormalities' : 'ceaoabb',
'Follow-up' : 'cefu',
'When' : 'cefuw',
'Follow-up Date' : 'cefud',
'Special Attention CT' : 'cefusa',
'Impression Nodules' : 'ceimn',
'Other Findings' : 'ceimo',
'Impression Remarks' : 'ceimre'
}