change_health 0.8.0 → 0.9.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: ac67086d3b413c76be97296012100a822dc8c803f87c2a36cf66904aef24e9e6
4
- data.tar.gz: 9bb60539514b873f4f254075d671ad70e93ee5c9d6bc3e0dfc7e34bb385a448a
3
+ metadata.gz: 904aa6681679c9892aa03e139a4a903adb04a5f894b205166bbad94c7b2609c2
4
+ data.tar.gz: 51069c6515bbeefa60d50f10b9bc44b0bde77b3028ba93e467e7da23555cb2b7
5
5
  SHA512:
6
- metadata.gz: b68b71dd41df082e4dc349e3fb16da3950805e1f0f767f293ee7c699fe7d1edb960774870cd5b9afb119b8e95194b75c089b4f61bc24644c2c131266b50b0557
7
- data.tar.gz: ce0c9747de2134e13a404702d0af42ab9555bf3555bf0e712ef6bd731bc187f11b5ecaf49a1f5899c508b383f7cbb9ab03ff047862691cc94c7c1bec21f911b3
6
+ metadata.gz: 458730a47ceb33666fd5ee0c625c2b48c64660b1276ad3b58d9caf8c5c2be3190f415e3d7887af956819ecef97a7de23d15db65bcaa3443cf2c19506a81d44d0
7
+ data.tar.gz: 579a1ac6070e74afb2d5c6124102afac5d83e5e6991ea0ab9d4746302125e3cf5251bf76c52acd6c55688afc4bae583bff44b627e26b0c5748d6f9468a81936c
data/CHANGELOG.md CHANGED
@@ -4,9 +4,18 @@ 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
+ ## [0.9.0] - [2020-04-08]
8
+ ### Added
9
+ - Added EligibilityBenefit#medicare?
10
+ - Added EligibilityData#medicare?
11
+
12
+ ### Changed
13
+ - EligibilityBenefit(s)#individual returns true for medicare in benefit and queries that look for 'IND'
14
+ - EligibilityBenefit(s)#in\_network returns true for medicare in benefit and queries that look for 'Y'
15
+
7
16
  ## [0.8.0] - [2020-04-04]
8
17
  ### Changed
9
- - Attemp to serialize all properties with 'date' in the name to ChangeHealth date format
18
+ - Attempt to serialize all properties with 'date' in the name to ChangeHealth date format
10
19
 
11
20
  ## [0.7.0] - [2020-04-03]
12
21
  ### Changed
@@ -39,6 +39,11 @@ module ChangeHealth
39
39
  year: YEAR,
40
40
  remaining: REMAINING
41
41
  }
42
+ MEDICARE = {
43
+ part_a: 'MA',
44
+ part_b: 'MB',
45
+ primary: 'MP'
46
+ }
42
47
  HELPERS = {
43
48
  timeQualifierCode: TIMEFRAMES,
44
49
  coverageLevelCode: COVERAGES,
@@ -48,27 +53,32 @@ module ChangeHealth
48
53
  HELPERS.each do |key, types|
49
54
  types.each do |method, value|
50
55
  define_method("#{method}?") do
51
- value == self[key]
56
+ value == self[key] || :individual == method && self[key].nil? && self.medicare?
52
57
  end
53
58
  end
54
59
  end
55
60
 
61
+ def medicare?
62
+ MEDICARE.values.include?(self.insuranceTypeCode)
63
+ end
64
+
56
65
  %w(benefitAmount benefitPercent).each do |amount_method|
57
66
  define_method("#{amount_method}") do
58
67
  format_amount(amount_method)
59
68
  end
60
69
  end
61
70
 
62
- %w(insuranceType benefitsDateInformation).each do |method|
71
+ %w(insuranceType insuranceTypeCode benefitsDateInformation).each do |method|
63
72
  define_method("#{method}") do
64
73
  self[method]
65
74
  end
66
75
  end
67
76
  alias_method :date_info, :benefitsDateInformation
68
77
  alias_method :insurance_type, :insuranceType
78
+ alias_method :insurance_type_code, :insuranceTypeCode
69
79
 
70
80
  def in_plan_network?
71
- return 'Y' == self[:inPlanNetworkIndicatorCode]
81
+ return 'Y' == self[:inPlanNetworkIndicatorCode] || self[:inPlanNetworkIndicatorCode].nil? && self.medicare?
72
82
  end
73
83
  alias_method :in_plan?, :in_plan_network?
74
84
  alias_method :in_network?, :in_plan_network?
@@ -92,6 +102,19 @@ module ChangeHealth
92
102
  alias_method :plan_end_date, :planEnd
93
103
  alias_method :service_date, :service
94
104
 
105
+ def plan_date_range
106
+ pd = self.date_info&.dig('plan') || ''
107
+ pd.split('-')
108
+ end
109
+
110
+ def plan_date_range_start
111
+ ChangeHealth::Models::EligibilityData::PARSE_DATE.call(self.plan_date_range[0])
112
+ end
113
+
114
+ def plan_date_range_end
115
+ ChangeHealth::Models::EligibilityData::PARSE_DATE.call(self.plan_date_range[1])
116
+ end
117
+
95
118
  private
96
119
  def format_amount(key)
97
120
  amt = self[key]
@@ -65,9 +65,17 @@ module ChangeHealth
65
65
  else
66
66
  if v.is_a?(Array)
67
67
  return v.include?(benefit[k])
68
- else
69
- return v == benefit[k]
68
+ elsif benefit.medicare?
69
+ if :inPlanNetworkIndicatorCode == k.to_sym
70
+ return false == benefit.in_plan_network? if 'N' == v
71
+ return benefit.in_plan_network? if 'Y' == v
72
+ elsif :coverageLevelCode == k.to_sym
73
+ return false == benefit.individual? if EligibilityBenefit::INDIVIDUAL != v
74
+ return benefit.individual? if EligibilityBenefit::INDIVIDUAL == v
75
+ end
70
76
  end
77
+
78
+ return v == benefit[k]
71
79
  end
72
80
  end
73
81
  end
@@ -39,6 +39,23 @@ module ChangeHealth
39
39
  return PARSE_DATE.call(self.date_info&.dig(f))
40
40
  end
41
41
  end
42
+ alias_method :eligibility_begin_date, :eligibilityBegin
43
+ alias_method :plan_begin_date, :planBegin
44
+ alias_method :service_date, :service
45
+
46
+ def plan_date_range
47
+ pd = self.date_info&.dig('plan') || ''
48
+ pd.split('-')
49
+ end
50
+
51
+ def plan_date_range_start
52
+ ChangeHealth::Models::EligibilityData::PARSE_DATE.call(self.plan_date_range[0])
53
+ end
54
+
55
+ def plan_date_range_end
56
+ ChangeHealth::Models::EligibilityData::PARSE_DATE.call(self.plan_date_range[1])
57
+ end
58
+
42
59
 
43
60
  def plan_status(service_code: )
44
61
  self.planStatus&.find {|plan| plan.dig('serviceTypeCodes').include?(service_code) } || {}
@@ -48,13 +65,14 @@ module ChangeHealth
48
65
  ChangeHealth::Models::EligibilityBenefits.new(self.benefitsInformation || [])
49
66
  end
50
67
 
68
+ def medicare?
69
+ false == benefits.empty? && benefits.all? {|b| b.medicare? }
70
+ end
71
+
51
72
  alias_method :control_number, :controlNumber
52
73
  alias_method :benefits_information, :benefitsInformation
53
74
  alias_method :plan_statuses, :planStatus
54
75
  alias_method :date_info, :planDateInformation
55
- alias_method :eligibility_begin_date, :eligibilityBegin
56
- alias_method :plan_begin_date, :planBegin
57
- alias_method :service_date, :service
58
76
  end
59
77
  end
60
78
  end
@@ -1,3 +1,3 @@
1
1
  module ChangeHealth
2
- VERSION = '0.8.0'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Crockett
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-04-03 00:00:00.000000000 Z
11
+ date: 2020-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty