canql 5.0.0 → 5.1.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
  SHA256:
3
- metadata.gz: 99a2f7ebbb5ae3c1cbdd8368b020f8eb7c54d969278db3bdd90277f113095ce9
4
- data.tar.gz: fb4f6561d61cc9da30dd9a30562c7374a95e52d615b014bc16e5e282529c4975
3
+ metadata.gz: 7388b9b6f880c7c55b4db80358ff06f5ac5753f70f70aae5e4791b3ad2f886d9
4
+ data.tar.gz: 44c1a08147f5d7eee119242432184238388af321f311149cf498550e417af5fd
5
5
  SHA512:
6
- metadata.gz: 93cc26e76a35a5b47600368d7208f81c6cd6457c416f942be852536952d54b9a1bbcb49df7c17f95fb09b5bdaa4581fda91b70e36ad229aae5213914d9d7db39
7
- data.tar.gz: 2a8bf966e8a0b93411117a09f790f20825c6b27850f1903cea53fd636855d920ec4fdc5dc9bb903b11ec0c2e34275af88ca2e49e4c09b3ea206a6ff2620d626b
6
+ metadata.gz: 3e0eec913600a18381b348c94a466ebc2ef3f8d1a92b505be0975bd77adc63781f54d63f18b7a7c890e0dcea2f3e83303d963fc767e78ee0d1287e4690f59090
7
+ data.tar.gz: e0ffb6f335045c5238a3b42c4469504cc6a24eaa4eff90e9f9fa217e0e76f9f06d53c6f98572302cfd8737626f4a558afae93408938c64f1e1f6aa0b7bf7f05a
@@ -1,6 +1,11 @@
1
1
  ## [Unreleased]
2
2
  *no unreleased changes*
3
3
 
4
+ ## 5.1.0 / 2021-01-25
5
+
6
+ ### Added
7
+ * Added new filters for test acceptance requirments (#59)
8
+
4
9
  ## 5.0.0 / 2021-01-19
5
10
 
6
11
  ### Changed
@@ -27,7 +27,7 @@ file safety:
27
27
  CHANGELOG.md:
28
28
  comments:
29
29
  reviewed_by: josh.pencheon
30
- safe_revision: f84cb2190f46ee550db796a17455980ab00d3187
30
+ safe_revision: aea0d1a480e886a63b723135c7381cdcee0d4b25
31
31
  CODE_OF_CONDUCT.md:
32
32
  comments:
33
33
  reviewed_by: drewthorp
@@ -103,7 +103,7 @@ file safety:
103
103
  comments: It is a known issue that this is potentially susceptible to certain
104
104
  kinds of DoS attack
105
105
  reviewed_by: josh.pencheon
106
- safe_revision: 42bb9bd177a761b9d04d728e53fcf0ebd0083ae4
106
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
107
107
  lib/canql/grammars/patient.treetop:
108
108
  comments: It is a known issue that this is potentially susceptible to certain
109
109
  kinds of DoS attack
@@ -130,7 +130,7 @@ file safety:
130
130
  lib/canql/grammars/test_result_group.treetop:
131
131
  comments:
132
132
  reviewed_by: josh.pencheon
133
- safe_revision: 8ea906ca663b98edee2592fc5b0731881573f06b
133
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
134
134
  lib/canql/nodes.rb:
135
135
  comments:
136
136
  reviewed_by: josh.pencheon
@@ -162,7 +162,7 @@ file safety:
162
162
  lib/canql/nodes/main.rb:
163
163
  comments:
164
164
  reviewed_by: josh.pencheon
165
- safe_revision: c5f8f76b2c335a8554f39a14d6165bf5cd8f9b67
165
+ safe_revision: 361dea5dc6d64bdb7b03434dd2878f8c3b128c95
166
166
  lib/canql/nodes/patient.rb:
167
167
  comments:
168
168
  reviewed_by: josh.pencheon
@@ -182,7 +182,7 @@ file safety:
182
182
  lib/canql/nodes/test_result_group.rb:
183
183
  comments:
184
184
  reviewed_by: josh.pencheon
185
- safe_revision: 42bb9bd177a761b9d04d728e53fcf0ebd0083ae4
185
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
186
186
  lib/canql/parser.rb:
187
187
  comments:
188
188
  reviewed_by: timgentry
@@ -194,7 +194,7 @@ file safety:
194
194
  lib/canql/version.rb:
195
195
  comments:
196
196
  reviewed_by: josh.pencheon
197
- safe_revision: cfe2f76a07880e268e1f29fbac5f6cd380202ce3
197
+ safe_revision: aea0d1a480e886a63b723135c7381cdcee0d4b25
198
198
  test/anomaly_test_helper.rb:
199
199
  comments:
200
200
  reviewed_by: josh.pencheon
@@ -262,7 +262,7 @@ file safety:
262
262
  test/nodes/test_result_groups_test.rb:
263
263
  comments:
264
264
  reviewed_by: josh.pencheon
265
- safe_revision: 8ea906ca663b98edee2592fc5b0731881573f06b
265
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
266
266
  test/nodes/test_results_test.rb:
267
267
  comments:
268
268
  reviewed_by: josh.pencheon
@@ -129,8 +129,8 @@ grammar Canql
129
129
 
130
130
  rule case_with_conditions
131
131
  anomalies / genetic_tests / test_results / perinatal_hospital /
132
- case_field_existance / test_result_groups / mother_conditions /
133
- action_or_ebr
132
+ case_field_existance / test_acceptance_existance / test_result_groups /
133
+ mother_conditions / action_or_ebr
134
134
  end
135
135
 
136
136
  rule patient_with_conditions
@@ -12,5 +12,17 @@ module Canql
12
12
  rule test_result_group_names
13
13
  space ('screening' / 'anomaly scan' / 'fetal medicine' / 'dating') word_break
14
14
  end
15
+
16
+ rule test_acceptance_existance
17
+ and_keyword? existance_modifier:test_acceptance_existance_keyword acceptance:test_acceptance_names <Nodes::TestAcceptanceExistamce::WithCondition>
18
+ end
19
+
20
+ rule test_acceptance_existance_keyword
21
+ space ('missing required' / 'missing' ) word_break
22
+ end
23
+
24
+ rule test_acceptance_names
25
+ space ('screening acceptance status' / 'anomaly scan acceptance status' ) word_break
26
+ end
15
27
  end
16
28
  end
@@ -29,27 +29,38 @@ module Canql #:nodoc: all
29
29
  module WithConditions
30
30
  def meta_data_item
31
31
  conditions = {}
32
- anomalies = []
33
- genetic_tests = []
34
- test_results = []
35
- test_result_groups = []
32
+ sub_clauses = build_sub_clauses
36
33
 
37
- post.elements.each do |element|
38
- anomalies << element.to_anomaly if element.respond_to?(:to_anomaly)
39
- genetic_tests << element.to_genetic_test if element.respond_to?(:to_genetic_test)
40
- test_results << element.to_test_result if element.respond_to?(:to_test_result)
41
- if element.respond_to?(:to_test_result_group)
42
- test_result_groups << element.to_test_result_group
34
+ %i[
35
+ anomalies genetic_tests test_results test_result_groups test_acceptances
36
+ ].each do |condition_key|
37
+ if sub_clauses[condition_key].present?
38
+ conditions[condition_key.to_s] = { Canql::ALL => sub_clauses[condition_key] }
43
39
  end
44
40
  end
41
+ conditions
42
+ end
45
43
 
46
- conditions['anomalies'] = { Canql::ALL => anomalies } if anomalies.any?
47
- conditions['genetic_tests'] = { Canql::ALL => genetic_tests } if genetic_tests.any?
48
- conditions['test_results'] = { Canql::ALL => test_results } if test_results.any?
49
- if test_result_groups.any?
50
- conditions['test_result_groups'] = { Canql::ALL => test_result_groups }
44
+ def build_sub_clauses
45
+ sub_clauses = {}
46
+
47
+ post.elements.each do |element|
48
+ add_sub_clause(sub_clauses, element, :anomalies, :to_anomaly)
49
+ add_sub_clause(sub_clauses, element, :genetic_tests, :to_genetic_test)
50
+ add_sub_clause(sub_clauses, element, :test_results, :to_test_result)
51
+ add_sub_clause(
52
+ sub_clauses, element, :test_result_groups, :to_test_result_group
53
+ )
54
+ add_sub_clause(sub_clauses, element, :test_acceptances, :to_test_acceptance)
51
55
  end
52
- conditions
56
+ sub_clauses
57
+ end
58
+
59
+ def add_sub_clause(sub_clauses, element, key, condition)
60
+ return sub_clauses unless element.respond_to?(condition)
61
+
62
+ sub_clauses[key] ||= []
63
+ sub_clauses[key] << element.send(condition)
53
64
  end
54
65
  end
55
66
  end
@@ -36,5 +36,40 @@ module Canql #:nodoc: all
36
36
  end
37
37
  end
38
38
  end
39
+
40
+ module TestAcceptanceExistamce
41
+ module WithCondition
42
+ def test_acceptance
43
+ acceptance.text_value.strip.parameterize.underscore
44
+ end
45
+
46
+ def to_test_acceptance
47
+ test_acceptance_hash = { 'exists' => existance_filter }
48
+ test_acceptance_hash['required'] = requirement_filter
49
+ test_acceptance_hash['acceptance'] = test_acceptance_filter if test_acceptance.present?
50
+ test_acceptance_hash
51
+ end
52
+
53
+ def existance_filter
54
+ {
55
+ Canql::EQUALS => ['supplied required', 'supplied'].include?(
56
+ existance_modifier.text_value.strip
57
+ )
58
+ }
59
+ end
60
+
61
+ def requirement_filter
62
+ {
63
+ Canql::EQUALS => ['supplied required', 'missing required'].include?(
64
+ existance_modifier.text_value.strip
65
+ )
66
+ }
67
+ end
68
+
69
+ def test_acceptance_filter
70
+ { Canql::EQUALS => test_acceptance }
71
+ end
72
+ end
73
+ end
39
74
  end
40
75
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # This stores the current version of the Canql gem
4
4
  module Canql
5
- VERSION = '5.0.0'
5
+ VERSION = '5.1.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canql
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - PHE NDR Development Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-19 00:00:00.000000000 Z
11
+ date: 2021-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic