roqua-rom-api 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5b4880dbb6d6c9993997cde7707b54c2868fcf06
4
- data.tar.gz: 3f2f850311daec6e0f7bba85aa9c8b8b73dc9b05
3
+ metadata.gz: 0e9e8469650f722f5c56ad4df3eb6762e7054001
4
+ data.tar.gz: eb58901e56a066fc16656e51929d4b57e9916315
5
5
  SHA512:
6
- metadata.gz: bacf33df8afbad8ae0340abe98b96f2cd56604dc597af1341bc448c83228b76622fc677bb453fa5b497fcd9fe97454567f789fde62c78bfa7183674399394d83
7
- data.tar.gz: 9ec1471630af1b4b3ad4980396e9cacfca009b048d10c3fd1616d5362f3590a47d6b1ad362b21911cef6c25d9f57afdc818c35c1755a23a2b6a9926e147c8bad
6
+ metadata.gz: b72e1e737e6a9389e2a34578dc9b12545b5338ba9b336227654031baf6af8f1d982ecce08294d16ca9f0996a8131b09f6b3f8f94539734c211881ae8f6ded730
7
+ data.tar.gz: 711f77ac9d5a8d642bf1dba8b293cd479fa9f84b8741069aec6e7556ad5955522b4603902eefc82e219d8c4e4c1e4c11a875dffcf69697fea4a4a16001eaeb8d
@@ -1,4 +1,13 @@
1
1
  ### HEAD
2
+
3
+ ### 2.1.0 / 2017-02-07
4
+
5
+ * Added ListProtocollen
6
+ * Added GetProtocol
7
+ * Added GetMeasurement
8
+ * Added ListRespondents
9
+ * Added GetRespondent
10
+
2
11
  ### 2.0.1 / 2016-08-15
3
12
 
4
13
  * Updated httparty gem to 0.14.0 to fix Virtus incompatibility
data/README.md CHANGED
@@ -29,6 +29,20 @@ this means that you'll usually write a pattern like this:
29
29
  log_or_display outcome.errors.full_messages
30
30
  end
31
31
 
32
+ ## [Respondents](http://docs.roqua.net/developer/rom/dossier/respondents/)
33
+
34
+ ### List
35
+
36
+ To retrieve all respondents belong to the dossier
37
+
38
+ outcome = Roqua::RomApi::ListRespondents.run dossier_id: 1
39
+
40
+ ### Get
41
+
42
+ To retrieve single respondent
43
+
44
+ outcome = Roqua::RomApi::GetRespondent.run dossier_id: 1, respondent_id: 2
45
+
32
46
 
33
47
  ## [Fill Out Requests](http://docs.roqua.net/developer/rom/dossier/fill_out_requests/)
34
48
 
@@ -106,6 +120,30 @@ To store external data on an existing pending response:
106
120
  id: 230, # response id,
107
121
  answer_data: {some: 'aswer_data'}
108
122
 
123
+ ## [Protocols](http://docs.roqua.net/developer/rom/global/protocols/)
124
+
125
+ ### List
126
+
127
+ To retrieve all protocols
128
+
129
+ outcome = Roqua::RomApi::ListProtocols.run
130
+
131
+ ### Get
132
+
133
+ To get a single protocol
134
+
135
+ outcome = Roqua::RomApi::GetProtocol.run protocol_id: 1
136
+
137
+
138
+ ## [Measurements](http://docs.roqua.net/developer/rom/global/measurements/)
139
+
140
+ ### Get
141
+
142
+ To get a single measurement
143
+
144
+ outcome = Roqua::RomApi::GetMeasurement.run measurement_id: 1
145
+
146
+
109
147
  ## [Stats](http://docs.roqua.net/developer/rom/dossier/stats/#stats)
110
148
 
111
149
  ### [List](http://docs.roqua.net/developer/rom/dossier/stats/#stats)
@@ -16,6 +16,11 @@ require 'roqua/rom_api/stop_protocol_subscription'
16
16
  require 'roqua/rom_api/report_calculations'
17
17
  require 'roqua/rom_api/get_questionnaire'
18
18
  require 'roqua/rom_api/list_dossier_stats'
19
+ require 'roqua/rom_api/list_protocols'
20
+ require 'roqua/rom_api/get_protocol'
21
+ require 'roqua/rom_api/get_measurement'
22
+ require 'roqua/rom_api/get_respondent'
23
+ require 'roqua/rom_api/list_respondents'
19
24
 
20
25
  module Roqua
21
26
  module RomApi
@@ -11,7 +11,7 @@ module Roqua
11
11
  time :open_from, default: nil, allow_nil: true
12
12
  time :open_till, default: nil, allow_nil: true
13
13
 
14
- validates :dossier_id, presence: { allow_blank: false }
14
+ validates :dossier_id, presence: {allow_blank: false}
15
15
 
16
16
  def execute
17
17
  validate_response_for do
@@ -0,0 +1,18 @@
1
+ module Roqua
2
+ module RomApi
3
+ # @api private
4
+ class GetMeasurement < Endpoint
5
+ integer :measurement_id
6
+
7
+ def execute
8
+ validate_response_for do
9
+ basic_auth_session.get "/measurements/#{measurement_id}"
10
+ end
11
+ end
12
+
13
+ def response_to_result(response)
14
+ Models::Measurement.new(response)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ module Roqua
2
+ module RomApi
3
+ # @api private
4
+ class GetProtocol < Endpoint
5
+ integer :protocol_id
6
+
7
+ def execute
8
+ validate_response_for do
9
+ basic_auth_session.get "/protocols/#{protocol_id}"
10
+ end
11
+ end
12
+
13
+ def response_to_result(response)
14
+ Models::Protocol.new(response)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ module Roqua
2
+ module RomApi
3
+ # @api private
4
+ class GetRespondent < Endpoint
5
+ string :dossier_id
6
+ integer :respondent_id
7
+
8
+ def execute
9
+ validate_response_for do
10
+ basic_auth_session.get "/dossiers/#{dossier_id}/respondents/#{respondent_id}"
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def response_to_result(response)
17
+ Models::Respondent.new(response)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,16 @@
1
+ module Roqua
2
+ module RomApi
3
+ # @api private
4
+ class ListProtocols < Endpoint
5
+ def execute
6
+ validate_response_for do
7
+ basic_auth_session.get "/protocols"
8
+ end
9
+ end
10
+
11
+ def response_to_result(response)
12
+ response.map { |r| Models::Protocol.new(r) }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ module Roqua
2
+ module RomApi
3
+ # @api private
4
+ class ListRespondents < Endpoint
5
+ string :dossier_id
6
+
7
+ def execute
8
+ validate_response_for do
9
+ basic_auth_session.get "/dossiers/#{dossier_id}/respondents"
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def response_to_result(response)
16
+ response.map { |r| Models::Respondent.new(r) }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,7 +1,10 @@
1
1
  require 'roqua/rom_api/models/response'
2
+ require 'roqua/rom_api/models/respondent'
2
3
  require 'roqua/rom_api/models/fill_out_request'
3
4
  require 'roqua/rom_api/models/protocol_subscription'
4
5
  require 'roqua/rom_api/models/measurement_sequence'
5
6
  require 'roqua/rom_api/models/questionnaire'
7
+ require 'roqua/rom_api/models/measurement'
8
+ require 'roqua/rom_api/models/protocol'
6
9
  require 'roqua/rom_api/models/dossier_stats'
7
10
  require 'roqua/rom_api/models/stats'
@@ -0,0 +1,19 @@
1
+ require 'virtus'
2
+
3
+ module Roqua
4
+ module RomApi
5
+ module Models
6
+ class Measurement
7
+ include Virtus.model
8
+
9
+ attribute :id, Integer
10
+ attribute :name, String
11
+ attribute :description, String
12
+ attribute :active, Boolean
13
+ attribute :label, String
14
+ attribute :protocol_id, Integer
15
+ attribute :questionnaires, Array[Models::Questionnaire]
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ require 'virtus'
2
+
3
+ module Roqua
4
+ module RomApi
5
+ module Models
6
+ class Protocol
7
+ include Virtus.model
8
+
9
+ attribute :id, Integer
10
+ attribute :name, String
11
+ attribute :description, String
12
+ attribute :active, Boolean
13
+ attribute :automatic, Boolean
14
+ attribute :measurements, Array[Models::Measurement]
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ require 'virtus'
2
+
3
+ module Roqua
4
+ module RomApi
5
+ module Models
6
+ class Respondent
7
+ include Virtus.model
8
+
9
+ attribute :id, Integer
10
+ attribute :label, String
11
+ attribute :respondent_type, String
12
+ end
13
+ end
14
+ end
15
+ end
@@ -7,6 +7,7 @@ module Roqua
7
7
  include Virtus.model
8
8
 
9
9
  attribute :id, Integer
10
+ attribute :respondent_id, Integer
10
11
  attribute :questionnaire_name, String
11
12
  attribute :questionnaire_key, String
12
13
  attribute :open_from, DateTime
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module RomApi
3
- VERSION = '2.0.1'
3
+ VERSION = '2.1.0'
4
4
  end
5
5
  end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ describe GetMeasurement do
4
+ let(:options) { {measurement_id: 1} }
5
+ let(:api_path) { "/measurements/#{options[:measurement_id]}" }
6
+ let(:response) { httparty_response \
7
+ 'id' => 1,
8
+ 'name' => 'meas',
9
+ 'questionnaires' => [{
10
+ 'id' => 2,
11
+ 'name' => 'quest'
12
+ }] }
13
+ let(:session) { Fabricate :basic_auth_session }
14
+ before { allow(BasicAuthSession).to receive(:new).and_return session }
15
+
16
+ it 'returns a protocol object' do
17
+ allow(session).to receive(:get).with(api_path).and_return response
18
+ measurement = GetMeasurement.run(options).result
19
+
20
+ expect(measurement).to be_a Measurement
21
+ expect(measurement.id).to eq 1
22
+ expect(measurement.name).to eq 'meas'
23
+ expect(measurement.questionnaires.first.id).to eq 2
24
+ expect(measurement.questionnaires.first.name).to eq 'quest'
25
+ end
26
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe GetProtocol do
4
+ let(:options) { {protocol_id: 1} }
5
+ let(:api_path) { "/protocols/#{options[:protocol_id]}" }
6
+ let(:response) { httparty_response \
7
+ 'id' => 1,
8
+ 'name' => 'prot',
9
+ 'measurements' => [{
10
+ 'id' => 2,
11
+ 'name' => 'meas',
12
+ 'questionnaires' => [{
13
+ 'id' => 3,
14
+ 'name' => 'quest'
15
+ }]
16
+ }] }
17
+ let(:session) { Fabricate :basic_auth_session }
18
+ before { allow(BasicAuthSession).to receive(:new).and_return session }
19
+
20
+ it 'returns a protocol object' do
21
+ allow(session).to receive(:get).with(api_path).and_return response
22
+ protocol = GetProtocol.run(options).result
23
+
24
+ expect(protocol).to be_a Protocol
25
+ expect(protocol.id).to eq 1
26
+ expect(protocol.name).to eq 'prot'
27
+ expect(protocol.measurements.first.id).to eq 2
28
+ expect(protocol.measurements.first.name).to eq 'meas'
29
+ expect(protocol.measurements.first.questionnaires.first.id).to eq 3
30
+ expect(protocol.measurements.first.questionnaires.first.name).to eq 'quest'
31
+ end
32
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe GetRespondent do
4
+ let(:options) { {dossier_id: 'some_dossier_id', respondent_id: 2} }
5
+ let(:api_path) { "/dossiers/some_dossier_id/respondents/2" }
6
+ let(:response) { httparty_response \
7
+ 'id' => 2,
8
+ 'label' => 'Patiënt',
9
+ 'respondent_type' => 'patient'
10
+ }
11
+ let(:session) { Fabricate :basic_auth_session }
12
+
13
+ before { allow(BasicAuthSession).to receive(:new).and_return session }
14
+
15
+ it 'returns a respondent object' do
16
+ expect(session).to receive(:get).with(api_path).and_return response
17
+ respondent = GetRespondent.run(options).result
18
+
19
+ expect(respondent).to be_a Respondent
20
+ expect(respondent.id).to eq 2
21
+ expect(respondent.label).to eq 'Patiënt'
22
+ expect(respondent.respondent_type).to eq 'patient'
23
+ end
24
+ end
@@ -0,0 +1,32 @@
1
+ require 'spec_helper'
2
+
3
+ describe ListProtocols do
4
+ let(:api_path) { "/protocols" }
5
+ let(:response) { httparty_response [{
6
+ 'id' => 1,
7
+ 'name' => 'prot',
8
+ 'measurements' => [{
9
+ 'id' => 2,
10
+ 'name' => 'meas',
11
+ 'questionnaires' => [{
12
+ 'id' => 3,
13
+ 'name' => 'quest'
14
+ }]
15
+ }]}] }
16
+ let(:session) { Fabricate :basic_auth_session }
17
+ before { allow(BasicAuthSession).to receive(:new).and_return session }
18
+
19
+ it 'returns an array of protocol objects' do
20
+ allow(session).to receive(:get).with(api_path).and_return response
21
+ protocols = ListProtocols.run.result
22
+
23
+ expect(protocols).to be_a(Array)
24
+ expect(protocols.first).to be_a Protocol
25
+ expect(protocols.first.id).to eq 1
26
+ expect(protocols.first.name).to eq 'prot'
27
+ expect(protocols.first.measurements.first.id).to eq 2
28
+ expect(protocols.first.measurements.first.name).to eq 'meas'
29
+ expect(protocols.first.measurements.first.questionnaires.first.id).to eq 3
30
+ expect(protocols.first.measurements.first.questionnaires.first.name).to eq 'quest'
31
+ end
32
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe ListRespondents do
4
+ let(:options) { {dossier_id: 'some_dossier_id'} }
5
+ let(:api_path) { "/dossiers/some_dossier_id/respondents" }
6
+ let(:response) { httparty_response \
7
+ [{'id' => 2,
8
+ 'label' => 'Patiënt',
9
+ 'respondent_type' => 'patient'}]
10
+ }
11
+ let(:session) { Fabricate :basic_auth_session }
12
+
13
+ before { allow(BasicAuthSession).to receive(:new).and_return session }
14
+
15
+ it 'returns an array of respondent objects' do
16
+ expect(session).to receive(:get).with(api_path).and_return response
17
+ respondents = ListRespondents.run(options).result
18
+ respondent = respondents.first
19
+
20
+ expect(respondent).to be_a Respondent
21
+ expect(respondent.id).to eq 2
22
+ expect(respondent.label).to eq 'Patiënt'
23
+ expect(respondent.respondent_type).to eq 'patient'
24
+ end
25
+ end
@@ -8,7 +8,7 @@ describe ProtocolSubscription do
8
8
  'stop_at' => nil,
9
9
  'state' => "a",
10
10
  'protocol_key' => "pkey",
11
- 'protocol_name' => 'pname' }
11
+ 'protocol_name' => 'pname'}
12
12
  end
13
13
 
14
14
  it 'assigns fields to attr_accessors' do
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Respondent do
4
+ let(:response_body) do
5
+ {'id' => 1,
6
+ 'label' => 'Patiënt',
7
+ 'respondent_type' => 'patient'}
8
+ end
9
+
10
+ it 'assigns fields to attr_accessors' do
11
+ respondent = Respondent.new response_body
12
+ expect(respondent.id).to eq 1
13
+ expect(respondent.label).to eq 'Patiënt'
14
+ expect(respondent.respondent_type).to eq 'patient'
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roqua-rom-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Esposito
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2016-08-15 00:00:00.000000000 Z
15
+ date: 2017-02-07 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: httparty
@@ -164,16 +164,24 @@ files:
164
164
  - lib/roqua/rom_api/create_measurement_sequence.rb
165
165
  - lib/roqua/rom_api/create_response.rb
166
166
  - lib/roqua/rom_api/endpoint.rb
167
+ - lib/roqua/rom_api/get_measurement.rb
168
+ - lib/roqua/rom_api/get_protocol.rb
167
169
  - lib/roqua/rom_api/get_questionnaire.rb
170
+ - lib/roqua/rom_api/get_respondent.rb
168
171
  - lib/roqua/rom_api/list_dossier_stats.rb
169
172
  - lib/roqua/rom_api/list_protocol_subscriptions.rb
173
+ - lib/roqua/rom_api/list_protocols.rb
174
+ - lib/roqua/rom_api/list_respondents.rb
170
175
  - lib/roqua/rom_api/list_responses.rb
171
176
  - lib/roqua/rom_api/models.rb
172
177
  - lib/roqua/rom_api/models/dossier_stats.rb
173
178
  - lib/roqua/rom_api/models/fill_out_request.rb
179
+ - lib/roqua/rom_api/models/measurement.rb
174
180
  - lib/roqua/rom_api/models/measurement_sequence.rb
181
+ - lib/roqua/rom_api/models/protocol.rb
175
182
  - lib/roqua/rom_api/models/protocol_subscription.rb
176
183
  - lib/roqua/rom_api/models/questionnaire.rb
184
+ - lib/roqua/rom_api/models/respondent.rb
177
185
  - lib/roqua/rom_api/models/response.rb
178
186
  - lib/roqua/rom_api/models/stats.rb
179
187
  - lib/roqua/rom_api/report_calculations.rb
@@ -190,12 +198,18 @@ files:
190
198
  - spec/lib/roqua/rom_api/create_fill_out_request_spec.rb
191
199
  - spec/lib/roqua/rom_api/create_response_spec.rb
192
200
  - spec/lib/roqua/rom_api/endpoint_spec.rb
201
+ - spec/lib/roqua/rom_api/get_measurement_spec.rb
202
+ - spec/lib/roqua/rom_api/get_protocol_spec.rb
203
+ - spec/lib/roqua/rom_api/get_respondent_spec.rb
193
204
  - spec/lib/roqua/rom_api/list_dossier_stats_spec.rb
194
205
  - spec/lib/roqua/rom_api/list_protocol_subscriptions_spec.rb
206
+ - spec/lib/roqua/rom_api/list_protocols_spec.rb
207
+ - spec/lib/roqua/rom_api/list_respondents_spec.rb
195
208
  - spec/lib/roqua/rom_api/list_responses_spec.rb
196
209
  - spec/lib/roqua/rom_api/models/dossier_stats_spec.rb
197
210
  - spec/lib/roqua/rom_api/models/fill_out_request_spec.rb
198
211
  - spec/lib/roqua/rom_api/models/protocol_subscription_spec.rb
212
+ - spec/lib/roqua/rom_api/models/respondent_spec.rb
199
213
  - spec/lib/roqua/rom_api/models/response_spec.rb
200
214
  - spec/lib/roqua/rom_api/models/stats_spec.rb
201
215
  - spec/lib/roqua/rom_api/report_calculations_spec.rb
@@ -228,7 +242,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
242
  version: '0'
229
243
  requirements: []
230
244
  rubyforge_project:
231
- rubygems_version: 2.4.8
245
+ rubygems_version: 2.6.8
232
246
  signing_key:
233
247
  specification_version: 4
234
248
  summary: API wrapper gem around RoQua's ROM API
@@ -238,12 +252,18 @@ test_files:
238
252
  - spec/lib/roqua/rom_api/create_fill_out_request_spec.rb
239
253
  - spec/lib/roqua/rom_api/create_response_spec.rb
240
254
  - spec/lib/roqua/rom_api/endpoint_spec.rb
255
+ - spec/lib/roqua/rom_api/get_measurement_spec.rb
256
+ - spec/lib/roqua/rom_api/get_protocol_spec.rb
257
+ - spec/lib/roqua/rom_api/get_respondent_spec.rb
241
258
  - spec/lib/roqua/rom_api/list_dossier_stats_spec.rb
242
259
  - spec/lib/roqua/rom_api/list_protocol_subscriptions_spec.rb
260
+ - spec/lib/roqua/rom_api/list_protocols_spec.rb
261
+ - spec/lib/roqua/rom_api/list_respondents_spec.rb
243
262
  - spec/lib/roqua/rom_api/list_responses_spec.rb
244
263
  - spec/lib/roqua/rom_api/models/dossier_stats_spec.rb
245
264
  - spec/lib/roqua/rom_api/models/fill_out_request_spec.rb
246
265
  - spec/lib/roqua/rom_api/models/protocol_subscription_spec.rb
266
+ - spec/lib/roqua/rom_api/models/respondent_spec.rb
247
267
  - spec/lib/roqua/rom_api/models/response_spec.rb
248
268
  - spec/lib/roqua/rom_api/models/stats_spec.rb
249
269
  - spec/lib/roqua/rom_api/report_calculations_spec.rb
@@ -256,3 +276,4 @@ test_files:
256
276
  - spec/spec_helper.rb
257
277
  - spec/support/httparty_helpers.rb
258
278
  - spec/support/test.yml
279
+ has_rdoc: