1
1
#!/usr/bin/env python
2
2
3
3
###############################################################################
4
- # Copyright 2015-2020 University of Florida. All rights reserved.
4
+ # Copyright 2015-2021 University of Florida. All rights reserved.
5
5
# This file is part of UF CTS-IT's NACCulator project.
6
6
# Use of this source code is governed by the license found in the LICENSE file.
7
7
###############################################################################
21
21
from nacc .uds3 .np import builder as np_builder
22
22
from nacc .uds3 .fvp import builder as fvp_builder
23
23
from nacc .uds3 .tfp import builder as tfp_builder
24
+ from nacc .uds3 .tfp .v3_2 import builder as tfp_new_builder
24
25
from nacc .uds3 .m import builder as m_builder
25
26
from nacc .lbd .ivp import builder as lbd_ivp_builder
26
27
from nacc .lbd .fvp import builder as lbd_fvp_builder
@@ -216,7 +217,26 @@ def check_redcap_event(options, record) -> bool:
216
217
elif options .np :
217
218
event_name = 'neuropath'
218
219
elif options .tfp :
219
- event_name = 'telephone'
220
+ event_name = 'follow'
221
+ try :
222
+ followup_match = record ['tvp_z1x_checklist_complete' ]
223
+ if followup_match in ['' , '0' ]:
224
+ return False
225
+ except KeyError :
226
+ try :
227
+ followup_match = record ['tfp_z1x_complete' ]
228
+ if followup_match in ['' , '0' ]:
229
+ return False
230
+ except KeyError :
231
+ try :
232
+ followup_match = record ['tele_z1x_complete' ]
233
+ if followup_match in ['' , '0' ]:
234
+ return False
235
+ except KeyError :
236
+ print ("Could not find a REDCap field for TFP Z1X form." )
237
+ return False
238
+ elif options .tfp3 :
239
+ event_name = 'tele'
220
240
elif options .m :
221
241
event_name = 'milestone'
222
242
@@ -284,44 +304,66 @@ def set_to_zero_if_blank(*field_names):
284
304
field .value = 0
285
305
286
306
# B8 2.
287
- if packet ['PARKSIGN' ] == 1 :
288
- set_to_zero_if_blank (
289
- 'RESTTRL' , 'RESTTRR' , 'SLOWINGL' , 'SLOWINGR' , 'RIGIDL' , 'RIGIDR' ,
290
- 'BRADY' , 'PARKGAIT' , 'POSTINST' )
307
+ try :
308
+ if packet ['PARKSIGN' ] == 1 :
309
+ set_to_zero_if_blank (
310
+ 'RESTTRL' , 'RESTTRR' , 'SLOWINGL' , 'SLOWINGR' , 'RIGIDL' , 'RIGIDR' ,
311
+ 'BRADY' , 'PARKGAIT' , 'POSTINST' )
312
+ except KeyError :
313
+ pass
291
314
292
315
# B8 3.
293
- if packet ['CVDSIGNS' ] == 1 :
294
- set_to_zero_if_blank ('CORTDEF' , 'SIVDFIND' , 'CVDMOTL' , 'CVDMOTR' ,
295
- 'CORTVISL' , 'CORTVISR' , 'SOMATL' , 'SOMATR' )
316
+ try :
317
+ if packet ['CVDSIGNS' ] == 1 :
318
+ set_to_zero_if_blank ('CORTDEF' , 'SIVDFIND' , 'CVDMOTL' , 'CVDMOTR' ,
319
+ 'CORTVISL' , 'CORTVISR' , 'SOMATL' , 'SOMATR' )
320
+ except KeyError :
321
+ pass
296
322
297
323
# B8 5.
298
- if packet ['PSPCBS' ] == 1 :
299
- set_to_zero_if_blank (
300
- 'PSPCBS' , 'EYEPSP' , 'DYSPSP' , 'AXIALPSP' , 'GAITPSP' , 'APRAXSP' ,
301
- 'APRAXL' , 'APRAXR' , 'CORTSENL' , 'CORTSENR' , 'ATAXL' , 'ATAXR' ,
302
- 'ALIENLML' , 'ALIENLMR' , 'DYSTONL' , 'DYSTONR' , 'MYOCLLT' , 'MYOCLRT' )
324
+ try :
325
+ if packet ['PSPCBS' ] == 1 :
326
+ set_to_zero_if_blank (
327
+ 'PSPCBS' , 'EYEPSP' , 'DYSPSP' , 'AXIALPSP' , 'GAITPSP' , 'APRAXSP' ,
328
+ 'APRAXL' , 'APRAXR' , 'CORTSENL' , 'CORTSENR' , 'ATAXL' , 'ATAXR' ,
329
+ 'ALIENLML' , 'ALIENLMR' , 'DYSTONL' , 'DYSTONR' , 'MYOCLLT' ,
330
+ 'MYOCLRT' )
331
+ except KeyError :
332
+ pass
303
333
304
334
# D1 4.
305
- if packet ['DEMENTED' ] == 1 :
306
- set_to_zero_if_blank (
307
- 'AMNDEM' , 'PCA' , 'PPASYN' , 'FTDSYN' , 'LBDSYN' , 'NAMNDEM' )
335
+ try :
336
+ if packet ['DEMENTED' ] == 1 :
337
+ set_to_zero_if_blank (
338
+ 'AMNDEM' , 'PCA' , 'PPASYN' , 'FTDSYN' , 'LBDSYN' , 'NAMNDEM' )
339
+ except KeyError :
340
+ pass
308
341
309
342
# D1 5.
310
- if packet ['DEMENTED' ] == 0 :
311
- set_to_zero_if_blank (
312
- 'MCIAMEM' , 'MCIAPLUS' , 'MCINON1' , 'MCINON2' , 'IMPNOMCI' )
343
+ try :
344
+ if packet ['DEMENTED' ] == 0 :
345
+ set_to_zero_if_blank (
346
+ 'MCIAMEM' , 'MCIAPLUS' , 'MCINON1' , 'MCINON2' , 'IMPNOMCI' )
347
+ except KeyError :
348
+ pass
313
349
314
350
# D1 11-39.
315
- set_to_zero_if_blank (
316
- 'ALZDIS' , 'LBDIS' , 'MSA' , 'PSP' , 'CORT' , 'FTLDMO' , 'FTLDNOS' , 'CVD' ,
317
- 'ESSTREM' , 'DOWNS' , 'HUNT' , 'PRION' , 'BRNINJ' , 'HYCEPH' , 'EPILEP' ,
318
- 'NEOP' , 'HIV' , 'OTHCOG' , 'DEP' , 'BIPOLDX' , 'SCHIZOP' , 'ANXIET' ,
319
- 'DELIR' , 'PTSDDX' , 'OTHPSY' , 'ALCDEM' , 'IMPSUB' , 'DYSILL' , 'MEDS' ,
320
- 'COGOTH' , 'COGOTH2' , 'COGOTH3' )
351
+ try :
352
+ set_to_zero_if_blank (
353
+ 'ALZDIS' , 'LBDIS' , 'MSA' , 'PSP' , 'CORT' , 'FTLDMO' , 'FTLDNOS' , 'CVD' ,
354
+ 'ESSTREM' , 'DOWNS' , 'HUNT' , 'PRION' , 'BRNINJ' , 'HYCEPH' , 'EPILEP' ,
355
+ 'NEOP' , 'HIV' , 'OTHCOG' , 'DEP' , 'BIPOLDX' , 'SCHIZOP' , 'ANXIET' ,
356
+ 'DELIR' , 'PTSDDX' , 'OTHPSY' , 'ALCDEM' , 'IMPSUB' , 'DYSILL' , 'MEDS' ,
357
+ 'COGOTH' , 'COGOTH2' , 'COGOTH3' )
358
+ except KeyError :
359
+ pass
321
360
322
361
# D2 11.
323
- if packet ['ARTH' ] == 1 :
324
- set_to_zero_if_blank ('ARTUPEX' , 'ARTLOEX' , 'ARTSPIN' , 'ARTUNKN' )
362
+ try :
363
+ if packet ['ARTH' ] == 1 :
364
+ set_to_zero_if_blank ('ARTUPEX' , 'ARTLOEX' , 'ARTSPIN' , 'ARTUNKN' )
365
+ except KeyError :
366
+ pass
325
367
326
368
327
369
def convert (fp , options , out = sys .stdout , err = sys .stderr ):
@@ -358,6 +400,8 @@ def convert(fp, options, out=sys.stdout, err=sys.stderr):
358
400
elif options .fvp :
359
401
packet = fvp_builder .build_uds3_fvp_form (record )
360
402
elif options .tfp :
403
+ packet = tfp_new_builder .build_uds3_tfp_new_form (record )
404
+ elif options .tfp3 :
361
405
packet = tfp_builder .build_uds3_tfp_form (record )
362
406
elif options .m :
363
407
packet = m_builder .build_uds3_m_form (record )
@@ -369,12 +413,11 @@ def convert(fp, options, out=sys.stdout, err=sys.stderr):
369
413
traceback .print_exc ()
370
414
continue
371
415
372
- if not options .np and not options .m and not options .tfp and not \
373
- options .lbd and not options .lbdsv and not options .ftld and not \
374
- options .csf :
416
+ if not (options .np or options .m or options .lbd or options .lbdsv or
417
+ options .ftld or options .csf ):
375
418
set_blanks_to_zero (packet )
376
419
377
- if options .m :
420
+ if options .m or options . tfp :
378
421
blanks_uds3 .set_zeros_to_blanks (packet )
379
422
380
423
warnings = []
@@ -439,7 +482,10 @@ def parse_args(args=None):
439
482
help = 'Set this flag to process as ivp data' )
440
483
option_group .add_argument (
441
484
'-tfp' , action = 'store_true' , dest = 'tfp' ,
442
- help = 'Set this flag to process as tfp data' )
485
+ help = 'Set this flag to process as tfp version 3.2 data' )
486
+ option_group .add_argument (
487
+ '-tfp3' , action = 'store_true' , dest = 'tfp3' ,
488
+ help = 'Set this flag to process as tfp version 3.0 (pre-June 2020) data' )
443
489
option_group .add_argument (
444
490
'-np' , action = 'store_true' , dest = 'np' ,
445
491
help = 'Set this flag to process as np data' )
@@ -483,8 +529,8 @@ def parse_args(args=None):
483
529
options = parser .parse_args (args )
484
530
# Defaults to processing of ivp.
485
531
# TODO this can be changed in future to process fvp by default.
486
- if not (options .ivp or options .fvp or options .tfp or options .np or
487
- options .m or options .csf or options .filter ):
532
+ if not (options .ivp or options .fvp or options .tfp or options .tfp3 or
533
+ options .np or options . m or options .csf or options .filter ):
488
534
options .ivp = True
489
535
490
536
return options
0 commit comments