roqua-rom-api 0.2.1 → 0.2.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: 5b5642304497ce4915b35dd98c38c742166385a9
4
- data.tar.gz: a0a69d3b3677fcaa315f9840e3fddf20de52ffd0
3
+ metadata.gz: 1147f731426ba8d48888a09646f3860a6a8021e8
4
+ data.tar.gz: fedd0999ef1093c511d1ca9ac73d4f9c9cb7f727
5
5
  SHA512:
6
- metadata.gz: ba9330f302f0060dc6bfc8163afc862e31d0e430326ed0cb6f4a7fc3de6498c6590fe30e02ba670f2116e8e62caafbc215c3779a3555650ed11082a6b4ee428e
7
- data.tar.gz: 2c1ee8912c3a8b6eeec42ed9a60bb24c9fffc060fcf2a54a32b5ffbeeaaf3413036a1b5f0fe4b504bda8e6b2bd36edba25b17928620bcb4271f26660b0ed1729
6
+ metadata.gz: 09739ac4db79ec5d8df98bfb6c05257ee75d88cd012bbf713deb1ae062cab204ae335c43f5f357fb720aaf65823a66eae7200199b4d71138199cf048be9f9678
7
+ data.tar.gz: b93858850435d5b864b880bb1db32914fa8b7b2ea7da118ff70d04aa3b148b986bddc85f7f0d07c89ade78be9cb15c69d8617eaac65b2789b9ac37a2e9f5cb99
data/ChangeLog.md CHANGED
@@ -1,5 +1,14 @@
1
1
  ### HEAD
2
2
 
3
+ * Retrieve responses by response_ids.
4
+
5
+ ### 0.2.2 / 2014-12-15
6
+
7
+ * Improve validation errors for protocol_subscriptions
8
+ * Add API endpoint for retrieving questionnaires
9
+ * Pass textvar and flag definitions of questionnaires
10
+ * Pass textvars and flags of responses
11
+
3
12
  ### 0.2.1 / 2014-11-17
4
13
 
5
14
  * Add progress url to fill_out session api endpoint
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Make sure the following environment variables are defined:
4
4
 
5
- ENV['ROM_HOST'] # URI of the RoQua application whose API you are targeting
5
+ ENV['ROM_SITE'] # URI of the RoQua application whose API you are targeting
6
6
  ENV['ROM_BASICAUTH_ID'] # username used for HTTP basic authentication on the RoQua API
7
7
  ENV['ROM_BASICAUTH_SECRET'] # password used for HTTP basic authentication on the RoQua API
8
8
 
@@ -6,11 +6,19 @@ nl:
6
6
  attributes:
7
7
  roqua/rom_api/start_protocol_subscription:
8
8
  attributes:
9
+ start_at:
10
+ must_not_be_in_the_past: mag niet in het verleden liggen.
9
11
  base:
12
+ protocol_must_be_automatic: Het protocol is niet geautomatiseerd.
13
+ protocol_scheduler_options_invalid: Het protocol is verkeerd ingesteld.
14
+ patient_id_taken: Dit dossier is reeds geabonneerd op dit protocol.
10
15
  flag_does_not_exist: Een van de opgegeven vlaggen bestaat niet.
11
16
  flag_value_invalid: Een van de opgegeven vlaggen bevat een waarde anders dan true, false of nil.
12
-
17
+ text_message_template_blank: Er is geen SMS-template beschikbaar voor het protocol.
18
+ invitation_template_blank: Er is geen Email-template beschikbaar voor het protocol.
13
19
  attributes:
14
20
  roqua/rom_api/start_fill_out_session:
15
21
  questionnaire_keys: Vragenlijsten
16
22
  return_to: Return url
23
+ roqua/rom_api/start_protocol_subscription:
24
+ start_at: Startmoment
@@ -9,7 +9,11 @@ module Roqua
9
9
  if response.parsed_response.is_a?(Hash) && response['errors'].present?
10
10
  response['errors'].each do |attribute, attribute_errors|
11
11
  attribute_errors.each do |error|
12
- errors.add attribute.to_sym, error.to_sym
12
+ if respond_to?(attribute.to_sym) || attribute.to_sym == :base
13
+ errors.add attribute.to_sym, error.to_sym
14
+ else
15
+ errors.add :base, [attribute, error].join('_').to_sym
16
+ end
13
17
  end
14
18
  end
15
19
  elsif response.code == 422
@@ -0,0 +1,18 @@
1
+ module Roqua
2
+ module RomApi
3
+ # @api private
4
+ class GetQuestionnaire < Endpoint
5
+ string :questionnaire_key
6
+
7
+ def execute
8
+ validate_response_for do
9
+ RomApi.basic_auth_session.get "/questionnaires/#{questionnaire_key}"
10
+ end
11
+ end
12
+
13
+ def response_to_result(response)
14
+ Models::Questionnaire.new(response)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -3,6 +3,7 @@ module Roqua
3
3
  # @api private
4
4
  class ListResponses < Endpoint
5
5
  string :dossier_id
6
+ array :response_ids, default: [] { string }
6
7
  array :questionnaire_keys, default: [] { string }
7
8
  time :completed_before, default: nil
8
9
  time :completed_after, default: nil
@@ -12,16 +13,21 @@ module Roqua
12
13
 
13
14
  def execute
14
15
  validate_response_for do
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
16
+ RomApi.basic_auth_session.get "/dossiers/#{dossier_id}/responses", filter_params
22
17
  end
23
18
  end
24
19
 
20
+ def filter_params
21
+ {response_ids: response_ids,
22
+ respondent_type: respondent_type,
23
+ status: status,
24
+ questionnaire_keys: questionnaire_keys,
25
+ completed_after: completed_after,
26
+ completed_before: completed_before,
27
+ protocol_subscription_id: protocol_subscription_id
28
+ }.keep_if { |_k, v| v.present? }
29
+ end
30
+
25
31
  def response_to_result(response)
26
32
  response.map { |r| Models::Response.new(r) }
27
33
  end
@@ -0,0 +1,21 @@
1
+ require 'virtus'
2
+
3
+ module Roqua
4
+ module RomApi
5
+ module Models
6
+ class Questionnaire
7
+ include Virtus.model
8
+
9
+ attribute :id, Integer
10
+ attribute :name, String
11
+ attribute :key, String
12
+ attribute :description, String
13
+ attribute :short_description, String
14
+ attribute :questions, Hash
15
+ attribute :scores, Hash
16
+ attribute :textvars, Hash
17
+ attribute :flags, Hash
18
+ end
19
+ end
20
+ end
21
+ end
@@ -18,6 +18,8 @@ module Roqua
18
18
  attribute :status, String
19
19
  attribute :values, Hash
20
20
  attribute :outcome, Hash
21
+ attribute :flags, Hash
22
+ attribute :textvars, Hash
21
23
 
22
24
  def name
23
25
  ActiveSupport::Deprecation.warn(
@@ -2,3 +2,4 @@ require 'roqua/rom_api/models/response'
2
2
  require 'roqua/rom_api/models/fill_out_request'
3
3
  require 'roqua/rom_api/models/protocol_subscription'
4
4
  require 'roqua/rom_api/models/measurement_sequence'
5
+ require 'roqua/rom_api/models/questionnaire'
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module RomApi
3
- VERSION = '0.2.1'
3
+ VERSION = '0.2.2'
4
4
  end
5
5
  end
data/lib/roqua/rom_api.rb CHANGED
@@ -13,6 +13,7 @@ require 'roqua/rom_api/create_fill_out_request'
13
13
  require 'roqua/rom_api/start_protocol_subscription'
14
14
  require 'roqua/rom_api/stop_protocol_subscription'
15
15
  require 'roqua/rom_api/report_calculations'
16
+ require 'roqua/rom_api/get_questionnaire'
16
17
 
17
18
  module Roqua
18
19
  module RomApi
@@ -25,14 +25,15 @@ describe ListResponses do
25
25
  protocol_subscription_id: 'protocol_subscription_id').result
26
26
  end
27
27
 
28
+ it 'can get responses by id' do
29
+ expect(session).to receive(:get).with(api_path, response_ids: ['1', '5', '7'])
30
+ .and_return response
31
+ ListResponses.run!(dossier_id: options[:dossier_id],
32
+ response_ids: ['1', '5', '7'])
33
+ end
34
+
28
35
  it 'returns an array of response objects' do
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
+ allow(session).to receive(:get).with(api_path, {})
36
37
  .and_return response
37
38
  responses = ListResponses.run(options).result
38
39
 
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.2.1
4
+ version: 0.2.2
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-17 00:00:00.000000000 Z
11
+ date: 2014-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -145,12 +145,14 @@ files:
145
145
  - lib/roqua/rom_api/create_measurement_sequence.rb
146
146
  - lib/roqua/rom_api/create_response.rb
147
147
  - lib/roqua/rom_api/endpoint.rb
148
+ - lib/roqua/rom_api/get_questionnaire.rb
148
149
  - lib/roqua/rom_api/list_protocol_subscriptions.rb
149
150
  - lib/roqua/rom_api/list_responses.rb
150
151
  - lib/roqua/rom_api/models.rb
151
152
  - lib/roqua/rom_api/models/fill_out_request.rb
152
153
  - lib/roqua/rom_api/models/measurement_sequence.rb
153
154
  - lib/roqua/rom_api/models/protocol_subscription.rb
155
+ - lib/roqua/rom_api/models/questionnaire.rb
154
156
  - lib/roqua/rom_api/models/response.rb
155
157
  - lib/roqua/rom_api/report_calculations.rb
156
158
  - lib/roqua/rom_api/sessions.rb
@@ -200,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
200
202
  version: '0'
201
203
  requirements: []
202
204
  rubyforge_project:
203
- rubygems_version: 2.2.2
205
+ rubygems_version: 2.3.0
204
206
  signing_key:
205
207
  specification_version: 4
206
208
  summary: API wrapper gem around RoQua's ROM API