canql 4.2.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: cae877e85501e0232435e382e6d85d2e459f7e6d56949af56da961b61cd6cad3
4
- data.tar.gz: e4784685847d709ee82f5efc5604bf64580abd40086508405ecb81033ef18bb1
3
+ metadata.gz: 7388b9b6f880c7c55b4db80358ff06f5ac5753f70f70aae5e4791b3ad2f886d9
4
+ data.tar.gz: 44c1a08147f5d7eee119242432184238388af321f311149cf498550e417af5fd
5
5
  SHA512:
6
- metadata.gz: e6422e9a620ca68b7b2e2652acac3a5c26a23b9df77805cb447dbf8686a2a83854724d04494724b1191dbfc23c49364962651661ff626ad01c61cd093c8a4ab3
7
- data.tar.gz: 226e646ada25dfd3b642b10c21436d500be7cc3ed7597fe5d6f5cc6c824a3165d88a8b9d227004db3e550bcb2bf2c94431068f10fba2ecddc794e6ae8e9178d5
6
+ metadata.gz: 3e0eec913600a18381b348c94a466ebc2ef3f8d1a92b505be0975bd77adc63781f54d63f18b7a7c890e0dcea2f3e83303d963fc767e78ee0d1287e4690f59090
7
+ data.tar.gz: e0ffb6f335045c5238a3b42c4469504cc6a24eaa4eff90e9f9fa217e0e76f9f06d53c6f98572302cfd8737626f4a558afae93408938c64f1e1f6aa0b7bf7f05a
@@ -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 }}
@@ -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
@@ -1,6 +1,32 @@
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
+
9
+ ## 5.0.0 / 2021-01-19
10
+
11
+ ### Changed
12
+ * Changed the values of registry to use registry name rather than codes and added new supra-region options (#54)
13
+
14
+ ### Added
15
+ * Added fetal medicine and dating options to the test group filter (#50)
16
+ * Added new gestation at delivery and booking date to case field existance filter (#52)
17
+
18
+ ## 4.4.1 / 2021-01-13
19
+ ### Fixed
20
+ * Relax constraints to support Rails 6.x
21
+
22
+ ## 4.4.0 / 2020-07-08
23
+ ### Added
24
+ * Added filter for missing and supplied required test result groups (#47)
25
+
26
+ ## 4.3.0 / 2020-06-10
27
+ ### Added
28
+ * Added additional field existance options (#45)
29
+
4
30
  ## 4.2.0 / 2020-03-25
5
31
  ### Added
6
32
  * Added additional EUROCAT category filters for RAG combination
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
 
@@ -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/
@@ -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
29
  reviewed_by: josh.pencheon
22
- safe_revision: 9eb40acab7fee77ec063809d284116abfaca226c
30
+ safe_revision: aea0d1a480e886a63b723135c7381cdcee0d4b25
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
@@ -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: ed542274fcb2a9ad9982825fc42f2ab5948d73b6
111
+ safe_revision: 7490099869e368dcd5c26ded11eb90229baf4cae
104
112
  lib/canql/grammars/perinatal_hospital.treetop:
105
113
  comments:
106
114
  reviewed_by: josh.pencheon
@@ -113,16 +121,20 @@ 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
@@ -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: ed542274fcb2a9ad9982825fc42f2ab5948d73b6
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
@@ -178,7 +194,7 @@ file safety:
178
194
  lib/canql/version.rb:
179
195
  comments:
180
196
  reviewed_by: josh.pencheon
181
- safe_revision: 9eb40acab7fee77ec063809d284116abfaca226c
197
+ safe_revision: aea0d1a480e886a63b723135c7381cdcee0d4b25
182
198
  test/anomaly_test_helper.rb:
183
199
  comments:
184
200
  reviewed_by: josh.pencheon
@@ -202,7 +218,7 @@ file safety:
202
218
  test/nodes/case_test.rb:
203
219
  comments:
204
220
  reviewed_by: josh.pencheon
205
- safe_revision: ed542274fcb2a9ad9982825fc42f2ab5948d73b6
221
+ safe_revision: 7490099869e368dcd5c26ded11eb90229baf4cae
206
222
  test/nodes/code_test.rb:
207
223
  comments:
208
224
  reviewed_by: josh.pencheon
@@ -210,7 +226,7 @@ file safety:
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
@@ -234,7 +250,7 @@ file safety:
234
250
  test/nodes/patient_test.rb:
235
251
  comments:
236
252
  reviewed_by: josh.pencheon
237
- safe_revision: ed542274fcb2a9ad9982825fc42f2ab5948d73b6
253
+ safe_revision: 43425805d9ad4a99e63eeb5d50495fa14eaa053b
238
254
  test/nodes/perinatal_hospital_test.rb:
239
255
  comments:
240
256
  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__))
@@ -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
@@ -46,16 +46,18 @@ module Canql
46
46
 
47
47
  rule case_field_names
48
48
  patient_field_name:(
49
- 'date of birth' / 'dob' / 'nhs number' / 'delivery postcode' /
50
- 'booking postcode' / 'birth weight' /
49
+ 'date of birth' / 'dob' / 'date of vital status' / 'nhs number' /
50
+ 'delivery postcode' / 'booking postcode' / 'birth weight' /
51
51
  'place of delivery' / 'sex' / 'outcome' / 'edd' /
52
- 'expected delivery date' / 'booking hospital' / 'screening status'
52
+ 'expected delivery date' / 'booking hospital' / 'screening status' /
53
+ 'number of fetuses at delivery' / 'malformed in set' / 'gestation at delivery' /
54
+ 'booking date'
53
55
  )
54
56
  end
55
57
 
56
58
  rule patient_field_names
57
59
  patient_field_name:(
58
- 'date of birth' / 'dob' / 'nhs number' / 'sex'
60
+ 'date of birth' / 'dob' / 'date of vital status' / 'nhs number' / 'sex'
59
61
  )
60
62
  end
61
63
 
@@ -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
@@ -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'
@@ -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
@@ -39,19 +39,24 @@ module Canql #:nodoc: all
39
39
 
40
40
  module FieldExists
41
41
  FIELDS = {
42
- 'date of birth': { patient: 'birthdate', mother: 'birthdate' },
43
- 'dob': { patient: 'birthdate', mother: 'birthdate' },
44
- 'delivery postcode': { patient: 'delivery_postcode' },
45
- 'booking postcode': { patient: 'booking_postcode' },
46
- 'nhs number': { patient: 'nhsnumber', mother: 'nhsnumber' },
47
- 'birth weight': { patient: 'weight' },
48
- 'place of delivery': { patient: 'placeofdelivery' },
49
- 'sex': { patient: 'sex' },
50
- 'outcome': { patient: 'outcome' },
51
- 'edd': { patient: 'expecteddeliverydate' },
42
+ 'date of birth': { patient: 'birthdate', mother: 'birthdate' },
43
+ 'dob': { patient: 'birthdate', mother: 'birthdate' },
44
+ 'date of vital status': { patient: 'dateofvitalstatus', mother: 'dateofvitalstatus' },
45
+ 'delivery postcode': { patient: 'delivery_postcode' },
46
+ 'booking postcode': { patient: 'booking_postcode' },
47
+ 'nhs number': { patient: 'nhsnumber', mother: 'nhsnumber' },
48
+ 'birth weight': { patient: 'weight' },
49
+ 'place of delivery': { patient: 'placeofdelivery' },
50
+ 'sex': { patient: 'sex' },
51
+ 'outcome': { patient: 'outcome' },
52
+ 'edd': { patient: 'expecteddeliverydate' },
52
53
  'expected delivery date': { patient: 'expecteddeliverydate' },
53
- 'booking hospital': { patient: 'booking_hospital' },
54
- 'screening status': { patient: 'screeningstatus' }
54
+ 'booking hospital': { patient: 'booking_hospital' },
55
+ 'screening status': { patient: 'screeningstatus' },
56
+ 'number of fetuses at delivery': { patient: 'numoffetusesatdelivery' },
57
+ 'malformed in set': { patient: 'malformedinset' },
58
+ 'gestation at delivery': { patient: 'gestationallength' },
59
+ 'booking date': { patient: 'firstbookingdate' }
55
60
  }.freeze
56
61
 
57
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
@@ -2,5 +2,5 @@
2
2
 
3
3
  # This stores the current version of the Canql gem
4
4
  module Canql
5
- VERSION = '4.2.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: 4.2.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: 2020-03-25 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
@@ -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