bonnie_bundler 2.0.2 → 2.0.3

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
  SHA1:
3
- metadata.gz: '09fad5431a725716e82f1102598fa03d7e88b389'
4
- data.tar.gz: 01d459f365bd058999fa42c231d33a223f5a56a3
3
+ metadata.gz: ee582288be3cfd05d88916295b4cddd2002350c0
4
+ data.tar.gz: 052e03dc984ea038e5469c45f60bc44307befc3c
5
5
  SHA512:
6
- metadata.gz: e6095973b1224e9b3c8b3419a01dc6b61e4bb44a9727a86ffb8d5c26183a7c7e1605a97ccf42448aad6aa584327d9db168e1d14f6ee8e0cb28c65d95580f4768
7
- data.tar.gz: 4b77d0640c3279926db64a9b7873e004e8074636c21b0773fa26c6fc3672b21def3138c8984037b03414fecc2071130f8c56284fb5a0a8f9676168296735025c
6
+ metadata.gz: b228407edd054902045f684c4ed9e1faa96c34a2d68f15f532a4035fa0dbffe33e0398e19e3f6493252aa0db8ffa5a5223408232ee62f916cf4459c2e57bd9ee
7
+ data.tar.gz: c2885dbe838270ee02367978e472fbef37b570ffbdfe7b5d3da5d164ed3e364012b362f68e6465dadac53a4411d53bccbcff37fd756b61d7c7bbd685835b63c7
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bonnie_bundler (2.0.2)
4
+ bonnie_bundler (2.0.3)
5
5
  diffy (~> 3.0.0)
6
6
  health-data-standards (~> 4.0)
7
7
  hqmf2js (~> 1.4)
@@ -84,7 +84,7 @@ GEM
84
84
  globalid (0.4.1)
85
85
  activesupport (>= 4.2.0)
86
86
  hashdiff (0.3.6)
87
- health-data-standards (4.0.1)
87
+ health-data-standards (4.0.2)
88
88
  activesupport (~> 4.2.0)
89
89
  builder (~> 3.1)
90
90
  erubis (~> 2.7.0)
@@ -93,7 +93,7 @@ GEM
93
93
  memoist (~> 0.9.1)
94
94
  mongoid (~> 5.0.0)
95
95
  mongoid-tree (~> 2.0.0)
96
- nokogiri (~> 1.8.1)
96
+ nokogiri (~> 1.8.2)
97
97
  protected_attributes (~> 1.0.5)
98
98
  rest-client (~> 1.8.0)
99
99
  rubyzip (~> 1.2.1)
@@ -146,7 +146,7 @@ GEM
146
146
  mongoid (>= 4.0, < 6.0)
147
147
  multi_json (1.12.2)
148
148
  netrc (0.11.0)
149
- nokogiri (1.8.1)
149
+ nokogiri (1.8.2)
150
150
  mini_portile2 (~> 2.3.0)
151
151
  origin (2.3.1)
152
152
  protected_attributes (1.0.9)
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.email = "pophealth-talk@googlegroups.com"
8
8
  s.homepage = "http://github.com/projecttacoma/bonnie_bundler"
9
9
  s.authors = ["The MITRE Corporation"]
10
- s.version = '2.0.2'
10
+ s.version = '2.0.3'
11
11
  s.license = 'Apache-2.0'
12
12
 
13
13
  s.add_dependency 'health-data-standards', '~> 4.0'
@@ -129,31 +129,22 @@ module Measures
129
129
  raise VSACException.new "Error Loading Value Sets from VSAC: #{e.message}"
130
130
  end
131
131
  else
132
- # if VSAC credentials aren't provided, find the value sets in the database
133
- elm_value_sets.each do |elm_value_set|
134
- version = elm_value_set[:version] || "N/A" # 'N/A' is what is stored in the DB for value sets without versions
135
- query_params = {user_id: user.id, oid: elm_value_set[:oid]}
136
-
137
- if (elm_value_set[:profile])
138
- query_params[:profile] = elm_value_set[:profile]
139
- else
140
- query_params[:version] = version
141
- end
142
-
143
- value_set = HealthDataStandards::SVS::ValueSet.where(query_params).first()
144
- if value_set
145
- value_set_models << value_set
146
- elsif version == "N/A"
147
- # if the version is "N/A" and a value set doesn't exist with that version, just grab the existing value set
148
- value_set = HealthDataStandards::SVS::ValueSet.where({user_id: user.id, oid: elm_value_set[:oid]}).first()
132
+ # No vsac credentials were provided grab the valueset and valueset versions from the 'value_set_oid_version_object' on the existing measure
133
+ db_measure = CqlMeasure.by_user(user).where(hqmf_set_id: measure_id).first
134
+ unless db_measure.nil?
135
+ measure_value_set_version_map = db_measure.value_set_oid_version_objects
136
+ measure_value_set_version_map.each do |value_set|
137
+ query_params = {user_id: user.id, oid: value_set['oid'], version: value_set['version']}
138
+ value_set = HealthDataStandards::SVS::ValueSet.where(query_params).first()
149
139
  if value_set
150
140
  value_set_models << value_set
141
+ else
142
+ raise MeasureLoadingException.new "Value Set not found in database: #{query_params}"
151
143
  end
152
144
  end
153
145
  end
154
146
  end
155
147
 
156
-
157
148
  # Get code systems and codes for all value sets in the elm.
158
149
  all_codes_and_code_names = HQMF2JS::Generator::CodesToJson.from_value_sets(value_set_models)
159
150
  # Replace code system oids with friendly names
@@ -167,7 +158,10 @@ module Measures
167
158
  # Add our new fake oids to measure value sets.
168
159
  all_value_set_oids = value_set_models.collect{|vs| vs.oid}
169
160
  single_code_references.each do |single_code|
170
- all_value_set_oids << single_code[:guid]
161
+ # Only add unique Direct Reference Codes
162
+ unless all_value_set_oids.include?(single_code[:guid])
163
+ all_value_set_oids << single_code[:guid]
164
+ end
171
165
  end
172
166
 
173
167
  # Add a list of value set oids and their versions
@@ -192,8 +186,12 @@ module Measures
192
186
  value_set_oid_version_objects << {:oid => vs.oid, :version => vs.version}
193
187
  end
194
188
  single_code_references.each do |single_code|
195
- value_set_oid_version_objects << {:oid => single_code[:guid], :version => ""}
189
+ # Only add unique Direct Reference Codes to the object
190
+ unless value_set_oid_version_objects.include?({:oid => single_code[:guid], :version => ""})
191
+ value_set_oid_version_objects << {:oid => single_code[:guid], :version => ""}
192
+ end
196
193
  end
194
+ # Return a list of unique objects only
197
195
  value_set_oid_version_objects
198
196
  end
199
197
 
@@ -51,4 +51,38 @@ class CQLLoaderTest < ActiveSupport::TestCase
51
51
  assert_equal measures[0]['data_criteria']['prefix_5195_3_LaboratoryTestPerformed_70C9F083_14BD_4331_99D7_201F8589059D']['code_list_id'], measures[1]['data_criteria']['prefix_5195_3_LaboratoryTestPerformed_70C9F083_14BD_4331_99D7_201F8589059D']['code_list_id']
52
52
  end
53
53
  end
54
+
55
+ test 'Re-loading a measure with no VSAC credentials' do
56
+ direct_reference_mat_export = File.new File.join('test', 'fixtures', 'CMS158_v5_4_Artifacts_Update.zip')
57
+ VCR.use_cassette('valid_vsac_response_158_update') do
58
+ dump_db
59
+ user = User.new
60
+ user.save
61
+
62
+ measure_details = { 'episode_of_care'=> false }
63
+ Measures::CqlLoader.load(direct_reference_mat_export, user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD']).save
64
+ assert_equal 1, CqlMeasure.all.count
65
+ measure = CqlMeasure.all.first
66
+ before_value_sets = measure.value_set_oids
67
+ before_value_set_version_object = measure.value_set_oid_version_objects
68
+ before_data_criteria = measure.data_criteria
69
+ before_source_data_criteria = measure.source_data_criteria
70
+
71
+ # Re-load the Measure without VSAC Credentials
72
+ Measures::CqlLoader.load(direct_reference_mat_export, user, measure_details, nil, nil).save
73
+ assert_equal 2, CqlMeasure.all.count
74
+ measures = CqlMeasure.all
75
+
76
+ # Assert the value sets were loaded properly when no VSAC credentials are provided for both instances of the measure
77
+ assert Digest::MD5.hexdigest(before_value_sets.to_json) == Digest::MD5.hexdigest(measures[0].value_set_oids.to_json)
78
+ assert Digest::MD5.hexdigest(before_value_set_version_object.to_json) == Digest::MD5.hexdigest(measures[0].value_set_oid_version_objects.to_json)
79
+ assert Digest::MD5.hexdigest(before_data_criteria.to_json) == Digest::MD5.hexdigest(measures[0].data_criteria.to_json)
80
+ assert Digest::MD5.hexdigest(before_source_data_criteria.to_json) == Digest::MD5.hexdigest(measures[0].source_data_criteria.to_json)
81
+
82
+ assert Digest::MD5.hexdigest(before_value_sets.to_json) == Digest::MD5.hexdigest(measures[1].value_set_oids.to_json)
83
+ assert Digest::MD5.hexdigest(before_value_set_version_object.to_json) == Digest::MD5.hexdigest(measures[1].value_set_oid_version_objects.to_json)
84
+ assert Digest::MD5.hexdigest(before_data_criteria.to_json) == Digest::MD5.hexdigest(measures[1].data_criteria.to_json)
85
+ assert Digest::MD5.hexdigest(before_source_data_criteria.to_json) == Digest::MD5.hexdigest(measures[1].source_data_criteria.to_json)
86
+ end
87
+ end
54
88
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bonnie_bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - The MITRE Corporation
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-17 00:00:00.000000000 Z
11
+ date: 2018-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: health-data-standards
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  requirements: []
258
258
  rubyforge_project:
259
- rubygems_version: 2.5.2.1
259
+ rubygems_version: 2.6.14
260
260
  signing_key:
261
261
  specification_version: 4
262
262
  summary: A Gem for creating and managing bonnie bundles