lib/Convert/Pheno/ConversionRequest.pm

filter: Statementstmt 100% 49 / 49 Branchbran 90.0% 9 / 10 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 6 totaltotal 91.4% 75 / 82 CC 8 SCAR 9.1
CC
8
Cov
98%
from_converter
5.0
_copy_value
3.0
stage_arguments
2.0
CRAP 2.5
« lib/Convert/Pheno/ExecutionContext.pm ↑ Summary lib/Convert/Pheno/Context.pm »
1 package Convert::Pheno::ConversionRequest;
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 Hash::Util qw(lock_hashref);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 136 ▶use Storable qw(dclone);
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 136 ▶use Convert::Pheno::Operations qw(conversion_spec);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 136 my @ARGUMENT_KEYS = qw(
12 data
13 debug
14 default_vital_status
15 define_xml
16 derived_entity_overrides
17 entities
18 exposures_file
19 id
20 in_file
21 in_files
22 in_textfile
23 include_dataset_id
24 levenshtein_weight
25 log
26 mapping_file
27 max_lines_sql
28 min_text_similarity_score
29 ohdsi_db
30 omop_tables
31 out_dir
32 out_file
33 output_name_overrides
34 path_to_ohdsi_db
35 redcap_dictionary
36 schema_file
37 search
38 term_audit_file
39 self_validate_schema
40 sep
41 source_info
42 sql2csv
43 stream
44 test
45 text_similarity_method
46 username
47 verbose
48 );
49  
50 313 ▶sub from_converter {
Subroutine from_converter: called CC=5 SCAR=16.1
Pod undocumented
51 313 my ( $class, $converter ) = @_;
52 313 my $method = $converter->{method};
53 313 ▶ my $spec = conversion_spec($method)
Branch: 1 branch
BranchTrueFalseTotal
my $spec = conversion_spec($method) or die "Unsupported conversion <$method>\n" 313 0 313
54 or die "Unsupported conversion <$method>\n";
55  
56 313 my %arguments;
57 313 for my $key (@ARGUMENT_KEYS) {
58 11268 ▶ next unless exists $converter->{$key};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $converter->{$key} 3872 7396 11268
59 7396 $arguments{$key} = _copy_value( $converter->{$key}, $key eq 'data' );
60 }
61  
62 313 lock_hashref(\%arguments);
63 my $self = {
64 method => $method,
65 spec => $spec,
66 arguments => \%arguments,
67 313 ▶ has_data => exists $converter->{data} ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
exists $converter->{'data'} ? : 254 59 313
68 };
69 313 bless $self, $class;
70 313 lock_hashref($self);
71 313 return $self;
72 }
73  
74 1 ▶sub method { return $_[0]->{method} }
Subroutine method: called CC=1 SCAR=0.0
Pod undocumented
75 6 ▶sub has_data { return $_[0]->{has_data} }
Subroutine has_data: called CC=1 SCAR=0.0
Pod undocumented
76  
77 49 ▶sub spec {
Subroutine spec: called CC=1 SCAR=0.0
Pod undocumented
78 49 my ($self) = @_;
79 49 return dclone( $self->{spec} );
80 }
81  
82 51 ▶sub pipeline {
Subroutine pipeline: called CC=1 SCAR=0.0
Pod undocumented
83 51 my ($self) = @_;
84 51 return [ @{ $self->{spec}{pipeline} } ];
85 }
86  
87 361 ▶sub stage_arguments {
Subroutine stage_arguments: called CC=2 SCAR=6.9
Pod undocumented
88 361 my ( $self, $stage, %arg ) = @_;
89 my %arguments = map {
90 8480 $_ => _copy_value( $self->{arguments}{$_}, $_ eq 'data' )
91 361 } keys %{ $self->{arguments} };
92  
93 361 $arguments{method} = $stage;
94 361 ▶ if ( exists $arg{data} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $arg{"data"}) 48 313 361
95 48 $arguments{data} = $arg{data};
96 48 $arguments{in_textfile} = 0;
97 # The source mapping has already been applied by the first stage.
98 # Do not reinterpret it as a mapping for the intermediate BFF records.
99 48 delete @arguments{qw(mapping_file schema_file)};
100 }
101  
102 361 return \%arguments;
103 }
104  
105 15876 ▶sub _copy_value {
Subroutine _copy_value: called CC=3 SCAR=11.0
106 15876 my ( $value, $preserve_reference ) = @_;
107 15876 ▶ return $value if $preserve_reference || !ref($value);
Branch: 1 branch
BranchTrueFalseTotal
if $preserve_reference or not ref $value 12342 3534 15876
Condition100%3/3
$preserve_reference or not ref $value
l!l&&r!l&&!r
519118233534
MC/DC100%2/2
$preserve_reference or not ref $value
$preserve_reference not ref $value
Truth table100%3/3
A or not(B)
A= $preserve_referenceB= not ref $value
ABresult
1X1
011
000
108 3534 return dclone($value);
109 }
110  
111 136 1;
« lib/Convert/Pheno/ExecutionContext.pm ↑ Summary lib/Convert/Pheno/Context.pm »