| 1 | package Convert::Pheno::Emit::OMOP; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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 | 136 | ▶ | use autodie; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 136 | ▶ | use feature qw(say); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 136 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 136 | ▶ | use JSON::XS; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 136 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 136 | ▶ | use Convert::Pheno::IO::Atomic qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | commit_staged_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | create_staged_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | discard_staged_path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 136 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 136 | our @EXPORT_OK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | dispatcher_open_stream_out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | transform_item | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | finalize_stream_out | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | omop_dispatcher | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | omop_stream_targets_open | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | omop_stream_targets_write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | omop_stream_targets_finalize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | omop_streams_multiple_entities | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 200 | ▶ | sub dispatcher_open_stream_out { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatcher_open_stream_out: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 200 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 200 | ▶ | return unless ( $self->{method} eq 'omop2bff' && $self->{omop_cli} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"method"} eq "omop2bff" and $self->{"omop_cli"}
MC/DC100%2/2
$self->{"method"} eq "omop2bff" and $self->{"omop_cli"}
$self->{"method"} eq "omop2bff"
$self->{"omop_cli"}
Truth table100%3/3
A and B
A= $self->{"method"} eq "omop2bff"B= $self->{"omop_cli"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 14 | my $fh = Convert::Pheno::open_filehandle( $self->{out_file}, 'a' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 14 | say $fh "["; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 14 | return { fh => $fh, first => 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 6000 | ▶ | sub transform_item { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transform_item: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 6000 | my ( $self, $method_result, $fh_out, $is_last_item, $json ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 6000 | ▶ | $json //= JSON::XS->new->canonical->pretty; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$json //= "JSON::XS"->new->canonical->pretty
MC/DC0%0/2
$json //= "JSON::XS"->new->canonical->pretty
$json
"JSON::XS"->new->canonical->pretty
Truth table33%1/3
A //= B
A= $jsonB= "JSON::XS"->new->canonical->pretty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 6000 | my $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 6000 | ▶ | if ( $self->{method_ori} && $self->{method_ori} eq 'omop2pxf' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"method_ori"} and $self->{"method_ori"} eq "omop2pxf"
MC/DC50%1/2
$self->{"method_ori"} and $self->{"method_ori"} eq "omop2pxf"
$self->{"method_ori"}
$self->{"method_ori"} eq "omop2pxf"
Truth table66%2/3
A and B
A= $self->{"method_ori"}B= $self->{"method_ori"} eq "omop2pxf"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1000 | my $pxf = Convert::Pheno::do_bff2pxf( $self, $method_result ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1000 | $out = $json->encode($pxf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 5000 | $out = $json->encode($method_result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 6000 | chomp $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 6000 | print $fh_out $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 6000 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 12 | ▶ | sub finalize_stream_out { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finalize_stream_out: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 12 | my ($stream) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 12 | say { $stream->{fh} } "\n]"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 12 | close $stream->{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 12 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | sub omop_dispatcher { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
omop_dispatcher: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 2 | my ( $self, $method_result, $json ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 2 | ▶ | $json //= JSON::XS->new->canonical->pretty; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$json //= "JSON::XS"->new->canonical->pretty
MC/DC0%0/2
$json //= "JSON::XS"->new->canonical->pretty
$json
"JSON::XS"->new->canonical->pretty
Truth table33%1/3
A //= B
A= $jsonB= "JSON::XS"->new->canonical->pretty
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 2 | my $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 2 | ▶ | if ( $self->{method_ori} ne 'omop2pxf' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 1 | $out = $json->encode($method_result); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 1 | my $pxf = Convert::Pheno::do_bff2pxf( $self, $method_result ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 1 | $out = $json->encode($pxf); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 2 | chomp $out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 2 | return \$out; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 13899 | ▶ | sub omop_streams_multiple_entities { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
omop_streams_multiple_entities: called CC=3 SCAR=11.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 13899 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 13899 | ▶ | my @entities = @{ $self->{entities} || ['individuals'] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'entities'} || ['individuals']
MC/DC0%0/1
$self->{'entities'} || ['individuals']
$self->{'entities'}
Truth table50%1/2
A
A= $self->{'entities'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 13899 | ▶ | return @entities != 1 || $entities[0] ne 'individuals'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
@entities != 1 || $entities[0] ne 'individuals'
MC/DC50%1/2
@entities != 1 || $entities[0] ne 'individuals'
@entities != 1
$entities[0] ne 'individuals'
Truth table66%2/3
A || B
A= @entities != 1B= $entities[0] ne 'individuals'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 45 | ▶ | sub omop_stream_targets_open { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
omop_stream_targets_open: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 45 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | return $self->{_omop_stream_targets} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 45 | ▶ | if exists $self->{_omop_stream_targets}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 6 | ▶ | my @entities = @{ $self->{entities} || ['individuals'] }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'entities'} || ['individuals']
MC/DC0%0/1
$self->{'entities'} || ['individuals']
$self->{'entities'}
Truth table50%1/2
A
A= $self->{'entities'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 6 | my %targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 6 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 6 | for my $entity (@entities) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 11 | my $path = _stream_output_path( $self, $entity ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 11 | my $staged = create_staged_path($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 10 | my $fh = Convert::Pheno::open_filehandle( $staged, 'w' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 10 | $targets{$entity} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | fh => $fh, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | staged => $staged, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 6 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | for my $target ( values %targets ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 1 | ▶ | eval { close $target->{fh} if defined fileno( $target->{fh} ) }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 1 | eval { discard_staged_path( $target->{staged} ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 1 | die $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 5 | $self->{_omop_stream_targets} = \%targets; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 5 | $self->{_omop_stream_seen} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 5 | return $self->{_omop_stream_targets}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 41 | ▶ | sub omop_stream_targets_write { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
omop_stream_targets_write: called CC=10 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 41 | my ( $self, $result ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 41 | my $targets = omop_stream_targets_open($self); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 41 | my $json = JSON::XS->new->canonical; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 41 | ▶ | my $seen = $self->{_omop_stream_seen} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"_omop_stream_seen"} ||= {}
MC/DC0%0/1
$self->{"_omop_stream_seen"} ||= {}
$self->{"_omop_stream_seen"}
Truth table50%1/2
A
A= $self->{"_omop_stream_seen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 41 | ▶ | if ( blessed($result) && $result->can('entities') ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
builtin::blessed($result) and $result->can("entities")
MC/DC50%1/2
builtin::blessed($result) and $result->can("entities")
builtin::blessed($result)
$result->can("entities")
Truth table66%2/3
A and B
A= builtin::blessed($result)B= $result->can("entities")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 37 | for my $entity ( keys %{$targets} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 74 | for my $entry ( @{ $result->entities($entity) } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 53 | ▶ | next if _stream_entity_entry_seen( $seen, $entity, $entry ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 50 | print { $targets->{$entity}{fh} } $json->encode($entry), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 37 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 4 | ▶ | return 1 unless defined $result; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 3 | ▶ | return 1 unless exists $targets->{individuals}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 3 | ▶ | return 1 if _stream_entity_entry_seen( $seen, 'individuals', $result ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 2 | print { $targets->{individuals}{fh} } $json->encode($result), "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 2 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 6 | ▶ | sub omop_stream_targets_finalize { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
omop_stream_targets_finalize: called CC=13 SCAR=27.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 6 | my ( $self, $commit ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 6 | ▶ | $commit = 1 unless defined $commit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 6 | ▶ | return 1 unless exists $self->{_omop_stream_targets}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 5 | my @errors; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | for my $entity ( keys %{ $self->{_omop_stream_targets} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 9 | my $target = $self->{_omop_stream_targets}{$entity}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 9 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 9 | ▶ | close $target->{fh} if defined fileno( $target->{fh} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 9 | ▶ | push @errors, $@ unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 5 | ▶ | $commit = 0 if @errors; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 5 | for my $entity ( sort keys %{ $self->{_omop_stream_targets} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 9 | my $target = $self->{_omop_stream_targets}{$entity}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 9 | ▶ | if ($commit) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 7 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 7 | commit_staged_path( $target->{staged}, $target->{path} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 7 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 7 | ▶ | unless ($ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | push @errors, $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | my $discarded = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | discard_staged_path( $target->{staged} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | push @errors, $@ unless $discarded; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $commit = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 2 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 2 | discard_staged_path( $target->{staged} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 2 | ▶ | push @errors, $@ unless $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 5 | delete $self->{_omop_stream_targets}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 5 | delete $self->{_omop_stream_seen}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 5 | ▶ | die join q{}, @errors if @errors; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 5 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 56 | ▶ | sub _stream_entity_entry_seen { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_entity_entry_seen: called CC=6 SCAR=18.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 56 | my ( $seen, $entity, $entry ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | return 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | unless $entity eq 'individuals' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | && ref($entry) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | && exists $entry->{id} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 56 | ▶ | && defined $entry->{id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
$entity eq "individuals" and ref $entry eq "HASH" and exists $entry->{"id"} and defined $entry->{"id"}
$entity eq "individuals" and ref $entry eq "HASH" and exists $entry->{"id"}
$entity eq "individuals" and ref $entry eq "HASH"
MC/DC25%1/4
$entity eq "individuals" and ref $entry eq "HASH" and exists $entry->{"id"} and defined $entry->{"id"}
$entity eq "individuals"
ref $entry eq "HASH"
exists $entry->{"id"}
defined $entry->{"id"}
Truth table40%2/5
A and B and C and D
A= $entity eq "individuals"B= ref $entry eq "HASH"C= exists $entry->{"id"}D= defined $entry->{"id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 19 | ▶ | return 1 if $seen->{$entity}{ $entry->{id} }++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 15 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 11 | ▶ | sub _stream_output_path { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_output_path: called CC=7 SCAR=19.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 11 | my ( $self, $entity ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 11 | ▶ | if ( !omop_streams_multiple_entities($self) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
not omop_streams_multiple_entities($self) and $entity eq "individuals" and defined $self->{"out_file"} and length $self->{"out_file"}
not omop_streams_multiple_entities($self) and $entity eq "individuals" and defined $self->{"out_file"}
not omop_streams_multiple_entities($self) and $entity eq "individuals"
MC/DC25%1/4
not omop_streams_multiple_entities($self) and $entity eq "individuals" and defined $self->{"out_file"} and length $self->{"out_file"}
not omop_streams_multiple_entities($self)
$entity eq "individuals"
defined $self->{"out_file"}
length $self->{"out_file"}
Truth table40%2/5
not(A) and B and C and D
A= not omop_streams_multiple_entities($self)B= $entity eq "individuals"C= defined $self->{"out_file"}D= length $self->{"out_file"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | && $entity eq 'individuals' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | && defined $self->{out_file} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | && length $self->{out_file} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 1 | return $self->{out_file}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 10 | ▶ | if ( exists $self->{output_name_overrides} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
exists $self->{"output_name_overrides"} and exists $self->{"output_name_overrides"}{$entity}
MC/DC50%1/2
exists $self->{"output_name_overrides"} and exists $self->{"output_name_overrides"}{$entity}
exists $self->{"output_name_overrides"}
exists $self->{"output_name_overrides"}{$entity}
Truth table66%2/3
A and B
A= exists $self->{"output_name_overrides"}B= exists $self->{"output_name_overrides"}{$entity}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | && exists $self->{output_name_overrides}{$entity} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 2 | return $self->{output_name_overrides}{$entity}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 8 | return $self->{out_dir} . q{/} . $entity . '.json'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 136 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||