canql 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fcf2d37654027295939edf58f998fcc355b899da
4
+ data.tar.gz: 5f13b67d937e9e5f7517f06a7cd7d296d82e87df
5
+ SHA512:
6
+ metadata.gz: d8adc584f9bc0c2a66c80217875d838591b38838e2a9a1ef1da96b42445877db37f4b3a829f2b67601e1a3d6d616592738d62844a1b2f9e91ff6b29e714bb6ae
7
+ data.tar.gz: 0d591c714d021a59182f9fbd129734fd59e07496c9bfeb24f586614f894ae9ce655fbb5559294e3d75ab83a9bcc6b971a299f77c340fe1f37bbf7cb5c4986255
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .rubocop-https---raw-githubusercontent-com-PublicHealthEngland-ndr-dev-support-master--rubocop-yml
data/.hound.yml ADDED
@@ -0,0 +1,10 @@
1
+ fail_on_violations: true
2
+
3
+ coffeescript:
4
+ enabled: false
5
+ javascript:
6
+ enabled: false
7
+ ruby:
8
+ config_file: .rubocop.yml
9
+ scss:
10
+ enabled: false
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ inherit_from: 'https://raw.githubusercontent.com/PublicHealthEngland/ndr_dev_support/master/.rubocop.yml'
2
+
3
+ Rails:
4
+ Enabled: false
5
+
6
+ AllCops:
7
+ TargetRubyVersion: 2.3
8
+
9
+ Style/FrozenStringLiteralComment:
10
+ Enabled: true
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+
3
+ rvm:
4
+ - 2.2.5
5
+ - 2.3.1
6
+
7
+ sudo: false
8
+
9
+ cache: bundler
10
+
11
+ before_script: "bundle update"
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ source 'https://rubygems.org'
3
+
4
+ # Specify your gem's dependencies in canql.gemspec
5
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Public Health England
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # CANQL [![Build Status](https://travis-ci.org/PublicHealthEngland/canql.svg?branch=master)](https://travis-ci.org/PublicHealthEngland/canql)
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.
4
+
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
+
7
+ CANQL is decoupled from the specifics of the NCARDRS systems by producing an intermediate representation, known as Disease Intermediate Representation (DIR). This allows us to:
8
+
9
+ 1. implement separate DIR adapters for different datastores (e.g. SQL and NoSQL datastores);
10
+ 2. utilize the same DIR adapters for different but over-lapping DSLs, including Tumour Natural Query Language ([TNQL](https://github.com/PublicHealthEngland/tnql)) ; and
11
+ 3. pass DIR queries to non-ruby backend systems using any simple format like JSON.
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'canql'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install canql
28
+
29
+ ## Usage
30
+
31
+ Here is a simple example showing a CANQL query of all male cases in south west registration region:
32
+
33
+ ```ruby
34
+ require 'canql'
35
+ require 'json'
36
+
37
+ query = 'All Male South West Cases'
38
+ parser = Canql::Parser.new(query)
39
+
40
+ if parser.valid?
41
+ puts JSON.dump(parser.meta_data)
42
+ end
43
+ ```
44
+
45
+ would output:
46
+
47
+ ```json
48
+ {"patient.sex":{"equals":"1"},"patient.registry":{"equals":"84"}}
49
+ ```
50
+
51
+ The parser is case insensitive. An example of an almost fully involved CANQL query is:
52
+
53
+ > First 27 Male Liveborn Thames Cases Due between 20/06/2015 and 25/06/2015 and Born on 22/06/2015 and that Died on 07/07/2015 with Prenatal Anomalies and Postnatal Tests and Missing Postcode and Date of Birth and Wait 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
54
+
55
+ Please see the tests for many more examples.
56
+
57
+ ## Development
58
+
59
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
60
+
61
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
62
+
63
+ ## Contributing
64
+
65
+ 1. Fork it ( https://github.com/PublicHealthEngland/canql/fork )
66
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
67
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
68
+ 4. Push to the branch (`git push origin my-new-feature`)
69
+ 5. Create a new Pull Request
70
+
71
+ This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
76
+
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/testtask'
4
+ require 'ndr_dev_support/tasks'
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << 'test'
8
+ t.test_files = FileList['test/**/*_test.rb']
9
+ t.verbose = false
10
+ t.warning = false
11
+ end
12
+
13
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'bundler/setup'
5
+ require 'canql'
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ require 'pry'
11
+ Pry.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/canql.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+ # coding: utf-8
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'canql/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'canql'
9
+ spec.version = Canql::VERSION
10
+ spec.authors = ['PHE NDR Development Team']
11
+ spec.email = []
12
+
13
+ spec.summary = 'Congenital Anomaly Natural Query Language'
14
+ spec.description = 'Domain Specific Language for querying PHE NCARDRS datastores'
15
+ spec.homepage = 'https://github.com/PublicHealthEngland/canql'
16
+ spec.license = 'MIT'
17
+
18
+ spec.required_ruby_version = '>= 2.2'
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").
21
+ reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ spec.bindir = 'exe'
23
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24
+ spec.require_paths = ['lib']
25
+
26
+ spec.add_dependency 'ndr_support', '>= 3.0', '< 6'
27
+ spec.add_dependency 'treetop', '>= 1.4.10'
28
+ spec.add_dependency 'chronic', '~> 0.3.0'
29
+
30
+ spec.add_development_dependency 'ndr_dev_support', '~> 2.0', '>= 2.0.2'
31
+ spec.add_development_dependency 'bundler'
32
+ spec.add_development_dependency 'rake'
33
+ spec.add_development_dependency 'minitest'
34
+ spec.add_development_dependency 'pry'
35
+ spec.add_development_dependency 'guard'
36
+ spec.add_development_dependency 'guard-rubocop'
37
+ spec.add_development_dependency 'guard-minitest'
38
+ spec.add_development_dependency 'terminal-notifier-guard' if RUBY_PLATFORM =~ /darwin/
39
+ end
data/code_safety.yml ADDED
@@ -0,0 +1,201 @@
1
+ ---
2
+ file safety:
3
+ ".gitignore":
4
+ comments:
5
+ reviewed_by: timgentry
6
+ safe_revision: cbb48a04cbac04a6dce845110928f69492e152a1
7
+ ".hound.yml":
8
+ comments:
9
+ reviewed_by: timgentry
10
+ safe_revision: 0b34688f1198eace9310f47060aa8915f5b44985
11
+ ".rubocop.yml":
12
+ comments:
13
+ reviewed_by: timgentry
14
+ safe_revision: 618d1e7fa4793df5bff0bdb763ff90dd5ea63236
15
+ ".travis.yml":
16
+ comments:
17
+ reviewed_by: timgentry
18
+ safe_revision: 5c88b8eec43f7e7fd18fae6ac952ea6c2efddbbc
19
+ CODE_OF_CONDUCT.md:
20
+ comments:
21
+ reviewed_by: drewthorp
22
+ safe_revision: 6a666fcabe027056b1c774b2eabb3fdf686911d2
23
+ Gemfile:
24
+ comments:
25
+ reviewed_by: timgentry
26
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
27
+ LICENSE.txt:
28
+ comments:
29
+ reviewed_by: timgentry
30
+ safe_revision: ee80c4bbd5e990d38b5fc954f4fd037177672db2
31
+ README.md:
32
+ comments:
33
+ reviewed_by: timgentry
34
+ safe_revision: cb1bd5162935d259f67a42044cbe5644fe6a76f8
35
+ Rakefile:
36
+ comments:
37
+ reviewed_by: timgentry
38
+ safe_revision: 16a9dac62316fbc2ef953457732bc7d9b2f67111
39
+ bin/console:
40
+ comments:
41
+ reviewed_by: timgentry
42
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
43
+ bin/setup:
44
+ comments:
45
+ reviewed_by: timgentry
46
+ safe_revision: 6a666fcabe027056b1c774b2eabb3fdf686911d2
47
+ canql.gemspec:
48
+ comments:
49
+ reviewed_by: timgentry
50
+ safe_revision: b67d28ae2648219607e40dc77d6aef846a64f647
51
+ lib/canql.rb:
52
+ comments:
53
+ reviewed_by: timgentry
54
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
55
+ lib/canql/constants.rb:
56
+ comments:
57
+ reviewed_by: timgentry
58
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
59
+ lib/canql/grammars.rb:
60
+ comments:
61
+ reviewed_by: timgentry
62
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
63
+ lib/canql/grammars/age.treetop:
64
+ comments: It is a known issue that this is potentially susceptible to certain
65
+ kinds of DoS attack
66
+ reviewed_by: timgentry
67
+ safe_revision: b152e94eb4e1ae6064204c95dbb56ad1200b576b
68
+ lib/canql/grammars/anomaly.treetop:
69
+ comments: It is a known issue that this is potentially susceptible to certain
70
+ kinds of DoS attack
71
+ reviewed_by: timgentry
72
+ safe_revision: a7b0ddabf0c3f7d8b129b4cd206b6e1d65781a10
73
+ lib/canql/grammars/batch_types.treetop:
74
+ comments:
75
+ reviewed_by: timgentry
76
+ safe_revision: 41d8f146c456e7bf252784476438574a9d283408
77
+ lib/canql/grammars/dates.treetop:
78
+ comments: It is a known issue that this is potentially susceptible to certain
79
+ kinds of DoS attack
80
+ reviewed_by: timgentry
81
+ safe_revision: 2346abb4435bf95cbe9b4d8c124123b9fefe60d6
82
+ lib/canql/grammars/e_base_records.treetop:
83
+ comments:
84
+ reviewed_by: timgentry
85
+ safe_revision: 41d8f146c456e7bf252784476438574a9d283408
86
+ lib/canql/grammars/main.treetop:
87
+ comments: It is a known issue that this is potentially susceptible to certain
88
+ kinds of DoS attack
89
+ reviewed_by: timgentry
90
+ safe_revision: 67be9ba603f1f1d1bd73c696fc1d814b4138ba5f
91
+ lib/canql/grammars/patient.treetop:
92
+ comments: It is a known issue that this is potentially susceptible to certain
93
+ kinds of DoS attack
94
+ reviewed_by: timgentry
95
+ safe_revision: 0bf684b681372d16145cae8c6bb831f1bb96f442
96
+ lib/canql/grammars/registry.treetop:
97
+ comments: It is a known issue that this is potentially susceptible to certain
98
+ kinds of DoS attack
99
+ reviewed_by: timgentry
100
+ safe_revision: c095990308c4a90316964cbe0d9bc8f4747ca8cc
101
+ lib/canql/grammars/test_result.treetop:
102
+ comments: It is a known issue that this is potentially susceptible to certain
103
+ kinds of DoS attack
104
+ reviewed_by: timgentry
105
+ safe_revision: a7b0ddabf0c3f7d8b129b4cd206b6e1d65781a10
106
+ lib/canql/nodes.rb:
107
+ comments:
108
+ reviewed_by: timgentry
109
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
110
+ lib/canql/nodes/age.rb:
111
+ comments:
112
+ reviewed_by: timgentry
113
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
114
+ lib/canql/nodes/anomaly.rb:
115
+ comments:
116
+ reviewed_by: timgentry
117
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
118
+ lib/canql/nodes/batch_types.rb:
119
+ comments:
120
+ reviewed_by: timgentry
121
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
122
+ lib/canql/nodes/dates.rb:
123
+ comments:
124
+ reviewed_by: timgentry
125
+ safe_revision: 2346abb4435bf95cbe9b4d8c124123b9fefe60d6
126
+ lib/canql/nodes/e_base_records.rb:
127
+ comments:
128
+ reviewed_by: timgentry
129
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
130
+ lib/canql/nodes/main.rb:
131
+ comments:
132
+ reviewed_by: timgentry
133
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
134
+ lib/canql/nodes/patient.rb:
135
+ comments:
136
+ reviewed_by: timgentry
137
+ safe_revision: 0bf684b681372d16145cae8c6bb831f1bb96f442
138
+ lib/canql/nodes/registry.rb:
139
+ comments:
140
+ reviewed_by: timgentry
141
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
142
+ lib/canql/nodes/test_result.rb:
143
+ comments:
144
+ reviewed_by: timgentry
145
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
146
+ lib/canql/parser.rb:
147
+ comments:
148
+ reviewed_by: timgentry
149
+ safe_revision: a923656606f581c220ea7af16196f2c68b5248f2
150
+ lib/canql/treetop/extensions.rb:
151
+ comments:
152
+ reviewed_by: timgentry
153
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
154
+ lib/canql/version.rb:
155
+ comments:
156
+ reviewed_by: timgentry
157
+ safe_revision: b67d28ae2648219607e40dc77d6aef846a64f647
158
+ test/canql_test.rb:
159
+ comments:
160
+ reviewed_by: timgentry
161
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
162
+ test/minitest_helper.rb:
163
+ comments:
164
+ reviewed_by: timgentry
165
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
166
+ test/nodes/age_test.rb:
167
+ comments:
168
+ reviewed_by: timgentry
169
+ safe_revision: 2346abb4435bf95cbe9b4d8c124123b9fefe60d6
170
+ test/nodes/anomaly_test.rb:
171
+ comments:
172
+ reviewed_by: timgentry
173
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
174
+ test/nodes/e_base_rescords_test.rb:
175
+ comments:
176
+ reviewed_by: timgentry
177
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
178
+ test/nodes/main_test.rb:
179
+ comments:
180
+ reviewed_by: timgentry
181
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
182
+ test/nodes/patient_test.rb:
183
+ comments:
184
+ reviewed_by: timgentry
185
+ safe_revision: 0bf684b681372d16145cae8c6bb831f1bb96f442
186
+ test/nodes/registry_test.rb:
187
+ comments:
188
+ reviewed_by: timgentry
189
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
190
+ test/nodes/test_results_test.rb:
191
+ comments:
192
+ reviewed_by: timgentry
193
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a
194
+ test/parser_test.rb:
195
+ comments:
196
+ reviewed_by: timgentry
197
+ safe_revision: a923656606f581c220ea7af16196f2c68b5248f2
198
+ test/test_helper.rb:
199
+ comments:
200
+ reviewed_by: timgentry
201
+ safe_revision: d6f1ccac606735190d30c962b7681ed12aec374a