line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Convert::Pheno::CDISC; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
44
|
use strict; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
192
|
|
4
|
6
|
|
|
6
|
|
33
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
141
|
|
5
|
6
|
|
|
6
|
|
33
|
use autodie; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
40
|
|
6
|
6
|
|
|
6
|
|
32984
|
use feature qw(say); |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
492
|
|
7
|
6
|
|
|
6
|
|
45
|
use Data::Dumper; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
401
|
|
8
|
6
|
|
|
6
|
|
3024
|
use Convert::Pheno::REDCap; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
367
|
|
9
|
6
|
|
|
6
|
|
47
|
use Convert::Pheno::Mapping; |
|
6
|
|
|
|
|
12
|
|
|
6
|
|
|
|
|
817
|
|
10
|
6
|
|
|
6
|
|
43
|
use Exporter 'import'; |
|
6
|
|
|
|
|
19
|
|
|
6
|
|
|
|
|
2656
|
|
11
|
|
|
|
|
|
|
our @EXPORT = qw(do_cdisc2bff cdisc2redcap); |
12
|
|
|
|
|
|
|
$Data::Dumper::Sortkeys = 1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
############### |
15
|
|
|
|
|
|
|
############### |
16
|
|
|
|
|
|
|
# CDISC2BFF # |
17
|
|
|
|
|
|
|
############### |
18
|
|
|
|
|
|
|
############### |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub do_cdisc2bff { |
21
|
|
|
|
|
|
|
|
22
|
72
|
|
|
72
|
0
|
151
|
my ( $self, $participant ) = @_; |
23
|
72
|
|
|
|
|
166
|
return do_redcap2bff( $self, $participant ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub cdisc2redcap { |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
0
|
7
|
my $data = shift; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# We take $subject information from the nested data structure |
31
|
2
|
|
|
|
|
9
|
my $subjects = $data->{ODM}{ClinicalData}{SubjectData}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Now we iterate over the array of subjects |
34
|
2
|
|
|
|
|
6
|
my $individuals = []; |
35
|
2
|
|
|
|
|
4
|
for my $subject ( @{$subjects} ) { |
|
2
|
|
|
|
|
8
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# The data in CDISC-ODM has the following hierarchy |
38
|
|
|
|
|
|
|
# StudyEventData->'-redcap:UniqueEventName'->FormData->ItemGroupData->ItemData |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# StudyEventData |
41
|
16
|
|
|
|
|
25
|
for my $StudyEventData ( @{ $subject->{'StudyEventData'} } ) { |
|
16
|
|
|
|
|
28
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# We'll store the new data on $individual |
44
|
|
|
|
|
|
|
my $individual = { |
45
|
|
|
|
|
|
|
study_id => $subject->{'-SubjectKey'}, |
46
|
|
|
|
|
|
|
redcap_event_name => |
47
|
72
|
|
|
|
|
259
|
$StudyEventData->{'-redcap:UniqueEventName'} |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# FormData |
51
|
72
|
|
|
|
|
84
|
for my $FormData ( @{ $StudyEventData->{FormData} } ) { |
|
72
|
|
|
|
|
139
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# ItemGroupData |
54
|
438
|
|
|
|
|
482
|
for my $ItemGroupData ( @{ $FormData->{ItemGroupData} } ) { |
|
438
|
|
|
|
|
689
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# The elements can arrive as {} or [] |
57
|
|
|
|
|
|
|
# Both will be loaded as [] |
58
|
3324
|
100
|
|
|
|
6172
|
if ( ref $ItemGroupData->{ItemData} eq ref [] ) { |
59
|
1590
|
|
|
|
|
1485
|
for my $ItemData ( @{ $ItemGroupData->{ItemData} } ) { |
|
1590
|
|
|
|
|
2112
|
|
60
|
|
|
|
|
|
|
$individual->{ $ItemData->{'-ItemOID'} } = |
61
|
21698
|
|
|
|
|
32241
|
dotify_and_coerce_number( $ItemData->{'-Value'} ); |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
else { |
65
|
|
|
|
|
|
|
# Converting from hash to 1-subject array |
66
|
|
|
|
|
|
|
$individual->{ $ItemGroupData->{ItemData}{'-ItemOID'} } |
67
|
|
|
|
|
|
|
= dotify_and_coerce_number( |
68
|
1734
|
|
|
|
|
3737
|
$ItemGroupData->{ItemData}{'-Value'} ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
72
|
|
|
|
|
108
|
push @{$individuals}, $individual; |
|
72
|
|
|
|
|
144
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
2
|
|
|
|
|
15
|
return $individuals; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
1; |