change_health 6.1.1 → 6.1.2

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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/Gemfile +12 -0
  4. data/Rakefile +2 -0
  5. data/change_health.gemspec +8 -9
  6. data/lib/change_health/authentication.rb +20 -16
  7. data/lib/change_health/change_health_exception.rb +15 -12
  8. data/lib/change_health/connection.rb +5 -1
  9. data/lib/change_health/extensions.rb +5 -3
  10. data/lib/change_health/models/claim/submission/address.rb +2 -0
  11. data/lib/change_health/models/claim/submission/billing_pay_to_address_name.rb +2 -0
  12. data/lib/change_health/models/claim/submission/claim_code_information.rb +2 -0
  13. data/lib/change_health/models/claim/submission/claim_date_information.rb +2 -0
  14. data/lib/change_health/models/claim/submission/claim_information.rb +2 -0
  15. data/lib/change_health/models/claim/submission/claim_supplemental_information.rb +2 -0
  16. data/lib/change_health/models/claim/submission/contact_information.rb +2 -0
  17. data/lib/change_health/models/claim/submission/dependent.rb +2 -0
  18. data/lib/change_health/models/claim/submission/diagnosis.rb +2 -0
  19. data/lib/change_health/models/claim/submission/drug_identification.rb +2 -0
  20. data/lib/change_health/models/claim/submission/institutional_service.rb +2 -0
  21. data/lib/change_health/models/claim/submission/line_adjudication_information.rb +2 -0
  22. data/lib/change_health/models/claim/submission/other_payer_name.rb +2 -0
  23. data/lib/change_health/models/claim/submission/other_subscriber_information.rb +2 -0
  24. data/lib/change_health/models/claim/submission/other_subscriber_name.rb +2 -0
  25. data/lib/change_health/models/claim/submission/professional_service.rb +2 -0
  26. data/lib/change_health/models/claim/submission/provider.rb +2 -0
  27. data/lib/change_health/models/claim/submission/receiver.rb +2 -0
  28. data/lib/change_health/models/claim/submission/report_information.rb +2 -0
  29. data/lib/change_health/models/claim/submission/service_facility_location.rb +2 -0
  30. data/lib/change_health/models/claim/submission/service_line.rb +2 -0
  31. data/lib/change_health/models/claim/submission/submitter.rb +2 -0
  32. data/lib/change_health/models/claim/submission/subscriber.rb +2 -0
  33. data/lib/change_health/models/eligibility/encounter.rb +5 -3
  34. data/lib/change_health/models/eligibility/provider.rb +3 -1
  35. data/lib/change_health/models/eligibility/subscriber.rb +4 -1
  36. data/lib/change_health/models/model.rb +20 -8
  37. data/lib/change_health/models/trading_partner/trading_partner.rb +2 -0
  38. data/lib/change_health/request/eligibility.rb +9 -6
  39. data/lib/change_health/request/report.rb +12 -2
  40. data/lib/change_health/request/submission.rb +10 -8
  41. data/lib/change_health/request/trading_partner.rb +4 -2
  42. data/lib/change_health/response/claim/report/report_277_claim.rb +2 -0
  43. data/lib/change_health/response/claim/report/report_277_data.rb +87 -48
  44. data/lib/change_health/response/claim/report/report_277_info_claim_status.rb +2 -0
  45. data/lib/change_health/response/claim/report/report_277_info_status.rb +2 -0
  46. data/lib/change_health/response/claim/report/report_835_claim.rb +2 -0
  47. data/lib/change_health/response/claim/report/report_835_data.rb +31 -14
  48. data/lib/change_health/response/claim/report/report_835_health_care_check_remark_code.rb +2 -0
  49. data/lib/change_health/response/claim/report/report_835_payment.rb +2 -0
  50. data/lib/change_health/response/claim/report/report_835_provider_adjustment.rb +2 -0
  51. data/lib/change_health/response/claim/report/report_835_service_adjustment.rb +2 -0
  52. data/lib/change_health/response/claim/report/report_835_service_line.rb +2 -0
  53. data/lib/change_health/response/claim/report/report_claim.rb +2 -0
  54. data/lib/change_health/response/claim/report/report_data.rb +4 -1
  55. data/lib/change_health/response/claim/report/report_list_data.rb +3 -3
  56. data/lib/change_health/response/claim/submission/submission_data.rb +8 -8
  57. data/lib/change_health/response/eligibility/eligibility_benefit.rb +38 -35
  58. data/lib/change_health/response/eligibility/eligibility_benefits.rb +66 -47
  59. data/lib/change_health/response/eligibility/eligibility_data.rb +33 -30
  60. data/lib/change_health/response/error.rb +5 -3
  61. data/lib/change_health/response/response_data.rb +6 -2
  62. data/lib/change_health/response/trading_partner/trading_partner_data.rb +2 -0
  63. data/lib/change_health/response/trading_partner/trading_partners_data.rb +5 -1
  64. data/lib/change_health/version.rb +3 -1
  65. data/lib/change_health.rb +9 -7
  66. metadata +8 -97
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c48e5a833ac4455745b3bc9a78e4f928a225a094cfc22b905495a00a6bd59a60
4
- data.tar.gz: 0fffec97226198d5a9d778a4431ebad2ee4323f403ce2c5bf3f8f2b408f3cb68
3
+ metadata.gz: 5b3aeaa4ef2ca260c28862838a67cfb270d8350725af6aed958c519ba9371c3e
4
+ data.tar.gz: 0f27cc0e7f26fdb1a1fca6099dfcb06d903d202c725bd1c1ac3cebe3e3315d40
5
5
  SHA512:
6
- metadata.gz: 4aaddd07aa48dad10b0fd70d6b75cbe0894d14f05b33ee4f0281826b5b4a676ad0160da7a07b6b0cd9c6f201b1bdf689d766904b248c5f601ea768bc03937b97
7
- data.tar.gz: '0999b19cdb5eb21c0d1c5c647bef7d38748049d82a8cf67080d90235319e311ecf83e8237e755af664e00868d5b940355f1ca86b46a626cfb15bdd57c58bdc65'
6
+ metadata.gz: 49d4bbcf780a360836f34792728be99048f1c65988909793c5a0d01ab399aa6e28a044a913f9c813c903d1df5d9e487907b2a09f5f663a56246df262d334185d
7
+ data.tar.gz: 83af98e96baa90258668886c8ca92417670e43d629a2731af7de1223d19830a2d1a43e58aa862bacac97d667a70f98149b020539c9544ac7cf674a51f296b73a
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
+ # [6.1.2] - 2025-07-02
9
+
10
+ Updates ChangeHealth Response error message to return description if field is not found instead of previous behaviour returning nil.
11
+
8
12
  # [6.1.1] - 2025-01-30
9
13
 
10
14
  ### Bug Fix
@@ -780,6 +784,7 @@ Added the ability to hit professional claim submission API. For more details, se
780
784
  * Authentication
781
785
  * Configuration
782
786
 
787
+ [6.1.2]: https://github.com/WeInfuse/change_health/compare/v6.1.1...v6.1.2
783
788
  [6.1.1]: https://github.com/WeInfuse/change_health/compare/v6.1.0...v6.1.1
784
789
  [6.1.0]: https://github.com/WeInfuse/change_health/compare/v6.0.0...v6.1.0
785
790
  [6.0.0]: https://github.com/WeInfuse/change_health/compare/v5.18.0...v6.0.0
data/Gemfile CHANGED
@@ -1,4 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in change_health.gemspec
4
6
  gemspec
7
+
8
+ gem 'bundler', '>=1', '<3'
9
+ gem 'byebug', '~> 11'
10
+ gem 'minitest', '~> 5.0'
11
+ gem 'rake', '~> 13.0'
12
+ gem 'rubocop'
13
+ gem 'rubocop-minitest'
14
+ gem 'rubocop-performance'
15
+ gem 'webmock', '~> 3.1'
16
+ gem 'yard', '~> 0.9'
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'bundler/gem_tasks'
2
4
  require 'rake/testtask'
3
5
 
@@ -1,8 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  lib = File.expand_path('lib', __dir__)
2
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
5
  require 'change_health/version'
4
6
 
5
7
  Gem::Specification.new do |spec|
8
+ spec.required_ruby_version = '>= 2.7.8'
9
+
6
10
  spec.name = 'change_health'
7
11
  spec.version = ChangeHealth::VERSION
8
12
  spec.authors = ['Mike Crockett']
@@ -14,13 +18,14 @@ Gem::Specification.new do |spec|
14
18
  # Prevent pushing this gem to RubyGems.org.
15
19
  if spec.respond_to?(:metadata)
16
20
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
21
+ spec.metadata['rubygems_mfa_required'] = 'true'
17
22
  else
18
23
  raise 'RubyGems 2.0 or newer is required to protect against ' \
19
- 'public gem pushes.'
24
+ 'public gem pushes.'
20
25
  end
21
26
 
22
27
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
- f.match?(%r{^(test|spec|features|bin|helpers|)/}) || f.match?(%r{^(\.[[:alnum:]]+)})
28
+ f.match?(%r{^(test|spec|features|bin|helpers|)/}) || f.match?(/^(\.[[:alnum:]]+)/)
24
29
  end
25
30
 
26
31
  spec.bindir = 'exe'
@@ -28,12 +33,6 @@ Gem::Specification.new do |spec|
28
33
  spec.require_paths = ['lib']
29
34
  spec.licenses = ['MIT']
30
35
 
31
- spec.add_dependency 'httparty', '~> 0.17'
32
36
  spec.add_dependency 'hashie', '~> 3.5'
33
- spec.add_development_dependency 'bundler', '>=1', '<3'
34
- spec.add_development_dependency 'byebug', '~> 11'
35
- spec.add_development_dependency 'minitest', '~> 5.0'
36
- spec.add_development_dependency 'rake', '~> 13.0'
37
- spec.add_development_dependency 'webmock', '~> 3.1'
38
- spec.add_development_dependency 'yard', '~> 0.9'
37
+ spec.add_dependency 'httparty', '~> 0.17'
39
38
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  class Authentication
3
5
  attr_accessor :response
4
6
 
5
- AUTH_ENDPOINT = '/apip/auth/v2/token'.freeze
7
+ AUTH_ENDPOINT = '/apip/auth/v2/token'
6
8
 
7
9
  def initialize
8
10
  @response = nil
@@ -10,16 +12,20 @@ module ChangeHealth
10
12
  end
11
13
 
12
14
  def authenticate(base_uri: nil)
13
- if (self.expires?)
15
+ if expires?
14
16
  base_uri ||= Connection.base_uri
15
17
  request = {
16
- body: { client_id: ChangeHealth.configuration.client_id, client_secret: ChangeHealth.configuration.client_secret, grant_type: ChangeHealth.configuration.grant_type },
18
+ body: {
19
+ client_id: ChangeHealth.configuration.client_id,
20
+ client_secret: ChangeHealth.configuration.client_secret,
21
+ grant_type: ChangeHealth.configuration.grant_type
22
+ },
17
23
  endpoint: AUTH_ENDPOINT
18
24
  }
19
25
 
20
26
  response = Connection.new.request(**request, auth: false, base_uri: base_uri)
21
27
 
22
- if (false == response.ok?)
28
+ if false == response.ok?
23
29
  @response = nil
24
30
  raise ChangeHealthException.from_response(response, msg: 'Authentication')
25
31
  else
@@ -28,36 +34,34 @@ module ChangeHealth
28
34
  end
29
35
  end
30
36
 
31
- return self
37
+ self
32
38
  end
33
39
 
34
40
  def access_token
35
- return @response['access_token'] if @response
41
+ @response['access_token'] if @response
36
42
  end
37
43
 
38
44
  def expires_in
39
- return @response['expires_in'].to_i if @response
45
+ @response['expires_in'].to_i if @response
40
46
  end
41
47
 
42
48
  def token_type
43
- return @response['token_type'] if @response
49
+ @response['token_type'] if @response
44
50
  end
45
51
 
46
52
  def expiry
47
- @request_time + self.expires_in if @request_time && self.expires_in
53
+ @request_time + expires_in if @request_time && expires_in
48
54
  end
49
55
 
50
56
  def expires?(seconds_from_now = 60)
51
- if (self.expiry)
52
- return self.expiry.utc <= (Time.now + seconds_from_now).utc
53
- else
54
- return true
55
- end
57
+ return expiry.utc <= (Time.now + seconds_from_now).utc if expiry
58
+
59
+ true
56
60
  end
57
61
 
58
62
  def access_header
59
- return {
60
- 'Authorization' => "Bearer #{self.access_token}",
63
+ {
64
+ 'Authorization' => "Bearer #{access_token}"
61
65
  }
62
66
  end
63
67
 
@@ -1,22 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
- class ChangeHealthException < Exception
4
+ class ChangeHealthException < StandardError
3
5
  def self.from_response(response, msg: nil)
4
- exception_msg = "Failed #{msg}:"
5
- exception_msg << " HTTP code: #{response.code} MSG: "
6
+ error_msg = nil
6
7
 
7
8
  begin
8
- error_response = response.parsed_response
9
-
10
- if (error_response.is_a?(Hash) && error_response.include?("error_description"))
11
- exception_msg << error_response["error_description"]
12
- else
13
- exception_msg << error_response
14
- end
9
+ error_msg = parse_error_msg(response.parsed_response)
15
10
  rescue JSON::ParserError
16
- exception_msg << response.body
11
+ error_msg = response.body
17
12
  end
18
13
 
19
- return ChangeHealthException.new(exception_msg)
14
+ ChangeHealthException.new("Failed #{msg}: HTTP code: #{response&.code} MSG: #{error_msg}")
15
+ end
16
+
17
+ def self.parse_error_msg(error_response)
18
+ if error_response.is_a?(Hash) && error_response.include?('error_description')
19
+ error_response['error_description']
20
+ else
21
+ error_response
22
+ end
20
23
  end
21
24
  end
22
25
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  class Connection
3
- URI_BUILDER = ->(host) { "https://#{host}apigw.changehealthcare.com/".freeze }
5
+ URI_BUILDER = ->(host) { "https://#{host}apigw.changehealthcare.com/" }
4
6
 
5
7
  QA_ENDPOINT = URI_BUILDER.call('sandbox.')
6
8
  PROD_ENDPOINT = URI_BUILDER.call('')
@@ -13,6 +15,7 @@ module ChangeHealth
13
15
 
14
16
  format :json
15
17
 
18
+ # rubocop:disable Metrics/ParameterLists
16
19
  def request(
17
20
  endpoint:,
18
21
  query: nil,
@@ -30,6 +33,7 @@ module ChangeHealth
30
33
 
31
34
  self.class.send(verb.to_s, endpoint, query: query, body: body, headers: headers, base_uri: base_uri)
32
35
  end
36
+ # rubocop:enable Metrics/ParameterLists
33
37
 
34
38
  def self.endpoint_for(klass, default_endpoint: nil)
35
39
  endpoint_options = ChangeHealth.configuration.endpoints || {}
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Extensions
3
5
  module InNetworkW
4
6
  def in_network
5
- self.where(inPlanNetworkIndicatorCode: 'Y') + self.where(inPlanNetworkIndicatorCode: 'W')
7
+ where(inPlanNetworkIndicatorCode: 'Y') + where(inPlanNetworkIndicatorCode: 'W')
6
8
  end
7
9
  end
8
10
 
9
11
  module InNetworkMissing
10
12
  def in_network
11
- self.where_not(inPlanNetworkIndicatorCode: 'N')
13
+ where_not(inPlanNetworkIndicatorCode: 'N')
12
14
  end
13
15
  end
14
16
 
@@ -32,7 +34,7 @@ module ChangeHealth
32
34
 
33
35
  module IndividualsAllNonFamily
34
36
  def individuals
35
- self.where_not(coverageLevelCode: 'FAM')
37
+ where_not(coverageLevelCode: 'FAM')
36
38
  end
37
39
  end
38
40
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Claim
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Eligibility
@@ -8,9 +10,9 @@ module ChangeHealth
8
10
  property :endDateOfService, from: :end_date_of_service, required: false
9
11
  property :serviceTypeCodes, from: :service_type_codes, required: false
10
12
 
11
- alias_method :dateRange?, :dateRange
12
- alias_method :date_range?, :dateRange
13
- alias_method :service_type_codes, :serviceTypeCodes
13
+ alias dateRange? dateRange
14
+ alias date_range? dateRange
15
+ alias service_type_codes serviceTypeCodes
14
16
 
15
17
  def add_service_type_code(code)
16
18
  self[:serviceTypeCodes] ||= []
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Eligibility
@@ -16,7 +18,7 @@ module ChangeHealth
16
18
  property :serviceProviderNumber, from: :service_provider_number, required: false
17
19
  property :taxId, from: :tax_id, required: false
18
20
 
19
- alias_method :name?, :name
21
+ alias name? name
20
22
  end
21
23
  end
22
24
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  module Eligibility
@@ -14,7 +16,8 @@ module ChangeHealth
14
16
  property :idCard, from: :id_card, required: false
15
17
  property :idCardIssueDate, from: :id_card_issued_date, required: false
16
18
  property :lastName, from: :last_name, required: false
17
- property :medicaidRecipientIdentificationNumber, from: :medicaid_recipient_identification_number, required: false
19
+ property :medicaidRecipientIdentificationNumber, from: :medicaid_recipient_identification_number,
20
+ required: false
18
21
  property :memberId, from: :member_id, required: false
19
22
  property :providerCode, from: :provider_code, required: false
20
23
  property :providerIdentifier, from: :provider_identification, required: false
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
- DATE_FORMAT = '%Y%m%d'.freeze
4
- DATE_HOUR_FORMAT = '%Y%m%d%H%M'.freeze
5
- HOUR_FORMAT = '%H%M'.freeze
5
+ DATE_FORMAT = '%Y%m%d'
6
+ DATE_HOUR_FORMAT = '%Y%m%d%H%M'
7
+ HOUR_FORMAT = '%H%M'
6
8
 
7
9
  # Deprecated should use date_formatter instead
8
10
  DATE_FORMATTER = lambda { |date|
@@ -21,6 +23,7 @@ module ChangeHealth
21
23
  time_formatter(hour, HOUR_FORMAT)
22
24
  end
23
25
 
26
+ # rubocop:disable Lint/SuppressedException
24
27
  def self.time_formatter(time, format)
25
28
  begin
26
29
  time = Time.parse(time) if time.is_a?(String)
@@ -31,7 +34,9 @@ module ChangeHealth
31
34
 
32
35
  time
33
36
  end
37
+ # rubocop:enable Lint/SuppressedException
34
38
 
39
+ # rubocop:disable Lint/SuppressedException
35
40
  PARSE_DATE = lambda { |d|
36
41
  begin
37
42
  d = Date.strptime(d.tr('-', ''), ChangeHealth::Models::DATE_FORMAT)
@@ -40,7 +45,9 @@ module ChangeHealth
40
45
 
41
46
  d
42
47
  }
48
+ # rubocop:enable Lint/SuppressedException
43
49
 
50
+ # rubocop:disable Lint/SuppressedException
44
51
  POSTAL_CODE_FORMATTER = lambda { |postal_code|
45
52
  begin
46
53
  formatted_postal_code = postal_code&.to_s&.tr('-', '')
@@ -48,14 +55,16 @@ module ChangeHealth
48
55
  end
49
56
  formatted_postal_code || postal_code
50
57
  }
58
+ # rubocop:enable Lint/SuppressedException
51
59
 
52
- CONTROL_NUMBER = -> { '%09d' % rand(1_000_000_000) }
60
+ CONTROL_NUMBER = -> { format('%09d', rand(1_000_000_000)) }
53
61
 
54
62
  class Model < Hashie::Trash
55
63
  def to_h
56
64
  self.class.hashify(self)
57
65
  end
58
66
 
67
+ # rubocop:disable Style/MapToHash
59
68
  def self.hashify(model)
60
69
  model.map do |key, value|
61
70
  formatted_value = case value
@@ -75,17 +84,20 @@ module ChangeHealth
75
84
  [key, formatted_value]
76
85
  end.to_h
77
86
  end
87
+ # rubocop:enable Style/MapToHash
78
88
 
79
89
  def self.format_value(key, value)
80
90
  return nil if value == ''
81
91
 
82
- return ChangeHealth::Models.date_hour_formatter(value) if key.to_s.downcase.include?('dateandhour')
92
+ downcased_key = key.to_s.downcase
93
+
94
+ return ChangeHealth::Models.date_hour_formatter(value) if downcased_key.include?('dateandhour')
83
95
 
84
- return ChangeHealth::Models.hour_formatter(value) if key.to_s.downcase.include?('hour')
96
+ return ChangeHealth::Models.hour_formatter(value) if downcased_key.include?('hour')
85
97
 
86
- return ChangeHealth::Models.date_formatter(value) if key.to_s.downcase.include?('date')
98
+ return ChangeHealth::Models.date_formatter(value) if downcased_key.include?('date')
87
99
 
88
- return ChangeHealth::Models::POSTAL_CODE_FORMATTER.call(value) if key.to_s.downcase.include?('postalcode')
100
+ return ChangeHealth::Models::POSTAL_CODE_FORMATTER.call(value) if downcased_key.include?('postalcode')
89
101
 
90
102
  value
91
103
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Models
3
5
  class TradingPartner < Hashie::Trash
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Request
3
5
  class Eligibility < Hashie::Trash
4
- ENDPOINT = '/medicalnetwork/eligibility/v3'.freeze
5
- HEALTH_CHECK_ENDPOINT = ENDPOINT + '/healthcheck'.freeze
6
+ ENDPOINT = '/medicalnetwork/eligibility/v3'
7
+ HEALTH_CHECK_ENDPOINT = "#{ENDPOINT}/healthcheck"
6
8
 
7
9
  property :controlNumber, from: :control_number, required: true, default: ChangeHealth::Models::CONTROL_NUMBER
8
10
  property :dependents, required: false
@@ -16,8 +18,8 @@ module ChangeHealth
16
18
  property :tradingPartnerId, from: :trading_partner_id, required: false
17
19
  property :tradingPartnerServiceId, from: :trading_partner_service_id, required: false
18
20
 
19
- alias_method :partnerId?, :partnerId
20
- alias_method :partner_id?, :partnerId
21
+ alias partnerId? partnerId
22
+ alias partner_id? partnerId
21
23
 
22
24
  def add_dependent(dependent)
23
25
  self[:dependents] ||= []
@@ -27,7 +29,8 @@ module ChangeHealth
27
29
  def query
28
30
  endpoint = ChangeHealth::Connection.endpoint_for(self.class)
29
31
 
30
- ChangeHealth::Response::EligibilityData.new(response: ChangeHealth::Connection.new.request(endpoint: endpoint, body: self.to_h))
32
+ ChangeHealth::Response::EligibilityData.new(response: ChangeHealth::Connection.new.request(endpoint: endpoint,
33
+ body: to_h))
31
34
  end
32
35
 
33
36
  def self.health_check
@@ -35,7 +38,7 @@ module ChangeHealth
35
38
  end
36
39
 
37
40
  def self.ping
38
- self.health_check
41
+ health_check
39
42
  end
40
43
  end
41
44
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ChangeHealth
2
4
  module Request
3
5
  module Claim
4
6
  class Report
5
- ENDPOINT = '/medicalnetwork/reports/v2'.freeze
6
- HEALTH_CHECK_ENDPOINT = ENDPOINT + '/healthcheck'.freeze
7
+ ENDPOINT = '/medicalnetwork/reports/v2'
8
+ HEALTH_CHECK_ENDPOINT = "#{ENDPOINT}/healthcheck"
7
9
 
8
10
  def self.report_list(headers: nil, more_url: nil, base_uri: nil, endpoint: nil, auth_headers: nil)
9
11
  endpoint ||= ChangeHealth::Connection.endpoint_for(self)
@@ -18,6 +20,10 @@ module ChangeHealth
18
20
  ))
19
21
  end
20
22
 
23
+ # rubocop:disable Metrics/CyclomaticComplexity
24
+ # rubocop:disable Metrics/MethodLength
25
+ # rubocop:disable Metrics/PerceivedComplexity
26
+ # rubocop:disable Metrics/ParameterLists
21
27
  def self.get_report(
22
28
  report_name,
23
29
  as_json_report: true,
@@ -67,6 +73,10 @@ module ChangeHealth
67
73
  response: response)
68
74
  end
69
75
  end
76
+ # rubocop:enable Metrics/CyclomaticComplexity
77
+ # rubocop:enable Metrics/MethodLength
78
+ # rubocop:enable Metrics/PerceivedComplexity
79
+ # rubocop:enable Metrics/ParameterLists
70
80
 
71
81
  def self.delete_report(report_name, headers: nil, base_uri: nil, endpoint: nil, auth_headers: nil)
72
82
  return if report_name.nil? || report_name.empty?