| 1 | package Convert::Pheno::CDISC::SDTM::Normalizer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 136 | ▶ | use Scalar::Util qw(blessed looks_like_number); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 136 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 136 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | collect_sdtm_source_terms | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | derive_sdtm_entity_overrides | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | normalize_sdtm_datasets | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | sdtm_source_fields | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 35 | ▶ | sub normalize_sdtm_datasets { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
normalize_sdtm_datasets: called CC=33 SCAR=36.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 35 | my ( $datasets, $labels, %option ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 35 | ▶ | my $format_name = $option{format_name} || 'Dataset-JSON'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$option{'format_name'} || 'Dataset-JSON'
MC/DC0%0/1
$option{'format_name'} || 'Dataset-JSON'
$option{'format_name'}
Truth table50%1/2
A
A= $option{'format_name'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 35 | ▶ | my $version_key = $option{version_key} || 'datasetJSONVersion'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$option{'version_key'} || 'datasetJSONVersion'
MC/DC0%0/1
$option{'version_key'} || 'datasetJSONVersion'
$option{'version_key'}
Truth table50%1/2
A
A= $option{'version_key'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 35 | ▶ | my $source_format = $option{source_format} || 'dataset-json'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$option{'source_format'} || 'dataset-json'
MC/DC0%0/1
$option{'source_format'} || 'dataset-json'
$option{'source_format'}
Truth table50%1/2
A
A= $option{'source_format'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 35 | my $validate = $option{validate}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 35 | ▶ | my $subject_metadata_fields = $option{subject_metadata_fields} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$option{'subject_metadata_fields'} || []
MC/DC100%1/1
$option{'subject_metadata_fields'} || []
$option{'subject_metadata_fields'}
Truth table100%2/2
A
A= $option{'subject_metadata_fields'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | die "$format_name input does not contain any datasets\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 35 | ▶ | unless @{$datasets}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 35 | my %documents; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | my @domain_order; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 35 | my $study_oid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 35 | for my $index ( 0 .. $#{$datasets} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 213 | my $dataset = $datasets->[$index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 213 | my $label = $labels->[$index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 213 | ▶ | die "$format_name input <$label> must contain an object\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | unless ref($dataset) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 213 | ▶ | $validate->( $dataset, $label ) if $validate; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 213 | ▶ | my $domain = uc( _trim( $dataset->{name} ) // q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_trim($dataset->{"name"}) // ""
MC/DC0%0/1
_trim($dataset->{"name"}) // ""
_trim($dataset->{"name"})
Truth table50%1/2
A
A= _trim($dataset->{"name"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 213 | ▶ | die "$format_name input <$label> has an invalid SDTM domain name <$domain>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | unless $domain =~ /\A[A-Z][A-Z0-9]{0,7}\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | die "$format_name domain <$domain> was supplied more than once\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 213 | ▶ | if exists $documents{$domain}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 213 | my $current_study = _trim( $dataset->{studyOID} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 213 | ▶ | if ( defined $current_study && length $current_study ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $current_study and length $current_study
MC/DC0%0/2
defined $current_study and length $current_study
defined $current_study
length $current_study
Truth table33%1/3
A and B
A= defined $current_studyB= length $current_study
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 213 | ▶ | $study_oid //= $current_study; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$study_oid //= $current_study
MC/DC0%0/2
$study_oid //= $current_study
$study_oid
$current_study
Truth table66%2/3
A //= B
A= $study_oidB= $current_study
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 213 | ▶ | die "$format_name files contain inconsistent studyOID values <$study_oid> and <$current_study>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | if $current_study ne $study_oid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 213 | my $decoded = _decode_dataset( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | $dataset, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | $domain, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | $label, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | $format_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 211 | $documents{$domain} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | dataset => $dataset, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | rows => $decoded, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | label => $label, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 211 | push @domain_order, $domain; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | die "$format_name SDTM input requires exactly one <DM> dataset\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 33 | ▶ | unless exists $documents{DM}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 32 | my ( %subjects, @subject_order ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 32 | for my $row ( @{ $documents{DM}{rows} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | my $subject_id = _required_subject_id( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | $row, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'DM', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | $documents{DM}{label}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 63 | $format_name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | die "$format_name DM contains duplicate USUBJID <$subject_id>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 63 | ▶ | if exists $subjects{$subject_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | $subjects{$subject_id} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | id => $subject_id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | sourceFormat => $source_format, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | domains => { DM => [$row] }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | metadata => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 63 | $version_key => $documents{DM}{dataset}{$version_key}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 63 | ▶ | $subjects{$subject_id}{metadata}{studyOID} = $study_oid | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | if defined $study_oid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 63 | for my $field ( @{$subject_metadata_fields} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 130 | ▶ | next unless exists $documents{DM}{dataset}{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 100 | my $value = $documents{DM}{dataset}{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 100 | ▶ | $subjects{$subject_id}{metadata}{$field} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | ref($value) ? dclone($value) : $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 63 | push @subject_order, $subject_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 32 | ▶ | die "$format_name DM does not contain any participant records\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | unless @subject_order; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 32 | my %subject_independent; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 32 | for my $domain (@domain_order) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 210 | ▶ | next if $domain eq 'DM'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 178 | my $document = $documents{$domain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 1046 | my $has_usubjid = scalar grep { uc( $_->{name} ) eq 'USUBJID' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 178 | @{ $document->{dataset}{columns} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 178 | ▶ | if ( !$has_usubjid ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 27 | $subject_independent{$domain} = $document->{rows}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 27 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 151 | for my $row ( @{ $document->{rows} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | my $subject_id = _required_subject_id( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | $row, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | $domain, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | $document->{label}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 264 | $format_name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | die "$format_name domain <$domain> references unknown USUBJID <$subject_id>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 264 | ▶ | unless exists $subjects{$subject_id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 263 | push @{ $subjects{$subject_id}{domains}{$domain} }, $row; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | my @metadata_domains = map { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 31 | my $dataset = $documents{$_}{dataset}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | +{ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | name => $_, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | label => $dataset->{label}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | itemGroupOID => $dataset->{itemGroupOID}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | records => $dataset->{records}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 208 | columns => dclone( $dataset->{columns} ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } @domain_order; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | my $metadata = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 31 | $version_key => $documents{DM}{dataset}{$version_key}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | domains => \@metadata_domains, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 31 | ▶ | $metadata->{studyOID} = $study_oid if defined $study_oid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 31 | for my $field ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | qw(originator sourceSystem metaDataRef metaDataVersionOID defineXMLVersion) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 155 | ▶ | if ( exists $documents{DM}{dataset}{$field} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 52 | my $value = $documents{DM}{dataset}{$field}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 52 | ▶ | $metadata->{$field} = ref($value) ? dclone($value) : $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 31 | subjects => [ map { $subjects{$_} } @subject_order ], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | metadata => $metadata, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | subject_independent => \%subject_independent, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 3 | ▶ | sub sdtm_source_fields { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sdtm_source_fields: called CC=9 SCAR=23.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 3 | my ($metadata) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 3 | my @fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 3 | ▶ | for my $domain ( @{ $metadata->{domains} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$metadata->{'domains'} || []
MC/DC0%0/1
$metadata->{'domains'} || []
$metadata->{'domains'}
Truth table50%1/2
A
A= $metadata->{'domains'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 30 | ▶ | my $domain_name = uc( _trim( $domain->{name} ) // q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_trim($domain->{"name"}) // ""
MC/DC0%0/1
_trim($domain->{"name"}) // ""
_trim($domain->{"name"})
Truth table50%1/2
A
A= _trim($domain->{"name"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 30 | ▶ | next unless length $domain_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 30 | ▶ | for my $column ( @{ $domain->{columns} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$domain->{'columns'} || []
MC/DC0%0/1
$domain->{'columns'} || []
$domain->{'columns'}
Truth table50%1/2
A
A= $domain->{'columns'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 177 | ▶ | my $field = uc( _trim( $column->{name} ) // q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_trim($column->{"name"}) // ""
MC/DC0%0/1
_trim($column->{"name"}) // ""
_trim($column->{"name"})
Truth table50%1/2
A
A= _trim($column->{"name"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 177 | ▶ | push @fields, "$domain_name.$field" if length $field; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 3 | return \@fields; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 31 | ▶ | sub collect_sdtm_source_terms { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
collect_sdtm_source_terms: called CC=10 SCAR=24.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 31 | my ($metadata) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 31 | my %terms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 31 | ▶ | for my $domain ( @{ $metadata->{domains} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$metadata->{'domains'} || []
MC/DC0%0/1
$metadata->{'domains'} || []
$metadata->{'domains'}
Truth table50%1/2
A
A= $metadata->{'domains'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 208 | ▶ | my $domain_name = uc( _trim( $domain->{name} ) // q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_trim($domain->{"name"}) // ""
MC/DC0%0/1
_trim($domain->{"name"}) // ""
_trim($domain->{"name"})
Truth table50%1/2
A
A= _trim($domain->{"name"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 208 | ▶ | next unless length $domain_name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 208 | ▶ | for my $column ( @{ $domain->{columns} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$domain->{'columns'} || []
MC/DC0%0/1
$domain->{'columns'} || []
$domain->{'columns'}
Truth table50%1/2
A
A= $domain->{'columns'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 1250 | ▶ | next unless ref( $column->{controlledTerms} ) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 3 | ▶ | my $field = uc( _trim( $column->{name} ) // q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_trim($column->{"name"}) // ""
MC/DC0%0/1
_trim($column->{"name"}) // ""
_trim($column->{"name"})
Truth table50%1/2
A
A= _trim($column->{"name"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 3 | ▶ | next unless length $field; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | $terms{"$domain_name.$field"} = dclone( $column->{controlledTerms} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 31 | return \%terms; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 31 | ▶ | sub derive_sdtm_entity_overrides { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
derive_sdtm_entity_overrides: called CC=14 SCAR=28.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 31 | my ( $converter, $metadata, $subject_independent, %option ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 31 | my $study_oid = $metadata->{studyOID}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 31 | ▶ | return {} unless defined $study_oid && length $study_oid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $study_oid and length $study_oid
MC/DC0%0/2
defined $study_oid and length $study_oid
defined $study_oid
length $study_oid
Truth table33%1/3
A and B
A= defined $study_oidB= length $study_oid
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 31 | my $study_name = $study_oid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 31 | ▶ | for my $row ( @{ $subject_independent->{TS} || [] } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$subject_independent->{'TS'} || []
MC/DC100%1/1
$subject_independent->{'TS'} || []
$subject_independent->{'TS'}
Truth table100%2/2
A
A= $subject_independent->{'TS'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 27 | ▶ | next unless uc( _trim( $row->{TSPARMCD} ) // q{} ) eq 'TITLE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
_trim($row->{"TSPARMCD"}) // ""
MC/DC0%0/1
_trim($row->{"TSPARMCD"}) // ""
_trim($row->{"TSPARMCD"})
Truth table50%1/2
A
A= _trim($row->{"TSPARMCD"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 27 | my $title = _trim( $row->{TSVAL} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 27 | ▶ | $study_name = $title if defined $title && length $title; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $title and length $title
MC/DC0%0/2
defined $title and length $title
defined $title
length $title
Truth table33%1/3
A and B
A= defined $titleB= length $title
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 27 | last; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 31 | ▶ | my $format_label = $option{format_label} || 'Dataset-JSON'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$option{'format_label'} || 'Dataset-JSON'
MC/DC0%0/1
$option{'format_label'} || 'Dataset-JSON'
$option{'format_label'}
Truth table50%1/2
A
A= $option{'format_label'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 31 | ▶ | my $provenance_key = $option{provenance_key} || 'datasetJson'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$option{'provenance_key'} || 'datasetJson'
MC/DC0%0/1
$option{'provenance_key'} || 'datasetJson'
$option{'provenance_key'}
Truth table50%1/2
A
A= $option{'provenance_key'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 31 | my $overrides = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | datasets => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | id => $study_oid, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | name => $study_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | description => "CDISC $format_label study $study_oid.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | cohorts => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | id => $study_oid . '-cohort', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | name => $study_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | cohortType => 'study-defined', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 31 | ▶ | if ( $converter->{source_info} // 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$converter->{"source_info"} // 1
MC/DC0%0/1
$converter->{"source_info"} // 1
$converter->{"source_info"}
Truth table50%1/2
A
A= $converter->{"source_info"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 29 | $overrides->{datasets}{info}{$provenance_key} = dclone($metadata); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 29 | ▶ | if ( keys %{$subject_independent} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | $overrides->{datasets}{info}{$provenance_key} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 25 | {subjectIndependentDomains} = dclone($subject_independent); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 31 | return $overrides; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 213 | ▶ | sub _decode_dataset { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_decode_dataset: called CC=18 SCAR=31.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 213 | my ( $dataset, $domain, $label, $format_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 213 | my $columns = $dataset->{columns}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | die "$format_name domain <$domain> does not define any columns\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 213 | ▶ | unless ref($columns) eq 'ARRAY' && @{$columns}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $columns eq "ARRAY" and @{$columns;}
MC/DC0%0/2
ref $columns eq "ARRAY" and @{$columns;}
ref $columns eq "ARRAY"
@{$columns;}
Truth table33%1/3
A and B
A= ref $columns eq "ARRAY"B= @{$columns;}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 213 | my ( %seen, @names ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 213 | for my $column ( @{$columns} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 1281 | ▶ | my $name = uc( _trim( $column->{name} ) // q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_trim($column->{"name"}) // ""
MC/DC0%0/1
_trim($column->{"name"}) // ""
_trim($column->{"name"})
Truth table50%1/2
A
A= _trim($column->{"name"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 1281 | ▶ | die "$format_name domain <$domain> contains an empty column name\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | unless length $name; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | die "$format_name domain <$domain> contains duplicate column <$name>\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 1281 | ▶ | if $seen{$name}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 1281 | push @names, $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 213 | ▶ | my $rows = $dataset->{rows} || []; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$dataset->{'rows'} || []
MC/DC0%0/1
$dataset->{'rows'} || []
$dataset->{'rows'}
Truth table50%1/2
A
A= $dataset->{'rows'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | die "$format_name domain <$domain> declares $dataset->{records} records but contains " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 1 | . scalar( @{$rows} ) . " rows\n" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 213 | ▶ | unless $dataset->{records} == @{$rows}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 212 | my @decoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 212 | for my $row_index ( 0 .. $#{$rows} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 358 | my $row = $rows->[$row_index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 358 | my $number = $row_index + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 358 | ▶ | die "$format_name domain <$domain> row $number must contain an array\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | unless ref($row) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 1 | die "$format_name domain <$domain> row $number has " . scalar( @{$row} ) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | . ' values but ' . scalar(@names) . " columns are defined\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 358 | ▶ | unless @{$row} == @names; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 357 | my %record; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 357 | for my $column_index ( 0 .. $#names ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2388 | my $value = $row->[$column_index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2388 | my $column = $columns->[$column_index]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | _validate_value_type( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | $column->{dataType}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2388 | "$domain row $number column $names[$column_index]", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | $format_name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 2388 | $record{ $names[$column_index] } = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 357 | ▶ | if ( exists $record{DOMAIN} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition36%4/11
exists $record{"DOMAIN"} and defined $record{"DOMAIN"} and length(_trim($record{"DOMAIN"}) // "") and uc _trim($record{"DOMAIN"}) ne $domain
exists $record{"DOMAIN"} and defined $record{"DOMAIN"} and length(_trim($record{"DOMAIN"}) // "")
exists $record{"DOMAIN"} and defined $record{"DOMAIN"}
_trim($record{"DOMAIN"}) // ""
MC/DC0%0/4
exists $record{"DOMAIN"} and defined $record{"DOMAIN"} and length(_trim($record{"DOMAIN"}) // "") and uc _trim($record{"DOMAIN"}) ne $domain
exists $record{"DOMAIN"}
defined $record{"DOMAIN"}
_trim($record{"DOMAIN"})
uc _trim($record{"DOMAIN"}) ne $domain
Truth table20%1/5
A and B and C and D
A= exists $record{"DOMAIN"}B= defined $record{"DOMAIN"}C= _trim($record{"DOMAIN"})D= uc _trim($record{"DOMAIN"}) ne $domain
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | && defined $record{DOMAIN} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | && length( _trim( $record{DOMAIN} ) // q{} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | && uc( _trim( $record{DOMAIN} ) ) ne $domain ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | die "$format_name domain <$domain> row $number contains DOMAIN <$record{DOMAIN}>\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 357 | push @decoded, \%record; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 211 | return \@decoded; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 2388 | ▶ | sub _validate_value_type { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_validate_value_type: called CC=17 SCAR=34.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 2388 | my ( $value, $type, $where, $format_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 2388 | ▶ | return 1 if !defined $value || ( !ref($value) && $value eq q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
not defined $value or not ref $value and $value eq ""
not ref $value and $value eq ""
MC/DC66%2/3
not defined $value or not ref $value and $value eq ""
not defined $value
not ref $value
$value eq ""
Truth table75%3/4
not(A) or not(B) and C
A= not defined $valueB= not ref $valueC= $value eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 2250 | ▶ | if ( $type eq 'integer' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 58 | ▶ | die "$format_name $where must contain an integer\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not ref $value and &looks_like_number($value) and int $value == $value
not ref $value and &looks_like_number($value)
MC/DC0%0/3
not ref $value and &looks_like_number($value) and int $value == $value
not ref $value
&looks_like_number($value)
int $value == $value
Truth table25%1/4
not(A) and B and C
A= not ref $valueB= &looks_like_number($value)C= int $value == $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | unless !ref($value) && looks_like_number($value) && int($value) == $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 58 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 2192 | ▶ | if ( $type eq 'decimal' || $type eq 'float' || $type eq 'double' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$type eq "decimal" or $type eq "float" or $type eq "double"
$type eq "decimal" or $type eq "float"
MC/DC33%1/3
$type eq "decimal" or $type eq "float" or $type eq "double"
$type eq "decimal"
$type eq "float"
$type eq "double"
Truth table50%2/4
A or B or C
A= $type eq "decimal"B= $type eq "float"C= $type eq "double"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 194 | ▶ | die "$format_name $where must contain a number\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not ref $value and &looks_like_number($value)
MC/DC0%0/2
not ref $value and &looks_like_number($value)
not ref $value
&looks_like_number($value)
Truth table33%1/3
not(A) and B
A= not ref $valueB= &looks_like_number($value)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | unless !ref($value) && looks_like_number($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 194 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 1998 | ▶ | if ( $type eq 'boolean' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | die "$format_name $where must contain a JSON boolean\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($value) and $value->isa("JSON::PP::Boolean")
MC/DC0%0/2
builtin::blessed($value) and $value->isa("JSON::PP::Boolean")
builtin::blessed($value)
$value->isa("JSON::PP::Boolean")
Truth table0%0/3
A and B
A= builtin::blessed($value)B= $value->isa("JSON::PP::Boolean")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | unless blessed($value) && $value->isa('JSON::PP::Boolean'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 1998 | ▶ | die "$format_name $where must contain a string\n" if ref($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 1998 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 327 | ▶ | sub _required_subject_id { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_required_subject_id: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 327 | my ( $row, $domain, $label, $format_name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 327 | my $subject_id = _trim( $row->{USUBJID} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 327 | ▶ | die "$format_name domain <$domain> in <$label> contains a row without USUBJID\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $subject_id and length $subject_id
MC/DC0%0/2
defined $subject_id and length $subject_id
defined $subject_id
length $subject_id
Truth table33%1/3
A and B
A= defined $subject_idB= length $subject_id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | unless defined $subject_id && length $subject_id; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 327 | return $subject_id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 3220 | ▶ | sub _trim { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trim: called CC=3 SCAR=11.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 3220 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 3220 | ▶ | return unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 3220 | ▶ | return $value if ref($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 3220 | $value =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 3220 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 136 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||