Class: CtGov::ClinicalTrial

Inherits:
Object
  • Object
show all
Defined in:
lib/ct_gov/clinical_trial.rb

Instance Method Summary collapse

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_summaryObject



65
66
67
# File 'lib/ct_gov/clinical_trial.rb', line 65

def brief_summary
  @raw_trial['brief_summary']['textblock'].strip
end

#brief_titleObject



15
16
17
# File 'lib/ct_gov/clinical_trial.rb', line 15

def brief_title
  @raw_trial['brief_title']
end

#browse_conditionsObject



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_interventionsObject



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_dateObject



23
24
25
# File 'lib/ct_gov/clinical_trial.rb', line 23

def completion_date
  Date.parse(@raw_trial['completion_date'])
end

#detailed_descriptionObject



69
70
71
# File 'lib/ct_gov/clinical_trial.rb', line 69

def detailed_description
  @raw_trial['detailed_description']['textblock'].strip
end

#eligibility_descriptionObject



73
74
75
# File 'lib/ct_gov/clinical_trial.rb', line 73

def eligibility_description
  @raw_trial['eligibility']['criteria']['textblock']
end

#healthy_volunteers?Boolean

Returns:

  • (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

#keywordsObject



31
32
33
# File 'lib/ct_gov/clinical_trial.rb', line 31

def keywords
  @raw_trial['keyword'].nil? ? [] : [@raw_trial['keyword']].flatten
end

#locationsObject



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_ageObject



81
82
83
# File 'lib/ct_gov/clinical_trial.rb', line 81

def max_age
  @raw_trial['eligibility']['maximum_age']
end

#min_ageObject



77
78
79
# File 'lib/ct_gov/clinical_trial.rb', line 77

def min_age
  @raw_trial['eligibility']['minimum_age']
end

#nctidObject



11
12
13
# File 'lib/ct_gov/clinical_trial.rb', line 11

def nctid
  @raw_trial['id_info']['nct_id']
end

#official_titleObject



45
46
47
# File 'lib/ct_gov/clinical_trial.rb', line 45

def official_title
  @raw_trial['official_title']
end

#overall_contactsObject



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_officialObject



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_statusObject



85
86
87
# File 'lib/ct_gov/clinical_trial.rb', line 85

def overall_status
  @raw_trial['overall_status']
end

#primary_completion_dateObject



99
100
101
# File 'lib/ct_gov/clinical_trial.rb', line 99

def primary_completion_date
  Date.parse(@raw_trial['primary_completion_date'])
end

#publicationsObject



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_dateObject



103
104
105
# File 'lib/ct_gov/clinical_trial.rb', line 103

def start_date
  Date.parse(@raw_trial['start_date'])
end

#study_typeObject



107
108
109
# File 'lib/ct_gov/clinical_trial.rb', line 107

def study_type
  @raw_trial['study_type']
end