roqua-rom-api 0.1.12 → 0.2.0

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: 9b191aee54049eed911532caa0bd2d3d16459626
4
- data.tar.gz: f5b755d2759a8920984a8f36dca1c0136f721855
3
+ metadata.gz: 30ed2a42e8a301108183e50522a8f7e9bce394f6
4
+ data.tar.gz: b50538aa9e6deb136b3bdde1afcf94b2af850824
5
5
  SHA512:
6
- metadata.gz: f599a248e80d020849a6f2771e13116110895d8ec912daac8a94d8ec7b5271974013fed867b7d3932717580f8b6d0fea725ea0e02e99dd0c514e0799ce0a0a2c
7
- data.tar.gz: 14539ad8b98495ec7bdeb86a8084dd08dcd33df26be5af254643a2ef4b04e83657263a1774625954a7fb68b0a931bbf1c1be61c5f91c8040172dd3da99d39306
6
+ metadata.gz: a11ca264905e5ac7f804526d62d4dd0dd9f34040a2ae698660c7f9da6c7b5bbce405c1a20cd7de7b0631b812760286b73ef6062a33f5e4c9daebc374c9ea963e
7
+ data.tar.gz: 3b45dc6223a2f27be6eb835421960a9fd51e0f3c971936133a0e81e239b13a8fa563fd626fc97739decea018a1115bce4e0a3eef6e1949fb77eb7b335201dbad
data/ChangeLog.md CHANGED
@@ -1,6 +1,10 @@
1
1
  ### HEAD
2
2
 
3
+ ### 0.2.0 / 2014-11-11
3
4
 
5
+ * Added CreateMeasurementSequence
6
+ * BACKWARD INCOMPATIBLE: Starting a protocol subscription now returns ProtocolSubscription model
7
+ * Add responses to protocol subscriptions
4
8
 
5
9
  ### 0.1.12 / 2014-10-28
6
10
 
data/README.md CHANGED
@@ -2,20 +2,35 @@
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
6
- ENV['ROM_KEY'] # username used for HTTP basic authentication on the RoQua API
7
- ENV['ROM_SECRET'] # password used for HTTP basic authentication on the RoQua API
5
+ ENV['ROM_HOST'] # URI of the RoQua application whose API you are targeting
6
+ ENV['ROM_BASICAUTH_ID'] # username used for HTTP basic authentication on the RoQua API
7
+ ENV['ROM_BASICAUTH_SECRET'] # password used for HTTP basic authentication on the RoQua API
8
8
 
9
9
  An HTTP basic auth username password combination can be generated in the RoQua admin interface integration tab
10
10
 
11
- ## I18n
11
+ ## General notes
12
+
13
+ ### I18n
12
14
 
13
15
  By default the ROM API Gem supports the `:nl` language only. If you use another locale or want to change some of the messages, simply extend your locale file by providing a value for some or all of the keys defined `config/locales/*.yml` in the root of this Gem.
14
16
 
15
17
 
16
- ## Fill Out Requests
18
+ ### Usecases
19
+
20
+ In general, the use case classes will return an outcome object. You can query this object to find out if the API call was
21
+ successful with `#valid?`. The result of the API call is available under `#result`, and/or the errors under `#errors`. In general,
22
+ this means that you'll usually write a pattern like this:
23
+
24
+ outcome = Roqua::RomApi::Something.run param: 1, other: 2
25
+
26
+ if outcome.valid?
27
+ responses = outcome.result
28
+ else
29
+ log_or_display outcome.errors.full_messages
30
+ end
31
+
17
32
 
18
- See [api](http://roqua.github.io/developer/rom_v1/dossier/fill_out_requests/) for more info what this does and format of callbacks.
33
+ ## [Fill Out Requests](http://roqua.github.io/developer/rom/dossier/fill_out_requests/)
19
34
 
20
35
  To create a fill out request run:
21
36
 
@@ -23,18 +38,11 @@ To create a fill out request run:
23
38
  questionnaire_keys: ['key1', 'key2'],
24
39
  callback_url: notify_callback_path(token: 'secret')
25
40
 
26
- #### Parameters
41
+ See [api](http://roqua.github.io/developer/rom/dossier/fill_out_requests/) for more info on how callbacks work.
27
42
 
28
- * `dossier_id:` [Required] - Unique dossier identifier string for the patient about to fill out questionnaires
29
- * `questionnaire_keys:` [Required] - Array of keys of questionnaires to fill out
30
- * `open_from:` Time the patient can start filling out the questionnaires and time.
31
- * `open_till:` Time the patient can no longer fill in the questionnaire.
32
- * `callback_url:` [Required] - Url for event callbacks
33
- * `reminders:` Array of durations after which a reminder should be sent if fill_out_request has not been finished.
34
- * `respondent_type:` Defaults to 'patient_version', each type is a separate list of questionnaires to fill out.
35
43
 
36
44
 
37
- ## Fill Out Sessions
45
+ ## [Fill Out Sessions](http://roqua.github.io/developer/rom/dossier/fill_out_sessions/)
38
46
 
39
47
  To start filling out a set of questionnaires run:
40
48
 
@@ -42,129 +50,46 @@ To start filling out a set of questionnaires run:
42
50
  questionnaire_keys: questionnaire_keys,
43
51
  return_to: '/some/return/url/or/path'
44
52
 
45
- #### Parameters
46
-
47
- * `dossier_id:` [Required] - Unique dossier identifier for the patient about to fill out a questionnaire.
48
- * `questionnaire_keys:` Array of keys uniquely identifying the questionnaires to be filled out.
49
- * `response_ids:` Array of ids uniquely identifying aborted responses for which filling out has to be resumed.
50
- * `return_to:` [Required] - Address to return to after filling out the questionnaire.
51
-
52
- When questionnaire keys are provided, a set of blank questionnaires will be filled out. When response ids are provided,
53
- filling out questionnaires for these responses is resumed.
54
-
55
53
  Redirect to the fill_out url received when the outcome is valid:
56
54
 
57
55
  if outcome.valid?
58
56
  redirect_to outcome.result
59
-
60
- or do something with the validation errors:
61
-
62
57
  else
63
58
  log_or_display outcome.errors.full_messages
64
59
  end
65
60
 
61
+ ## [Protocol Subscriptions](http://roqua.github.io/developer/rom/dossier/protocol_subscriptions/)
66
62
 
67
- ## Protocol Subscriptions
63
+ ### [List](http://roqua.github.io/developer/rom/dossier/protocol_subscriptions/#list-active-protocol-subscriptions-for-a-patient)
68
64
 
69
- ### Index
70
65
  To retrieve active protocol subscriptions run:
71
66
 
72
67
  outcome = Roqua::RomApi::ListProtocolSubscriptions.run dossier_id: dossier_id
73
68
 
74
- #### Parameters
75
-
76
- * `dossier_id:` [Required] - Unique dossier identifier for the patient you want the subscriptions for.
77
-
78
- When the request succeeds, an array of subscriptions is returned:
79
-
80
- if outcome.valid?
81
- subscriptions = outcome.result
82
-
83
- Else some validation errors can be shown:
69
+ ### [Start](http://roqua.github.io/developer/rom/dossier/protocol_subscriptions/#start-a-protocol-subscription)
84
70
 
85
- else
86
- log_or_display outcome.errors.full_messages
87
- end
88
-
89
- ### Create
90
71
  To subscribe to a protocol run the following command:
91
72
 
92
73
  outcome = Roqua::RomApi::StartProtocolSubscription.run dossier_id: dossier_id,
93
74
  protocol_key: protocol_key,
94
75
  start_at: start_at
95
76
 
96
- #### Parameters
97
-
98
- * `dossier_id:` [Required] - Unique dossier identifier for the patient to be subscribed.
99
- * `protocol_key:` [Required] - Key uniquely identifying the protocol of interest as specified in RoQua.
100
- * `start_at:` [Defaults to the present] - Timestamp specifying when the first measurement should be prepared.
101
- * `flags` - Boolean flags that are passed in when a questionnaire is being filled out.
102
- * `textvars` - String variables that are passed in when a questionnaire is being filled out.
77
+ ### [Stop](http://roqua.github.io/developer/rom/dossier/protocol_subscriptions/#stop-a-protocol-subscription)
103
78
 
104
- When the subscription succeeds, the subscription object is available through the `#result` accessor:
105
-
106
- if outcome.valid?
107
- subscription = outcome.result
108
-
109
- Else the validation errors can be inspected:
110
-
111
- else
112
- log_or_display outcome.errors.full_messages
113
- end
114
-
115
- ### Destroy
116
79
  To unsubscribe from a protocol run the command:
117
80
 
118
81
  outcome = Roqua::RomApi::StopProtocolSubscription.run dossier_id: dossier_id,
119
82
  protocol_subscription_id: subscription_id
120
83
 
121
- #### Parameters
84
+ ## [Responses](http://roqua.github.io/developer/rom/dossier/responses/)
122
85
 
123
- * `dossier_id:` [Required] - Unique dossier identifier for the patient to be unsubscribed.
124
- * `protocol_subscription_id:` [Required] - Unique identifier for the protocolsubscription to be stopped.
125
-
126
- When stopping the subscription succeeds, the subscription object is available through the `#result` accessor:
127
-
128
- if outcome.valid?
129
- subscription = outcome.result
130
-
131
- Else the validation errors can be inspected:
132
-
133
- else
134
- log_or_display outcome.errors.full_messages
135
- end
136
-
137
- ## Responses
138
-
139
- ### Index
86
+ ### [List](http://roqua.github.io/developer/rom/dossier/responses/#list-all-responses-for-dossier)
140
87
 
141
88
  To retrieve filled out, pending or scheduled questionnaires run:
142
89
 
143
90
  outcome = Roqua::RomApi::ListResponses.run dossier_id: dossier_id
144
91
 
145
- #### Parameters
146
-
147
- * `dossier_id:` [Required] - Unique dossier identifier for the patient you want the responses for.
148
- * `questionnaire_keys` Only return responses on questionnaires whose key is listed
149
- * `completed_before` Only return responses filled out before the specified time
150
- * `completed_after` Only return responses filled out after the specified time
151
- * `respondent_type` Only return responses whose `completer_type` equals the given value
152
- * `status` ['completed', 'aborted', 'open', 'scheduled'] Only return responses whose `status` equals the given value
153
- * `protocol_subscription_id` Only return responses associated to the protocol subscription with the given id
154
-
155
-
156
- When the request succeeds, an array of responses is returned:
157
-
158
- if outcome.valid?
159
- responses = outcome.result
160
-
161
- Else some validation errors can be shown:
162
-
163
- else
164
- log_or_display outcome.errors.full_messages
165
- end
166
-
167
- ### Create
92
+ ### [Create](http://roqua.github.io/developer/rom/dossier/responses/#store-a-new-response)
168
93
 
169
94
  To store an externally filled out questionnaire run:
170
95
 
@@ -172,27 +97,7 @@ To store an externally filled out questionnaire run:
172
97
  dossier_id: 'dossier_id',
173
98
  answer_data: {some: 'aswer_data'}
174
99
 
175
- #### Parameters
176
-
177
- * `questionnaire_key:` [Required] - Key uniquely identifying the questionnaire in RoQua
178
- * `dossier_id:` [Required] - Unique dossier identifier for the patient you want to store the questionnaire for
179
- * `answer_data:` [Required] - Hash storing the answered option key for every question key
180
- * `filled_out_at:` Timestamp indicating the time the questionnaire was filled out (greater or equal to 31 december 1999)
181
- * `respondent:` ['patient'(default)|'parent'|'second_parent'|'teacher'|'caregiver']
182
- - String identifying the respondent which filled out the questionnaire
183
-
184
- When the request succeeds, the stored response is returned:
185
-
186
- if outcome.valid?
187
- responses = outcome.result
188
-
189
- Else some validation errors are provided:
190
-
191
- else
192
- log_or_display outcome.errors.full_messages
193
- end
194
-
195
- ### Update
100
+ ### [Update](http://roqua.github.io/developer/rom/dossier/responses/#update-a-response)
196
101
 
197
102
  To store external data on an existing pending response:
198
103
 
@@ -201,25 +106,6 @@ To store external data on an existing pending response:
201
106
  id: 230, # response id,
202
107
  answer_data: {some: 'aswer_data'}
203
108
 
204
- #### Parameters
205
-
206
- * `questionnaire_key:` [Required] - Key uniquely identifying the questionnaire in RoQua
207
- * `dossier_id:` [Required] - Unique dossier identifier for the patient you want to store the questionnaire for
208
- * `id:` [Required] - Id of the response object to update
209
- * `answer_data:` [Required] - Hash storing the answered option key for every question key
210
- * `filled_out_at:` Timestamp indicating the time the questionnaire was filled out (greater or equal to 31 december 1999)
211
-
212
- When the request succeeds, the stored response is returned:
213
-
214
- if outcome.valid?
215
- responses = outcome.result
216
-
217
- Else some validation errors are provided:
218
-
219
- else
220
- log_or_display outcome.errors.full_messages
221
- end
222
-
223
109
  ## Contributing to roqua-rom-api
224
110
 
225
111
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
@@ -232,5 +118,5 @@ Else some validation errors are provided:
232
118
 
233
119
  ## Copyright
234
120
 
235
- Copyright (c) 2014 Samuel Esposito. See LICENSE.txt for further details.
121
+ Copyright (c) 2014 RoQua. See LICENSE.txt for further details.
236
122
 
@@ -3,6 +3,7 @@ module Roqua
3
3
  # @api private
4
4
  class CreateFillOutRequest < Endpoint
5
5
  string :dossier_id
6
+ integer :measurement_sequence_id, default: nil
6
7
  array :questionnaire_keys, default: [] { string }
7
8
  string :respondent_type, default: nil
8
9
  string :callback_url, default: nil
@@ -13,6 +14,7 @@ module Roqua
13
14
  def execute
14
15
  validate_response_for do
15
16
  fill_out_request = {
17
+ measurement_sequence_id: measurement_sequence_id,
16
18
  questionnaire_keys: questionnaire_keys,
17
19
  respondent_type: respondent_type,
18
20
  callback_url: callback_url,
@@ -0,0 +1,21 @@
1
+ module Roqua
2
+ module RomApi
3
+ # @api private
4
+ class CreateMeasurementSequence < Endpoint
5
+ string :dossier_id
6
+ hash :flags, default: {}, strip: false
7
+ hash :textvars, default: {}, strip: false
8
+
9
+ def execute
10
+ validate_response_for do
11
+ RomApi.basic_auth_session.post("/dossiers/#{dossier_id}/measurement_sequences",
12
+ measurement_sequence: {flags: flags, textvars: textvars})
13
+ end
14
+ end
15
+
16
+ def response_to_result(response)
17
+ Models::MeasurementSequence.new(response)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,13 @@
1
+ module Roqua
2
+ module RomApi
3
+ module Models
4
+ class MeasurementSequence
5
+ include Virtus.model
6
+
7
+ attribute :id, Integer
8
+ attribute :flags, Hash
9
+ attribute :textvars, Hash
10
+ end
11
+ end
12
+ end
13
+ end
@@ -12,6 +12,7 @@ module Roqua
12
12
  attribute :protocol_name, String
13
13
  attribute :flags, Hash
14
14
  attribute :textvars, Hash
15
+ attribute :responses, Array[Response]
15
16
  end
16
17
  end
17
18
  end
@@ -1,3 +1,4 @@
1
1
  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
+ require 'roqua/rom_api/models/measurement_sequence'
@@ -16,25 +16,35 @@ module Roqua
16
16
 
17
17
  def get(path, params = {})
18
18
  perform_request_or_fail do
19
- HTTParty.get(full_url_for(path), query: params, basic_auth: basic_auth)
19
+ HTTParty.get(full_url_for(path),
20
+ query: params,
21
+ basic_auth: basic_auth)
20
22
  end
21
23
  end
22
24
 
23
25
  def post(path, params = {})
24
26
  perform_request_or_fail do
25
- HTTParty.post(full_url_for(path), body: params, basic_auth: basic_auth)
27
+ HTTParty.post(full_url_for(path),
28
+ headers: {'Content-Type' => 'application/json'},
29
+ body: params.to_json,
30
+ basic_auth: basic_auth)
26
31
  end
27
32
  end
28
33
 
29
34
  def patch(path, params = {})
30
35
  perform_request_or_fail do
31
- HTTParty.patch(full_url_for(path), body: params, basic_auth: basic_auth)
36
+ HTTParty.patch(full_url_for(path),
37
+ headers: {'Content-Type' => 'application/json'},
38
+ body: params.to_json,
39
+ basic_auth: basic_auth)
32
40
  end
33
41
  end
34
42
 
35
43
  def delete(path, params = {})
36
44
  perform_request_or_fail do
37
- HTTParty.delete(full_url_for(path), query: params, basic_auth: basic_auth)
45
+ HTTParty.delete(full_url_for(path),
46
+ query: params,
47
+ basic_auth: basic_auth)
38
48
  end
39
49
  end
40
50
 
@@ -15,6 +15,10 @@ module Roqua
15
15
  RomApi.basic_auth_session.post("/dossiers/#{dossier_id}/protocol_subscriptions", options)
16
16
  end
17
17
  end
18
+
19
+ def response_to_result(response)
20
+ Models::ProtocolSubscription.new(response)
21
+ end
18
22
  end
19
23
  end
20
24
  end
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module RomApi
3
- VERSION = '0.1.12'
3
+ VERSION = '0.2.0'
4
4
  end
5
5
  end
data/lib/roqua/rom_api.rb CHANGED
@@ -7,6 +7,7 @@ require 'roqua/rom_api/list_protocol_subscriptions'
7
7
  require 'roqua/rom_api/list_responses'
8
8
  require 'roqua/rom_api/create_response'
9
9
  require 'roqua/rom_api/update_response'
10
+ require 'roqua/rom_api/create_measurement_sequence'
10
11
  require 'roqua/rom_api/start_fill_out_session'
11
12
  require 'roqua/rom_api/create_fill_out_request'
12
13
  require 'roqua/rom_api/start_protocol_subscription'
@@ -29,6 +29,7 @@ describe StartProtocolSubscription do
29
29
  end
30
30
 
31
31
  it 'returns the response' do
32
- expect(StartProtocolSubscription.run!(options)).to eq(response)
32
+ subscription = StartProtocolSubscription.run!(options)
33
+ expect(subscription).to be_a(Models::ProtocolSubscription)
33
34
  end
34
35
  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.12
4
+ version: 0.2.0
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-10-28 00:00:00.000000000 Z
11
+ date: 2014-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -142,12 +142,14 @@ files:
142
142
  - lib/roqua-rom-api.rb
143
143
  - lib/roqua/rom_api.rb
144
144
  - lib/roqua/rom_api/create_fill_out_request.rb
145
+ - lib/roqua/rom_api/create_measurement_sequence.rb
145
146
  - lib/roqua/rom_api/create_response.rb
146
147
  - lib/roqua/rom_api/endpoint.rb
147
148
  - lib/roqua/rom_api/list_protocol_subscriptions.rb
148
149
  - lib/roqua/rom_api/list_responses.rb
149
150
  - lib/roqua/rom_api/models.rb
150
151
  - lib/roqua/rom_api/models/fill_out_request.rb
152
+ - lib/roqua/rom_api/models/measurement_sequence.rb
151
153
  - lib/roqua/rom_api/models/protocol_subscription.rb
152
154
  - lib/roqua/rom_api/models/response.rb
153
155
  - lib/roqua/rom_api/report_calculations.rb
@@ -198,7 +200,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
200
  version: '0'
199
201
  requirements: []
200
202
  rubyforge_project:
201
- rubygems_version: 2.2.2
203
+ rubygems_version: 2.3.0
202
204
  signing_key:
203
205
  specification_version: 4
204
206
  summary: API wrapper gem around RoQua's ROM API