bonnie_bundler 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +3 -0
  3. data/.travis.yml +12 -0
  4. data/Gemfile +29 -0
  5. data/Gemfile.lock +267 -0
  6. data/README.md +4 -0
  7. data/Rakefile +29 -0
  8. data/bonnie-bundler.gemspec +29 -0
  9. data/config/initializers/mongo.rb +1 -0
  10. data/config/measures/measures_2_4_0.yml +719 -0
  11. data/config/mongoid.yml +6 -0
  12. data/lib/bonnie_bundler.rb +39 -0
  13. data/lib/ext/hash.rb +28 -0
  14. data/lib/ext/railtie.rb +11 -0
  15. data/lib/ext/valueset.rb +11 -0
  16. data/lib/measures/cql_to_elm_helper.rb +90 -0
  17. data/lib/measures/elm_parser.rb +74 -0
  18. data/lib/measures/loading/base_loader_definition.rb +61 -0
  19. data/lib/measures/loading/cql_loader.rb +420 -0
  20. data/lib/measures/loading/exceptions.rb +10 -0
  21. data/lib/measures/loading/loader.rb +178 -0
  22. data/lib/measures/loading/value_set_loader.rb +137 -0
  23. data/lib/measures/logic_extractor.rb +552 -0
  24. data/lib/measures/mongo_hash_key_wrapper.rb +44 -0
  25. data/lib/models/cql_measure.rb +160 -0
  26. data/lib/models/measure.rb +330 -0
  27. data/test/fixtures/BCS_v5_0_Artifacts.zip +0 -0
  28. data/test/fixtures/CMS158_v5_4_Artifacts.zip +0 -0
  29. data/test/fixtures/CMS158_v5_4_Artifacts_Update.zip +0 -0
  30. data/test/fixtures/DRAFT_CMS2_CQL.zip +0 -0
  31. data/test/fixtures/bonnienesting01_fixed.zip +0 -0
  32. data/test/fixtures/vcr_cassettes/mat_5-4_cql_export_vsac_response.yml +4723 -0
  33. data/test/fixtures/vcr_cassettes/multi_library_webcalls.yml +1892 -0
  34. data/test/fixtures/vcr_cassettes/valid_translation_response.yml +1120 -0
  35. data/test/fixtures/vcr_cassettes/valid_vsac_response.yml +1678 -0
  36. data/test/fixtures/vcr_cassettes/valid_vsac_response_158.yml +1670 -0
  37. data/test/fixtures/vcr_cassettes/valid_vsac_response_158_update.yml +1670 -0
  38. data/test/fixtures/vcr_cassettes/valid_vsac_response_includes_draft.yml +3480 -0
  39. data/test/fixtures/vcr_cassettes/vs_loading_draft_no_profile_version.yml +1198 -0
  40. data/test/fixtures/vcr_cassettes/vs_loading_draft_profile.yml +1198 -0
  41. data/test/fixtures/vcr_cassettes/vs_loading_draft_verion.yml +1198 -0
  42. data/test/fixtures/vcr_cassettes/vs_loading_no_profile_version.yml +1198 -0
  43. data/test/fixtures/vcr_cassettes/vs_loading_profile.yml +1196 -0
  44. data/test/fixtures/vcr_cassettes/vs_loading_version.yml +20331 -0
  45. data/test/fixtures/vs_loading/DocofMeds_v5_1_Artifacts.zip +0 -0
  46. data/test/fixtures/vs_loading/DocofMeds_v5_1_Artifacts_Version.zip +0 -0
  47. data/test/fixtures/vs_loading/DocofMeds_v5_1_Artifacts_With_Profiles.zip +0 -0
  48. data/test/simplecov_init.rb +18 -0
  49. data/test/test_helper.rb +44 -0
  50. data/test/unit/load_mat_export_test.rb +181 -0
  51. data/test/unit/measure_complexity_test.rb +32 -0
  52. data/test/unit/measure_diff_test.rb +68 -0
  53. data/test/unit/mongo_hash_key_wrapper_test.rb +247 -0
  54. data/test/unit/storing_mat_export_package_test.rb +45 -0
  55. data/test/unit/value_set_loading_test.rb +109 -0
  56. data/test/vcr_setup.rb +20 -0
  57. metadata +258 -0
@@ -0,0 +1,45 @@
1
+ require 'test_helper'
2
+ require 'vcr_setup.rb'
3
+
4
+ class StoringMATExportPackageTest < ActiveSupport::TestCase
5
+
6
+ setup do
7
+ @cql_mat_export = File.new File.join('test', 'fixtures', 'CMS158_v5_4_Artifacts.zip')
8
+ end
9
+
10
+ test "Loading a MAT package, confirming the contents of the MAT package are viewable and stored correctly" do
11
+ VCR.use_cassette("valid_vsac_response_158") do
12
+ dump_db
13
+ user = User.new
14
+ user.save
15
+
16
+ measure_details = { 'episode_of_care'=> false }
17
+ Measures::CqlLoader.load(@cql_mat_export, user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD']).save
18
+ assert_equal 1, CqlMeasure.all.count
19
+ measure = CqlMeasure.all.first
20
+ assert_equal "Test 158", measure.title
21
+
22
+ assert_equal 1, CqlMeasurePackage.all.count
23
+ measure_package = CqlMeasurePackage.all.first
24
+ assert_equal measure.id, measure_package.measure_id
25
+
26
+ Dir.mktmpdir do |dir|
27
+ # Write the package to a temp directory
28
+ File.open(File.join(dir, measure.measure_id + '.zip'), 'wb') do |zip_file|
29
+ # Write the package binary to a zip file.
30
+ zip_file.write(measure_package.file.data)
31
+ Zip::ZipFile.open(zip_file.path) do |file|
32
+ cql_files = file.glob(File.join('**','**.cql')).select {|x| !x.name.starts_with?('__MACOSX') }
33
+ xml_files = file.glob(File.join('**','**.xml')).select {|x| !x.name.starts_with?('__MACOSX') }
34
+ json_files = file.glob(File.join('**','**.json')).select {|x| !x.name.starts_with?('__MACOSX') }
35
+
36
+ assert_equal 1, cql_files.count
37
+ assert_equal 2, xml_files.count
38
+ assert_equal 1, json_files.count
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ end
@@ -0,0 +1,109 @@
1
+ require 'test_helper'
2
+ require 'vcr_setup.rb'
3
+
4
+ # Test ensures that the correct vsac requests are made when loading a measure.
5
+ class ValueSetLoadingTest < ActiveSupport::TestCase
6
+
7
+ setup do
8
+ dump_db
9
+ @user = User.new
10
+ @user.save
11
+ end
12
+
13
+ test 'Loading with IncludeDraft and no Profile or Version' do
14
+ # Expects that draft and default profile will be used
15
+ VCR.use_cassette("vs_loading_draft_no_profile_version") do
16
+ mat_file = File.new File.join("test", "fixtures", "vs_loading", "DocofMeds_v5_1_Artifacts.zip")
17
+ measure_details = {}
18
+ measure = Measures::CqlLoader.load(mat_file, @user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD'], false, false, true)
19
+ measure.value_sets.each do |vs|
20
+ if vs.oid == "2.16.840.1.113883.3.600.1.1834"
21
+ assert_equal 154, vs.concepts.count
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ test 'Loading with IncludeDraft and a Profile' do
28
+ # Expects that draft and default profile will be used, and provided Profile will be ignored
29
+ VCR.use_cassette("vs_loading_draft_profile") do
30
+ mat_file = File.new File.join("test", "fixtures", "vs_loading", "DocofMeds_v5_1_Artifacts_With_Profiles.zip")
31
+ measure_details = {}
32
+ measure = Measures::CqlLoader.load(mat_file, @user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD'], false, false, true)
33
+ measure.value_sets.each do |vs|
34
+ if vs.oid == "2.16.840.1.113883.3.600.1.1834"
35
+ assert_equal 154, vs.concepts.count
36
+ end
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ test 'Loading with IncludeDraft and a Version' do
43
+ # Expects that draft and default profile will be used, and provided Version will be ignored
44
+ VCR.use_cassette("vs_loading_draft_verion") do
45
+ mat_file = File.new File.join("test", "fixtures", "vs_loading", "DocofMeds_v5_1_Artifacts_Version.zip")
46
+ measure_details = {}
47
+ measure = Measures::CqlLoader.load(mat_file, @user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD'], false, false, true)
48
+ measure.value_sets.each do |vs|
49
+ if vs.oid == "2.16.840.1.113883.3.600.1.1834"
50
+ assert_equal 154, vs.concepts.count
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ test 'Loading without IncludeDraft and no Profile or Version' do
57
+ # Expects that default profile will be used
58
+ VCR.use_cassette("vs_loading_no_profile_version") do
59
+ mat_file = File.new File.join("test", "fixtures", "vs_loading", "DocofMeds_v5_1_Artifacts.zip")
60
+ measure_details = {}
61
+ measure = Measures::CqlLoader.load(mat_file, @user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD'], false, false, false)
62
+ measure.value_sets.each do |vs|
63
+ if vs.oid == "2.16.840.1.113883.3.600.1.1834"
64
+ assert_equal 154, vs.concepts.count
65
+ end
66
+ end
67
+ end
68
+ end
69
+
70
+ test 'VSAC Error Exception Handling' do
71
+ # Expects that default profile will be used
72
+ VCR.use_cassette("vs_loading_no_profile_version") do
73
+ mat_file = File.new File.join("test", "fixtures", "vs_loading", "DocofMeds_v5_1_Artifacts.zip")
74
+ measure_details = {}
75
+ exception = assert_raise Measures::VSACException do
76
+ measure = Measures::CqlLoader.load(mat_file, "fake user", measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD'], false, false, false)
77
+ end
78
+ assert_equal 'Error Loading Value Sets from VSAC: undefined method `id\' for "fake user":String', exception.message
79
+ end
80
+ end
81
+
82
+ test 'Loading without IncludeDraft and a Profile' do
83
+ # Expects that given profile will be used
84
+ VCR.use_cassette("vs_loading_profile") do
85
+ mat_file = File.new File.join("test", "fixtures", "vs_loading", "DocofMeds_v5_1_Artifacts_With_Profiles.zip")
86
+ measure_details = {}
87
+ measure = Measures::CqlLoader.load(mat_file, @user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD'], false, false, false)
88
+ measure.value_sets.each do |vs|
89
+ if vs.oid == "2.16.840.1.113883.3.600.1.1834"
90
+ assert_equal 152, vs.concepts.count
91
+ end
92
+ end
93
+ end
94
+ end
95
+
96
+ test 'Loading without IncludeDraft and a Version' do
97
+ # Expects that given version will be used
98
+ VCR.use_cassette("vs_loading_version") do
99
+ mat_file = File.new File.join("test", "fixtures", "vs_loading", "DocofMeds_v5_1_Artifacts_Version.zip")
100
+ measure_details = {}
101
+ measure = Measures::CqlLoader.load(mat_file, @user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD'], false, false, false)
102
+ measure.value_sets.each do |vs|
103
+ if vs.oid == "2.16.840.1.113883.3.600.1.1834"
104
+ assert_equal 148, vs.concepts.count
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
data/test/vcr_setup.rb ADDED
@@ -0,0 +1,20 @@
1
+ require 'vcr'
2
+ # VCR records HTTP interactions to cassettes that can be replayed during unit tests
3
+ # allowing for faster, more predictible web interactions
4
+ VCR.configure do |c|
5
+ # This is where the various cassettes will be recorded to
6
+ c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
7
+ c.hook_into :webmock
8
+
9
+ # To avoid storing plain text VSAC credentials or requiring the VSAC credentials
10
+ # be provided at every run of the rake tests, provide the VSAC_USERNAME and VSAC_PASSWORD
11
+ # whenever you need to record a cassette that requires valid credentials
12
+ ENV['VSAC_USERNAME'] = "vcrtest" unless ENV['VSAC_USERNAME']
13
+ ENV['VSAC_PASSWORD'] = "vcrpass" unless ENV['VSAC_PASSWORD']
14
+
15
+ # Ensure plain text passwords do not show up during logging
16
+ c.filter_sensitive_data('<VSAC_USERNAME>') {ENV['VSAC_USERNAME']}
17
+ c.filter_sensitive_data('<VSAC_PASSWORD>') {ENV['VSAC_PASSWORD']}
18
+ c.default_cassette_options = {record: :once }
19
+
20
+ end
metadata ADDED
@@ -0,0 +1,258 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bonnie_bundler
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.0
5
+ platform: ruby
6
+ authors:
7
+ - The MITRE Corporation
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: health-data-standards
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: quality-measure-engine
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.2'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hquery-patient-api
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.1'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.1'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplexml_parser
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: hqmf2js
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.4'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.4'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '4.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '4.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: mongoid
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '5.0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '5.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubyzip
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.2'
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: 1.2.1
121
+ type: :runtime
122
+ prerelease: false
123
+ version_requirements: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - "~>"
126
+ - !ruby/object:Gem::Version
127
+ version: '1.2'
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: 1.2.1
131
+ - !ruby/object:Gem::Dependency
132
+ name: zip-zip
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: '0.3'
138
+ type: :runtime
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: '0.3'
145
+ - !ruby/object:Gem::Dependency
146
+ name: diffy
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: 3.0.0
152
+ type: :runtime
153
+ prerelease: false
154
+ version_requirements: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - "~>"
157
+ - !ruby/object:Gem::Version
158
+ version: 3.0.0
159
+ - !ruby/object:Gem::Dependency
160
+ name: roo
161
+ requirement: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - "~>"
164
+ - !ruby/object:Gem::Version
165
+ version: '1.13'
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ requirements:
170
+ - - "~>"
171
+ - !ruby/object:Gem::Version
172
+ version: '1.13'
173
+ description: A Gem for creating and managing bonnie bundles
174
+ email: pophealth-talk@googlegroups.com
175
+ executables: []
176
+ extensions: []
177
+ extra_rdoc_files: []
178
+ files:
179
+ - ".gitignore"
180
+ - ".travis.yml"
181
+ - Gemfile
182
+ - Gemfile.lock
183
+ - README.md
184
+ - Rakefile
185
+ - bonnie-bundler.gemspec
186
+ - config/initializers/mongo.rb
187
+ - config/measures/measures_2_4_0.yml
188
+ - config/mongoid.yml
189
+ - lib/bonnie_bundler.rb
190
+ - lib/ext/hash.rb
191
+ - lib/ext/railtie.rb
192
+ - lib/ext/valueset.rb
193
+ - lib/measures/cql_to_elm_helper.rb
194
+ - lib/measures/elm_parser.rb
195
+ - lib/measures/loading/base_loader_definition.rb
196
+ - lib/measures/loading/cql_loader.rb
197
+ - lib/measures/loading/exceptions.rb
198
+ - lib/measures/loading/loader.rb
199
+ - lib/measures/loading/value_set_loader.rb
200
+ - lib/measures/logic_extractor.rb
201
+ - lib/measures/mongo_hash_key_wrapper.rb
202
+ - lib/models/cql_measure.rb
203
+ - lib/models/measure.rb
204
+ - test/fixtures/BCS_v5_0_Artifacts.zip
205
+ - test/fixtures/CMS158_v5_4_Artifacts.zip
206
+ - test/fixtures/CMS158_v5_4_Artifacts_Update.zip
207
+ - test/fixtures/DRAFT_CMS2_CQL.zip
208
+ - test/fixtures/bonnienesting01_fixed.zip
209
+ - test/fixtures/vcr_cassettes/mat_5-4_cql_export_vsac_response.yml
210
+ - test/fixtures/vcr_cassettes/multi_library_webcalls.yml
211
+ - test/fixtures/vcr_cassettes/valid_translation_response.yml
212
+ - test/fixtures/vcr_cassettes/valid_vsac_response.yml
213
+ - test/fixtures/vcr_cassettes/valid_vsac_response_158.yml
214
+ - test/fixtures/vcr_cassettes/valid_vsac_response_158_update.yml
215
+ - test/fixtures/vcr_cassettes/valid_vsac_response_includes_draft.yml
216
+ - test/fixtures/vcr_cassettes/vs_loading_draft_no_profile_version.yml
217
+ - test/fixtures/vcr_cassettes/vs_loading_draft_profile.yml
218
+ - test/fixtures/vcr_cassettes/vs_loading_draft_verion.yml
219
+ - test/fixtures/vcr_cassettes/vs_loading_no_profile_version.yml
220
+ - test/fixtures/vcr_cassettes/vs_loading_profile.yml
221
+ - test/fixtures/vcr_cassettes/vs_loading_version.yml
222
+ - test/fixtures/vs_loading/DocofMeds_v5_1_Artifacts.zip
223
+ - test/fixtures/vs_loading/DocofMeds_v5_1_Artifacts_Version.zip
224
+ - test/fixtures/vs_loading/DocofMeds_v5_1_Artifacts_With_Profiles.zip
225
+ - test/simplecov_init.rb
226
+ - test/test_helper.rb
227
+ - test/unit/load_mat_export_test.rb
228
+ - test/unit/measure_complexity_test.rb
229
+ - test/unit/measure_diff_test.rb
230
+ - test/unit/mongo_hash_key_wrapper_test.rb
231
+ - test/unit/storing_mat_export_package_test.rb
232
+ - test/unit/value_set_loading_test.rb
233
+ - test/vcr_setup.rb
234
+ homepage: http://github.com/projecttacoma/bonnie_bundler
235
+ licenses:
236
+ - Apache-2.0
237
+ metadata: {}
238
+ post_install_message:
239
+ rdoc_options: []
240
+ require_paths:
241
+ - lib
242
+ required_ruby_version: !ruby/object:Gem::Requirement
243
+ requirements:
244
+ - - ">="
245
+ - !ruby/object:Gem::Version
246
+ version: '0'
247
+ required_rubygems_version: !ruby/object:Gem::Requirement
248
+ requirements:
249
+ - - ">="
250
+ - !ruby/object:Gem::Version
251
+ version: '0'
252
+ requirements: []
253
+ rubyforge_project:
254
+ rubygems_version: 2.6.14
255
+ signing_key:
256
+ specification_version: 4
257
+ summary: A Gem for creating and managing bonnie bundles
258
+ test_files: []