class ChangeHealthcare::Eligibility::Inspector

Provides basic inspection capabilities for a benefits information response.

Attributes

response[R]

@return [ChangeHealthcare::Eligibility::SwaggerClient::Response]

Public Class Methods

new(response) click to toggle source

Set up an inspector for a response.

@param response [ChangeHealthcare::Eligibility::SwaggerClient::Response]

# File lib/change_healthcare/eligibility/inspector.rb, line 10
def initialize(response)
  @response = response
end

Public Instance Methods

active_coverage?(matcher) click to toggle source

Does this document certify we have coverage for a service type matching the given matcher? `#===` on this matcher should take a string and return a boolean value.

We use `#===` as there's a lot of service type codes, and you might want to use a `Proc`, a `Set`, or a `Regexp` to do your matching.

@param matcher [#===] matcher to match against, using `#===` @return [true,false]

# File lib/change_healthcare/eligibility/inspector.rb, line 23
def active_coverage?(matcher)
  active_coverage_information.any? do |coverage|
    (coverage.service_types || []).any? { |type| matcher === type } # rubocop:disable Style/CaseEquality
  end
end
active_coverage_information() click to toggle source

Benefits Information for active coverage

@return [Array<ChangeHealthcare::Eligibility::SwaggerClient::BenefitsInformation>]

# File lib/change_healthcare/eligibility/inspector.rb, line 63
def active_coverage_information
  benefits_information.select do |bv|
    bv.name == 'Active Coverage'
  end
end
benefits_information() click to toggle source

A list of all benefits information.

@return [Array<ChangeHealthcare::Eligibility::SwaggerClient::BenefitsInformation>]

# File lib/change_healthcare/eligibility/inspector.rb, line 73
def benefits_information
  response.benefits_information || []
end
coinsurance_records() click to toggle source

All BV records for co-insurance.

@return [Array<ChangeHealthcare::Eligibility::SwaggerClient::BenefitsInformation>]

# File lib/change_healthcare/eligibility/inspector.rb, line 43
def coinsurance_records
  benefits_information.select do |bv|
    bv.name = 'Co-Insurance'
  end
end
copayment_records() click to toggle source

All BV records for co-payment.

@return [Array<ChangeHealthcare::Eligibility::SwaggerClient::BenefitsInformation>]

# File lib/change_healthcare/eligibility/inspector.rb, line 53
def copayment_records
  benefits_information.select do |bv|
    bv.name = 'Co-Payment'
  end
end
deductible_records() click to toggle source

All benefits information records that describe a deductible.

@return [Array<ChangeHealthcare::Eligibility::SwaggerClient::BenefitsInformation>]

# File lib/change_healthcare/eligibility/inspector.rb, line 33
def deductible_records
  benefits_information.select do |bv|
    bv.name == 'Deductible'
  end
end