lib/Convert/Pheno/Audit/Terminology.pm

filter: Statementstmt 98.9% 189 / 191 Branchbran 79.4% 54 / 68 Conditioncond 72.3% 34 / 47 MC/DCmcdc 45.8% 11 / 24 Subroutinesub 94.7% 18 / 19 Podpod 0.0% 0 / 5 totaltotal 86.4% 306 / 354 CC 60 SCAR 19.5
CC
60
Cov
91%
_review_category
14.1
_write_xlsx_row
9.1
_close_xlsx
9.0
CRAP 7.0
« lib/Convert/Pheno/ClinicalCDM/ToBFF.pm ↑ Summary lib/Convert/Pheno/Source/OpenEHR.pm »
1 package Convert::Pheno::Audit::Terminology;
2  
3 143 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 143 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 143 ▶use IO::Compress::Gzip qw($GzipError);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 143 my @COLUMNS = qw(
9 row
10 source_record
11 source_field
12 source_value
13 source_label
14 lookup_query
15 lookup_column
16 converted_term_label
17 converted_term_id
18 ontology
19 configured_search_mode
20 effective_search_mode
21 text_similarity_method
22 min_text_similarity_score
23 levenshtein_weight
24 match_status
25 decision_reason
26 review_action
27 match_source
28 lookup_resolution
29 fallback_action
30 retrieval_path
31 best_candidate_label
32 best_candidate_id
33 best_candidate_score
34 score_margin
35 );
36  
37 143 my %NUMERIC_COLUMN = map { $_ => 1 } qw(
38 row
39 min_text_similarity_score
40 levenshtein_weight
41 best_candidate_score
42 score_margin
43 );
44  
45 143 ▶use constant MAX_XLSX_DATA_ROWS => 1_048_575;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 143 ▶use constant PREVIEW_ROWS_PER_ACTION => 100;
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 143 my @REVIEW_ACTIONS = qw(
49 resolve_or_accept_fallback
50 review_similarity
51 review_source_fallback
52 preserve_source
53 keep
54 );
55  
56 18 ▶sub new {
Subroutine new: called CC=6 SCAR=18.6
Pod undocumented
57 18 my ( $class, %arg ) = @_;
58 18 my $path = $arg{path};
59 18 ▶ die "A terminology audit output path is required\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $path and length $path 0 18 18
Condition33%1/3
defined $path and length $path
!ll&&!rl&&r
0018
MC/DC0%0/2
defined $path and length $path
defined $path length $path
Truth table33%1/3
A and B
A= defined $pathB= length $path
ABresult
0X0
100
111
60 unless defined $path && length $path;
61  
62 my $self = bless {
63 path => $path,
64 config => $arg{config} || {},
65 counts => {
66 resolved => 0,
67 review => 0,
68 unresolved => 0,
69 not_searched => 0,
70 preserved => 0,
71 },
72 90 action_counts => { map { $_ => 0 } @REVIEW_ACTIONS },
73 18 ▶ preview_rows => { map { $_ => [] } @REVIEW_ACTIONS },
Condition100%2/2
$arg{'config'} || {}
l!l
153
MC/DC100%1/1
$arg{'config'} || {}
$arg{'config'}
Truth table100%2/2
A
A= $arg{'config'}
Aresult
11
00
74 total_rows => 0,
75 }, $class;
76  
77 18 ▶ if ( $path =~ /\.tsv(?:\.gz)?\z/i ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($path =~ /\.tsv(?:\.gz)?\z/i) { } 14 4 18
elsif ($path =~ /\.xlsx\z/i) { } 4 0 4
78 14 $self->_open_tsv;
79 }
80 elsif ( $path =~ /\.xlsx\z/i ) {
81 4 $self->_open_xlsx;
82 }
83 else {
84 0 die "Unsupported terminology audit format for <$path>; use .tsv, .tsv.gz, or .xlsx\n";
85 }
86  
87 18 return $self;
88 }
89  
90 0 ▶sub columns {
Subroutine columns: not called CC=2 SCAR=17.9
Pod undocumented
91 0 ▶ return wantarray ? @COLUMNS : [@COLUMNS];
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
92 }
93  
94 3959 ▶sub write_row {
Subroutine write_row: called CC=5 SCAR=16.2
Pod undocumented
95 3959 my ( $self, $row ) = @_;
96 3959 ▶ die "A terminology audit row must be a hash reference\n"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $row eq "HASH" 0 3959 3959
97 unless ref $row eq 'HASH';
98  
99 3959 my %output_row = %{$row};
100 3959 ▶ $output_row{review_action} //= _review_action(\%output_row);
Condition33%1/3
$output_row{"review_action"} //= _review_action(\%output_row)
l!l&&r!l&&!r
039590
MC/DC0%0/2
$output_row{"review_action"} //= _review_action(\%output_row)
$output_row{"review_action"} _review_action(\%output_row)
Truth table33%1/3
A //= B
A= $output_row{"review_action"}B= _review_action(\%output_row)
ABresult
1X1
011
000
101 3959 ▶ if ( $self->{format} eq 'xlsx' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'format'} eq 'xlsx') { } 986 2973 3959
102 986 $self->_write_xlsx_row(\%output_row);
103 }
104 else {
105 2973 $self->_write_tsv_row(\%output_row);
106 }
107  
108 3959 my $category = _review_category(\%output_row);
109 3959 my $action = $output_row{review_action};
110 3959 $self->{counts}{$category}++;
111 3959 $self->{action_counts}{$action}++;
112 3959 ▶ if ( @{ $self->{preview_rows}{$action} } < PREVIEW_ROWS_PER_ACTION ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$self->{"preview_rows"}{$action};} < 100) 1008 2951 3959
113 1008 push @{ $self->{preview_rows}{$action} },
114 1008 { map { $_ => $output_row{$_} } @COLUMNS };
115 }
116 3959 $self->{total_rows}++;
117 3959 return 1;
118 }
119  
120 18 ▶sub review {
Subroutine review: called CC=2 SCAR=6.9
Pod undocumented
121 18 my ($self) = @_;
122 18 my @rows = map { @{ $self->{preview_rows}{$_} } } @REVIEW_ACTIONS;
123 18 my %settings = map { $_ => $self->{config}{$_} }
124 qw(search text_similarity_method min_text_similarity_score levenshtein_weight);
125  
126 return {
127 total_decisions => $self->{total_rows},
128 18 ▶ counts => { %{ $self->{action_counts} } },
Branch: 1 branch
BranchTrueFalseTotal
$self->{'total_rows'} > @rows ? : 9 9 18
129 rows => \@rows,
130 preview_rows => scalar @rows,
131 preview_limit_per_action => PREVIEW_ROWS_PER_ACTION,
132 18 truncated => $self->{total_rows} > @rows ? 1 : 0,
133 settings => \%settings,
134 };
135 }
136  
137 18 ▶sub close {
Subroutine close: called CC=4 SCAR=14.0
Pod undocumented
138 18 my ($self) = @_;
139 18 ▶ return 1 if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 18 18
140  
141 18 ▶ if ( $self->{format} eq 'xlsx' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'format'} eq 'xlsx') { } 4 14 18
142 4 $self->_close_xlsx;
143 }
144 else {
145 close $self->{fh}
146 14 ▶ or die "Failed to finalize terminology audit '$self->{path}': $!\n";
Branch: 1 branch
BranchTrueFalseTotal
CORE::close $self->{"fh"} or die qq[Failed to finalize terminology audit '$self->{"path"}': $!\n] 14 0 14
147 }
148  
149 18 $self->{closed} = 1;
150 18 return 1;
151 }
152  
153 14 ▶sub _open_tsv {
Subroutine _open_tsv: called CC=4 SCAR=13.9
154 14 my ($self) = @_;
155 14 my $path = $self->{path};
156 14 my $fh;
157  
158 14 ▶ if ( $path =~ /\.gz\z/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($path =~ /\.gz\z/i) { } 2 12 14
159 # IO::Compress::Gzip ignores binmode; encode text through its own option.
160 2 ▶ $fh = IO::Compress::Gzip->new($path, Encode => 'UTF-8')
Branch: 1 branch
BranchTrueFalseTotal
$fh = "IO::Compress::Gzip"->new($path, "Encode", "UTF-8") or die "Cannot gzip <$path>: $Convert::Pheno::Audit::Terminology::GzipError\n" 2 0 2
161 or die "Cannot gzip <$path>: $GzipError\n";
162 2 $self->{format} = 'tsv_gzip';
163 }
164 else {
165 # Match gzip and the other text writers: encode once, preserve LF.
166 12 ▶ open $fh, '>:raw:encoding(UTF-8)', $path
Branch: 1 branch
BranchTrueFalseTotal
open $fh, ">:raw:encoding(UTF-8)", $path or die "Cannot write terminology audit <$path>: $!\n" 12 0 12
167 or die "Cannot write terminology audit <$path>: $!\n";
168 12 $self->{format} = 'tsv';
169 }
170  
171 14 print {$fh} join( "\t", @COLUMNS ), "\n";
172 14 $self->{fh} = $fh;
173 14 return 1;
174 }
175  
176 2973 ▶sub _write_tsv_row {
Subroutine _write_tsv_row: called CC=4 SCAR=13.9
177 2973 my ( $self, $row ) = @_;
178 my @values = map {
179 2973 my $value = $row->{$_};
180 77298 ▶ $value = sprintf '%.4f', $value
Branch: 1 branch
BranchTrueFalseTotal
if defined $value and $_ eq "best_candidate_score" || $_ eq "score_margin" 2489 74809 77298
Condition100%6/6
defined $value and $_ eq "best_candidate_score" || $_ eq "score_margin"
!ll&&!rl&&r
9153656562489
$_ eq "best_candidate_score" or $_ eq "score_margin"
l!l&&r!l&&!r
24672265656
MC/DC100%3/3
defined $value and $_ eq "best_candidate_score" || $_ eq "score_margin"
defined $value $_ eq "best_candidate_score" $_ eq "score_margin"
Truth table100%4/4
A and B or C
A= defined $valueB= $_ eq "best_candidate_score"C= $_ eq "score_margin"
ABCresult
0XX0
1000
11X1
1011
181 if defined $value
182 && ( $_ eq 'best_candidate_score' || $_ eq 'score_margin' );
183 77298 _tsv_field($value);
184 } @COLUMNS;
185  
186 2973 print { $self->{fh} } join( "\t", @values ), "\n";
187 2973 return 1;
188 }
189  
190 4 ▶sub _open_xlsx {
Subroutine _open_xlsx: called CC=6 SCAR=17.9
191 4 my ($self) = @_;
192  
193 4 ▶ eval { require Excel::Writer::XLSX; 1 }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { require Excel::Writer::XLSX; 1 } } or die "Excel::Writer::XLSX is required for .xlsx terminology audits. Install the distribution dependencies and retry.\n" 4 0 4
194 or die
195 "Excel::Writer::XLSX is required for .xlsx terminology audits. Install the distribution dependencies and retry.\n";
196  
197 my $workbook = Excel::Writer::XLSX->new( $self->{path} )
198 4 ▶ or die "Failed to create XLSX terminology audit '$self->{path}'\n";
Branch: 1 branch
BranchTrueFalseTotal
my $workbook = "Excel::Writer::XLSX"->new($self->{"path"}) or die qq[Failed to create XLSX terminology audit '$self->{"path"}'\n] 4 0 4
199 4 my $summary = $workbook->add_worksheet('Summary');
200 4 my $audit = $workbook->add_worksheet('Terminology Audit');
201  
202 4 my $header_format = $workbook->add_format(
203 bold => 1,
204 color => 'white',
205 bg_color => '#1F4E78',
206 border => 1,
207 valign => 'vcenter',
208 );
209 4 my $summary_label_format = $workbook->add_format( bold => 1 );
210 4 my $score_format = $workbook->add_format( num_format => '0.0000' );
211  
212 4 my %row_format = (
213 resolved => $workbook->add_format( bg_color => '#E2F0D9' ),
214 review => $workbook->add_format( bg_color => '#FFF2CC' ),
215 unresolved => $workbook->add_format( bg_color => '#FCE4D6' ),
216 not_searched => $workbook->add_format( bg_color => '#E7E6E6' ),
217 preserved => $workbook->add_format( bg_color => '#DDEBF7' ),
218 );
219 4 my %legend_format = (
220 preserved => $workbook->add_format(
221 bold => 1, color => '#1F4E78', bg_color => '#DDEBF7', border => 1,
222 ),
223 resolved => $workbook->add_format(
224 bold => 1, color => 'white', bg_color => '#1B5E20', border => 1,
225 ),
226 review => $workbook->add_format(
227 bold => 1, color => '#5F4300', bg_color => '#FFD966', border => 1,
228 ),
229 unresolved => $workbook->add_format(
230 bold => 1, color => 'white', bg_color => '#8B0000', border => 1,
231 ),
232 not_searched => $workbook->add_format(
233 bold => 1, color => '#404040', bg_color => '#BFBFBF', border => 1,
234 ),
235 );
236  
237 4 $workbook->set_properties(
238 title => 'Convert-Pheno terminology audit',
239 subject => 'Terminology resolution and candidate review',
240 author => 'Convert-Pheno',
241 comments => 'Colors indicate review priority, not clinical confidence',
242 );
243  
244 4 $summary->write_row( 0, 0, [ 'Field', 'Value' ], $header_format );
245 4 $summary->set_column( 0, 0, 31 );
246 4 $summary->set_column( 1, 1, 58 );
247 4 $summary->freeze_panes(1, 0);
248  
249 4 for my $index ( 0 .. $#COLUMNS ) {
250 104 $audit->write_string( 0, $index, $COLUMNS[$index], $header_format );
251 }
252 4 $audit->freeze_panes( 1, 3 );
253 4 $audit->set_selection( 1, 0 );
254 4 $audit->set_zoom(85);
255  
256 4 my @widths = (
257 8, 18, 25, 28, 28, 28, 18, 32, 22, 14,
258 20, 20, 20, 18, 18, 16, 27, 29, 16, 20,
259 17, 20, 32, 22, 17, 17,
260 );
261 4 for my $index ( 0 .. $#widths ) {
262 104 $audit->set_column( $index, $index, $widths[$index] );
263 }
264  
265 # Keep the default workbook focused on review while retaining all evidence
266 # for users who choose to unhide the technical columns.
267 4 my @hidden_columns = ( 6, 9 .. 15, 18 .. 21 );
268 4 for my $index (@hidden_columns) {
269 48 $audit->set_column( $index, $index, $widths[$index], undef, 1 );
270 }
271  
272 4 $self->{format} = 'xlsx';
273 4 $self->{workbook} = $workbook;
274 4 $self->{summary_worksheet} = $summary;
275 4 $self->{audit_worksheet} = $audit;
276 4 $self->{header_format} = $header_format;
277 4 $self->{summary_label_format} = $summary_label_format;
278 4 $self->{score_format} = $score_format;
279 4 $self->{row_format} = \%row_format;
280 4 $self->{legend_format} = \%legend_format;
281 4 $self->{next_xlsx_row} = 1;
282 4 return 1;
283 }
284  
285 986 ▶sub _write_xlsx_row {
Subroutine _write_xlsx_row: called CC=9 SCAR=22.1
286 986 my ( $self, $row ) = @_;
287 die "XLSX terminology audits support at most "
288 . MAX_XLSX_DATA_ROWS
289 . " decisions; use .tsv.gz for larger runs\n"
290 986 ▶ if $self->{next_xlsx_row} > MAX_XLSX_DATA_ROWS;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"next_xlsx_row"} > 1048575 0 986 986
291  
292 986 my $worksheet = $self->{audit_worksheet};
293 986 my $xlsx_row = $self->{next_xlsx_row};
294  
295 986 for my $index ( 0 .. $#COLUMNS ) {
296 25636 my $column = $COLUMNS[$index];
297 25636 my $value = $row->{$column};
298 25636 ▶ next unless defined $value && length $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value and length $value 1997 23639 25636
Condition66%2/3
defined $value and length $value
!ll&&!rl&&r
1997023639
MC/DC50%1/2
defined $value and length $value
defined $value length $value
Truth table66%2/3
A and B
A= defined $valueB= length $value
ABresult
0X0
100
111
299  
300 23639 ▶ if ( $NUMERIC_COLUMN{$column} && _is_number($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($NUMERIC_COLUMN{$column} and _is_number($value)) { } 3946 19693 23639
Condition66%2/3
$NUMERIC_COLUMN{$column} and _is_number($value)
!ll&&!rl&&r
1969303946
MC/DC50%1/2
$NUMERIC_COLUMN{$column} and _is_number($value)
$NUMERIC_COLUMN{$column} _is_number($value)
Truth table66%2/3
A and B
A= $NUMERIC_COLUMN{$column}B= _is_number($value)
ABresult
0X0
100
111
301 my $format =
302 $column eq 'best_candidate_score' || $column eq 'score_margin'
303 ? $self->{score_format}
304 3946 ▶ : undef;
Branch: 1 branch
BranchTrueFalseTotal
$column eq 'best_candidate_score' || $column eq 'score_margin' ? : 993 2953 3946
Condition100%3/3
$column eq "best_candidate_score" or $column eq "score_margin"
l!l&&r!l&&!r
98582953
MC/DC100%2/2
$column eq "best_candidate_score" or $column eq "score_margin"
$column eq "best_candidate_score" $column eq "score_margin"
Truth table100%3/3
A or B
A= $column eq "best_candidate_score"B= $column eq "score_margin"
ABresult
1X1
011
000
305 3946 $worksheet->write_number( $xlsx_row, $index, $value, $format );
306 }
307 else {
308 # Explicit string writes prevent source values beginning with '='
309 # from being interpreted as spreadsheet formulas.
310 19693 $worksheet->write_string( $xlsx_row, $index, "$value" );
311 }
312 }
313  
314 986 $self->{next_xlsx_row}++;
315 986 return 1;
316 }
317  
318 4 ▶sub _close_xlsx {
Subroutine _close_xlsx: called CC=9 SCAR=22.0
319 4 my ($self) = @_;
320 4 my $summary = $self->{summary_worksheet};
321 4 my $config = $self->{config};
322 4 my $counts = $self->{counts};
323  
324 my @summary_rows = (
325 [ 'report_format', 'XLSX' ],
326 [ 'configured_search_mode', $config->{search} ],
327 [ 'text_similarity_method', $config->{text_similarity_method} ],
328 [ 'min_text_similarity_score', $config->{min_text_similarity_score} ],
329 [ 'levenshtein_weight', $config->{levenshtein_weight} ],
330 [ 'total_decisions', $self->{total_rows} ],
331 [ 'exact_or_direct', $counts->{resolved} ],
332 [ 'similarity_review', $counts->{review} ],
333 [ 'unresolved', $counts->{unresolved} ],
334 [ 'not_searched_or_source_fallback', $counts->{not_searched} ],
335 4 [ 'source_value_preserved', $counts->{preserved} ],
336 );
337 4 for my $index ( 0 .. $#summary_rows ) {
338 $summary->write_string(
339 $index + 1,
340 0,
341 $summary_rows[$index][0],
342 $self->{summary_label_format},
343 44 );
344 44 my $value = $summary_rows[$index][1];
345 44 ▶ if ( defined $value && _is_number($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value and _is_number($value)) { } 30 14 44
Condition100%3/3
defined $value and _is_number($value)
!ll&&!rl&&r
41030
MC/DC100%2/2
defined $value and _is_number($value)
defined $value _is_number($value)
Truth table100%3/3
A and B
A= defined $valueB= _is_number($value)
ABresult
0X0
100
111
346 30 $summary->write_number( $index + 1, 1, $value );
347 }
348 else {
349 14 ▶ $summary->write_string( $index + 1, 1, defined $value ? "$value" : q{} );
Branch: 1 branch
BranchTrueFalseTotal
defined $value ? : 10 4 14
350 }
351 }
352  
353 4 my $legend_row = @summary_rows + 3;
354 4 $summary->write_string( $legend_row, 0, 'Review colors', $self->{summary_label_format} );
355 4 my @legend = (
356 [ resolved => 'Exact, direct, or configured resolution' ],
357 [ review => 'Similarity or spelling result to review' ],
358 [ unresolved => 'No term emitted' ],
359 [ not_searched => 'Not searched or source fallback' ],
360 [ preserved => 'Source text deliberately retained; no ontology lookup attempted' ],
361 );
362 4 for my $index ( 0 .. $#legend ) {
363 20 my ( $category, $description ) = @{ $legend[$index] };
364 $summary->write_string(
365 $legend_row + $index + 1,
366 0,
367 $category,
368 20 $self->{legend_format}{$category},
369 );
370 20 $summary->write_string( $legend_row + $index + 1, 1, $description );
371 }
372 $summary->write_string(
373 $legend_row + @legend + 2,
374 0,
375 'Interpretation',
376 $self->{summary_label_format},
377 4 );
378 4 $summary->write_string(
379 $legend_row + @legend + 2,
380 1,
381 'Colors prioritize review; they do not measure clinical confidence.',
382 );
383 $summary->write_string(
384 $legend_row + @legend + 4,
385 0,
386 'Workbook view',
387 $self->{summary_label_format},
388 4 );
389 4 $summary->write_string(
390 $legend_row + @legend + 4,
391 1,
392 'Technical audit columns are present but hidden by default.',
393 );
394  
395 4 my $audit = $self->{audit_worksheet};
396 4 $audit->autofilter( 0, 0, $self->{total_rows}, $#COLUMNS );
397 4 ▶ if ( $self->{total_rows} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"total_rows"}) 4 0 4
398 4 my $last_row = $self->{total_rows} + 1;
399 4 my $range = "A2:Z$last_row";
400 4 my @rules = (
401 [ preserved => '=$P2="preserved"' ],
402 [ unresolved => '=$P2="not_found"' ],
403 [ not_searched => '=OR($P2="not_searched",$Q2="source_fallback")' ],
404 [ review => '=AND($P2<>"preserved",$P2<>"not_found",$P2<>"not_searched",$Q2<>"source_fallback",OR($T2="similarity",$V2="one_token_relaxed"))' ],
405 [ resolved => '=AND($P2<>"preserved",$P2<>"not_found",$P2<>"not_searched",$Q2<>"source_fallback",$T2<>"similarity",$V2<>"one_token_relaxed")' ],
406 );
407 4 for my $rule (@rules) {
408 $audit->conditional_formatting(
409 $range,
410 {
411 type => 'formula',
412 criteria => $rule->[1],
413 20 format => $self->{row_format}{ $rule->[0] },
414 }
415 );
416 }
417 }
418  
419 $self->{workbook}->close()
420 4 ▶ or die "Failed to finalize XLSX terminology audit '$self->{path}'\n";
Branch: 1 branch
BranchTrueFalseTotal
$self->{"workbook"}->close or die qq[Failed to finalize XLSX terminology audit '$self->{"path"}'\n] 4 0 4
421 4 return 1;
422 }
423  
424 7918 ▶sub _review_category {
Subroutine _review_category: called CC=13 SCAR=26.5
425 7918 my ($row) = @_;
426 7918 ▶ return 'preserved' if ($row->{match_status} // q{}) eq 'preserved';
Branch: 1 branch
BranchTrueFalseTotal
if ($row->{"match_status"} // "") eq "preserved" 4 7914 7918
Condition50%1/2
$row->{"match_status"} // ""
l!l
79180
MC/DC0%0/1
$row->{"match_status"} // ""
$row->{"match_status"}
Truth table50%1/2
A
A= $row->{"match_status"}
Aresult
11
00
427 7914 ▶ return 'unresolved' if ( $row->{match_status} // q{} ) eq 'not_found';
Branch: 1 branch
BranchTrueFalseTotal
if ($row->{"match_status"} // "") eq "not_found" 612 7302 7914
Condition50%1/2
$row->{"match_status"} // ""
l!l
79140
MC/DC0%0/1
$row->{"match_status"} // ""
$row->{"match_status"}
Truth table50%1/2
A
A= $row->{"match_status"}
Aresult
11
00
428 return 'not_searched'
429 if ( $row->{match_status} // q{} ) eq 'not_searched'
430 7302 ▶ || ( $row->{decision_reason} // q{} ) eq 'source_fallback';
Branch: 1 branch
BranchTrueFalseTotal
if ($row->{"match_status"} // "") eq "not_searched" or ($row->{"decision_reason"} // "") eq "source_fallback" 38 7264 7302
Condition71%5/7
($row->{"match_status"} // "") eq "not_searched" or ($row->{"decision_reason"} // "") eq "source_fallback"
l!l&&r!l&&!r
3807264
$row->{"match_status"} // ""
l!l
73020
$row->{"decision_reason"} // ""
l!l
7054210
MC/DC0%0/2
($row->{"match_status"} // "") eq "not_searched" or ($row->{"decision_reason"} // "") eq "source_fallback"
$row->{"match_status"} $row->{"decision_reason"}
Truth table33%1/3
A or B
A= $row->{"match_status"}B= $row->{"decision_reason"}
ABresult
1X1
011
000
431 return 'review'
432 if ( $row->{lookup_resolution} // q{} ) eq 'similarity'
433 7264 ▶ || ( $row->{retrieval_path} // q{} ) eq 'one_token_relaxed';
Branch: 1 branch
BranchTrueFalseTotal
if ($row->{"lookup_resolution"} // "") eq "similarity" or ($row->{"retrieval_path"} // "") eq "one_token_relaxed" 2 7262 7264
Condition71%5/7
($row->{"lookup_resolution"} // "") eq "similarity" or ($row->{"retrieval_path"} // "") eq "one_token_relaxed"
l!l&&r!l&&!r
207262
$row->{"lookup_resolution"} // ""
l!l
72640
$row->{"retrieval_path"} // ""
l!l
7052210
MC/DC0%0/2
($row->{"lookup_resolution"} // "") eq "similarity" or ($row->{"retrieval_path"} // "") eq "one_token_relaxed"
$row->{"lookup_resolution"} $row->{"retrieval_path"}
Truth table33%1/3
A or B
A= $row->{"lookup_resolution"}B= $row->{"retrieval_path"}
ABresult
1X1
011
000
434 7262 return 'resolved';
435 }
436  
437 3959 ▶sub _review_action {
Subroutine _review_action: called CC=5 SCAR=16.1
438 3959 my ($row) = @_;
439 3959 my $category = _review_category($row);
440 3959 ▶ return 'preserve_source' if $category eq 'preserved';
Branch: 1 branch
BranchTrueFalseTotal
if $category eq "preserved" 2 3957 3959
441 3957 ▶ return 'keep' if $category eq 'resolved';
Branch: 1 branch
BranchTrueFalseTotal
if $category eq "resolved" 3631 326 3957
442 326 ▶ return 'review_similarity' if $category eq 'review';
Branch: 1 branch
BranchTrueFalseTotal
if $category eq "review" 1 325 326
443 325 ▶ return 'resolve_or_accept_fallback' if $category eq 'unresolved';
Branch: 1 branch
BranchTrueFalseTotal
if $category eq "unresolved" 306 19 325
444 19 return 'review_source_fallback';
445 }
446  
447 77298 ▶sub _tsv_field {
Subroutine _tsv_field: called CC=2 SCAR=6.9
448 77298 my ($value) = @_;
449 77298 ▶ return q{} unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 9153 68145 77298
450 68145 $value =~ s/[\t\r\n]+/ /g;
451 68145 return $value;
452 }
453  
454 3986 ▶sub _is_number {
Subroutine _is_number: called CC=2 SCAR=7.1
455 3986 my ($value) = @_;
456 3986 ▶ return defined $value
Condition66%2/3
defined $value && $value =~ /\A[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?\z/
!ll&&!rl&&r
0103976
MC/DC50%1/2
defined $value && $value =~ /\A[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?\z/
defined $value $value =~ /\A[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?\z/
Truth table66%2/3
A && B
A= defined $valueB= $value =~ /\A[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?\z/
ABresult
0X0
100
111
457 && $value =~ /\A[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[Ee][+-]?\d+)?\z/;
458 }
459  
460 143 1;
« lib/Convert/Pheno/ClinicalCDM/ToBFF.pm ↑ Summary lib/Convert/Pheno/Source/OpenEHR.pm »