line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package WebService::ClinicalTrialsdotGov; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
39559
|
use warnings; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
228
|
|
4
|
3
|
|
|
3
|
|
20
|
use strict; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
132
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
18
|
use Carp qw( cluck ); |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
217
|
|
7
|
3
|
|
|
3
|
|
3690
|
use LWP::UserAgent; |
|
3
|
|
|
|
|
180630
|
|
|
3
|
|
|
|
|
209
|
|
8
|
3
|
|
|
3
|
|
2506
|
use Data::Dumper; |
|
3
|
|
|
|
|
16015
|
|
|
3
|
|
|
|
|
255
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
2215
|
use WebService::ClinicalTrialsdotGov::Request; |
|
3
|
|
|
|
|
27
|
|
|
3
|
|
|
|
|
118
|
|
11
|
3
|
|
|
3
|
|
1998
|
use WebService::ClinicalTrialsdotGov::Reply; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
my $RH_VALID_MODES = { |
16
|
|
|
|
|
|
|
'search' => 1, |
17
|
|
|
|
|
|
|
'show' => 1, |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $RH_REQUIRED_PARAMS = { |
21
|
|
|
|
|
|
|
'search' => { |
22
|
|
|
|
|
|
|
'term' => 1, |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
'show' => { |
26
|
|
|
|
|
|
|
'id' => 1, |
27
|
|
|
|
|
|
|
}, |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
}; |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my $RH_VALID_PARAMS = { |
32
|
|
|
|
|
|
|
'search' => { |
33
|
|
|
|
|
|
|
'start' => 1, |
34
|
|
|
|
|
|
|
'count' => 1, |
35
|
|
|
|
|
|
|
'term' => 1, |
36
|
|
|
|
|
|
|
'recr' => 1, |
37
|
|
|
|
|
|
|
'displayxml' => 1, |
38
|
|
|
|
|
|
|
}, |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
'show' => { |
41
|
|
|
|
|
|
|
'id' => 1, |
42
|
|
|
|
|
|
|
}, |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
}; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
my $RH_DEFAULT_PARAMS = { |
47
|
|
|
|
|
|
|
'search' => { |
48
|
|
|
|
|
|
|
'count' => '20', |
49
|
|
|
|
|
|
|
'start' => '0', |
50
|
|
|
|
|
|
|
'displayxml' => 'true', |
51
|
|
|
|
|
|
|
}, |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
'show' => { |
54
|
|
|
|
|
|
|
'displayxml' => 'true', |
55
|
|
|
|
|
|
|
}, |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
}; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=head1 NAME |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
WebService::ClinicalTrialsdotGov - Wrapper around the clinicaltrials.gov API |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 SYNOPSIS |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
For a generic search: |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
use WebService::ClinicalTrialsdotGov; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
my $rh_params = { |
70
|
|
|
|
|
|
|
'term' => 'cancer', |
71
|
|
|
|
|
|
|
'start' => 0, |
72
|
|
|
|
|
|
|
'count' => 10, |
73
|
|
|
|
|
|
|
'mode' => 'search', |
74
|
|
|
|
|
|
|
}; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $CT = |
77
|
|
|
|
|
|
|
WebService::ClinicalTrialsdotGov->new( $rh_params ); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
my $Results = $CT->results; |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
my $ra_all = |
82
|
|
|
|
|
|
|
$Results->get_search_results; |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
foreach my $Study ( @$ra_all ) { |
85
|
|
|
|
|
|
|
print $Study->title; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
For obtaining the details of a specific study: |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
use WebService::ClinicalTrialsdotGov; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
my $rh_params = { |
93
|
|
|
|
|
|
|
'id' => 'NCT00622401', |
94
|
|
|
|
|
|
|
'mode' => 'show', |
95
|
|
|
|
|
|
|
}; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
my $CT = |
98
|
|
|
|
|
|
|
WebService::ClinicalTrialsdotGov->new( $rh_params ); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
my $Results = $CT->results; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $Study = |
103
|
|
|
|
|
|
|
$Results->get_study; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 FUNCTIONS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 new |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Creates a new instance of the module. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
my $rh_params = { |
112
|
|
|
|
|
|
|
'term' => 'cancer', |
113
|
|
|
|
|
|
|
'start' => 0, |
114
|
|
|
|
|
|
|
'count' => 10, |
115
|
|
|
|
|
|
|
'mode' => 'search', |
116
|
|
|
|
|
|
|
}; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
my $CT = |
119
|
|
|
|
|
|
|
WebService::ClinicalTrialsdotGov->new( $rh_params ); |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
The I parameter can either be I for a generic search using the contents |
122
|
|
|
|
|
|
|
of the I parameter as the query or be I using the contents of the I paramter |
123
|
|
|
|
|
|
|
for identifying the study's ncd_id. |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
One can additionally specific a stating offset using I and a max results offset |
126
|
|
|
|
|
|
|
using I. By default, the API will return 20 results. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This function returns I on error. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=cut |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
sub new { |
133
|
|
|
|
|
|
|
my $class = shift; |
134
|
|
|
|
|
|
|
my $rh_params = shift; |
135
|
|
|
|
|
|
|
my $self = { }; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
## |
138
|
|
|
|
|
|
|
## Check for valid mode |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
cluck "Invalid search mode: $rh_params->{mode} " |
141
|
|
|
|
|
|
|
unless ( exists $RH_VALID_MODES->{ $rh_params->{mode} } ); |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
## |
144
|
|
|
|
|
|
|
## Check for required params |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
foreach my $k ( keys %{ $RH_REQUIRED_PARAMS->{ $rh_params->{mode} } } ) { |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
cluck "Required parameter $k is missing." |
149
|
|
|
|
|
|
|
unless ( $rh_params->{$k} ); |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
}; |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
## |
154
|
|
|
|
|
|
|
## Fill in some defaults |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
foreach my $k ( keys %{ $RH_DEFAULT_PARAMS->{ $rh_params->{mode} } } ) { |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
unless ( exists $rh_params->{$k} ) { |
159
|
|
|
|
|
|
|
$rh_params->{$k} = $RH_DEFAULT_PARAMS->{ $rh_params->{mode} }->{$k}; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
$self->{request} = |
165
|
|
|
|
|
|
|
WebService::ClinicalTrialsdotGov::Request->new( $rh_params ); |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
$self->{agent} = |
168
|
|
|
|
|
|
|
LWP::UserAgent->new( ); |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
$self->{params} = |
171
|
|
|
|
|
|
|
$rh_params; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
return bless $self, $class; |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 results |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
my $ResultsObject = $CT->results; |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
This function returns a I object which can be |
182
|
|
|
|
|
|
|
interrogated to obtain the results in some form or shape. |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
This function returns I on error. |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
=cut |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
sub results { |
189
|
|
|
|
|
|
|
my $self = shift; |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
my $response = |
192
|
|
|
|
|
|
|
$self->{agent}->request( $self->{request}->request ); |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
if ( $response->is_success ) { |
195
|
|
|
|
|
|
|
return |
196
|
|
|
|
|
|
|
WebService::ClinicalTrialsdotGov::Reply->new( $self->{params}, $response->decoded_content ); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
else { |
199
|
|
|
|
|
|
|
cluck $response->status_line; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
} |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=head1 AUTHOR |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
Spiros Denaxas, C<< >> |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
=head1 BUGS |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
211
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
212
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=head1 SUPPORT |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
perldoc WebService::ClinicalTrialsdotGov |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
You can also look for information at: |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=over 4 |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
L |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
L |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * CPAN Ratings |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
L |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * Search CPAN |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
L |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=back |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
Copyright 2010 Spiros Denaxas, all rights reserved. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
247
|
|
|
|
|
|
|
under the same terms as Perl itself. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
1; |