canql 5.9.0 → 6.0.1

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: 3df8c282627168b3542193781928b6be1e0b581c1f256b313b7fadfa4ba4adab
4
- data.tar.gz: 89b9e95e96f7c8e1f4989ccdbc08462996ccb44246c0f6ced446e3b7b5ca3498
3
+ metadata.gz: 360922ab34dbdcb72c3cad8ba6ae105044534b8955c77237dcc90789e610caca
4
+ data.tar.gz: 7b8f9550fcf004647b8831cbc401c417a34c81e3c27dbd7446725acca012b3ac
5
5
  SHA512:
6
- metadata.gz: 41ee65bb71db281d780de7083905ed120a5d046d0ec31980b21ffeeddf7b942233ceb8b5554cf19774d89f5628a40b8ef08e905514c621ae4b7691ecd9f9b8fb
7
- data.tar.gz: 9741961b88ac1fc9b243f5c2217004357ee92188170dfd6f285bdf08702d8a2e2ee1ed59da9f883d2151b2f80f3bb49b076afaa2c044e79bd4c6e2f4fb0e6c72
6
+ metadata.gz: b7c4eefb874fd4f0dd5b9ad0a5cdaab212d595d5ddd46a60f9f0b02704309597bda66b39edaf2abdf9d488e6676c9b81e1e09660700bedd3e744c24dd45fc481
7
+ data.tar.gz: 33a6c07541a128f31393d219246bf1e2135ac25ad30f84926232a1b86574ccf88ba159ef1b5798bb5a8e8d4e05ef279aa330c82c7779ff36230b7ef553297afa
data/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## 6.0.1 / 2024-10-14
4
+ ### Fixed
5
+ * Code only misspelling of existence
6
+ * Code only misspelling of modifier
7
+ * Code only misspelling of number
8
+ * Code only misspelling of acceptance
9
+ * Moved development dependencies to Gem files
10
+
11
+ ## 6.0.0 / 2024-09-30
12
+ ### Changed
13
+ * Changed the hes event filter to align with other new event filter
14
+ ### Added
15
+ * Added event filters for birth, death, pregnancy loss and MSDS
16
+ * Added 'number of fetuses in early pregnancy' to field existence modifier
17
+ * Removed 'CODING_CLINIC' & 'REG_GROUP' actions from the action filter
18
+ * Added 'BADGER_CHECKED', 'DELETE', 'FASP_CATEGORISATION', 'MSDS_SENT', 'RARE_DISEASE_TEAM', 'REG_CODING_FORUM' & 'SOURCES_CHECKED' actions to the action filter
19
+
3
20
  ## 5.9.0 / 2023-01-17
4
21
  * Added 'other' option to anomaly screening status filter (#90)
5
22
 
@@ -1,7 +1,7 @@
1
1
  module Canql
2
2
  grammar Anomaly
3
3
  rule anomalies
4
- and_keyword? existance_modifier:anomalies_no_keyword? status_type:anomaly_status? natal_period:anomalies_natal_period? screening_status_type:anomaly_screening_status? code_data:(space first:anomalies_icd_code rest:more_anomalies_icd_codes* word_break)? anomalies_keyword <Nodes::Anomaly::WithCondition>
4
+ and_keyword? existence_modifier:anomalies_no_keyword? status_type:anomaly_status? natal_period:anomalies_natal_period? screening_status_type:anomaly_screening_status? code_data:(space first:anomalies_icd_code rest:more_anomalies_icd_codes* word_break)? anomalies_keyword <Nodes::Anomaly::WithCondition>
5
5
  end
6
6
 
7
7
  rule anomalies_no_keyword
@@ -49,8 +49,10 @@ module Canql
49
49
  end
50
50
 
51
51
  rule accepted_action
52
- 'badger_search' / 'coding_clinic' / 'coding_group' / 'complete' / 'qa' /
53
- 'reg_group' / 'scr_checked' / 'scr_check' / 'search' / 'technical'
52
+ 'badger_search' / 'badger_checked' / 'coding_group' / 'complete' /
53
+ 'delete' / 'fasp_categorisation' / 'msds_sent' / 'qa' /
54
+ 'rare_disease_team' / 'reg_coding_forum' /
55
+ 'scr_checked' / 'scr_check' / 'search' / 'sources_checked' / 'technical'
54
56
  end
55
57
 
56
58
  rule all_or_none_actions
@@ -0,0 +1,39 @@
1
+ module Canql
2
+ grammar Events
3
+ rule events
4
+ and_keyword? existence_modifier:events_no_keyword? events_name event_object_keyword <Nodes::Events::WithCondition>
5
+ end
6
+
7
+ rule events_no_keyword
8
+ space ('no' / 'some') word_break
9
+ end
10
+
11
+ rule events_keywords
12
+ space ('birth' / 'death' / 'hes' / 'preg loss hes' / 'pregnancy loss hes' / 'preg loss bpas' / 'pregnancy loss bpas' / 'msds') word_break
13
+ end
14
+
15
+ rule relevant_events_keywords
16
+ space ('preg loss hes' / 'pregnancy loss hes' / 'preg loss bpas' / 'pregnancy loss bpas' / 'msds') word_break
17
+ end
18
+
19
+ rule events_name
20
+ (relevant_events / non_relevant_events)
21
+ end
22
+
23
+ rule non_relevant_events
24
+ event_type:events_keywords
25
+ end
26
+
27
+ rule relevant_events
28
+ event_relevance:event_relevant_keyword event_type:relevant_events_keywords
29
+ end
30
+
31
+ rule event_relevant_keyword
32
+ space ('linked' / 'relevant' / 'related' / 'unlinked' / 'irrelevant' / 'unrelated') word_break
33
+ end
34
+
35
+ rule event_object_keyword
36
+ space ('events' / 'event' / 'records' / 'record') word_break
37
+ end
38
+ end
39
+ end
@@ -1,7 +1,7 @@
1
1
  module Canql
2
2
  grammar GeneticTest
3
3
  rule genetic_tests
4
- and_keyword? existance_modifier:genetic_tests_no_keyword? genetic_tests_keyword <Nodes::GeneticTest::WithCondition>
4
+ and_keyword? existence_modifier:genetic_tests_no_keyword? genetic_tests_keyword <Nodes::GeneticTest::WithCondition>
5
5
  end
6
6
 
7
7
  rule genetic_tests_no_keyword
@@ -6,7 +6,7 @@ grammar Canql
6
6
  include GeneticTest
7
7
  include TestResult
8
8
  include TestResultGroup
9
- include HesEvent
9
+ include Events
10
10
  include Dates
11
11
  include EBaseRecords
12
12
  include BatchTypes
@@ -92,7 +92,7 @@ grammar Canql
92
92
  space 'and' word_break
93
93
  end
94
94
 
95
- rule existance_keyword
95
+ rule existence_keyword
96
96
  space ('missing' / ('field' 's'?) / 'populated') word_break
97
97
  end
98
98
 
@@ -130,12 +130,12 @@ grammar Canql
130
130
 
131
131
  rule case_with_conditions
132
132
  anomalies / genetic_tests / test_results / perinatal_hospital /
133
- case_field_existance / test_acceptance_existance / test_result_groups /
134
- mother_conditions / action_or_ebr / hes_events
133
+ case_field_existence / test_acceptance_existence / test_result_groups /
134
+ mother_conditions / action_or_ebr / events
135
135
  end
136
136
 
137
137
  rule patient_with_conditions
138
- anomalies / genetic_tests / test_results / patient_field_existance /
139
- action_or_ebr / hes_events
138
+ anomalies / genetic_tests / test_results / patient_field_existence /
139
+ action_or_ebr / events
140
140
  end
141
141
  end
@@ -30,12 +30,12 @@ module Canql
30
30
  expected_keyword fuzzy_date <Nodes::Patient::ExpectedDateRangeNode>
31
31
  end
32
32
 
33
- rule case_field_existance
34
- and_keyword? field_existance_modifier:existance_keyword patient_field_list:case_field_list <Nodes::Patient::FieldExists>
33
+ rule case_field_existence
34
+ and_keyword? field_existence_modifier:existence_keyword patient_field_list:case_field_list <Nodes::Patient::FieldExists>
35
35
  end
36
36
 
37
- rule patient_field_existance
38
- and_keyword? field_existance_modifier:existance_keyword patient_field_list:patient_field_list <Nodes::Patient::FieldExists>
37
+ rule patient_field_existence
38
+ and_keyword? field_existence_modifier:existence_keyword patient_field_list:patient_field_list <Nodes::Patient::FieldExists>
39
39
  end
40
40
 
41
41
  rule patient_fields_keyword
@@ -56,8 +56,8 @@ module Canql
56
56
  'delivery postcode' / 'booking postcode' / 'birth weight' /
57
57
  'place of delivery' / 'sex' / 'outcome' / 'edd' /
58
58
  'expected delivery date' / 'booking hospital' / 'screening status' /
59
- 'number of fetuses at delivery' / 'malformed in set' / 'gestation at delivery' /
60
- 'booking date'
59
+ 'number of fetuses at delivery' / 'number of fetuses in early pregnancy' /
60
+ 'malformed in set' / 'gestation at delivery' / 'booking date'
61
61
  )
62
62
  end
63
63
 
@@ -84,7 +84,7 @@ module Canql
84
84
  end
85
85
 
86
86
  rule mother_with_conditions
87
- patient_field_existance / action_or_ebr
87
+ patient_field_existence / action_or_ebr
88
88
  end
89
89
  end
90
90
  end
@@ -1,7 +1,7 @@
1
1
  module Canql
2
2
  grammar TestResult
3
3
  rule test_results
4
- and_keyword? existance_modifier:test_result_no_keyword? natal_period:test_result_natal_period? test_results_keyword <Nodes::TestResult::WithCondition>
4
+ and_keyword? existence_modifier:test_result_no_keyword? natal_period:test_result_natal_period? test_results_keyword <Nodes::TestResult::WithCondition>
5
5
  end
6
6
 
7
7
  rule test_result_no_keyword
@@ -1,10 +1,10 @@
1
1
  module Canql
2
2
  grammar TestResultGroup
3
3
  rule test_result_groups
4
- and_keyword? existance_modifier:test_result_group_existance_keyword group:test_result_group_names <Nodes::TestResultGroup::WithCondition>
4
+ and_keyword? existence_modifier:test_result_group_existence_keyword group:test_result_group_names <Nodes::TestResultGroup::WithCondition>
5
5
  end
6
6
 
7
- rule test_result_group_existance_keyword
7
+ rule test_result_group_existence_keyword
8
8
  # If in furture the reverse is needed use 'supplied require'
9
9
  space ('missing required' / 'missing' / 'supplied required' / 'supplied') word_break
10
10
  end
@@ -13,11 +13,11 @@ module Canql
13
13
  space ('screening' / 'anomaly scan' / 'fetal medicine' / 'dating') word_break
14
14
  end
15
15
 
16
- rule test_acceptance_existance
17
- and_keyword? existance_modifier:test_acceptance_existance_keyword acceptance:test_acceptance_names <Nodes::TestAcceptanceExistamce::WithCondition>
16
+ rule test_acceptance_existence
17
+ and_keyword? existence_modifier:test_acceptance_existence_keyword acceptance:test_acceptance_names <Nodes::TestAcceptanceExistence::WithCondition>
18
18
  end
19
19
 
20
- rule test_acceptance_existance_keyword
20
+ rule test_acceptance_existence_keyword
21
21
  space ('missing required' / 'missing' ) word_break
22
22
  end
23
23
 
@@ -14,5 +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
+ Treetop.load File.expand_path('grammars/events', File.dirname(__FILE__))
18
18
  Treetop.load File.expand_path('grammars/main', File.dirname(__FILE__))
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Canql #:nodoc: all
3
+ module Canql # :nodoc: all
4
4
  module Nodes
5
5
  module Age
6
6
  module BirthDateNode
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Canql #:nodoc: all
3
+ module Canql # :nodoc: all
4
4
  module Nodes
5
5
  module Anomaly
6
6
  module WithCondition
@@ -17,7 +17,7 @@ module Canql #:nodoc: all
17
17
  end
18
18
 
19
19
  def to_anomaly
20
- anomaly_hash = { 'exists' => existance_filter }
20
+ anomaly_hash = { 'exists' => existence_filter }
21
21
  anomaly_hash['type'] = anomaly_type_filter if anomaly_type.present?
22
22
  anomaly_hash['status'] = anomaly_status_type_filter if anomaly_status_type.present?
23
23
  if anomaly_screening_status_type.present?
@@ -30,16 +30,14 @@ module Canql #:nodoc: all
30
30
 
31
31
  def code_filters(anomaly_hash)
32
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
33
+ anomaly_hash['code_groups'] = code_filter[:code_group] if code_filter[:code_group].present?
36
34
  return if code_filter[:fasp_rating].blank?
37
35
 
38
36
  anomaly_hash['fasp_rating'] = code_filter[:fasp_rating]
39
37
  end
40
38
 
41
- def existance_filter
42
- { Canql::EQUALS => existance_modifier.text_value.strip != 'no' }
39
+ def existence_filter
40
+ { Canql::EQUALS => existence_modifier.text_value.strip != 'no' }
43
41
  end
44
42
 
45
43
  def anomaly_type_filter
@@ -73,28 +71,20 @@ module Canql #:nodoc: all
73
71
  clean_code_array(code_array)
74
72
 
75
73
  code_filters = {}
76
- if code_array[:icd_code].any?
77
- code_filters[:icd_code] = { Canql::BEGINS => code_array[:icd_code] }
78
- end
79
-
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
74
+ code_filters[:icd_code] = { Canql::BEGINS => code_array[:icd_code] } if code_array[:icd_code].any?
75
+ code_filters[:code_group] = { Canql::EQUALS => code_array[:code_group] } if code_array[:code_group].any?
76
+ code_filters[:fasp_rating] = { Canql::EQUALS => code_array[:fasp_rating] } if code_array[:fasp_rating].any?
87
77
 
88
78
  code_filters
89
79
  end
90
80
 
91
81
  def clean_code_array(code_array)
92
82
  code_array[:icd_code].flatten!
93
- code_array[:icd_code].delete_if(&:blank?)
83
+ code_array[:icd_code].compact_blank!
94
84
  code_array[:code_group].flatten!
95
- code_array[:code_group].delete_if(&:blank?)
85
+ code_array[:code_group].compact_blank!
96
86
  code_array[:fasp_rating].flatten!
97
- code_array[:fasp_rating].delete_if(&:blank?)
87
+ code_array[:fasp_rating].compact_blank!
98
88
  end
99
89
 
100
90
  def code_filter
@@ -3,7 +3,7 @@
3
3
  require 'chronic'
4
4
  require 'ndr_support/daterange'
5
5
 
6
- module Canql #:nodoc: all
6
+ module Canql # :nodoc: all
7
7
  module Nodes
8
8
  module FuzzyDateNode
9
9
  delegate :to_daterange, to: :date
@@ -25,12 +25,12 @@ module Canql #:nodoc: all
25
25
  module YearQuarterNode
26
26
  def to_daterange
27
27
  quarter = text_value[0..1]
28
- year = text_value[3..-1]
28
+ year = text_value[3..]
29
29
  quarters = {
30
- 'q1': "01-04-#{year}",
31
- 'q2': "01-07-#{year}",
32
- 'q3': "01-10-#{year}",
33
- 'q4': "01-01-#{year.to_i + 1}"
30
+ q1: "01-04-#{year}",
31
+ q2: "01-07-#{year}",
32
+ q3: "01-10-#{year}",
33
+ q4: "01-01-#{year.to_i + 1}"
34
34
  }
35
35
  Daterange.new(quarters[quarter.to_sym].to_date,
36
36
  quarters[quarter.to_sym].to_date + 3.months - 1.day)
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Canql #:nodoc: all
3
+ module Canql # :nodoc: all
4
4
  module Nodes
5
5
  module EBaseRecordsNode
6
6
  def meta_data_item
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Canql # :nodoc: all
4
+ module Nodes
5
+ module Events
6
+ module WithCondition
7
+ def to_events
8
+ event_type = text_values_for_marker(:event_type).first.strip
9
+ event_relevance = text_values_for_marker(:event_relevance).first.to_s.strip
10
+ hash = existence_filter
11
+ hash['type'] = event_type_name[event_type]
12
+ hash['relevant'] = event_relevance_flag(event_relevance) || false
13
+
14
+ hash
15
+ end
16
+
17
+ def event_type_name
18
+ {
19
+ 'birth' => 'birth',
20
+ 'death' => 'death',
21
+ 'hes' => 'hes',
22
+ 'preg loss hes' => 'pregnancy_loss_hes',
23
+ 'pregnancy loss hes' => 'pregnancy_loss_hes',
24
+ 'preg loss bpas' => 'pregnancy_loss_bpas',
25
+ 'pregnancy loss bpas' => 'pregnancy_loss_bpas',
26
+ 'msds' => 'msds'
27
+ }
28
+ end
29
+
30
+ def event_relevance_flag(relevance)
31
+ %w[linked relevant related].include?(relevance)
32
+ end
33
+
34
+ def existence_filter
35
+ { Canql::EQUALS => existence_modifier.text_value.strip != 'no' }
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,16 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Canql #:nodoc: all
3
+ module Canql # :nodoc: all
4
4
  module Nodes
5
5
  module GeneticTest
6
6
  module WithCondition
7
7
  def to_genetic_test
8
- genetic_test_hash = { 'exists' => existance_filter }
9
- genetic_test_hash
8
+ { 'exists' => existence_filter }
10
9
  end
11
10
 
12
- def existance_filter
13
- { Canql::EQUALS => existance_modifier.text_value.strip != 'no' }
11
+ def existence_filter
12
+ { Canql::EQUALS => existence_modifier.text_value.strip != 'no' }
14
13
  end
15
14
  end
16
15
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  # require 'active_support/core_ext/object/blank'
4
4
 
5
- module Canql #:nodoc: all
5
+ module Canql # :nodoc: all
6
6
  module Nodes
7
7
  module RecordCountNode
8
8
  def meta_data_item
@@ -12,7 +12,7 @@ module Canql #:nodoc: all
12
12
  end
13
13
  end
14
14
 
15
- module Canql #:nodoc: all
15
+ module Canql # :nodoc: all
16
16
  module Nodes
17
17
  # Returns a filter detailing the require result type (cases or patients)
18
18
  module SubjectNode
@@ -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 hes_events
35
+ anomalies genetic_tests test_results test_result_groups test_acceptances 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,7 +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
+ add_sub_clause(sub_clauses, element, :events, :to_events)
56
56
  end
57
57
  sub_clauses
58
58
  end
@@ -55,6 +55,7 @@ module Canql # :nodoc: all
55
55
  'booking hospital': { patient: 'booking_hospital' },
56
56
  'screening status': { patient: 'screeningstatus' },
57
57
  'number of fetuses at delivery': { patient: 'numoffetusesatdelivery' },
58
+ 'number of fetuses in early pregnancy': { patient: 'numberoffetuses' },
58
59
  'malformed in set': { patient: 'malformedinset' },
59
60
  'gestation at delivery': { patient: 'gestationallength' },
60
61
  'booking date': { patient: 'firstbookingdate' }
@@ -65,9 +66,9 @@ module Canql # :nodoc: all
65
66
  field_names = actual_field_names(
66
67
  patient_field_list.text_values_for_marker(:patient_field_name), subject.to_sym
67
68
  )
68
- modifer = field_existance_modifier.text_value.strip
69
- existance = modifer == 'missing' ? 'fields_missing' : 'fields_populated'
70
- { "#{subject}.#{existance}" => { Canql::EQUALS => field_names } }
69
+ modifier = field_existence_modifier.text_value.strip
70
+ existence = modifier == 'missing' ? 'fields_missing' : 'fields_populated'
71
+ { "#{subject}.#{existence}" => { Canql::EQUALS => field_names } }
71
72
  end
72
73
 
73
74
  def actual_field_names(fields, subject)
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Canql # :nodoc: all
4
+ module Nodes
5
+ module PatientEvents
6
+ module WithCondition
7
+ def to_events
8
+ event_name = event_type_name
9
+ { "#{event_name}_event" => existence_filter }
10
+ end
11
+
12
+ def maternal_relevant_event_types
13
+ %w[pregnancy_loss_hes pregnancy_loss_bpas msds]
14
+ end
15
+
16
+ def event_type_name
17
+ map = {
18
+ 'birth' => 'birth',
19
+ 'death' => 'death',
20
+ 'hes' => 'hes',
21
+ 'preg loss hes' => 'pregnancy_loss_hes',
22
+ 'pregnancy loss hes' => 'pregnancy_loss_hes',
23
+ 'preg loss bpas' => 'pregnancy_loss_bpas',
24
+ 'pregnancy loss bpas' => 'pregnancy_loss_bpas',
25
+ 'msds' => 'msds'
26
+ }
27
+ map[event_type.text_value.strip]
28
+ end
29
+
30
+ def existence_filter
31
+ { Canql::EQUALS => existence_modifier.text_value.strip != 'no' }
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Canql #:nodoc: all
3
+ module Canql # :nodoc: all
4
4
  module Nodes
5
5
  module PerinatalProviderCodeNode
6
6
  def meta_data_item
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Canql #:nodoc: all
3
+ module Canql # :nodoc: all
4
4
  module Nodes
5
5
  module RegistryNode
6
6
  def meta_data_item
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Canql #:nodoc: all
3
+ module Canql # :nodoc: all
4
4
  module Nodes
5
5
  module TestResult
6
6
  module WithCondition
@@ -9,13 +9,13 @@ module Canql #:nodoc: all
9
9
  end
10
10
 
11
11
  def to_test_result
12
- test_result_hash = { 'exists' => existance_filter }
12
+ test_result_hash = { 'exists' => existence_filter }
13
13
  test_result_hash['type'] = test_result_type_filter if test_result_type.present?
14
14
  test_result_hash
15
15
  end
16
16
 
17
- def existance_filter
18
- { Canql::EQUALS => existance_modifier.text_value.strip != 'no' }
17
+ def existence_filter
18
+ { Canql::EQUALS => existence_modifier.text_value.strip != 'no' }
19
19
  end
20
20
 
21
21
  def test_result_type_filter
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module Canql #:nodoc: all
3
+ module Canql # :nodoc: all
4
4
  module Nodes
5
5
  module TestResultGroup
6
6
  module WithCondition
@@ -9,16 +9,16 @@ module Canql #:nodoc: all
9
9
  end
10
10
 
11
11
  def to_test_result_group
12
- test_result_group_hash = { 'exists' => existance_filter }
12
+ test_result_group_hash = { 'exists' => existence_filter }
13
13
  test_result_group_hash['required'] = requirement_filter
14
14
  test_result_group_hash['group'] = test_result_group_filter if test_result_group.present?
15
15
  test_result_group_hash
16
16
  end
17
17
 
18
- def existance_filter
18
+ def existence_filter
19
19
  {
20
20
  Canql::EQUALS => ['supplied required', 'supplied'].include?(
21
- existance_modifier.text_value.strip
21
+ existence_modifier.text_value.strip
22
22
  )
23
23
  }
24
24
  end
@@ -26,7 +26,7 @@ module Canql #:nodoc: all
26
26
  def requirement_filter
27
27
  {
28
28
  Canql::EQUALS => ['supplied required', 'missing required'].include?(
29
- existance_modifier.text_value.strip
29
+ existence_modifier.text_value.strip
30
30
  )
31
31
  }
32
32
  end
@@ -37,23 +37,23 @@ module Canql #:nodoc: all
37
37
  end
38
38
  end
39
39
 
40
- module TestAcceptanceExistamce
40
+ module TestAcceptanceExistence
41
41
  module WithCondition
42
42
  def test_acceptance
43
43
  acceptance.text_value.strip.parameterize.underscore
44
44
  end
45
45
 
46
46
  def to_test_acceptance
47
- test_acceptance_hash = { 'exists' => existance_filter }
47
+ test_acceptance_hash = { 'exists' => existence_filter }
48
48
  test_acceptance_hash['required'] = requirement_filter
49
49
  test_acceptance_hash['acceptance'] = test_acceptance_filter if test_acceptance.present?
50
50
  test_acceptance_hash
51
51
  end
52
52
 
53
- def existance_filter
53
+ def existence_filter
54
54
  {
55
55
  Canql::EQUALS => ['supplied required', 'supplied'].include?(
56
- existance_modifier.text_value.strip
56
+ existence_modifier.text_value.strip
57
57
  )
58
58
  }
59
59
  end
@@ -61,7 +61,7 @@ module Canql #:nodoc: all
61
61
  def requirement_filter
62
62
  {
63
63
  Canql::EQUALS => ['supplied required', 'missing required'].include?(
64
- existance_modifier.text_value.strip
64
+ existence_modifier.text_value.strip
65
65
  )
66
66
  }
67
67
  end
data/lib/canql/nodes.rb CHANGED
@@ -22,4 +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'
25
+ require 'canql/nodes/events'
@@ -26,7 +26,8 @@ module Treetop
26
26
 
27
27
  def reverse_scan_for_marker(marker)
28
28
  marker_value = reverse_marker_scanner(self, marker)
29
- return if marker_value.nil? || marker_value.empty?
29
+ return if marker_value.blank?
30
+
30
31
  marker_value
31
32
  end
32
33
 
@@ -34,6 +35,7 @@ module Treetop
34
35
 
35
36
  def text_values_for_marker_scanner(root, marker, list)
36
37
  return if root.elements.nil?
38
+
37
39
  root.elements.each do |e|
38
40
  list << e.send(marker).text_value if e.respond_to?(marker)
39
41
  text_values_for_marker_scanner(e, marker, list)
@@ -43,10 +45,9 @@ module Treetop
43
45
 
44
46
  def reverse_marker_scanner(root, marker)
45
47
  return if root.nil? || root.elements.nil?
48
+
46
49
  marker_value = root.send(marker).text_value if root.respond_to?(marker)
47
- if marker_value.nil? || marker_value.empty?
48
- marker_value = reverse_marker_scanner(root.parent, marker)
49
- end
50
+ marker_value = reverse_marker_scanner(root.parent, marker) if marker_value.blank?
50
51
  marker_value
51
52
  end
52
53
  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.9.0'
5
+ VERSION = '6.0.1'
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.9.0
4
+ version: 6.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - NHSD NDRS Development Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-17 00:00:00.000000000 Z
11
+ date: 2024-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronic
@@ -78,138 +78,6 @@ dependencies:
78
78
  - - ">="
79
79
  - !ruby/object:Gem::Version
80
80
  version: 1.4.10
81
- - !ruby/object:Gem::Dependency
82
- name: bundler
83
- requirement: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :development
89
- prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- version: '0'
95
- - !ruby/object:Gem::Dependency
96
- name: guard
97
- requirement: !ruby/object:Gem::Requirement
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: '0'
102
- type: :development
103
- prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- version: '0'
109
- - !ruby/object:Gem::Dependency
110
- name: guard-minitest
111
- requirement: !ruby/object:Gem::Requirement
112
- requirements:
113
- - - ">="
114
- - !ruby/object:Gem::Version
115
- version: '0'
116
- type: :development
117
- prerelease: false
118
- version_requirements: !ruby/object:Gem::Requirement
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- version: '0'
123
- - !ruby/object:Gem::Dependency
124
- name: guard-rubocop
125
- requirement: !ruby/object:Gem::Requirement
126
- requirements:
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- version: '0'
130
- type: :development
131
- prerelease: false
132
- version_requirements: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - ">="
135
- - !ruby/object:Gem::Version
136
- version: '0'
137
- - !ruby/object:Gem::Dependency
138
- name: minitest
139
- requirement: !ruby/object:Gem::Requirement
140
- requirements:
141
- - - ">="
142
- - !ruby/object:Gem::Version
143
- version: 5.0.0
144
- type: :development
145
- prerelease: false
146
- version_requirements: !ruby/object:Gem::Requirement
147
- requirements:
148
- - - ">="
149
- - !ruby/object:Gem::Version
150
- version: 5.0.0
151
- - !ruby/object:Gem::Dependency
152
- name: ndr_dev_support
153
- requirement: !ruby/object:Gem::Requirement
154
- requirements:
155
- - - ">="
156
- - !ruby/object:Gem::Version
157
- version: '6.0'
158
- - - "<"
159
- - !ruby/object:Gem::Version
160
- version: '8.0'
161
- type: :development
162
- prerelease: false
163
- version_requirements: !ruby/object:Gem::Requirement
164
- requirements:
165
- - - ">="
166
- - !ruby/object:Gem::Version
167
- version: '6.0'
168
- - - "<"
169
- - !ruby/object:Gem::Version
170
- version: '8.0'
171
- - !ruby/object:Gem::Dependency
172
- name: pry
173
- requirement: !ruby/object:Gem::Requirement
174
- requirements:
175
- - - ">="
176
- - !ruby/object:Gem::Version
177
- version: '0'
178
- type: :development
179
- prerelease: false
180
- version_requirements: !ruby/object:Gem::Requirement
181
- requirements:
182
- - - ">="
183
- - !ruby/object:Gem::Version
184
- version: '0'
185
- - !ruby/object:Gem::Dependency
186
- name: rake
187
- requirement: !ruby/object:Gem::Requirement
188
- requirements:
189
- - - ">="
190
- - !ruby/object:Gem::Version
191
- version: '0'
192
- type: :development
193
- prerelease: false
194
- version_requirements: !ruby/object:Gem::Requirement
195
- requirements:
196
- - - ">="
197
- - !ruby/object:Gem::Version
198
- version: '0'
199
- - !ruby/object:Gem::Dependency
200
- name: terminal-notifier-guard
201
- requirement: !ruby/object:Gem::Requirement
202
- requirements:
203
- - - ">="
204
- - !ruby/object:Gem::Version
205
- version: '0'
206
- type: :development
207
- prerelease: false
208
- version_requirements: !ruby/object:Gem::Requirement
209
- requirements:
210
- - - ">="
211
- - !ruby/object:Gem::Version
212
- version: '0'
213
81
  description: Domain Specific Language for querying NHS NCARDRS datastores
214
82
  email: []
215
83
  executables: []
@@ -229,8 +97,8 @@ files:
229
97
  - lib/canql/grammars/batch_types.treetop
230
98
  - lib/canql/grammars/dates.treetop
231
99
  - lib/canql/grammars/e_base_records.treetop
100
+ - lib/canql/grammars/events.treetop
232
101
  - lib/canql/grammars/genetic_test.treetop
233
- - lib/canql/grammars/hes_event.treetop
234
102
  - lib/canql/grammars/main.treetop
235
103
  - lib/canql/grammars/patient.treetop
236
104
  - lib/canql/grammars/perinatal_hospital.treetop
@@ -244,10 +112,11 @@ files:
244
112
  - lib/canql/nodes/batch_types.rb
245
113
  - lib/canql/nodes/dates.rb
246
114
  - lib/canql/nodes/e_base_records.rb
115
+ - lib/canql/nodes/events.rb
247
116
  - lib/canql/nodes/genetic_test.rb
248
- - lib/canql/nodes/hes_event.rb
249
117
  - lib/canql/nodes/main.rb
250
118
  - lib/canql/nodes/patient.rb
119
+ - lib/canql/nodes/patient_events.rb
251
120
  - lib/canql/nodes/perinatal_hospital.rb
252
121
  - lib/canql/nodes/registry.rb
253
122
  - lib/canql/nodes/test_result.rb
@@ -274,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
274
143
  - !ruby/object:Gem::Version
275
144
  version: '0'
276
145
  requirements: []
277
- rubygems_version: 3.2.33
146
+ rubygems_version: 3.4.10
278
147
  signing_key:
279
148
  specification_version: 4
280
149
  summary: Congenital Anomaly Natural Query Language
@@ -1,15 +0,0 @@
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
@@ -1,17 +0,0 @@
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