| 1 | package Convert::Pheno::CDISC::SDTM::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 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 136 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 136 | ▶ | use JSON::PP (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 136 | ▶ | use Scalar::Util qw(looks_like_number); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 136 | ▶ | use Storable qw(dclone); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 136 | ▶ | use Convert::Pheno::CDISC::SDTM::Terminology qw(resolve_sdtm_term); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 136 | ▶ | use Convert::Pheno::Context; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 136 | ▶ | use Convert::Pheno::Model::Bundle; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 136 | ▶ | use Convert::Pheno::Utils::Default qw(get_defaults); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 136 | our @EXPORT_OK = qw(run_sdtm_to_bundle); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 136 | my $DEFAULT = get_defaults(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 136 | my %MAPPED_DOMAIN = map { $_ => 1 } qw(DM MH AE LB VS CM EX PR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 53 | ▶ | sub run_sdtm_to_bundle { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_sdtm_to_bundle: called CC=20 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 53 | my ( $self, $subject, $context ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | my $source_format = ref($subject) eq 'HASH' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 53 | ▶ | ? ( $subject->{sourceFormat} // 'dataset-json' ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$subject->{"sourceFormat"} // "dataset-json"
MC/DC0%0/1
$subject->{"sourceFormat"} // "dataset-json"
$subject->{"sourceFormat"}
Truth table50%1/2
A
A= $subject->{"sourceFormat"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | : 'dataset-json'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 53 | ▶ | my $format_label = $source_format eq 'dataset-xml' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | ? 'Dataset-XML' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | : 'Dataset-JSON'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 53 | ▶ | my $provenance_key = $source_format eq 'dataset-xml' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | ? 'datasetXml' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | : 'datasetJson'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | $context ||= Convert::Pheno::Context->from_self( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | source_format => $source_format, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | target_format => 'beacon', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 53 | ▶ | entities => $self->{entities} || ['individuals'], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition20%1/5
$context ||= "Convert::Pheno::Context"->from_self($self, {"source_format", $source_format, "target_format", "beacon", "entities", $self->{"entities"} || ["individuals"]})
$self->{'entities'} || ['individuals']
MC/DC0%0/2
$context ||= "Convert::Pheno::Context"->from_self($self, {"source_format", $source_format, "target_format", "beacon", "entities", $self->{"entities"} || ["individuals"]})
$context
"Convert::Pheno::Context"->from_self($self, {"source_format", $source_format, "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", $source_format, "target_format", "beacon", "entities", $self->{"entities"} || ["individuals"]})
Truth table0%0/2
A
A= $self->{'entities'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 53 | ▶ | die "Normalized $format_label subject input must contain an object\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | unless ref($subject) eq 'HASH'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | die "Normalized $format_label subject input is missing its id\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 53 | ▶ | unless defined $subject->{id} && length $subject->{id}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $subject->{"id"} and length $subject->{"id"}
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->{"id"}B= length $subject->{"id"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | die "Normalized $format_label subject <$subject->{id}> is missing DM\n" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | unless ref( $subject->{domains}{DM} ) eq 'ARRAY' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 53 | ▶ | && @{ $subject->{domains}{DM} } == 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $subject->{"domains"}{"DM"} eq "ARRAY" and @{$subject->{"domains"}{"DM"};} == 1
MC/DC0%0/2
ref $subject->{"domains"}{"DM"} eq "ARRAY" and @{$subject->{"domains"}{"DM"};} == 1
ref $subject->{"domains"}{"DM"} eq "ARRAY"
@{$subject->{"domains"}{"DM"};} == 1
Truth table33%1/3
A and B
A= ref $subject->{"domains"}{"DM"} eq "ARRAY"B= @{$subject->{"domains"}{"DM"};} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 53 | my $bundle = Convert::Pheno::Model::Bundle->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | context => $context, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | entities => $context->entities, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 53 | my $dm = $subject->{domains}{DM}[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | my $individual = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | id => $subject->{id}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 53 | sex => _map_sex( $dm->{SEX} ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 53 | _map_demographics( $self, $dm, $individual ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 53 | _append_mapped_rows( $self, $subject->{domains}{MH}, $individual, 'diseases', \&_map_medical_history, 'MH' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 53 | _append_mapped_rows( $self, $subject->{domains}{AE}, $individual, 'phenotypicFeatures', \&_map_adverse_event, 'AE' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 53 | _append_mapped_rows( $self, $subject->{domains}{LB}, $individual, 'measures', \&_map_measurement, 'LB' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 53 | _append_mapped_rows( $self, $subject->{domains}{VS}, $individual, 'measures', \&_map_measurement, 'VS' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 53 | _append_mapped_rows( $self, $subject->{domains}{CM}, $individual, 'treatments', \&_map_treatment, 'CM' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 53 | _append_mapped_rows( $self, $subject->{domains}{EX}, $individual, 'treatments', \&_map_treatment, 'EX' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 53 | _append_mapped_rows( $self, $subject->{domains}{PR}, $individual, 'interventionsOrProcedures', \&_map_procedure, 'PR' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 53 | ▶ | if ( $self->{source_info} // 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$self->{"source_info"} // 1
MC/DC0%0/1
$self->{"source_info"} // 1
$self->{"source_info"}
Truth table50%1/2
A
A= $self->{"source_info"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 49 | ▶ | my @unmapped = sort grep { !$MAPPED_DOMAIN{$_} } keys %{ $subject->{domains} || {} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$subject->{'domains'} || {}
MC/DC0%0/1
$subject->{'domains'} || {}
$subject->{'domains'}
Truth table50%1/2
A
A= $subject->{'domains'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | $individual->{info}{$provenance_key} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 49 | ▶ | %{ dclone( $subject->{metadata} || {} ) }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%2/4
$subject->{'metadata'} || {}
$subject->{'domains'} || {}
MC/DC0%0/1
$subject->{'metadata'} || {}
$subject->{'metadata'}
MC/DC0%0/1
$subject->{'domains'} || {}
$subject->{'domains'}
Truth table50%1/2
A
A= $subject->{'metadata'}
Truth table50%1/2
A
A= $subject->{'domains'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 49 | domains => dclone( $subject->{domains} || {} ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | $individual->{info}{$provenance_key}{unmappedDomains} = \@unmapped | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 49 | ▶ | if @unmapped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 53 | ▶ | unless ( $self->{test} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | $individual->{info}{convertPheno} = $self->{convertPheno} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if defined $self->{convertPheno}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 53 | $bundle->add_entity( individuals => $individual ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 53 | return $bundle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 53 | ▶ | sub _map_demographics { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_map_demographics: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 53 | my ( $self, $dm, $individual ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 53 | my $ethnicity = _first_value( $dm, qw(ETHNIC) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 53 | ▶ | $individual->{ethnicity} = _resolved_source_term( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | $self, 'DM', 'ETHNIC', $ethnicity, $ethnicity, 'ETHNIC', 'DM[1]' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | if defined $ethnicity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 53 | my $country = _first_value( $dm, qw(COUNTRY) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 53 | ▶ | if ( defined $country ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 48 | my $country_code = uc $country; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 48 | ▶ | my $fallback = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | $country_code =~ /\A[A-Z]{2,3}\z/ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | ? { id => "ISO3166-1:$country_code", label => $country } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | : _source_term( 'COUNTRY', $country, $country ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 48 | $individual->{geographicOrigin} = resolve_sdtm_term( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | self => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | domain => 'DM', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | field => 'COUNTRY', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | value => $country, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | label => $country, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | source_record => 'DM[1]', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | fallback => $fallback, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 53 | my $birth = _timestamp( _first_value( $dm, qw(BRTHDTC) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 53 | ▶ | $individual->{info}{phenopacket}{dateOfBirth} = $birth | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | if defined $birth; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 53 | ▶ | my $death_flag = uc( _first_value( $dm, qw(DTHFL) ) // q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
_first_value($dm, "DTHFL") // ""
MC/DC100%1/1
_first_value($dm, "DTHFL") // ""
_first_value($dm, "DTHFL")
Truth table100%2/2
A
A= _first_value($dm, "DTHFL")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 53 | my $death_date = _first_value( $dm, qw(DTHDTC) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 53 | ▶ | if ( $death_flag eq 'Y' || defined $death_date ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$death_flag eq "Y" or defined $death_date
MC/DC50%1/2
$death_flag eq "Y" or defined $death_date
$death_flag eq "Y"
defined $death_date
Truth table66%2/3
A or B
A= $death_flag eq "Y"B= defined $death_date
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | $individual->{info}{phenopacket}{vitalStatus} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 24 | status => 'DECEASED', | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 24 | my $death_timestamp = _timestamp($death_date); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | $individual->{info}{phenopacket}{vitalStatus}{timeOfDeath} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 24 | ▶ | timestamp => $death_timestamp, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | if defined $death_timestamp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 53 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 46 | ▶ | sub _map_medical_history { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_map_medical_history: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 46 | my ( $self, $row, $source_record ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | 46 | my ( $code_field, $code ) = _first_named_value( $row, qw(MHDECOD MHTERM) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 46 | ▶ | return unless defined $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 46 | my $label = _first_value( $row, qw(MHTERM MHDECOD) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 46 | diseaseCode => _resolved_source_term( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | $self, 'MH', $code_field, $code, $label, $code_field, $source_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 28 | ▶ | sub _map_adverse_event { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_map_adverse_event: called CC=5 SCAR=16.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 28 | my ( $self, $row, $source_record ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 28 | my ( $code_field, $code ) = _first_named_value( $row, qw(AEDECOD AETERM) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 28 | ▶ | return unless defined $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 28 | my $label = _first_value( $row, qw(AETERM AEDECOD) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 28 | my $feature = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | featureType => _resolved_source_term( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | $self, 'AE', $code_field, $code, $label, $code_field, $source_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | excluded => JSON::PP::false(), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 28 | my $severity = _first_value( $row, qw(AESEV) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 28 | ▶ | $feature->{severity} = _resolved_source_term( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | $self, 'AE', 'AESEV', $severity, $severity, 'AESEV', $source_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | if defined $severity; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 28 | my $onset = _timestamp( _first_value( $row, qw(AESTDTC) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 28 | my $resolution = _timestamp( _first_value( $row, qw(AEENDTC) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 28 | ▶ | $feature->{onset} = { timestamp => $onset } if defined $onset; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 28 | ▶ | $feature->{resolution} = { timestamp => $resolution } if defined $resolution; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 28 | return $feature; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 97 | ▶ | sub _map_measurement { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_map_measurement: called CC=14 SCAR=27.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 97 | my ( $self, $row, $source_record ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 97 | ▶ | my $domain = uc( _first_value( $row, qw(DOMAIN) ) // q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_first_value($row, "DOMAIN") // ""
MC/DC0%0/1
_first_value($row, "DOMAIN") // ""
_first_value($row, "DOMAIN")
Truth table50%1/2
A
A= _first_value($row, "DOMAIN")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 97 | ▶ | return unless $domain eq 'LB' || $domain eq 'VS'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$domain eq "LB" or $domain eq "VS"
MC/DC0%0/2
$domain eq "LB" or $domain eq "VS"
$domain eq "LB"
$domain eq "VS"
Truth table66%2/3
A or B
A= $domain eq "LB"B= $domain eq "VS"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 97 | my $test_code_field = $domain . 'TESTCD'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 97 | my $test_label_field = $domain . 'TEST'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 97 | my $result_number_field = $domain . 'STRESN'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 97 | my $result_text_field = $domain . 'STRESC'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 97 | my $unit_field = $domain . 'STRESU'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 97 | my $low_field = $domain . 'STNRLO'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 97 | my $high_field = $domain . 'STNRHI'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 97 | my $date_field = $domain . 'DTC'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 97 | my ( $code_field, $code ) = | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | _first_named_value( $row, $test_code_field, $test_label_field ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 97 | ▶ | return unless defined $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 97 | my $label = _first_value( $row, $test_label_field, $test_code_field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 97 | my $measure = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | assayCode => _resolved_source_term( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | $self, $domain, $code_field, $code, $label, $code_field, $source_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 97 | my $numeric = _first_value( $row, $result_number_field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 97 | ▶ | if ( defined $numeric && looks_like_number($numeric) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $numeric and &looks_like_number($numeric)
MC/DC50%1/2
defined $numeric and &looks_like_number($numeric)
defined $numeric
&looks_like_number($numeric)
Truth table66%2/3
A and B
A= defined $numericB= &looks_like_number($numeric)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 74 | my $unit_label = _first_value( $row, $unit_field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | my $unit = defined $unit_label | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ? _resolved_source_term( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | $self, $domain, $unit_field, $unit_label, $unit_label, 'UNIT', $source_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 74 | ▶ | : dclone( $DEFAULT->{ontology_term} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 74 | my $quantity = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | value => 0 + $numeric, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | unit => $unit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 74 | my $low = _first_value( $row, $low_field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 74 | my $high = _first_value( $row, $high_field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 74 | ▶ | if ( defined $low | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
defined $low and defined $high and &looks_like_number($low) and &looks_like_number($high)
defined $low and defined $high and &looks_like_number($low)
defined $low and defined $high
MC/DC25%1/4
defined $low and defined $high and &looks_like_number($low) and &looks_like_number($high)
defined $low
defined $high
&looks_like_number($low)
&looks_like_number($high)
Truth table40%2/5
A and B and C and D
A= defined $lowB= defined $highC= &looks_like_number($low)D= &looks_like_number($high)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | && defined $high | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | && looks_like_number($low) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | && looks_like_number($high) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | $quantity->{referenceRange} = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 46 | low => 0 + $low, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | high => 0 + $high, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | unit => dclone($unit), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 74 | $measure->{measurementValue} = { quantity => $quantity }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 23 | my $text = _first_value( $row, $result_text_field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 23 | ▶ | return unless defined $text; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 23 | $measure->{measurementValue} = _resolved_source_term( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | $self, $domain, $result_text_field, $text, $text, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | $result_text_field, $source_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 97 | my $date = _date( _first_value( $row, $date_field ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 97 | ▶ | $measure->{date} = $date if defined $date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 97 | return $measure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 28 | ▶ | sub _map_treatment { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_map_treatment: called CC=8 SCAR=21.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 28 | my ( $self, $row, $source_record ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 28 | ▶ | my $domain = uc( _first_value( $row, qw(DOMAIN) ) // q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_first_value($row, "DOMAIN") // ""
MC/DC0%0/1
_first_value($row, "DOMAIN") // ""
_first_value($row, "DOMAIN")
Truth table50%1/2
A
A= _first_value($row, "DOMAIN")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 28 | ▶ | return unless $domain eq 'CM' || $domain eq 'EX'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$domain eq "CM" or $domain eq "EX"
MC/DC0%0/2
$domain eq "CM" or $domain eq "EX"
$domain eq "CM"
$domain eq "EX"
Truth table66%2/3
A or B
A= $domain eq "CM"B= $domain eq "EX"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 28 | ▶ | my @code_fields = $domain eq 'CM' ? qw(CMDECOD CMTRT) : qw(EXTRT); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 28 | my ( $code_field, $code ) = _first_named_value( $row, @code_fields ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 28 | ▶ | return unless defined $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 28 | ▶ | my $label = $domain eq 'CM' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | ? _first_value( $row, qw(CMTRT CMDECOD) ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | : _first_value( $row, qw(EXTRT) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 28 | my $treatment = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | treatmentCode => _resolved_source_term( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | $self, $domain, $code_field, $code, $label, $code_field, $source_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 28 | my $route_field = $domain . 'ROUTE'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 28 | my $route = _first_value( $row, $route_field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | $treatment->{routeOfAdministration} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 28 | ▶ | _resolved_source_term( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | $self, $domain, $route_field, $route, $route, $route_field, $source_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | if defined $route; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 28 | return $treatment; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 14 | ▶ | sub _map_procedure { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_map_procedure: called CC=4 SCAR=14.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 14 | my ( $self, $row, $source_record ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 14 | my ( $code_field, $code ) = _first_named_value( $row, qw(PRDECOD PRTRT) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 14 | ▶ | return unless defined $code; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 14 | my $label = _first_value( $row, qw(PRTRT PRDECOD) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 14 | my $procedure = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | procedureCode => _resolved_source_term( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | $self, 'PR', $code_field, $code, $label, $code_field, $source_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 14 | my $date = _date( _first_value( $row, qw(PRSTDTC) ) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 14 | ▶ | $procedure->{dateOfProcedure} = $date if defined $date; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 14 | my $body_site = _first_value( $row, qw(PRLOC) ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 14 | ▶ | $procedure->{bodySite} = _resolved_source_term( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | $self, 'PR', 'PRLOC', $body_site, $body_site, 'PRLOC', $source_record | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | if defined $body_site; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 14 | return $procedure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 371 | ▶ | sub _append_mapped_rows { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_append_mapped_rows: called CC=6 SCAR=18.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 371 | my ( $self, $rows, $individual, $target, $mapper, $domain ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 371 | ▶ | return 1 unless ref($rows) eq 'ARRAY'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 190 | for my $index ( 0 .. $#{$rows} ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 213 | my $mapped = $mapper->( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | $rows->[$index], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | $domain . '[' . ( $index + 1 ) . ']', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 213 | ▶ | push @{ $individual->{$target} }, $mapped if defined $mapped; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | delete $individual->{$target} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | 190 | ▶ | if exists $individual->{$target} && !@{ $individual->{$target} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
exists $individual->{$target} and not @{$individual->{$target};}
MC/DC0%0/2
exists $individual->{$target} and not @{$individual->{$target};}
exists $individual->{$target}
not @{$individual->{$target};}
Truth table33%1/3
A and not(B)
A= exists $individual->{$target}B= not @{$individual->{$target};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 190 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 433 | ▶ | sub _resolved_source_term { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolved_source_term: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 433 | my ( $self, $domain, $field, $value, $label, $fallback_field, $source_record ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 433 | return resolve_sdtm_term( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | self => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | domain => $domain, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | field => $field, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | value => $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | label => $label, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | source_record => $source_record, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | fallback => _source_term( $fallback_field, $value, $label ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 53 | ▶ | sub _map_sex { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_map_sex: called CC=8 SCAR=28.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 53 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 53 | ▶ | my $sex = uc( _trim($value) // q{} ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_trim($value) // ""
MC/DC0%0/1
_trim($value) // ""
_trim($value)
Truth table50%1/2
A
A= _trim($value)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 53 | ▶ | return dclone( $DEFAULT->{sex}{male} ) if $sex eq 'M' || $sex eq 'MALE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$sex eq "M" or $sex eq "MALE"
MC/DC50%1/2
$sex eq "M" or $sex eq "MALE"
$sex eq "M"
$sex eq "MALE"
Truth table66%2/3
A or B
A= $sex eq "M"B= $sex eq "MALE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 27 | ▶ | return dclone( $DEFAULT->{sex}{female} ) if $sex eq 'F' || $sex eq 'FEMALE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$sex eq "F" or $sex eq "FEMALE"
MC/DC0%0/2
$sex eq "F" or $sex eq "FEMALE"
$sex eq "F"
$sex eq "FEMALE"
Truth table33%1/3
A or B
A= $sex eq "F"B= $sex eq "FEMALE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | return dclone( $DEFAULT->{sex}{other} ) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | if $sex eq 'UNDIFFERENTIATED' || $sex eq 'OTHER'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$sex eq "UNDIFFERENTIATED" or $sex eq "OTHER"
MC/DC0%0/2
$sex eq "UNDIFFERENTIATED" or $sex eq "OTHER"
$sex eq "UNDIFFERENTIATED"
$sex eq "OTHER"
Truth table0%0/3
A or B
A= $sex eq "UNDIFFERENTIATED"B= $sex eq "OTHER"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | return dclone( $DEFAULT->{sex}{unknown} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | # Dataset-JSON supplies SDTM codelist values rather than resolved ontology | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | # identifiers. These source-derived CURIEs preserve that identity without | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | # claiming that the value was mapped to an external terminology. Whitespace and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | # punctuation are normalized because Beacon API implementations commonly use | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | # CURIEs as path or query values even though the Beacon schema is permissive. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 433 | ▶ | sub _source_term { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_source_term: called CC=3 SCAR=12.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 433 | my ( $field, $value, $label ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 433 | my $component = _curie_component($value); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 433 | my $namespace = _curie_component($field); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 433 | ▶ | id => "CDISC:$namespace.$component", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $label and length _trim($label)
MC/DC0%0/2
defined $label and length _trim($label)
defined $label
length _trim($label)
Truth table33%1/3
A and B
A= defined $labelB= length _trim($label)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | label => defined $label && length _trim($label) ? _trim($label) : $value, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 866 | ▶ | sub _curie_component { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_curie_component: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 866 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 866 | ▶ | $value = uc( _trim($value) // 'NA' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
_trim($value) // "NA"
MC/DC0%0/1
_trim($value) // "NA"
_trim($value)
Truth table50%1/2
A
A= _trim($value)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 866 | $value =~ s/[^A-Z0-9._~-]+/_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 866 | $value =~ s/_+/_/g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 866 | $value =~ s/^[_\.]+|[_\.]+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 866 | ▶ | return length($value) ? $value : 'NA'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 213 | ▶ | sub _first_named_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_first_named_value: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 213 | my ( $row, @fields ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 213 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 213 | my $value = _first_value( $row, $field ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 213 | ▶ | return ( $field, $value ) if defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 1395 | ▶ | sub _first_value { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_first_value: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 1395 | my ( $row, @fields ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 1395 | for my $field (@fields) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 1395 | ▶ | next unless exists $row->{$field}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 1273 | my $value = _trim( $row->{$field} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 1273 | ▶ | return $value if defined $value && length $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $value and length $value
MC/DC100%2/2
defined $value and length $value
defined $value
length $value
Truth table100%3/3
A and B
A= defined $valueB= length $value
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | 170 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 111 | ▶ | sub _date { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_date: called CC=3 SCAR=12.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 111 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 111 | ▶ | return unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 111 | ▶ | return $1 if $value =~ /\A(\d{4}-\d{2}-\d{2})(?:T|\z)/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 133 | ▶ | sub _timestamp { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_timestamp: called CC=5 SCAR=18.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 133 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 133 | ▶ | return unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 105 | ▶ | return "$1T00:00:00Z" if $value =~ /\A(\d{4}-\d{2}-\d{2})\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 28 | ▶ | return $value if $value =~ /\A\d{4}-\d{2}-\d{2}T.*(?:Z|[+-]\d{2}:?\d{2})\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | return $value . 'Z' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | if $value =~ /\A\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 3058 | ▶ | sub _trim { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_trim: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 3058 | my ($value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 3058 | ▶ | return unless defined $value; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 3040 | ▶ | return $value if ref($value); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 3040 | $value =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 3040 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 136 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||