cqm-validators 0.1.1 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/PULL_REQUEST_TEMPLATE.md +23 -0
  3. data/.gitignore +3 -1
  4. data/.overcommit.yml +18 -0
  5. data/.rubocop.yml +74 -0
  6. data/.simplecov +12 -0
  7. data/.travis.yml +20 -0
  8. data/Gemfile +11 -3
  9. data/README.md +23 -6
  10. data/Rakefile +8 -6
  11. data/config/mongoid.yml +6 -0
  12. data/cqm_validators.gemspec +23 -14
  13. data/lib/base_validator.rb +20 -20
  14. data/lib/cqm_validators.rb +4 -2
  15. data/lib/cqm_validators/version.rb +3 -1
  16. data/lib/data_validator.rb +74 -79
  17. data/lib/measure_validator.rb +104 -107
  18. data/lib/performance_rate_validator.rb +43 -63
  19. data/lib/qrda_qdm_template_validator.rb +164 -311
  20. data/lib/reported_result_extractor.rb +137 -139
  21. data/lib/schema_validator.rb +20 -19
  22. data/lib/schematron/c_processor.rb +19 -19
  23. data/lib/schematron/java_processor.rb +66 -68
  24. data/lib/schematron/qrda/{cat_1_r4/HL7 QRDA Category I STU 4.sch → cat_1_r5_1/HL7 QRDA Category I STU 5.1.sch } +1559 -1964
  25. data/lib/schematron/qrda/{cat_1_r4 → cat_1_r5_1}/voc.xml +7 -2
  26. data/lib/schematron/qrda/cat_1_r5_2/HL7 QRDA Category I STU 5.2.sch +3961 -0
  27. data/lib/schematron/qrda/{cat_3_r2 → cat_1_r5_2}/voc.xml +7 -2
  28. data/lib/schematron_validator.rb +31 -32
  29. data/lib/validation_error.rb +11 -9
  30. data/lib/validators.rb +48 -105
  31. data/notice.md +9 -0
  32. metadata +99 -36
  33. data/lib/schematron/qrda/cat_1/HL7_CDAR2_QRDA_Category_I_2_12_16.sch +0 -4693
  34. data/lib/schematron/qrda/cat_1/voc.xml +0 -1177
  35. data/lib/schematron/qrda/cat_1_r2/QRDA Category I Release 2.sch +0 -4069
  36. data/lib/schematron/qrda/cat_1_r2/voc.xml +0 -1065
  37. data/lib/schematron/qrda/cat_1_r3_1/HL7 QRDA Category I STU 3.1.sch +0 -3573
  38. data/lib/schematron/qrda/cat_1_r3_1/HL7 QRDA Category III STU 1.1.sch +0 -464
  39. data/lib/schematron/qrda/cat_1_r3_1/QRDA Category I STU Release 3.1.sch +0 -5394
  40. data/lib/schematron/qrda/cat_1_r3_1/voc.xml +0 -1229
  41. data/lib/schematron/qrda/cat_3/QRDA Category III.sch +0 -675
  42. data/lib/schematron/qrda/cat_3/voc.xml +0 -21
  43. data/lib/schematron/qrda/cat_3_r1_1/HL7 QRDA Category III STU 1.1.sch +0 -528
  44. data/lib/schematron/qrda/cat_3_r1_1/voc.xml +0 -8
  45. data/lib/schematron/qrda/cat_3_r2/HL7 QRDA Category III STU 2.sch +0 -677
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc74cabec43d438d636823c7eec265a7263145a32c4df0143e428919c41800c3
4
- data.tar.gz: 337fd6b7fa1c87a145fcb7d47e697e1778f8da43bc3ccad499bd6a535e4d1ed5
3
+ metadata.gz: ee2392d581780f96f7b1b57b2e39bb007d8d450f69f0f903b8c0b18bac2fad9d
4
+ data.tar.gz: ad2ef24b759d799e4c6fe49cb6438a4aec9c4af8f002ec67d136b97357e1eabf
5
5
  SHA512:
6
- metadata.gz: ad9fe931e4f105f29120564a5438f4b47771bd5d01afa6509dcef88f140d52f7152a840b2158bbbb9b369f63be571e37b7679c3a3b961131993d41cbdcc5e068
7
- data.tar.gz: 9b9624e81a2f06b68db52364c4c3b1ac12e170934a88c7c353219007403221254ab5fd1f6173e8639e8e90a54146329baf5cabb1c6ec4eb9d17c1408e3d67616
6
+ metadata.gz: 2f57e881a5825ce58d928f46559c42279faec7b41ba7f1dade50ece69ee72a50443be5b59aef15683aee670809712dc832afe66c6b81c7988fba59783239f84f
7
+ data.tar.gz: ad889cec773305338b0d4d268f1b4fd5fc33abe3edb81636c3013eac715eab7fbc88ddc899bac42dd3fae08eecf4b5e4742e2921e43640f39ff37215be923e4a
@@ -0,0 +1,23 @@
1
+ Pull requests into cqm-validators require the following. Submitter and reviewer should :white_check_mark: when done. For items that are not-applicable, note it's not-applicable ("N/A") and :white_check_mark:.
2
+
3
+ **Submitter:**
4
+ - [ ] This pull request describes why these changes were made.
5
+ - [ ] Internal ticket for this PR:
6
+ - [ ] Internal ticket links to this PR
7
+ - [ ] Code diff has been done and been reviewed
8
+ - [ ] Tests are included and test edge cases
9
+ - [ ] Tests have been run locally and pass
10
+
11
+ **Reviewer 1:**
12
+
13
+ Name:
14
+ - [ ] Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose
15
+ - [ ] The tests appropriately test the new code, including edge cases
16
+ - [ ] You have tried to break the code
17
+
18
+ **Reviewer 2:**
19
+
20
+ Name:
21
+ - [ ] Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose
22
+ - [ ] The tests appropriately test the new code, including edge cases
23
+ - [ ] You have tried to break the code
data/.gitignore CHANGED
@@ -4,4 +4,6 @@ test/xsd
4
4
  tmp
5
5
  .DS_Store
6
6
  .idea
7
- .rvmrc
7
+ .rvmrc
8
+ Gemfile.lock
9
+ .byebug_history
@@ -0,0 +1,18 @@
1
+ PreCommit:
2
+ RuboCop:
3
+ enabled: true
4
+ on_warn: 'fail'
5
+ HardTabs:
6
+ enabled: true
7
+ exclude: ['test/fixtures/**/*', 'lib/schema/**/*', 'lib/schematron/iso-schematron-xslt1/**/*', 'lib/schematron/iso-schematron-xslt2/**/*', 'lib/schematron/qrda/**/*']
8
+ AuthorName:
9
+ enabled: false
10
+ CommitMsg:
11
+ RussianNovel:
12
+ enabled: true
13
+ HardTabs:
14
+ enabled: true
15
+ TextWidth:
16
+ enabled: false
17
+ CapitalizedSubject:
18
+ enabled: false
@@ -0,0 +1,74 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+ Exclude:
4
+ - bin/*
5
+ Style/Documentation:
6
+ Enabled: false
7
+ # TODO: remove this exception when java_processor.rb is fixed to rescue StandardError
8
+ Style/HashEachMethods:
9
+ Enabled: false
10
+ Style/HashTransformKeys:
11
+ Enabled: false
12
+ Style/HashTransformValues:
13
+ Enabled: false
14
+ Lint/RescueException:
15
+ Exclude:
16
+ - 'lib/schematron/java_processor.rb'
17
+ Metrics/AbcSize:
18
+ # The ABC size is a calculated magnitude, so this number can be a Fixnum or
19
+ # a Float.
20
+ Max: 32
21
+ Exclude:
22
+ - 'test/**/*.rb'
23
+ # TODO: remove exclusions below this line as ABC Size is fixed
24
+ - 'lib/performance_rate_validator.rb'
25
+ Metrics/BlockLength:
26
+ Exclude:
27
+ - 'test/factories/*'
28
+ Metrics/ClassLength:
29
+ Max: 120
30
+ Exclude:
31
+ - 'test/**/*'
32
+ # TODO: remove exclusions below this line as Class length is fixed
33
+ - 'lib/qrda_qdm_template_validator.rb'
34
+ Layout/LineLength:
35
+ Max: 150
36
+ Exclude:
37
+ - 'test/**/*'
38
+ # TODO: remove exclusions below this line as line length is fixed
39
+ - 'lib/reported_result_extractor.rb'
40
+ - 'lib/data_validator.rb'
41
+ - 'lib/measure_validator.rb'
42
+ Metrics/MethodLength:
43
+ CountComments: false # count full line comments?
44
+ Max: 20
45
+ Exclude:
46
+ - 'test/**/*'
47
+ # TODO: remove exclusions below this line as method length is fixed
48
+ - 'lib/reported_result_extractor.rb'
49
+ Metrics/ModuleLength:
50
+ Max: 110
51
+ Exclude:
52
+ # TODO: remove exclusions below this line as module length is fixed
53
+ - 'lib/reported_result_extractor.rb'
54
+ # Avoid complex methods.
55
+ Metrics/CyclomaticComplexity:
56
+ Max: 10
57
+ Metrics/PerceivedComplexity:
58
+ Max: 10
59
+ Exclude:
60
+ - 'lib/reported_result_extractor.rb'
61
+ Naming/MethodParameterName:
62
+ Enabled: false
63
+ Style/DateTime:
64
+ Enabled: false
65
+ Style/GuardClause:
66
+ MinBodyLength: 100
67
+ Exclude:
68
+ # TODO: remove exclusions below this line as ABC Size is fixed
69
+ - 'lib/performance_rate_validator.rb'
70
+ Style/MixinUsage:
71
+ Exclude:
72
+ - 'test/test_helper.rb'
73
+ Style/RescueStandardError:
74
+ Enabled: false
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ SimpleCov.start do
4
+ merge_timeout 3600
5
+ end
6
+
7
+ if ENV['CI'] == 'true'
8
+ require 'codecov'
9
+ SimpleCov.formatter = SimpleCov::Formatter::Codecov
10
+ else
11
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
12
+ end
@@ -0,0 +1,20 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.6
4
+ - 2.5
5
+ cache:
6
+ - bundler
7
+ sudo: required
8
+ services:
9
+ - mongodb
10
+ branches:
11
+ only:
12
+ - master
13
+ - cqm_validators_2_x
14
+ before_script:
15
+ - git config --global user.email "travis@travis.ci"
16
+ - git config --global user.name "Travis CI"
17
+ script:
18
+ - bundle exec overcommit --sign
19
+ - bundle exec overcommit --run
20
+ - travis_retry bundle exec rake test
data/Gemfile CHANGED
@@ -1,6 +1,14 @@
1
- source "https://rubygems.org"
1
+ # frozen_string_literal: true
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
6
 
5
7
  # Specify your gem's dependencies in cqm_validators.gemspec
6
- gemspec
8
+ gemspec development_group: :test
9
+
10
+ group :test do
11
+ gem 'codecov', require: false
12
+ gem 'cqm-models', git: 'https://github.com/projecttacoma/cqm-models.git', branch: 'master'
13
+ gem 'simplecov', require: false
14
+ end
data/README.md CHANGED
@@ -1,11 +1,11 @@
1
- This is a validation library that is used by Cypress for QRDA validation.
1
+ This is a library that is used by Cypress for QRDA validation. It contains Schematron validators, schema validators, and validators for QRDA-specific features (measure IDs, performance rates, result extraction, etc).
2
2
 
3
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cqm_validators.
3
+ Bug reports and pull requests are welcome on GitHub at https://github.com/projecttacoma/cqm_validators.
4
4
 
5
5
  Environment
6
6
  ===========
7
7
 
8
- This project currently uses Ruby 2.0.0, Ruby 2.1.1, Ruby 2.2.1, and JRuby 1.7.11 and is built using [Bundler](http://gembundler.com/). To get all of the dependencies for the project, first install bundler:
8
+ This project currently uses Ruby 2.3, Ruby 2.4, Ruby 2.5 and Ruby 2.6 and is built using [Bundler](http://gembundler.com/). To get all of the dependencies for the project, first install bundler:
9
9
 
10
10
  gem install bundler
11
11
 
@@ -13,9 +13,26 @@ Then run bundler to grab all of the necessary gems:
13
13
 
14
14
  bundle install
15
15
 
16
- The Quality Measure engine relies on a MongoDB [MongoDB](http://www.mongodb.org/) running a minimum of version 2.4.* or higher. To get and install Mongo refer to:
17
16
 
18
- http://www.mongodb.org/display/DOCS/Quickstart
17
+
18
+ Versioning
19
+ ==========
20
+
21
+ Starting with version **2.0.0** released on 6/20/19, cqm-validators versioning has the format **X.Y.Z**, where:
22
+
23
+ * **X** maps to a version of QRDA. See the table below to see the existing mapping to QRDA versions.
24
+
25
+ | X | QRDA Cat 1 | QRDA Cat 3 |
26
+ | --- | --- | --- |
27
+ | 2 | R1 STU5.1 | R1 STU2.1 |
28
+ | 3 | R1 STU5.2 | R1 STU2.1 |
29
+
30
+ * **Y** indicates major changes (incompatible API changes)
31
+
32
+ * **Z** indicates minor changes (added functionality in a backwards-compatible manner) and patch changes (backwards-compatible bug fixes)
33
+
34
+ For the versions available, see [tags on this repository](https://github.com/projecttacoma/cqm-validators/tags).
35
+
19
36
 
20
37
  Project Practices
21
38
  =================
@@ -37,4 +54,4 @@ Unless required by applicable law or agreed to in writing, software
37
54
  distributed under the License is distributed on an "AS IS" BASIS,
38
55
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
39
56
  See the License for the specific language governing permissions and
40
- limitations under the License.
57
+ limitations under the License.
data/Rakefile CHANGED
@@ -1,10 +1,12 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rake/testtask'
3
5
 
4
6
  Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
7
+ t.libs << 'test'
8
+ t.libs << 'lib'
9
+ t.test_files = FileList['test/**/*_test.rb']
8
10
  end
9
11
 
10
- task :default => :test
12
+ task default: :test
@@ -0,0 +1,6 @@
1
+ test:
2
+ clients:
3
+ default:
4
+ database: cqmv_test
5
+ hosts:
6
+ - <%= ENV['TEST_DB_HOST'] || '127.0.0.1' %>:27017
@@ -1,28 +1,37 @@
1
+ # frozen_string_literal: true
1
2
 
2
- lib = File.expand_path("../lib", __FILE__)
3
+ lib = File.expand_path('lib', __dir__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "cqm_validators/version"
5
+ require 'cqm_validators/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "cqm-validators"
8
+ spec.name = 'cqm-validators'
8
9
  spec.version = CqmValidators::VERSION
9
- spec.authors = ["Laura", "Michael O'Keefe"]
10
- spec.email = ["laclark@mitre.org", 'mokeefe@mitre.org']
10
+ spec.authors = ['Laura', "Michael O'Keefe"]
11
+ spec.email = ['laclark@mitre.org', 'mokeefe@mitre.org']
11
12
  spec.license = 'Apache-2.0'
12
13
 
13
- spec.summary = "new cqm validator library"
14
- spec.description = "new cqm validator library"
15
- spec.homepage = "https://github.com/projecttacoma/cqm-validators"
14
+ spec.summary = 'new cqm validator library'
15
+ spec.description = 'new cqm validator library'
16
+ spec.homepage = 'https://github.com/projecttacoma/cqm-validators'
16
17
 
17
18
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
19
  f.match(%r{^(test|spec|features)/})
19
20
  end
20
- spec.bindir = "exe"
21
+ spec.bindir = 'exe'
21
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
- spec.require_paths = ["lib"]
23
+ spec.require_paths = ['lib']
23
24
 
24
- spec.add_dependency "nokogiri", "~>1.10.3"
25
- spec.add_development_dependency "bundler", "~> 1.16"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "minitest", "~> 5.0"
25
+ spec.required_ruby_version = '>= 2.5.0'
26
+
27
+ spec.add_dependency 'nokogiri', '~>1.10'
28
+
29
+ spec.add_development_dependency 'bundler'
30
+ spec.add_development_dependency 'byebug'
31
+ spec.add_development_dependency 'minitest', '~> 5.0'
32
+ spec.add_development_dependency 'minitest-reporters'
33
+ spec.add_development_dependency 'mongoid'
34
+ spec.add_development_dependency 'overcommit'
35
+ spec.add_development_dependency 'rake', '>= 12.3.3'
36
+ spec.add_development_dependency 'rubocop', '~> 0.93'
28
37
  end
@@ -1,22 +1,22 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CqmValidators
2
- module BaseValidator
3
-
4
- def build_error(msg, loc, file_name)
5
- ValidationError.new(message: msg, location: loc, file_name: file_name, validator: @name)
6
- end
7
-
8
- def get_document(input)
9
- doc = case input
10
- when File
11
- input.read
12
- when Nokogiri::XML::Document
13
- return input
14
- else
15
- input
16
- end
17
- Nokogiri::XML(doc.to_s) { |conf| conf.strict.nonet.noblanks } #grumble, grumble nokogiri java @SS
18
- end
19
- end
20
-
4
+ module BaseValidator
5
+ def build_error(msg, loc, file_name)
6
+ ValidationError.new(message: msg, location: loc, file_name: file_name, validator: @name)
7
+ end
8
+
9
+ def get_document(input)
10
+ doc = case input
11
+ when File
12
+ input.rewind
13
+ input.read
14
+ when Nokogiri::XML::Document
15
+ return input
16
+ else
17
+ input
18
+ end
19
+ Nokogiri::XML(doc.to_s) { |conf| conf.strict.nonet.noblanks } # grumble, grumble nokogiri java @SS
20
+ end
21
+ end
21
22
  end
22
-
@@ -1,4 +1,6 @@
1
- require "cqm_validators/version"
1
+ # frozen_string_literal: true
2
+
3
+ require 'cqm_validators/version'
2
4
  require 'reported_result_extractor'
3
5
  require 'base_validator'
4
6
  require 'data_validator'
@@ -8,7 +10,7 @@ require 'qrda_qdm_template_validator'
8
10
  require 'schema_validator'
9
11
  require 'schematron_validator'
10
12
  require 'validators'
11
- require "schematron/c_processor"
13
+ require 'schematron/c_processor'
12
14
 
13
15
  module CqmValidators
14
16
  # Your code goes here...
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CqmValidators
2
- VERSION = "0.1.1"
4
+ VERSION = '3.0.1'
3
5
  end
@@ -1,82 +1,77 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module CqmValidators
2
- class DataValidator
3
- include BaseValidator
4
-
5
- HL7_QRDA_OIDS = ["2.16.840.1.113883.3.221.5",
6
- "2.16.840.1.113883.3.88.12.3221.8.7",
7
- "2.16.840.1.113883.3.88.12.3221.8.9",
8
- "2.16.840.1.113883.1.11.12839",
9
- "2.16.840.1.113883.3.88.12.3221.8.11",
10
- "2.16.840.1.113883.3.88.12.3221.6.2",
11
- "2.16.840.1.113883.11.20.9.40",
12
- "2.16.840.1.113883.11.20.9.23",
13
- "2.16.840.1.113883.3.88.12.3221.7.4",
14
- "2.16.840.1.113883.11.20.9.18",
15
- "2.16.840.1.113883.11.20.9.22",
16
- "2.16.840.1.113883.1.11.16866",
17
- "2.16.840.1.113883.1.11.20275",
18
- "2.16.840.1.113883.11.20.9.34",
19
- "2.16.840.1.113883.3.88.12.3221.7.2",
20
- "2.16.840.1.113883.3.88.12.80.17",
21
- "2.16.840.1.113883.3.88.12.80.22",
22
- "2.16.840.1.113883.3.88.12.80.64",
23
- "2.16.840.1.113883.3.88.12.3221.6.8",
24
- "2.16.840.1.113883.1.11.78",
25
- "2.16.840.1.113883.11.20.9.25",
26
- "2.16.840.1.113883.11.20.9.39",
27
- "2.16.840.1.113883.3.88.12.80.32",
28
- "2.16.840.1.113883.11.20.9.21",
29
- "2.16.840.1.113883.3.88.12.80.68",
30
- "2.16.840.1.113883.1.11.20.12",
31
- "2.16.840.1.113883.11.20.9.24",
32
- "2.16.840.1.113883.11.20.9.41",
33
- "2.16.840.1.113883.1.11.16926",
34
- "2.16.840.1.113883.1.11.12212",
35
- "2.16.840.1.113883.1.11.19185",
36
- "2.16.840.1.113883.1.11.14914",
37
- "2.16.840.1.114222.4.11.837",
38
- "2.16.840.1.113883.1.11.19563",
39
- "2.16.840.1.113883.1.11.11526",
40
- "2.16.840.1.113883.11.20.9.20",
41
- "2.16.840.1.113883.3.88.12.80.2",
42
- "2.16.840.1.113883.3.88.12.80.63",
43
- "2.16.840.1.113883.1.11.12249",
44
- "2.16.840.1.113883.1.11.1",
45
- "2.16.840.1.113883.1.11.12199",
46
- "2.16.840.1.113883.11.20.9.33",
47
- "2.16.840.1.114222.4.11.1066",
48
- "2.16.840.1.113883.1.11.19579"]
49
-
50
- def initialize(bundle, measure_ids)
51
- @bundle = bundle
52
- measures = @bundle.measures.in(hqmf_id: measure_ids)
53
-
54
- @oids = measures.collect{|m| m.oids}.flatten.uniq + HL7_QRDA_OIDS
4
+ class DataValidator
5
+ include BaseValidator
6
+
7
+ HL7_QRDA_OIDS = ['2.16.840.1.113883.3.221.5',
8
+ '2.16.840.1.113883.3.88.12.3221.8.7',
9
+ '2.16.840.1.113883.3.88.12.3221.8.9',
10
+ '2.16.840.1.113883.1.11.12839',
11
+ '2.16.840.1.113883.3.88.12.3221.8.11',
12
+ '2.16.840.1.113883.3.88.12.3221.6.2',
13
+ '2.16.840.1.113883.11.20.9.40',
14
+ '2.16.840.1.113883.11.20.9.23',
15
+ '2.16.840.1.113883.3.88.12.3221.7.4',
16
+ '2.16.840.1.113883.11.20.9.18',
17
+ '2.16.840.1.113883.11.20.9.22',
18
+ '2.16.840.1.113883.1.11.16866',
19
+ '2.16.840.1.113883.1.11.20275',
20
+ '2.16.840.1.113883.11.20.9.34',
21
+ '2.16.840.1.113883.3.88.12.3221.7.2',
22
+ '2.16.840.1.113883.3.88.12.80.17',
23
+ '2.16.840.1.113883.3.88.12.80.22',
24
+ '2.16.840.1.113883.3.88.12.80.64',
25
+ '2.16.840.1.113883.3.88.12.3221.6.8',
26
+ '2.16.840.1.113883.1.11.78',
27
+ '2.16.840.1.113883.11.20.9.25',
28
+ '2.16.840.1.113883.11.20.9.39',
29
+ '2.16.840.1.113883.3.88.12.80.32',
30
+ '2.16.840.1.113883.11.20.9.21',
31
+ '2.16.840.1.113883.3.88.12.80.68',
32
+ '2.16.840.1.113883.1.11.20.12',
33
+ '2.16.840.1.113883.11.20.9.24',
34
+ '2.16.840.1.113883.11.20.9.41',
35
+ '2.16.840.1.113883.1.11.16926',
36
+ '2.16.840.1.113883.1.11.12212',
37
+ '2.16.840.1.113883.1.11.19185',
38
+ '2.16.840.1.113883.1.11.14914',
39
+ '2.16.840.1.114222.4.11.837',
40
+ '2.16.840.1.113883.1.11.19563',
41
+ '2.16.840.1.113883.1.11.11526',
42
+ '2.16.840.1.113883.11.20.9.20',
43
+ '2.16.840.1.113883.3.88.12.80.2',
44
+ '2.16.840.1.113883.3.88.12.80.63',
45
+ '2.16.840.1.113883.1.11.12249',
46
+ '2.16.840.1.113883.1.11.1',
47
+ '2.16.840.1.113883.1.11.12199',
48
+ '2.16.840.1.113883.11.20.9.33',
49
+ '2.16.840.1.114222.4.11.1066',
50
+ '2.16.840.1.113883.1.11.19579'].freeze
51
+
52
+ def initialize(measure_ids)
53
+ measures = CQM::Measure.find(measure_ids)
54
+ @value_set_ids = measures.collect { |m| m.value_sets.map(&:_id) }.flatten.uniq
55
+ end
56
+
57
+ def validate(file, options = {})
58
+ doc = get_document(file)
59
+
60
+ doc.xpath('//*[@sdtc:valueSet]').each_with_object([]) do |node, errors|
61
+ oid = node.at_xpath('@sdtc:valueSet')
62
+ vs = CQM::ValueSet.where('oid' => oid, '_id' => { '$in' => @value_set_ids }).first
63
+ next unless vs
64
+
65
+ code = node.at_xpath('@code')
66
+ code_system_oid = node.at_xpath('@codeSystem')
67
+ null_flavor = node.at_xpath('@nullFlavor')
68
+ next unless vs.concepts.where(code: code, code_system_oid: code_system_oid).count.zero?
69
+
70
+ unless null_flavor
71
+ errors << build_error("The code #{code} in codeSystem #{code_system_oid} cannot be found in the declared valueset #{oid}",
72
+ node.path, options[:file_name])
55
73
  end
56
-
57
- def validate(file, options={})
58
- doc = get_document(file)
59
-
60
- doc.xpath("//*[@sdtc:valueSet]").inject([]) do |errors, node|
61
- oid = node.at_xpath("@sdtc:valueSet")
62
- vs = @bundle.value_sets.where({"oid" => oid}).first
63
- code = node.at_xpath("@code")
64
- code_system = node.at_xpath("@codeSystem")
65
- null_flavor = node.at_xpath("@nullFlavor")
66
- if !vs
67
- errors << build_error("The valueset #{oid} declared in the document cannot be found", node.path, options[:file_name])
68
- elsif !@oids.include?(oid.value)
69
- errors << build_error("File appears to contain data criteria outside that required by the measures. Valuesets in file not in measures tested #{oid}'",
70
- node.path, options[:file_name])
71
- elsif vs.concepts.where({"code" => code, "code_system"=>code_system}).count() == 0
72
- if !null_flavor
73
- errors << build_error("The code #{code} in codeSystem #{code_system} cannot be found in the declared valueset #{oid}",
74
- node.path, options[:file_name])
75
- end
76
- end
77
- errors
78
- end
79
- end
80
-
81
74
  end
82
- end
75
+ end
76
+ end
77
+ end