cqm-parsers 4.1.0.2 → 4.1.1.0

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
  SHA256:
3
- metadata.gz: e60a708b2788c37979d5e9d7ce7f70bb32787792d58fd073737a827789778804
4
- data.tar.gz: a7cc6b5ddf58d94b5ae5228670a8eb5a37f31c00d9837bce0a4f6b5d44343ad4
3
+ metadata.gz: 5ab2f0fafb17c1c9415e34a3732ed3c941c57c5efe3efc87509baa866b1df0cb
4
+ data.tar.gz: 821f980170ae280b0bb604a2cb8fe6b577ac1f4d21d6b23ec9deb3bc31c1dcfa
5
5
  SHA512:
6
- metadata.gz: f18c068ea67e2429f6783410c311b7fb8494bc4a08fcc03397c061b95fea31ec1b2339cbe0396916498d53d35a7db8482d1d4cebffe5d45b59e5265514bfd9c6
7
- data.tar.gz: 2af99fdf0c20dd579724d08cda966db616f96e16b02bc93c276043c730e345e5e970b1b3ca8fb8878213a0fab80d97d13c39b94601ece3ab2ce7891a7b34ce90
6
+ metadata.gz: 6ef8af2c1fa8bdd7a6e3abcffb6a01c0ff531a6540cb04bf2a362dc8065d75caf682c0c95efa559ec3e926cdd1ecc52411d65df85e66f6724212da9e63678304
7
+ data.tar.gz: 441a018ffe31ead27d482d0fa70c019739de1ac96dab583cd0c317553af0e4c118c0c4f5e1c9ab62160c052e36630a40c7d45de0db6f99b5a6678eb56978969f
data/Gemfile CHANGED
@@ -2,15 +2,15 @@ source 'https://rubygems.org'
2
2
 
3
3
  gemspec :development_group => :test
4
4
 
5
- gem 'mongoid', '> 6.0.5', '< 8.0.0'
5
+ gem 'mongoid', '> 6.0.5', '< 9.0.0'
6
6
 
7
7
  # gem 'cqm-models', git: 'https://github.com/projecttacoma/cqm-models.git', branch: 'master'
8
8
  # gem 'cqm-models', :path => '../cqm-models'
9
9
 
10
10
  group :development, :test do
11
11
  gem 'bundler-audit'
12
- gem 'rubocop', '~> 0.52.1', require: false
13
- gem 'byebug', '~> 6.0.2', platforms: [:ruby_20, :ruby_21, :ruby_22, :ruby_23]
12
+ gem 'rubocop', '~> 0.63.0', require: false
13
+ gem 'byebug'
14
14
  gem 'pry'
15
15
  gem 'pry-nav'
16
16
  end
@@ -20,7 +20,7 @@ group :development do
20
20
  end
21
21
 
22
22
  group :test do
23
- gem 'factory_girl', '~> 4.1.0'
23
+ gem 'factory_bot'
24
24
  gem 'tailor', '~> 1.1.2'
25
25
  gem 'cane', '~> 2.3.0'
26
26
  gem 'codecov'
@@ -6,8 +6,7 @@ module Measures
6
6
  def initialize(options)
7
7
  options.symbolize_keys!
8
8
  @vsac_options = options[:options]
9
- @vsac_ticket_granting_ticket = options[:ticket_granting_ticket]
10
- @vsac_api_key = options[:api_key]
9
+ @vsac_api_key = options[:vsac_api_key]
11
10
  @vs_model_cache = {}
12
11
  end
13
12
 
@@ -47,7 +46,7 @@ module Measures
47
46
 
48
47
  def load_api
49
48
  return @api if @api.present?
50
- @api = Util::VSAC::VSACAPI.new(config: APP_CONFIG['vsac'], ticket_granting_ticket: @vsac_ticket_granting_ticket, api_key: @vsac_api_key)
49
+ @api = Util::VSAC::VSACAPI.new(config: APP_CONFIG['vsac'], api_key: @vsac_api_key)
51
50
  return @api
52
51
  end
53
52
 
data/lib/util/vsac_api.rb CHANGED
@@ -40,13 +40,6 @@ module Util
40
40
  end
41
41
  end
42
42
 
43
- # Raised when the ticket granting ticket has expired.
44
- class VSACTicketExpiredError < VSACError
45
- def initialize
46
- super('VSAC session expired. Please re-enter credentials and try again.')
47
- end
48
- end
49
-
50
43
  # Raised when the user credentials were invalid.
51
44
  class VSACInvalidCredentialsError < VSACError
52
45
  def initialize
@@ -69,14 +62,13 @@ module Util
69
62
  # The default program to use for get_program_details and get_program_release_names calls.
70
63
  # This can be overriden by providing a :program in the config or by the single optional parameter for those
71
64
  # methods.
72
- DEFAULT_PROGRAM = "CMS eCQM"
65
+ DEFAULT_PROGRAM = "CMS eCQM and Hybrid Measure"
73
66
 
74
67
  # This is the value of the service parameter passed when getting a ticket. This never changes.
75
68
  TICKET_SERVICE_PARAM = "http://umlsks.nlm.nih.gov"
76
69
 
77
- # The ticket granting that will be obtained if needed. Accessible so it may be stored in user session.
78
- # Is a hash of the :ticket and time it :expires.
79
- attr_reader :ticket_granting_ticket
70
+ # Requester UMLS API KEY
71
+ attr_reader :api_key
80
72
 
81
73
  ##
82
74
  # Creates a new VSACAPI. If credentials were provided they are checked now. If no credentials
@@ -91,24 +83,17 @@ module Util
91
83
  unless check_config @config
92
84
  raise VSACArgumentError.new("Required param :config is missing required URLs.")
93
85
  end
86
+ @api_key = options[:api_key]
87
+ validate_api_key_vsac unless options[:api_key].nil?
88
+ end
94
89
 
95
- # if a ticket_granting_ticket was passed in, check it and raise errors if found
96
- # VSAC API Key will be ignored
97
- if !options[:ticket_granting_ticket].nil?
98
- provided_ticket_granting_ticket = options[:ticket_granting_ticket]
99
- if provided_ticket_granting_ticket[:ticket].nil? || provided_ticket_granting_ticket[:expires].nil?
100
- raise VSACArgumentError.new("Optional param :ticket_granting_ticket is missing :ticket or :expires")
101
- end
102
-
103
- raise VSACTicketExpiredError.new if Time.now > provided_ticket_granting_ticket[:expires]
104
-
105
- @ticket_granting_ticket = { ticket: provided_ticket_granting_ticket[:ticket],
106
- expires: provided_ticket_granting_ticket[:expires] }
107
-
108
- # if api key was provided use it to get a ticket granting ticket
109
- elsif !options[:api_key].nil?
110
- @ticket_granting_ticket = get_ticket_granting_ticket(options[:api_key])
111
- end
90
+ ##
91
+ # Attempt to retrieve the ONC Admin Sex VS to verify
92
+ # VSAC connectivity with the supplied UMLS API Key.
93
+ def validate_api_key_vsac
94
+ response = get_multiple_valueset_raw_responses([{value_set: {oid: "2.16.840.1.113762.1.4.1"}, vs_vsac_options: {}}])[0]
95
+ raise VSACInvalidCredentialsError.new if !response.body || response.response_code == 401
96
+ validate_http_status(response.response_code)
112
97
  end
113
98
 
114
99
  ##
@@ -204,8 +189,7 @@ module Util
204
189
  # hash = {vs_vsac_options: ___, value_set: {oid: ___} }
205
190
  #
206
191
  def get_multiple_valuesets(needed_value_sets)
207
- raise VSACNoCredentialsError.new unless @ticket_granting_ticket
208
- raise VSACTicketExpiredError.new if Time.now > @ticket_granting_ticket[:expires]
192
+ raise VSACNoCredentialsError.new unless @api_key
209
193
 
210
194
  vs_responses = get_multiple_valueset_raw_responses(needed_value_sets)
211
195
  vs_datas = [needed_value_sets,vs_responses].transpose.map do |needed_vs,vs_response|
@@ -221,7 +205,7 @@ module Util
221
205
  # Given a raw valueset response, process and validate
222
206
  def process_and_validate_vsac_response(vs_response, expected_oid)
223
207
  raise VSNotFoundError.new(expected_oid) if vs_response.response_code == 404
224
- validate_http_status_for_ticket_based_request(vs_response.response_code)
208
+ validate_http_status_for_apikey_based_request(vs_response.response_code)
225
209
 
226
210
  vs_data = vs_response.body.force_encoding("utf-8")
227
211
  begin
@@ -240,11 +224,9 @@ module Util
240
224
 
241
225
  # Execute bulk requests for valuesets, return the raw Typheous responses (requests executed in parallel)
242
226
  def get_multiple_valueset_raw_responses(needed_value_sets)
243
- service_tickets = get_service_tickets(needed_value_sets.size)
244
-
245
227
  hydra = Typhoeus::Hydra.new(max_concurrency: 1) # Hydra executes multiple HTTP requests at once
246
228
  requests = needed_value_sets.map do |n|
247
- request = create_valueset_request(n[:value_set][:oid], service_tickets.pop, n[:vs_vsac_options])
229
+ request = create_valueset_request(n[:value_set][:oid], n[:vs_vsac_options])
248
230
  hydra.queue(request)
249
231
  request
250
232
  end
@@ -254,28 +236,8 @@ module Util
254
236
  return responses
255
237
  end
256
238
 
257
- # Bulk get an amount of service tickets (requests executed in parallel)
258
- def get_service_tickets(amount)
259
- raise VSACNoCredentialsError.new unless @ticket_granting_ticket
260
- raise VSACTicketExpiredError.new if Time.now > @ticket_granting_ticket[:expires]
261
-
262
- hydra = Typhoeus::Hydra.new # Hydra executes multiple HTTP requests at once
263
- requests = amount.times.map do
264
- request = create_service_ticket_request
265
- hydra.queue(request)
266
- request
267
- end
268
-
269
- hydra.run
270
- tickets = requests.map do |request|
271
- validate_http_status_for_ticket_based_request(request.response.response_code)
272
- request.response.body
273
- end
274
- return tickets
275
- end
276
-
277
239
  # Create a typheous request for a valueset (this must be executed later)
278
- def create_valueset_request(oid, ticket, options = {})
240
+ def create_valueset_request(oid, options = {})
279
241
  # base parameter oid is always needed
280
242
  params = { id: oid }
281
243
  # release parameter, should be used moving forward
@@ -292,34 +254,16 @@ module Util
292
254
 
293
255
  # version parameter, rarely used
294
256
  params[:version] = options[:version] unless options[:version].nil?
295
- params[:ticket] = ticket
296
257
 
297
- return Typhoeus::Request.new("#{@config[:content_url]}/RetrieveMultipleValueSets", params: params)
258
+ return Typhoeus::Request.new("#{@config[:content_url]}/RetrieveMultipleValueSets",
259
+ params: params,
260
+ userpwd: "apikey:#{@api_key}")
298
261
  end
299
262
 
300
- # Create a typheous request for a service ticket (this must be executed later)
301
- def create_service_ticket_request
302
- return Typhoeus::Request.new("#{@config[:auth_url]}/Ticket/#{@ticket_granting_ticket[:ticket]}",
303
- method: :post,
304
- params: { service: TICKET_SERVICE_PARAM})
305
- end
306
-
307
- # Use your API Key to retrive a ticket granting ticket from VSAC
308
- def get_ticket_granting_ticket(api_key)
309
- response = Typhoeus.post(
310
- "#{@config[:auth_url]}/Ticket",
311
- body: URI.encode_www_form(apikey: api_key)
312
- )
313
- raise VSACInvalidCredentialsError.new if response.response_code == 401
314
- validate_http_status(response.response_code)
315
- return { ticket: String.new(response.body), expires: Time.now + 8.hours }
316
- end
317
-
318
- # Raise errors if http_status is not OK (200), and expire TGT if auth fails
319
- def validate_http_status_for_ticket_based_request(http_status)
263
+ # Raise errors if http_status is not OK (200)
264
+ def validate_http_status_for_apikey_based_request(http_status)
320
265
  if http_status == 401
321
- @ticket_granting_ticket[:expires] = Time.now
322
- raise VSACTicketExpiredError.new
266
+ raise VSACInvalidCredentialsError.new
323
267
  end
324
268
  validate_http_status(http_status)
325
269
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cqm-parsers
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0.2
4
+ version: 4.1.1.0
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: 2023-03-13 00:00:00.000000000 Z
11
+ date: 2024-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cqm-models
@@ -61,7 +61,7 @@ dependencies:
61
61
  version: 6.0.5
62
62
  - - "<"
63
63
  - !ruby/object:Gem::Version
64
- version: 8.0.0
64
+ version: 9.0.0
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
@@ -71,21 +71,21 @@ dependencies:
71
71
  version: 6.0.5
72
72
  - - "<"
73
73
  - !ruby/object:Gem::Version
74
- version: 8.0.0
74
+ version: 9.0.0
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: mongoid-tree
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: 2.1.0
81
+ version: 2.2.0
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: 2.1.0
88
+ version: 2.2.0
89
89
  - !ruby/object:Gem::Dependency
90
90
  name: activesupport
91
91
  requirement: !ruby/object:Gem::Requirement
@@ -134,20 +134,14 @@ dependencies:
134
134
  requirements:
135
135
  - - ">="
136
136
  - !ruby/object:Gem::Version
137
- version: 1.8.5
138
- - - "<"
139
- - !ruby/object:Gem::Version
140
- version: 1.15.0
137
+ version: 1.16.2
141
138
  type: :runtime
142
139
  prerelease: false
143
140
  version_requirements: !ruby/object:Gem::Requirement
144
141
  requirements:
145
142
  - - ">="
146
143
  - !ruby/object:Gem::Version
147
- version: 1.8.5
148
- - - "<"
149
- - !ruby/object:Gem::Version
150
- version: 1.15.0
144
+ version: 1.16.2
151
145
  - !ruby/object:Gem::Dependency
152
146
  name: highline
153
147
  requirement: !ruby/object:Gem::Requirement
@@ -335,7 +329,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
335
329
  - !ruby/object:Gem::Version
336
330
  version: '0'
337
331
  requirements: []
338
- rubygems_version: 3.1.6
332
+ rubygems_version: 3.1.4
339
333
  signing_key:
340
334
  specification_version: 4
341
335
  summary: A library for parsing HQMF documents.