lib/Convert/Pheno/Source/CDISC/DatasetXML.pm

filter: Statementstmt 100% 170 / 170 Branchbran 60.2% 47 / 78 Conditioncond 46.3% 38 / 82 MC/DCmcdc 12.2% 6 / 49 Subroutinesub 100% 22 / 22 Podpod 0.0% 0 / 3 totaltotal 70.0% 283 / 404 CC 73 SCAR 33.6
CC
73
Cov
77%
_dataset_document
60.7
load
21.7
prepare
12.7
CRAP 28.9
« lib/Convert/Pheno/HTTP/Jobs.pm ↑ Summary lib/Convert/Pheno/FHIR/ToBFF.pm »
1 package Convert::Pheno::Source::CDISC::DatasetXML;
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 Path::Tiny qw(path);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 136 ▶use Scalar::Util qw(looks_like_number);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 136 ▶use Storable qw(dclone);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 136 ▶use XML::Fast qw(xml2hash);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 136 ▶use Convert::Pheno::CDISC::DefineXML qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
13 load_define_catalog
14 resolve_define_group
15 136 );
16 136 ▶use Convert::Pheno::CDISC::ODM::Detector qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
17 attribute_by_namespace
18 detect_odm_document
19 136 );
20 136 ▶use Convert::Pheno::CDISC::ODM::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
21 attr
22 children
23 136 );
24 136 ▶use Convert::Pheno::CDISC::SDTM::Normalizer qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
25 derive_sdtm_entity_overrides
26 normalize_sdtm_datasets
27 136 );
28 136 ▶use Convert::Pheno::CDISC::SDTM::Terminology qw(prepare_sdtm_terminology);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 136 ▶use Convert::Pheno::Mapping::Shared qw(get_info);
Subroutine BEGIN: called CC=1 SCAR=0.0
30 136 ▶use Convert::Pheno::Source::Result;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 136 my $DATASET_XML_NAMESPACE = 'http://www.cdisc.org/ns/Dataset-XML/v1.0';
33  
34 15 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
35 15 my ( $class, $converter ) = @_;
36 15 return bless { converter => $converter }, $class;
37 }
38  
39 15 ▶sub load {
Subroutine load: called CC=17 SCAR=30.8
Pod undocumented
40 15 my ($self) = @_;
41 15 my $converter = $self->{converter};
42 15 my ( $define_input, @dataset_documents, @labels );
43  
44 15 ▶ if ( exists $converter->{data} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $converter->{'data'}) { } 5 10 15
45 5 my $input = $converter->{data};
46 die "In-memory Dataset-XML input must contain <define> and <datasets>\n"
47 unless ref($input) eq 'HASH'
48 && exists $input->{define}
49 5 ▶ && ref( $input->{datasets} ) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $input eq "HASH" and exists $input->{"define"} and ref $input->{"datasets"} eq "ARRAY" 0 5 5
Condition33%2/6
ref $input eq "HASH" and exists $input->{"define"} and ref $input->{"datasets"} eq "ARRAY"
!ll&&!rl&&r
005
ref $input eq "HASH" and exists $input->{"define"}
!ll&&!rl&&r
005
MC/DC0%0/3
ref $input eq "HASH" and exists $input->{"define"} and ref $input->{"datasets"} eq "ARRAY"
ref $input eq "HASH" exists $input->{"define"} ref $input->{"datasets"} eq "ARRAY"
Truth table25%1/4
A and B and C
A= ref $input eq "HASH"B= exists $input->{"define"}C= ref $input->{"datasets"} eq "ARRAY"
ABCresult
0XX0
10X0
1100
1111
50  
51 5 $define_input = _clone_input( $input->{define} );
52 @dataset_documents = map {
53 20 _xml_document( _clone_input($_), 'in-memory Dataset-XML' )
54 5 } @{ $input->{datasets} };
55 5 @labels = map { 'in-memory Dataset-XML dataset ' . ( $_ + 1 ) }
56 0 .. $#dataset_documents;
57 }
58 else {
59 10 my $define_file = $converter->{define_xml};
60 10 ▶ die "Dataset-XML input requires --define-xml <file>\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $define_file and length $define_file 0 10 10
Condition33%1/3
defined $define_file and length $define_file
!ll&&!rl&&r
0010
MC/DC0%0/2
defined $define_file and length $define_file
defined $define_file length $define_file
Truth table33%1/3
A and B
A= defined $define_fileB= length $define_file
ABresult
0X0
100
111
61 unless defined $define_file && length $define_file;
62 10 ▶ die "Dataset-XML Define-XML file <$define_file> does not exist\n"
Branch: 1 branch
BranchTrueFalseTotal
unless -f $define_file 0 10 10
63 unless -f $define_file;
64  
65 10 ▶ my @files = @{ $converter->{in_files} || [] };
Condition50%1/2
$converter->{'in_files'} || []
l!l
100
MC/DC0%0/1
$converter->{'in_files'} || []
$converter->{'in_files'}
Truth table50%1/2
A
A= $converter->{'in_files'}
Aresult
11
00
66 push @files, $converter->{in_file}
67 10 ▶ if !@files && defined $converter->{in_file};
Branch: 1 branch
BranchTrueFalseTotal
if not @files and defined $converter->{"in_file"} 0 10 10
Condition33%1/3
not @files and defined $converter->{"in_file"}
!ll&&!rl&&r
1000
MC/DC0%0/2
not @files and defined $converter->{"in_file"}
not @files defined $converter->{"in_file"}
Truth table33%1/3
not(A) and B
A= not @filesB= defined $converter->{"in_file"}
ABresult
0X0
100
111
68 10 ▶ die "Dataset-XML input requires at least one XML dataset file\n"
Branch: 1 branch
BranchTrueFalseTotal
unless @files 0 10 10
69 unless @files;
70  
71 10 $define_input = $define_file;
72 10 for my $file (@files) {
73 34 ▶ die "Dataset-XML file <$file> does not exist\n" unless -f $file;
Branch: 1 branch
BranchTrueFalseTotal
unless -f $file 0 34 34
74 34 push @dataset_documents, _read_xml_file($file);
75 34 push @labels, $file;
76 }
77 }
78  
79 15 my $catalog = load_define_catalog( $define_input, 'Define-XML' );
80 15 my @datasets;
81 my $metadata_version_oid;
82 15 for my $index ( 0 .. $#dataset_documents ) {
83 48 my $dataset = _dataset_document(
84 $dataset_documents[$index],
85 $labels[$index],
86 $catalog,
87 );
88 46 ▶ $metadata_version_oid //= $dataset->{metaDataVersionOID};
Condition66%2/3
$metadata_version_oid //= $dataset->{"metaDataVersionOID"}
l!l&&r!l&&!r
33130
MC/DC0%0/2
$metadata_version_oid //= $dataset->{"metaDataVersionOID"}
$metadata_version_oid $dataset->{"metaDataVersionOID"}
Truth table66%2/3
A //= B
A= $metadata_version_oidB= $dataset->{"metaDataVersionOID"}
ABresult
1X1
011
000
89 die "Dataset-XML files contain inconsistent MetaDataVersionOID values <$metadata_version_oid> and <$dataset->{metaDataVersionOID}>\n"
90 46 ▶ if $dataset->{metaDataVersionOID} ne $metadata_version_oid;
Branch: 1 branch
BranchTrueFalseTotal
if $dataset->{"metaDataVersionOID"} ne $metadata_version_oid 0 46 46
91 46 push @datasets, $dataset;
92 }
93  
94 13 my $normalized = normalize_sdtm_datasets(
95 \@datasets,
96 \@labels,
97 format_name => 'Dataset-XML',
98 source_format => 'dataset-xml',
99 version_key => 'datasetXMLVersion',
100 subject_metadata_fields => [
101 qw(defineXMLVersion metaDataVersionOID metaDataRef originator sourceSystem)
102 ],
103 );
104 my $terminology = prepare_sdtm_terminology(
105 $converter,
106 $normalized->{metadata},
107 13 );
108  
109 return Convert::Pheno::Source::Result->new(
110 {
111 data => $normalized->{subjects},
112 owned => 1,
113 artifacts => {
114 dataset_metadata => $normalized->{metadata},
115 subject_independent_domains => $normalized->{subject_independent},
116 terminology_mapping => $terminology->{mapping},
117 source_terminology => $terminology->{source_terms},
118 terminology_requires_sqlite => $terminology->{requires_sqlite},
119 derived_entity_overrides => derive_sdtm_entity_overrides(
120 $converter,
121 $normalized->{metadata},
122 $normalized->{subject_independent},
123 13 format_label => 'Dataset-XML',
124 provenance_key => 'datasetXml',
125 ),
126 },
127 }
128 );
129 }
130  
131 25 ▶sub _clone_input {
Subroutine _clone_input: called CC=2 SCAR=7.2
132 25 my ($input) = @_;
133 25 ▶ return ref($input) ? dclone($input) : $input;
Branch: 1 branch
BranchTrueFalseTotal
ref $input ? : 0 25 25
134 }
135  
136 34 ▶sub _read_xml_file {
Subroutine _read_xml_file: called CC=1 SCAR=0.0
137 34 my ($file) = @_;
138 34 return _xml_document( path($file)->slurp_utf8, $file );
139 }
140  
141 54 ▶sub _xml_document {
Subroutine _xml_document: called CC=5 SCAR=17.5
142 54 my ( $input, $label ) = @_;
143 54 ▶ return $input if ref($input) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if ref $input eq "HASH" 0 54 54
144 54 ▶ die "XML input <$label> must contain an XML string or parsed object\n"
Branch: 1 branch
BranchTrueFalseTotal
if ref $input or not defined $input 0 54 54
Condition33%1/3
ref $input or not defined $input
l!l&&r!l&&!r
0054
MC/DC0%0/2
ref $input or not defined $input
ref $input not defined $input
Truth table33%1/3
A or not(B)
A= ref $inputB= not defined $input
ABresult
1X1
011
000
145 if ref($input) || !defined $input;
146  
147 54 my $document = eval { xml2hash $input, attr => '-', text => '~' };
148 54 ▶ die "Could not parse XML input <$label>: $@" if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 54 54
149 54 return $document;
150 }
151  
152 48 ▶sub _dataset_document {
Subroutine _dataset_document: called CC=34 SCAR=41.1
153 48 my ( $document, $label, $catalog ) = @_;
154 48 my $descriptor = detect_odm_document($document);
155 die "Dataset-XML input <$label> must use the ODM 1.3 namespace\n"
156 48 ▶ unless $descriptor->{adapter} eq 'v1';
Branch: 1 branch
BranchTrueFalseTotal
unless $descriptor->{"adapter"} eq "v1" 0 48 48
157  
158 48 my %seen_namespace;
159 my @dataset_namespaces = grep {
160 96 ▶ $_ eq $DATASET_XML_NAMESPACE && !$seen_namespace{$_}++
Condition66%2/3
$_ eq $DATASET_XML_NAMESPACE && !$seen_namespace{$_}++
!ll&&!rl&&r
48048
MC/DC50%1/2
$_ eq $DATASET_XML_NAMESPACE && !$seen_namespace{$_}++
$_ eq $DATASET_XML_NAMESPACE !$seen_namespace{$_}++
Truth table66%2/3
A && not(B)
A= $_ eq $DATASET_XML_NAMESPACEB= !$seen_namespace{$_}++
ABresult
0X0
100
111
161 48 } values %{ $descriptor->{namespaces} };
162 48 ▶ die "Dataset-XML input <$label> is missing the Dataset-XML v1.0 namespace\n"
Branch: 1 branch
BranchTrueFalseTotal
unless @dataset_namespaces == 1 0 48 48
163 unless @dataset_namespaces == 1;
164 my $dataset_version = attribute_by_namespace(
165 $descriptor->{root},
166 $descriptor->{namespaces},
167 48 $DATASET_XML_NAMESPACE,
168 'DatasetXMLVersion',
169 );
170 48 ▶ die "Dataset-XML input <$label> is missing DatasetXMLVersion\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $dataset_version and length $dataset_version 0 48 48
Condition33%1/3
defined $dataset_version and length $dataset_version
!ll&&!rl&&r
0048
MC/DC0%0/2
defined $dataset_version and length $dataset_version
defined $dataset_version length $dataset_version
Truth table33%1/3
A and B
A= defined $dataset_versionB= length $dataset_version
ABresult
0X0
100
111
171 unless defined $dataset_version && length $dataset_version;
172 48 ▶ die "Unsupported Dataset-XML version <$dataset_version> in <$label>; expected 1.0.0\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $dataset_version eq "1.0.0" 0 48 48
173 unless $dataset_version eq '1.0.0';
174  
175 my @containers = (
176 48 @{ children( $descriptor->{root}, 'ClinicalData' ) },
177 48 @{ children( $descriptor->{root}, 'ReferenceData' ) },
178 );
179 48 ▶ die "Dataset-XML input <$label> must contain exactly one ClinicalData or ReferenceData element\n"
Branch: 1 branch
BranchTrueFalseTotal
unless @containers == 1 0 48 48
180 unless @containers == 1;
181 48 my $container = $containers[0];
182 48 my $study_oid = attr( $container, 'StudyOID' );
183 48 my $version_oid = attr( $container, 'MetaDataVersionOID' );
184 48 ▶ die "Dataset-XML input <$label> is missing StudyOID or MetaDataVersionOID\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $study_oid and length $study_oid and defined $version_oid and length $version_oid 0 48 48
Condition33%3/9
defined $study_oid and length $study_oid and defined $version_oid and length $version_oid
!ll&&!rl&&r
0048
defined $study_oid and length $study_oid and defined $version_oid
!ll&&!rl&&r
0048
defined $study_oid and length $study_oid
!ll&&!rl&&r
0048
MC/DC0%0/4
defined $study_oid and length $study_oid and defined $version_oid and length $version_oid
defined $study_oid length $study_oid defined $version_oid length $version_oid
Truth table20%1/5
A and B and C and D
A= defined $study_oidB= length $study_oidC= defined $version_oidD= length $version_oid
ABCDresult
0XXX0
10XX0
110X0
11100
11111
185 unless defined $study_oid && length $study_oid
186 && defined $version_oid && length $version_oid;
187  
188 48 my @groups = @{ children( $container, 'ItemGroupData' ) };
189 48 ▶ die "Dataset-XML input <$label> does not contain any ItemGroupData rows\n"
Branch: 1 branch
BranchTrueFalseTotal
unless @groups 0 48 48
190 unless @groups;
191 48 my $group_oid = attr( $groups[0], 'ItemGroupOID' );
192 48 ▶ die "Dataset-XML input <$label> contains an ItemGroupData row without ItemGroupOID\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $group_oid and length $group_oid 0 48 48
Condition33%1/3
defined $group_oid and length $group_oid
!ll&&!rl&&r
0048
MC/DC0%0/2
defined $group_oid and length $group_oid
defined $group_oid length $group_oid
Truth table33%1/3
A and B
A= defined $group_oidB= length $group_oid
ABresult
0X0
100
111
193 unless defined $group_oid && length $group_oid;
194 48 my ( $provider, $group ) = resolve_define_group(
195 $catalog,
196 $study_oid,
197 $version_oid,
198 $group_oid,
199 "Dataset-XML input <$label>",
200 );
201  
202 47 my %column_by_oid = map { $_->{itemOID} => $_ } @{ $group->{columns} };
203 47 my ( @rows, %sequence );
204 47 for my $row_index ( 0 .. $#groups ) {
205 94 my $row = $groups[$row_index];
206 94 my $current_group_oid = attr( $row, 'ItemGroupOID' );
207 94 ▶ die "Dataset-XML input <$label> contains multiple ItemGroupOID values <$group_oid> and <$current_group_oid>\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $current_group_oid and $current_group_oid eq $group_oid 0 94 94
Condition33%1/3
defined $current_group_oid and $current_group_oid eq $group_oid
!ll&&!rl&&r
0094
MC/DC0%0/2
defined $current_group_oid and $current_group_oid eq $group_oid
defined $current_group_oid $current_group_oid eq $group_oid
Truth table33%1/3
A and B
A= defined $current_group_oidB= $current_group_oid eq $group_oid
ABresult
0X0
100
111
208 unless defined $current_group_oid && $current_group_oid eq $group_oid;
209  
210 my $sequence = attribute_by_namespace(
211 $row,
212 $descriptor->{namespaces},
213 94 $DATASET_XML_NAMESPACE,
214 'ItemGroupDataSeq',
215 );
216 94 ▶ die "Dataset-XML input <$label> row " . ( $row_index + 1 )
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sequence and length $sequence 0 94 94
Condition33%1/3
defined $sequence and length $sequence
!ll&&!rl&&r
0094
MC/DC0%0/2
defined $sequence and length $sequence
defined $sequence length $sequence
Truth table33%1/3
A and B
A= defined $sequenceB= length $sequence
ABresult
0X0
100
111
217 . " is missing ItemGroupDataSeq\n"
218 unless defined $sequence && length $sequence;
219 die "Dataset-XML input <$label> contains duplicate ItemGroupDataSeq <$sequence>\n"
220 94 ▶ if $sequence{$sequence}++;
Branch: 1 branch
BranchTrueFalseTotal
if $sequence{$sequence}++ 0 94 94
221  
222 94 my %values;
223 94 for my $item ( @{ children( $row, 'ItemData' ) } ) {
224 612 my $item_oid = attr( $item, 'ItemOID' );
225 612 ▶ die "Dataset-XML input <$label> row $sequence contains ItemData without ItemOID\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $item_oid and length $item_oid 0 612 612
Condition33%1/3
defined $item_oid and length $item_oid
!ll&&!rl&&r
00612
MC/DC0%0/2
defined $item_oid and length $item_oid
defined $item_oid length $item_oid
Truth table33%1/3
A and B
A= defined $item_oidB= length $item_oid
ABresult
0X0
100
111
226 unless defined $item_oid && length $item_oid;
227 die "Dataset-XML input <$label> row $sequence contains ItemOID <$item_oid> outside ItemGroupDef <$group_oid>\n"
228 612 ▶ unless exists $column_by_oid{$item_oid};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $column_by_oid{$item_oid} 0 612 612
229 die "Dataset-XML input <$label> row $sequence contains duplicate ItemOID <$item_oid>\n"
230 612 ▶ if exists $values{$item_oid};
Branch: 1 branch
BranchTrueFalseTotal
if exists $values{$item_oid} 0 612 612
231  
232 612 my $value = attr( $item, 'Value' );
233 612 ▶ die "Dataset-XML input <$label> row $sequence ItemOID <$item_oid> is missing Value; omit ItemData for a missing value\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 612 612
234 unless defined $value;
235 $values{$item_oid} = _coerce_value(
236 $value,
237 $column_by_oid{$item_oid}{dataType},
238 612 );
239 }
240  
241 push @rows,
242 [
243 map {
244 exists $values{ $_->{itemOID} }
245 ? $values{ $_->{itemOID} }
246 : undef
247 94 ▶ } @{ $group->{columns} }
Branch: 1 branch
BranchTrueFalseTotal
exists $values{$_->{'itemOID'}} ? : 612 56 668
248 ];
249 }
250  
251 47 my $root = $descriptor->{root};
252 47 my $prior_file_oid = attr( $root, 'PriorFileOID' );
253 die "Dataset-XML input <$label> links to Define-XML <$prior_file_oid>, but the supplied Define-XML FileOID is <$catalog->{fileOID}>\n"
254 if defined $prior_file_oid
255 && defined $catalog->{fileOID}
256 47 ▶ && $prior_file_oid ne $catalog->{fileOID};
Branch: 1 branch
BranchTrueFalseTotal
if defined $prior_file_oid and defined $catalog->{"fileOID"} and $prior_file_oid ne $catalog->{"fileOID"} 1 46 47
Condition50%3/6
defined $prior_file_oid and defined $catalog->{"fileOID"} and $prior_file_oid ne $catalog->{"fileOID"}
!ll&&!rl&&r
0461
defined $prior_file_oid and defined $catalog->{"fileOID"}
!ll&&!rl&&r
0047
MC/DC33%1/3
defined $prior_file_oid and defined $catalog->{"fileOID"} and $prior_file_oid ne $catalog->{"fileOID"}
defined $prior_file_oid defined $catalog->{"fileOID"} $prior_file_oid ne $catalog->{"fileOID"}
Truth table50%2/4
A and B and C
A= defined $prior_file_oidB= defined $catalog->{"fileOID"}C= $prior_file_oid ne $catalog->{"fileOID"}
ABCresult
0XX0
10X0
1100
1111
257  
258 my $dataset = {
259 datasetXMLVersion => $dataset_version,
260 defineXMLVersion => $provider->{defineXMLVersion},
261 studyOID => $study_oid,
262 metaDataVersionOID => $version_oid,
263 name => $group->{name},
264 label => $group->{label},
265 itemGroupOID => $group_oid,
266 records => scalar(@rows),
267 46 columns => dclone( $group->{columns} ),
268 rows => \@rows,
269 };
270 46 ▶ $dataset->{originator} = attr( $root, 'Originator' )
Branch: 1 branch
BranchTrueFalseTotal
if defined attr($root, "Originator") 44 2 46
271 if defined attr( $root, 'Originator' );
272 46 ▶ $dataset->{sourceSystem} = attr( $root, 'SourceSystem' )
Branch: 1 branch
BranchTrueFalseTotal
if defined attr($root, "SourceSystem") 0 46 46
273 if defined attr( $root, 'SourceSystem' );
274 46 ▶ $dataset->{metaDataRef} = $prior_file_oid if defined $prior_file_oid;
Branch: 1 branch
BranchTrueFalseTotal
if defined $prior_file_oid 46 0 46
275 46 return $dataset;
276 }
277  
278 612 ▶sub _coerce_value {
Subroutine _coerce_value: called CC=8 SCAR=23.7
279 612 my ( $value, $type ) = @_;
280 612 ▶ $type = lc( $type // q{} );
Condition50%1/2
$type // ""
l!l
6120
MC/DC0%0/1
$type // ""
$type
Truth table50%1/2
A
A= $type
Aresult
11
00
281  
282 612 ▶ return 0 + $value
Branch: 1 branch
BranchTrueFalseTotal
if $type =~ /\A(?:integer|float|double|decimal)\z/ and &looks_like_number($value) 88 524 612
Condition66%2/3
$type =~ /\A(?:integer|float|double|decimal)\z/ and &looks_like_number($value)
!ll&&!rl&&r
524088
MC/DC50%1/2
$type =~ /\A(?:integer|float|double|decimal)\z/ and &looks_like_number($value)
$type =~ /\A(?:integer|float|double|decimal)\z/ &looks_like_number($value)
Truth table66%2/3
A and B
A= $type =~ /\A(?:integer|float|double|decimal)\z/B= &looks_like_number($value)
ABresult
0X0
100
111
283 if $type =~ /\A(?:integer|float|double|decimal)\z/
284 && looks_like_number($value);
285 524 ▶ return JSON::PP::true()
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "boolean" and $value =~ /\A(?:true|1)\z/i 0 524 524
Condition33%1/3
$type eq "boolean" and $value =~ /\A(?:true|1)\z/i
!ll&&!rl&&r
52400
MC/DC0%0/2
$type eq "boolean" and $value =~ /\A(?:true|1)\z/i
$type eq "boolean" $value =~ /\A(?:true|1)\z/i
Truth table33%1/3
A and B
A= $type eq "boolean"B= $value =~ /\A(?:true|1)\z/i
ABresult
0X0
100
111
286 if $type eq 'boolean' && $value =~ /\A(?:true|1)\z/i;
287 524 ▶ return JSON::PP::false()
Branch: 1 branch
BranchTrueFalseTotal
if $type eq "boolean" and $value =~ /\A(?:false|0)\z/i 0 524 524
Condition33%1/3
$type eq "boolean" and $value =~ /\A(?:false|0)\z/i
!ll&&!rl&&r
52400
MC/DC0%0/2
$type eq "boolean" and $value =~ /\A(?:false|0)\z/i
$type eq "boolean" $value =~ /\A(?:false|0)\z/i
Truth table33%1/3
A and B
A= $type eq "boolean"B= $value =~ /\A(?:false|0)\z/i
ABresult
0X0
100
111
288 if $type eq 'boolean' && $value =~ /\A(?:false|0)\z/i;
289 524 return $value;
290 }
291  
292 13 ▶sub prepare {
Subroutine prepare: called CC=12 SCAR=25.4
Pod undocumented
293 13 my ($self) = @_;
294 13 my $converter = $self->{converter};
295 return 1 if $converter->{dataset_xml_input_prepared}
296 13 ▶ && exists $converter->{data};
Branch: 1 branch
BranchTrueFalseTotal
if $converter->{"dataset_xml_input_prepared"} and exists $converter->{"data"} 0 13 13
Condition66%2/3
$converter->{"dataset_xml_input_prepared"} and exists $converter->{"data"}
!ll&&!rl&&r
1210
MC/DC0%0/2
$converter->{"dataset_xml_input_prepared"} and exists $converter->{"data"}
$converter->{"dataset_xml_input_prepared"} exists $converter->{"data"}
Truth table66%2/3
A and B
A= $converter->{"dataset_xml_input_prepared"}B= exists $converter->{"data"}
ABresult
0X0
100
111
297  
298 $converter->{_dataset_xml_source_data} = $converter->{data}
299 if exists $converter->{data}
300 13 ▶ && !exists $converter->{_dataset_xml_source_data};
Branch: 1 branch
BranchTrueFalseTotal
if exists $converter->{"data"} and not exists $converter->{"_dataset_xml_source_data"} 3 10 13
Condition66%2/3
exists $converter->{"data"} and not exists $converter->{"_dataset_xml_source_data"}
!ll&&!rl&&r
1003
MC/DC50%1/2
exists $converter->{"data"} and not exists $converter->{"_dataset_xml_source_data"}
exists $converter->{"data"} not exists $converter->{"_dataset_xml_source_data"}
Truth table66%2/3
A and not(B)
A= exists $converter->{"data"}B= not exists $converter->{"_dataset_xml_source_data"}
ABresult
0X0
100
111
301 $converter->{data} = $converter->{_dataset_xml_source_data}
302 if !exists $converter->{data}
303 13 ▶ && exists $converter->{_dataset_xml_source_data};
Branch: 1 branch
BranchTrueFalseTotal
if not exists $converter->{"data"} and exists $converter->{"_dataset_xml_source_data"} 1 12 13
Condition100%3/3
not exists $converter->{"data"} and exists $converter->{"_dataset_xml_source_data"}
!ll&&!rl&&r
391
MC/DC100%2/2
not exists $converter->{"data"} and exists $converter->{"_dataset_xml_source_data"}
not exists $converter->{"data"} exists $converter->{"_dataset_xml_source_data"}
Truth table100%3/3
not(A) and B
A= not exists $converter->{"data"}B= exists $converter->{"_dataset_xml_source_data"}
ABresult
0X0
100
111
304  
305 13 my $source = $self->load;
306 11 $source->apply_to($converter);
307 $converter->{dataset_xml_metadata} =
308 11 $source->artifact('dataset_metadata');
309 $converter->{dataset_xml_subject_independent_domains} =
310 11 $source->artifact('subject_independent_domains');
311 $converter->{source_derived_entity_overrides} =
312 11 ▶ $source->artifact('derived_entity_overrides') || {};
Condition50%1/2
$source->artifact('derived_entity_overrides') || {}
l!l
110
MC/DC0%0/1
$source->artifact('derived_entity_overrides') || {}
$source->artifact('derived_entity_overrides')
Truth table50%1/2
A
A= $source->artifact('derived_entity_overrides')
Aresult
11
00
313 $converter->{sdtm_terminology_mapping} =
314 11 ▶ $source->artifact('terminology_mapping') || {};
Condition50%1/2
$source->artifact('terminology_mapping') || {}
l!l
011
MC/DC0%0/1
$source->artifact('terminology_mapping') || {}
$source->artifact('terminology_mapping')
Truth table50%1/2
A
A= $source->artifact('terminology_mapping')
Aresult
11
00
315 $converter->{sdtm_source_terms} =
316 11 ▶ $source->artifact('source_terminology') || {};
Condition50%1/2
$source->artifact('source_terminology') || {}
l!l
110
MC/DC0%0/1
$source->artifact('source_terminology') || {}
$source->artifact('source_terminology')
Truth table50%1/2
A
A= $source->artifact('source_terminology')
Aresult
11
00
317 $converter->{terminology_lookup_required} =
318 11 ▶ $source->artifact('terminology_requires_sqlite') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$source->artifact('terminology_requires_sqlite') ? : 2 9 11
319 11 ▶ $converter->{convertPheno} ||= get_info($converter);
Condition66%2/3
$converter->{"convertPheno"} ||= get_info($converter)
l!l&&r!l&&!r
1100
MC/DC0%0/2
$converter->{"convertPheno"} ||= get_info($converter)
$converter->{"convertPheno"} get_info($converter)
Truth table66%2/3
A ||= B
A= $converter->{"convertPheno"}B= get_info($converter)
ABresult
1X1
011
000
320 11 $converter->{dataset_xml_input_prepared} = 1;
321 11 return 1;
322 }
323  
324 136 1;
« lib/Convert/Pheno/HTTP/Jobs.pm ↑ Summary lib/Convert/Pheno/FHIR/ToBFF.pm »