lib/Convert/Pheno/FHIR/Profile/MCode.pm

filter: Statementstmt 87.8% 58 / 66 Branchbran 57.5% 23 / 40 Conditioncond 29.4% 5 / 17 MC/DCmcdc 22.2% 2 / 9 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 3 totaltotal 67.3% 97 / 144 CC 33 SCAR 34.0
CC
33
Cov
70%
condition_stage
76.8
detected_profile_metadata
9.3
has_profile
6.2
CRAP 30.1
« lib/Convert/Pheno/Source/FHIR.pm ↑ Summary lib/Convert/Pheno/HTTP/Jobs.pm »
1 package Convert::Pheno::FHIR::Profile::MCode;
2  
3 136 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 136 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 136 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 136 ▶use Convert::Pheno::FHIR::Util qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
9 codeable_concept_to_term
10 resolve_reference
11 136 );
12  
13 136 our @EXPORT_OK = qw(
14 condition_stage
15 detected_profile_metadata
16 has_profile
17 );
18  
19 136 my $CANONICAL = 'http://hl7.org/fhir/us/mcode';
20 136 my $VERSION = '4.0.0';
21 136 my $PROFILE_PREFIX = "$CANONICAL/StructureDefinition/";
22  
23 20 ▶sub has_profile {
Subroutine has_profile: called CC=6 SCAR=18.2
Pod undocumented
24 20 my ( $resource, $profile_name ) = @_;
25 20 ▶ return 0 unless ref($resource) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $resource eq "HASH" 0 20 20
26  
27 20 my $wanted = $PROFILE_PREFIX . $profile_name;
28 20 for my $profile ( @{ _profile_urls($resource) } ) {
29 3 ▶ next if ref($profile);
Branch: 1 branch
BranchTrueFalseTotal
if ref $profile 0 3 3
30 3 my ($canonical) = _supported_profile_identity($profile);
31 3 ▶ next unless defined $canonical;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $canonical 1 2 3
32 2 ▶ return 1 if $canonical eq $wanted;
Branch: 1 branch
BranchTrueFalseTotal
if $canonical eq $wanted 2 0 2
33 }
34  
35 18 return 0;
36 }
37  
38 18 ▶sub condition_stage {
Subroutine condition_stage: called CC=14 SCAR=43.4
Pod undocumented
39 18 my ( $condition, $resource_index ) = @_;
40 18 ▶ return unless has_profile( $condition, 'mcode-primary-cancer-condition' );
Branch: 1 branch
BranchTrueFalseTotal
unless has_profile($condition, "mcode-primary-cancer-condition") 17 1 18
41  
42 1 ▶ for my $stage ( @{ $condition->{stage} || [] } ) {
Condition50%1/2
$condition->{'stage'} || []
l!l
10
MC/DC0%0/1
$condition->{'stage'} || []
$condition->{'stage'}
Truth table50%1/2
A
A= $condition->{'stage'}
Aresult
11
00
43 1 ▶ next unless ref($stage) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $stage eq "HASH" 0 1 1
44  
45 my $summary = codeable_concept_to_term(
46 $stage->{summary},
47 1 'CancerStage',
48 );
49 1 ▶ return $summary if $summary;
Branch: 1 branch
BranchTrueFalseTotal
if $summary 1 0 1
50  
51 0 ▶ for my $assessment ( @{ $stage->{assessment} || [] } ) {
Condition0%0/2
$stage->{'assessment'} || []
l!l
00
MC/DC0%0/1
$stage->{'assessment'} || []
$stage->{'assessment'}
Truth table0%0/2
A
A= $stage->{'assessment'}
Aresult
11
00
52 0 ▶ next unless ref($assessment) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $assessment eq "HASH" 0 0 0
53 my $observation = resolve_reference(
54 $resource_index || {},
55 $assessment->{reference},
56 0 ▶ );
Condition0%0/2
$resource_index || {}
l!l
00
MC/DC0%0/1
$resource_index || {}
$resource_index
Truth table0%0/2
A
A= $resource_index
Aresult
11
00
57 next unless ref($observation) eq 'HASH'
58 0 ▶ && ( $observation->{resourceType} || q{} ) eq 'Observation';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $observation eq "HASH" and ($observation->{"resourceType"} || "") eq "Observation" 0 0 0
Condition0%0/5
ref $observation eq "HASH" and ($observation->{"resourceType"} || "") eq "Observation"
!ll&&!rl&&r
000
$observation->{'resourceType'} || ''
l!l
00
MC/DC0%0/2
ref $observation eq "HASH" and ($observation->{"resourceType"} || "") eq "Observation"
ref $observation eq "HASH" $observation->{'resourceType'}
Truth table0%0/3
A and B
A= ref $observation eq "HASH"B= $observation->{'resourceType'}
ABresult
0X0
100
111
59  
60 my $value = codeable_concept_to_term(
61 $observation->{valueCodeableConcept},
62 0 'CancerStage',
63 );
64 0 ▶ return $value if $value;
Branch: 1 branch
BranchTrueFalseTotal
if $value 0 0 0
65 }
66 }
67  
68 0 return;
69 }
70  
71 17 ▶sub detected_profile_metadata {
Subroutine detected_profile_metadata: called CC=9 SCAR=22.3
Pod undocumented
72 17 my (@resources) = @_;
73 17 my %profiles;
74  
75 17 for my $resource (@resources) {
76 214 ▶ next unless ref($resource) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $resource eq "HASH" 0 214 214
77 214 for my $profile ( @{ _profile_urls($resource) } ) {
78 51 ▶ next if ref($profile);
Branch: 1 branch
BranchTrueFalseTotal
if ref $profile 0 51 51
79 51 my ($canonical) = _supported_profile_identity($profile);
80 51 ▶ next unless defined $canonical;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $canonical 0 51 51
81 51 ▶ next unless index( $canonical, $PROFILE_PREFIX ) == 0;
Branch: 1 branch
BranchTrueFalseTotal
unless index($canonical, $PROFILE_PREFIX) == 0 26 25 51
82  
83 25 my $name = substr $canonical, length $PROFILE_PREFIX;
84 25 ▶ next unless length $name;
Branch: 1 branch
BranchTrueFalseTotal
unless length $name 0 25 25
85 25 $profiles{$name} = 1;
86 }
87 }
88  
89 17 ▶ return unless keys %profiles;
Branch: 1 branch
BranchTrueFalseTotal
unless keys %profiles 16 1 17
90 return {
91 1 canonical => $CANONICAL,
92 supportedVersion => $VERSION,
93 detectedProfiles => [ sort keys %profiles ],
94 };
95 }
96  
97 54 ▶sub _supported_profile_identity {
Subroutine _supported_profile_identity: called CC=5 SCAR=16.5
98 54 my ($profile) = @_;
99 54 ▶ return if !defined $profile || ref($profile);
Branch: 1 branch
BranchTrueFalseTotal
if not defined $profile or ref $profile 0 54 54
Condition33%1/3
not defined $profile or ref $profile
l!l&&r!l&&!r
0054
MC/DC0%0/2
not defined $profile or ref $profile
not defined $profile ref $profile
Truth table33%1/3
not(A) or B
A= not defined $profileB= ref $profile
ABresult
1X1
011
000
100  
101 54 my ( $canonical, $version ) = split /\|/, $profile, 2;
102 54 ▶ return if defined $version && $version ne $VERSION;
Branch: 1 branch
BranchTrueFalseTotal
if defined $version and $version ne $VERSION 1 53 54
Condition100%3/3
defined $version and $version ne $VERSION
!ll&&!rl&&r
5211
MC/DC100%2/2
defined $version and $version ne $VERSION
defined $version $version ne $VERSION
Truth table100%3/3
A and B
A= defined $versionB= $version ne $VERSION
ABresult
0X0
100
111
103 53 return $canonical;
104 }
105  
106 234 ▶sub _profile_urls {
Subroutine _profile_urls: called CC=3 SCAR=11.0
107 234 my ($resource) = @_;
108 234 ▶ return [] unless ref( $resource->{meta} ) eq 'HASH';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $resource->{"meta"} eq "HASH" 180 54 234
109 54 ▶ return [] unless ref( $resource->{meta}{profile} ) eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $resource->{"meta"}{"profile"} eq "ARRAY" 0 54 54
110 54 return $resource->{meta}{profile};
111 }
112  
113 136 1;
« lib/Convert/Pheno/Source/FHIR.pm ↑ Summary lib/Convert/Pheno/HTTP/Jobs.pm »