line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Convert::Pheno::CDISC; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
46
|
use strict; |
|
6
|
|
|
|
|
16
|
|
|
6
|
|
|
|
|
217
|
|
4
|
6
|
|
|
6
|
|
37
|
use warnings; |
|
6
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
168
|
|
5
|
6
|
|
|
6
|
|
34
|
use autodie; |
|
6
|
|
|
|
|
18
|
|
|
6
|
|
|
|
|
41
|
|
6
|
6
|
|
|
6
|
|
33218
|
use feature qw(say); |
|
6
|
|
|
|
|
31
|
|
|
6
|
|
|
|
|
452
|
|
7
|
6
|
|
|
6
|
|
49
|
use Data::Dumper; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
412
|
|
8
|
6
|
|
|
6
|
|
3004
|
use Convert::Pheno::REDCap; |
|
6
|
|
|
|
|
22
|
|
|
6
|
|
|
|
|
312
|
|
9
|
6
|
|
|
6
|
|
53
|
use Convert::Pheno::Mapping; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
862
|
|
10
|
6
|
|
|
6
|
|
49
|
use Exporter 'import'; |
|
6
|
|
|
|
|
14
|
|
|
6
|
|
|
|
|
2761
|
|
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
|
188
|
my ( $self, $participant ) = @_; |
23
|
72
|
|
|
|
|
176
|
return do_redcap2bff( $self, $participant ); |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub cdisc2redcap { |
27
|
|
|
|
|
|
|
|
28
|
2
|
|
|
2
|
0
|
8
|
my $data = shift; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
# We take $subject information from the nested data structure |
31
|
2
|
|
|
|
|
10
|
my $subjects = $data->{ODM}{ClinicalData}{SubjectData}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Now we iterate over the array of subjects |
34
|
2
|
|
|
|
|
7
|
my $individuals = []; |
35
|
2
|
|
|
|
|
6
|
for my $subject ( @{$subjects} ) { |
|
2
|
|
|
|
|
11
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# The data in CDISC-ODM has the following hierarchy |
38
|
|
|
|
|
|
|
# StudyEventData->'-redcap:UniqueEventName'->FormData->ItemGroupData->ItemData |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# StudyEventData |
41
|
16
|
|
|
|
|
18
|
for my $StudyEventData ( @{ $subject->{'StudyEventData'} } ) { |
|
16
|
|
|
|
|
59
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# We'll store the new data on $individual |
44
|
|
|
|
|
|
|
my $individual = { |
45
|
|
|
|
|
|
|
study_id => $subject->{'-SubjectKey'}, |
46
|
|
|
|
|
|
|
redcap_event_name => |
47
|
72
|
|
|
|
|
361
|
$StudyEventData->{'-redcap:UniqueEventName'} |
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# FormData |
51
|
72
|
|
|
|
|
90
|
for my $FormData ( @{ $StudyEventData->{FormData} } ) { |
|
72
|
|
|
|
|
167
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# ItemGroupData |
54
|
438
|
|
|
|
|
533
|
for my $ItemGroupData ( @{ $FormData->{ItemGroupData} } ) { |
|
438
|
|
|
|
|
901
|
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# The elements can arrive as {} or [] |
57
|
|
|
|
|
|
|
# Both will be loaded as [] |
58
|
3324
|
100
|
|
|
|
6833
|
if ( ref $ItemGroupData->{ItemData} eq ref [] ) { |
59
|
1590
|
|
|
|
|
1542
|
for my $ItemData ( @{ $ItemGroupData->{ItemData} } ) { |
|
1590
|
|
|
|
|
2366
|
|
60
|
|
|
|
|
|
|
$individual->{ $ItemData->{'-ItemOID'} } = |
61
|
21698
|
|
|
|
|
36085
|
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
|
|
|
|
|
3153
|
$ItemGroupData->{ItemData}{'-Value'} ); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
72
|
|
|
|
|
125
|
push @{$individuals}, $individual; |
|
72
|
|
|
|
|
161
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
2
|
|
|
|
|
19
|
return $individuals; |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
1; |