lib/Convert/Pheno/CDISC/ODM/Record.pm

filter: Statementstmt 87.3% 207 / 237 Branchbran 70.7% 58 / 82 Conditioncond 63.2% 43 / 68 MC/DCmcdc 39.4% 15 / 38 Subroutinesub 90.0% 27 / 30 Podpod 0.0% 0 / 16 totaltotal 74.3% 350 / 471 CC 79 SCAR 23.1
CC
79
Cov
80%
new
22.4
views_for
20.7
has_choice_labels
12.0
CRAP 10.0
« lib/Convert/Pheno/CDISC/ODM/Metadata.pm ↑ Summary lib/Convert/Pheno/Execution/Files.pm »
1 package Convert::Pheno::CDISC::ODM::Record;
2  
3 136 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 136 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 136 ▶use JSON::PP;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 136 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 136 ▶use Convert::Pheno::Mapping::Shared qw(dotify_and_coerce_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 136 my $JSON = JSON::PP->new->canonical;
12  
13 221 ▶sub new {
Subroutine new: called CC=21 SCAR=31.1
Pod undocumented
14 221 my ( $class, $arg ) = @_;
15 221 ▶ $arg ||= {};
Condition50%1/2
$arg ||= {}
l!l
2210
MC/DC0%0/1
$arg ||= {}
$arg
Truth table50%1/2
A
A= $arg
Aresult
11
00
16  
17 my $self = bless {
18 221 ▶ context => { %{ $arg->{context} || {} } },
Condition50%1/2
$arg->{'context'} || {}
l!l
2210
MC/DC0%0/1
$arg->{'context'} || {}
$arg->{'context'}
Truth table50%1/2
A
A= $arg->{'context'}
Aresult
11
00
19 221 ▶ context_order => [ @{ $arg->{context_order} || [] } ],
Condition100%2/2
$arg->{'context_order'} || []
l!l
2192
MC/DC100%1/1
$arg->{'context_order'} || []
$arg->{'context_order'}
Truth table100%2/2
A
A= $arg->{'context_order'}
Aresult
11
00
20 221 ▶ descriptor => { %{ $arg->{descriptor} || {} } },
Condition100%4/4
$arg->{'descriptor'} || {}
l!l
2192
$arg->{'record_profile'} || 'cdisc-odm'
l!l
2201
MC/DC100%1/1
$arg->{'descriptor'} || {}
$arg->{'descriptor'}
MC/DC100%1/1
$arg->{'record_profile'} || 'cdisc-odm'
$arg->{'record_profile'}
Truth table100%2/2
A
A= $arg->{'descriptor'}
Aresult
11
00
Truth table100%2/2
A
A= $arg->{'record_profile'}
Aresult
11
00
21 entries => {},
22 field_order => [],
23 groups => [],
24 metadata => $arg->{metadata},
25 overrides => {},
26 221 recordProfile => $arg->{record_profile} || 'cdisc-odm',
27 sourceFormat => 'cdisc-odm',
28 }, $class;
29  
30 221 my ( %seen_field, %seen_group );
31 221 ▶ for my $group ( @{ $arg->{groups} || [] } ) {
Condition50%1/2
$arg->{'groups'} || []
l!l
2210
MC/DC0%0/1
$arg->{'groups'} || []
$arg->{'groups'}
Truth table50%1/2
A
A= $arg->{'groups'}
Aresult
11
00
32 9985 ▶ my $context = { %{ $group->{context} || {} } };
Condition50%1/2
$group->{'context'} || {}
l!l
99850
MC/DC0%0/1
$group->{'context'} || {}
$group->{'context'}
Truth table50%1/2
A
A= $group->{'context'}
Aresult
11
00
33 9985 my $identity = $JSON->encode($context);
34 die "Duplicate CDISC-ODM item-group occurrence "
35 . _format_context($context) . "\n"
36 9985 ▶ if $seen_group{$identity}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen_group{$identity}++ 0 9985 9985
37  
38 9985 my $group_index = @{ $self->{groups} };
39 9985 push @{ $self->{groups} }, {
40 context => $context,
41 itemOrder => [],
42 9985 ▶ scopePath => [ @{ $group->{scopePath} || [] } ],
Condition50%1/2
$group->{'scopePath'} || []
l!l
99850
MC/DC0%0/1
$group->{'scopePath'} || []
$group->{'scopePath'}
Truth table50%1/2
A
A= $group->{'scopePath'}
Aresult
11
00
43 };
44  
45 9985 my %seen_item;
46 9985 ▶ for my $item ( @{ $group->{items} || [] } ) {
Condition50%1/2
$group->{'items'} || []
l!l
99850
MC/DC0%0/1
$group->{'items'} || []
$group->{'items'}
Truth table50%1/2
A
A= $group->{'items'}
Aresult
11
00
47 70325 my $field = $item->{itemOID};
48 70325 ▶ die "CDISC-ODM ItemData is missing ItemOID "
Branch: 1 branch
BranchTrueFalseTotal
unless defined $field and length $field 0 70325 70325
Condition33%1/3
defined $field and length $field
!ll&&!rl&&r
0070325
MC/DC0%0/2
defined $field and length $field
defined $field length $field
Truth table33%1/3
A and B
A= defined $fieldB= length $field
ABresult
0X0
100
111
49 . _format_context($context) . "\n"
50 unless defined $field && length $field;
51 die "Duplicate CDISC-ODM ItemOID <$field> in item-group occurrence "
52 . _format_context($context) . "\n"
53 70325 ▶ if $seen_item{$field}++;
Branch: 1 branch
BranchTrueFalseTotal
if $seen_item{$field}++ 1 70324 70325
54 70324 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"recordProfile"} eq "cdisc-odm" and builtin::blessed($self->{"metadata"}) and $self->{"metadata"}->can("field_meta") and not defined $self->{"metadata"}->field_meta($field)) 1 70323 70324
Condition88%8/9
$self->{"recordProfile"} eq "cdisc-odm" and builtin::blessed($self->{"metadata"}) and $self->{"metadata"}->can("field_meta") and not defined $self->{"metadata"}->field_meta($field)
!ll&&!rl&&r
70297261
$self->{"recordProfile"} eq "cdisc-odm" and builtin::blessed($self->{"metadata"}) and $self->{"metadata"}->can("field_meta")
!ll&&!rl&&r
70297027
$self->{"recordProfile"} eq "cdisc-odm" and builtin::blessed($self->{"metadata"})
!ll&&!rl&&r
70296127
MC/DC75%3/4
$self->{"recordProfile"} eq "cdisc-odm" and builtin::blessed($self->{"metadata"}) and $self->{"metadata"}->can("field_meta") and not defined $self->{"metadata"}->field_meta($field)
$self->{"recordProfile"} eq "cdisc-odm" builtin::blessed($self->{"metadata"}) $self->{"metadata"}->can("field_meta") not defined $self->{"metadata"}->field_meta($field)
Truth table80%4/5
A and B and C and not(D)
A= $self->{"recordProfile"} eq "cdisc-odm"B= builtin::blessed($self->{"metadata"})C= $self->{"metadata"}->can("field_meta")D= not defined $self->{"metadata"}->field_meta($field)
ABCDresult
0XXX0
10XX0
110X0
11100
11111
55 $self->{recordProfile} eq 'cdisc-odm'
56 && blessed( $self->{metadata} )
57 && $self->{metadata}->can('field_meta')
58 && !defined $self->{metadata}->field_meta($field)
59 )
60 {
61 1 die "CDISC-ODM ItemData <ItemOID=$field> references no ItemDef in the active MetaDataVersion "
62 . _format_context($context) . "\n";
63 }
64  
65 70323 my $raw = _coerce_value( $self, $field, $item->{value} );
66 my $entry = {
67 groupIndex => $group_index,
68 raw => $raw,
69 sourceValue => $item->{value},
70 70323 working => $raw,
71 };
72 70323 push @{ $self->{entries}{$field} }, $entry;
73 70323 push @{ $self->{groups}[$group_index]{itemOrder} }, $field;
74 70323 ▶ push @{ $self->{field_order} }, $field unless $seen_field{$field}++;
Branch: 1 branch
BranchTrueFalseTotal
unless $seen_field{$field}++ 70309 14 70323
75 }
76 }
77  
78 219 return $self;
79 }
80  
81 0 ▶sub source_format { return 'cdisc-odm' }
Subroutine source_format: not called CC=1 SCAR=6.9
Pod undocumented
82 0 ▶sub record_profile { return _root( $_[0] )->{recordProfile} }
Subroutine record_profile: not called CC=1 SCAR=6.9
Pod undocumented
83  
84 221 ▶sub headers {
Subroutine headers: called CC=1 SCAR=0.0
Pod undocumented
85 221 my ($self) = @_;
86 221 my $root = _root($self);
87 221 my %seen;
88 return [
89 71220 grep { !$seen{$_}++ }
90 221 @{ $root->{context_order} },
91 221 sort( keys %{ $root->{context} } ),
92 221 @{ $root->{field_order} },
93 ];
94 }
95  
96 16099 ▶sub raw_value {
Subroutine raw_value: called CC=1 SCAR=0.0
Pod undocumented
97 16099 my ( $self, $field ) = @_;
98 16099 return _resolved_value( $self, $field, 'raw' );
99 }
100  
101 19802 ▶sub working_value {
Subroutine working_value: called CC=1 SCAR=0.0
Pod undocumented
102 19802 my ( $self, $field ) = @_;
103 19802 return _resolved_value( $self, $field, 'working' );
104 }
105  
106 46593 ▶sub value {
Subroutine value: called CC=1 SCAR=0.0
Pod undocumented
107 46593 my ( $self, $field ) = @_;
108 46593 my $value = _resolved_value( $self, $field, 'working' );
109 46591 return _mapped_value( _root($self), $field, $value );
110 }
111  
112 1998 ▶sub info_value {
Subroutine info_value: called CC=7 SCAR=19.7
Pod undocumented
113 1998 my ( $self, $field ) = @_;
114 1998 my $root = _root($self);
115 1998 ▶ return $self->value($field) if exists $self->{boundGroup};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"boundGroup"} 0 1998 1998
116 1998 my $entries = $root->{entries}{$field};
117 1998 ▶ return $self->value($field) unless $entries && @{$entries} > 1;
Branch: 1 branch
BranchTrueFalseTotal
unless $entries and @{$entries;} > 1 1995 3 1998
Condition100%3/3
$entries and @{$entries;} > 1
!ll&&!rl&&r
15904053
MC/DC100%2/2
$entries and @{$entries;} > 1
$entries @{$entries;} > 1
Truth table100%3/3
A and B
A= $entriesB= @{$entries;} > 1
ABresult
0X0
100
111
118  
119 my @values = map {
120 {
121 context => _public_group_context(
122 $root->{groups}[ $_->{groupIndex} ]{context}
123 ),
124 11 value => _mapped_value( $root, $field, $_->{working} ),
125 }
126 3 } @{$entries};
127  
128 3 my %distinct;
129 3 for my $item (@values) {
130 11 my $comparison = $item->{value};
131 11 ▶ my $key = defined $comparison ? "$comparison" : "\x00undef";
Branch: 1 branch
BranchTrueFalseTotal
defined $comparison ? : 11 0 11
132 11 $distinct{$key} = 1;
133 }
134 3 ▶ return $values[0]{value} if keys(%distinct) == 1;
Branch: 1 branch
BranchTrueFalseTotal
if keys %distinct == 1 3 0 3
135 0 return \@values;
136 }
137  
138 11260 ▶sub set_value {
Subroutine set_value: called CC=5 SCAR=24.7
Pod undocumented
139 11260 my ( $self, $field, $value ) = @_;
140 11260 my $root = _root($self);
141  
142 11260 ▶ if ( exists $self->{boundGroup} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"boundGroup"}) 0 11260 11260
143 0 my @exact = grep { $_->{groupIndex} == $self->{boundGroup} }
144 0 ▶ @{ $root->{entries}{$field} || [] };
Condition0%0/2
$root->{'entries'}{$field} || []
l!l
00
MC/DC0%0/1
$root->{'entries'}{$field} || []
$root->{'entries'}{$field}
Truth table0%0/2
A
A= $root->{'entries'}{$field}
Aresult
11
00
145 0 ▶ if (@exact) {
Branch: 1 branch
BranchTrueFalseTotal
if (@exact) 0 0 0
146 0 $_->{working} = $value for @exact;
147 0 return 1;
148 }
149 }
150  
151 11260 $root->{overrides}{$field} = $value;
152 11260 return 1;
153 }
154  
155 0 ▶sub has_choice_labels {
Subroutine has_choice_labels: not called CC=3 SCAR=24.8
Pod undocumented
156 0 my ( $self, $field ) = @_;
157 0 my $metadata = _root($self)->{metadata};
158 0 ▶ return 0 unless blessed($metadata) && $metadata->can('has_choice_labels');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($metadata) and $metadata->can("has_choice_labels") 0 0 0
Condition0%0/3
builtin::blessed($metadata) and $metadata->can("has_choice_labels")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($metadata) and $metadata->can("has_choice_labels")
builtin::blessed($metadata) $metadata->can("has_choice_labels")
Truth table0%0/3
A and B
A= builtin::blessed($metadata)B= $metadata->can("has_choice_labels")
ABresult
0X0
100
111
159 0 return $metadata->has_choice_labels($field);
160 }
161  
162 5918 ▶sub field_meta {
Subroutine field_meta: called CC=3 SCAR=12.0
Pod undocumented
163 5918 my ( $self, $field ) = @_;
164 5918 my $metadata = _root($self)->{metadata};
165 5918 ▶ return unless blessed($metadata) && $metadata->can('field_meta');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($metadata) and $metadata->can("field_meta") 0 5918 5918
Condition33%1/3
builtin::blessed($metadata) and $metadata->can("field_meta")
!ll&&!rl&&r
005918
MC/DC0%0/2
builtin::blessed($metadata) and $metadata->can("field_meta")
builtin::blessed($metadata) $metadata->can("field_meta")
Truth table33%1/3
A and B
A= builtin::blessed($metadata)B= $metadata->can("field_meta")
ABresult
0X0
100
111
166 5918 return $metadata->field_meta($field);
167 }
168  
169 2785 ▶sub field_note {
Subroutine field_note: called CC=3 SCAR=12.0
Pod undocumented
170 2785 my ( $self, $field ) = @_;
171 2785 my $metadata = _root($self)->{metadata};
172 2785 ▶ return unless blessed($metadata) && $metadata->can('field_note');
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($metadata) and $metadata->can("field_note") 0 2785 2785
Condition33%1/3
builtin::blessed($metadata) and $metadata->can("field_note")
!ll&&!rl&&r
002785
MC/DC0%0/2
builtin::blessed($metadata) and $metadata->can("field_note")
builtin::blessed($metadata) $metadata->can("field_note")
Truth table33%1/3
A and B
A= builtin::blessed($metadata)B= $metadata->can("field_note")
ABresult
0X0
100
111
173 2785 return $metadata->field_note($field);
174 }
175  
176 12065 ▶sub views_for {
Subroutine views_for: called CC=9 SCAR=30.3
Pod undocumented
177 12065 my ( $self, $field ) = @_;
178 12065 my $root = _root($self);
179 12065 ▶ my $entries = $root->{entries}{$field} || [];
Condition100%2/2
$root->{'entries'}{$field} || []
l!l
67455320
MC/DC100%1/1
$root->{'entries'}{$field} || []
$root->{'entries'}{$field}
Truth table100%2/2
A
A= $root->{'entries'}{$field}
Aresult
11
00
180 12065 ▶ return [$self] if exists $root->{overrides}{$field};
Branch: 1 branch
BranchTrueFalseTotal
if exists $root->{"overrides"}{$field} 3105 8960 12065
181  
182 8960 ▶ if ( exists $self->{boundGroup} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"boundGroup"}) 0 8960 8960
183 0 my $bound = $root->{groups}[ $self->{boundGroup} ];
184 0 my @exact = grep { $_->{groupIndex} == $self->{boundGroup} } @{$entries};
185 0 ▶ return [ map { _bound_view( $root, $_->{groupIndex} ) } @exact ] if @exact;
Branch: 1 branch
BranchTrueFalseTotal
if @exact 0 0 0
186  
187 my @descendants = grep {
188 _path_is_prefix(
189 $bound->{scopePath},
190 $root->{groups}[ $_->{groupIndex} ]{scopePath},
191 )
192 0 } @{$entries};
193 0 ▶ return [ map { _bound_view( $root, $_->{groupIndex} ) } @descendants ]
Branch: 1 branch
BranchTrueFalseTotal
if @descendants 0 0 0
194 if @descendants;
195  
196 0 ▶ return [$self] if defined $self->working_value($field);
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->working_value($field) 0 0 0
197 0 return [];
198 }
199  
200 6750 return [ map { _bound_view( $root, $_->{groupIndex} ) } @{$entries} ]
201 8960 ▶ if @{$entries};
Branch: 1 branch
BranchTrueFalseTotal
if @{$entries;} 6745 2215 8960
202 2215 ▶ return [$self] if exists $root->{context}{$field};
Branch: 1 branch
BranchTrueFalseTotal
if exists $root->{"context"}{$field} 0 2215 2215
203 2215 return [];
204 }
205  
206 182 ▶sub columns_snapshot {
Subroutine columns_snapshot: called CC=3 SCAR=11.0
Pod undocumented
207 182 my ($self) = @_;
208 182 my $root = _root($self);
209 182 my %snapshot = %{ $root->{context} };
210  
211 182 for my $field ( @{ $root->{field_order} } ) {
212 my ( $value, $ambiguous ) = _collapse_entries(
213 $root,
214 $field,
215 58588 $root->{entries}{$field},
216 'raw',
217 0,
218 );
219 58588 ▶ $snapshot{$field} = $value unless $ambiguous;
Branch: 1 branch
BranchTrueFalseTotal
unless $ambiguous 58584 4 58588
220 }
221 182 return \%snapshot;
222 }
223  
224 180 ▶sub has_repeated_fields {
Subroutine has_repeated_fields: called CC=1 SCAR=0.0
Pod undocumented
225 180 my ($self) = @_;
226 180 my $root = _root($self);
227 58580 return scalar grep { @{ $root->{entries}{$_} } > 1 }
228 180 keys %{ $root->{entries} };
229 }
230  
231 3 ▶sub odm_provenance {
Subroutine odm_provenance: called CC=6 SCAR=17.9
Pod undocumented
232 3 my ($self) = @_;
233 3 my $root = _root($self);
234 3 my @groups;
235  
236 3 for my $group_index ( 0 .. $#{ $root->{groups} } ) {
237 11 my $group = $root->{groups}[$group_index];
238 11 my @items;
239 11 for my $field ( @{ $group->{itemOrder} } ) {
240 26 ▶ for my $entry ( @{ $root->{entries}{$field} || [] } ) {
Condition50%1/2
$root->{'entries'}{$field} || []
l!l
260
MC/DC0%0/1
$root->{'entries'}{$field} || []
$root->{'entries'}{$field}
Truth table50%1/2
A
A= $root->{'entries'}{$field}
Aresult
11
00
241 68 ▶ next unless $entry->{groupIndex} == $group_index;
Branch: 1 branch
BranchTrueFalseTotal
unless $entry->{"groupIndex"} == $group_index 42 26 68
242 push @items, {
243 itemOID => $field,
244 value => $entry->{sourceValue},
245 26 };
246 }
247 }
248 push @groups, {
249 11 %{ _public_group_context( $group->{context} ) },
250 items => \@items,
251 };
252 }
253  
254 return {
255 3 %{ $root->{descriptor} },
256 3 %{ $root->{context} },
257 itemGroups => \@groups,
258 };
259 }
260  
261 82494 ▶sub _resolved_value {
Subroutine _resolved_value: called CC=9 SCAR=22.1
262 82494 my ( $self, $field, $kind ) = @_;
263 82494 my $root = _root($self);
264 82494 ▶ return $root->{overrides}{$field} if exists $root->{overrides}{$field};
Branch: 1 branch
BranchTrueFalseTotal
if exists $root->{"overrides"}{$field} 19825 62669 82494
265  
266 62669 ▶ my $entries = $root->{entries}{$field} || [];
Condition100%2/2
$root->{'entries'}{$field} || []
l!l
4068321986
MC/DC100%1/1
$root->{'entries'}{$field} || []
$root->{'entries'}{$field}
Truth table100%2/2
A
A= $root->{'entries'}{$field}
Aresult
11
00
267 62669 ▶ if ( exists $self->{boundGroup} && @{$entries} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $self->{"boundGroup"} and @{$entries;}) 34897 27772 62669
Condition100%3/3
exists $self->{"boundGroup"} and @{$entries;}
!ll&&!rl&&r
23382439034897
MC/DC100%2/2
exists $self->{"boundGroup"} and @{$entries;}
exists $self->{"boundGroup"} @{$entries;}
Truth table100%3/3
A and B
A= exists $self->{"boundGroup"}B= @{$entries;}
ABresult
0X0
100
111
268 34897 my @exact = grep { $_->{groupIndex} == $self->{boundGroup} } @{$entries};
269 34897 ▶ return $exact[0]{$kind} if @exact;
Branch: 1 branch
BranchTrueFalseTotal
if @exact 34857 40 34897
270  
271 40 my $bound_path = $root->{groups}[ $self->{boundGroup} ]{scopePath};
272 my @ancestors = sort {
273 0 @{ $root->{groups}[ $b->{groupIndex} ]{scopePath} }
274 0 <=> @{ $root->{groups}[ $a->{groupIndex} ]{scopePath} }
275 } grep {
276 _path_is_prefix(
277 $root->{groups}[ $_->{groupIndex} ]{scopePath},
278 40 $bound_path,
279 )
280 40 } @{$entries};
281 40 ▶ return $ancestors[0]{$kind} if @ancestors;
Branch: 1 branch
BranchTrueFalseTotal
if @ancestors 0 40 40
282 }
283  
284 27812 ▶ if ( @{$entries} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$entries;}) 5826 21986 27812
285 5826 my ($value) = _collapse_entries( $root, $field, $entries, $kind, 1 );
286 5824 return $value;
287 }
288 21986 ▶ return $root->{context}{$field} if exists $root->{context}{$field};
Branch: 1 branch
BranchTrueFalseTotal
if exists $root->{"context"}{$field} 8326 13660 21986
289 13660 return;
290 }
291  
292 64414 ▶sub _collapse_entries {
Subroutine _collapse_entries: called CC=6 SCAR=17.9
293 64414 my ( $root, $field, $entries, $kind, $fatal ) = @_;
294 64414 my %distinct;
295 64414 for my $entry ( @{$entries} ) {
296 # Compare through a copy. Stringifying the hash value directly changes
297 # Perl's scalar flags and makes JSON::XS serialize numbers as strings.
298 64438 my $comparison = $entry->{$kind};
299 64438 ▶ my $key = defined $comparison ? "$comparison" : "\x00undef";
Branch: 1 branch
BranchTrueFalseTotal
defined $comparison ? : 45973 18465 64438
300 64438 push @{ $distinct{$key} }, $entry;
301 }
302  
303 64414 ▶ return ( $entries->[0]{$kind}, 0 ) if keys(%distinct) <= 1;
Branch: 1 branch
BranchTrueFalseTotal
if keys %distinct <= 1 64408 6 64414
304 6 ▶ return ( undef, 1 ) unless $fatal;
Branch: 1 branch
BranchTrueFalseTotal
unless $fatal 4 2 6
305  
306 my @occurrences = map {
307 4 ▶ my $value = defined $_->{$kind} ? $_->{$kind} : 'null';
Branch: 1 branch
BranchTrueFalseTotal
defined $_->{$kind} ? : 4 0 4
308 $value . ' at '
309 . _format_context( $root->{groups}[ $_->{groupIndex} ]{context} )
310 2 } @{$entries};
311 2 die "Ambiguous CDISC-ODM scalar field <$field> has differing occurrence values: "
312 . join( '; ', @occurrences ) . "\n";
313 }
314  
315 46602 ▶sub _mapped_value {
Subroutine _mapped_value: called CC=6 SCAR=18.2
316 46602 my ( $root, $field, $value ) = @_;
317 46602 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 14110 32492 46602
318 32492 my $metadata = $root->{metadata};
319 32492 ▶ return $value
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($metadata) and $metadata->can("has_choice_labels") and $metadata->has_choice_labels($field) 25009 7483 32492
Condition50%3/6
builtin::blessed($metadata) and $metadata->can("has_choice_labels") and $metadata->has_choice_labels($field)
!ll&&!rl&&r
0250097483
builtin::blessed($metadata) and $metadata->can("has_choice_labels")
!ll&&!rl&&r
0032492
MC/DC33%1/3
builtin::blessed($metadata) and $metadata->can("has_choice_labels") and $metadata->has_choice_labels($field)
builtin::blessed($metadata) $metadata->can("has_choice_labels") $metadata->has_choice_labels($field)
Truth table50%2/4
A and B and C
A= builtin::blessed($metadata)B= $metadata->can("has_choice_labels")C= $metadata->has_choice_labels($field)
ABCresult
0XX0
10X0
1100
1111
320 unless blessed($metadata)
321 && $metadata->can('has_choice_labels')
322 && $metadata->has_choice_labels($field);
323  
324 7483 my $mapped = $metadata->choice_label( $field, $value );
325 7483 ▶ return defined $mapped ? dotify_and_coerce_number($mapped) : $value;
Branch: 1 branch
BranchTrueFalseTotal
defined $mapped ? : 2688 4795 7483
326 }
327  
328 70323 ▶sub _coerce_value {
Subroutine _coerce_value: called CC=4 SCAR=13.9
329 70323 my ( $self, $field, $value ) = @_;
330 return dotify_and_coerce_number($value)
331 70323 ▶ if $self->{recordProfile} eq 'redcap';
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"recordProfile"} eq "redcap" 70296 27 70323
332  
333 27 my $metadata = $self->{metadata};
334 27 ▶ return $metadata->coerce_value( $field, $value )
Branch: 1 branch
BranchTrueFalseTotal
if builtin::blessed($metadata) and $metadata->can("coerce_value") 26 1 27
Condition66%2/3
builtin::blessed($metadata) and $metadata->can("coerce_value")
!ll&&!rl&&r
1026
MC/DC50%1/2
builtin::blessed($metadata) and $metadata->can("coerce_value")
builtin::blessed($metadata) $metadata->can("coerce_value")
Truth table66%2/3
A and B
A= builtin::blessed($metadata)B= $metadata->can("coerce_value")
ABresult
0X0
100
111
335 if blessed($metadata) && $metadata->can('coerce_value');
336 1 return $value;
337 }
338  
339 6750 ▶sub _bound_view {
Subroutine _bound_view: called CC=1 SCAR=0.0
340 6750 my ( $root, $group_index ) = @_;
341 6750 return bless {
342 parent => $root,
343 boundGroup => $group_index,
344 }, __PACKAGE__;
345 }
346  
347 163697 ▶sub _root {
Subroutine _root: called CC=2 SCAR=7.1
348 163697 my ($self) = @_;
349 163697 ▶ return $self->{parent} || $self;
Condition66%2/3
$self->{'parent'} || $self
l!l&&r!l&&!r
611771025200
MC/DC0%0/2
$self->{'parent'} || $self
$self->{'parent'} $self
Truth table66%2/3
A || B
A= $self->{'parent'}B= $self
ABresult
1X1
011
000
350 }
351  
352 40 ▶sub _path_is_prefix {
Subroutine _path_is_prefix: called CC=4 SCAR=14.5
353 40 my ( $candidate, $path ) = @_;
354 40 ▶ return 0 if @{$candidate} > @{$path};
Branch: 1 branch
BranchTrueFalseTotal
if @{$candidate;} > @{$path;} 0 40 40
355 40 for my $index ( 0 .. $#{$candidate} ) {
356 40 ▶ return 0 if $candidate->[$index] ne $path->[$index];
Branch: 1 branch
BranchTrueFalseTotal
if $candidate->[$index] ne $path->[$index] 40 0 40
357 }
358 0 return 1;
359 }
360  
361 22 ▶sub _public_group_context {
Subroutine _public_group_context: called CC=1 SCAR=0.0
362 22 my ($context) = @_;
363 22 my %public = %{$context};
364 22 delete $public{scopePath};
365 22 return \%public;
366 }
367  
368 6 ▶sub _format_context {
Subroutine _format_context: called CC=3 SCAR=11.0
369 6 my ($context) = @_;
370 my @parts = map {
371 40 ▶ defined $context->{$_} && length "$context->{$_}"
Branch: 1 branch
BranchTrueFalseTotal
defined $context->{$_} && length "$context->{$_}" ? : 38 2 40
Condition66%2/3
defined $context->{$_} and length "$context->{$_}"
!ll&&!rl&&r
2038
MC/DC50%1/2
defined $context->{$_} and length "$context->{$_}"
defined $context->{$_} length "$context->{$_}"
Truth table66%2/3
A and B
A= defined $context->{$_}B= length "$context->{$_}"
ABresult
0X0
100
111
372 ? "$_=$context->{$_}"
373 : ()
374 6 } sort keys %{$context};
375 6 return '<' . join( ', ', @parts ) . '>';
376 }
377  
378 136 1;
« lib/Convert/Pheno/CDISC/ODM/Metadata.pm ↑ Summary lib/Convert/Pheno/Execution/Files.pm »