ct_gov 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e726cad0b0d02673299f96f3d350d4d27a079218
4
- data.tar.gz: df9624ee898759b807acf9ec6374711db6167895
3
+ metadata.gz: a2cbc97f4cd880185f298bb615c8f3c8c9b67b2b
4
+ data.tar.gz: fedc4b404245cc5582168ae9c4cd90aad6b4a3c8
5
5
  SHA512:
6
- metadata.gz: b46eb17b91d054b0b5d99ecc9312d5c144bc283d58137d45488d25812f4489c2ba0db10375ce7f9fc2681a116f1eadc92e3c6f57434748b2336ab771fbb9a0a7
7
- data.tar.gz: c27d0f6f91a08049328749fc4453fae2a084ea289b8cc1aa71e0a1f107b038c04196d60d9f986c238323f792b2e8a3e643777be2774117cf49de35885598f3cf
6
+ metadata.gz: 84b5c655602e955600b1fec84b6db4386e9cef1663ef662336e012b55c2c07fd4a9c80c0348bd9a1805c42a8e00fadb70bd550bf2031b545ba0f0512e8451c69
7
+ data.tar.gz: 23612bf19e8b575894dbeddb2f566d467158b66670169dcb8cbe5003f495fd9be9ef72247008b93635c20467ec9eef3423228a2d63b39fc1c52656d115ead1a5
data/Rakefile CHANGED
@@ -1,2 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
+ task :console do
4
+ exec "irb -r ct_gov -I ./lib"
5
+ end
data/ct_gov-0.0.1.gem ADDED
Binary file
data/lib/ct_gov.rb CHANGED
@@ -1,5 +1,10 @@
1
1
  require "ct_gov/version"
2
+ require 'ct_gov/address'
2
3
  require 'ct_gov/clinical_trial'
4
+ require 'ct_gov/contact'
5
+ require 'ct_gov/facility'
6
+ require 'ct_gov/investigator'
7
+ require 'ct_gov/location'
3
8
  require 'ct_gov/publication'
4
9
 
5
10
  require 'saxerator'
@@ -10,7 +15,7 @@ module CtGov
10
15
  BASE_OPTIONS = '?displayxml=true'
11
16
 
12
17
  def self.find_by_nctid(nctid)
13
- uri = URI.parse("#{BASE_URL}/ct2/show/#{nctid}#{BASE_OPTIONS}")
18
+ uri = ::URI.parse("#{BASE_URL}/ct2/show/#{nctid}#{BASE_OPTIONS}")
14
19
  http = Net::HTTP.new(uri.host, uri.port)
15
20
  http.use_ssl = true
16
21
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
@@ -0,0 +1,24 @@
1
+ module CtGov
2
+ class Address
3
+
4
+ def initialize(raw_address)
5
+ @raw_address = raw_address
6
+ end
7
+
8
+ def city
9
+ @raw_address['city']
10
+ end
11
+
12
+ def country
13
+ @raw_address['country']
14
+ end
15
+
16
+ def state
17
+ @raw_address['state']
18
+ end
19
+
20
+ def zip
21
+ @raw_address['zip']
22
+ end
23
+ end
24
+ end
@@ -4,6 +4,10 @@ module CtGov
4
4
  @raw_trial = raw_trial
5
5
  end
6
6
 
7
+ def healthy_volunteers?
8
+ @raw_trial['eligibility']['accepts_healthy_volunteers'] == 'Accepts Healthy Volunteers'
9
+ end
10
+
7
11
  def nctid
8
12
  @raw_trial['id_info']['nct_id']
9
13
  end
@@ -12,10 +16,52 @@ module CtGov
12
16
  @raw_trial['brief_title']
13
17
  end
14
18
 
19
+ def browse_conditions
20
+ @raw_trial['condition_browse'].nil? ? [] : [@raw_trial['condition_browse']['mesh_term']].flatten
21
+ end
22
+
23
+ def completion_date
24
+ Date.parse(@raw_trial['completion_date'])
25
+ end
26
+
27
+ def browse_interventions
28
+ @raw_trial['intervention_browse'].nil? ? [] : [@raw_trial['intervention_browse']['mesh_term']].flatten
29
+ end
30
+
31
+ def keywords
32
+ @raw_trial['keyword'].nil? ? [] : [@raw_trial['keyword']].flatten
33
+ end
34
+
35
+ def locations
36
+ if @raw_trial['location'].nil?
37
+ []
38
+ else
39
+ [@raw_trial['location']].flatten.map do |loc|
40
+ Location.new(loc) unless loc.nil?
41
+ end
42
+ end
43
+ end
44
+
15
45
  def official_title
16
46
  @raw_trial['official_title']
17
47
  end
18
48
 
49
+ def overall_contacts
50
+ contacts = []
51
+
52
+ contacts.push Contact.new(@raw_trial['overall_contact']) if @raw_trial['overall_contact']
53
+
54
+ [@raw_trial['overall_contact_backup']].flatten.each do |contact|
55
+ contacts.push Contact.new(contact)
56
+ end
57
+
58
+ contacts
59
+ end
60
+
61
+ def overall_official
62
+ CtGov::Investigator.new(@raw_trial['overall_official']) unless @raw_trial['overall_official'].nil?
63
+ end
64
+
19
65
  def brief_summary
20
66
  @raw_trial['brief_summary']['textblock'].strip
21
67
  end
@@ -28,6 +74,14 @@ module CtGov
28
74
  @raw_trial['eligibility']['criteria']['textblock']
29
75
  end
30
76
 
77
+ def min_age
78
+ @raw_trial['eligibility']['minimum_age']
79
+ end
80
+
81
+ def max_age
82
+ @raw_trial['eligibility']['maximum_age']
83
+ end
84
+
31
85
  def overall_status
32
86
  @raw_trial['overall_status']
33
87
  end
@@ -38,6 +92,10 @@ module CtGov
38
92
  end
39
93
  end
40
94
 
95
+ def primary_completion_date
96
+ Date.parse(@raw_trial['primary_completion_date'])
97
+ end
98
+
41
99
  def start_date
42
100
  Date.parse(@raw_trial['start_date'])
43
101
  end
@@ -0,0 +1,24 @@
1
+ module CtGov
2
+ class Contact
3
+
4
+ def initialize(raw_contact)
5
+ @raw_contact = raw_contact
6
+ end
7
+
8
+ def name
9
+ @raw_contact['last_name']
10
+ end
11
+
12
+ def phone
13
+ @raw_contact['phone']
14
+ end
15
+
16
+ def phone_extension
17
+ @raw_contact['phone_ext']
18
+ end
19
+
20
+ def email
21
+ @raw_contact['email']
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ module CtGov
2
+ class Facility
3
+
4
+ def initialize(raw_facility)
5
+ @raw_facility = raw_facility
6
+ end
7
+
8
+ def name
9
+ @raw_facility['name']
10
+ end
11
+
12
+ def address
13
+ Address.new(@raw_facility['address']) unless @raw_facility['address'].nil?
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ module CtGov
2
+ class Investigator
3
+
4
+ def initialize(raw_investigator)
5
+ @raw_investigator = raw_investigator
6
+ end
7
+
8
+ def affiliation
9
+ @raw_investigator['affiliation']
10
+ end
11
+
12
+ def name
13
+ @raw_investigator['last_name']
14
+ end
15
+
16
+ def role
17
+ @raw_investigator['role']
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,30 @@
1
+ module CtGov
2
+ class Location
3
+
4
+ def initialize(raw_location)
5
+ @raw_location = raw_location
6
+ end
7
+
8
+ def contact
9
+ Contact.new(@raw_location['contact']) unless @raw_location['contact'].nil?
10
+ end
11
+
12
+ def contact_backup
13
+ Contact.new(@raw_location['contact_backup']) unless @raw_location['contact_backup'].nil?
14
+ end
15
+
16
+ def facility
17
+ Facility.new(@raw_location['facility']) unless @raw_location['facility'].nil?
18
+ end
19
+
20
+ def investigators
21
+ [@raw_location['investigator']].flatten.map do |investigator|
22
+ Investigator.new(investigator) unless investigator.nil?
23
+ end
24
+ end
25
+
26
+ def status
27
+ @raw_location['status']
28
+ end
29
+ end
30
+ end
@@ -1,3 +1,3 @@
1
1
  module CtGov
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,40 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe CtGov::Address do
4
+
5
+ let(:raw_address) {
6
+ Saxerator.parser('<address>
7
+ <city>Bethesda</city>
8
+ <state>Maryland</state>
9
+ <zip>20892</zip>
10
+ <country>United States</country>
11
+ </address>').for_tag(:address).first
12
+ }
13
+
14
+ let(:address) { CtGov::Address.new(raw_address) }
15
+
16
+ describe '#city' do
17
+ subject { address.city }
18
+
19
+ it { expect(subject).to eq 'Bethesda' }
20
+ end
21
+
22
+ describe '#state' do
23
+ subject { address.state }
24
+
25
+ it { expect(subject).to eq 'Maryland' }
26
+ end
27
+
28
+ describe '#zip' do
29
+ subject { address.zip }
30
+
31
+ it { expect(subject).to eq '20892' }
32
+ end
33
+
34
+ describe '#country' do
35
+ subject { address.country }
36
+
37
+ it { expect(subject).to eq 'United States' }
38
+ end
39
+
40
+ end
@@ -6,10 +6,11 @@ describe CtGov::ClinicalTrial do
6
6
 
7
7
  let(:study) { described_class.new(raw_trial) }
8
8
 
9
- describe '#nctid' do
10
- subject { study.nctid }
9
+
10
+ describe '#brief_summary' do
11
+ subject { study.brief_summary }
11
12
 
12
- it { expect(subject).to eq 'NCT00001372' }
13
+ it { expect(subject).to eq raw_trial['brief_summary']['textblock'].strip }
13
14
  end
14
15
 
15
16
  describe '#brief_title' do
@@ -18,16 +19,26 @@ describe CtGov::ClinicalTrial do
18
19
  it { expect(subject).to eq 'Study of Systemic Lupus Erythematosus' }
19
20
  end
20
21
 
21
- describe '#official_title' do
22
- subject { study.official_title }
22
+ describe '#completion_date' do
23
+ subject { study.completion_date }
23
24
 
24
- it { expect(subject).to eq 'Studies of the Pathogenesis and Natural History of Systemic Lupus Erythematosus (SLE)' }
25
+ it { expect(subject).to eq Date.parse('2015-07-01') }
25
26
  end
26
27
 
27
- describe '#brief_summary' do
28
- subject { study.brief_summary }
28
+ describe '#browse_conditions' do
29
+ subject { study.browse_conditions }
29
30
 
30
- it { expect(subject).to eq raw_trial['brief_summary']['textblock'].strip }
31
+ it 'returns an array of all browse conditions' do
32
+ expect(subject.count).to eq 2
33
+
34
+ expect(subject).to eq ['Lupus Erythematosus, Systemic', 'Nephritis']
35
+ end
36
+
37
+ context 'when there are no browse_conditions' do
38
+ before { raw_trial.delete('condition_browse') }
39
+
40
+ it { expect(subject).to eq [] }
41
+ end
31
42
  end
32
43
 
33
44
  describe '#detailed_description' do
@@ -36,28 +47,152 @@ describe CtGov::ClinicalTrial do
36
47
  it { expect(subject).to eq raw_trial['detailed_description']['textblock'].strip }
37
48
  end
38
49
 
50
+ describe '#eligibility_description' do
51
+ subject { study.eligibility_description }
52
+
53
+ it { expect(subject).to eq raw_trial['eligibility']['criteria']['textblock'] }
54
+ end
55
+
56
+ describe '#healthy_volunteers?' do
57
+ subject { study.healthy_volunteers? }
58
+
59
+ context 'when the source value is "Accepts Healthy Volunteers"' do
60
+ before { raw_trial['eligibility']['accepts_healthy_volunteers'] = 'Accepts Healthy Volunteers' }
61
+
62
+ it { expect(subject).to eq true }
63
+ end
64
+
65
+ context 'when the source value is anything else' do
66
+ before { raw_trial['eligibility']['accepts_healthy_volunteers'] = 'No way!' }
67
+
68
+ it { expect(subject).to eq false }
69
+ end
70
+ end
71
+
72
+ describe '#browse_interventions' do
73
+ subject { study.browse_interventions }
74
+
75
+ it 'returns an array of all browse conditions' do
76
+ expect(subject.count).to eq 2
77
+
78
+ expect(subject).to eq ['Methylprednisolone', 'Mycophenolic']
79
+ end
80
+
81
+ context 'when there are no browse_conditions' do
82
+ before { raw_trial.delete('intervention_browse') }
83
+
84
+ it { expect(subject).to eq [] }
85
+ end
86
+ end
87
+
88
+ describe '#keywords' do
89
+ subject { study.keywords }
90
+
91
+ let(:expected_keywords) {[
92
+ "Systemic Lupus Erythematosus",
93
+ "Natural History",
94
+ "Lupus Nephritis",
95
+ "Lupus",
96
+ "Systemic Lupus",
97
+ "SLE"
98
+ ]}
99
+
100
+ it 'returns an array of all keywords for the study' do
101
+ expect(subject.count).to eq 6
102
+
103
+ expect(subject - expected_keywords).to eq []
104
+ end
105
+ end
106
+
107
+ describe '#locations' do
108
+ subject { study.locations }
109
+
110
+ it 'returns an array of locations' do
111
+ expect(subject.first).to be_a CtGov::Location
112
+ end
113
+
114
+ it 'sets the right values for the locations' do
115
+ loc = subject.first
116
+
117
+ expect(loc.status).to eq 'Recruiting'
118
+ end
119
+
120
+ context 'when no location is present' do
121
+ before { raw_trial.delete('location') }
122
+
123
+ it { expect(subject).to eq [] }
124
+ end
125
+
126
+ context 'when there are multiple locations' do
127
+ before { raw_trial['location'] = [{'status' => 'Recruiting'},{'status' => 'Not Recruiting'}] }
128
+
129
+ it 'returns all locations' do
130
+ expect(subject.count).to eq 2
131
+
132
+ expect(subject.first.status).to eq 'Recruiting'
133
+ expect(subject.last.status).to eq 'Not Recruiting'
134
+ end
135
+ end
136
+ end
137
+
138
+ describe '#max_age' do
139
+ subject { study.max_age }
140
+
141
+ it { expect(subject).to eq raw_trial['eligibility']['maximum_age'] }
142
+ end
143
+
144
+ describe '#min_age' do
145
+ subject { study.min_age }
146
+
147
+ it { expect(subject).to eq raw_trial['eligibility']['minimum_age'] }
148
+ end
149
+
150
+ describe '#nctid' do
151
+ subject { study.nctid }
152
+
153
+ it { expect(subject).to eq 'NCT00001372' }
154
+ end
155
+
156
+ describe '#official_title' do
157
+ subject { study.official_title }
158
+
159
+ it { expect(subject).to eq 'Studies of the Pathogenesis and Natural History of Systemic Lupus Erythematosus (SLE)' }
160
+ end
161
+
162
+ describe '#overall_contacts' do
163
+ subject { study.overall_contacts }
164
+
165
+ it { expect(subject.count).to eq 2 }
166
+
167
+ it { expect(subject.first).to be_a CtGov::Contact }
168
+
169
+ it { expect(subject.first.name).to eq 'Elizabeth Joyal, R.N.' }
170
+ end
171
+
39
172
  describe '#overall_status' do
40
173
  subject { study.overall_status }
41
174
 
42
175
  it { expect(subject).to eq 'Recruiting' }
43
176
  end
44
177
 
45
- describe '#start_date' do
46
- subject { study.start_date }
178
+ describe '#overall_official' do
179
+ subject { study.overall_official }
47
180
 
48
- it { expect(subject).to eq Date.parse('1994-02-01') }
49
- end
50
-
51
- describe '#study_type' do
52
- subject { study.study_type }
181
+ it { expect(subject).to be_a CtGov::Investigator }
53
182
 
54
- it { expect(subject).to eq 'Observational' }
183
+ it { expect(subject.name).to eq 'Sarfaraz A Hasni, M.D.' }
184
+
185
+ context 'when overall official is not present' do
186
+ before { raw_trial.delete('overall_official') }
187
+
188
+ it { expect(subject).to be_nil }
189
+ end
55
190
  end
56
191
 
57
- describe '#eligibility_description' do
58
- subject { study.eligibility_description }
192
+ describe '#primary_completion_date' do
193
+ subject { study.primary_completion_date }
59
194
 
60
- it { expect(subject).to eq raw_trial['eligibility']['criteria']['textblock'] }
195
+ it { expect(subject).to eq Date.parse('2015-08-01') }
61
196
  end
62
197
 
63
198
  describe '#publications' do
@@ -69,4 +204,16 @@ describe CtGov::ClinicalTrial do
69
204
 
70
205
  it { expect(subject.first.pmid).to eq '7762914' }
71
206
  end
207
+
208
+ describe '#start_date' do
209
+ subject { study.start_date }
210
+
211
+ it { expect(subject).to eq Date.parse('1994-02-01') }
212
+ end
213
+
214
+ describe '#study_type' do
215
+ subject { study.study_type }
216
+
217
+ it { expect(subject).to eq 'Observational' }
218
+ end
72
219
  end
@@ -0,0 +1,40 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe CtGov::Contact do
4
+
5
+ let(:raw_data) { '
6
+ <contact>
7
+ <last_name>Elizabeth Joyal, R.N.</last_name>
8
+ <phone>(301) 435-4489</phone>
9
+ <phone_ext>321</phone_ext>
10
+ <email>ejoyal@mail.cc.nih.gov</email>
11
+ </contact>'
12
+ }
13
+
14
+ let(:contact) { CtGov::Contact.new(Saxerator.parser(raw_data).for_tag(:contact).first) }
15
+
16
+ describe '#name' do
17
+ subject { contact.name }
18
+
19
+ it { expect(subject).to eq 'Elizabeth Joyal, R.N.' }
20
+ end
21
+
22
+ describe '#phone' do
23
+ subject { contact.phone }
24
+
25
+ it { expect(subject).to eq '(301) 435-4489' }
26
+ end
27
+
28
+ describe '#phone_extension' do
29
+ subject { contact.phone_extension }
30
+
31
+ it { expect(subject).to eq '321' }
32
+ end
33
+
34
+ describe '#email' do
35
+ subject { contact.email }
36
+
37
+ it { expect(subject).to eq 'ejoyal@mail.cc.nih.gov' }
38
+ end
39
+
40
+ end
@@ -0,0 +1,36 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe CtGov::Facility do
4
+ let(:raw_facility) {
5
+ Saxerator.parser('
6
+ <facility>
7
+ <name>National Institutes of Health Clinical Center, 9000 Rockville Pike</name>
8
+ <address>
9
+ <city>Bethesda</city>
10
+ <state>Maryland</state>
11
+ <zip>20892</zip>
12
+ <country>United States</country>
13
+ </address>
14
+ </facility>').for_tag(:facility).first
15
+ }
16
+
17
+ let(:facility) { CtGov::Facility.new(raw_facility) }
18
+
19
+ describe '#name' do
20
+ subject { facility.name }
21
+
22
+ it { expect(subject).to eq 'National Institutes of Health Clinical Center, 9000 Rockville Pike' }
23
+ end
24
+
25
+ describe '#address' do
26
+ subject { facility.address }
27
+
28
+ it 'returns an address' do
29
+ expect(subject).to be_a CtGov::Address
30
+ end
31
+
32
+ it 'returns an address with the right values' do
33
+ expect(subject.city).to eq 'Bethesda'
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,32 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe CtGov::Investigator do
4
+
5
+ let(:raw_data) {
6
+ '<overall_official>
7
+ <last_name>Sarfaraz A Hasni, M.D.</last_name>
8
+ <role>Principal Investigator</role>
9
+ <affiliation>National Institute of Arthritis and Musculoskeletal and Skin Diseases (NIAMS)</affiliation>
10
+ </overall_official>'
11
+ }
12
+
13
+ let(:investigator) { CtGov::Investigator.new(Saxerator.parser(raw_data).for_tag(:overall_official).first) }
14
+
15
+ describe '#name' do
16
+ subject { investigator.name }
17
+
18
+ it { expect(subject).to eq 'Sarfaraz A Hasni, M.D.' }
19
+ end
20
+
21
+ describe '#role' do
22
+ subject { investigator.role }
23
+
24
+ it { expect(subject).to eq 'Principal Investigator' }
25
+ end
26
+
27
+ describe '#affiliation' do
28
+ subject { investigator.affiliation }
29
+
30
+ it { expect(subject).to eq 'National Institute of Arthritis and Musculoskeletal and Skin Diseases (NIAMS)' }
31
+ end
32
+ end
@@ -0,0 +1,124 @@
1
+ require_relative '../spec_helper'
2
+
3
+ describe CtGov::Location do
4
+
5
+ let(:raw_location) { Saxerator.parser(
6
+ '<location>
7
+ <facility>
8
+ <name>National Institutes of Health Clinical Center, 9000 Rockville Pike</name>
9
+ <address>
10
+ <city>Bethesda</city>
11
+ <state>Maryland</state>
12
+ <zip>20892</zip>
13
+ <country>United States</country>
14
+ </address>
15
+ </facility>
16
+ <status>Recruiting</status>
17
+ <contact>
18
+ <last_name>For more information at the NIH Clinical Center contact Patient Recruitment and Public Liaison Office (PRPL)</last_name>
19
+ <phone>800-411-1222</phone>
20
+ <phone_ext>TTY8664111010</phone_ext>
21
+ <email>prpl@mail.cc.nih.gov</email>
22
+ </contact>
23
+ <contact_backup>
24
+ <last_name>David Hyman, MD</last_name>
25
+ <phone>646-888-4544</phone>
26
+ </contact_backup>
27
+ <investigator>
28
+ <last_name>Matthew Fury, MD, PhD</last_name>
29
+ <role>Principal Investigator</role>
30
+ </investigator>
31
+ </location>'
32
+ ).for_tag(:location).first }
33
+
34
+ let(:location) { CtGov::Location.new(raw_location) }
35
+
36
+ describe '#contact' do
37
+ subject { location.contact }
38
+
39
+ it 'returns a contact' do
40
+ expect(subject).to be_a CtGov::Contact
41
+ end
42
+
43
+ it 'sets the right values for the contact' do
44
+ expect(subject.phone).to eq '800-411-1222'
45
+ end
46
+
47
+ context 'when there is no contact backup' do
48
+ before { raw_location['contact'] = nil }
49
+
50
+ it { expect(subject).to be_nil }
51
+ end
52
+ end
53
+
54
+ describe '#contact_bacup' do
55
+ subject { location.contact_backup }
56
+
57
+ it 'returns a contact' do
58
+ expect(subject).to be_a CtGov::Contact
59
+ end
60
+
61
+ it 'sets the right values for the contact' do
62
+ expect(subject.phone).to eq '646-888-4544'
63
+ end
64
+
65
+ context 'when there is no contact backup' do
66
+ before { raw_location['contact_backup'] = nil }
67
+
68
+ it { expect(subject).to be_nil }
69
+ end
70
+ end
71
+
72
+ describe '#investigators' do
73
+ subject { location.investigators }
74
+
75
+ it 'returns an array of investigators' do
76
+ investigators = subject
77
+ expect(subject).to be_a Array
78
+ investigators.each { |i| expect(i).to be_a CtGov::Investigator }
79
+ end
80
+
81
+ it 'returns investigators with the right values' do
82
+ investigator = subject.first
83
+ expect(investigator.name).to eq 'Matthew Fury, MD, PhD'
84
+ end
85
+
86
+ context 'when there are multiple investigators' do
87
+ before { raw_location['investigator'] = [{'last_name' => 'Homer Simpson'}, {'last_name' => 'Peter Griffin'}] }
88
+
89
+ it 'returns both investigaors' do
90
+ expect(subject.count).to eq 2
91
+
92
+ expect(subject.first.name).to eq 'Homer Simpson'
93
+ expect(subject.last.name).to eq 'Peter Griffin'
94
+ end
95
+ end
96
+ end
97
+
98
+ describe '#facility' do
99
+ subject { location.facility }
100
+
101
+ it 'returns a facility object' do
102
+ expect(subject).to be_a CtGov::Facility
103
+ end
104
+
105
+ it 'passes the right values to the facility' do
106
+ facility = subject
107
+ expect(facility.name).to eq 'National Institutes of Health Clinical Center, 9000 Rockville Pike'
108
+ expect(facility.address.city).to eq 'Bethesda'
109
+ end
110
+
111
+ context 'when there is no facility' do
112
+ before { raw_location['facility'] = nil }
113
+
114
+ it { expect(subject).to be_nil }
115
+ end
116
+ end
117
+
118
+ describe '#status' do
119
+ subject { location.status }
120
+
121
+ it { expect(subject).to eq 'Recruiting' }
122
+ end
123
+
124
+ end
@@ -92,6 +92,9 @@
92
92
  </detailed_description>
93
93
  <overall_status>Recruiting</overall_status>
94
94
  <start_date>February 1994</start_date>
95
+ <end_date>June 2015</end_date>
96
+ <completion_date>July 2015</completion_date>
97
+ <primary_completion_date>August 2015</primary_completion_date>
95
98
  <phase>N/A</phase>
96
99
  <study_type>Observational</study_type>
97
100
  <study_design>N/A</study_design>
@@ -258,6 +261,12 @@
258
261
  <condition_browse>
259
262
  <!-- CAUTION: The following MeSH terms are assigned with an imperfect algorithm -->
260
263
  <mesh_term>Lupus Erythematosus, Systemic</mesh_term>
264
+ <mesh_term>Nephritis</mesh_term>
261
265
  </condition_browse>
262
266
  <!-- Results have not yet been posted for this study -->
267
+
268
+ <intervention_browse>
269
+ <mesh_term>Methylprednisolone</mesh_term>
270
+ <mesh_term>Mycophenolic</mesh_term>
271
+ </intervention_browse>
263
272
  </clinical_study>
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ct_gov
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Carpenter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2015-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: saxerator
@@ -64,12 +64,23 @@ files:
64
64
  - LICENSE
65
65
  - README.md
66
66
  - Rakefile
67
+ - ct_gov-0.0.1.gem
67
68
  - ct_gov.gemspec
68
69
  - lib/ct_gov.rb
70
+ - lib/ct_gov/address.rb
69
71
  - lib/ct_gov/clinical_trial.rb
72
+ - lib/ct_gov/contact.rb
73
+ - lib/ct_gov/facility.rb
74
+ - lib/ct_gov/investigator.rb
75
+ - lib/ct_gov/location.rb
70
76
  - lib/ct_gov/publication.rb
71
77
  - lib/ct_gov/version.rb
78
+ - rspec/ct_gov/address_spec.rb
72
79
  - rspec/ct_gov/clinical_trial_spec.rb
80
+ - rspec/ct_gov/contact_spec.rb
81
+ - rspec/ct_gov/facility_spec.rb
82
+ - rspec/ct_gov/investigator_spec.rb
83
+ - rspec/ct_gov/location_spec.rb
73
84
  - rspec/ct_gov/publication_spec.rb
74
85
  - rspec/ct_gov_spec.rb
75
86
  - rspec/data/sample_trial.xml