canql 4.4.1 → 5.4.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: 128e610596fb3e43cd6072162b21fa77259823716772ed80272ceafc2f1a6b4c
4
- data.tar.gz: 54b9bc4e7dcb9f8952d07784089ab4c28d747bcc9f9c367e2ead3f91c4c74cdc
3
+ metadata.gz: 6fcbeb6ccebc9a99388e3eeb15f29d9faa270ac17f85cafecdf0384936fc8229
4
+ data.tar.gz: 99b63524c4ac676bf7e878475ec59d53701cc35003ecc9dfdafd10630a98b637
5
5
  SHA512:
6
- metadata.gz: 802678de8f0d709f40e5d1e049e0ab2d5c18590fda76e9a473b016a55c639821833d8f755d56ee7e79a29bd7cabdf78e50a99f7c32711e5bd197722055226102
7
- data.tar.gz: 2d56d8da5357e9b66f8f486dec03887f1d31ec0f6c405c34ae8e66ada36cb51e520a89808821b0b308dfdc7581eb39c2d4f17c3d1987e9dadf7540ad2feadd50
6
+ metadata.gz: d7b16d016a069fb971fdbf749a3aaa935a9310d9f461109c3a12eb8a72d65ac98beb60eb3f6f7c5040c16b6a52fd39afdb513414cf82b3bdf35b7528c70ad8ae
7
+ data.tar.gz: c44e33ce868f67731f27918dad42d4a683057390a9668c60332171ac337d3f643c6f0b03c103da05517be16720ac883cd4824a4a57870653f0363c30b3884649
@@ -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 relevant changes
3
+
4
+ ## 5.4.0 / 2021-03-08
5
+
6
+ * Add 'pending data' option to the anomaly screening status filter (#69)
7
+
8
+ ## 5.3.0 / 2021-03-05
9
+
10
+ * Added new FASP case RAG rating filters (#66)
11
+
12
+ ## 5.2.0 / 2021-03-04
13
+
14
+ * Added new FASP anomaly RAG rating filters (#63)
15
+
16
+ ## 5.1.0 / 2021-01-25
17
+
18
+ ### Added
19
+ * Added new filters for test acceptance requirments (#59)
20
+
21
+ ## 5.0.0 / 2021-01-19
22
+
23
+ ### Changed
24
+ * Changed the values of registry to use registry name rather than codes and added new supra-region options (#54)
25
+
26
+ ### Added
27
+ * Added fetal medicine and dating options to the test group filter (#50)
28
+ * Added new gestation at delivery and booking date to case field existance filter (#52)
3
29
 
4
30
  ## 4.4.1 / 2021-01-13
5
31
  ### Fixed
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
@@ -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: bb0b75b6914deea03a7a520cd0827eaf5ecab92f
26
+ safe_revision: 146b255b240b0efc928d39dd1b70ab221ddc3138
19
27
  CHANGELOG.md:
20
28
  comments:
21
- reviewed_by: josh.pencheon
22
- safe_revision: 171f61eb19427e34aeb4d6e901260d447094b6d0
29
+ reviewed_by: ollietulloch
30
+ safe_revision: 8e66f9ea2d880e368446969c3b0e63a1660cb427
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
@@ -51,7 +59,7 @@ file safety:
51
59
  canql.gemspec:
52
60
  comments:
53
61
  reviewed_by: josh.pencheon
54
- safe_revision: bb0b75b6914deea03a7a520cd0827eaf5ecab92f
62
+ safe_revision: 146b255b240b0efc928d39dd1b70ab221ddc3138
55
63
  lib/canql.rb:
56
64
  comments:
57
65
  reviewed_by: timgentry
@@ -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: b0b092613c94a8c2f04191dbe2a1a347c8e14d16
77
85
  lib/canql/grammars/batch_types.treetop:
78
86
  comments:
79
87
  reviewed_by: josh.pencheon
@@ -95,12 +103,12 @@ file safety:
95
103
  comments: It is a known issue that this is potentially susceptible to certain
96
104
  kinds of DoS attack
97
105
  reviewed_by: josh.pencheon
98
- safe_revision: 42bb9bd177a761b9d04d728e53fcf0ebd0083ae4
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
- reviewed_by: josh.pencheon
103
- safe_revision: 43425805d9ad4a99e63eeb5d50495fa14eaa053b
110
+ reviewed_by: ollietulloch
111
+ safe_revision: 481194575c30b48987f957a9cc5535d604ea0117
104
112
  lib/canql/grammars/perinatal_hospital.treetop:
105
113
  comments:
106
114
  reviewed_by: josh.pencheon
@@ -113,7 +121,7 @@ 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
@@ -122,7 +130,7 @@ file safety:
122
130
  lib/canql/grammars/test_result_group.treetop:
123
131
  comments:
124
132
  reviewed_by: josh.pencheon
125
- safe_revision: 42bb9bd177a761b9d04d728e53fcf0ebd0083ae4
133
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
126
134
  lib/canql/nodes.rb:
127
135
  comments:
128
136
  reviewed_by: josh.pencheon
@@ -133,8 +141,8 @@ file safety:
133
141
  safe_revision: 6932d590299ad4a9d2ba24b425b158c67142bf74
134
142
  lib/canql/nodes/anomaly.rb:
135
143
  comments:
136
- reviewed_by: josh.pencheon
137
- safe_revision: b7778ca1d536022a807420cc9fe0f1c2df7f73ef
144
+ reviewed_by: ollietulloch
145
+ safe_revision: e549c0dcafdd6004ec279bd256fae8b9964c9629
138
146
  lib/canql/nodes/batch_types.rb:
139
147
  comments:
140
148
  reviewed_by: josh.pencheon
@@ -154,11 +162,11 @@ file safety:
154
162
  lib/canql/nodes/main.rb:
155
163
  comments:
156
164
  reviewed_by: josh.pencheon
157
- safe_revision: c5f8f76b2c335a8554f39a14d6165bf5cd8f9b67
165
+ safe_revision: 361dea5dc6d64bdb7b03434dd2878f8c3b128c95
158
166
  lib/canql/nodes/patient.rb:
159
167
  comments:
160
- reviewed_by: josh.pencheon
161
- safe_revision: 43425805d9ad4a99e63eeb5d50495fa14eaa053b
168
+ reviewed_by: ollietulloch
169
+ safe_revision: 481194575c30b48987f957a9cc5535d604ea0117
162
170
  lib/canql/nodes/perinatal_hospital.rb:
163
171
  comments:
164
172
  reviewed_by: josh.pencheon
@@ -174,7 +182,7 @@ file safety:
174
182
  lib/canql/nodes/test_result_group.rb:
175
183
  comments:
176
184
  reviewed_by: josh.pencheon
177
- safe_revision: 42bb9bd177a761b9d04d728e53fcf0ebd0083ae4
185
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
178
186
  lib/canql/parser.rb:
179
187
  comments:
180
188
  reviewed_by: timgentry
@@ -185,12 +193,12 @@ file safety:
185
193
  safe_revision: 6932d590299ad4a9d2ba24b425b158c67142bf74
186
194
  lib/canql/version.rb:
187
195
  comments:
188
- reviewed_by: josh.pencheon
189
- safe_revision: 171f61eb19427e34aeb4d6e901260d447094b6d0
196
+ reviewed_by: ollietulloch
197
+ safe_revision: 8e66f9ea2d880e368446969c3b0e63a1660cb427
190
198
  test/anomaly_test_helper.rb:
191
199
  comments:
192
- reviewed_by: josh.pencheon
193
- safe_revision: 73a7dac17b20fcc77bcbd9d38777c8aa4d524816
200
+ reviewed_by: ollietulloch
201
+ safe_revision: e549c0dcafdd6004ec279bd256fae8b9964c9629
194
202
  test/canql_test.rb:
195
203
  comments:
196
204
  reviewed_by: timgentry
@@ -201,8 +209,8 @@ file safety:
201
209
  safe_revision: 6932d590299ad4a9d2ba24b425b158c67142bf74
202
210
  test/nodes/anomaly_test.rb:
203
211
  comments:
204
- reviewed_by: josh.pencheon
205
- safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
212
+ reviewed_by: ollietulloch
213
+ safe_revision: b0b092613c94a8c2f04191dbe2a1a347c8e14d16
206
214
  test/nodes/case_age_test.rb:
207
215
  comments:
208
216
  reviewed_by: josh.pencheon
@@ -210,15 +218,15 @@ file safety:
210
218
  test/nodes/case_test.rb:
211
219
  comments:
212
220
  reviewed_by: josh.pencheon
213
- safe_revision: 43425805d9ad4a99e63eeb5d50495fa14eaa053b
221
+ safe_revision: 7490099869e368dcd5c26ded11eb90229baf4cae
214
222
  test/nodes/code_test.rb:
215
223
  comments:
216
- reviewed_by: josh.pencheon
217
- safe_revision: b7778ca1d536022a807420cc9fe0f1c2df7f73ef
224
+ reviewed_by: ollietulloch
225
+ safe_revision: e549c0dcafdd6004ec279bd256fae8b9964c9629
218
226
  test/nodes/e_base_records_test.rb:
219
227
  comments:
220
228
  reviewed_by: josh.pencheon
221
- safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
229
+ safe_revision: 293248a17d087d7557a6aacdcb5bf3fbec946b87
222
230
  test/nodes/genetic_tests_test.rb:
223
231
  comments:
224
232
  reviewed_by: josh.pencheon
@@ -241,8 +249,8 @@ file safety:
241
249
  safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
242
250
  test/nodes/patient_test.rb:
243
251
  comments:
244
- reviewed_by: josh.pencheon
245
- safe_revision: 43425805d9ad4a99e63eeb5d50495fa14eaa053b
252
+ reviewed_by: ollietulloch
253
+ safe_revision: 481194575c30b48987f957a9cc5535d604ea0117
246
254
  test/nodes/perinatal_hospital_test.rb:
247
255
  comments:
248
256
  reviewed_by: josh.pencheon
@@ -250,19 +258,19 @@ file safety:
250
258
  test/nodes/registry_test.rb:
251
259
  comments:
252
260
  reviewed_by: josh.pencheon
253
- safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
261
+ safe_revision: 293248a17d087d7557a6aacdcb5bf3fbec946b87
254
262
  test/nodes/test_result_groups_test.rb:
255
263
  comments:
256
264
  reviewed_by: josh.pencheon
257
- safe_revision: 42bb9bd177a761b9d04d728e53fcf0ebd0083ae4
265
+ safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
258
266
  test/nodes/test_results_test.rb:
259
267
  comments:
260
268
  reviewed_by: josh.pencheon
261
269
  safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
262
270
  test/parser_test.rb:
263
271
  comments:
264
- reviewed_by: timgentry
265
- safe_revision: 05ccd47fcbba92bf5525c4d36118274696169d61
272
+ reviewed_by: josh.pencheon
273
+ safe_revision: 293248a17d087d7557a6aacdcb5bf3fbec946b87
266
274
  test/test_helper.rb:
267
275
  comments:
268
276
  reviewed_by: josh.pencheon
@@ -23,7 +23,7 @@ module Canql
23
23
  'ics' / 'ineligible unbooked' / 'inb' / 'early detected' / 'ied' /
24
24
  'screen declined' / 'sd' / 'ineligible early loss' / 'iefl' / 'ineligible top' /
25
25
  'itop' / 'missed screen' / 'ms' / 'excluded' / 'exc' / 'detected' /
26
- 'undetected' / 'ineligible') word_break
26
+ 'undetected' / 'ineligible' / 'pending data') word_break
27
27
  end
28
28
 
29
29
  rule anomalies_keyword
@@ -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
@@ -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
@@ -13,7 +13,12 @@ module Canql
13
13
  end
14
14
 
15
15
  rule category
16
- space category:('eurocat amber and green' / 'eurocat red and amber' / 'eurocat red' / 'eurocat amber' / 'eurocat green' / 'eurocat') word_break <Nodes::Patient::CategoryNode>
16
+ space category:('eurocat amber and green' /
17
+ 'eurocat red and amber' / 'eurocat red' / 'eurocat amber' /
18
+ 'eurocat green' / 'eurocat' /
19
+ 'fasp red and amber' / 'fasp amber and red' / 'fasp red' /
20
+ 'fasp amber' / 'fasp green' / 'fasp excluded'
21
+ ) word_break <Nodes::Patient::CategoryNode>
17
22
  end
18
23
 
19
24
  rule expected_keyword
@@ -50,7 +55,8 @@ module Canql
50
55
  'delivery postcode' / 'booking postcode' / 'birth weight' /
51
56
  'place of delivery' / 'sex' / 'outcome' / 'edd' /
52
57
  'expected delivery date' / 'booking hospital' / 'screening status' /
53
- 'number of fetuses at delivery' / 'malformed in set'
58
+ 'number of fetuses at delivery' / 'malformed in set' / 'gestation at delivery' /
59
+ 'booking date'
54
60
  )
55
61
  end
56
62
 
@@ -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
@@ -10,7 +10,19 @@ module Canql
10
10
  end
11
11
 
12
12
  rule test_result_group_names
13
- space ('screening' / 'anomaly scan') word_break
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
14
26
  end
15
27
  end
16
28
  end
@@ -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,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
@@ -27,11 +27,11 @@ module Canql #:nodoc: all
27
27
  end
28
28
 
29
29
  def clean_category
30
- return 'eurocat_red' if 'eurocat red' == category.text_value
31
- return 'eurocat_amber' if 'eurocat amber' == category.text_value
32
- return 'eurocat_green' if 'eurocat green' == category.text_value
33
- return 'eurocat_amber_green' if 'eurocat amber and green' == category.text_value
34
- return 'eurocat_red_amber' if 'eurocat red and amber' == category.text_value
30
+ if category.text_value.start_with?('eurocat ') || category.text_value.start_with?('fasp ')
31
+ filter_value = category.text_value.gsub(/( )/, '_').downcase.gsub(/(_and_)/, '_')
32
+ filter_value = 'fasp_red_amber' if filter_value == 'fasp_amber_red'
33
+ return filter_value
34
+ end
35
35
 
36
36
  category.text_value
37
37
  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
@@ -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
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.4.1'
5
+ VERSION = '5.4.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.4.1
4
+ version: 5.4.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-13 00:00:00.000000000 Z
11
+ date: 2021-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic
@@ -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"