canql 4.3.0 → 5.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
  SHA256:
3
- metadata.gz: 2b054c9d0f56e07afcd4521b2e56b23fc21647f419f9bef7f04104bd2544e3b5
4
- data.tar.gz: 48bf63bc902135454291778e23905535570bc5fd3019c13acb55709c9795e827
3
+ metadata.gz: c11d88eb61eaebcc1fee8bbcf02c3528a26799b7a62800971c34517619b98668
4
+ data.tar.gz: ac2d55b1fcf88636a1ccfdf3a2f11b4d4ef7e878ba886fceddd2dcdce26a6fb6
5
5
  SHA512:
6
- metadata.gz: ad41792d7cfb4d5c79077ac53ca462e03cac72042095c51f41a03c53b92a01e3b16777e4f55d7c3167ab589be134cdf35547724a35b61b496bf9beb58f37ae1a
7
- data.tar.gz: ca725da517e80d207eaaed88a7128461bfdadc3a23e5754682e342367762d2dbc7d69ae9d1b462fc8529f7135a1486c90d57516882b972964642cacf8b265618
6
+ metadata.gz: 767d7da5878ba53e624db9090a0bce25ee2b17c039b5ecce4bbb65126f0d32bc988851f7b31e41be235f9911919051a07a7e5478b54d11bc0aefdf7c6a939389
7
+ data.tar.gz: bd874eb46ba2641c84ba40d2a521db212b218879cf6e789777514d36bea0672fd9b38e24804ca4a86b54b722c62b5a7a89003d3040cd8179991b134ebb7543ab
@@ -0,0 +1,2 @@
1
+ # Admins should have oversight of the version:
2
+ lib/canql/version.rb @publichealthengland/ndr-admins
@@ -0,0 +1,23 @@
1
+ name: Lint
2
+
3
+ on: [pull_request]
4
+
5
+ jobs:
6
+ rubocop:
7
+ name: RuboCop
8
+
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ fetch-depth: 0 # fetch everything
15
+ - name: Set up Ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 3.0
19
+ - name: Install dependencies
20
+ run: bundle install
21
+ - name: Run RuboCop against BASE..HEAD changes
22
+ run: bundle exec rake rubocop:diff origin/${GITHUB_BASE_REF#*/}
23
+
@@ -0,0 +1,65 @@
1
+ name: Test
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ strategy:
8
+ matrix:
9
+ ruby-version:
10
+ - 2.6
11
+ - 2.7
12
+ - 3.0
13
+
14
+ name: Ruby ${{ matrix.ruby-version }}
15
+
16
+ runs-on: ubuntu-latest
17
+
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
22
+ with:
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ - name: Install dependencies
25
+ run: bundle install
26
+ - name: Run tests
27
+ run: bundle exec rake
28
+
29
+ # A utility job upon which Branch Protection can depend,
30
+ # thus remaining agnostic of the matrix.
31
+ test_matrix:
32
+ if: ${{ always() }}
33
+ runs-on: ubuntu-latest
34
+ name: Matrix
35
+ needs: test
36
+ steps:
37
+ - name: Check build matrix status
38
+ if: ${{ needs.test.result != 'success' }}
39
+ run: exit 1
40
+
41
+ notify:
42
+ # Run only on master, but regardless of whether tests past:
43
+ if: ${{ always() && github.ref == 'refs/heads/master' }}
44
+
45
+ needs: test_matrix
46
+
47
+ runs-on: ubuntu-latest
48
+
49
+ steps:
50
+ - uses: 8398a7/action-slack@v3
51
+ with:
52
+ status: custom
53
+ fields: workflow,commit,author
54
+ custom_payload: |
55
+ {
56
+ channel: 'C7FQWGDHP',
57
+ username: 'CI – ' + '${{ github.repository }}'.split('/')[1],
58
+ icon_emoji: ':hammer_and_wrench:',
59
+ attachments: [{
60
+ color: '${{ needs.test_matrix.result }}' === 'success' ? 'good' : '${{ needs.test_matrix.result }}' === 'failure' ? 'danger' : 'warning',
61
+ text: `${process.env.AS_WORKFLOW} against \`${{ github.ref }}\` (${process.env.AS_COMMIT}) for ${{ github.actor }} resulted in *${{ needs.test_matrix.result }}*.`
62
+ }]
63
+ }
64
+ env:
65
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
data/.rubocop.yml CHANGED
@@ -1,11 +1 @@
1
- inherit_from: 'https://raw.githubusercontent.com/PublicHealthEngland/ndr_dev_support/master/.rubocop.yml'
2
-
3
- Rails:
4
- Enabled: false
5
-
6
- AllCops:
7
- TargetRailsVersion: 4.2
8
- TargetRubyVersion: 2.3
9
-
10
- Style/FrozenStringLiteralComment:
11
- Enabled: true
1
+ require: ndr_dev_support
data/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  ## [Unreleased]
2
- *no unreleased changes*
2
+ * no relevent changes
3
+
4
+ ## 5.2.0 / 2021-03-04
5
+
6
+ * Added new FASP anomaly RAG rating filters (#63)
7
+
8
+ ## 5.1.0 / 2021-01-25
9
+
10
+ ### Added
11
+ * Added new filters for test acceptance requirments (#59)
12
+
13
+ ## 5.0.0 / 2021-01-19
14
+
15
+ ### Changed
16
+ * Changed the values of registry to use registry name rather than codes and added new supra-region options (#54)
17
+
18
+ ### Added
19
+ * Added fetal medicine and dating options to the test group filter (#50)
20
+ * Added new gestation at delivery and booking date to case field existance filter (#52)
21
+
22
+ ## 4.4.1 / 2021-01-13
23
+ ### Fixed
24
+ * Relax constraints to support Rails 6.x
25
+
26
+ ## 4.4.0 / 2020-07-08
27
+ ### Added
28
+ * Added filter for missing and supplied required test result groups (#47)
3
29
 
4
30
  ## 4.3.0 / 2020-06-10
5
31
  ### Added
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # CANQL [![Build Status](https://travis-ci.org/PublicHealthEngland/canql.svg?branch=master)](https://travis-ci.org/PublicHealthEngland/canql) [![Gem Version](https://badge.fury.io/rb/canql.svg)](https://rubygems.org/gems/canql)
1
+ # CANQL [![Build Status](https://github.com/publichealthengland/canql/workflows/Test/badge.svg)](https://github.com/publichealthengland/canql/actions?query=workflow%3Atest) [![Gem Version](https://badge.fury.io/rb/canql.svg)](https://rubygems.org/gems/canql)
2
2
 
3
- Congenital Anomaly Natural Query Language (CANQL) is a [Treetop](http://treetop.rubyforge.org/) driven Domain Specific Language (DSL) used by the Public Health England (PHE) National Congenital Anomaly and Rare Disease Registration Service (NCARDRS) to identify cohorts of cases.
3
+ Congenital Anomaly Natural Query Language (CANQL) is a [Treetop](http://treetop.rubyforge.org/)-driven Domain Specific Language (DSL) used by the Public Health England (PHE) National Congenital Anomaly and Rare Disease Registration Service (NCARDRS) to identify cohorts of cases.
4
4
 
5
5
  Used for analysis, research and day-to-day operations to empower non-technical users to write sophisticated human readable queries without the need to know or understand the underlying datastore and/or schema.
6
6
 
data/canql.gemspec CHANGED
@@ -28,7 +28,7 @@ Gem::Specification.new do |spec|
28
28
 
29
29
  spec.add_dependency 'chronic', '~> 0.3'
30
30
  spec.add_dependency 'ndr_support', '>= 3.0', '< 6'
31
- spec.add_dependency 'rails', '>= 4.1', '< 6'
31
+ spec.add_dependency 'rails', '>= 4.1', '< 7'
32
32
  spec.add_dependency 'treetop', '>= 1.4.10'
33
33
 
34
34
  spec.add_development_dependency 'bundler'
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
36
36
  spec.add_development_dependency 'guard-minitest'
37
37
  spec.add_development_dependency 'guard-rubocop'
38
38
  spec.add_development_dependency 'minitest'
39
- spec.add_development_dependency 'ndr_dev_support', '~> 5.6'
39
+ spec.add_development_dependency 'ndr_dev_support', '~> 5.9'
40
40
  spec.add_development_dependency 'pry'
41
41
  spec.add_development_dependency 'rake'
42
42
  spec.add_development_dependency 'terminal-notifier-guard' if RUBY_PLATFORM =~ /darwin/
data/code_safety.yml CHANGED
@@ -1,5 +1,17 @@
1
1
  ---
2
2
  file safety:
3
+ ".github/CODEOWNERS":
4
+ comments:
5
+ reviewed_by: josh.pencheon
6
+ safe_revision: a964c47962d47724afd66ba59660589fc3c8b02c
7
+ ".github/workflows/lint.yml":
8
+ comments:
9
+ reviewed_by: josh.pencheon
10
+ safe_revision: 71f6a631758a5a38814d3eafec407e0fde30101f
11
+ ".github/workflows/test.yml":
12
+ comments:
13
+ reviewed_by: josh.pencheon
14
+ safe_revision: 865fc970554fee9207f8e3cd0247133c6a849b24
3
15
  ".gitignore":
4
16
  comments:
5
17
  reviewed_by: timgentry
@@ -9,17 +21,13 @@ file safety:
9
21
  reviewed_by: timgentry
10
22
  safe_revision: 0b34688f1198eace9310f47060aa8915f5b44985
11
23
  ".rubocop.yml":
12
- comments:
13
- reviewed_by: timgentry
14
- safe_revision: 5bc563431f7822e2baf37bbeac9861c36675602d
15
- ".travis.yml":
16
24
  comments:
17
25
  reviewed_by: josh.pencheon
18
- safe_revision: 8adb767031a19aa6b3cea3f1cb05b4a9bcc964f3
26
+ safe_revision: 146b255b240b0efc928d39dd1b70ab221ddc3138
19
27
  CHANGELOG.md:
20
28
  comments:
21
- reviewed_by: josh.pencheon
22
- safe_revision: 23852bc731fdf82a87fd06070a89ec81affe8155
29
+ reviewed_by: ollietulloch
30
+ safe_revision: 9af6ea0bcdac493fe5f31d62b504b285658867c4
23
31
  CODE_OF_CONDUCT.md:
24
32
  comments:
25
33
  reviewed_by: drewthorp
@@ -35,7 +43,7 @@ file safety:
35
43
  README.md:
36
44
  comments:
37
45
  reviewed_by: josh.pencheon
38
- safe_revision: 33feeeaa4b2089e33f563e4c766e91c38b108e36
46
+ safe_revision: 8c07968aa84db92b6f1cc528180f73530ddc6ff5
39
47
  Rakefile:
40
48
  comments:
41
49
  reviewed_by: timgentry
@@ -50,8 +58,8 @@ file safety:
50
58
  safe_revision: 6a666fcabe027056b1c774b2eabb3fdf686911d2
51
59
  canql.gemspec:
52
60
  comments:
53
- reviewed_by: timgentry
54
- safe_revision: 6cb13f43b4353ab7c90ff0406ec13ac169b8e64c
61
+ reviewed_by: josh.pencheon
62
+ safe_revision: 146b255b240b0efc928d39dd1b70ab221ddc3138
55
63
  lib/canql.rb:
56
64
  comments:
57
65
  reviewed_by: timgentry
@@ -63,7 +71,7 @@ file safety:
63
71
  lib/canql/grammars.rb:
64
72
  comments:
65
73
  reviewed_by: josh.pencheon
66
- safe_revision: c431b8a476b84d077e9c39a2a13c2b17a296773d
74
+ safe_revision: c5f8f76b2c335a8554f39a14d6165bf5cd8f9b67
67
75
  lib/canql/grammars/age.treetop:
68
76
  comments: It is a known issue that this is potentially susceptible to certain
69
77
  kinds of DoS attack
@@ -72,8 +80,8 @@ file safety:
72
80
  lib/canql/grammars/anomaly.treetop:
73
81
  comments: It is a known issue that this is potentially susceptible to certain
74
82
  kinds of DoS attack
75
- reviewed_by: josh.pencheon
76
- safe_revision: b7778ca1d536022a807420cc9fe0f1c2df7f73ef
83
+ reviewed_by: ollietulloch
84
+ safe_revision: e549c0dcafdd6004ec279bd256fae8b9964c9629
77
85
  lib/canql/grammars/batch_types.treetop:
78
86
  comments:
79
87
  reviewed_by: josh.pencheon
@@ -94,13 +102,13 @@ file safety:
94
102
  lib/canql/grammars/main.treetop:
95
103
  comments: It is a known issue that this is potentially susceptible to certain
96
104
  kinds of DoS attack
97
- reviewed_by: timgentry
98
- safe_revision: 05ccd47fcbba92bf5525c4d36118274696169d61
105
+ reviewed_by: josh.pencheon
106
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
99
107
  lib/canql/grammars/patient.treetop:
100
108
  comments: It is a known issue that this is potentially susceptible to certain
101
109
  kinds of DoS attack
102
110
  reviewed_by: josh.pencheon
103
- safe_revision: 43425805d9ad4a99e63eeb5d50495fa14eaa053b
111
+ safe_revision: 7490099869e368dcd5c26ded11eb90229baf4cae
104
112
  lib/canql/grammars/perinatal_hospital.treetop:
105
113
  comments:
106
114
  reviewed_by: josh.pencheon
@@ -113,24 +121,28 @@ file safety:
113
121
  comments: It is a known issue that this is potentially susceptible to certain
114
122
  kinds of DoS attack
115
123
  reviewed_by: josh.pencheon
116
- safe_revision: 4e26ac746098452b01dac88373e401e39f309b74
124
+ safe_revision: 293248a17d087d7557a6aacdcb5bf3fbec946b87
117
125
  lib/canql/grammars/test_result.treetop:
118
126
  comments: It is a known issue that this is potentially susceptible to certain
119
127
  kinds of DoS attack
120
128
  reviewed_by: timgentry
121
129
  safe_revision: c39d24bb500719971969762e94545e82866bf92f
130
+ lib/canql/grammars/test_result_group.treetop:
131
+ comments:
132
+ reviewed_by: josh.pencheon
133
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
122
134
  lib/canql/nodes.rb:
123
135
  comments:
124
136
  reviewed_by: josh.pencheon
125
- safe_revision: c431b8a476b84d077e9c39a2a13c2b17a296773d
137
+ safe_revision: c5f8f76b2c335a8554f39a14d6165bf5cd8f9b67
126
138
  lib/canql/nodes/age.rb:
127
139
  comments:
128
140
  reviewed_by: timgentry
129
141
  safe_revision: 6932d590299ad4a9d2ba24b425b158c67142bf74
130
142
  lib/canql/nodes/anomaly.rb:
131
143
  comments:
132
- reviewed_by: josh.pencheon
133
- safe_revision: b7778ca1d536022a807420cc9fe0f1c2df7f73ef
144
+ reviewed_by: ollietulloch
145
+ safe_revision: e549c0dcafdd6004ec279bd256fae8b9964c9629
134
146
  lib/canql/nodes/batch_types.rb:
135
147
  comments:
136
148
  reviewed_by: josh.pencheon
@@ -150,11 +162,11 @@ file safety:
150
162
  lib/canql/nodes/main.rb:
151
163
  comments:
152
164
  reviewed_by: josh.pencheon
153
- safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
165
+ safe_revision: 361dea5dc6d64bdb7b03434dd2878f8c3b128c95
154
166
  lib/canql/nodes/patient.rb:
155
167
  comments:
156
168
  reviewed_by: josh.pencheon
157
- safe_revision: 43425805d9ad4a99e63eeb5d50495fa14eaa053b
169
+ safe_revision: 7490099869e368dcd5c26ded11eb90229baf4cae
158
170
  lib/canql/nodes/perinatal_hospital.rb:
159
171
  comments:
160
172
  reviewed_by: josh.pencheon
@@ -167,6 +179,10 @@ file safety:
167
179
  comments:
168
180
  reviewed_by: timgentry
169
181
  safe_revision: c39d24bb500719971969762e94545e82866bf92f
182
+ lib/canql/nodes/test_result_group.rb:
183
+ comments:
184
+ reviewed_by: josh.pencheon
185
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
170
186
  lib/canql/parser.rb:
171
187
  comments:
172
188
  reviewed_by: timgentry
@@ -177,12 +193,12 @@ file safety:
177
193
  safe_revision: 6932d590299ad4a9d2ba24b425b158c67142bf74
178
194
  lib/canql/version.rb:
179
195
  comments:
180
- reviewed_by: josh.pencheon
181
- safe_revision: 23852bc731fdf82a87fd06070a89ec81affe8155
196
+ reviewed_by: ollietulloch
197
+ safe_revision: 9af6ea0bcdac493fe5f31d62b504b285658867c4
182
198
  test/anomaly_test_helper.rb:
183
199
  comments:
184
- reviewed_by: josh.pencheon
185
- safe_revision: 73a7dac17b20fcc77bcbd9d38777c8aa4d524816
200
+ reviewed_by: ollietulloch
201
+ safe_revision: e549c0dcafdd6004ec279bd256fae8b9964c9629
186
202
  test/canql_test.rb:
187
203
  comments:
188
204
  reviewed_by: timgentry
@@ -202,15 +218,15 @@ file safety:
202
218
  test/nodes/case_test.rb:
203
219
  comments:
204
220
  reviewed_by: josh.pencheon
205
- safe_revision: 43425805d9ad4a99e63eeb5d50495fa14eaa053b
221
+ safe_revision: 7490099869e368dcd5c26ded11eb90229baf4cae
206
222
  test/nodes/code_test.rb:
207
223
  comments:
208
- reviewed_by: josh.pencheon
209
- safe_revision: b7778ca1d536022a807420cc9fe0f1c2df7f73ef
224
+ reviewed_by: ollietulloch
225
+ safe_revision: e549c0dcafdd6004ec279bd256fae8b9964c9629
210
226
  test/nodes/e_base_records_test.rb:
211
227
  comments:
212
228
  reviewed_by: josh.pencheon
213
- safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
229
+ safe_revision: 293248a17d087d7557a6aacdcb5bf3fbec946b87
214
230
  test/nodes/genetic_tests_test.rb:
215
231
  comments:
216
232
  reviewed_by: josh.pencheon
@@ -242,16 +258,20 @@ file safety:
242
258
  test/nodes/registry_test.rb:
243
259
  comments:
244
260
  reviewed_by: josh.pencheon
245
- safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
261
+ safe_revision: 293248a17d087d7557a6aacdcb5bf3fbec946b87
262
+ test/nodes/test_result_groups_test.rb:
263
+ comments:
264
+ reviewed_by: josh.pencheon
265
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
246
266
  test/nodes/test_results_test.rb:
247
267
  comments:
248
268
  reviewed_by: josh.pencheon
249
269
  safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
250
270
  test/parser_test.rb:
251
271
  comments:
252
- reviewed_by: timgentry
253
- safe_revision: 05ccd47fcbba92bf5525c4d36118274696169d61
272
+ reviewed_by: josh.pencheon
273
+ safe_revision: 293248a17d087d7557a6aacdcb5bf3fbec946b87
254
274
  test/test_helper.rb:
255
275
  comments:
256
276
  reviewed_by: josh.pencheon
257
- safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
277
+ safe_revision: 42bb9bd177a761b9d04d728e53fcf0ebd0083ae4
@@ -9,6 +9,7 @@ Treetop.load File.expand_path('grammars/batch_types', File.dirname(__FILE__))
9
9
  Treetop.load File.expand_path('grammars/e_base_records', File.dirname(__FILE__))
10
10
  Treetop.load File.expand_path('grammars/genetic_test', File.dirname(__FILE__))
11
11
  Treetop.load File.expand_path('grammars/test_result', File.dirname(__FILE__))
12
+ Treetop.load File.expand_path('grammars/test_result_group', File.dirname(__FILE__))
12
13
  Treetop.load File.expand_path('grammars/patient', File.dirname(__FILE__))
13
14
  Treetop.load File.expand_path('grammars/registry', File.dirname(__FILE__))
14
15
  Treetop.load File.expand_path('grammars/provider', File.dirname(__FILE__))
@@ -35,7 +35,7 @@ module Canql
35
35
  end
36
36
 
37
37
  rule anomalies_icd_code
38
- (icd_code_name / code_group)
38
+ (fasp_rating / icd_code_name / code_group)
39
39
  end
40
40
 
41
41
  rule icd_code_name
@@ -45,5 +45,9 @@ module Canql
45
45
  rule code_group
46
46
  ('fasp plus' / 'plus' / 'fasp' / 'structural' / 'trisomy') <Nodes::Anomaly::SingleCodeGroupNode>
47
47
  end
48
+
49
+ rule fasp_rating
50
+ ('fasp red and amber' / 'fasp amber and red' / 'fasp red' / 'fasp amber' / 'fasp green') <Nodes::Anomaly::SingleFaspRatingNode>
51
+ end
48
52
  end
49
53
  end
@@ -5,6 +5,7 @@ grammar Canql
5
5
  include Anomaly
6
6
  include GeneticTest
7
7
  include TestResult
8
+ include TestResultGroup
8
9
  include Dates
9
10
  include EBaseRecords
10
11
  include BatchTypes
@@ -127,7 +128,9 @@ grammar Canql
127
128
  end
128
129
 
129
130
  rule case_with_conditions
130
- anomalies / genetic_tests / test_results / perinatal_hospital / case_field_existance / mother_conditions / action_or_ebr
131
+ anomalies / genetic_tests / test_results / perinatal_hospital /
132
+ case_field_existance / test_acceptance_existance / test_result_groups /
133
+ mother_conditions / action_or_ebr
131
134
  end
132
135
 
133
136
  rule patient_with_conditions
@@ -50,7 +50,8 @@ module Canql
50
50
  'delivery postcode' / 'booking postcode' / 'birth weight' /
51
51
  'place of delivery' / 'sex' / 'outcome' / 'edd' /
52
52
  'expected delivery date' / 'booking hospital' / 'screening status' /
53
- 'number of fetuses at delivery' / 'malformed in set'
53
+ 'number of fetuses at delivery' / 'malformed in set' / 'gestation at delivery' /
54
+ 'booking date'
54
55
  )
55
56
  end
56
57
 
@@ -14,14 +14,15 @@ module Canql
14
14
 
15
15
  rule registry_abbr
16
16
  (england / east_mids / thames / east / yorkshire / north_east / north_west /
17
- west_mids / south_west / wessex / london / limbo)
17
+ west_mids / south_west_supra / south_west / wessex / london / limbo /
18
+ northern_supra / midlands_east_supra)
18
19
  end
19
20
 
20
21
  rule thames
21
22
  ('thames valley' / 'thames')
22
23
  {
23
24
  def to_registrycode
24
- '68'
25
+ 'thames'
25
26
  end
26
27
  }
27
28
  end
@@ -30,7 +31,7 @@ module Canql
30
31
  ('east mids' / 'east midlands and south yorkshire' / 'east midlands')
31
32
  {
32
33
  def to_registrycode
33
- '72'
34
+ 'east_mids'
34
35
  end
35
36
  }
36
37
  end
@@ -39,7 +40,7 @@ module Canql
39
40
  'yorkshire'
40
41
  {
41
42
  def to_registrycode
42
- '93'
43
+ 'yorkshire'
43
44
  end
44
45
  }
45
46
  end
@@ -48,7 +49,7 @@ module Canql
48
49
  'north east'
49
50
  {
50
51
  def to_registrycode
51
- '73'
52
+ 'north_east'
52
53
  end
53
54
  }
54
55
  end
@@ -57,7 +58,7 @@ module Canql
57
58
  'north west'
58
59
  {
59
60
  def to_registrycode
60
- '94'
61
+ 'north_west'
61
62
  end
62
63
  }
63
64
  end
@@ -66,7 +67,7 @@ module Canql
66
67
  ('west mids' / 'west midlands')
67
68
  {
68
69
  def to_registrycode
69
- '99'
70
+ 'west_mids'
70
71
  end
71
72
  }
72
73
  end
@@ -75,7 +76,7 @@ module Canql
75
76
  'south west'
76
77
  {
77
78
  def to_registrycode
78
- '84'
79
+ 'south_west'
79
80
  end
80
81
  }
81
82
  end
@@ -84,7 +85,7 @@ module Canql
84
85
  'wessex'
85
86
  {
86
87
  def to_registrycode
87
- '70'
88
+ 'wessex'
88
89
  end
89
90
  }
90
91
  end
@@ -93,7 +94,7 @@ module Canql
93
94
  ('london and south east' / 'london')
94
95
  {
95
96
  def to_registrycode
96
- '95'
97
+ 'london'
97
98
  end
98
99
  }
99
100
  end
@@ -102,7 +103,7 @@ module Canql
102
103
  ('east of england' / 'east')
103
104
  {
104
105
  def to_registrycode
105
- '96'
106
+ 'east'
106
107
  end
107
108
  }
108
109
  end
@@ -111,7 +112,7 @@ module Canql
111
112
  'limbo'
112
113
  {
113
114
  def to_registrycode
114
- '01'
115
+ 'limbo'
115
116
  end
116
117
  }
117
118
  end
@@ -120,7 +121,34 @@ module Canql
120
121
  'england'
121
122
  {
122
123
  def to_registrycode
123
- '00'
124
+ 'england'
125
+ end
126
+ }
127
+ end
128
+
129
+ rule northern_supra
130
+ ('northern supra' / 'northern')
131
+ {
132
+ def to_registrycode
133
+ 'northern_supra'
134
+ end
135
+ }
136
+ end
137
+
138
+ rule midlands_east_supra
139
+ ('midlands & east supra' / 'midlands & east')
140
+ {
141
+ def to_registrycode
142
+ 'midlands_east_supra'
143
+ end
144
+ }
145
+ end
146
+
147
+ rule south_west_supra
148
+ 'south west supra'
149
+ {
150
+ def to_registrycode
151
+ 'south_west_supra'
124
152
  end
125
153
  }
126
154
  end
@@ -0,0 +1,28 @@
1
+ module Canql
2
+ grammar TestResultGroup
3
+ rule test_result_groups
4
+ and_keyword? existance_modifier:test_result_group_existance_keyword group:test_result_group_names <Nodes::TestResultGroup::WithCondition>
5
+ end
6
+
7
+ rule test_result_group_existance_keyword
8
+ # If in furture the reverse is needed use 'supplied require'
9
+ space ('missing required' / 'missing' / 'supplied required' / 'supplied') word_break
10
+ end
11
+
12
+ rule test_result_group_names
13
+ space ('screening' / 'anomaly scan' / 'fetal medicine' / 'dating') word_break
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
27
+ end
28
+ end
data/lib/canql/nodes.rb CHANGED
@@ -17,6 +17,7 @@ require 'canql/nodes/batch_types'
17
17
  require 'canql/nodes/anomaly'
18
18
  require 'canql/nodes/genetic_test'
19
19
  require 'canql/nodes/test_result'
20
+ require 'canql/nodes/test_result_group'
20
21
  require 'canql/nodes/patient'
21
22
  require 'canql/nodes/main'
22
23
  require 'canql/nodes/registry'
@@ -23,13 +23,21 @@ module Canql #:nodoc: all
23
23
  if anomaly_screening_status_type.present?
24
24
  anomaly_hash['screening_status'] = anomaly_screening_status_type_filter
25
25
  end
26
- anomaly_hash['icd_codes'] = code_filter[:icd_code] if code_filter[:icd_code].present?
27
- return anomaly_hash if code_filter[:code_group].blank?
26
+ code_filters(anomaly_hash)
28
27
 
29
- anomaly_hash['code_groups'] = code_filter[:code_group]
30
28
  anomaly_hash
31
29
  end
32
30
 
31
+ def code_filters(anomaly_hash)
32
+ anomaly_hash['icd_codes'] = code_filter[:icd_code] if code_filter[:icd_code].present?
33
+ if code_filter[:code_group].present?
34
+ anomaly_hash['code_groups'] = code_filter[:code_group]
35
+ end
36
+ return if code_filter[:fasp_rating].blank?
37
+
38
+ anomaly_hash['fasp_rating'] = code_filter[:fasp_rating]
39
+ end
40
+
33
41
  def existance_filter
34
42
  { Canql::EQUALS => existance_modifier.text_value.strip != 'no' }
35
43
  end
@@ -49,36 +57,50 @@ module Canql #:nodoc: all
49
57
  def code_type(code)
50
58
  return :icd_code if code.respond_to?(:to_code) && code.to_code.present?
51
59
  return :code_group if code.respond_to?(:to_code_group) && code.to_code_group.present?
60
+ return :fasp_rating if code.respond_to?(:to_fasp_rating) && code.to_fasp_rating.present?
52
61
 
53
62
  raise 'Unable to find code type'
54
63
  end
55
64
 
56
65
  def code_value(code)
57
66
  return code.to_code if :icd_code == code_type(code)
67
+ return code.to_code_group if :code_group == code_type(code)
58
68
 
59
- code.to_code_group
69
+ code.to_fasp_rating
60
70
  end
61
71
 
62
72
  def prepare_code_filters(code_array)
63
- code_array[:icd_code].flatten!
64
- code_array[:icd_code].delete_if(&:blank?)
65
- code_array[:code_group].flatten!
66
- code_array[:code_group].delete_if(&:blank?)
73
+ clean_code_array(code_array)
67
74
 
68
75
  code_filters = {}
69
76
  if code_array[:icd_code].any?
70
77
  code_filters[:icd_code] = { Canql::BEGINS => code_array[:icd_code] }
71
78
  end
72
- return code_filters if code_array[:code_group].blank?
73
79
 
74
- code_filters[:code_group] = { Canql::EQUALS => code_array[:code_group] }
80
+ if code_array[:code_group].any?
81
+ code_filters[:code_group] = { Canql::EQUALS => code_array[:code_group] }
82
+ end
83
+
84
+ if code_array[:fasp_rating].any?
85
+ code_filters[:fasp_rating] = { Canql::EQUALS => code_array[:fasp_rating] }
86
+ end
87
+
75
88
  code_filters
76
89
  end
77
90
 
91
+ def clean_code_array(code_array)
92
+ code_array[:icd_code].flatten!
93
+ code_array[:icd_code].delete_if(&:blank?)
94
+ code_array[:code_group].flatten!
95
+ code_array[:code_group].delete_if(&:blank?)
96
+ code_array[:fasp_rating].flatten!
97
+ code_array[:fasp_rating].delete_if(&:blank?)
98
+ end
99
+
78
100
  def code_filter
79
101
  return {} if code_data.text_value.blank?
80
102
 
81
- code_arrays = { icd_code: [], code_group: [] }
103
+ code_arrays = { icd_code: [], code_group: [], fasp_rating: [] }
82
104
  code_arrays[code_type(code_data.first)] << code_value(code_data.first)
83
105
  code_data.rest.elements.each do |code|
84
106
  code_arrays[code_type(code)] << code_value(code)
@@ -90,8 +112,9 @@ module Canql #:nodoc: all
90
112
  module AdditionalCodeNode
91
113
  def code_type
92
114
  return :icd_code if anomalies_icd_code.respond_to?(:to_code)
115
+ return :code_group if anomalies_icd_code.respond_to?(:to_code_group)
93
116
 
94
- :code_group
117
+ :fasp_rating
95
118
  end
96
119
 
97
120
  def to_code
@@ -101,6 +124,10 @@ module Canql #:nodoc: all
101
124
  def to_code_group
102
125
  anomalies_icd_code.to_code_group if :code_group == code_type
103
126
  end
127
+
128
+ def to_fasp_rating
129
+ anomalies_icd_code.to_fasp_rating if :fasp_rating == code_type
130
+ end
104
131
  end
105
132
 
106
133
  module SingleIcdCodeNode
@@ -114,6 +141,14 @@ module Canql #:nodoc: all
114
141
  text_value.gsub(/( )/, '_').upcase
115
142
  end
116
143
  end
144
+
145
+ module SingleFaspRatingNode
146
+ def to_fasp_rating
147
+ text_value.gsub(/( )/, '_').upcase.split('_AND_').map do |value|
148
+ value.start_with?('FASP_') ? value : "FASP_#{value}"
149
+ end
150
+ end
151
+ end
117
152
  end
118
153
  end
119
154
  end
@@ -29,20 +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 = []
32
+ sub_clauses = build_sub_clauses
33
+
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] }
39
+ end
40
+ end
41
+ conditions
42
+ end
43
+
44
+ def build_sub_clauses
45
+ sub_clauses = {}
35
46
 
36
47
  post.elements.each do |element|
37
- anomalies << element.to_anomaly if element.respond_to?(:to_anomaly)
38
- genetic_tests << element.to_genetic_test if element.respond_to?(:to_genetic_test)
39
- test_results << element.to_test_result if element.respond_to?(:to_test_result)
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)
40
55
  end
56
+ sub_clauses
57
+ end
41
58
 
42
- conditions['anomalies'] = { Canql::ALL => anomalies } if anomalies.any?
43
- conditions['genetic_tests'] = { Canql::ALL => genetic_tests } if genetic_tests.any?
44
- conditions['test_results'] = { Canql::ALL => test_results } if test_results.any?
45
- conditions
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)
46
64
  end
47
65
  end
48
66
  end
@@ -54,7 +54,9 @@ module Canql #:nodoc: all
54
54
  'booking hospital': { patient: 'booking_hospital' },
55
55
  'screening status': { patient: 'screeningstatus' },
56
56
  'number of fetuses at delivery': { patient: 'numoffetusesatdelivery' },
57
- 'malformed in set': { patient: 'malformedinset' }
57
+ 'malformed in set': { patient: 'malformedinset' },
58
+ 'gestation at delivery': { patient: 'gestationallength' },
59
+ 'booking date': { patient: 'firstbookingdate' }
58
60
  }.freeze
59
61
 
60
62
  def meta_data_item
@@ -0,0 +1,75 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Canql #:nodoc: all
4
+ module Nodes
5
+ module TestResultGroup
6
+ module WithCondition
7
+ def test_result_group
8
+ group.text_value.strip.parameterize.underscore
9
+ end
10
+
11
+ def to_test_result_group
12
+ test_result_group_hash = { 'exists' => existance_filter }
13
+ test_result_group_hash['required'] = requirement_filter
14
+ test_result_group_hash['group'] = test_result_group_filter if test_result_group.present?
15
+ test_result_group_hash
16
+ end
17
+
18
+ def existance_filter
19
+ {
20
+ Canql::EQUALS => ['supplied required', 'supplied'].include?(
21
+ existance_modifier.text_value.strip
22
+ )
23
+ }
24
+ end
25
+
26
+ def requirement_filter
27
+ {
28
+ Canql::EQUALS => ['supplied required', 'missing required'].include?(
29
+ existance_modifier.text_value.strip
30
+ )
31
+ }
32
+ end
33
+
34
+ def test_result_group_filter
35
+ { Canql::EQUALS => test_result_group }
36
+ end
37
+ end
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
74
+ end
75
+ end
data/lib/canql/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  # This stores the current version of the Canql gem
4
4
  module Canql
5
- VERSION = '4.3.0'
5
+ VERSION = '5.2.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: 4.3.0
4
+ version: 5.2.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: 2020-06-10 00:00:00.000000000 Z
11
+ date: 2021-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic
@@ -53,7 +53,7 @@ dependencies:
53
53
  version: '4.1'
54
54
  - - "<"
55
55
  - !ruby/object:Gem::Version
56
- version: '6'
56
+ version: '7'
57
57
  type: :runtime
58
58
  prerelease: false
59
59
  version_requirements: !ruby/object:Gem::Requirement
@@ -63,7 +63,7 @@ dependencies:
63
63
  version: '4.1'
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
- version: '6'
66
+ version: '7'
67
67
  - !ruby/object:Gem::Dependency
68
68
  name: treetop
69
69
  requirement: !ruby/object:Gem::Requirement
@@ -154,14 +154,14 @@ dependencies:
154
154
  requirements:
155
155
  - - "~>"
156
156
  - !ruby/object:Gem::Version
157
- version: '5.6'
157
+ version: '5.9'
158
158
  type: :development
159
159
  prerelease: false
160
160
  version_requirements: !ruby/object:Gem::Requirement
161
161
  requirements:
162
162
  - - "~>"
163
163
  - !ruby/object:Gem::Version
164
- version: '5.6'
164
+ version: '5.9'
165
165
  - !ruby/object:Gem::Dependency
166
166
  name: pry
167
167
  requirement: !ruby/object:Gem::Requirement
@@ -210,6 +210,9 @@ executables: []
210
210
  extensions: []
211
211
  extra_rdoc_files: []
212
212
  files:
213
+ - ".github/CODEOWNERS"
214
+ - ".github/workflows/lint.yml"
215
+ - ".github/workflows/test.yml"
213
216
  - ".gitignore"
214
217
  - ".hound.yml"
215
218
  - ".rubocop.yml"
@@ -238,6 +241,7 @@ files:
238
241
  - lib/canql/grammars/provider.treetop
239
242
  - lib/canql/grammars/registry.treetop
240
243
  - lib/canql/grammars/test_result.treetop
244
+ - lib/canql/grammars/test_result_group.treetop
241
245
  - lib/canql/nodes.rb
242
246
  - lib/canql/nodes/age.rb
243
247
  - lib/canql/nodes/anomaly.rb
@@ -250,6 +254,7 @@ files:
250
254
  - lib/canql/nodes/perinatal_hospital.rb
251
255
  - lib/canql/nodes/registry.rb
252
256
  - lib/canql/nodes/test_result.rb
257
+ - lib/canql/nodes/test_result_group.rb
253
258
  - lib/canql/parser.rb
254
259
  - lib/canql/treetop/extensions.rb
255
260
  - lib/canql/version.rb