Class: HCA::EnrollmentEligibility::Service

Inherits:
Common::Client::Base show all
Includes:
Common::Client::Concerns::Monitoring
Defined in:
lib/hca/enrollment_eligibility/service.rb

Constant Summary collapse

XPATH_PREFIX =
'env:Envelope/env:Body/getEESummaryResponse/summary/'
STATSD_KEY_PREFIX =
'api.hca_ee'
NAME_MAPPINGS =
[
  %i[first givenName],
  %i[middle middleName],
  %i[last familyName],
  %i[suffix suffix]
].freeze
INSURANCE_MAPPINGS =

left API key, right schema key

{
  'companyName' => 'insuranceName',
  'policyNumber' => 'insurancePolicyNumber',
  'policyHolderName' => 'insurancePolicyHolderName',
  'groupNumber' => 'insuranceGroupCode'
}.freeze
MARITAL_STATUSES =
%w[
  Married
  Never Married
  Separated
  Widowed
  Divorced
].freeze
MEDICARE =
'Medicare'

Instance Method Summary collapse

Methods included from Common::Client::Concerns::Monitoring

#with_monitoring

Methods inherited from Common::Client::Base

configuration, #raise_backend_exception

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Instance Method Details

#get_ezr_data(icn) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/hca/enrollment_eligibility/service.rb', line 41

def get_ezr_data(icn)
  response = with_monitoring do
    lookup_user_req(icn)
  end

  providers = parse_insurance_providers(response)
  dependents = parse_dependents(response)
  spouse = parse_spouse(response)

  OpenStruct.new(
    convert_insurance_hash(
      response, providers
    ).merge(
      dependents.present? ? { dependents: } : {}
    ).merge(spouse)
  )
end

#lookup_user(icn) ⇒ Object

rubocop:disable Metrics/MethodLength



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/hca/enrollment_eligibility/service.rb', line 60

def lookup_user(icn)
  response = with_monitoring do
    lookup_user_req(icn)
  end

  {
    enrollment_status: get_xpath(
      response,
      "#{XPATH_PREFIX}enrollmentDeterminationInfo/enrollmentStatus"
    ),
    application_date: get_xpath(
      response,
      "#{XPATH_PREFIX}enrollmentDeterminationInfo/applicationDate"
    ),
    enrollment_date: get_xpath(
      response,
      "#{XPATH_PREFIX}enrollmentDeterminationInfo/enrollmentDate"
    ),
    preferred_facility: get_xpath(
      response,
      "#{XPATH_PREFIX}demographics/preferredFacility"
    ),
    ineligibility_reason: get_xpath(
      response,
      "#{XPATH_PREFIX}enrollmentDeterminationInfo/ineligibilityFactor/reason"
    ),
    effective_date: get_xpath(
      response,
      "#{XPATH_PREFIX}enrollmentDeterminationInfo/effectiveDate"
    ),
    primary_eligibility: get_xpath(
      response,
      "#{XPATH_PREFIX}enrollmentDeterminationInfo/primaryEligibility/type"
    ),
    veteran: get_xpath(
      response,
      "#{XPATH_PREFIX}enrollmentDeterminationInfo/veteran"
    ),
    priority_group: get_xpath(
      response,
      "#{XPATH_PREFIX}enrollmentDeterminationInfo/priorityGroup"
    ),
    can_submit_financial_info: !income_year_is_last_year?(response)
  }
end