lib/Convert/Pheno/OpenEHR/ToBFF.pm

filter: Statementstmt 90.0% 372 / 413 Branchbran 62.5% 190 / 304 Conditioncond 47.3% 105 / 222 MC/DCmcdc 15.7% 20 / 127 Subroutinesub 94.0% 47 / 50 Podpod 0.0% 0 / 5 totaltotal 65.4% 734 / 1121 CC 245 SCAR 31.2
CC
245
Cov
71%
__ANON__
210.0
_quantity_from_dv_quantity
28.8
resolve_openehr_patient_id
25.9
CRAP 22.6
« lib/Convert/Pheno/IO/Atomic.pm ↑ Summary bin/convert-pheno »
1 package Convert::Pheno::OpenEHR::ToBFF;
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  
7 136 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 136 ▶use JSON::PP ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 136 ▶use Convert::Pheno::Context;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 136 ▶use Convert::Pheno::Model::Bundle;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 136 ▶use Convert::Pheno::Utils::Default qw(get_defaults);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 136 our @EXPORT_OK = qw(
15 do_openehr2bff
16 run_openehr_to_bundle
17 extract_openehr_compositions
18 resolve_openehr_embedded_patient_id
19 resolve_openehr_patient_id
20 );
21 136 my $DEFAULT = get_defaults();
22  
23 0 ▶sub do_openehr2bff {
Subroutine do_openehr2bff: not called CC=1 SCAR=6.9
Pod undocumented
24 0 my ( $self, $data ) = @_;
25 0 my $bundle = run_openehr_to_bundle( $self, $data, $self->{conversion_context} );
26 0 return $bundle->primary_entity('individuals');
27 }
28  
29 20 ▶sub run_openehr_to_bundle {
Subroutine run_openehr_to_bundle: called CC=13 SCAR=28.6
Pod undocumented
30 20 my ( $self, $data, $context ) = @_;
31  
32 $context ||= Convert::Pheno::Context->from_self(
33 $self,
34 {
35 source_format => 'openehr',
36 target_format => 'beacon',
37 20 ▶ entities => $self->{entities} || ['individuals'],
Condition20%1/5
$context ||= "Convert::Pheno::Context"->from_self($self, {"source_format", "openehr", "target_format", "beacon", "entities", $self->{"entities"} || ["individuals"]})
l!l&&r!l&&!r
2000
$self->{'entities'} || ['individuals']
l!l
00
MC/DC0%0/2
$context ||= "Convert::Pheno::Context"->from_self($self, {"source_format", "openehr", "target_format", "beacon", "entities", $self->{"entities"} || ["individuals"]})
$context "Convert::Pheno::Context"->from_self($self, {"source_format", "openehr", "target_format", "beacon", "entities", $self->{"entities"} || ["individuals"]})
MC/DC0%0/1
$self->{'entities'} || ['individuals']
$self->{'entities'}
Truth table33%1/3
A ||= B
A= $contextB= "Convert::Pheno::Context"->from_self($self, {"source_format", "openehr", "target_format", "beacon", "entities", $self->{"entities"} || ["individuals"]})
ABresult
1X1
011
000
Truth table0%0/2
A
A= $self->{'entities'}
Aresult
11
00
38 }
39 );
40  
41 20 my $bundle = Convert::Pheno::Model::Bundle->new(
42 {
43 context => $context,
44 entities => $context->entities,
45 }
46 );
47  
48 20 my $compositions = extract_openehr_compositions($data);
49 20 _validate_compositions($compositions);
50  
51 20 my $id = resolve_openehr_patient_id( $self, $data, $compositions );
52 20 my $sex = _resolve_sex($compositions);
53 20 my $mapped = _map_first_class_arrays($compositions);
54  
55 20 ▶ die "The input <openEHR> data could not be resolved to a patient id; please provide one composition set with a stable patient identifier in the payload or envelope\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id and length $id 0 20 20
Condition33%1/3
defined $id and length $id
!ll&&!rl&&r
0020
MC/DC0%0/2
defined $id and length $id
defined $id length $id
Truth table33%1/3
A and B
A= defined $idB= length $id
ABresult
0X0
100
111
56 unless defined $id && length $id;
57 20 ▶ die "The input <openEHR> data could not be resolved to <sex>; please include a demographic composition carrying administrative gender\n"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $sex 0 20 20
58 unless defined $sex;
59  
60 20 my $individual = {
61 id => $id,
62 sex => $sex,
63 };
64  
65 20 ▶ if ( $self->{source_info} // 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'source_info'} // 1) { } 19 1 20
Condition50%1/2
$self->{"source_info"} // 1
l!l
200
MC/DC0%0/1
$self->{"source_info"} // 1
$self->{"source_info"}
Truth table50%1/2
A
A= $self->{"source_info"}
Aresult
11
00
66 19 $individual->{info}{openehr}{compositions} = $compositions;
67 }
68 else {
69 1 _remove_source_info($mapped);
70 }
71  
72 20 for my $field ( qw(diseases measures phenotypicFeatures interventionsOrProcedures treatments) ) {
73 100 ▶ next unless exists $mapped->{$field} && @{ $mapped->{$field} };
Branch: 1 branch
BranchTrueFalseTotal
unless exists $mapped->{$field} and @{$mapped->{$field};} 75 25 100
Condition66%2/3
exists $mapped->{$field} and @{$mapped->{$field};}
!ll&&!rl&&r
07525
MC/DC50%1/2
exists $mapped->{$field} and @{$mapped->{$field};}
exists $mapped->{$field} @{$mapped->{$field};}
Truth table66%2/3
A and B
A= exists $mapped->{$field}B= @{$mapped->{$field};}
ABresult
0X0
100
111
74 25 $individual->{$field} = $mapped->{$field};
75 }
76  
77 20 ▶ unless ( $self->{test} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"test"}) 0 20 20
78 $individual->{info}{convertPheno} = $self->{convertPheno}
79 0 ▶ if defined $self->{convertPheno};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"convertPheno"} 0 0 0
80 }
81  
82 20 $bundle->add_entity( individuals => $individual );
83 20 return $bundle;
84 }
85  
86 55 ▶sub _remove_source_info {
Subroutine _remove_source_info: called CC=8 SCAR=20.8
87 55 my ($node) = @_;
88 55 ▶ return unless ref($node);
Branch: 1 branch
BranchTrueFalseTotal
unless ref $node 26 29 55
89  
90 29 ▶ if ( ref($node) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node eq "HASH") 24 5 29
91 24 ▶ if ( ref( $node->{_info} ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node->{"_info"} eq "HASH") 7 17 24
92 7 delete $node->{_info}{openEHR};
93 7 ▶ delete $node->{_info} unless keys %{ $node->{_info} };
Branch: 1 branch
BranchTrueFalseTotal
unless keys %{$$node{"_info"};} 7 0 7
94 }
95 24 _remove_source_info($_) for values %{$node};
96 24 return;
97 }
98  
99 5 ▶ if ( ref($node) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node eq "ARRAY") 5 0 5
100 5 _remove_source_info($_) for @{$node};
101 }
102 5 return;
103 }
104  
105 73 ▶sub extract_openehr_compositions {
Subroutine extract_openehr_compositions: called CC=6 SCAR=25.0
Pod undocumented
106 73 my ($data) = @_;
107  
108 73 ▶ return [] unless defined $data;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $data 0 73 73
109  
110 73 ▶ if ( ref($data) eq 'HASH' && exists $data->{compositions} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq "HASH" and exists $data->{"compositions"}) 73 0 73
Condition33%1/3
ref $data eq "HASH" and exists $data->{"compositions"}
!ll&&!rl&&r
0073
MC/DC0%0/2
ref $data eq "HASH" and exists $data->{"compositions"}
ref $data eq "HASH" exists $data->{"compositions"}
Truth table33%1/3
A and B
A= ref $data eq "HASH"B= exists $data->{"compositions"}
ABresult
0X0
100
111
111 73 ▶ return $data->{compositions} if ref( $data->{compositions} ) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $data->{"compositions"} eq "ARRAY" 73 0 73
112 0 return [ $data->{compositions} ];
113 }
114  
115 0 ▶ return $data if ref($data) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $data eq "ARRAY" 0 0 0
116 0 return [$data];
117 }
118  
119 20 ▶sub _validate_compositions {
Subroutine _validate_compositions: called CC=8 SCAR=24.7
120 20 my ($compositions) = @_;
121 die "The input <openEHR> payload does not contain any compositions\n"
122 20 ▶ unless defined $compositions && ref($compositions) eq 'ARRAY' && @{$compositions};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $compositions and ref $compositions eq "ARRAY" and @{$compositions;} 0 20 20
Condition33%2/6
defined $compositions and ref $compositions eq "ARRAY" and @{$compositions;}
!ll&&!rl&&r
0020
defined $compositions and ref $compositions eq "ARRAY"
!ll&&!rl&&r
0020
MC/DC0%0/3
defined $compositions and ref $compositions eq "ARRAY" and @{$compositions;}
defined $compositions ref $compositions eq "ARRAY" @{$compositions;}
Truth table25%1/4
A and B and C
A= defined $compositionsB= ref $compositions eq "ARRAY"C= @{$compositions;}
ABCresult
0XX0
10X0
1100
1111
123  
124 20 for my $composition ( @{$compositions} ) {
125 33 ▶ die "Each openEHR input item must be a JSON object\n"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $composition eq "HASH" 0 33 33
126 unless ref($composition) eq 'HASH';
127 die "Each openEHR input item must be a canonical <COMPOSITION> JSON document\n"
128 33 ▶ unless defined $composition->{_type} && $composition->{_type} eq 'COMPOSITION';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $composition->{"_type"} and $composition->{"_type"} eq "COMPOSITION" 0 33 33
Condition33%1/3
defined $composition->{"_type"} and $composition->{"_type"} eq "COMPOSITION"
!ll&&!rl&&r
0033
MC/DC0%0/2
defined $composition->{"_type"} and $composition->{"_type"} eq "COMPOSITION"
defined $composition->{"_type"} $composition->{"_type"} eq "COMPOSITION"
Truth table33%1/3
A and B
A= defined $composition->{"_type"}B= $composition->{"_type"} eq "COMPOSITION"
ABresult
0X0
100
111
129 }
130  
131 20 return 1;
132 }
133  
134 41 ▶sub resolve_openehr_patient_id {
Subroutine resolve_openehr_patient_id: called CC=20 SCAR=32.6
Pod undocumented
135 41 my ( $self, $data, $compositions ) = @_;
136  
137 41 ▶ $compositions ||= extract_openehr_compositions($data);
Condition66%2/3
$compositions ||= extract_openehr_compositions($data)
l!l&&r!l&&!r
20210
MC/DC0%0/2
$compositions ||= extract_openehr_compositions($data)
$compositions extract_openehr_compositions($data)
Truth table66%2/3
A ||= B
A= $compositionsB= extract_openehr_compositions($data)
ABresult
1X1
011
000
138  
139 41 ▶ if ( ref($data) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq "HASH") 41 0 41
140 return $data->{patient}{id}
141 if exists $data->{patient}
142 && ref( $data->{patient} ) eq 'HASH'
143 && defined $data->{patient}{id}
144 41 ▶ && length $data->{patient}{id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $data->{"patient"} and ref $data->{"patient"} eq "HASH" and defined $data->{"patient"}{"id"} and length $data->{"patient"}{"id"} 30 11 41
Condition66%6/9
exists $data->{"patient"} and ref $data->{"patient"} eq "HASH" and defined $data->{"patient"}{"id"} and length $data->{"patient"}{"id"}
!ll&&!rl&&r
11030
exists $data->{"patient"} and ref $data->{"patient"} eq "HASH" and defined $data->{"patient"}{"id"}
!ll&&!rl&&r
11030
exists $data->{"patient"} and ref $data->{"patient"} eq "HASH"
!ll&&!rl&&r
11030
MC/DC25%1/4
exists $data->{"patient"} and ref $data->{"patient"} eq "HASH" and defined $data->{"patient"}{"id"} and length $data->{"patient"}{"id"}
exists $data->{"patient"} ref $data->{"patient"} eq "HASH" defined $data->{"patient"}{"id"} length $data->{"patient"}{"id"}
Truth table40%2/5
A and B and C and D
A= exists $data->{"patient"}B= ref $data->{"patient"} eq "HASH"C= defined $data->{"patient"}{"id"}D= length $data->{"patient"}{"id"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
145  
146 return $data->{id}
147 11 ▶ if defined $data->{id} && !ref( $data->{id} ) && length $data->{id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $data->{"id"} and not ref $data->{"id"} and length $data->{"id"} 0 11 11
Condition33%2/6
defined $data->{"id"} and not ref $data->{"id"} and length $data->{"id"}
!ll&&!rl&&r
1100
defined $data->{"id"} and not ref $data->{"id"}
!ll&&!rl&&r
1100
MC/DC0%0/3
defined $data->{"id"} and not ref $data->{"id"} and length $data->{"id"}
defined $data->{"id"} not ref $data->{"id"} length $data->{"id"}
Truth table25%1/4
A and not(B) and C
A= defined $data->{"id"}B= not ref $data->{"id"}C= length $data->{"id"}
ABCresult
0XX0
10X0
1100
1111
148  
149 my $ehr_status_subject_id = _extract_party_proxy_external_ref_id( $data->{ehr_status}{subject} )
150 11 ▶ if exists $data->{ehr_status} && ref( $data->{ehr_status} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if exists $data->{"ehr_status"} and ref $data->{"ehr_status"} eq "HASH" 1 10 11
Condition66%2/3
exists $data->{"ehr_status"} and ref $data->{"ehr_status"} eq "HASH"
!ll&&!rl&&r
1001
MC/DC50%1/2
exists $data->{"ehr_status"} and ref $data->{"ehr_status"} eq "HASH"
exists $data->{"ehr_status"} ref $data->{"ehr_status"} eq "HASH"
Truth table66%2/3
A and B
A= exists $data->{"ehr_status"}B= ref $data->{"ehr_status"} eq "HASH"
ABresult
0X0
100
111
151 11 ▶ return $ehr_status_subject_id
Branch: 1 branch
BranchTrueFalseTotal
if defined $ehr_status_subject_id and length $ehr_status_subject_id 1 10 11
Condition66%2/3
defined $ehr_status_subject_id and length $ehr_status_subject_id
!ll&&!rl&&r
1001
MC/DC50%1/2
defined $ehr_status_subject_id and length $ehr_status_subject_id
defined $ehr_status_subject_id length $ehr_status_subject_id
Truth table66%2/3
A and B
A= defined $ehr_status_subject_idB= length $ehr_status_subject_id
ABresult
0X0
100
111
152 if defined $ehr_status_subject_id && length $ehr_status_subject_id;
153  
154 10 my $ehr_id = _extract_identifier_value( $data->{ehr_id} );
155 10 ▶ return $ehr_id if defined $ehr_id && length $ehr_id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $ehr_id and length $ehr_id 1 9 10
Condition66%2/3
defined $ehr_id and length $ehr_id
!ll&&!rl&&r
901
MC/DC50%1/2
defined $ehr_id and length $ehr_id
defined $ehr_id length $ehr_id
Truth table66%2/3
A and B
A= defined $ehr_idB= length $ehr_id
ABresult
0X0
100
111
156 }
157  
158 9 ▶ if ( ref($compositions) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $compositions eq "ARRAY") 9 0 9
159 9 for my $composition ( @{$compositions} ) {
160 9 my $subject_id = _find_party_self_external_ref_id($composition);
161 9 ▶ return $subject_id if defined $subject_id && length $subject_id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $subject_id and length $subject_id 8 1 9
Condition66%2/3
defined $subject_id and length $subject_id
!ll&&!rl&&r
108
MC/DC50%1/2
defined $subject_id and length $subject_id
defined $subject_id length $subject_id
Truth table66%2/3
A and B
A= defined $subject_idB= length $subject_id
ABresult
0X0
100
111
162 }
163 }
164  
165 1 return;
166 }
167  
168 6 ▶sub resolve_openehr_embedded_patient_id {
Subroutine resolve_openehr_embedded_patient_id: called CC=11 SCAR=30.1
Pod undocumented
169 6 my ( $data, $compositions ) = @_;
170  
171 6 ▶ $compositions ||= extract_openehr_compositions($data);
Condition33%1/3
$compositions ||= extract_openehr_compositions($data)
l!l&&r!l&&!r
600
MC/DC0%0/2
$compositions ||= extract_openehr_compositions($data)
$compositions extract_openehr_compositions($data)
Truth table33%1/3
A ||= B
A= $compositionsB= extract_openehr_compositions($data)
ABresult
1X1
011
000
172  
173 6 ▶ if ( ref($data) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $data eq "HASH") 6 0 6
174 my $ehr_status_subject_id = _extract_party_proxy_external_ref_id( $data->{ehr_status}{subject} )
175 6 ▶ if exists $data->{ehr_status} && ref( $data->{ehr_status} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
if exists $data->{"ehr_status"} and ref $data->{"ehr_status"} eq "HASH" 0 6 6
Condition33%1/3
exists $data->{"ehr_status"} and ref $data->{"ehr_status"} eq "HASH"
!ll&&!rl&&r
600
MC/DC0%0/2
exists $data->{"ehr_status"} and ref $data->{"ehr_status"} eq "HASH"
exists $data->{"ehr_status"} ref $data->{"ehr_status"} eq "HASH"
Truth table33%1/3
A and B
A= exists $data->{"ehr_status"}B= ref $data->{"ehr_status"} eq "HASH"
ABresult
0X0
100
111
176 6 ▶ return $ehr_status_subject_id
Branch: 1 branch
BranchTrueFalseTotal
if defined $ehr_status_subject_id and length $ehr_status_subject_id 0 6 6
Condition33%1/3
defined $ehr_status_subject_id and length $ehr_status_subject_id
!ll&&!rl&&r
600
MC/DC0%0/2
defined $ehr_status_subject_id and length $ehr_status_subject_id
defined $ehr_status_subject_id length $ehr_status_subject_id
Truth table33%1/3
A and B
A= defined $ehr_status_subject_idB= length $ehr_status_subject_id
ABresult
0X0
100
111
177 if defined $ehr_status_subject_id && length $ehr_status_subject_id;
178 }
179  
180 6 ▶ if ( ref($compositions) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $compositions eq "ARRAY") 6 0 6
181 6 for my $composition ( @{$compositions} ) {
182 6 my $subject_id = _find_party_self_external_ref_id($composition);
183 6 ▶ return $subject_id if defined $subject_id && length $subject_id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $subject_id and length $subject_id 6 0 6
Condition33%1/3
defined $subject_id and length $subject_id
!ll&&!rl&&r
006
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
ABresult
0X0
100
111
184 }
185 }
186  
187 0 return;
188 }
189  
190 25 ▶sub _extract_identifier_value {
Subroutine _extract_identifier_value: called CC=8 SCAR=27.1
191 25 my ($value) = @_;
192 25 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 9 16 25
193  
194 16 ▶ return $value
Branch: 1 branch
BranchTrueFalseTotal
if not ref $value and length $value 0 16 16
Condition33%1/3
not ref $value and length $value
!ll&&!rl&&r
1600
MC/DC0%0/2
not ref $value and length $value
not ref $value length $value
Truth table33%1/3
not(A) and B
A= not ref $valueB= length $value
ABresult
0X0
100
111
195 if !ref($value) && length $value;
196  
197 return $value->{value}
198 if ref($value) eq 'HASH'
199 && defined $value->{value}
200 && !ref( $value->{value} )
201 16 ▶ && length $value->{value};
Branch: 1 branch
BranchTrueFalseTotal
if ref $value eq "HASH" and defined $value->{"value"} and not ref $value->{"value"} and length $value->{"value"} 16 0 16
Condition33%3/9
ref $value eq "HASH" and defined $value->{"value"} and not ref $value->{"value"} and length $value->{"value"}
!ll&&!rl&&r
0016
ref $value eq "HASH" and defined $value->{"value"} and not ref $value->{"value"}
!ll&&!rl&&r
0016
ref $value eq "HASH" and defined $value->{"value"}
!ll&&!rl&&r
0016
MC/DC0%0/4
ref $value eq "HASH" and defined $value->{"value"} and not ref $value->{"value"} and length $value->{"value"}
ref $value eq "HASH" defined $value->{"value"} not ref $value->{"value"} length $value->{"value"}
Truth table20%1/5
A and B and not(C) and D
A= ref $value eq "HASH"B= defined $value->{"value"}C= not ref $value->{"value"}D= length $value->{"value"}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
202  
203 0 return;
204 }
205  
206 24 ▶sub _extract_party_proxy_external_ref_id {
Subroutine _extract_party_proxy_external_ref_id: called CC=4 SCAR=14.1
207 24 my ($party) = @_;
208 24 ▶ return unless ref($party) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $party eq "HASH" 0 24 24
209 24 ▶ return unless exists $party->{external_ref} && ref( $party->{external_ref} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless exists $party->{"external_ref"} and ref $party->{"external_ref"} eq "HASH" 9 15 24
Condition66%2/3
exists $party->{"external_ref"} and ref $party->{"external_ref"} eq "HASH"
!ll&&!rl&&r
9015
MC/DC50%1/2
exists $party->{"external_ref"} and ref $party->{"external_ref"} eq "HASH"
exists $party->{"external_ref"} ref $party->{"external_ref"} eq "HASH"
Truth table66%2/3
A and B
A= exists $party->{"external_ref"}B= ref $party->{"external_ref"} eq "HASH"
ABresult
0X0
100
111
210 15 return _extract_identifier_value( $party->{external_ref}{id} );
211 }
212  
213 2095 ▶sub _find_party_self_external_ref_id {
Subroutine _find_party_self_external_ref_id: called CC=12 SCAR=24.9
214 2095 my ($node) = @_;
215 2095 ▶ return unless defined $node;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node 0 2095 2095
216  
217 2095 ▶ if ( ref($node) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node eq "HASH") 785 1310 2095
218 785 ▶ if ( ( $node->{_type} || '' ) eq 'PARTY_SELF' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (($node->{"_type"} || "") eq "PARTY_SELF") 23 762 785
Condition100%2/2
$node->{'_type'} || ''
l!l
518267
MC/DC100%1/1
$node->{'_type'} || ''
$node->{'_type'}
Truth table100%2/2
A
A= $node->{'_type'}
Aresult
11
00
219 23 my $id = _extract_party_proxy_external_ref_id($node);
220 23 ▶ return $id if defined $id && length $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id and length $id 14 9 23
Condition66%2/3
defined $id and length $id
!ll&&!rl&&r
9014
MC/DC50%1/2
defined $id and length $id
defined $id length $id
Truth table66%2/3
A and B
A= defined $idB= length $id
ABresult
0X0
100
111
221 }
222  
223 771 for my $value ( values %{$node} ) {
224 1927 my $id = _find_party_self_external_ref_id($value);
225 1927 ▶ return $id if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 14 1913 1927
226 }
227  
228 757 return;
229 }
230  
231 1310 ▶ if ( ref($node) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node eq "ARRAY") 54 1256 1310
232 54 for my $entry ( @{$node} ) {
233 153 my $id = _find_party_self_external_ref_id($entry);
234 153 ▶ return $id if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 0 153 153
235 }
236 }
237  
238 1310 return;
239 }
240  
241 20 ▶sub _resolve_sex {
Subroutine _resolve_sex: called CC=3 SCAR=11.3
242 20 my ($compositions) = @_;
243  
244 20 for my $composition ( @{$compositions} ) {
245 20 my $code = _find_gender_code($composition);
246 20 ▶ next unless defined $code;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code 0 20 20
247 20 return _map_gender_code($code);
248 }
249  
250 0 return;
251 }
252  
253 11506 ▶sub _find_gender_code {
Subroutine _find_gender_code: called CC=17 SCAR=28.7
254 11506 my ($node) = @_;
255 11506 ▶ return unless defined $node;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node 0 11506 11506
256  
257 11506 ▶ if ( ref($node) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node eq "HASH") 4083 7423 11506
258 4083 ▶ if ( exists $node->{name}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $node->{"name"} and ref $node->{"name"} eq "HASH" and defined $node->{"name"}{"value"} and _matches_administrative_gender_name($node->{"name"}{"value"}) and exists $node->{"value"} and ref $node->{"value"} eq "HASH" and exists $node->{"value"}{"defining_code"} and ref $node->{"value"}{"defining_code"} eq "HASH" and defined $node->{"value"}{"defining_code"}{"code_string"}) 20 4063 4083
Condition75%18/24
exists $node->{"name"} and ref $node->{"name"} eq "HASH" and defined $node->{"name"}{"value"} and _matches_administrative_gender_name($node->{"name"}{"value"}) and exists $node->{"value"} and ref $node->{"value"} eq "HASH" and exists $node->{"value"}{"defining_code"} and ref $node->{"value"}{"defining_code"} eq "HASH" and defined $node->{"value"}{"defining_code"}{"code_string"}
!ll&&!rl&&r
4063020
exists $node->{"name"} and ref $node->{"name"} eq "HASH" and defined $node->{"name"}{"value"} and _matches_administrative_gender_name($node->{"name"}{"value"}) and exists $node->{"value"} and ref $node->{"value"} eq "HASH" and exists $node->{"value"}{"defining_code"} and ref $node->{"value"}{"defining_code"} eq "HASH"
!ll&&!rl&&r
4063020
exists $node->{"name"} and ref $node->{"name"} eq "HASH" and defined $node->{"name"}{"value"} and _matches_administrative_gender_name($node->{"name"}{"value"}) and exists $node->{"value"} and ref $node->{"value"} eq "HASH" and exists $node->{"value"}{"defining_code"}
!ll&&!rl&&r
4063020
exists $node->{"name"} and ref $node->{"name"} eq "HASH" and defined $node->{"name"}{"value"} and _matches_administrative_gender_name($node->{"name"}{"value"}) and exists $node->{"value"} and ref $node->{"value"} eq "HASH"
!ll&&!rl&&r
4063020
exists $node->{"name"} and ref $node->{"name"} eq "HASH" and defined $node->{"name"}{"value"} and _matches_administrative_gender_name($node->{"name"}{"value"}) and exists $node->{"value"}
!ll&&!rl&&r
4063020
exists $node->{"name"} and ref $node->{"name"} eq "HASH" and defined $node->{"name"}{"value"} and _matches_administrative_gender_name($node->{"name"}{"value"})
!ll&&!rl&&r
2961110220
exists $node->{"name"} and ref $node->{"name"} eq "HASH" and defined $node->{"name"}{"value"}
!ll&&!rl&&r
296101122
exists $node->{"name"} and ref $node->{"name"} eq "HASH"
!ll&&!rl&&r
295381122
MC/DC33%3/9
exists $node->{"name"} and ref $node->{"name"} eq "HASH" and defined $node->{"name"}{"value"} and _matches_administrative_gender_name($node->{"name"}{"value"}) and exists $node->{"value"} and ref $node->{"value"} eq "HASH" and exists $node->{"value"}{"defining_code"} and ref $node->{"value"}{"defining_code"} eq "HASH" and defined $node->{"value"}{"defining_code"}{"code_string"}
exists $node->{"name"} ref $node->{"name"} eq "HASH" defined $node->{"name"}{"value"} _matches_administrative_gender_name($node->{"name"}{"value"}) exists $node->{"value"} ref $node->{"value"} eq "HASH" exists $node->{"value"}{"defining_code"} ref $node->{"value"}{"defining_code"} eq "HASH" defined $node->{"value"}{"defining_code"}{"code_string"}
Truth table40%4/10
A and B and C and D and E and F and G and H and I
A= exists $node->{"name"}B= ref $node->{"name"} eq "HASH"C= defined $node->{"name"}{"value"}D= _matches_administrative_gender_name($node->{"name"}{"value"})E= exists $node->{"value"}F= ref $node->{"value"} eq "HASH"G= exists $node->{"value"}{"defining_code"}H= ref $node->{"value"}{"defining_code"} eq "HASH"I= defined $node->{"value"}{"defining_code"}{"code_string"}
ABCDEFGHIresult
0XXXXXXXX0
10XXXXXXX0
110XXXXXX0
1110XXXXX0
11110XXXX0
111110XXX0
1111110XX0
11111110X0
1111111100
1111111111
259 && ref( $node->{name} ) eq 'HASH'
260 && defined $node->{name}{value}
261 && _matches_administrative_gender_name( $node->{name}{value} )
262 && exists $node->{value}
263 && ref( $node->{value} ) eq 'HASH'
264 && exists $node->{value}{defining_code}
265 && ref( $node->{value}{defining_code} ) eq 'HASH'
266 && defined $node->{value}{defining_code}{code_string} )
267 {
268 20 return lc $node->{value}{defining_code}{code_string};
269 }
270  
271 4063 for my $value ( values %{$node} ) {
272 10486 my $code = _find_gender_code($value);
273 10486 ▶ return $code if defined $code;
Branch: 1 branch
BranchTrueFalseTotal
if defined $code 60 10426 10486
274 }
275  
276 4003 return;
277 }
278  
279 7423 ▶ if ( ref($node) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node eq "ARRAY") 342 7081 7423
280 342 for my $entry ( @{$node} ) {
281 1000 my $code = _find_gender_code($entry);
282 1000 ▶ return $code if defined $code;
Branch: 1 branch
BranchTrueFalseTotal
if defined $code 40 960 1000
283 }
284 }
285  
286 7383 return;
287 }
288  
289 20 ▶sub _map_gender_code {
Subroutine _map_gender_code: called CC=6 SCAR=21.4
290 20 my ($code) = @_;
291 20 ▶ return unless defined $code;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code 0 20 20
292 20 $code = lc $code;
293  
294 20 ▶ return { %{ $DEFAULT->{sex}{male} } } if $code eq 'male';
Branch: 1 branch
BranchTrueFalseTotal
if $code eq "male" 19 1 20
295 0 ▶ return { %{ $DEFAULT->{sex}{female} } } if $code eq 'female';
Branch: 1 branch
BranchTrueFalseTotal
if $code eq "female" 0 1 1
296 1 ▶ return { %{ $DEFAULT->{sex}{other} } } if $code eq 'other';
Branch: 1 branch
BranchTrueFalseTotal
if $code eq "other" 1 0 1
297 0 ▶ return { %{ $DEFAULT->{sex}{unknown} } } if $code eq 'unknown';
Branch: 1 branch
BranchTrueFalseTotal
if $code eq "unknown" 0 0 0
298  
299 0 return;
300 }
301  
302 1122 ▶sub _matches_administrative_gender_name {
Subroutine _matches_administrative_gender_name: called CC=5 SCAR=16.6
303 1122 my ($name) = @_;
304 1122 ▶ return 0 unless defined $name && length $name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and length $name 0 1122 1122
Condition33%1/3
defined $name and length $name
!ll&&!rl&&r
001122
MC/DC0%0/2
defined $name and length $name
defined $name length $name
Truth table33%1/3
A and B
A= defined $nameB= length $name
ABresult
0X0
100
111
305  
306 1122 ▶ return 1 if $name =~ /Administratives Geschlecht/i;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /Administratives Geschlecht/i 19 1103 1122
307 1103 ▶ return 1 if $name =~ /Administrative gender/i;
Branch: 1 branch
BranchTrueFalseTotal
if $name =~ /Administrative gender/i 1 1102 1103
308  
309 1102 return 0;
310 }
311  
312 20 ▶sub _map_first_class_arrays {
Subroutine _map_first_class_arrays: called CC=2 SCAR=6.9
313 20 my ($compositions) = @_;
314  
315 20 my %mapped = (
316 diseases => [],
317 measures => [],
318 phenotypicFeatures => [],
319 interventionsOrProcedures => [],
320 treatments => [],
321 );
322  
323 20 for my $composition ( @{$compositions} ) {
324 _walk_nodes(
325 $composition,
326 18653 ▶ sub {
Subroutine __ANON__: called CC=16 SCAR=27.8
327 18653 my ($node) = @_;
328 18653 ▶ return unless ref($node) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $node eq "HASH" 0 18653 18653
329 18653 ▶ return unless defined $node->{archetype_node_id};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node->{"archetype_node_id"} 14803 3850 18653
330  
331 3850 ▶ if ( $node->{archetype_node_id} eq 'openEHR-EHR-OBSERVATION.lab_test-result.v1'
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.lab_test-result.v1" or $node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.laboratory_test_result.v1") 10 3840 3850
Condition100%3/3
$node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.lab_test-result.v1" or $node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.laboratory_test_result.v1"
l!l&&r!l&&!r
463840
MC/DC100%2/2
$node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.lab_test-result.v1" or $node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.laboratory_test_result.v1"
$node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.lab_test-result.v1" $node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.laboratory_test_result.v1"
Truth table100%3/3
A or B
A= $node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.lab_test-result.v1"B= $node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.laboratory_test_result.v1"
ABresult
1X1
011
000
332 || $node->{archetype_node_id} eq 'openEHR-EHR-OBSERVATION.laboratory_test_result.v1' )
333 {
334 10 my $measure = _map_lab_measure($node);
335 10 ▶ push @{ $mapped{measures} }, $measure if defined $measure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $measure 4 6 10
336 10 return;
337 }
338  
339 3840 ▶ if ( $node->{archetype_node_id} eq 'openEHR-EHR-OBSERVATION.body_temperature.v2' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.body_temperature.v2") 9 3831 3840
340 9 my $measure = _map_temperature_measure($node);
341 9 ▶ push @{ $mapped{measures} }, $measure if defined $measure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $measure 3 6 9
342 9 return;
343 }
344  
345 3831 ▶ if ( $node->{archetype_node_id} eq 'openEHR-EHR-OBSERVATION.symptom_sign_screening.v0' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{"archetype_node_id"} eq "openEHR-EHR-OBSERVATION.symptom_sign_screening.v0") 21 3810 3831
346 21 my $feature = _map_phenotypic_feature($node);
347 21 ▶ push @{ $mapped{phenotypicFeatures} }, $feature if defined $feature;
Branch: 1 branch
BranchTrueFalseTotal
if defined $feature 21 0 21
348 21 return;
349 }
350  
351 3810 ▶ if ( $node->{archetype_node_id} eq 'openEHR-EHR-EVALUATION.problem_diagnosis.v1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{"archetype_node_id"} eq "openEHR-EHR-EVALUATION.problem_diagnosis.v1") 18 3792 3810
352 18 my $disease = _map_disease($node);
353 18 ▶ push @{ $mapped{diseases} }, $disease if defined $disease;
Branch: 1 branch
BranchTrueFalseTotal
if defined $disease 18 0 18
354 18 return;
355 }
356  
357 3792 ▶ if ( $node->{archetype_node_id} eq 'openEHR-EHR-ACTION.procedure.v1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{"archetype_node_id"} eq "openEHR-EHR-ACTION.procedure.v1") 6 3786 3792
358 6 my $procedure = _map_procedure($node);
359 6 ▶ push @{ $mapped{interventionsOrProcedures} }, $procedure
Branch: 1 branch
BranchTrueFalseTotal
if defined $procedure 6 0 6
360 if defined $procedure;
361 6 return;
362 }
363  
364 3786 ▶ if ( $node->{archetype_node_id} eq 'openEHR-EHR-ACTION.medication.v1' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($node->{"archetype_node_id"} eq "openEHR-EHR-ACTION.medication.v1") 12 3774 3786
365 12 my $treatment = _map_treatment($node);
366 12 ▶ push @{ $mapped{treatments} }, $treatment if defined $treatment;
Branch: 1 branch
BranchTrueFalseTotal
if defined $treatment 12 0 12
367 12 return;
368 }
369 }
370 33 );
371 }
372  
373 20 return \%mapped;
374 }
375  
376 84054 ▶sub _walk_nodes {
Subroutine _walk_nodes: called CC=6 SCAR=17.9
377 84054 my ( $node, $callback ) = @_;
378 84054 ▶ return unless defined $node;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $node 0 84054 84054
379  
380 84054 ▶ if ( ref($node) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node eq "HASH") 27473 56581 84054
381 27473 $callback->($node);
382 27473 _walk_nodes( $_, $callback ) for values %{$node};
383 27473 return;
384 }
385  
386 56581 ▶ if ( ref($node) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $node eq "ARRAY") 2036 54545 56581
387 2036 _walk_nodes( $_, $callback ) for @{$node};
388 }
389  
390 56581 return;
391 }
392  
393 10 ▶sub _map_lab_measure {
Subroutine _map_lab_measure: called CC=8 SCAR=22.5
394 10 my ($node) = @_;
395  
396 10 ▶ my $assay =
Condition33%2/6
_find_first_element_value($node, 'Test result name', 'Test name', 'Analyte name') || _find_first_named_cluster_code($node, 'Result group') || _term_from_text(_node_name($node), $node)
l!l&&r!l&&!r
1000
_find_first_element_value($node, "Test result name", "Test name", "Analyte name") or _find_first_named_cluster_code($node, "Result group")
l!l&&r!l&&!r
1000
MC/DC0%0/3
_find_first_element_value($node, 'Test result name', 'Test name', 'Analyte name') || _find_first_named_cluster_code($node, 'Result group') || _term_from_text(_node_name($node), $node)
_find_first_element_value($node, "Test result name", "Test name", "Analyte name") _find_first_named_cluster_code($node, "Result group") _term_from_text(_node_name($node), $node)
Truth table25%1/4
A or B || C
A= _find_first_element_value($node, "Test result name", "Test name", "Analyte name")B= _find_first_named_cluster_code($node, "Result group")C= _term_from_text(_node_name($node), $node)
ABCresult
1XX1
01X1
0011
0000
397 _find_first_element_value( $node, 'Test result name', 'Test name', 'Analyte name' )
398 || _find_first_named_cluster_code( $node, 'Result group' )
399 || _term_from_text( _node_name($node), $node );
400  
401 10 my $quantity = _find_first_quantity_value( $node, 'Result value', 'Temperatur' );
402 10 my $time = _find_first_datetime_value($node);
403  
404 10 ▶ return unless defined $assay && defined $quantity;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $assay and defined $quantity 6 4 10
Condition66%2/3
defined $assay and defined $quantity
!ll&&!rl&&r
064
MC/DC50%1/2
defined $assay and defined $quantity
defined $assay defined $quantity
Truth table66%2/3
A and B
A= defined $assayB= defined $quantity
ABresult
0X0
100
111
405  
406 4 my $measure = {
407 _info => {
408 openEHR => $node,
409 },
410 };
411  
412 4 ▶ $measure->{assayCode} = $assay if defined $assay;
Branch: 1 branch
BranchTrueFalseTotal
if defined $assay 4 0 4
413 4 ▶ if ( defined $quantity ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $quantity) 4 0 4
414 $measure->{measurementValue} = {
415 4 quantity => $quantity,
416 };
417 }
418 4 ▶ $measure->{timeObserved} = { timestamp => $time } if defined $time;
Branch: 1 branch
BranchTrueFalseTotal
if defined $time 4 0 4
419  
420 4 return $measure;
421 }
422  
423 9 ▶sub _map_temperature_measure {
Subroutine _map_temperature_measure: called CC=3 SCAR=11.0
424 9 my ($node) = @_;
425 9 my $quantity = _find_first_quantity_value( $node, 'Temperatur' );
426 9 my $time = _find_first_datetime_value($node);
427  
428 9 ▶ return unless defined $quantity;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $quantity 6 3 9
429  
430 3 my $measure = {
431 assayCode => _term_from_text( _node_name($node), $node ),
432 measurementValue => {
433 quantity => $quantity,
434 },
435 _info => {
436 openEHR => $node,
437 },
438 };
439  
440 3 ▶ $measure->{timeObserved} = { timestamp => $time } if defined $time;
Branch: 1 branch
BranchTrueFalseTotal
if defined $time 3 0 3
441 3 return $measure;
442 }
443  
444 21 ▶sub _map_phenotypic_feature {
Subroutine _map_phenotypic_feature: called CC=4 SCAR=14.6
445 21 my ($node) = @_;
446  
447 21 ▶ my $feature_name =
Condition33%1/3
_find_first_text_value($node, 'Bezeichnung des Symptoms oder Anzeichens.') || _node_name($node)
l!l&&r!l&&!r
2100
MC/DC0%0/2
_find_first_text_value($node, 'Bezeichnung des Symptoms oder Anzeichens.') || _node_name($node)
_find_first_text_value($node, 'Bezeichnung des Symptoms oder Anzeichens.') _node_name($node)
Truth table33%1/3
A || B
A= _find_first_text_value($node, 'Bezeichnung des Symptoms oder Anzeichens.')B= _node_name($node)
ABresult
1X1
011
000
448 _find_first_text_value( $node, 'Bezeichnung des Symptoms oder Anzeichens.' )
449 || _node_name($node);
450 21 ▶ return unless defined $feature_name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $feature_name 0 21 21
451  
452 21 my $presence = _find_first_element_value( $node, 'Vorhanden?' );
453 21 my $excluded = _excluded_from_presence($presence);
454  
455 21 my $feature = {
456 featureType => _term_from_text( $feature_name, $node ),
457 _info => {
458 openEHR => $node,
459 },
460 };
461  
462 21 ▶ $feature->{excluded} = $excluded if defined $excluded;
Branch: 1 branch
BranchTrueFalseTotal
if defined $excluded 21 0 21
463  
464 21 return $feature;
465 }
466  
467 18 ▶sub _map_disease {
Subroutine _map_disease: called CC=2 SCAR=7.0
468 18 my ($node) = @_;
469 18 my $code = _find_first_element_value( $node, 'Problem/Diagnosis name' );
470 18 ▶ return unless defined $code;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code 0 18 18
471  
472 return {
473 18 diseaseCode => $code,
474 _info => {
475 openEHR => $node,
476 },
477 };
478 }
479  
480 6 ▶sub _map_procedure {
Subroutine _map_procedure: called CC=4 SCAR=14.2
481 6 my ($node) = @_;
482 6 my $code = _find_first_element_value( $node, 'Procedure name' );
483 6 ▶ return unless defined $code;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code 0 6 6
484  
485 6 my $procedure = {
486 procedureCode => $code,
487 _info => {
488 openEHR => $node,
489 },
490 };
491  
492 6 my $body_site = _find_first_element_value( $node, 'Body site' );
493 6 ▶ $procedure->{bodySite} = $body_site if defined $body_site;
Branch: 1 branch
BranchTrueFalseTotal
if defined $body_site 6 0 6
494  
495 6 my $date = _extract_date( $node->{time}{value} );
496 6 ▶ $procedure->{dateOfProcedure} = $date if defined $date;
Branch: 1 branch
BranchTrueFalseTotal
if defined $date 6 0 6
497  
498 6 return $procedure;
499 }
500  
501 12 ▶sub _map_treatment {
Subroutine _map_treatment: called CC=4 SCAR=14.2
502 12 my ($node) = @_;
503  
504 12 ▶ my $code =
Condition66%2/3
_find_first_element_value($node, 'Name') || _find_first_element_value($node, 'Medication item', 'Immunisation item')
l!l&&r!l&&!r
660
MC/DC0%0/2
_find_first_element_value($node, 'Name') || _find_first_element_value($node, 'Medication item', 'Immunisation item')
_find_first_element_value($node, 'Name') _find_first_element_value($node, 'Medication item', 'Immunisation item')
Truth table66%2/3
A || B
A= _find_first_element_value($node, 'Name')B= _find_first_element_value($node, 'Medication item', 'Immunisation item')
ABresult
1X1
011
000
505 _find_first_element_value( $node, 'Name' )
506 || _find_first_element_value( $node, 'Medication item', 'Immunisation item' );
507 12 ▶ return unless defined $code;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code 0 12 12
508  
509 12 my $treatment = {
510 treatmentCode => $code,
511 _info => {
512 openEHR => $node,
513 },
514 };
515  
516 12 my $route = _find_first_element_value( $node, 'Route' );
517 12 ▶ $treatment->{routeOfAdministration} = $route if defined $route;
Branch: 1 branch
BranchTrueFalseTotal
if defined $route 12 0 12
518  
519 12 return $treatment;
520 }
521  
522 91 ▶sub _find_first_element_value {
Subroutine _find_first_element_value: called CC=1 SCAR=0.0
523 91 my ( $node, @names ) = @_;
524 91 my %wanted = map { $_ => 1 } @names;
525 91 my $found;
526  
527 _walk_nodes(
528 $node,
529 6457 ▶ sub {
Subroutine __ANON__: called CC=7 SCAR=19.7
530 6457 my ($cursor) = @_;
531 6457 ▶ return if defined $found;
Branch: 1 branch
BranchTrueFalseTotal
if defined $found 3961 2496 6457
532 2496 ▶ return unless ref($cursor) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cursor eq "HASH" 0 2496 2496
533 2496 ▶ return unless ( $cursor->{_type} || '' ) eq 'ELEMENT';
Branch: 1 branch
BranchTrueFalseTotal
unless ($cursor->{"_type"} || "") eq "ELEMENT" 2129 367 2496
Condition50%1/2
$cursor->{'_type'} || ''
l!l
24960
MC/DC0%0/1
$cursor->{'_type'} || ''
$cursor->{'_type'}
Truth table50%1/2
A
A= $cursor->{'_type'}
Aresult
11
00
534  
535 367 my $name = _node_name($cursor);
536 367 ▶ return unless defined $name && $wanted{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and $wanted{$name} 282 85 367
Condition66%2/3
defined $name and $wanted{$name}
!ll&&!rl&&r
028285
MC/DC50%1/2
defined $name and $wanted{$name}
defined $name $wanted{$name}
Truth table66%2/3
A and B
A= defined $nameB= $wanted{$name}
ABresult
0X0
100
111
537  
538 85 $found = _term_from_value( $cursor->{value}, $cursor );
539 }
540 91 );
541  
542 91 return $found;
543 }
544  
545 21 ▶sub _find_first_text_value {
Subroutine _find_first_text_value: called CC=1 SCAR=0.1
546 21 my ( $node, @names ) = @_;
547 21 my %wanted = map { $_ => 1 } @names;
548 21 my $found;
549  
550 _walk_nodes(
551 $node,
552 567 ▶ sub {
Subroutine __ANON__: called CC=9 SCAR=23.6
553 567 my ($cursor) = @_;
554 567 ▶ return if defined $found;
Branch: 1 branch
BranchTrueFalseTotal
if defined $found 286 281 567
555 281 ▶ return unless ref($cursor) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cursor eq "HASH" 0 281 281
556 281 ▶ return unless ( $cursor->{_type} || '' ) eq 'ELEMENT';
Branch: 1 branch
BranchTrueFalseTotal
unless ($cursor->{"_type"} || "") eq "ELEMENT" 260 21 281
Condition50%1/2
$cursor->{'_type'} || ''
l!l
2810
MC/DC0%0/1
$cursor->{'_type'} || ''
$cursor->{'_type'}
Truth table50%1/2
A
A= $cursor->{'_type'}
Aresult
11
00
557  
558 21 my $name = _node_name($cursor);
559 21 ▶ return unless defined $name && $wanted{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and $wanted{$name} 0 21 21
Condition33%1/3
defined $name and $wanted{$name}
!ll&&!rl&&r
0021
MC/DC0%0/2
defined $name and $wanted{$name}
defined $name $wanted{$name}
Truth table33%1/3
A and B
A= defined $nameB= $wanted{$name}
ABresult
0X0
100
111
560 21 ▶ return unless ref( $cursor->{value} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cursor->{"value"} eq "HASH" 0 21 21
561 21 ▶ return unless defined $cursor->{value}{value};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cursor->{"value"}{"value"} 0 21 21
562  
563 21 $found = $cursor->{value}{value};
564 }
565 21 );
566  
567 21 return $found;
568 }
569  
570 19 ▶sub _find_first_quantity_value {
Subroutine _find_first_quantity_value: called CC=1 SCAR=0.1
571 19 my ( $node, @names ) = @_;
572 19 my %wanted = map { $_ => 1 } @names;
573 19 my $found;
574  
575 _walk_nodes(
576 $node,
577 898 ▶ sub {
Subroutine __ANON__: called CC=10 SCAR=24.0
578 898 my ($cursor) = @_;
579 898 ▶ return if defined $found;
Branch: 1 branch
BranchTrueFalseTotal
if defined $found 108 790 898
580 790 ▶ return unless ref($cursor) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cursor eq "HASH" 0 790 790
581 790 ▶ return unless ( $cursor->{_type} || '' ) eq 'ELEMENT';
Branch: 1 branch
BranchTrueFalseTotal
unless ($cursor->{"_type"} || "") eq "ELEMENT" 715 75 790
Condition50%1/2
$cursor->{'_type'} || ''
l!l
7900
MC/DC0%0/1
$cursor->{'_type'} || ''
$cursor->{'_type'}
Truth table50%1/2
A
A= $cursor->{'_type'}
Aresult
11
00
582  
583 75 my $name = _node_name($cursor);
584 75 ▶ return unless defined $name && $wanted{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $name and $wanted{$name} 68 7 75
Condition66%2/3
defined $name and $wanted{$name}
!ll&&!rl&&r
0687
MC/DC50%1/2
defined $name and $wanted{$name}
defined $name $wanted{$name}
Truth table66%2/3
A and B
A= defined $nameB= $wanted{$name}
ABresult
0X0
100
111
585 7 ▶ return unless ref( $cursor->{value} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cursor->{"value"} eq "HASH" 0 7 7
586 7 ▶ return unless ( $cursor->{value}{_type} || '' ) eq 'DV_QUANTITY';
Branch: 1 branch
BranchTrueFalseTotal
unless ($cursor->{"value"}{"_type"} || "") eq "DV_QUANTITY" 0 7 7
Condition50%1/2
$cursor->{'value'}{'_type'} || ''
l!l
70
MC/DC0%0/1
$cursor->{'value'}{'_type'} || ''
$cursor->{'value'}{'_type'}
Truth table50%1/2
A
A= $cursor->{'value'}{'_type'}
Aresult
11
00
587  
588 7 $found = _quantity_from_dv_quantity( $cursor->{value} );
589 }
590 19 );
591  
592 19 return $found;
593 }
594  
595 0 ▶sub _find_first_named_cluster_code {
Subroutine _find_first_named_cluster_code: not called CC=1 SCAR=6.9
596 0 my ( $node, $cluster_name ) = @_;
597 0 my $found;
598  
599 _walk_nodes(
600 $node,
601 0 ▶ sub {
Subroutine __ANON__: not called CC=14 SCAR=53.5
602 0 my ($cursor) = @_;
603 0 ▶ return if defined $found;
Branch: 1 branch
BranchTrueFalseTotal
if defined $found 0 0 0
604 0 ▶ return unless ref($cursor) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cursor eq "HASH" 0 0 0
605 0 ▶ return unless ( $cursor->{_type} || '' ) eq 'CLUSTER';
Branch: 1 branch
BranchTrueFalseTotal
unless ($cursor->{"_type"} || "") eq "CLUSTER" 0 0 0
Condition0%0/2
$cursor->{'_type'} || ''
l!l
00
MC/DC0%0/1
$cursor->{'_type'} || ''
$cursor->{'_type'}
Truth table0%0/2
A
A= $cursor->{'_type'}
Aresult
11
00
606 0 ▶ return unless defined _node_name($cursor) && _node_name($cursor) eq $cluster_name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined _node_name($cursor) and _node_name($cursor) eq $cluster_name 0 0 0
Condition0%0/3
defined _node_name($cursor) and _node_name($cursor) eq $cluster_name
!ll&&!rl&&r
000
MC/DC0%0/2
defined _node_name($cursor) and _node_name($cursor) eq $cluster_name
defined _node_name($cursor) _node_name($cursor) eq $cluster_name
Truth table0%0/3
A and B
A= defined _node_name($cursor)B= _node_name($cursor) eq $cluster_name
ABresult
0X0
100
111
607  
608 0 ▶ if ( ref( $cursor->{items} ) eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $cursor->{"items"} eq "ARRAY") 0 0 0
609 0 for my $item ( @{ $cursor->{items} } ) {
610 0 ▶ next unless ref($item) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $item eq "HASH" 0 0 0
611 0 my $name = $item->{name};
612 0 ▶ next unless ref($name) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $name eq "HASH" 0 0 0
613 0 ▶ next unless ( $name->{_type} || '' ) eq 'DV_CODED_TEXT';
Branch: 1 branch
BranchTrueFalseTotal
unless ($name->{"_type"} || "") eq "DV_CODED_TEXT" 0 0 0
Condition0%0/2
$name->{'_type'} || ''
l!l
00
MC/DC0%0/1
$name->{'_type'} || ''
$name->{'_type'}
Truth table0%0/2
A
A= $name->{'_type'}
Aresult
11
00
614 0 $found = _term_from_value( $name, $item );
615 0 ▶ last if defined $found;
Branch: 1 branch
BranchTrueFalseTotal
if defined $found 0 0 0
616 }
617 }
618 }
619 0 );
620  
621 0 return $found;
622 }
623  
624 19 ▶sub _find_first_datetime_value {
Subroutine _find_first_datetime_value: called CC=1 SCAR=0.3
625 19 my ($node) = @_;
626 19 my $found;
627  
628 _walk_nodes(
629 $node,
630 898 ▶ sub {
Subroutine __ANON__: called CC=9 SCAR=25.1
631 898 my ($cursor) = @_;
632 898 ▶ return if defined $found;
Branch: 1 branch
BranchTrueFalseTotal
if defined $found 615 283 898
633 283 ▶ return unless ref($cursor) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cursor eq "HASH" 0 283 283
634  
635 283 ▶ if ( exists $cursor->{time}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $cursor->{"time"} and ref $cursor->{"time"} eq "HASH" and defined $cursor->{"time"}{"value"}) 0 283 283
Condition33%2/6
exists $cursor->{"time"} and ref $cursor->{"time"} eq "HASH" and defined $cursor->{"time"}{"value"}
!ll&&!rl&&r
28300
exists $cursor->{"time"} and ref $cursor->{"time"} eq "HASH"
!ll&&!rl&&r
28300
MC/DC0%0/3
exists $cursor->{"time"} and ref $cursor->{"time"} eq "HASH" and defined $cursor->{"time"}{"value"}
exists $cursor->{"time"} ref $cursor->{"time"} eq "HASH" defined $cursor->{"time"}{"value"}
Truth table25%1/4
A and B and C
A= exists $cursor->{"time"}B= ref $cursor->{"time"} eq "HASH"C= defined $cursor->{"time"}{"value"}
ABCresult
0XX0
10X0
1100
1111
636 && ref( $cursor->{time} ) eq 'HASH'
637 && defined $cursor->{time}{value} )
638 {
639 0 $found = $cursor->{time}{value};
640 0 return;
641 }
642  
643 283 ▶ if ( exists $cursor->{origin}
Branch: 1 branch
BranchTrueFalseTotal
if (exists $cursor->{"origin"} and ref $cursor->{"origin"} eq "HASH" and defined $cursor->{"origin"}{"value"}) 19 264 283
Condition66%4/6
exists $cursor->{"origin"} and ref $cursor->{"origin"} eq "HASH" and defined $cursor->{"origin"}{"value"}
!ll&&!rl&&r
264019
exists $cursor->{"origin"} and ref $cursor->{"origin"} eq "HASH"
!ll&&!rl&&r
264019
MC/DC33%1/3
exists $cursor->{"origin"} and ref $cursor->{"origin"} eq "HASH" and defined $cursor->{"origin"}{"value"}
exists $cursor->{"origin"} ref $cursor->{"origin"} eq "HASH" defined $cursor->{"origin"}{"value"}
Truth table50%2/4
A and B and C
A= exists $cursor->{"origin"}B= ref $cursor->{"origin"} eq "HASH"C= defined $cursor->{"origin"}{"value"}
ABCresult
0XX0
10X0
1100
1111
644 && ref( $cursor->{origin} ) eq 'HASH'
645 && defined $cursor->{origin}{value} )
646 {
647 19 $found = $cursor->{origin}{value};
648 19 return;
649 }
650 }
651 19 );
652  
653 19 return $found;
654 }
655  
656 85 ▶sub _term_from_value {
Subroutine _term_from_value: called CC=8 SCAR=26.7
657 85 my ( $value, $source_node ) = @_;
658 85 ▶ return unless defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 0 85 85
659  
660 85 ▶ if ( ref($value) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "HASH") 85 0 85
661 85 ▶ if ( defined $value->{value} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value->{"value"}) 85 0 85
662 85 my %term = ( label => $value->{value} );
663 85 my $id = _term_id_from_defining_code( $value->{defining_code} );
664 85 ▶ $id ||= _synthetic_term_id( $value->{value}, $source_node );
Condition66%2/3
$id ||= _synthetic_term_id($value->{"value"}, $source_node)
l!l&&r!l&&!r
4810
MC/DC0%0/2
$id ||= _synthetic_term_id($value->{"value"}, $source_node)
$id _synthetic_term_id($value->{"value"}, $source_node)
Truth table66%2/3
A ||= B
A= $idB= _synthetic_term_id($value->{"value"}, $source_node)
ABresult
1X1
011
000
665 85 ▶ $term{id} = $id if defined $id;
Branch: 1 branch
BranchTrueFalseTotal
if defined $id 85 0 85
666 85 return \%term;
667 }
668 0 return;
669 }
670  
671 return {
672 0 ▶ id => _synthetic_term_id( $value, $source_node ),
Branch: 1 branch
BranchTrueFalseTotal
if not ref $value and length $value 0 0 0
Condition0%0/3
not ref $value and length $value
!ll&&!rl&&r
000
MC/DC0%0/2
not ref $value and length $value
not ref $value length $value
Truth table0%0/3
not(A) and B
A= not ref $valueB= length $value
ABresult
0X0
100
111
673 label => $value,
674 }
675 if !ref($value) && length $value;
676 0 return;
677 }
678  
679 24 ▶sub _term_from_text {
Subroutine _term_from_text: called CC=3 SCAR=12.5
680 24 my ( $text, $source_node ) = @_;
681 24 ▶ return unless defined $text && length $text;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $text and length $text 0 24 24
Condition33%1/3
defined $text and length $text
!ll&&!rl&&r
0024
MC/DC0%0/2
defined $text and length $text
defined $text length $text
Truth table33%1/3
A and B
A= defined $textB= length $text
ABresult
0X0
100
111
682 return {
683 24 id => _synthetic_term_id( $text, $source_node ),
684 label => $text,
685 };
686 }
687  
688 85 ▶sub _term_id_from_defining_code {
Subroutine _term_id_from_defining_code: called CC=7 SCAR=19.9
689 85 my ($code) = @_;
690 85 ▶ return unless ref($code) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $code eq "HASH" 60 25 85
691 25 ▶ return unless defined $code->{code_string};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code->{"code_string"} 0 25 25
692 25 ▶ return unless ref( $code->{terminology_id} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $code->{"terminology_id"} eq "HASH" 0 25 25
693 25 ▶ return unless defined $code->{terminology_id}{value};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $code->{"terminology_id"}{"value"} 0 25 25
694  
695 25 my $terminology = $code->{terminology_id}{value};
696 25 ▶ return if $terminology eq 'local' || $terminology eq 'openehr';
Branch: 1 branch
BranchTrueFalseTotal
if $terminology eq "local" or $terminology eq "openehr" 21 4 25
Condition66%2/3
$terminology eq "local" or $terminology eq "openehr"
l!l&&r!l&&!r
2104
MC/DC50%1/2
$terminology eq "local" or $terminology eq "openehr"
$terminology eq "local" $terminology eq "openehr"
Truth table66%2/3
A or B
A= $terminology eq "local"B= $terminology eq "openehr"
ABresult
1X1
011
000
697  
698 4 return $terminology . ':' . $code->{code_string};
699 }
700  
701 7 ▶sub _quantity_from_dv_quantity {
Subroutine _quantity_from_dv_quantity: called CC=14 SCAR=33.6
702 7 my ($value) = @_;
703 7 ▶ return unless ref($value) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $value eq "HASH" 0 7 7
704 7 ▶ return unless defined $value->{magnitude};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value->{"magnitude"} 0 7 7
705  
706 7 my %quantity = ( value => $value->{magnitude} );
707 $quantity{unit} = { label => $value->{units} }
708 7 ▶ if defined $value->{units} && length $value->{units};
Branch: 1 branch
BranchTrueFalseTotal
if defined $value->{"units"} and length $value->{"units"} 7 0 7
Condition33%1/3
defined $value->{"units"} and length $value->{"units"}
!ll&&!rl&&r
007
MC/DC0%0/2
defined $value->{"units"} and length $value->{"units"}
defined $value->{"units"} length $value->{"units"}
Truth table33%1/3
A and B
A= defined $value->{"units"}B= length $value->{"units"}
ABresult
0X0
100
111
709  
710 7 ▶ if ( ref( $value->{normal_range} ) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value->{"normal_range"} eq "HASH") 4 3 7
711 4 my %range;
712 4 ▶ if ( ref( $value->{normal_range}{lower} ) eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value->{"normal_range"}{"lower"} eq "HASH" and defined $value->{"normal_range"}{"lower"}{"magnitude"}) 0 4 4
Condition33%1/3
ref $value->{"normal_range"}{"lower"} eq "HASH" and defined $value->{"normal_range"}{"lower"}{"magnitude"}
!ll&&!rl&&r
400
MC/DC0%0/2
ref $value->{"normal_range"}{"lower"} eq "HASH" and defined $value->{"normal_range"}{"lower"}{"magnitude"}
ref $value->{"normal_range"}{"lower"} eq "HASH" defined $value->{"normal_range"}{"lower"}{"magnitude"}
Truth table33%1/3
A and B
A= ref $value->{"normal_range"}{"lower"} eq "HASH"B= defined $value->{"normal_range"}{"lower"}{"magnitude"}
ABresult
0X0
100
111
713 && defined $value->{normal_range}{lower}{magnitude} )
714 {
715 0 $range{low} = $value->{normal_range}{lower}{magnitude};
716 $range{unit} = { label => $value->{normal_range}{lower}{units} }
717 0 ▶ if defined $value->{normal_range}{lower}{units};
Branch: 1 branch
BranchTrueFalseTotal
if defined $value->{"normal_range"}{"lower"}{"units"} 0 0 0
718 }
719 4 ▶ if ( ref( $value->{normal_range}{upper} ) eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value->{"normal_range"}{"upper"} eq "HASH" and defined $value->{"normal_range"}{"upper"}{"magnitude"}) 4 0 4
Condition33%1/3
ref $value->{"normal_range"}{"upper"} eq "HASH" and defined $value->{"normal_range"}{"upper"}{"magnitude"}
!ll&&!rl&&r
004
MC/DC0%0/2
ref $value->{"normal_range"}{"upper"} eq "HASH" and defined $value->{"normal_range"}{"upper"}{"magnitude"}
ref $value->{"normal_range"}{"upper"} eq "HASH" defined $value->{"normal_range"}{"upper"}{"magnitude"}
Truth table33%1/3
A and B
A= ref $value->{"normal_range"}{"upper"} eq "HASH"B= defined $value->{"normal_range"}{"upper"}{"magnitude"}
ABresult
0X0
100
111
720 && defined $value->{normal_range}{upper}{magnitude} )
721 {
722 4 $range{high} = $value->{normal_range}{upper}{magnitude};
723 $range{unit} = { label => $value->{normal_range}{upper}{units} }
724 4 ▶ if defined $value->{normal_range}{upper}{units} && !exists $range{unit};
Branch: 1 branch
BranchTrueFalseTotal
if defined $value->{"normal_range"}{"upper"}{"units"} and not exists $range{"unit"} 4 0 4
Condition33%1/3
defined $value->{"normal_range"}{"upper"}{"units"} and not exists $range{"unit"}
!ll&&!rl&&r
004
MC/DC0%0/2
defined $value->{"normal_range"}{"upper"}{"units"} and not exists $range{"unit"}
defined $value->{"normal_range"}{"upper"}{"units"} not exists $range{"unit"}
Truth table33%1/3
A and not(B)
A= defined $value->{"normal_range"}{"upper"}{"units"}B= not exists $range{"unit"}
ABresult
0X0
100
111
725 }
726 4 ▶ $quantity{referenceRange} = \%range if %range;
Branch: 1 branch
BranchTrueFalseTotal
if %range 4 0 4
727 }
728  
729 7 return \%quantity;
730 }
731  
732 21 ▶sub _excluded_from_presence {
Subroutine _excluded_from_presence: called CC=8 SCAR=25.8
733 21 my ($presence) = @_;
734 21 ▶ return unless defined $presence && ref($presence) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless defined $presence and ref $presence eq "HASH" 0 21 21
Condition33%1/3
defined $presence and ref $presence eq "HASH"
!ll&&!rl&&r
0021
MC/DC0%0/2
defined $presence and ref $presence eq "HASH"
defined $presence ref $presence eq "HASH"
Truth table33%1/3
A and B
A= defined $presenceB= ref $presence eq "HASH"
ABresult
0X0
100
111
735  
736 return JSON::PP::true() if defined $presence->{label}
737 21 ▶ && $presence->{label} =~ /Nicht vorhanden/i;
Branch: 1 branch
BranchTrueFalseTotal
if defined $presence->{"label"} and $presence->{"label"} =~ /Nicht vorhanden/i 12 9 21
Condition66%2/3
defined $presence->{"label"} and $presence->{"label"} =~ /Nicht vorhanden/i
!ll&&!rl&&r
0912
MC/DC50%1/2
defined $presence->{"label"} and $presence->{"label"} =~ /Nicht vorhanden/i
defined $presence->{"label"} $presence->{"label"} =~ /Nicht vorhanden/i
Truth table66%2/3
A and B
A= defined $presence->{"label"}B= $presence->{"label"} =~ /Nicht vorhanden/i
ABresult
0X0
100
111
738 return JSON::PP::false() if defined $presence->{label}
739 9 ▶ && ( $presence->{label} =~ /Vorhanden/i || $presence->{label} =~ /Present/i );
Branch: 1 branch
BranchTrueFalseTotal
if defined $presence->{"label"} and $presence->{"label"} =~ /Vorhanden/i || $presence->{"label"} =~ /Present/i 9 0 9
Condition33%2/6
defined $presence->{"label"} and $presence->{"label"} =~ /Vorhanden/i || $presence->{"label"} =~ /Present/i
!ll&&!rl&&r
009
$presence->{"label"} =~ /Vorhanden/i or $presence->{"label"} =~ /Present/i
l!l&&r!l&&!r
900
MC/DC0%0/3
defined $presence->{"label"} and $presence->{"label"} =~ /Vorhanden/i || $presence->{"label"} =~ /Present/i
defined $presence->{"label"} $presence->{"label"} =~ /Vorhanden/i $presence->{"label"} =~ /Present/i
Truth table25%1/4
A and B or C
A= defined $presence->{"label"}B= $presence->{"label"} =~ /Vorhanden/iC= $presence->{"label"} =~ /Present/i
ABCresult
0XX0
1000
11X1
1011
740  
741 0 return;
742 }
743  
744 105 ▶sub _synthetic_term_id {
Subroutine _synthetic_term_id: called CC=12 SCAR=31.7
745 105 my ( $text, $source_node ) = @_;
746 105 ▶ return unless defined $text && length $text;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $text and length $text 0 105 105
Condition33%1/3
defined $text and length $text
!ll&&!rl&&r
00105
MC/DC0%0/2
defined $text and length $text
defined $text length $text
Truth table33%1/3
A and B
A= defined $textB= length $text
ABresult
0X0
100
111
747  
748 105 my @parts = ('openEHR');
749 105 ▶ if ( ref($source_node) eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $source_node eq "HASH") 105 0 105
750 push @parts, $source_node->{archetype_node_id}
751 105 ▶ if defined $source_node->{archetype_node_id} && length $source_node->{archetype_node_id};
Branch: 1 branch
BranchTrueFalseTotal
if defined $source_node->{"archetype_node_id"} and length $source_node->{"archetype_node_id"} 105 0 105
Condition33%1/3
defined $source_node->{"archetype_node_id"} and length $source_node->{"archetype_node_id"}
!ll&&!rl&&r
00105
MC/DC0%0/2
defined $source_node->{"archetype_node_id"} and length $source_node->{"archetype_node_id"}
defined $source_node->{"archetype_node_id"} length $source_node->{"archetype_node_id"}
Truth table33%1/3
A and B
A= defined $source_node->{"archetype_node_id"}B= length $source_node->{"archetype_node_id"}
ABresult
0X0
100
111
752 push @parts, $source_node->{_type}
753 105 ▶ if defined $source_node->{_type} && length $source_node->{_type};
Branch: 1 branch
BranchTrueFalseTotal
if defined $source_node->{"_type"} and length $source_node->{"_type"} 105 0 105
Condition33%1/3
defined $source_node->{"_type"} and length $source_node->{"_type"}
!ll&&!rl&&r
00105
MC/DC0%0/2
defined $source_node->{"_type"} and length $source_node->{"_type"}
defined $source_node->{"_type"} length $source_node->{"_type"}
Truth table33%1/3
A and B
A= defined $source_node->{"_type"}B= length $source_node->{"_type"}
ABresult
0X0
100
111
754 105 ▶ if ( ref( $source_node->{name} ) eq 'HASH'
Branch: 1 branch
BranchTrueFalseTotal
if (ref $source_node->{"name"} eq "HASH" and defined $source_node->{"name"}{"value"} and length $source_node->{"name"}{"value"}) 105 0 105
Condition33%2/6
ref $source_node->{"name"} eq "HASH" and defined $source_node->{"name"}{"value"} and length $source_node->{"name"}{"value"}
!ll&&!rl&&r
00105
ref $source_node->{"name"} eq "HASH" and defined $source_node->{"name"}{"value"}
!ll&&!rl&&r
00105
MC/DC0%0/3
ref $source_node->{"name"} eq "HASH" and defined $source_node->{"name"}{"value"} and length $source_node->{"name"}{"value"}
ref $source_node->{"name"} eq "HASH" defined $source_node->{"name"}{"value"} length $source_node->{"name"}{"value"}
Truth table25%1/4
A and B and C
A= ref $source_node->{"name"} eq "HASH"B= defined $source_node->{"name"}{"value"}C= length $source_node->{"name"}{"value"}
ABCresult
0XX0
10X0
1100
1111
755 && defined $source_node->{name}{value}
756 && length $source_node->{name}{value} )
757 {
758 105 push @parts, _normalize_term_id_component( $source_node->{name}{value} );
759 }
760 }
761 105 push @parts, _normalize_term_id_component($text);
762  
763 105 ▶ return join ':', grep { defined && length } @parts;
Condition33%1/3
defined $_ && length $_
!ll&&!rl&&r
00525
MC/DC0%0/2
defined $_ && length $_
defined $_ length $_
Truth table33%1/3
A && B
A= defined $_B= length $_
ABresult
0X0
100
111
764 }
765  
766 210 ▶sub _normalize_term_id_component {
Subroutine _normalize_term_id_component: called CC=3 SCAR=11.1
767 210 my ($text) = @_;
768 210 ▶ return unless defined $text;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $text 0 210 210
769  
770 210 $text =~ s/^\s+|\s+$//g;
771 210 $text =~ s/\s+/_/g;
772 210 $text =~ s/[^A-Za-z0-9_.:-]+/_/g;
773 210 $text =~ s/_+/_/g;
774 210 $text =~ s/^_+|_+$//g;
775  
776 210 ▶ return length $text ? $text : 'term';
Branch: 1 branch
BranchTrueFalseTotal
length $text ? : 210 0 210
777 }
778  
779 6 ▶sub _extract_date {
Subroutine _extract_date: called CC=3 SCAR=12.5
780 6 my ($datetime) = @_;
781 6 ▶ return unless defined $datetime;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $datetime 0 6 6
782 6 ▶ return $1 if $datetime =~ /^(\d{4}-\d{2}-\d{2})/;
Branch: 1 branch
BranchTrueFalseTotal
if $datetime =~ /^(\d{4}-\d{2}-\d{2})/ 6 0 6
783 0 return;
784 }
785  
786 466 ▶sub _node_name {
Subroutine _node_name: called CC=3 SCAR=11.4
787 466 my ($node) = @_;
788 466 ▶ return unless ref($node) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $node eq "HASH" 0 466 466
789 466 ▶ return unless ref( $node->{name} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $node->{"name"} eq "HASH" 0 466 466
790 466 return $node->{name}{value};
791 }
792  
793 136 1;
« lib/Convert/Pheno/IO/Atomic.pm ↑ Summary bin/convert-pheno »