| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package WebService::ClinicalTrialsdotGov::Reply; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 3 |  |  | 3 |  | 16 | use strict; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 115 |  | 
| 4 | 3 |  |  | 3 |  | 17 | use warnings; | 
|  | 3 |  |  |  |  | 6 |  | 
|  | 3 |  |  |  |  | 96 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 | 3 |  |  | 3 |  | 1759 | use WebService::ClinicalTrialsdotGov::Parser; | 
|  | 0 |  |  |  |  |  |  | 
|  | 0 |  |  |  |  |  |  | 
| 7 |  |  |  |  |  |  | use WebService::ClinicalTrialsdotGov::SearchResult; | 
| 8 |  |  |  |  |  |  | use WebService::ClinicalTrialsdotGov::Study; | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | use Carp qw( cluck ); | 
| 12 |  |  |  |  |  |  | use Data::Dumper; | 
| 13 |  |  |  |  |  |  |  | 
| 14 |  |  |  |  |  |  | =head1 NAME | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  | WebService::ClinicalTrialsdotGov::Reply - Wrapper around the clinicaltrials.gov API | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | =head1 FUNCTIONS | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | =head2 new | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | Create a new instance of the reply object. | 
| 23 |  |  |  |  |  |  | Do not use this function directly. | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =cut | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | sub new { | 
| 28 |  |  |  |  |  |  | my $class     = shift; | 
| 29 |  |  |  |  |  |  | my $rh_params = shift; | 
| 30 |  |  |  |  |  |  | my $raw_data  = shift; | 
| 31 |  |  |  |  |  |  | my $self      = { }; | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | return undef | 
| 34 |  |  |  |  |  |  | unless defined $raw_data; | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | bless $self, $class; | 
| 37 |  |  |  |  |  |  |  | 
| 38 |  |  |  |  |  |  | $self->{parser} = | 
| 39 |  |  |  |  |  |  | WebService::ClinicalTrialsdotGov::Parser->new(); | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | $self->{decoded} = | 
| 42 |  |  |  |  |  |  | $self->{parser}->parse( $raw_data ); | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | return $self; | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | =head2 get_study | 
| 49 |  |  |  |  |  |  |  | 
| 50 |  |  |  |  |  |  | my $Study = $Results->get_study; | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | A series of accessors are provided: | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | oversight_info | 
| 55 |  |  |  |  |  |  | detailed_description | 
| 56 |  |  |  |  |  |  | study_type | 
| 57 |  |  |  |  |  |  | primary_completion_date | 
| 58 |  |  |  |  |  |  | primary_outcome | 
| 59 |  |  |  |  |  |  | intervention | 
| 60 |  |  |  |  |  |  | intervention_browse | 
| 61 |  |  |  |  |  |  | has_expanded_access | 
| 62 |  |  |  |  |  |  | arm_group | 
| 63 |  |  |  |  |  |  | number_of_arms | 
| 64 |  |  |  |  |  |  | overall_official | 
| 65 |  |  |  |  |  |  | brief_title | 
| 66 |  |  |  |  |  |  | study_design | 
| 67 |  |  |  |  |  |  | location | 
| 68 |  |  |  |  |  |  | id_info | 
| 69 |  |  |  |  |  |  | firstreceived_date | 
| 70 |  |  |  |  |  |  | overall_contact | 
| 71 |  |  |  |  |  |  | overall_status | 
| 72 |  |  |  |  |  |  | verification_date | 
| 73 |  |  |  |  |  |  | source | 
| 74 |  |  |  |  |  |  | keyword | 
| 75 |  |  |  |  |  |  | sponsors | 
| 76 |  |  |  |  |  |  | official_title | 
| 77 |  |  |  |  |  |  | enrollment | 
| 78 |  |  |  |  |  |  | condition_browse | 
| 79 |  |  |  |  |  |  | brief_summary | 
| 80 |  |  |  |  |  |  | location_countries | 
| 81 |  |  |  |  |  |  | is_section_801 | 
| 82 |  |  |  |  |  |  | secondary_outcome | 
| 83 |  |  |  |  |  |  | responsible_party | 
| 84 |  |  |  |  |  |  | eligibility | 
| 85 |  |  |  |  |  |  | phase | 
| 86 |  |  |  |  |  |  | lastchanged_date | 
| 87 |  |  |  |  |  |  | start_date | 
| 88 |  |  |  |  |  |  | is_fda_regulated | 
| 89 |  |  |  |  |  |  | required_header | 
| 90 |  |  |  |  |  |  | overall_contact_backup | 
| 91 |  |  |  |  |  |  | condition | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | This function returns a I object for a single study. | 
| 94 |  |  |  |  |  |  | This function returns I on error. | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  | =cut | 
| 97 |  |  |  |  |  |  |  | 
| 98 |  |  |  |  |  |  | sub get_study { | 
| 99 |  |  |  |  |  |  | my $self = shift; | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | my $study_content = | 
| 102 |  |  |  |  |  |  | $self->{decoded}; | 
| 103 |  |  |  |  |  |  |  | 
| 104 |  |  |  |  |  |  | return undef | 
| 105 |  |  |  |  |  |  | unless defined $study_content && $study_content; | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | return  WebService::ClinicalTrialsdotGov::Study->new( $study_content ); | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | } | 
| 110 |  |  |  |  |  |  |  | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | =head2 get_search_results | 
| 113 |  |  |  |  |  |  |  | 
| 114 |  |  |  |  |  |  | my $ra_all_obj = | 
| 115 |  |  |  |  |  |  | $Results->get_search_results; | 
| 116 |  |  |  |  |  |  |  | 
| 117 |  |  |  |  |  |  | A series of accessors are provided: | 
| 118 |  |  |  |  |  |  |  | 
| 119 |  |  |  |  |  |  | last_changed | 
| 120 |  |  |  |  |  |  | condition_summary | 
| 121 |  |  |  |  |  |  | nct_id | 
| 122 |  |  |  |  |  |  | status | 
| 123 |  |  |  |  |  |  | order | 
| 124 |  |  |  |  |  |  | url | 
| 125 |  |  |  |  |  |  | title | 
| 126 |  |  |  |  |  |  | score | 
| 127 |  |  |  |  |  |  |  | 
| 128 |  |  |  |  |  |  | This function returns a reference to an array of I objects. | 
| 129 |  |  |  |  |  |  | The nct_id field can be used to obtain the data on individual studies. | 
| 130 |  |  |  |  |  |  | This function returns I on error. | 
| 131 |  |  |  |  |  |  |  | 
| 132 |  |  |  |  |  |  | =cut | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | sub get_search_results { | 
| 135 |  |  |  |  |  |  | my $self = shift; | 
| 136 |  |  |  |  |  |  | my $ra_studies = | 
| 137 |  |  |  |  |  |  | $self->{decoded}->{clinical_study} || [ ]; | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | return undef | 
| 140 |  |  |  |  |  |  | unless defined $ra_studies && scalar(@$ra_studies); | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  | my $ra_out = [ ]; | 
| 143 |  |  |  |  |  |  |  | 
| 144 |  |  |  |  |  |  | foreach my $rh_study ( @$ra_studies ) { | 
| 145 |  |  |  |  |  |  | my $obj = | 
| 146 |  |  |  |  |  |  | WebService::ClinicalTrialsdotGov::SearchResult->new( $rh_study ); | 
| 147 |  |  |  |  |  |  | push( @$ra_out, $obj ); | 
| 148 |  |  |  |  |  |  | } | 
| 149 |  |  |  |  |  |  | return $ra_out; | 
| 150 |  |  |  |  |  |  | } | 
| 151 |  |  |  |  |  |  |  | 
| 152 |  |  |  |  |  |  | =head2 count_total | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | my $num = $Results->count; | 
| 155 |  |  |  |  |  |  |  | 
| 156 |  |  |  |  |  |  | Returns the total number of search results reported by the API. | 
| 157 |  |  |  |  |  |  | This function returns I on error. | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | =cut | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | sub count_total { | 
| 162 |  |  |  |  |  |  | my $self = shift; | 
| 163 |  |  |  |  |  |  | return $self->{decoded}->{count} || 0; | 
| 164 |  |  |  |  |  |  | } | 
| 165 |  |  |  |  |  |  |  | 
| 166 |  |  |  |  |  |  | =head2 count | 
| 167 |  |  |  |  |  |  |  | 
| 168 |  |  |  |  |  |  | my $num = $Results->count; | 
| 169 |  |  |  |  |  |  |  | 
| 170 |  |  |  |  |  |  | Returns the total number of search results returned by the API. | 
| 171 |  |  |  |  |  |  | This function return I on error. | 
| 172 |  |  |  |  |  |  |  | 
| 173 |  |  |  |  |  |  | =cut | 
| 174 |  |  |  |  |  |  |  | 
| 175 |  |  |  |  |  |  | sub count { | 
| 176 |  |  |  |  |  |  | my $self = shift; | 
| 177 |  |  |  |  |  |  | my $ra_all = | 
| 178 |  |  |  |  |  |  | $self->get_all_studies(); | 
| 179 |  |  |  |  |  |  | return scalar(@$ra_all); | 
| 180 |  |  |  |  |  |  | } | 
| 181 |  |  |  |  |  |  |  | 
| 182 |  |  |  |  |  |  | =head1 AUTHOR | 
| 183 |  |  |  |  |  |  |  | 
| 184 |  |  |  |  |  |  | Spiros Denaxas, C<<  >> | 
| 185 |  |  |  |  |  |  |  | 
| 186 |  |  |  |  |  |  | =head1 BUGS | 
| 187 |  |  |  |  |  |  |  | 
| 188 |  |  |  |  |  |  | Please report any bugs or feature requests to C, or through | 
| 189 |  |  |  |  |  |  | the web interface at L.  I will be notified, and then you'll | 
| 190 |  |  |  |  |  |  | automatically be notified of progress on your bug as I make changes. | 
| 191 |  |  |  |  |  |  |  | 
| 192 |  |  |  |  |  |  | =head1 SUPPORT | 
| 193 |  |  |  |  |  |  |  | 
| 194 |  |  |  |  |  |  | You can find documentation for this module with the perldoc command. | 
| 195 |  |  |  |  |  |  |  | 
| 196 |  |  |  |  |  |  | perldoc WebService::ClinicalTrialsdotGov | 
| 197 |  |  |  |  |  |  |  | 
| 198 |  |  |  |  |  |  | You can also look for information at: | 
| 199 |  |  |  |  |  |  |  | 
| 200 |  |  |  |  |  |  | =over 4 | 
| 201 |  |  |  |  |  |  |  | 
| 202 |  |  |  |  |  |  | =item * RT: CPAN's request tracker | 
| 203 |  |  |  |  |  |  |  | 
| 204 |  |  |  |  |  |  | L | 
| 205 |  |  |  |  |  |  |  | 
| 206 |  |  |  |  |  |  | =item * AnnoCPAN: Annotated CPAN documentation | 
| 207 |  |  |  |  |  |  |  | 
| 208 |  |  |  |  |  |  | L | 
| 209 |  |  |  |  |  |  |  | 
| 210 |  |  |  |  |  |  | =item * CPAN Ratings | 
| 211 |  |  |  |  |  |  |  | 
| 212 |  |  |  |  |  |  | L | 
| 213 |  |  |  |  |  |  |  | 
| 214 |  |  |  |  |  |  | =item * Search CPAN | 
| 215 |  |  |  |  |  |  |  | 
| 216 |  |  |  |  |  |  | L | 
| 217 |  |  |  |  |  |  |  | 
| 218 |  |  |  |  |  |  | =back | 
| 219 |  |  |  |  |  |  |  | 
| 220 |  |  |  |  |  |  | =head1 COPYRIGHT & LICENSE | 
| 221 |  |  |  |  |  |  |  | 
| 222 |  |  |  |  |  |  | Copyright 2010 Spiros Denaxas, all rights reserved. | 
| 223 |  |  |  |  |  |  |  | 
| 224 |  |  |  |  |  |  | This program is free software; you can redistribute it and/or modify it | 
| 225 |  |  |  |  |  |  | under the same terms as Perl itself. | 
| 226 |  |  |  |  |  |  |  | 
| 227 |  |  |  |  |  |  | =cut | 
| 228 |  |  |  |  |  |  |  | 
| 229 |  |  |  |  |  |  | 1; |