canql 5.1.0 → 5.6.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: 7388b9b6f880c7c55b4db80358ff06f5ac5753f70f70aae5e4791b3ad2f886d9
4
- data.tar.gz: 44c1a08147f5d7eee119242432184238388af321f311149cf498550e417af5fd
3
+ metadata.gz: 69ac77dc14c9bcc2dd95a64e29769c0745f22618dcde8d61da511037b9a57ac1
4
+ data.tar.gz: 3a75f686973aff03cae2f87d573c6037db3d28e1de8f3c2a41ded5f42b04b8c0
5
5
  SHA512:
6
- metadata.gz: 3e0eec913600a18381b348c94a466ebc2ef3f8d1a92b505be0975bd77adc63781f54d63f18b7a7c890e0dcea2f3e83303d963fc767e78ee0d1287e4690f59090
7
- data.tar.gz: e0ffb6f335045c5238a3b42c4469504cc6a24eaa4eff90e9f9fa217e0e76f9f06d53c6f98572302cfd8737626f4a558afae93408938c64f1e1f6aa0b7bf7f05a
6
+ metadata.gz: 9daec279858e2f8aeeb96ea9bf06c87d50e0061f6a5b47a7c06f8f7de071d2c85033f2025b7e1a4ad50af4f8e41d222e45f1a0a60f4bf1da45010c2ae5bf6b14
7
+ data.tar.gz: 9c691d7d0e6b356ed2af4cdfc0787d8499d81ab930db1c295932384e35a5c3283698fb7fb361332ef2db67263ea337fefc1110b8872bacded290b61f2c669bad
@@ -1,6 +1,6 @@
1
1
  name: Test
2
2
 
3
- on: [push, pull_request]
3
+ on: [push]
4
4
 
5
5
  jobs:
6
6
  test:
data/CHANGELOG.md CHANGED
@@ -1,13 +1,31 @@
1
1
  ## [Unreleased]
2
- *no unreleased changes*
2
+ * no relevant changes
3
3
 
4
- ## 5.1.0 / 2021-01-25
4
+ ## 5.6.0 / 2021-03-16
5
+ ### Added
6
+ * Add new CA Death option to the unprocessed record filter (#75)
7
+
8
+ ## 5.5.0 / 2021-03-16
9
+ ### Added
10
+ * Add HES event filter (#72)
11
+
12
+ ## 5.4.0 / 2021-03-08
13
+ ### Added
14
+ * Add 'pending data' option to the anomaly screening status filter (#69)
5
15
 
16
+ ## 5.3.0 / 2021-03-05
17
+ ### Added
18
+ * Added new FASP case RAG rating filters (#66)
19
+
20
+ ## 5.2.0 / 2021-03-04
21
+ ### Added
22
+ * Added new FASP anomaly RAG rating filters (#63)
23
+
24
+ ## 5.1.0 / 2021-01-25
6
25
  ### Added
7
26
  * Added new filters for test acceptance requirments (#59)
8
27
 
9
28
  ## 5.0.0 / 2021-01-19
10
-
11
29
  ### Changed
12
30
  * Changed the values of registry to use registry name rather than codes and added new supra-region options (#54)
13
31
 
data/README.md CHANGED
@@ -50,7 +50,7 @@ would output:
50
50
  and booking at hospital RGT01 and delivery at addenbrookes trust
51
51
  The parser is case insensitive. An example of an almost fully involved CANQL query is:
52
52
 
53
- > First 27 Male Liveborn Thames Primary Cases Due between 20/06/2015 and 25/06/2015 and Born on 22/06/2015 and that Died on 07/07/2015 with Suspected Prenatal Q20 Anomalies and Booking at hospital RGT01 and Delivery at addenbrookes trust and Postnatal Tests and Missing Postcode and Date of Birth and QA Action and Unprocessed paediatric records and Mother Born between 01/10/1990 and 10/01/1999 and who Died on 01/08/2015 with Populated Postcode and NHS Number
53
+ > First 27 Male Liveborn Thames Primary Cases Due between 20/06/2015 and 25/06/2015 and Born on 22/06/2015 and that Died on 07/07/2015 with Suspected Prenatal Q20 Anomalies and Booking at hospital RGT01 and Delivery at addenbrookes trust and Postnatal Tests and Missing Postcode and Date of Birth and QA Action and Unprocessed paediatric records and hes records and Mother Born between 01/10/1990 and 10/01/1999 and who Died on 01/08/2015 with Populated Postcode and NHS Number
54
54
 
55
55
  Please see the tests for many more examples.
56
56
 
data/code_safety.yml CHANGED
@@ -11,7 +11,7 @@ file safety:
11
11
  ".github/workflows/test.yml":
12
12
  comments:
13
13
  reviewed_by: josh.pencheon
14
- safe_revision: 865fc970554fee9207f8e3cd0247133c6a849b24
14
+ safe_revision: a3f5265f1d20a6dcb8c45ab5f09207ca7d1e255c
15
15
  ".gitignore":
16
16
  comments:
17
17
  reviewed_by: timgentry
@@ -27,7 +27,7 @@ file safety:
27
27
  CHANGELOG.md:
28
28
  comments:
29
29
  reviewed_by: josh.pencheon
30
- safe_revision: aea0d1a480e886a63b723135c7381cdcee0d4b25
30
+ safe_revision: 29d2a4accc6fbe9305b01e79cb285e5bf8531cbc
31
31
  CODE_OF_CONDUCT.md:
32
32
  comments:
33
33
  reviewed_by: drewthorp
@@ -43,7 +43,7 @@ file safety:
43
43
  README.md:
44
44
  comments:
45
45
  reviewed_by: josh.pencheon
46
- safe_revision: 8c07968aa84db92b6f1cc528180f73530ddc6ff5
46
+ safe_revision: 3ace8794c1c545b47898da1fbee49af8afdbf521
47
47
  Rakefile:
48
48
  comments:
49
49
  reviewed_by: timgentry
@@ -71,7 +71,7 @@ file safety:
71
71
  lib/canql/grammars.rb:
72
72
  comments:
73
73
  reviewed_by: josh.pencheon
74
- safe_revision: c5f8f76b2c335a8554f39a14d6165bf5cd8f9b67
74
+ safe_revision: 3ace8794c1c545b47898da1fbee49af8afdbf521
75
75
  lib/canql/grammars/age.treetop:
76
76
  comments: It is a known issue that this is potentially susceptible to certain
77
77
  kinds of DoS attack
@@ -80,12 +80,12 @@ file safety:
80
80
  lib/canql/grammars/anomaly.treetop:
81
81
  comments: It is a known issue that this is potentially susceptible to certain
82
82
  kinds of DoS attack
83
- reviewed_by: josh.pencheon
84
- safe_revision: b7778ca1d536022a807420cc9fe0f1c2df7f73ef
83
+ reviewed_by: ollietulloch
84
+ safe_revision: b0b092613c94a8c2f04191dbe2a1a347c8e14d16
85
85
  lib/canql/grammars/batch_types.treetop:
86
86
  comments:
87
87
  reviewed_by: josh.pencheon
88
- safe_revision: 1892161f3c300f3b199aa318b3fe23a54dd80829
88
+ safe_revision: df64f58ac3cc8dbd70d1792d24071ef013f9ae42
89
89
  lib/canql/grammars/dates.treetop:
90
90
  comments: It is a known issue that this is potentially susceptible to certain
91
91
  kinds of DoS attack
@@ -99,16 +99,20 @@ file safety:
99
99
  comments:
100
100
  reviewed_by: josh.pencheon
101
101
  safe_revision: 526dbe8a3dc3334b4174928e6f51d07e48ed9247
102
+ lib/canql/grammars/hes_event.treetop:
103
+ comments:
104
+ reviewed_by: josh.pencheon
105
+ safe_revision: 3ace8794c1c545b47898da1fbee49af8afdbf521
102
106
  lib/canql/grammars/main.treetop:
103
107
  comments: It is a known issue that this is potentially susceptible to certain
104
108
  kinds of DoS attack
105
109
  reviewed_by: josh.pencheon
106
- safe_revision: 9bb663b220e76e78f3f0f48e4bc6334fe9451925
110
+ safe_revision: 3ace8794c1c545b47898da1fbee49af8afdbf521
107
111
  lib/canql/grammars/patient.treetop:
108
112
  comments: It is a known issue that this is potentially susceptible to certain
109
113
  kinds of DoS attack
110
- reviewed_by: josh.pencheon
111
- safe_revision: 7490099869e368dcd5c26ded11eb90229baf4cae
114
+ reviewed_by: ollietulloch
115
+ safe_revision: 481194575c30b48987f957a9cc5535d604ea0117
112
116
  lib/canql/grammars/perinatal_hospital.treetop:
113
117
  comments:
114
118
  reviewed_by: josh.pencheon
@@ -134,19 +138,19 @@ file safety:
134
138
  lib/canql/nodes.rb:
135
139
  comments:
136
140
  reviewed_by: josh.pencheon
137
- safe_revision: c5f8f76b2c335a8554f39a14d6165bf5cd8f9b67
141
+ safe_revision: 3ace8794c1c545b47898da1fbee49af8afdbf521
138
142
  lib/canql/nodes/age.rb:
139
143
  comments:
140
144
  reviewed_by: timgentry
141
145
  safe_revision: 6932d590299ad4a9d2ba24b425b158c67142bf74
142
146
  lib/canql/nodes/anomaly.rb:
143
147
  comments:
144
- reviewed_by: josh.pencheon
145
- safe_revision: b7778ca1d536022a807420cc9fe0f1c2df7f73ef
148
+ reviewed_by: ollietulloch
149
+ safe_revision: e549c0dcafdd6004ec279bd256fae8b9964c9629
146
150
  lib/canql/nodes/batch_types.rb:
147
151
  comments:
148
152
  reviewed_by: josh.pencheon
149
- safe_revision: 1892161f3c300f3b199aa318b3fe23a54dd80829
153
+ safe_revision: df64f58ac3cc8dbd70d1792d24071ef013f9ae42
150
154
  lib/canql/nodes/dates.rb:
151
155
  comments:
152
156
  reviewed_by: timgentry
@@ -159,14 +163,18 @@ file safety:
159
163
  comments:
160
164
  reviewed_by: josh.pencheon
161
165
  safe_revision: 526dbe8a3dc3334b4174928e6f51d07e48ed9247
166
+ lib/canql/nodes/hes_event.rb:
167
+ comments:
168
+ reviewed_by: josh.pencheon
169
+ safe_revision: 3ace8794c1c545b47898da1fbee49af8afdbf521
162
170
  lib/canql/nodes/main.rb:
163
171
  comments:
164
172
  reviewed_by: josh.pencheon
165
- safe_revision: 361dea5dc6d64bdb7b03434dd2878f8c3b128c95
173
+ safe_revision: 3ace8794c1c545b47898da1fbee49af8afdbf521
166
174
  lib/canql/nodes/patient.rb:
167
175
  comments:
168
- reviewed_by: josh.pencheon
169
- safe_revision: 7490099869e368dcd5c26ded11eb90229baf4cae
176
+ reviewed_by: ollietulloch
177
+ safe_revision: 481194575c30b48987f957a9cc5535d604ea0117
170
178
  lib/canql/nodes/perinatal_hospital.rb:
171
179
  comments:
172
180
  reviewed_by: josh.pencheon
@@ -194,23 +202,27 @@ file safety:
194
202
  lib/canql/version.rb:
195
203
  comments:
196
204
  reviewed_by: josh.pencheon
197
- safe_revision: aea0d1a480e886a63b723135c7381cdcee0d4b25
205
+ safe_revision: 29d2a4accc6fbe9305b01e79cb285e5bf8531cbc
198
206
  test/anomaly_test_helper.rb:
199
207
  comments:
200
- reviewed_by: josh.pencheon
201
- safe_revision: 73a7dac17b20fcc77bcbd9d38777c8aa4d524816
208
+ reviewed_by: ollietulloch
209
+ safe_revision: e549c0dcafdd6004ec279bd256fae8b9964c9629
202
210
  test/canql_test.rb:
203
211
  comments:
204
212
  reviewed_by: timgentry
205
213
  safe_revision: 6932d590299ad4a9d2ba24b425b158c67142bf74
214
+ test/hes_event_test_helper.rb:
215
+ comments:
216
+ reviewed_by: josh.pencheon
217
+ safe_revision: 3ace8794c1c545b47898da1fbee49af8afdbf521
206
218
  test/minitest_helper.rb:
207
219
  comments:
208
220
  reviewed_by: timgentry
209
221
  safe_revision: 6932d590299ad4a9d2ba24b425b158c67142bf74
210
222
  test/nodes/anomaly_test.rb:
211
223
  comments:
212
- reviewed_by: josh.pencheon
213
- safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
224
+ reviewed_by: ollietulloch
225
+ safe_revision: b0b092613c94a8c2f04191dbe2a1a347c8e14d16
214
226
  test/nodes/case_age_test.rb:
215
227
  comments:
216
228
  reviewed_by: josh.pencheon
@@ -221,16 +233,20 @@ file safety:
221
233
  safe_revision: 7490099869e368dcd5c26ded11eb90229baf4cae
222
234
  test/nodes/code_test.rb:
223
235
  comments:
224
- reviewed_by: josh.pencheon
225
- safe_revision: b7778ca1d536022a807420cc9fe0f1c2df7f73ef
236
+ reviewed_by: ollietulloch
237
+ safe_revision: e549c0dcafdd6004ec279bd256fae8b9964c9629
226
238
  test/nodes/e_base_records_test.rb:
227
239
  comments:
228
240
  reviewed_by: josh.pencheon
229
- safe_revision: 293248a17d087d7557a6aacdcb5bf3fbec946b87
241
+ safe_revision: df64f58ac3cc8dbd70d1792d24071ef013f9ae42
230
242
  test/nodes/genetic_tests_test.rb:
231
243
  comments:
232
244
  reviewed_by: josh.pencheon
233
245
  safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
246
+ test/nodes/hes_event_test.rb:
247
+ comments:
248
+ reviewed_by: josh.pencheon
249
+ safe_revision: 3ace8794c1c545b47898da1fbee49af8afdbf521
234
250
  test/nodes/main_case_test.rb:
235
251
  comments:
236
252
  reviewed_by: josh.pencheon
@@ -249,8 +265,8 @@ file safety:
249
265
  safe_revision: 511e4238f83eb5b32839c25d94ec2a59145539bb
250
266
  test/nodes/patient_test.rb:
251
267
  comments:
252
- reviewed_by: josh.pencheon
253
- safe_revision: 43425805d9ad4a99e63eeb5d50495fa14eaa053b
268
+ reviewed_by: ollietulloch
269
+ safe_revision: 481194575c30b48987f957a9cc5535d604ea0117
254
270
  test/nodes/perinatal_hospital_test.rb:
255
271
  comments:
256
272
  reviewed_by: josh.pencheon
@@ -270,7 +286,7 @@ file safety:
270
286
  test/parser_test.rb:
271
287
  comments:
272
288
  reviewed_by: josh.pencheon
273
- safe_revision: 293248a17d087d7557a6aacdcb5bf3fbec946b87
289
+ safe_revision: 3ace8794c1c545b47898da1fbee49af8afdbf521
274
290
  test/test_helper.rb:
275
291
  comments:
276
292
  reviewed_by: josh.pencheon
@@ -14,4 +14,5 @@ Treetop.load File.expand_path('grammars/patient', File.dirname(__FILE__))
14
14
  Treetop.load File.expand_path('grammars/registry', File.dirname(__FILE__))
15
15
  Treetop.load File.expand_path('grammars/provider', File.dirname(__FILE__))
16
16
  Treetop.load File.expand_path('grammars/perinatal_hospital', File.dirname(__FILE__))
17
+ Treetop.load File.expand_path('grammars/hes_event', File.dirname(__FILE__))
17
18
  Treetop.load File.expand_path('grammars/main', File.dirname(__FILE__))
@@ -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
@@ -1,7 +1,7 @@
1
1
  module Canql
2
2
  grammar BatchTypes
3
3
  rule batch_type
4
- (paediatric / enote2 / badger / ucyto / nipt / rddeath / umum) <Nodes::BatchTypeNode>
4
+ (paediatric / enote2 / badger / ucyto / nipt / rddeath / umum / ca_death) <Nodes::BatchTypeNode>
5
5
  end
6
6
 
7
7
  rule paediatric
@@ -25,11 +25,15 @@ module Canql
25
25
  end
26
26
 
27
27
  rule rddeath
28
- ('rddeath' / 'rare disease death') <Nodes::RddeathNode>
28
+ ('rddeath' / 'rd death' / 'rare disease death') <Nodes::RddeathNode>
29
29
  end
30
30
 
31
31
  rule umum
32
32
  ('umum' / 'mum') <Nodes::UmumNode>
33
33
  end
34
+
35
+ rule ca_death
36
+ ('cadeath' / 'ca death' / 'congenital anomaly death') <Nodes::CADeathNode>
37
+ end
34
38
  end
35
39
  end
@@ -0,0 +1,15 @@
1
+ module Canql
2
+ grammar HesEvent
3
+ rule hes_events
4
+ and_keyword? existance_modifier:hes_no_keyword? hes_keyword <Nodes::HesEvent::WithCondition>
5
+ end
6
+
7
+ rule hes_no_keyword
8
+ space ('no' / 'some') word_break
9
+ end
10
+
11
+ rule hes_keyword
12
+ space ('hes events' / 'hes records') word_break
13
+ end
14
+ end
15
+ end
@@ -6,6 +6,7 @@ grammar Canql
6
6
  include GeneticTest
7
7
  include TestResult
8
8
  include TestResultGroup
9
+ include HesEvent
9
10
  include Dates
10
11
  include EBaseRecords
11
12
  include BatchTypes
@@ -130,10 +131,11 @@ grammar Canql
130
131
  rule case_with_conditions
131
132
  anomalies / genetic_tests / test_results / perinatal_hospital /
132
133
  case_field_existance / test_acceptance_existance / test_result_groups /
133
- mother_conditions / action_or_ebr
134
+ mother_conditions / action_or_ebr / hes_events
134
135
  end
135
136
 
136
137
  rule patient_with_conditions
137
- anomalies / genetic_tests / test_results / patient_field_existance / action_or_ebr
138
+ anomalies / genetic_tests / test_results / patient_field_existance /
139
+ action_or_ebr / hes_events
138
140
  end
139
141
  end
@@ -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
data/lib/canql/nodes.rb CHANGED
@@ -22,3 +22,4 @@ require 'canql/nodes/patient'
22
22
  require 'canql/nodes/main'
23
23
  require 'canql/nodes/registry'
24
24
  require 'canql/nodes/perinatal_hospital'
25
+ require 'canql/nodes/hes_event'
@@ -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
@@ -50,5 +50,11 @@ module Canql #:nodoc: all
50
50
  'umum'
51
51
  end
52
52
  end
53
+
54
+ module CADeathNode
55
+ def normalise
56
+ 'ca_death'
57
+ end
58
+ end
53
59
  end
54
60
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Canql #:nodoc: all
4
+ module Nodes
5
+ module HesEvent
6
+ module WithCondition
7
+ def to_hes
8
+ { 'exists' => existance_filter }
9
+ end
10
+
11
+ def existance_filter
12
+ { Canql::EQUALS => existance_modifier.text_value.strip != 'no' }
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -32,7 +32,7 @@ module Canql #:nodoc: all
32
32
  sub_clauses = build_sub_clauses
33
33
 
34
34
  %i[
35
- anomalies genetic_tests test_results test_result_groups test_acceptances
35
+ anomalies genetic_tests test_results test_result_groups test_acceptances hes_events
36
36
  ].each do |condition_key|
37
37
  if sub_clauses[condition_key].present?
38
38
  conditions[condition_key.to_s] = { Canql::ALL => sub_clauses[condition_key] }
@@ -52,6 +52,7 @@ module Canql #:nodoc: all
52
52
  sub_clauses, element, :test_result_groups, :to_test_result_group
53
53
  )
54
54
  add_sub_clause(sub_clauses, element, :test_acceptances, :to_test_acceptance)
55
+ add_sub_clause(sub_clauses, element, :hes_events, :to_hes)
55
56
  end
56
57
  sub_clauses
57
58
  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
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 = '5.1.0'
5
+ VERSION = '5.6.0'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canql
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.1.0
4
+ version: 5.6.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-25 00:00:00.000000000 Z
11
+ date: 2021-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic
@@ -235,6 +235,7 @@ files:
235
235
  - lib/canql/grammars/dates.treetop
236
236
  - lib/canql/grammars/e_base_records.treetop
237
237
  - lib/canql/grammars/genetic_test.treetop
238
+ - lib/canql/grammars/hes_event.treetop
238
239
  - lib/canql/grammars/main.treetop
239
240
  - lib/canql/grammars/patient.treetop
240
241
  - lib/canql/grammars/perinatal_hospital.treetop
@@ -249,6 +250,7 @@ files:
249
250
  - lib/canql/nodes/dates.rb
250
251
  - lib/canql/nodes/e_base_records.rb
251
252
  - lib/canql/nodes/genetic_test.rb
253
+ - lib/canql/nodes/hes_event.rb
252
254
  - lib/canql/nodes/main.rb
253
255
  - lib/canql/nodes/patient.rb
254
256
  - lib/canql/nodes/perinatal_hospital.rb