Skip to content

Commit

Permalink
Merge branch 'release/0.2.3' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
takirala committed Feb 15, 2017
2 parents 6f08598 + 593518e commit 158940c
Show file tree
Hide file tree
Showing 5 changed files with 188 additions and 153 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## [0.2.3] - 2017-02-14
### Changed
* Refactored c1s form - redcap C1 form to C1S in alz website

### Added
* Added few fields in the fvp form builder and forms file.


## [0.2.2] - 2017-02-02
### Changed
* Header key names for fvp forms.
Expand Down
2 changes: 1 addition & 1 deletion nacc/redcap2nacc.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,4 @@ def main():
print form

if __name__ == '__main__':
main()
main()
262 changes: 143 additions & 119 deletions nacc/uds3/fvp/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,127 +544,24 @@ def build_uds3_fvp_form(record):
packet.append(b9)


c1 = fvp_forms.FormC1()
c1.MMSECOMP = record['fu_mmsecomp']
c1.MMSEREAS = record['fu_mmsereas']
c1.MMSELOC = record['fu_mmseloc']
c1.MMSELAN = record['fu_mmselan']
c1.MMSELANX = record['fu_mmselanx']
c1.MMSEVIS = record['fu_mmsevis']
c1.MMSEHEAR = record['fu_mmsehear']
c1.MMSEORDA = record['fu_mmseorda']
c1.MMSEORLO = record['fu_mmseorlo']
c1.PENTAGON = record['fu_pentagon']
c1.MMSE = record['fu_mmse']
c1.NPSYCLOC = record['fu_npsycloc']
c1.NPSYLAN = record['fu_npsylan']
c1.NPSYLANX = record['fu_npsylanx']
c1.LOGIMO = record['fu_logimo']
c1.LOGIPREV = record['fu_logiprev']
c1.LOGIMEM = record['fu_logimem']
c1.UDSBENTC = record['fu_udsbentc']
c1.DIGIF = record['fu_digif']
c1.DIGIFLEN = record['fu_digiflen']
c1.DIGIB = record['fu_digib']
c1.DIGIBLEN = record['fu_digiblen']
c1.ANIMALS = record['fu_animals']
c1.VEG = record['fu_veg']
c1.TRAILA = record['fu_traila']
c1.TRAILARR = record['fu_trailarr']
c1.TRAILALI = record['fu_trailali']
c1.TRAILB = record['fu_trailb']
c1.TRAILBRR = record['fu_trailbrr']
c1.TRAILBLI = record['fu_trailbli']
c1.MEMUNITS = record['fu_memunits']
c1.MEMTIME = record['fu_memtime']
c1.UDSBENTD = record['fu_udsbentd']
c1.UDSBENRS = record['fu_udsbenrs']
c1.BOSTON = record['fu_boston']
c1.UDSVERFC = record['fu_udsverfc']
c1.UDSVERFN = record['fu_udsverfn']
c1.UDSVERNF = record['fu_udsvernf']
c1.UDSVERLC = record['fu_udsverlc']
c1.UDSVERLR = record['fu_udsverlr']
c1.UDSVERLN = record['fu_udsverln']
c1.UDSVERTN = record['fu_udsvertn']
c1.UDSVERTE = record['fu_udsverte']
c1.UDSVERTI = record['fu_udsverti']
c1.COGSTAT = record['fu_cogstat']
packet.append(c1)
# Among C1 and C2 forms, one must be filled, one must be empty.
isC1NotBlank = '0' + (record['fu_mmseloc'] and record['fu_mmseloc'].strip()) \
or (record['fu_cogstat'] and record['fu_cogstat'].strip())
isC2NotBlank = '0' + (record['fu_mocacomp'] and record['fu_mocacomp'].strip()) \
or (record['fu_cogstat_c2'] and record['fu_cogstat_c2'].strip())

condition = int(isC1NotBlank) + int(isC2NotBlank)

c2 = fvp_forms.FormC2()
c2.MOCACOMP = record['fu_mocacomp']
c2.MOCAREAS = record['fu_mocareas']
c2.MOCALOC = record['fu_mocaloc']
c2.MOCALAN = record['fu_mocalan']
c2.MOCALANX = record['fu_mocalanx']
c2.MOCAVIS = record['fu_mocavis']
c2.MOCAHEAR = record['fu_mocahear']
c2.MOCATOTS = record['fu_mocatots']
c2.MOCATRAI = record['fu_mocatrai']
c2.MOCACUBE = record['fu_mocacube']
c2.MOCACLOC = record['fu_mocacloc']
c2.MOCACLON = record['fu_mocaclon']
c2.MOCACLOH = record['fu_mocacloh']
c2.MOCANAMI = record['fu_mocanami']
c2.MOCAREGI = record['fu_mocaregi']
c2.MOCADIGI = record['fu_mocadigi']
c2.MOCALETT = record['fu_mocalett']
c2.MOCASER7 = record['fu_mocaser7']
c2.MOCAREPE = record['fu_mocarepe']
c2.MOCAFLUE = record['fu_mocaflue']
c2.MOCAABST = record['fu_mocaabst']
c2.MOCARECN = record['fu_mocarecn']
c2.MOCARECC = record['fu_mocarecc']
c2.MOCARECR = record['fu_mocarecr']
c2.MOCAORDT = record['fu_mocaordt']
c2.MOCAORMO = record['fu_mocaormo']
c2.MOCAORYR = record['fu_mocaoryr']
c2.MOCAORDY = record['fu_mocaordy']
c2.MOCAORPL = record['fu_mocaorpl']
c2.MOCAORCT = record['fu_mocaorct']
c2.NPSYCLOC = record['fu_npsycloc']
c2.NPSYLAN = record['fu_npsylan']
c2.NPSYLANX = record['fu_npsylanx']
c2.CRAFTVRS = record['fu_craftvrs']
c2.CRAFTURS = record['fu_crafturs']
c2.UDSBENTC = record['fu_udsbentc']
c2.DIGFORCT = record['fu_digforct']
c2.DIGFORSL = record['fu_digforsl']
c2.DIGBACCT = record['fu_digbacct']
c2.DIGBACLS = record['fu_digbacls']
c2.ANIMALS = record['fu_animals']
c2.VEG = record['fu_veg']
c2.TRAILA = record['fu_traila']
c2.TRAILARR = record['fu_trailarr']
c2.TRAILALI = record['fu_trailali']
c2.TRAILB = record['fu_trailb']
c2.TRAILBRR = record['fu_trailbrr']
c2.TRAILBLI = record['fu_trailbli']
c2.CRAFTDVR = record['fu_craftdvr']
c2.CRAFTDRE = record['fu_craftdre']
c2.CRAFTDTI = record['fu_craftdti']
c2.CRAFTCUE = record['fu_craftcue']
c2.UDSBENTD = record['fu_udsbentd']
c2.UDSBENRS = record['fu_udsbenrs']
c2.MINTTOTS = record['fu_minttots']
c2.MINTTOTW = record['fu_minttotw']
c2.MINTSCNG = record['fu_mintscng']
c2.MINTSCNC = record['fu_mintscnc']
c2.MINTPCNG = record['fu_mintpcng']
c2.MINTPCNC = record['fu_mintpcnc']
c2.UDSVERFC = record['fu_udsverfc']
c2.UDSVERFN = record['fu_udsverfn']
c2.UDSVERNF = record['fu_udsvernf']
c2.UDSVERLC = record['fu_udsverlc']
c2.UDSVERLR = record['fu_udsverlr']
c2.UDSVERLN = record['fu_udsverln']
c2.UDSVERTN = record['fu_udsvertn']
c2.UDSVERTE = record['fu_udsverte']
c2.UDSVERTI = record['fu_udsverti']
c2.COGSTAT = record['fu_cogstat']
packet.append(c2)
if(condition != 1):
ptid = record['ptid']
message = "Could not parse packet as " + ("both" if condition > 1 else "neither") + " c1/c2 forms has data";
message = message + " for PTID : " + ("unknown" if not ptid else ptid)
raise Exception(message)

if(isC1NotBlank):
add_redcap_C1_alz_C1S(record, packet)
else:
addC2(record, packet)


d1 = fvp_forms.FormD1()
Expand Down Expand Up @@ -831,6 +728,8 @@ def build_uds3_fvp_form(record):
d2.ANGIOPCI = record['fu_angiopci']
d2.PACEMAKE = record['fu_pacemake']
d2.HVALVE = record['fu_hvalve']
d2.ANTIENC = record['fu_antienc']
d2.ANTIENCX = record['fu_antiencx']
d2.OTHCOND = record['fu_othcond']
d2.OTHCONDX = record['fu_othcondx']
packet.append(d2)
Expand Down Expand Up @@ -863,6 +762,131 @@ def build_uds3_fvp_form(record):
update_header(record, packet)
return packet

def add_redcap_C1_alz_C1S(record, packet):
c1 = fvp_forms.FormC1S()
c1.MMSECOMP = record['fu_mmsecomp']
c1.MMSEREAS = record['fu_mmsereas']
c1.MMSELOC = record['fu_mmseloc']
c1.MMSELAN = record['fu_mmselan']
c1.MMSELANX = record['fu_mmselanx']
c1.MMSEVIS = record['fu_mmsevis']
c1.MMSEHEAR = record['fu_mmsehear']
c1.MMSEORDA = record['fu_mmseorda']
c1.MMSEORLO = record['fu_mmseorlo']
c1.PENTAGON = record['fu_pentagon']
c1.MMSE = record['fu_mmse']
c1.NPSYCLOC = record['fu_npsycloc']
c1.NPSYLAN = record['fu_npsylan']
c1.NPSYLANX = record['fu_npsylanx']
c1.LOGIMO = record['fu_logimo']
c1.LOGIDAY = record['fu_logiday'] #TODO
c1.LOGIYR = record['fu_logiyr'] #TODO
c1.LOGIPREV = record['fu_logiprev']
c1.LOGIMEM = record['fu_logimem']
c1.UDSBENTC = record['fu_udsbentc_c1'] #TODO
c1.DIGIF = record['fu_digif']
c1.DIGIFLEN = record['fu_digiflen']
c1.DIGIB = record['fu_digib']
c1.DIGIBLEN = record['fu_digiblen']
c1.ANIMALS = record['fu_animals']
c1.VEG = record['fu_veg']
c1.TRAILA = record['fu_traila']
c1.TRAILARR = record['fu_trailarr']
c1.TRAILALI = record['fu_trailali']
c1.TRAILB = record['fu_trailb']
c1.TRAILBRR = record['fu_trailbrr']
c1.TRAILBLI = record['fu_trailbli']
c1.MEMUNITS = record['fu_memunits']
c1.MEMTIME = record['fu_memtime']
c1.UDSBENTD = record['fu_udsbentd_c1'] #TODO
c1.UDSBENRS = record['fu_udsbenrs_c1'] #TODO
c1.BOSTON = record['fu_boston']
c1.UDSVERFC = record['fu_udsverfc_c1'] #TODO
c1.UDSVERFN = record['fu_udsverfn_c1'] #TODO
c1.UDSVERNF = record['fu_udsvernf_c1'] #TODO
c1.UDSVERLC = record['fu_udsverlc_c1'] #TODO
c1.UDSVERLR = record['fu_udsverlr_c1'] #TODO
c1.UDSVERLN = record['fu_udsverln_c1'] #TODO
c1.UDSVERTN = record['fu_udsvertn_c1'] #TODO
c1.UDSVERTE = record['fu_udsverte_c1'] #TODO
c1.UDSVERTI = record['fu_udsverti_c1'] #TODO
c1.COGSTAT = record['fu_cogstat']
packet.append(c1)

def addC2(record, packet):
c2 = fvp_forms.FormC2()
c2.MOCACOMP = record['fu_mocacomp']
c2.MOCAREAS = record['fu_mocareas']
c2.MOCALOC = record['fu_mocaloc']
c2.MOCALAN = record['fu_mocalan']
c2.MOCALANX = record['fu_mocalanx']
c2.MOCAVIS = record['fu_mocavis']
c2.MOCAHEAR = record['fu_mocahear']
c2.MOCATOTS = record['fu_mocatots']
c2.MOCATRAI = record['fu_mocatrai']
c2.MOCACUBE = record['fu_mocacube']
c2.MOCACLOC = record['fu_mocacloc']
c2.MOCACLON = record['fu_mocaclon']
c2.MOCACLOH = record['fu_mocacloh']
c2.MOCANAMI = record['fu_mocanami']
c2.MOCAREGI = record['fu_mocaregi']
c2.MOCADIGI = record['fu_mocadigi']
c2.MOCALETT = record['fu_mocalett']
c2.MOCASER7 = record['fu_mocaser7']
c2.MOCAREPE = record['fu_mocarepe']
c2.MOCAFLUE = record['fu_mocaflue']
c2.MOCAABST = record['fu_mocaabst']
c2.MOCARECN = record['fu_mocarecn']
c2.MOCARECC = record['fu_mocarecc']
c2.MOCARECR = record['fu_mocarecr']
c2.MOCAORDT = record['fu_mocaordt']
c2.MOCAORMO = record['fu_mocaormo']
c2.MOCAORYR = record['fu_mocaoryr']
c2.MOCAORDY = record['fu_mocaordy']
c2.MOCAORPL = record['fu_mocaorpl']
c2.MOCAORCT = record['fu_mocaorct']
c2.NPSYCLOC = record['fu_npsycloc_c2'] #TODO
c2.NPSYLAN = record['fu_npsylan_c2'] #TODO
c2.NPSYLANX = record['fu_npsylanx_c2'] #TODO
c2.CRAFTVRS = record['fu_craftvrs']
c2.CRAFTURS = record['fu_crafturs']
c2.UDSBENTC = record['fu_udsbentc']
c2.DIGFORCT = record['fu_digforct']
c2.DIGFORSL = record['fu_digforsl']
c2.DIGBACCT = record['fu_digbacct']
c2.DIGBACLS = record['fu_digbacls']
c2.ANIMALS = record['fu_animals_c2'] #TODO
c2.VEG = record['fu_veg_c2'] #TODO
c2.TRAILA = record['fu_traila_c2'] #TODO
c2.TRAILARR = record['fu_trailarr_c2'] #TODO
c2.TRAILALI = record['fu_trailali_c2'] #TODO
c2.TRAILB = record['fu_trailb_c2'] #TODO
c2.TRAILBRR = record['fu_trailbrr_c2'] #TODO
c2.TRAILBLI = record['fu_trailbli_c2'] #TODO
c2.CRAFTDVR = record['fu_craftdvr']
c2.CRAFTDRE = record['fu_craftdre']
c2.CRAFTDTI = record['fu_craftdti']
c2.CRAFTCUE = record['fu_craftcue']
c2.UDSBENTD = record['fu_udsbentd']
c2.UDSBENRS = record['fu_udsbenrs']
c2.MINTTOTS = record['fu_minttots']
c2.MINTTOTW = record['fu_minttotw']
c2.MINTSCNG = record['fu_mintscng']
c2.MINTSCNC = record['fu_mintscnc']
c2.MINTPCNG = record['fu_mintpcng']
c2.MINTPCNC = record['fu_mintpcnc']
c2.UDSVERFC = record['fu_udsverfc']
c2.UDSVERFN = record['fu_udsverfn']
c2.UDSVERNF = record['fu_udsvernf']
c2.UDSVERLC = record['fu_udsverlc']
c2.UDSVERLR = record['fu_udsverlr']
c2.UDSVERLN = record['fu_udsverln']
c2.UDSVERTN = record['fu_udsvertn']
c2.UDSVERTE = record['fu_udsverte']
c2.UDSVERTI = record['fu_udsverti']
c2.COGSTAT = record['fu_cogstat_c2'] #TODO
packet.append(c2)

def update_header(record, packet):
for header in packet:
header.PACKET = "F"
Expand Down
Loading

0 comments on commit 158940c

Please sign in to comment.