line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::Parser::ClinicalTrials::Study; |
2
|
|
|
|
|
|
|
{ |
3
|
|
|
|
|
|
|
$XML::Parser::ClinicalTrials::Study::VERSION = '1.20140111'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
287158
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
49
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use constant PREFIX => 'XML::Parser::ClinicalTrials::Study'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
79
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
363756
|
use XML::Rabbit::Root; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use DateTime::Format::Natural; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has_xpath_value nct_number => './id_info/nct_id'; |
14
|
|
|
|
|
|
|
has_xpath_value sponsor => './sponsors/lead_sponsor/agency'; |
15
|
|
|
|
|
|
|
has_xpath_value condition => './condition'; |
16
|
|
|
|
|
|
|
has_xpath_value study_design => './study_design'; |
17
|
|
|
|
|
|
|
has_xpath_value description_raw => './detailed_description/textblock'; |
18
|
|
|
|
|
|
|
has_xpath_value recruitment_status => './overall_status'; |
19
|
|
|
|
|
|
|
has_xpath_value source => './source'; |
20
|
|
|
|
|
|
|
has_xpath_value summary_raw => './brief_summary/textblock'; |
21
|
|
|
|
|
|
|
has_xpath_value type => './study_type'; |
22
|
|
|
|
|
|
|
has_xpath_value brief_title => './brief_title'; |
23
|
|
|
|
|
|
|
has_xpath_value official_title => './official_title'; |
24
|
|
|
|
|
|
|
has_xpath_value phase => './phase'; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has_xpath_value start_date_raw => './start_date'; |
27
|
|
|
|
|
|
|
has_xpath_value last_changed_raw => './lastchanged_date'; |
28
|
|
|
|
|
|
|
has_xpath_value first_received_raw => './firstreceived_date'; |
29
|
|
|
|
|
|
|
has_xpath_value completion_date_raw => |
30
|
|
|
|
|
|
|
q|./completion_date[@type='Actual']|; |
31
|
|
|
|
|
|
|
has_xpath_value estimated_completion_date_raw => |
32
|
|
|
|
|
|
|
q|./completion_date[@type='Anticipated']|; |
33
|
|
|
|
|
|
|
has_xpath_value primary_completion_date_raw => |
34
|
|
|
|
|
|
|
q|./primary_completion_date[@type='Actual']|; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has_xpath_value actual_enrollment => q|./enrollment[@type='Actual']|; |
37
|
|
|
|
|
|
|
has_xpath_value estimated_enrollment => q|./enrollment[@type='Anticipated']|; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has_xpath_value_list secondary_ids => |
40
|
|
|
|
|
|
|
'./id_info/org_study_id|./id_info/secondary_id'; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has_xpath_value_list sponsors => |
43
|
|
|
|
|
|
|
'./sponsors/lead_sponsor/agency|./sponsors/collaborator/agency'; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
has_xpath_object_list link => './link' |
46
|
|
|
|
|
|
|
=> PREFIX . '::Link'; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
has_xpath_object_list interventions => |
49
|
|
|
|
|
|
|
'./intervention' => PREFIX . '::Intervention'; |
50
|
|
|
|
|
|
|
has_xpath_object_list design => |
51
|
|
|
|
|
|
|
'./study_design' => PREFIX . '::Design'; |
52
|
|
|
|
|
|
|
has_xpath_object_list mesh_terms => |
53
|
|
|
|
|
|
|
'./condition_browse/mesh_term|./intervention_browse/mesh_term' |
54
|
|
|
|
|
|
|
=> PREFIX . '::MeSHTerm'; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has_xpath_object_list locations => './location' |
57
|
|
|
|
|
|
|
=> PREFIX . '::Location'; |
58
|
|
|
|
|
|
|
has_xpath_object_list contacts => './overall_contact|./overall_contact_backup' |
59
|
|
|
|
|
|
|
=> PREFIX . '::Contact'; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
has [qw( last_changed first_received start_date completion_date |
62
|
|
|
|
|
|
|
estimated_completion_date primary_completion_date )], is => 'rw'; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
has 'summary', is => 'ro', lazy => 1, builder => '_build_summary'; |
65
|
|
|
|
|
|
|
has 'description', is => 'ro', lazy => 1, builder => '_build_description'; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has 'normalized_phase', is => 'ro', lazy => 1, |
68
|
|
|
|
|
|
|
builder => '_build_normalized_phase'; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub _build_summary { |
71
|
|
|
|
|
|
|
my $raw = $_[0]->summary_raw; |
72
|
|
|
|
|
|
|
return unless $raw; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
$raw =~ s/\s+/ /g; |
75
|
|
|
|
|
|
|
$raw =~ s/\n/ /g; |
76
|
|
|
|
|
|
|
$raw =~ s/\A\s+|\s+\Z//g; |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
return $raw; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _build_description { |
82
|
|
|
|
|
|
|
my $raw = $_[0]->description_raw; |
83
|
|
|
|
|
|
|
return unless $raw; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
my @lines = split /\n\n/, $raw; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
do { |
88
|
|
|
|
|
|
|
s/^\s+|\s+$//g; |
89
|
|
|
|
|
|
|
s/\s+/ /g; |
90
|
|
|
|
|
|
|
} for @lines; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
return join "\n\n", @lines; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _build_normalized_phase { |
96
|
|
|
|
|
|
|
state $phases = { |
97
|
|
|
|
|
|
|
1 => 'I', |
98
|
|
|
|
|
|
|
2 => 'II', |
99
|
|
|
|
|
|
|
3 => 'III', |
100
|
|
|
|
|
|
|
4 => 'IV', |
101
|
|
|
|
|
|
|
5 => 'V', |
102
|
|
|
|
|
|
|
}; |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
my $raw = $_[0]->phase; |
105
|
|
|
|
|
|
|
return if $raw eq 'N/A'; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$raw =~ s/Phase (\d+)/$phases->{$1}/gi; |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
return $raw; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
has [qw( last_changed first_received start_date |
113
|
|
|
|
|
|
|
completion_date estimated_completion_date primary_completion_date )], |
114
|
|
|
|
|
|
|
is => 'ro', lazy_build => 1; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub _build_last_changed { $_[0]->_normalize_date( 'last_changed_raw' ) } |
117
|
|
|
|
|
|
|
sub _build_first_received { $_[0]->_normalize_date( 'first_received_raw' ) } |
118
|
|
|
|
|
|
|
sub _build_start_date { $_[0]->_normalize_date( 'start_date_raw' ) } |
119
|
|
|
|
|
|
|
sub _build_completion_date { $_[0]->_normalize_date( 'completion_date_raw' ) } |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
sub _build_estimated_completion_date { |
122
|
|
|
|
|
|
|
$_[0]->_normalize_date( 'estimated_completion_date_raw' ) |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub _build_primary_completion_date { |
126
|
|
|
|
|
|
|
$_[0]->_normalize_date( 'primary_completion_date_raw' ) |
127
|
|
|
|
|
|
|
} |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub _normalize_date { |
130
|
|
|
|
|
|
|
my ($self, $raw) = @_; |
131
|
|
|
|
|
|
|
my $value = $self->$raw; |
132
|
|
|
|
|
|
|
return unless $value; |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
return DateTime::Format::Natural->new->parse_datetime( $value )->ymd; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
finalize_class(); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
__END__ |