bonnie_bundler 2.0.1 → 2.0.2

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: 61e2a56d536dfc98d6737d50c746798b94640bb6
4
- data.tar.gz: 4b545b3b00f5daa2670da24798d9cfca0e35eaf3
3
+ metadata.gz: '09fad5431a725716e82f1102598fa03d7e88b389'
4
+ data.tar.gz: 01d459f365bd058999fa42c231d33a223f5a56a3
5
5
  SHA512:
6
- metadata.gz: 31322b05a378e3f5897f8ff193f78aef1565d5113d64238ea6ac13e5c28a510ebc0bcf47d4a109c48896c9563698d65cfb816e9ea0bc051d8bf4d1ea3f30c7a8
7
- data.tar.gz: '00292a81e87be77bf7c05270ff902eb970a3f8a13253739d907fa8d503d804f88e1cc731a8dff3fdacc7a9d91f343a0a72dab09fbbd35caae0fd226028945797'
6
+ metadata.gz: e6095973b1224e9b3c8b3419a01dc6b61e4bb44a9727a86ffb8d5c26183a7c7e1605a97ccf42448aad6aa584327d9db168e1d14f6ee8e0cb28c65d95580f4768
7
+ data.tar.gz: 4b77d0640c3279926db64a9b7873e004e8074636c21b0773fa26c6fc3672b21def3138c8984037b03414fecc2071130f8c56284fb5a0a8f9676168296735025c
@@ -0,0 +1,14 @@
1
+ # :clipboard: Bonnie Bundler contribution rules
2
+ 1. All tickets relating to a pull request must link to the pull request.
3
+ 2. All pull requests must link to their parent tickets.
4
+ 3. All pull requests must have accompanying tests. This means:
5
+ * Automated tests: Automated tests are expected unless they are not feasible. If they are not feasible, this should be explained in the pull request.
6
+ * A JIRA test should be included if the automated tests are not sufficient
7
+ - The JIRA test should link to the pull request
8
+ - The JIRA test should link to the tasks that were resolved by the pull request
9
+ * A pull request review also includes a review of the accompanying tests tests
10
+ 4. All pull requests must pass a calculation regression test to confirm that calculations do not break with these changes
11
+
12
+ :clipboard: For more details see: https://gitlab.mitre.org/bonnie/internal-documentation/wikis/pull-requests
13
+
14
+ As a reviewer of a pull request, you are accountable to verifying that the PR contains all items. :punch:
@@ -0,0 +1,45 @@
1
+ Pull requests into Bonnie Bundler 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
+ - [ ] This PR is into the correct branch.
6
+ - [ ] JIRA ticket for this PR:
7
+ - [ ] JIRA ticket links to this PR
8
+ - [ ] Code diff has been done and been reviewed (it **does not** contain: additional white space, not applicable code changes, debug statements, etc.)
9
+ - [ ] Tests are included and test edge cases
10
+ - [ ] Tests have been run locally and pass (remember to update Gemfile when applicable)
11
+ - [ ] Code coverage has not gone down and all code touched or added is covered.
12
+ * In rare situations, this may not be possible or applicable to a PR. In those situations:
13
+ 1. Note why this could not be done or is not applicable here:
14
+ 2. Add TODOs in the code noting that it requires a test
15
+ 3. Add a JIRA task to add the test and link it here:
16
+ - [ ] Automated regression test(s) pass
17
+
18
+ If JIRA tests were used to supplement or replace automated tests:
19
+ - [ ] JIRA test links:
20
+ - [ ] Justification for using JIRA tests:
21
+ - [ ] JIRA tests have been added to sprint
22
+
23
+
24
+ **Reviewer 1:**
25
+
26
+ Name:
27
+ - [ ] Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose
28
+ - [ ] The tests appropriately test the new code, including edge cases
29
+ - [ ] You have tried to break the code
30
+
31
+ If JIRA tests were used to supplement or replace automated tests:
32
+ - [ ] JIRA tests have been run and pass
33
+ - [ ] You agree with the justification for use of JIRA tests or have provided input on why you disagree
34
+
35
+
36
+ **Reviewer 2:**
37
+
38
+ Name:
39
+ - [ ] Code is maintainable and reusable, reuses existing code and infrastructure where appropriate, and accomplishes the task’s purpose
40
+ - [ ] The tests appropriately test the new code, including edge cases
41
+ - [ ] You have tried to break the code
42
+
43
+ If JIRA tests were used to supplement or replace automated tests:
44
+ - [ ] JIRA tests have been run and pass
45
+ - [ ] You agree with the justification for use of JIRA tests or have provided input on why you disagree
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bonnie_bundler (2.0.1)
4
+ bonnie_bundler (2.0.2)
5
5
  diffy (~> 3.0.0)
6
6
  health-data-standards (~> 4.0)
7
7
  hqmf2js (~> 1.4)
@@ -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.1'
10
+ s.version = '2.0.2'
11
11
  s.license = 'Apache-2.0'
12
12
 
13
13
  s.add_dependency 'health-data-standards', '~> 4.0'
@@ -42,10 +42,26 @@ module Measures
42
42
  json = hqmf_model.to_json
43
43
  json.convert_keys_to_strings
44
44
 
45
+ # Set the code list ids of data criteria and source data criteria that use direct reference codes to GUIDS.
46
+ json['source_data_criteria'], json['data_criteria'] = set_data_criteria_code_list_ids(json, cql_artifacts)
47
+
48
+ # Create CQL Measure
49
+ measure = Measures::Loader.load_hqmf_cql_model_json(json, user, cql_artifacts[:all_value_set_oids], main_cql_library, cql_artifacts[:cql_definition_dependency_structure],
50
+ cql_artifacts[:elms], cql_artifacts[:elm_annotations], files[:CQL], nil, cql_artifacts[:value_set_oid_version_objects])
51
+ measure['episode_of_care'] = measure_details['episode_of_care']
52
+ measure['type'] = measure_details['type']
53
+
54
+ # Create, associate and save the measure package.
55
+ measure.package = CqlMeasurePackage.new(file: BSON::Binary.new(zip_file.read()))
56
+ measure.package.save
57
+
58
+ measure
59
+ end
60
+
61
+ def self.set_data_criteria_code_list_ids(json, cql_artifacts)
45
62
  # Loop over data criteria to search for data criteria that is using a single reference code.
46
63
  # Once found set the Data Criteria's 'code_list_id' to our fake oid. Do the same for source data criteria.
47
64
  json['data_criteria'].each do |data_criteria_name, data_criteria|
48
- # We do not want to replace an existing code_list_id. Skip.
49
65
  unless data_criteria['code_list_id']
50
66
  if data_criteria['inline_code_list']
51
67
  # Check to see if inline_code_list contains the correct code_system and code for a direct reference code.
@@ -64,18 +80,7 @@ module Measures
64
80
  end
65
81
  end
66
82
  end
67
-
68
- # Create CQL Measure
69
- measure = Measures::Loader.load_hqmf_cql_model_json(json, user, cql_artifacts[:all_value_set_oids], main_cql_library, cql_artifacts[:cql_definition_dependency_structure],
70
- cql_artifacts[:elms], cql_artifacts[:elm_annotations], files[:CQL], nil, cql_artifacts[:value_set_oid_version_objects])
71
- measure['episode_of_care'] = measure_details['episode_of_care']
72
- measure['type'] = measure_details['type']
73
-
74
- # Create, associate and save the measure package.
75
- measure.package = CqlMeasurePackage.new(file: BSON::Binary.new(zip_file.read()))
76
- measure.package.save
77
-
78
- measure
83
+ return json['source_data_criteria'], json['data_criteria']
79
84
  end
80
85
 
81
86
  def self.load(file, user, measure_details, vsac_user=nil, vsac_password=nil, overwrite_valuesets=false, cache=false, includeDraft=false, ticket_granting_ticket=nil)
@@ -245,17 +250,18 @@ module Measures
245
250
 
246
251
  code_sets[code_system_name] ||= []
247
252
  code_sets[code_system_name] << code_reference['id']
248
- # Generate a unique number as our fake "oid"
249
- code_guid = SecureRandom.uuid
250
- # Keep a list of generated_guids and a hash of guids with code system names and codes.
251
- single_code_references << { guid: code_guid, code_system_name: code_system_name, code: code_reference['id'] }
252
-
253
- all_codes_and_code_names[code_guid] = code_sets
254
- # Create a new "ValueSet" and "Concept" object and save.
255
- valueSet = HealthDataStandards::SVS::ValueSet.new({oid: code_guid, display_name: code_reference['name'], version: '' ,concepts: [], user_id: user.id})
256
- concept = HealthDataStandards::SVS::Concept.new({code: code_reference['id'], code_system_name: code_system_name, code_system_version: code_system_version, display_name: code_reference['name']})
257
- valueSet.concepts << concept
258
- valueSet.save!
253
+ # Generate a unique number as our fake "oid" based on parameters that identify the DRC
254
+ code_hash = "drc-" + Digest::SHA2.hexdigest("#{code_system_name} #{code_reference['id']} #{code_reference['name']} #{code_system_version}") # Keep a list of generated_guids and a hash of guids with code system names and codes.
255
+ single_code_references << { guid: code_hash, code_system_name: code_system_name, code: code_reference['id'] }
256
+ all_codes_and_code_names[code_hash] = code_sets
257
+ # code_hashs are unique hashes, there's no sense in adding duplicates to the ValueSet collection
258
+ if !HealthDataStandards::SVS::ValueSet.all().where(oid: code_hash, user_id: user.id).first()
259
+ # Create a new "ValueSet" and "Concept" object and save.
260
+ valueSet = HealthDataStandards::SVS::ValueSet.new({oid: code_hash, display_name: code_reference['name'], version: '' ,concepts: [], user_id: user.id})
261
+ concept = HealthDataStandards::SVS::Concept.new({code: code_reference['id'], code_system_name: code_system_name, code_system_version: code_system_version, display_name: code_reference['name']})
262
+ valueSet.concepts << concept
263
+ valueSet.save!
264
+ end
259
265
  end
260
266
  end
261
267
  end
@@ -24,4 +24,31 @@ class CQLLoaderTest < ActiveSupport::TestCase
24
24
  assert_equal [], cql_statement_dependencies['Hospice']['Has Hospice']
25
25
  end
26
26
  end
27
+
28
+
29
+ test 'Loading a measure with a direct reference code handles the creation of code_list_id hash properly' do
30
+ direct_reference_mat_export = File.new File.join('test', 'fixtures', 'CMS158_v5_4_Artifacts_Update.zip')
31
+ VCR.use_cassette('valid_vsac_response_158_update') do
32
+ dump_db
33
+ user = User.new
34
+ user.save
35
+
36
+ measure_details = { 'episode_of_care'=> false }
37
+ Measures::CqlLoader.load(direct_reference_mat_export, user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD']).save
38
+ assert_equal 1, CqlMeasure.all.count
39
+ measure = CqlMeasure.all.first
40
+
41
+ # Confirm that the source data criteria with the direct reference code is equal to the expected hash
42
+ assert_equal measure['source_data_criteria']['prefix_5195_3_LaboratoryTestPerformed_70C9F083_14BD_4331_99D7_201F8589059D_source']['code_list_id'], "drc-986ea3d52eddc4927e63b3769b5efbaf38b76b35a9164e447fcde2e4dfd31a0c"
43
+ assert_equal measure['data_criteria']['prefix_5195_3_LaboratoryTestPerformed_70C9F083_14BD_4331_99D7_201F8589059D']['code_list_id'], "drc-986ea3d52eddc4927e63b3769b5efbaf38b76b35a9164e447fcde2e4dfd31a0c"
44
+
45
+ # Re-load the Measure
46
+ Measures::CqlLoader.load(direct_reference_mat_export, user, measure_details, ENV['VSAC_USERNAME'], ENV['VSAC_PASSWORD']).save
47
+ assert_equal 2, CqlMeasure.all.count
48
+ measures = CqlMeasure.all
49
+ # Confirm that the Direct Reference Code, code_list_id hash has not changed between Uploads.
50
+ assert_equal measures[0]['source_data_criteria']['prefix_5195_3_LaboratoryTestPerformed_70C9F083_14BD_4331_99D7_201F8589059D_source']['code_list_id'], measures[1]['source_data_criteria']['prefix_5195_3_LaboratoryTestPerformed_70C9F083_14BD_4331_99D7_201F8589059D_source']['code_list_id']
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
+ end
53
+ end
27
54
  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.1
4
+ version: 2.0.2
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: 2017-12-19 00:00:00.000000000 Z
11
+ date: 2018-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: health-data-standards
@@ -176,6 +176,8 @@ executables: []
176
176
  extensions: []
177
177
  extra_rdoc_files: []
178
178
  files:
179
+ - ".github/CONTRIBUTING.md"
180
+ - ".github/PULL_REQUEST_TEMPLATE.md"
179
181
  - ".gitignore"
180
182
  - ".travis.yml"
181
183
  - Gemfile
@@ -254,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
256
  version: '0'
255
257
  requirements: []
256
258
  rubyforge_project:
257
- rubygems_version: 2.6.12
259
+ rubygems_version: 2.5.2.1
258
260
  signing_key:
259
261
  specification_version: 4
260
262
  summary: A Gem for creating and managing bonnie bundles