Class: CTG::Query
- Inherits:
-
Object
- Object
- CTG::Query
- Defined in:
- lib/ctg/query.rb
Instance Attribute Summary collapse
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
-
#advanced_filter(expression) ⇒ CTG::Query
Add an advanced filter using the Essie expression syntax.
-
#condition(condition) ⇒ CTG::Query
Add a condition or disease to the query.
-
#format(format = 'json') ⇒ CTG::Query
Set the response format (json or csv).
-
#geo_filter(geo) ⇒ CTG::Query
Add a geographical filter based on distance.
-
#initialize ⇒ Query
constructor
A new instance of Query.
-
#intervention(intervention) ⇒ CTG::Query
Add an intervention or treatment to the query.
-
#lead_sponsor(lead_sponsor) ⇒ CTG::Query
Add a lead sponsor to the query.
-
#location(location) ⇒ CTG::Query
Add a location filter to the query.
-
#nct_ids(*ids) ⇒ CTG::Query
Add a filter for specific NCT IDs.
-
#outcome(outcome) ⇒ CTG::Query
Add an outcome measure to the query.
-
#page_size(page_size = 1000) ⇒ CTG::Query
Set the number of results per page.
-
#page_token(token) ⇒ CTG::Query
Token to get next page.
-
#patient(patient) ⇒ CTG::Query
Add a patient-related search to the query.
-
#sort_by(sort_by, direction = 'asc') ⇒ CTG::Query
Set the sorting order for the results.
-
#sponsor(sponsor) ⇒ CTG::Query
Add a sponsor or collaborator to the query.
-
#status(*statuses) ⇒ CTG::Query
Adds an overall status filter to the query.
-
#study_id(study_id) ⇒ CTG::Query
Adds a study ID filter to the query.
-
#term(term) ⇒ CTG::Query
Add a term to the query.
-
#title(title) ⇒ CTG::Query
Add a title or acronym to the query.
-
#total ⇒ CTG::Query
Count total number of studies.
Constructor Details
#initialize ⇒ Query
Returns a new instance of Query.
43 44 45 |
# File 'lib/ctg/query.rb', line 43 def initialize @params = {} end |
Instance Attribute Details
#params ⇒ Object (readonly)
Returns the value of attribute params.
41 42 43 |
# File 'lib/ctg/query.rb', line 41 def params @params end |
Instance Method Details
#advanced_filter(expression) ⇒ CTG::Query
Add an advanced filter using the Essie expression syntax
154 155 156 157 |
# File 'lib/ctg/query.rb', line 154 def advanced_filter(expression) @params['filter.advanced'] = expression self end |
#condition(condition) ⇒ CTG::Query
Add a condition or disease to the query
50 51 52 53 |
# File 'lib/ctg/query.rb', line 50 def condition(condition) @params['query.cond'] = condition self end |
#format(format = 'json') ⇒ CTG::Query
Set the response format (json or csv)
162 163 164 165 |
# File 'lib/ctg/query.rb', line 162 def format(format = 'json') @params['format'] = format self end |
#geo_filter(geo) ⇒ CTG::Query
Add a geographical filter based on distance
138 139 140 141 |
# File 'lib/ctg/query.rb', line 138 def geo_filter(geo) @params['filter.geo'] = geo self end |
#intervention(intervention) ⇒ CTG::Query
Add an intervention or treatment to the query
82 83 84 85 |
# File 'lib/ctg/query.rb', line 82 def intervention(intervention) @params['query.intr'] = intervention self end |
#lead_sponsor(lead_sponsor) ⇒ CTG::Query
Add a lead sponsor to the query
106 107 108 109 |
# File 'lib/ctg/query.rb', line 106 def lead_sponsor(lead_sponsor) @params['query.lead'] = lead_sponsor self end |
#location(location) ⇒ CTG::Query
Add a location filter to the query
66 67 68 69 |
# File 'lib/ctg/query.rb', line 66 def location(location) @params['query.locn'] = location self end |
#nct_ids(*ids) ⇒ CTG::Query
Add a filter for specific NCT IDs
146 147 148 149 |
# File 'lib/ctg/query.rb', line 146 def nct_ids(*ids) @params['filter.ids'] = ids.join('|') self end |
#outcome(outcome) ⇒ CTG::Query
Add an outcome measure to the query
90 91 92 93 |
# File 'lib/ctg/query.rb', line 90 def outcome(outcome) @params['query.outc'] = outcome self end |
#page_size(page_size = 1000) ⇒ CTG::Query
Set the number of results per page. If not specified or set to 0, the default value will be used. It will be coerced down to 1,000, if greater than that.
171 172 173 174 |
# File 'lib/ctg/query.rb', line 171 def page_size(page_size = 1000) @params['pageSize'] = page_size self end |
#page_token(token) ⇒ CTG::Query
Token to get next page. Set it to a nextPageToken value returned with the previous page in JSON format. For CSV, it can be found in x-next-page-token response header. Do not specify it for first page.
196 197 198 199 |
# File 'lib/ctg/query.rb', line 196 def page_token(token) @params['pageToken'] = token self end |
#patient(patient) ⇒ CTG::Query
Add a patient-related search to the query
122 123 124 125 |
# File 'lib/ctg/query.rb', line 122 def patient(patient) @params['query.patient'] = patient self end |
#sort_by(sort_by, direction = 'asc') ⇒ CTG::Query
Set the sorting order for the results
180 181 182 183 |
# File 'lib/ctg/query.rb', line 180 def sort_by(sort_by, direction = 'asc') @params['sort'] = "#{sort_by}:#{direction}" self end |
#sponsor(sponsor) ⇒ CTG::Query
Add a sponsor or collaborator to the query
98 99 100 101 |
# File 'lib/ctg/query.rb', line 98 def sponsor(sponsor) @params['query.spons'] = sponsor self end |
#status(*statuses) ⇒ CTG::Query
Adds an overall status filter to the query
130 131 132 133 |
# File 'lib/ctg/query.rb', line 130 def status(*statuses) @params['filter.overallStatus'] = statuses.join(',') self end |
#study_id(study_id) ⇒ CTG::Query
Adds a study ID filter to the query
114 115 116 117 |
# File 'lib/ctg/query.rb', line 114 def study_id(study_id) @params['query.id'] = study_id self end |
#term(term) ⇒ CTG::Query
Add a term to the query
58 59 60 61 |
# File 'lib/ctg/query.rb', line 58 def term(term) @params['query.term'] = term self end |
#title(title) ⇒ CTG::Query
Add a title or acronym to the query
74 75 76 77 |
# File 'lib/ctg/query.rb', line 74 def title(title) @params['query.titles'] = title self end |
#total ⇒ CTG::Query
Count total number of studies. The parameter is ignored for the subsequent pages.
187 188 189 190 |
# File 'lib/ctg/query.rb', line 187 def total @params['countTotal'] = true self end |