Class: CtGov::ClinicalTrial
- Inherits:
-
Object
- Object
- CtGov::ClinicalTrial
- Defined in:
- lib/ct_gov/clinical_trial.rb
Instance Method Summary collapse
- #brief_summary ⇒ Object
- #brief_title ⇒ Object
- #browse_conditions ⇒ Object
- #browse_interventions ⇒ Object
- #completion_date ⇒ Object
- #detailed_description ⇒ Object
- #eligibility_description ⇒ Object
- #healthy_volunteers? ⇒ Boolean
-
#initialize(raw_trial) ⇒ ClinicalTrial
constructor
A new instance of ClinicalTrial.
- #keywords ⇒ Object
- #locations ⇒ Object
- #max_age ⇒ Object
- #min_age ⇒ Object
- #nctid ⇒ Object
- #official_title ⇒ Object
- #overall_contacts ⇒ Object
- #overall_official ⇒ Object
- #overall_status ⇒ Object
- #primary_completion_date ⇒ Object
- #publications ⇒ Object
- #start_date ⇒ Object
- #study_type ⇒ Object
Constructor Details
#initialize(raw_trial) ⇒ ClinicalTrial
Returns a new instance of ClinicalTrial.
3 4 5 |
# File 'lib/ct_gov/clinical_trial.rb', line 3 def initialize(raw_trial) @raw_trial = raw_trial end |
Instance Method Details
#brief_summary ⇒ Object
65 66 67 |
# File 'lib/ct_gov/clinical_trial.rb', line 65 def brief_summary @raw_trial['brief_summary']['textblock'].strip end |
#brief_title ⇒ Object
15 16 17 |
# File 'lib/ct_gov/clinical_trial.rb', line 15 def brief_title @raw_trial['brief_title'] end |
#browse_conditions ⇒ Object
19 20 21 |
# File 'lib/ct_gov/clinical_trial.rb', line 19 def browse_conditions @raw_trial['condition_browse'].nil? ? [] : [@raw_trial['condition_browse']['mesh_term']].flatten end |
#browse_interventions ⇒ Object
27 28 29 |
# File 'lib/ct_gov/clinical_trial.rb', line 27 def browse_interventions @raw_trial['intervention_browse'].nil? ? [] : [@raw_trial['intervention_browse']['mesh_term']].flatten end |
#completion_date ⇒ Object
23 24 25 |
# File 'lib/ct_gov/clinical_trial.rb', line 23 def completion_date Date.parse(@raw_trial['completion_date']) end |
#detailed_description ⇒ Object
69 70 71 |
# File 'lib/ct_gov/clinical_trial.rb', line 69 def detailed_description @raw_trial['detailed_description']['textblock'].strip end |
#eligibility_description ⇒ Object
73 74 75 |
# File 'lib/ct_gov/clinical_trial.rb', line 73 def eligibility_description @raw_trial['eligibility']['criteria']['textblock'] end |
#healthy_volunteers? ⇒ Boolean
7 8 9 |
# File 'lib/ct_gov/clinical_trial.rb', line 7 def healthy_volunteers? @raw_trial['eligibility']['accepts_healthy_volunteers'] == 'Accepts Healthy Volunteers' end |
#keywords ⇒ Object
31 32 33 |
# File 'lib/ct_gov/clinical_trial.rb', line 31 def keywords @raw_trial['keyword'].nil? ? [] : [@raw_trial['keyword']].flatten end |
#locations ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/ct_gov/clinical_trial.rb', line 35 def locations if @raw_trial['location'].nil? [] else [@raw_trial['location']].flatten.map do |loc| Location.new(loc) unless loc.nil? end end end |
#max_age ⇒ Object
81 82 83 |
# File 'lib/ct_gov/clinical_trial.rb', line 81 def max_age @raw_trial['eligibility']['maximum_age'] end |
#min_age ⇒ Object
77 78 79 |
# File 'lib/ct_gov/clinical_trial.rb', line 77 def min_age @raw_trial['eligibility']['minimum_age'] end |
#nctid ⇒ Object
11 12 13 |
# File 'lib/ct_gov/clinical_trial.rb', line 11 def nctid @raw_trial['id_info']['nct_id'] end |
#official_title ⇒ Object
45 46 47 |
# File 'lib/ct_gov/clinical_trial.rb', line 45 def official_title @raw_trial['official_title'] end |
#overall_contacts ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/ct_gov/clinical_trial.rb', line 49 def overall_contacts contacts = [] contacts.push Contact.new(@raw_trial['overall_contact']) if @raw_trial['overall_contact'] [@raw_trial['overall_contact_backup']].flatten.each do |contact| contacts.push Contact.new(contact) end contacts end |
#overall_official ⇒ Object
61 62 63 |
# File 'lib/ct_gov/clinical_trial.rb', line 61 def overall_official CtGov::Investigator.new(@raw_trial['overall_official']) unless @raw_trial['overall_official'].nil? end |
#overall_status ⇒ Object
85 86 87 |
# File 'lib/ct_gov/clinical_trial.rb', line 85 def overall_status @raw_trial['overall_status'] end |
#primary_completion_date ⇒ Object
99 100 101 |
# File 'lib/ct_gov/clinical_trial.rb', line 99 def primary_completion_date Date.parse(@raw_trial['primary_completion_date']) end |
#publications ⇒ Object
89 90 91 92 93 94 95 96 97 |
# File 'lib/ct_gov/clinical_trial.rb', line 89 def publications if @raw_trial['reference'].nil? [] else [@raw_trial['reference']].flatten.map do |reference| Publication.new(reference) end end end |
#start_date ⇒ Object
103 104 105 |
# File 'lib/ct_gov/clinical_trial.rb', line 103 def start_date Date.parse(@raw_trial['start_date']) end |
#study_type ⇒ Object
107 108 109 |
# File 'lib/ct_gov/clinical_trial.rb', line 107 def study_type @raw_trial['study_type'] end |