change_health 0.12.0 → 1.0.1
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 +4 -4
- data/CHANGELOG.md +36 -1
- data/lib/change_health.rb +1 -0
- data/lib/change_health/extensions.rb +39 -0
- data/lib/change_health/models/eligibility_benefit.rb +3 -0
- data/lib/change_health/models/eligibility_benefits.rb +23 -8
- data/lib/change_health/models/eligibility_data.rb +75 -4
- data/lib/change_health/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c0475b9e925fd6ff896bb48a1d512f41085b35576b91b426b5ef83d567a428b
|
4
|
+
data.tar.gz: 42b48761b66ae58e8c72ec42b99082a20ccdda1f8554068a0981cebd35bd35d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7e2365fa92c0847c9363e518ff52631da5a17501b16d9f93b233edaea374491450d6cd3d9d5b8d91fb78b8dc3c326ab9dd05a1531ea765ad6c54769f2c58fdd
|
7
|
+
data.tar.gz: fec74c0bc9f129ec49632de92d147776d455643b190de8e750a4b5b5a6732b74ef164bdbd788d93345df0688e631f926d30506abc9c46ab0c50323a55ea42146
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,36 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
|
-
|
7
|
+
|
8
|
+
## [1.0.1] - [2021-03-24]
|
9
|
+
### Added
|
10
|
+
- EligibilityData#plan_status - adds ability to select instead of find
|
11
|
+
- EligibilityData#inactive? active? - use new plan_status select
|
12
|
+
|
13
|
+
## [1.0.0] - [2021-03-17]
|
14
|
+
### Added
|
15
|
+
- Model::Error - help with error codes
|
16
|
+
- EligibilityData#recommend_retry? - if it looks like you can retry the exact same request
|
17
|
+
- EligibilityData#inactive? - looks for plan status 6
|
18
|
+
|
19
|
+
## [0.15.0] - [2020-06-12]
|
20
|
+
### Added
|
21
|
+
- Extensions - InNetworkMissing for plans that don't provide in network indicators.
|
22
|
+
|
23
|
+
### Fixed
|
24
|
+
- Bug where active codes with no service codes cause exception.
|
25
|
+
|
26
|
+
## [0.14.0] - [2020-05-07]
|
27
|
+
### Added
|
28
|
+
- Extensions - mixins for common overrides
|
29
|
+
|
30
|
+
## [0.13.0] - [2020-05-05]
|
31
|
+
### Changed
|
32
|
+
- Removed `alias_method` for `where` helpers so you can override a single method
|
33
|
+
- Added type Year to Date type 24
|
34
|
+
- Added type Day type 7
|
35
|
+
|
36
|
+
## [0.12.0] - [2020-04-30]
|
8
37
|
### Added
|
9
38
|
- EligibilityData#errors
|
10
39
|
- EligibilityData#errors?
|
@@ -94,6 +123,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
|
|
94
123
|
- Authentication
|
95
124
|
- Configuration
|
96
125
|
|
126
|
+
[1.0.1]: https://github.com/WeInfuse/change_health/compare/v1.0.0...v1.0.1
|
127
|
+
[1.0.0]: https://github.com/WeInfuse/change_health/compare/v0.15.0...v1.0.0
|
128
|
+
[0.15.0]: https://github.com/WeInfuse/change_health/compare/v0.14.0...v0.15.0
|
129
|
+
[0.14.0]: https://github.com/WeInfuse/change_health/compare/v0.13.0...v0.14.0
|
130
|
+
[0.13.0]: https://github.com/WeInfuse/change_health/compare/v0.12.0...v0.13.0
|
131
|
+
[0.12.0]: https://github.com/WeInfuse/change_health/compare/v0.11.0...v0.12.0
|
97
132
|
[0.11.0]: https://github.com/WeInfuse/change_health/compare/v0.10.0...v0.11.0
|
98
133
|
[0.10.0]: https://github.com/WeInfuse/change_health/compare/v0.9.0...v0.10.0
|
99
134
|
[0.9.0]: https://github.com/WeInfuse/change_health/compare/v0.8.0...v0.9.0
|
data/lib/change_health.rb
CHANGED
@@ -4,6 +4,7 @@ require 'change_health/version'
|
|
4
4
|
require 'change_health/change_health_exception'
|
5
5
|
require 'change_health/connection'
|
6
6
|
require 'change_health/authentication'
|
7
|
+
require 'change_health/extensions'
|
7
8
|
require 'change_health/models/model'
|
8
9
|
require 'change_health/models/eligibility'
|
9
10
|
require 'change_health/models/eligibility_data'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module ChangeHealth
|
2
|
+
module Extensions
|
3
|
+
module InNetworkW
|
4
|
+
def in_network
|
5
|
+
self.where(inPlanNetworkIndicatorCode: 'Y') + self.where(inPlanNetworkIndicatorCode: 'W')
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
module InNetworkMissing
|
10
|
+
def in_network
|
11
|
+
self.where_not(inPlanNetworkIndicatorCode: 'N')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module DeductiblesIgnoreSpecialistZero
|
16
|
+
def deductibles
|
17
|
+
super.where_not(serviceTypeCodes: '98', benefitAmount: '0')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
module CopaymentsIgnoreSpecialistZero
|
22
|
+
def copayments
|
23
|
+
super.where_not(serviceTypeCodes: '98', benefitAmount: '0')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module CoinsurancesIgnoreSpecialistZero
|
28
|
+
def coinsurances
|
29
|
+
super.where_not(serviceTypeCodes: '98', benefitPercent: '0')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
module IndividualsAllNonFamily
|
34
|
+
def individuals
|
35
|
+
self.where_not(coverageLevelCode: 'FAM')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -34,33 +34,48 @@ module ChangeHealth
|
|
34
34
|
end
|
35
35
|
|
36
36
|
%w(family individual employee child employee_and_child).each do |method|
|
37
|
-
|
37
|
+
define_method(method) do
|
38
|
+
self.send("#{method}s")
|
39
|
+
end
|
38
40
|
|
39
41
|
%w(copayment coinsurance).each do |type_mod|
|
40
42
|
method_name = "#{method}_#{type_mod}"
|
41
|
-
alias_name = method_name.gsub('copayment', 'copay')
|
42
43
|
|
43
44
|
define_method(method_name) do |**kwargs|
|
44
45
|
self.send(method).send("#{type_mod}s").where(kwargs).first
|
45
46
|
end
|
46
47
|
|
47
|
-
|
48
|
+
if ('copayment' == type_mod)
|
49
|
+
define_method(method_name.gsub('copayment', 'copay')) do |**kwargs|
|
50
|
+
self.send(method_name, kwargs)
|
51
|
+
end
|
52
|
+
end
|
48
53
|
end
|
49
54
|
|
50
55
|
%w(deductible out_of_pocket).each do |type_mod|
|
51
56
|
%w(year remaining).each do |time_mod|
|
52
57
|
method_name = "#{method}_#{type_mod}_#{time_mod}"
|
53
|
-
alias_name = method_name.gsub('out_of_pocket', 'oop')
|
54
58
|
|
55
59
|
define_method(method_name) do |**kwargs|
|
56
60
|
self.send(method).send("#{type_mod}s").send("#{time_mod}s").where(kwargs).first || self.send(method).send("#{type_mod}s").where(kwargs).first
|
57
61
|
end
|
58
62
|
|
59
|
-
|
63
|
+
if ('out_of_pocket' == type_mod)
|
64
|
+
define_method(method_name.gsub('out_of_pocket', 'oop')) do |**kwargs|
|
65
|
+
self.send(method_name, kwargs)
|
66
|
+
end
|
67
|
+
|
68
|
+
if ('year' == time_mod)
|
69
|
+
define_method(method_name.gsub('out_of_pocket', 'oop').gsub('year', 'total')) do |**kwargs|
|
70
|
+
self.send(method_name, kwargs)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
60
74
|
|
61
|
-
if
|
62
|
-
|
63
|
-
|
75
|
+
if ('year' == time_mod)
|
76
|
+
define_method(method_name.gsub('year', 'total')) do |**kwargs|
|
77
|
+
self.send(method_name, kwargs)
|
78
|
+
end
|
64
79
|
end
|
65
80
|
end
|
66
81
|
end
|
@@ -1,8 +1,55 @@
|
|
1
1
|
module ChangeHealth
|
2
2
|
module Models
|
3
|
+
class Error
|
4
|
+
attr_reader :data
|
5
|
+
|
6
|
+
SIMPLE_RETRY_CODES = %w[
|
7
|
+
42
|
8
|
+
80
|
9
|
+
].freeze
|
10
|
+
|
11
|
+
NO_RESUBMIT_MESSAGES = %w[
|
12
|
+
resubmission not allowed
|
13
|
+
do not resubmit
|
14
|
+
].freeze
|
15
|
+
|
16
|
+
def initialize(data)
|
17
|
+
@data = data
|
18
|
+
end
|
19
|
+
|
20
|
+
def message
|
21
|
+
field_message || code_message
|
22
|
+
end
|
23
|
+
|
24
|
+
def field_message
|
25
|
+
"#{field}: #{description}" if field?
|
26
|
+
end
|
27
|
+
|
28
|
+
def code_message
|
29
|
+
"#{code}: #{description}" if code?
|
30
|
+
end
|
31
|
+
|
32
|
+
def retryable?
|
33
|
+
code? && SIMPLE_RETRY_CODES.include?(code) && followupAction? && NO_RESUBMIT_MESSAGES.none? {|msg| followupAction.downcase.include?(msg) }
|
34
|
+
end
|
35
|
+
|
36
|
+
%w[field description code followupAction location].each do |method_name|
|
37
|
+
define_method("#{method_name}?") do
|
38
|
+
false == send(method_name).nil?
|
39
|
+
end
|
40
|
+
|
41
|
+
define_method("#{method_name}") do
|
42
|
+
@data[method_name]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
3
47
|
class EligibilityData
|
4
48
|
attr_reader :response, :raw
|
5
49
|
|
50
|
+
ACTIVE = '1'
|
51
|
+
INACTIVE = '6'
|
52
|
+
|
6
53
|
PARSE_DATE = ->(d) {
|
7
54
|
begin
|
8
55
|
d = Date.strptime(d, ChangeHealth::Models::DATE_FORMAT)
|
@@ -25,18 +72,38 @@ module ChangeHealth
|
|
25
72
|
end
|
26
73
|
|
27
74
|
def active?(service_code: '30')
|
28
|
-
|
75
|
+
plan_status(service_code: service_code, single: false).any? {|status| ACTIVE == status['statusCode'] }
|
76
|
+
end
|
77
|
+
|
78
|
+
def inactive?(service_code: '30')
|
79
|
+
plan_status(service_code: service_code, single: false).any? {|status| INACTIVE == status['statusCode'] }
|
29
80
|
end
|
30
81
|
|
31
82
|
def errors?
|
32
83
|
self.errors.is_a?(Array) && false == self.errors.empty?
|
33
84
|
end
|
34
85
|
|
86
|
+
def errors
|
87
|
+
errors = @raw.dig('errors') || []
|
88
|
+
|
89
|
+
errors.flatten.map {|error| ChangeHealth::Models::Error.new(error) }
|
90
|
+
end
|
91
|
+
|
92
|
+
def recommend_retry?
|
93
|
+
return false if errors.empty?
|
94
|
+
|
95
|
+
error_codes = errors.select(&:code?)
|
96
|
+
|
97
|
+
return false if error_codes.empty?
|
98
|
+
|
99
|
+
return error_codes.all?(&:retryable?)
|
100
|
+
end
|
101
|
+
|
35
102
|
def dependents?
|
36
103
|
true == self.dependents&.any?
|
37
104
|
end
|
38
105
|
|
39
|
-
%w(planStatus benefitsInformation controlNumber planDateInformation dependents
|
106
|
+
%w(planStatus benefitsInformation controlNumber planDateInformation dependents).each do |v|
|
40
107
|
define_method(v) do
|
41
108
|
@raw.dig(v)
|
42
109
|
end
|
@@ -64,8 +131,12 @@ module ChangeHealth
|
|
64
131
|
ChangeHealth::Models::EligibilityData::PARSE_DATE.call(self.plan_date_range[1])
|
65
132
|
end
|
66
133
|
|
67
|
-
def plan_status(service_code: )
|
68
|
-
|
134
|
+
def plan_status(service_code: , single: true)
|
135
|
+
if true == single
|
136
|
+
self.planStatus&.find {|plan| plan.dig('serviceTypeCodes')&.include?(service_code) } || {}
|
137
|
+
else
|
138
|
+
self.planStatus&.select {|plan| plan.dig('serviceTypeCodes')&.include?(service_code) } || []
|
139
|
+
end
|
69
140
|
end
|
70
141
|
|
71
142
|
def benefits
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: change_health
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Crockett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -146,6 +146,7 @@ files:
|
|
146
146
|
- lib/change_health/authentication.rb
|
147
147
|
- lib/change_health/change_health_exception.rb
|
148
148
|
- lib/change_health/connection.rb
|
149
|
+
- lib/change_health/extensions.rb
|
149
150
|
- lib/change_health/models/eligibility.rb
|
150
151
|
- lib/change_health/models/eligibility_benefit.rb
|
151
152
|
- lib/change_health/models/eligibility_benefits.rb
|
@@ -179,8 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
179
180
|
- !ruby/object:Gem::Version
|
180
181
|
version: '0'
|
181
182
|
requirements: []
|
182
|
-
|
183
|
-
rubygems_version: 2.7.6
|
183
|
+
rubygems_version: 3.1.4
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Ruby wrapper for the ChangeHealth API
|