cqm-parsers 2.0.0 → 3.2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d83d5f1f9b8c3ee8b00ff2acf4340976cf4055ab43e9ab9cf178d91dc62feea5
4
- data.tar.gz: 92584ac7191a821a1cce7fff38805f526838b10555b184b643fcb3b479310b32
3
+ metadata.gz: 6de99bcf8dba65f0da5a44d71f6967cbe3c40e8b6c467fb1fb65bba22ba86050
4
+ data.tar.gz: 1cadc5ce07faae95299f4efeb1652dd0820c9f523e901a889653418be46acb2d
5
5
  SHA512:
6
- metadata.gz: 0fb80c3815803eb39df96cfee2dda409e3c8d3b675148d8aee06b5fc081ebe8996e952045cc8c0344204c29d02d449063c01850359b009de53bdae8a7f4a262c
7
- data.tar.gz: bcb9fa25b6d7c1ae6f9d31dfacd1a242a945a0b91d2c2e46fe58a6ea4e487dde327eee0d8b88b7ad67a70cdfb1482e50f09adbd924e5f2da3c9deb90f0d0a821
6
+ metadata.gz: c913a38c874d237033884e91eaaea893df6d7a675e981bf49a909fb3110cddd739438e7fca596e486aade40758a3d41daed619a34e5db4816694038077319dd4
7
+ data.tar.gz: 01b49c6290a42e6e776b6f791c89724e41121926726d3ef50d8b962dfe19f00090ed3748e286b204b529a09a68b2ac4c5a0a1bc96bd8794d185f7dc96acb9bba
data/Gemfile CHANGED
@@ -2,9 +2,9 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec :development_group => :test
4
4
 
5
- gem 'mongoid', '~> 6.4.2'
5
+ gem 'mongoid', '~> 7.0.5'
6
6
 
7
- gem 'cqm-models', '~> 2.0.0'
7
+ # gem 'cqm-models', '~> 3.0.0'
8
8
  # gem 'cqm-models', git: 'https://github.com/projecttacoma/cqm-models.git', branch: 'master'
9
9
  # gem 'cqm-models', :path => '../cqm-models'
10
10
 
data/README.md CHANGED
@@ -42,9 +42,22 @@ bundle exec rake test
42
42
 
43
43
  ```
44
44
 
45
+
45
46
  ## Versioning
46
47
 
47
- We use [SemVer](http://semver.org/) for versioning. For the versions available, see [tags on this repository](https://github.com/projecttacoma/cqm-parsers/tags).
48
+ Starting with version **2.0.0** released on 6/20/19, cqm-parsers versioning has the format **X.Y.Z**, where:
49
+
50
+ * **X** maps to a version of the CQL-based HQMF IG. See the table below to see the existing mapping to CQL-based HQMF IG versions.
51
+
52
+ | X | CQL-based HQMF IG|
53
+ | --- | --- |
54
+ | 2 | R1 STU3 |
55
+
56
+ * **Y** indicates major changes (incompatible API changes)
57
+
58
+ * **Z** indicates minor changes (added functionality in a backwards-compatible manner) and patch changes (backwards-compatible bug fixes)
59
+
60
+ For the versions available, see [tags on this repository](https://github.com/projecttacoma/cqm-parsers/tags).
48
61
 
49
62
  ## License
50
63
 
File without changes
@@ -74,7 +74,7 @@ module HQMF2
74
74
  fail 'Measure Observations criteria is missing computed expression(s) ' if exp.nil?
75
75
  parts = exp.to_s.split('-')
76
76
  dc = parse_parts_to_dc(parts)
77
- @doc.add_data_criteria(dc)
77
+ @doc.add_data_criteria(dc) unless dc.nil?
78
78
  # Update reference_ids with any newly referenced data criteria
79
79
  dc.children_criteria.each { |cc| @doc.add_reference_id(cc) } unless dc&.children_criteria.nil?
80
80
  dc
@@ -11,7 +11,7 @@ module HQMF2CQL
11
11
  end
12
12
 
13
13
  # Extracts potential measure observations from the CQL based HQMF.
14
- # This function needs to return a boolean so that it will continue to work with
14
+ # This function needs to return a boolean so that it will continue to work with
15
15
  # HQMF2::DocumentPopulationHelper::extract_populations_and_criteria
16
16
  # This function is being overridden because in CQL the observations are no longer data criteria in the HQMF.
17
17
  def extract_observations
@@ -22,10 +22,10 @@ module HQMF2CQL
22
22
  observation_section = @doc.xpath('/cda:QualityMeasureDocument/cda:component/cda:measureObservationSection',
23
23
  HQMF2::Document::NAMESPACES)
24
24
  unless observation_section.empty?
25
- observation_section.each do |entry|
25
+ observation_section.xpath('cda:definition').each do |obs_def|
26
26
  # Need to add population criteria for observations
27
27
  criteria_id = 'OBSERV'
28
- criteria = HQMF2::PopulationCriteria.new(entry.xpath('cda:definition'), @document, @id_generator)
28
+ criteria = HQMF2::PopulationCriteria.new(obs_def, @document, @id_generator)
29
29
  criteria.type = 'OBSERV'
30
30
  if @ids_by_hqmf_id["#{criteria.hqmf_id}"]
31
31
  criteria.create_human_readable_id(@ids_by_hqmf_id[criteria.hqmf_id])
@@ -39,16 +39,16 @@ module HQMF2CQL
39
39
  cql_define_function = {}
40
40
  # The at_xpath(...).values returns an array of a single element.
41
41
  # The match returns an array and since we don't want the double quotes we take the second element
42
- cql_define_function[:function_name] = entry.at_xpath("*/cda:measureObservationDefinition/cda:value/cda:expression").values.first.match('\\"([A-Za-z0-9 ]+)\\"')[1]
43
- cql_define_function[:function_aggregation_type] = entry.at_xpath("*/cda:measureObservationDefinition/cda:methodCode/cda:item").attributes['code'].value
44
- cql_define_function[:function_hqmf_oid] = entry.at_xpath("*/cda:measureObservationDefinition/cda:id").attributes['root'].value
42
+ cql_define_function[:function_name] = obs_def.at_xpath("cda:measureObservationDefinition/cda:value/cda:expression").values.first.match('\\"([A-Za-z0-9 ]+)\\"')[1]
43
+ cql_define_function[:function_aggregation_type] = obs_def.at_xpath("cda:measureObservationDefinition/cda:methodCode/cda:item").attributes['code'].value
44
+ cql_define_function[:function_hqmf_oid] = obs_def.at_xpath("cda:measureObservationDefinition/cda:id").attributes['root'].value
45
45
  # The criteria_reference_id is the id of the measurePopulationCriteria that should be used for this observation function
46
- measure_population_id = entry.at_xpath("*/cda:measureObservationDefinition/cda:component/cda:criteriaReference/cda:id").attributes['root'].value
46
+ measure_population_id = obs_def.at_xpath("cda:measureObservationDefinition/cda:component/cda:criteriaReference/cda:id").attributes['root'].value
47
47
  # Get the name of the parameter to the observation function within the measurePopulationCriteria section
48
48
 
49
- measure_population_name = entry.at_xpath("*/cda:measureObservationDefinition/cda:component/cda:criteriaReference/cda:id").attributes['extension'].value
50
- # Get the name of the parameter to the observation function within the relevant population criteria section
51
- cql_define_function[:parameter] = @doc.at_xpath("cda:QualityMeasureDocument/cda:component/cda:populationCriteriaSection/cda:component/cda:#{measure_population_name}Criteria/cda:id[@root = \"#{measure_population_id}\"]/../cda:precondition/cda:criteriaReference/cda:id").attributes['extension'].value.match('\\"([A-Za-z0-9 ]+)\\"')[1]
49
+ measure_population_name = obs_def.at_xpath("cda:measureObservationDefinition/cda:component/cda:criteriaReference/cda:id").attributes['extension'].value
50
+ criteria_reference_id = @doc.at_xpath("cda:QualityMeasureDocument/cda:component/cda:populationCriteriaSection/cda:component/cda:#{measure_population_name}Criteria/cda:id[@root = \"#{measure_population_id}\"]/../cda:precondition/cda:criteriaReference/cda:id")
51
+ cql_define_function[:parameter] = criteria_reference_id.attributes['extension'].value.match('\\"([A-Za-z0-9 ]+)\\"')[1]
52
52
 
53
53
  @observations << cql_define_function
54
54
  end
@@ -53,7 +53,7 @@ module Measures
53
53
 
54
54
  def unzip_measure_zip_into_hash(zip_file)
55
55
  folders = Hash.new { |h, k| h[k] = {files: []} }
56
- Zip::File.open zip_file do |file|
56
+ Zip::File.open zip_file.path do |file|
57
57
  file.each do |f|
58
58
  pn = Pathname(f.name)
59
59
  next if '__MACOSX'.in? pn.each_filename # ignore anything in a __MACOSX folder
@@ -26,7 +26,9 @@ module Measures
26
26
  extract_fields_from_single_code_reference_data_criteria(criteria)
27
27
  end
28
28
  hqmf_template_oid = criteria.at_css('templateId/item')['root']
29
- model = QDM::ModelFinder.by_hqmf_oid(hqmf_template_oid).new(model_fields)
29
+ model = QDM::ModelFinder.by_hqmf_oid(hqmf_template_oid)
30
+ raise "No datatype found for oid #{hqmf_template_oid}. Verify the QDM version of the measure package is correct." if model.nil?
31
+ model = model.new(model_fields)
30
32
  model.description = model.qdmTitle + ': ' + model.description
31
33
  return model
32
34
  end
@@ -42,9 +44,9 @@ module Measures
42
44
  end
43
45
 
44
46
  def extract_fields_from_single_code_reference_data_criteria(criteria)
45
- single_code_reference = criteria.css('value[codeSystem][code]').last || criteria.css('code[codeSystem][code]').last
47
+ single_code_reference = criteria.at_css('value[codeSystem][code]') || criteria.at_css('code[codeSystem][code]')
46
48
  system_id = "#{single_code_reference['codeSystem']}_#{single_code_reference['codeSystemVersion']}".to_sym
47
- concept = @single_code_concepts[system_id][single_code_reference['code'].to_sym]
49
+ concept = @single_code_concepts[system_id][single_code_reference['code'].to_sym] || get_concept_from_participation(criteria.at_css('participation'))
48
50
  value_set = concept._parent
49
51
  return {
50
52
  description: concept.display_name,
@@ -52,6 +54,14 @@ module Measures
52
54
  }
53
55
  end
54
56
 
57
+ # If QDM datatype template in MAT has includeSubTemplate, code gets nested into participation
58
+ # this method gets the codes from participation and form the code concept
59
+ def get_concept_from_participation(participation)
60
+ code_element = participation.at_css('code')
61
+ system_id = "#{code_element['codeSystem']}_#{code_element['codeSystemVersion']}".to_sym
62
+ @single_code_concepts[system_id][code_element['code'].to_sym]
63
+ end
64
+
55
65
  def map_single_code_concepts(value_sets_from_single_code_references)
56
66
  single_code_concepts = {}
57
67
  value_sets_from_single_code_references.flat_map(&:concepts).each do |concept|
data/lib/tasks/hqmf.rake CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'fileutils'
3
3
  require 'json'
4
- require 'hqmf-parser'
4
+ require 'cqm-parsers'
5
5
 
6
6
  namespace :hqmf do
7
7
 
data/lib/util/vsac_api.rb CHANGED
@@ -138,7 +138,7 @@ module Util
138
138
  # Gets the details for a program. This may be used without credentials.
139
139
  #
140
140
  # Optional parameter program is the program to request from the API. If it is not provided it will look for
141
- # a :program in the config passed in during construction. If there is no :program in the config it will use
141
+ # a :program in the config passed in during construction. If there is no :program in the config it will use
142
142
  # the DEFAULT_PROGRAM constant for the program.
143
143
  #
144
144
  # Returns the JSON parsed response for program details.
@@ -159,7 +159,7 @@ module Util
159
159
  # }
160
160
  #
161
161
  # Optional parameter program is the program to request from the API. If it is not provided it will look for
162
- # a :program in the config passed in during construction. If there is no :program in the config it will use
162
+ # a :program in the config passed in during construction. If there is no :program in the config it will use
163
163
  # the DEFAULT_PROGRAM constant for the program.
164
164
  #
165
165
  # Returns the name of the latest profile for the given program.
@@ -242,8 +242,8 @@ module Util
242
242
  def get_multiple_valueset_raw_responses(needed_value_sets)
243
243
  service_tickets = get_service_tickets(needed_value_sets.size)
244
244
 
245
- hydra = Typhoeus::Hydra.new # Hydra executes multiple HTTP requests at once
246
- requests = needed_value_sets.map do |n|
245
+ hydra = Typhoeus::Hydra.new(max_concurrency: 1) # Hydra executes multiple HTTP requests at once
246
+ requests = needed_value_sets.map do |n|
247
247
  request = create_valueset_request(n[:value_set][:oid], service_tickets.pop, n[:vs_vsac_options])
248
248
  hydra.queue(request)
249
249
  request
@@ -258,7 +258,7 @@ module Util
258
258
  def get_service_tickets(amount)
259
259
  raise VSACNoCredentialsError.new unless @ticket_granting_ticket
260
260
  raise VSACTicketExpiredError.new if Time.now > @ticket_granting_ticket[:expires]
261
-
261
+
262
262
  hydra = Typhoeus::Hydra.new # Hydra executes multiple HTTP requests at once
263
263
  requests = amount.times.map do
264
264
  request = create_service_ticket_request
@@ -299,7 +299,7 @@ module Util
299
299
 
300
300
  # Create a typheous request for a service ticket (this must be executed later)
301
301
  def create_service_ticket_request
302
- return Typhoeus::Request.new("#{@config[:auth_url]}/Ticket/#{@ticket_granting_ticket[:ticket]}",
302
+ return Typhoeus::Request.new("#{@config[:auth_url]}/Ticket/#{@ticket_granting_ticket[:ticket]}",
303
303
  method: :post,
304
304
  params: { service: TICKET_SERVICE_PARAM})
305
305
  end
@@ -307,7 +307,7 @@ module Util
307
307
  # Use your username and password to retrive a ticket granting ticket from VSAC
308
308
  def get_ticket_granting_ticket(username, password)
309
309
  response = Typhoeus.post(
310
- "#{@config[:auth_url]}/Ticket",
310
+ "#{@config[:auth_url]}/Ticket",
311
311
  # looks like typheous sometimes switches the order of username/password when encoding
312
312
  # which vsac cant handle (!?), so encode first
313
313
  body: URI.encode_www_form(username: username, password: password)
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cqm-parsers
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 3.2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - The MITRE Corporation
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-20 00:00:00.000000000 Z
11
+ date: 2021-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cqm-models
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: mustache
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,42 +58,42 @@ dependencies:
44
58
  requirements:
45
59
  - - "~>"
46
60
  - !ruby/object:Gem::Version
47
- version: 6.4.2
61
+ version: 7.0.5
48
62
  type: :runtime
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
66
  - - "~>"
53
67
  - !ruby/object:Gem::Version
54
- version: 6.4.2
68
+ version: 7.0.5
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: mongoid-tree
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: 2.1.1
75
+ version: '2.1'
62
76
  type: :runtime
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: 2.1.1
82
+ version: '2.1'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: activesupport
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
87
  - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '5.0'
89
+ version: '6.0'
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
- version: '5.0'
96
+ version: '6.0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: protected_attributes_continued
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -131,7 +145,7 @@ dependencies:
131
145
  version: 1.8.5
132
146
  - - "<"
133
147
  - !ruby/object:Gem::Version
134
- version: 1.11.0
148
+ version: 1.12.0
135
149
  type: :runtime
136
150
  prerelease: false
137
151
  version_requirements: !ruby/object:Gem::Requirement
@@ -141,7 +155,7 @@ dependencies:
141
155
  version: 1.8.5
142
156
  - - "<"
143
157
  - !ruby/object:Gem::Version
144
- version: 1.11.0
158
+ version: 1.12.0
145
159
  - !ruby/object:Gem::Dependency
146
160
  name: highline
147
161
  requirement: !ruby/object:Gem::Requirement
@@ -162,14 +176,14 @@ dependencies:
162
176
  requirements:
163
177
  - - "~>"
164
178
  - !ruby/object:Gem::Version
165
- version: 1.2.2
179
+ version: '1.3'
166
180
  type: :runtime
167
181
  prerelease: false
168
182
  version_requirements: !ruby/object:Gem::Requirement
169
183
  requirements:
170
184
  - - "~>"
171
185
  - !ruby/object:Gem::Version
172
- version: 1.2.2
186
+ version: '1.3'
173
187
  - !ruby/object:Gem::Dependency
174
188
  name: typhoeus
175
189
  requirement: !ruby/object:Gem::Requirement
@@ -235,6 +249,7 @@ files:
235
249
  - Gemfile
236
250
  - README.md
237
251
  - Rakefile
252
+ - lib/cqm-parsers.rb
238
253
  - lib/ext/data_element.rb
239
254
  - lib/hqmf-model/attribute.rb
240
255
  - lib/hqmf-model/data_criteria.json
@@ -244,7 +259,6 @@ files:
244
259
  - lib/hqmf-model/precondition.rb
245
260
  - lib/hqmf-model/types.rb
246
261
  - lib/hqmf-model/utilities.rb
247
- - lib/hqmf-parser.rb
248
262
  - lib/hqmf-parser/1.0/attribute.rb
249
263
  - lib/hqmf-parser/1.0/comparison.rb
250
264
  - lib/hqmf-parser/1.0/data_criteria.rb
@@ -314,7 +328,7 @@ homepage: https://github.com/projecttacoma/cqm-parsers
314
328
  licenses:
315
329
  - Apache-2.0
316
330
  metadata: {}
317
- post_install_message:
331
+ post_install_message:
318
332
  rdoc_options: []
319
333
  require_paths:
320
334
  - lib
@@ -329,8 +343,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
329
343
  - !ruby/object:Gem::Version
330
344
  version: '0'
331
345
  requirements: []
332
- rubygems_version: 3.0.3
333
- signing_key:
346
+ rubygems_version: 3.1.4
347
+ signing_key:
334
348
  specification_version: 4
335
349
  summary: A library for parsing HQMF documents.
336
350
  test_files: []