quby-compiler 0.4.9 → 0.4.12
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 +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/quby/compiler/entities/questionnaire.rb +0 -1
- data/lib/quby/compiler/outputs/quby_frontend_v2_serializer.rb +15 -2
- data/lib/quby/compiler/outputs/roqua_serializer.rb +61 -55
- data/lib/quby/compiler/services/definition_validator.rb +2 -2
- data/lib/quby/compiler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9f80c06ecab5163ba31ba68e5548ec4e53211b4d327d738b07947578409afed
|
4
|
+
data.tar.gz: a56fa925a142ec55eb909e33257c3f399d8990c79ace266e6ebc7687cefb49cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3aa823181f25722654444f7ad79e8922b59f6cb93463e12e61abef7ead8a391695156fcb4cb8f4551ad115b6a710ab2e5d81138575d7fce05d442db1e86dd809
|
7
|
+
data.tar.gz: 89376384e57965c290e667984fd98605668ef2a832a87d78215e6c0435379bd6ce4b4cf994091bcc9975554fb05e7ed3f6bfbf4beab6af13115fb3489cd87a94
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# 0.4.12
|
2
|
+
|
3
|
+
* roqua.json: Add questionnaire license
|
4
|
+
* roqua.json: Add `unchecks_all_others` for radio/checkbox question options
|
5
|
+
|
6
|
+
# 0.4.11
|
7
|
+
|
8
|
+
* roqua.json: Baseline for a chart now always exports as a hash of gender/age => value
|
9
|
+
|
10
|
+
# 0.4.10
|
11
|
+
|
12
|
+
* quby2.json: Fix validations json (regex-serialization and key-capitalization)
|
13
|
+
* roqua.json: Change questions, options, date_parts, scores, subscores and outcome_tables from hash to array, since ordering is important and not all systems preserve the order of hashes (like pg's jsonb)
|
14
|
+
|
1
15
|
# 0.4.9
|
2
16
|
|
3
17
|
* roqua.json: Fix html stripping for string with no whitespace
|
@@ -6,10 +6,23 @@ module Quby
|
|
6
6
|
@questionnaire = questionnaire
|
7
7
|
end
|
8
8
|
|
9
|
+
# TODO: Move all attributes here from Questionnaire#as_json
|
9
10
|
def as_json(options = {})
|
10
|
-
@questionnaire.as_json
|
11
|
+
@questionnaire.as_json.merge \
|
12
|
+
validations: validations
|
13
|
+
end
|
14
|
+
|
15
|
+
def validations
|
16
|
+
@questionnaire.validations.map do |validation|
|
17
|
+
validation.config.compact
|
18
|
+
.transform_keys{ _1.to_s.camelize(:lower) }
|
19
|
+
.tap do |validation_hsh|
|
20
|
+
# otherwise ruby will put a (?-mix around the regex, which js errors on.
|
21
|
+
validation_hsh['matcher'] = validation_hsh['matcher'].source.to_s if validation_hsh['matcher']
|
22
|
+
end.as_json
|
23
|
+
end
|
11
24
|
end
|
12
25
|
end
|
13
26
|
end
|
14
27
|
end
|
15
|
-
end
|
28
|
+
end
|
@@ -36,6 +36,8 @@ module Quby
|
|
36
36
|
outcome_tables_schema: outcome_tables_schema,
|
37
37
|
questions: questions,
|
38
38
|
scores: scores,
|
39
|
+
license: questionnaire.license,
|
40
|
+
licensor: questionnaire.licensor,
|
39
41
|
}
|
40
42
|
end
|
41
43
|
|
@@ -60,9 +62,8 @@ module Quby
|
|
60
62
|
case chart
|
61
63
|
when Quby::Compiler::Entities::Charting::LineChart
|
62
64
|
{
|
63
|
-
y_label: chart.y_label,
|
64
65
|
tonality: chart.tonality,
|
65
|
-
baseline:
|
66
|
+
baseline: chart_baseline(chart.baseline),
|
66
67
|
clinically_relevant_change: chart.clinically_relevant_change,
|
67
68
|
}
|
68
69
|
when Quby::Compiler::Entities::Charting::OverviewChart
|
@@ -89,6 +90,17 @@ module Quby
|
|
89
90
|
}
|
90
91
|
end
|
91
92
|
|
93
|
+
def chart_baseline(baseline)
|
94
|
+
case baseline
|
95
|
+
when nil
|
96
|
+
nil
|
97
|
+
when Float, Integer
|
98
|
+
{default: {default: baseline}}
|
99
|
+
when Hash
|
100
|
+
baseline
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
92
104
|
# configuration for outcome tables.
|
93
105
|
# tables:
|
94
106
|
# <outcome_table_name:Symbol>: # each entry is a table.
|
@@ -107,15 +119,18 @@ module Quby
|
|
107
119
|
|
108
120
|
def outcome_tables_from_definition
|
109
121
|
# hash of tables, with the score keys (rows) and subscore keys (columns) used for each
|
110
|
-
tables =
|
122
|
+
tables = []
|
111
123
|
# hash of `subscore_key: subscore_label` pairs used in tables
|
112
124
|
headers = {}
|
113
125
|
|
114
126
|
questionnaire.outcome_tables.each do |table|
|
115
|
-
tables
|
116
|
-
|
117
|
-
|
118
|
-
|
127
|
+
tables << {
|
128
|
+
key: table.key,
|
129
|
+
name: table.name,
|
130
|
+
default_collapsed: table.default_collapsed,
|
131
|
+
score_keys: table.score_keys,
|
132
|
+
subscore_keys: table.subscore_keys
|
133
|
+
}.compact
|
119
134
|
|
120
135
|
table.subscore_keys.each do |subscore_key|
|
121
136
|
table.score_keys.find do |score_key|
|
@@ -142,6 +157,7 @@ module Quby
|
|
142
157
|
questionnaire.score_schemas.values.each do |schema|
|
143
158
|
schema.subscore_schemas.each do |subschema|
|
144
159
|
next if subschema.outcome_table.blank?
|
160
|
+
tables[subschema.outcome_table][:key] = subschema.outcome_table
|
145
161
|
tables[subschema.outcome_table][:subscore_keys] << subschema.key
|
146
162
|
tables[subschema.outcome_table][:score_keys] << schema.key
|
147
163
|
headers[subschema.key] = subschema.label
|
@@ -150,7 +166,7 @@ module Quby
|
|
150
166
|
|
151
167
|
{
|
152
168
|
headers: headers,
|
153
|
-
tables: tables,
|
169
|
+
tables: tables.values,
|
154
170
|
}
|
155
171
|
end
|
156
172
|
|
@@ -170,25 +186,22 @@ module Quby
|
|
170
186
|
# date_parts [nil/{..}]
|
171
187
|
# options: [nil/{..}]
|
172
188
|
def questions
|
173
|
-
questionnaire.sorted_questions.reject{_1.type == :hidden}.
|
174
|
-
|
175
|
-
question.key,
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
options: options_for(question)
|
190
|
-
}.compact
|
191
|
-
]
|
189
|
+
questionnaire.sorted_questions.reject{_1.type == :hidden}.map { |question|
|
190
|
+
{
|
191
|
+
key: question.key,
|
192
|
+
sbg_key: question.sbg_key,
|
193
|
+
type: QUBY_TYPE_TO_ROQUA_TYPE.fetch(question.type),
|
194
|
+
title: parse_markdown_and_strip_tags(question.title),
|
195
|
+
context_free_title: question.context_free_title,
|
196
|
+
unit: question.unit,
|
197
|
+
deprecated: question.hidden.presence,
|
198
|
+
default_invisible: question.default_invisible.presence,
|
199
|
+
parent_question_key: question.parent&.key,
|
200
|
+
parent_option_key: question.parent_option_key,
|
201
|
+
title_question_key: question.title_question&.key,
|
202
|
+
date_parts: date_parts_for(question),
|
203
|
+
options: options_for(question)
|
204
|
+
}.compact
|
192
205
|
}
|
193
206
|
end
|
194
207
|
|
@@ -197,13 +210,11 @@ module Quby
|
|
197
210
|
def date_parts_for(question)
|
198
211
|
return nil unless question.type == :date
|
199
212
|
|
200
|
-
question.components.
|
201
|
-
|
202
|
-
component,
|
203
|
-
{
|
204
|
-
|
205
|
-
}
|
206
|
-
]
|
213
|
+
question.components.map { |component|
|
214
|
+
{
|
215
|
+
part: component,
|
216
|
+
key: question.send("#{component}_key")
|
217
|
+
}
|
207
218
|
}
|
208
219
|
end
|
209
220
|
|
@@ -216,22 +227,20 @@ module Quby
|
|
216
227
|
return nil if question.options.empty?
|
217
228
|
|
218
229
|
question.options.reject { |option| option.inner_title || option.placeholder }
|
219
|
-
.
|
220
|
-
|
221
|
-
option.key,
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
}.compact
|
228
|
-
]
|
230
|
+
.map { |option|
|
231
|
+
{
|
232
|
+
key: option.key,
|
233
|
+
value: (option.value.to_s unless question.type == :check_box),
|
234
|
+
description: option.context_free_description || parse_markdown_and_strip_tags(option.description),
|
235
|
+
child_question_keys: option.questions.map(&:key).presence,
|
236
|
+
unchecks_all_others: question.try(:uncheck_all_option) && question.uncheck_all_option == option.key
|
237
|
+
}.compact
|
229
238
|
}
|
230
239
|
end
|
231
240
|
|
232
241
|
# [{ key: { .., subscores: { subkey: {..} } } }]
|
233
242
|
def scores
|
234
|
-
questionnaire.score_schemas.
|
243
|
+
questionnaire.score_schemas.values.map { |score|
|
235
244
|
{
|
236
245
|
key: score.key,
|
237
246
|
label: score.label,
|
@@ -242,16 +251,13 @@ module Quby
|
|
242
251
|
|
243
252
|
# { subkey: {..} }
|
244
253
|
def subscores_for(score)
|
245
|
-
score.subscore_schemas.
|
246
|
-
|
247
|
-
subscore.key,
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
only_for_export: subscore.only_for_export.presence
|
253
|
-
}.compact
|
254
|
-
]
|
254
|
+
score.subscore_schemas.map { |subscore|
|
255
|
+
{
|
256
|
+
key: subscore.key,
|
257
|
+
label: subscore.label,
|
258
|
+
export_key: subscore.export_key,
|
259
|
+
only_for_export: subscore.only_for_export.presence
|
260
|
+
}.compact
|
255
261
|
}
|
256
262
|
end
|
257
263
|
|
@@ -137,14 +137,14 @@ module Quby
|
|
137
137
|
unknown_questions = flag.shows_questions.select { |key| !questionnaire.key_in_use?(key) }
|
138
138
|
return if unknown_questions.blank?
|
139
139
|
|
140
|
-
fail ArgumentError, "Flag '#{key}' has unknown shows_questions keys #{unknown_questions}"
|
140
|
+
fail ArgumentError, "Flag '#{flag.key}' has unknown shows_questions keys #{unknown_questions}"
|
141
141
|
end
|
142
142
|
|
143
143
|
def validate_flag_hides(questionnaire, flag)
|
144
144
|
unknown_questions = flag.hides_questions.select { |key| !questionnaire.key_in_use?(key) }
|
145
145
|
return if unknown_questions.blank?
|
146
146
|
|
147
|
-
fail ArgumentError, "Flag '#{key}' has unknown hides_questions keys #{unknown_questions}"
|
147
|
+
fail ArgumentError, "Flag '#{flag.key}' has unknown hides_questions keys #{unknown_questions}"
|
148
148
|
end
|
149
149
|
|
150
150
|
def validate_flag_depends_on(questionnaire, flag)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quby-compiler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|