roqua-rom-api 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog.md +4 -0
- data/Gemfile +3 -2
- data/README.md +37 -2
- data/lib/roqua/rom_api.rb +1 -0
- data/lib/roqua/rom_api/create_response.rb +6 -6
- data/lib/roqua/rom_api/list_responses.rb +13 -1
- data/lib/roqua/rom_api/update_response.rb +25 -0
- data/lib/roqua/rom_api/version.rb +1 -1
- data/roqua_rom_api.gemspec +3 -3
- data/spec/lib/roqua/rom_api/endpoint_spec.rb +1 -1
- data/spec/lib/roqua/rom_api/list_responses_spec.rb +26 -1
- data/spec/lib/roqua/rom_api/update_response_spec.rb +33 -0
- metadata +11 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bac266254c426f6b3dbc4f723bd32ffa354c30e
|
4
|
+
data.tar.gz: 0369fa376ee5388965c5398b1240832a35e5c86f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01acfc52290ea193019465edda26b7a45fd3f864b88b0e8bceea5dd36234b7fcf443b5d8ca9e0675b731a533b82c1adf5393e8b7f8ca7c14d60fc44ccba6ca3f
|
7
|
+
data.tar.gz: c677875fc78ebfd6c9162682970d6d164ae95c92a4438dc01ffcaf8ecb058fbd339ec782e6936eaf648db4016accddc729de6debd20d2f7de9163a1daf1f61fa
|
data/ChangeLog.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -142,7 +142,14 @@ To retrieve filled out, pending or scheduled questionnaires run:
|
|
142
142
|
|
143
143
|
#### Parameters
|
144
144
|
|
145
|
-
* `dossier_id:`
|
145
|
+
* `dossier_id:` [Required] - Unique dossier identifier for the patient you want the responses for.
|
146
|
+
* `questionnaire_keys` Only return responses on questionnaires whose key is listed
|
147
|
+
* `completed_before` Only return responses filled out before the specified time
|
148
|
+
* `completed_after` Only return responses filled out after the specified time
|
149
|
+
* `respondent_type` Only return responses whose `completer_type` equals the given value
|
150
|
+
* `status` ['completed', 'aborted', 'open', 'scheduled'] Only return responses whose `status` equals the given value
|
151
|
+
* `protocol_subscription_id` Only return responses associated to the protocol subscription with the given id
|
152
|
+
|
146
153
|
|
147
154
|
When the request succeeds, an array of responses is returned:
|
148
155
|
|
@@ -168,7 +175,7 @@ To store an externally filled out questionnaire run:
|
|
168
175
|
* `questionnaire_key:` [Required] - Key uniquely identifying the questionnaire in RoQua
|
169
176
|
* `dossier_id:` [Required] - Unique dossier identifier for the patient you want to store the questionnaire for
|
170
177
|
* `answer_data:` [Required] - Hash storing the answered option key for every question key
|
171
|
-
* `filled_out_at:` Timestamp indicating the time the questionnaire was filled out
|
178
|
+
* `filled_out_at:` Timestamp indicating the time the questionnaire was filled out (greater or equal to 31 december 1999)
|
172
179
|
* `respondent:` ['patient'(default)|'parent'|'second_parent'|'teacher'|'caregiver']
|
173
180
|
- String identifying the respondent which filled out the questionnaire
|
174
181
|
|
@@ -183,6 +190,34 @@ Else some validation errors are provided:
|
|
183
190
|
log_or_display outcome.errors.full_messages
|
184
191
|
end
|
185
192
|
|
193
|
+
### Update
|
194
|
+
|
195
|
+
To store external data on an existing pending response:
|
196
|
+
|
197
|
+
outcome = Roqua::RomApi::CreateResponse.run questionnaire_key: 'questionnaire_key',
|
198
|
+
dossier_id: 'dossier_id',
|
199
|
+
id: 230, # response id,
|
200
|
+
answer_data: {some: 'aswer_data'}
|
201
|
+
|
202
|
+
#### Parameters
|
203
|
+
|
204
|
+
* `questionnaire_key:` [Required] - Key uniquely identifying the questionnaire in RoQua
|
205
|
+
* `dossier_id:` [Required] - Unique dossier identifier for the patient you want to store the questionnaire for
|
206
|
+
* `id:` [Required] - Id of the response object to update
|
207
|
+
* `answer_data:` [Required] - Hash storing the answered option key for every question key
|
208
|
+
* `filled_out_at:` Timestamp indicating the time the questionnaire was filled out (greater or equal to 31 december 1999)
|
209
|
+
|
210
|
+
When the request succeeds, the stored response is returned:
|
211
|
+
|
212
|
+
if outcome.valid?
|
213
|
+
responses = outcome.result
|
214
|
+
|
215
|
+
Else some validation errors are provided:
|
216
|
+
|
217
|
+
else
|
218
|
+
log_or_display outcome.errors.full_messages
|
219
|
+
end
|
220
|
+
|
186
221
|
## Contributing to roqua-rom-api
|
187
222
|
|
188
223
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
data/lib/roqua/rom_api.rb
CHANGED
@@ -6,6 +6,7 @@ require 'roqua/rom_api/endpoint'
|
|
6
6
|
require 'roqua/rom_api/list_protocol_subscriptions'
|
7
7
|
require 'roqua/rom_api/list_responses'
|
8
8
|
require 'roqua/rom_api/create_response'
|
9
|
+
require 'roqua/rom_api/update_response'
|
9
10
|
require 'roqua/rom_api/start_fill_out_session'
|
10
11
|
require 'roqua/rom_api/create_fill_out_request'
|
11
12
|
require 'roqua/rom_api/start_protocol_subscription'
|
@@ -2,18 +2,18 @@ module Roqua
|
|
2
2
|
module RomApi
|
3
3
|
# @api private
|
4
4
|
class CreateResponse < Endpoint
|
5
|
-
string
|
6
|
-
string
|
7
|
-
hash
|
8
|
-
time
|
9
|
-
string
|
5
|
+
string :questionnaire_key
|
6
|
+
string :dossier_id
|
7
|
+
hash :answer_data, strip: false
|
8
|
+
time :filled_out_at, default: nil
|
9
|
+
string :respondent, default: nil
|
10
10
|
|
11
11
|
def execute
|
12
12
|
validate_response_for do
|
13
13
|
RomApi.basic_auth_session.post "/dossiers/#{dossier_id}/responses",
|
14
14
|
questionnaire_key: questionnaire_key,
|
15
15
|
answer_data: answer_data,
|
16
|
-
filled_out_at: filled_out_at.to_i,
|
16
|
+
filled_out_at: (filled_out_at.to_i if filled_out_at),
|
17
17
|
respondent: respondent
|
18
18
|
end
|
19
19
|
end
|
@@ -3,10 +3,22 @@ module Roqua
|
|
3
3
|
# @api private
|
4
4
|
class ListResponses < Endpoint
|
5
5
|
string :dossier_id
|
6
|
+
array :questionnaire_keys, default: [] { string }
|
7
|
+
time :completed_before, default: nil
|
8
|
+
time :completed_after, default: nil
|
9
|
+
string :respondent_type, default: nil
|
10
|
+
symbol :status, default: nil
|
11
|
+
string :protocol_subscription_id, default: nil
|
6
12
|
|
7
13
|
def execute
|
8
14
|
validate_response_for do
|
9
|
-
RomApi.basic_auth_session.get "/dossiers/#{dossier_id}/responses"
|
15
|
+
RomApi.basic_auth_session.get "/dossiers/#{dossier_id}/responses",
|
16
|
+
respondent_type: respondent_type,
|
17
|
+
status: status,
|
18
|
+
questionnaire_keys: questionnaire_keys,
|
19
|
+
completed_after: completed_after,
|
20
|
+
completed_before: completed_before,
|
21
|
+
protocol_subscription_id: protocol_subscription_id
|
10
22
|
end
|
11
23
|
end
|
12
24
|
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Roqua
|
2
|
+
module RomApi
|
3
|
+
# @api private
|
4
|
+
class UpdateResponse < Endpoint
|
5
|
+
string :questionnaire_key
|
6
|
+
string :dossier_id
|
7
|
+
integer :id
|
8
|
+
hash :answer_data, strip: false
|
9
|
+
time :filled_out_at, default: nil
|
10
|
+
|
11
|
+
def execute
|
12
|
+
validate_response_for do
|
13
|
+
RomApi.basic_auth_session.patch "/dossiers/#{dossier_id}/responses/#{id}",
|
14
|
+
questionnaire_key: questionnaire_key,
|
15
|
+
answer_data: answer_data,
|
16
|
+
filled_out_at: (filled_out_at.to_i if filled_out_at)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def response_to_result(response)
|
21
|
+
Models::Response.new(response)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/roqua_rom_api.gemspec
CHANGED
@@ -20,9 +20,9 @@ Gem::Specification.new do |gem|
|
|
20
20
|
gem.add_dependency 'active_interaction', '~> 1.1'
|
21
21
|
gem.add_dependency 'virtus', '~> 1.0'
|
22
22
|
|
23
|
-
gem.add_development_dependency 'bundler', '~> 1.
|
24
|
-
gem.add_development_dependency 'rake', '~> 10.
|
23
|
+
gem.add_development_dependency 'bundler', '~> 1.6'
|
24
|
+
gem.add_development_dependency 'rake', '~> 10.2'
|
25
25
|
gem.add_development_dependency 'yard', '~> 0.8'
|
26
|
-
gem.add_development_dependency 'rspec', '~>
|
26
|
+
gem.add_development_dependency 'rspec', '~> 3.0.0'
|
27
27
|
gem.add_development_dependency 'fabrication', '~> 2.9'
|
28
28
|
end
|
@@ -7,8 +7,33 @@ describe ListResponses do
|
|
7
7
|
let(:session) { Fabricate :basic_auth_session }
|
8
8
|
before { allow(BasicAuthSession).to receive(:new).and_return session }
|
9
9
|
|
10
|
+
it 'performs a GET on the responses API' do
|
11
|
+
expect(session).to receive(:get).with(api_path,
|
12
|
+
respondent_type: 'respondent_type',
|
13
|
+
status: :status,
|
14
|
+
questionnaire_keys: ['questionnaire_key'],
|
15
|
+
completed_after: Time.new(2014, 1, 1),
|
16
|
+
completed_before: Time.new(2014, 1, 31),
|
17
|
+
protocol_subscription_id: 'protocol_subscription_id')
|
18
|
+
.and_return response
|
19
|
+
ListResponses.run(dossier_id: options[:dossier_id],
|
20
|
+
respondent_type: 'respondent_type',
|
21
|
+
status: :status,
|
22
|
+
questionnaire_keys: ['questionnaire_key'],
|
23
|
+
completed_after: Time.new(2014, 1, 1),
|
24
|
+
completed_before: Time.new(2014, 1, 31),
|
25
|
+
protocol_subscription_id: 'protocol_subscription_id').result
|
26
|
+
end
|
27
|
+
|
10
28
|
it 'returns an array of response objects' do
|
11
|
-
allow(session).to receive(:get).with(api_path
|
29
|
+
allow(session).to receive(:get).with(api_path,
|
30
|
+
respondent_type: nil,
|
31
|
+
status: nil,
|
32
|
+
questionnaire_keys: [],
|
33
|
+
completed_after: nil,
|
34
|
+
completed_before: nil,
|
35
|
+
protocol_subscription_id: nil)
|
36
|
+
.and_return response
|
12
37
|
responses = ListResponses.run(options).result
|
13
38
|
|
14
39
|
expect(responses).to be_a(Array)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe UpdateResponse do
|
4
|
+
let(:session) { Sessions::BasicAuthSession.new }
|
5
|
+
let(:response) { httparty_response(questionnaire_name: 'Some Questionnaire') }
|
6
|
+
before do
|
7
|
+
allow(Sessions::BasicAuthSession).to receive(:new).and_return session
|
8
|
+
allow(session).to receive(:patch).and_return response
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'does a post to the rom responses api' do
|
12
|
+
filled_out_at = Time.now
|
13
|
+
expect(session).to receive(:patch).with '/dossiers/some_dossier_id/responses/230',
|
14
|
+
questionnaire_key: 'some_questionnaire_key',
|
15
|
+
answer_data: {some: 'answer_data'},
|
16
|
+
filled_out_at: filled_out_at.to_i
|
17
|
+
UpdateResponse.run! dossier_id: 'some_dossier_id',
|
18
|
+
questionnaire_key: 'some_questionnaire_key',
|
19
|
+
id: 230,
|
20
|
+
answer_data: {some: 'answer_data'},
|
21
|
+
filled_out_at: filled_out_at
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'returns a response object' do
|
25
|
+
response = UpdateResponse.run! dossier_id: 'some_dossier_id',
|
26
|
+
questionnaire_key: 'some_questionnaire_key',
|
27
|
+
answer_data: {some: 'answer_data'},
|
28
|
+
respondent: 'patient',
|
29
|
+
id: 230
|
30
|
+
expect(response).to be_a(Response)
|
31
|
+
expect(response.questionnaire_name).to eq('Some Questionnaire')
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roqua-rom-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Esposito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '1.
|
61
|
+
version: '1.6'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '1.
|
68
|
+
version: '1.6'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '10.
|
75
|
+
version: '10.2'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '10.
|
82
|
+
version: '10.2'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: yard
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
103
|
+
version: 3.0.0
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 3.0.0
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: fabrication
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/roqua/rom_api/start_fill_out_session.rb
|
156
156
|
- lib/roqua/rom_api/start_protocol_subscription.rb
|
157
157
|
- lib/roqua/rom_api/stop_protocol_subscription.rb
|
158
|
+
- lib/roqua/rom_api/update_response.rb
|
158
159
|
- lib/roqua/rom_api/version.rb
|
159
160
|
- roqua_rom_api.gemspec
|
160
161
|
- spec/fabricators/basic_auth_session_fabricator.rb
|
@@ -170,6 +171,7 @@ files:
|
|
170
171
|
- spec/lib/roqua/rom_api/start_fill_out_session_spec.rb
|
171
172
|
- spec/lib/roqua/rom_api/start_protocol_subscription_spec.rb
|
172
173
|
- spec/lib/roqua/rom_api/stop_protocol_subscription_spec.rb
|
174
|
+
- spec/lib/roqua/rom_api/update_response_spec.rb
|
173
175
|
- spec/lib/roqua_rom_api_spec.rb
|
174
176
|
- spec/spec_helper.rb
|
175
177
|
- spec/support/httparty_helpers.rb
|
@@ -212,6 +214,7 @@ test_files:
|
|
212
214
|
- spec/lib/roqua/rom_api/start_fill_out_session_spec.rb
|
213
215
|
- spec/lib/roqua/rom_api/start_protocol_subscription_spec.rb
|
214
216
|
- spec/lib/roqua/rom_api/stop_protocol_subscription_spec.rb
|
217
|
+
- spec/lib/roqua/rom_api/update_response_spec.rb
|
215
218
|
- spec/lib/roqua_rom_api_spec.rb
|
216
219
|
- spec/spec_helper.rb
|
217
220
|
- spec/support/httparty_helpers.rb
|