change_health 2.0.0 → 2.3.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: 984e07a44c15c8b628c8826d012e5acdee3695ba3a1b0bcdd000d07b0d9f920c
4
- data.tar.gz: af752baf4e2d7e0fe73b77d7a9199feb1f24ea6d9a6be9163d7c87ef6484c8d6
3
+ metadata.gz: 1cd3562c44027bac8e01ce8e9f68b0ec67ea6052f3786181539e9d0b579d10bd
4
+ data.tar.gz: 11760dc5ac46e4bde8d2a98608e83efecd5ba4fee02bfd5dfbfcca63c3902a8f
5
5
  SHA512:
6
- metadata.gz: 76641120792ba599030e2a3875696a2167dbf585095d0cafb7c5961a7f1a55a735769b91bea6cc098710adc418d819b5144ab8f9bbb1272add0f102c6dba2ad2
7
- data.tar.gz: 269647d12a949fc69ec6e1e493d522a13cd7ffdf59fcc2510f285219d1dc7e4a52212b83fdce4fb33fd72b2bcbc75eefa5400df5e0f539dcb7403b1b760cf1a3
6
+ metadata.gz: 7ec84c09d24a87c7d38709eaf6b5fd53ada29455541563f88a760c926a3a29c30bc138e1e0c5f2287368faad53127830eb8c155291118ec9c87b239a2209a2d6
7
+ data.tar.gz: 88a92b73cfb2159b6e091e9ab74b05067c461fa8be27c853a5387646e5049a8d4dc71dd178e6e20b282b50b06116c78b79468531d3340cbd15ac3458775ac5a2
data/CHANGELOG.md CHANGED
@@ -4,7 +4,32 @@ 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
- ## [2.0.0] - [2021-10-08]
7
+ ## [2.3.0] - 2021-11-18
8
+ ### Added
9
+ * Specific classes for 277 & 835 reports - Report277Data & Report835Data
10
+ * ReportClaim & ReportInfoClaimStatus- only works for json 277 reports
11
+
12
+ ### Fixed
13
+ * Headers can now be nil for requests
14
+
15
+ ## [2.2.1] - 2021-11-15
16
+ ### Added
17
+ Custom Headers for Reports API and Professional Claims API
18
+ * Report
19
+ * Submission
20
+
21
+ ## [2.2.0] - 2021-11-04
22
+ ### Added
23
+ Ability to hit [Claim Responses and Reports](https://developers.changehealthcare.com/eligibilityandclaims/docs/claims-responses-and-reports-getting-started)
24
+ * Report
25
+ * ReportListData
26
+ * ReportData
27
+
28
+ ## [2.1.0] - 2021-10-12
29
+ ### Changed
30
+ Model#to_h enhanced to change empty values AKA "" to nil. Reason: If a field is empty, Change Healthcare responds with an error - `Invalid value. Item must not be blank value.`. If the empty field is optional, Change Healthcare will accept the field as nil without error. If the empty field is required, Change Healthcare will return an error if the value is empty or nil.
31
+
32
+ ## [2.0.0] - 2021-10-08
8
33
  ### Added
9
34
  #### Models
10
35
  * ResponseData - for responses from calling change healthcare api used by EligibilityData and SubmissionData
@@ -35,50 +60,50 @@ Added the ability to hit professional claim submission API. For more details, se
35
60
  ### Fixed
36
61
  * Eligibility#add_dependent actually works
37
62
 
38
- ## [1.0.3] - [2021-04-26]
63
+ ## [1.0.3] - 2021-04-26
39
64
  ### Added
40
65
  - Model::Error#represents_down? - adds ability to distinguish error representing down state
41
66
  - Model::Error#retryable? - retryable when down
42
67
  - EligibilityData#recommend_retry? - recommend retry when down
43
68
 
44
- ## [1.0.2] - [2021-04-06]
69
+ ## [1.0.2] - 2021-04-06
45
70
  ### Added
46
71
  - EligibilityData#recommend_retry? - fix a bug in the search statement
47
72
 
48
- ## [1.0.1] - [2021-03-24]
73
+ ## [1.0.1] - 2021-03-24
49
74
  ### Added
50
75
  - EligibilityData#plan_status - adds ability to select instead of find
51
76
  - EligibilityData#inactive? active? - use new plan_status select
52
77
 
53
- ## [1.0.0] - [2021-03-17]
78
+ ## [1.0.0] - 2021-03-17
54
79
  ### Added
55
80
  - Model::Error - help with error codes
56
81
  - EligibilityData#recommend_retry? - if it looks like you can retry the exact same request
57
82
  - EligibilityData#inactive? - looks for plan status 6
58
83
 
59
- ## [0.15.0] - [2020-06-12]
84
+ ## [0.15.0] - 2020-06-12
60
85
  ### Added
61
86
  - Extensions - InNetworkMissing for plans that don't provide in network indicators.
62
87
 
63
88
  ### Fixed
64
89
  - Bug where active codes with no service codes cause exception.
65
90
 
66
- ## [0.14.0] - [2020-05-07]
91
+ ## [0.14.0] - 2020-05-07
67
92
  ### Added
68
93
  - Extensions - mixins for common overrides
69
94
 
70
- ## [0.13.0] - [2020-05-05]
95
+ ## [0.13.0] - 2020-05-05
71
96
  ### Changed
72
97
  - Removed `alias_method` for `where` helpers so you can override a single method
73
98
  - Added type Year to Date type 24
74
99
  - Added type Day type 7
75
100
 
76
- ## [0.12.0] - [2020-04-30]
101
+ ## [0.12.0] - 2020-04-30
77
102
  ### Added
78
103
  - EligibilityData#errors
79
104
  - EligibilityData#errors?
80
105
 
81
- ## [0.11.0] - [2020-04-24]
106
+ ## [0.11.0] - 2020-04-24
82
107
  ### Added
83
108
  - EligibilityData#medicare?
84
109
  - EligibilityData#plan\_id
@@ -93,7 +118,7 @@ Added the ability to hit professional claim submission API. For more details, se
93
118
  - EligibilityData initialize now checks for sub-classes of EligibilityBenefits with trading partner responds to `factory` to choose sub-class
94
119
  - EligibilityBenefits initializes `self.class` type in case it's a subclass
95
120
 
96
- ## [0.10.0] - [2020-04-09]
121
+ ## [0.10.0] - 2020-04-09
97
122
  ### Added
98
123
  - Add Trading Partner API querying capability
99
124
  - Request::TradingPartner
@@ -101,7 +126,7 @@ Added the ability to hit professional claim submission API. For more details, se
101
126
  - Response::TradingPartnersData
102
127
  - Models::TradingPartner
103
128
 
104
- ## [0.9.0] - [2020-04-08]
129
+ ## [0.9.0] - 2020-04-08
105
130
  ### Added
106
131
  - Added EligibilityBenefit#medicare?
107
132
  - Added EligibilityData#medicare?
@@ -110,20 +135,20 @@ Added the ability to hit professional claim submission API. For more details, se
110
135
  - EligibilityBenefit(s)#individual returns true for medicare in benefit and queries that look for 'IND'
111
136
  - EligibilityBenefit(s)#in\_network returns true for medicare in benefit and queries that look for 'Y'
112
137
 
113
- ## [0.8.0] - [2020-04-04]
138
+ ## [0.8.0] - 2020-04-04
114
139
  ### Changed
115
140
  - Attempt to serialize all properties with 'date' in the name to ChangeHealth date format
116
141
 
117
- ## [0.7.0] - [2020-04-03]
142
+ ## [0.7.0] - 2020-04-03
118
143
  ### Changed
119
144
  - Fixed bug in serializing date on subscriber and encounter
120
145
 
121
- ## [0.6.0] - [2020-04-02]
146
+ ## [0.6.0] - 2020-04-02
122
147
  ### Changed
123
148
  - Added Indifferent Access to hashes
124
149
  - Fixed bug with Authentication endpoint
125
150
 
126
- ## [0.5.0] - [2020-03-11]
151
+ ## [0.5.0] - 2020-03-11
127
152
  ### Added
128
153
  - EligibilityBenefit Deductible information
129
154
  - EligibilityBenefit benefits date information
@@ -135,17 +160,17 @@ Added the ability to hit professional claim submission API. For more details, se
135
160
  ### Changed
136
161
  - Broke EligibilityBenefit and EligibilityBenefits into separate files
137
162
 
138
- ## [0.4.0] - [2020-03-10]
163
+ ## [0.4.0] - 2020-03-10
139
164
  ### Added
140
165
  - EligibilityBenefit(s) Employee information
141
166
  - EligibilityData plan date information
142
167
  - EligibilityData eligibility, plan and service date helpers on date info
143
168
 
144
- ## [0.3.0] - [2020-03-09]
169
+ ## [0.3.0] - 2020-03-09
145
170
  ### Added
146
171
  - Production endpoint
147
172
 
148
- ## [0.2.0] - [2020-03-09]
173
+ ## [0.0.2] - 2020-03-09
149
174
  ### Added
150
175
  - EligibilityData
151
176
  - EligibilityBenefit
@@ -154,7 +179,7 @@ Added the ability to hit professional claim submission API. For more details, se
154
179
  ### Changed
155
180
  - Eligibility.query returns EligibilityData object
156
181
 
157
- ## [0.1.0] - 2020-03-04
182
+ ## [0.0.1] - 2020-03-04
158
183
  ### Added
159
184
  - Provider
160
185
  - Subscriber
@@ -163,7 +188,11 @@ Added the ability to hit professional claim submission API. For more details, se
163
188
  - Authentication
164
189
  - Configuration
165
190
 
166
- [Unreleased]: https://github.com/WeInfuse/change_health/compare/v1.0.3...HEAD
191
+ [2.3.0]: https://github.com/WeInfuse/change_health/compare/v2.2.1...v2.3.0
192
+ [2.2.1]: https://github.com/WeInfuse/change_health/compare/v2.2.0...v2.2.1
193
+ [2.2.0]: https://github.com/WeInfuse/change_health/compare/v2.1.0...v2.2.0
194
+ [2.1.0]: https://github.com/WeInfuse/change_health/compare/v2.0.0...v2.1.0
195
+ [2.0.0]: https://github.com/WeInfuse/change_health/compare/v1.0.3...v2.0.0
167
196
  [1.0.3]: https://github.com/WeInfuse/change_health/compare/v1.0.2...v1.0.3
168
197
  [1.0.2]: https://github.com/WeInfuse/change_health/compare/v1.0.1...v1.0.2
169
198
  [1.0.1]: https://github.com/WeInfuse/change_health/compare/v1.0.0...v1.0.1
@@ -180,6 +209,6 @@ Added the ability to hit professional claim submission API. For more details, se
180
209
  [0.6.0]: https://github.com/WeInfuse/change_health/compare/v0.5.0...v0.6.0
181
210
  [0.5.0]: https://github.com/WeInfuse/change_health/compare/v0.4.0...v0.5.0
182
211
  [0.4.0]: https://github.com/WeInfuse/change_health/compare/v0.3.0...v0.4.0
183
- [0.3.0]: https://github.com/WeInfuse/change_health/compare/v0.2.0...v0.3.0
184
- [0.2.0]: https://github.com/WeInfuse/change_health/compare/v0.1.0...v0.2.0
185
- [0.1.0]: https://github.com/WeInfuse/change_health/compare/v0.1.0
212
+ [0.3.0]: https://github.com/WeInfuse/change_health/compare/v0.0.2...v0.3.0
213
+ [0.0.2]: https://github.com/WeInfuse/change_health/compare/v0.0.1...v0.0.2
214
+ [0.0.1]: https://github.com/WeInfuse/change_health/compare/520a8c54d07...v0.0.1
data/README.md CHANGED
@@ -67,13 +67,13 @@ edata.response
67
67
  #<HTTParty::Response:0x7fa354c1fbe8>
68
68
 
69
69
  edata.response.ok?
70
- true
70
+ # true
71
71
 
72
72
  edata.individual_oop_remaining(service_code: '30')
73
- 1344.88
73
+ # 1344.88
74
74
 
75
75
  edata.raw == edata.response.parsed_response
76
- true
76
+ # true
77
77
  ```
78
78
 
79
79
  ### Trading Partners
@@ -83,10 +83,10 @@ true
83
83
  trading_partners = ChangeHealth::Request::TradingPartner.query("Aetna")
84
84
 
85
85
  trading_partners.first.name
86
- "Aetna"
86
+ # "Aetna"
87
87
 
88
88
  trading_partners.first.service_id
89
- "ABC123"
89
+ # "ABC123"
90
90
  ```
91
91
 
92
92
  ### Claim Submission
@@ -174,6 +174,12 @@ claim_information = ChangeHealth::Models::Claim::ClaimInformation.new(
174
174
  service_lines: [service_line1, service_line2]
175
175
  )
176
176
 
177
+ professional_headers = {
178
+ submitter_id: '111000',
179
+ biller_id: '000111',
180
+ username: '222333hey',
181
+ password: 'builder1'
182
+ }
177
183
 
178
184
  claim_submission = ChangeHealth::Request::Claim::Submission.new(
179
185
  trading_partner_service_id: "9496",
@@ -181,10 +187,69 @@ claim_submission = ChangeHealth::Request::Claim::Submission.new(
181
187
  receiver: receiver,
182
188
  subscriber: subscriber,
183
189
  providers: [provider],
184
- claim_information: claim_information
190
+ claim_information: claim_information,
191
+ headers: professional_headers
185
192
  )
186
193
 
187
194
  claim_submission_data = claim_submission.submission
195
+
196
+ validation = claim_submission.validation
197
+ ```
198
+
199
+ ### Claim Reports
200
+ [Change Healthcare Claim Responses and Reports Guide](https://developers.changehealthcare.com/eligibilityandclaims/docs/claims-responses-and-reports-getting-started)
201
+
202
+ #### Get Reports
203
+ ```ruby
204
+ ChangeHealth::Request::Claim::Report.ping # Test your connection
205
+
206
+ report_headers = {
207
+ username: '111000john',
208
+ password: 'WeInfuse1'
209
+ }
210
+
211
+ report_list = ChangeHealth::Request::Claim::Report.report_list(headers: report_headers)
212
+
213
+ report_list.report_names
214
+ # ["X3000000.XX", "R5000000.XY", "R5000000.XX", "X3000000.AB", "X3000000.AC", "X3000000.ZZ", "R5000000.XZ", "R5000000.YZ", "R5000000.WA", "R5000000.WB", "R5000000.WC"]
215
+
216
+ report0_edi = ChangeHealth::Request::Claim::Report.get_report(report_list.report_names.first, as_json_report: false)
217
+ # Report in edi format
218
+
219
+ report0_json = ChangeHealth::Request::Claim::Report.get_report(report_list.report_names.first, as_json_report: true)
220
+ # Report in json format
221
+
222
+ reports_json = report_list.report_names.map {|report_name| ChangeHealth::Request::Claim::Report.get_report(report_name, headers: report_headers)}
223
+ # all reports in json format
224
+
225
+ reports_edi = report_list.report_names.map {|report_name| ChangeHealth::Request::Claim::Report.get_report(report_name, as_json_report: false, headers: report_headers)}
226
+ # all reports in edi format
227
+ ```
228
+
229
+ #### Review Individual Claims
230
+ Currently only works for json 277 reports. json 835 reports coming soon!
231
+
232
+ From a report, you can get an array of claims. For a full list of fields, see `ChangeHealth::Response::Claim::ReportClaim`
233
+
234
+ ```ruby
235
+ report_claims = ChangeHealth::Request::Claim::Report.get_report("X3000000.AB", as_json_report: true).claims
236
+ # list of claims in the report
237
+
238
+ claim = report_claims.first
239
+ claim.payer_org_name
240
+ # "PREMERA"
241
+
242
+ claim.subscriber_first_name
243
+ # "JOHNONE"
244
+
245
+ claim.transaction_set_creation_date
246
+ # Tue, 01 Dec 2020
247
+
248
+ claim.latest_status_category_codes
249
+ # ["F1"]
250
+
251
+ claim.latest_total_charge_amount
252
+ # "100"
188
253
  ```
189
254
 
190
255
  ### Configuration
@@ -193,8 +258,8 @@ claim_submission_data = claim_submission.submission
193
258
  ChangeHealth.configure do |c|
194
259
  c.client_id = ENV['CHANGE_HEALTH_CLIENT_ID']
195
260
  c.client_secret = ENV['CHANGE_HEALTH_SECRET']
196
- c.grant_type = 'bob' # Defaults to client_credentials
197
- c.api_endpoint = 'http://hello.com' # Defaults to Change Health Sandbox endpoint
261
+ c.grant_type = 'client_credentials' # Defaults to client_credentials
262
+ c.api_endpoint = 'https://sandbox.apigw.changehealthcare.com' # Defaults to Change Health Sandbox endpoint
198
263
  end
199
264
  ```
200
265
 
@@ -13,11 +13,12 @@ module ChangeHealth
13
13
 
14
14
  format :json
15
15
 
16
- def request(endpoint: , query: nil, body: nil, headers: {}, auth: true, verb: :post)
16
+ def request(endpoint:, query: nil, body: nil, headers: {}, auth: true, verb: :post)
17
17
  body = body.to_json if body.is_a?(Hash)
18
+ headers = {} if headers.nil?
18
19
  headers = auth_header.merge(headers) if auth
19
20
 
20
- self.class.send("#{verb}", endpoint, query: query, body: body, headers: headers)
21
+ self.class.send(verb.to_s, endpoint, query: query, body: body, headers: headers)
21
22
  end
22
23
 
23
24
  private
@@ -25,7 +26,7 @@ module ChangeHealth
25
26
  def auth_header
26
27
  @auth ||= Authentication.new
27
28
 
28
- return @auth.authenticate.access_header
29
+ @auth.authenticate.access_header
29
30
  end
30
31
  end
31
32
  end
@@ -1,4 +1,5 @@
1
1
  module ChangeHealth
2
+ # TODO: This should be the response module/folder... next major release
2
3
  module Models
3
4
  class Error
4
5
  attr_reader :data
@@ -27,10 +27,11 @@ module ChangeHealth
27
27
  def to_h
28
28
  result = super.to_h
29
29
 
30
- self.class.properties.each do |key|
30
+ self.each_pair do |key, value|
31
31
  if key.to_s.downcase.include?('date')
32
32
  result[key] = ChangeHealth::Models::DATE_FORMATTER.call(result[key])
33
33
  end
34
+ result[key] = nil if value == ""
34
35
  end
35
36
 
36
37
  result
@@ -0,0 +1,60 @@
1
+ module ChangeHealth
2
+ module Request
3
+ module Claim
4
+ class Report
5
+ ENDPOINT = '/medicalnetwork/reports/v2'.freeze
6
+ HEALTH_CHECK_ENDPOINT = ENDPOINT + '/healthcheck'.freeze
7
+
8
+ def self.report_list(headers: nil)
9
+ final_headers = ChangeHealth::Request::Claim::Report.report_headers(headers)
10
+ ChangeHealth::Response::Claim::ReportListData.new(response: ChangeHealth::Connection.new.request(endpoint: ENDPOINT, verb: :get, headers: final_headers))
11
+ end
12
+
13
+ def self.get_report(report_name, as_json_report: true, headers: nil)
14
+ return if report_name.nil? || report_name.empty?
15
+ final_headers = ChangeHealth::Request::Claim::Report.report_headers(headers)
16
+
17
+ report_type = ChangeHealth::Response::Claim::ReportData.report_type(report_name)
18
+ return if report_type.nil?
19
+
20
+ individual_report_endpoint = ENDPOINT + '/' + report_name
21
+
22
+ # https://developers.changehealthcare.com/eligibilityandclaims/docs/what-file-types-does-this-api-get-from-the-mailbox
23
+ individual_report_endpoint += '/' + report_type if as_json_report
24
+
25
+ response = ChangeHealth::Connection.new.request(endpoint: individual_report_endpoint, verb: :get, headers: final_headers)
26
+ if ChangeHealth::Response::Claim::ReportData.is_277?(report_name)
27
+ ChangeHealth::Response::Claim::Report277Data
28
+ .new(report_name,
29
+ as_json_report,
30
+ response: response)
31
+ else
32
+ ChangeHealth::Response::Claim::Report835Data
33
+ .new(report_name,
34
+ as_json_report,
35
+ response: response)
36
+ end
37
+ end
38
+
39
+ def self.health_check
40
+ ChangeHealth::Connection.new.request(endpoint: HEALTH_CHECK_ENDPOINT, verb: :get)
41
+ end
42
+
43
+ def self.ping
44
+ self.health_check
45
+ end
46
+
47
+ def self.report_headers(headers)
48
+ if headers
49
+ extra_headers = {}
50
+ extra_headers["X-CHC-Reports-Username"] = headers[:username]
51
+ extra_headers["X-CHC-Reports-Password"] = headers[:password]
52
+ extra_headers
53
+ else
54
+ nil
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -2,9 +2,11 @@ module ChangeHealth
2
2
  module Request
3
3
  module Claim
4
4
  class Submission < Hashie::Trash
5
+
5
6
  ENDPOINT = '/medicalnetwork/professionalclaims/v3'.freeze
6
7
  HEALTH_CHECK_ENDPOINT = ENDPOINT + '/healthcheck'.freeze
7
8
  SUBMISSION_ENDPOINT = ENDPOINT + '/submission'.freeze
9
+ VALIDATION_ENDPOINT = ENDPOINT + '/validation'.freeze
8
10
 
9
11
  property :claimInformation, from: :claim_information, required: false
10
12
  property :controlNumber, from: :control_number, required: true, default: ChangeHealth::Models::CONTROL_NUMBER
@@ -12,6 +14,7 @@ module ChangeHealth
12
14
  property :receiver, required: false
13
15
  property :submitter, required: false
14
16
  property :subscriber, required: false
17
+ property :headers, required: false
15
18
  # Need one or the other, trading partner id or trading partner service id
16
19
  property :tradingPartnerId, from: :trading_partner_id, required: false
17
20
  property :tradingPartnerServiceId, from: :trading_partner_service_id, required: false
@@ -22,7 +25,11 @@ module ChangeHealth
22
25
  end
23
26
 
24
27
  def submission
25
- ChangeHealth::Response::Claim::SubmissionData.new(response: ChangeHealth::Connection.new.request(endpoint: SUBMISSION_ENDPOINT, body: self.to_h))
28
+ ChangeHealth::Response::Claim::SubmissionData.new(response: ChangeHealth::Connection.new.request(endpoint: SUBMISSION_ENDPOINT, body: self.to_h, headers: professional_headers))
29
+ end
30
+
31
+ def validation
32
+ ChangeHealth::Response::Claim::SubmissionData.new(response: ChangeHealth::Connection.new.request(endpoint: VALIDATION_ENDPOINT, body: self.to_h, headers: professional_headers))
26
33
  end
27
34
 
28
35
  def self.health_check
@@ -32,6 +39,19 @@ module ChangeHealth
32
39
  def self.ping
33
40
  self.health_check
34
41
  end
42
+
43
+ def professional_headers
44
+ if self[:headers]
45
+ extra_headers = {}
46
+ extra_headers["X-CHC-ClaimSubmission-SubmitterId"] = self[:headers][:submitter_id]
47
+ extra_headers["X-CHC-ClaimSubmission-BillerId"] = self[:headers][:biller_id]
48
+ extra_headers["X-CHC-ClaimSubmission-Username"] = self[:headers][:username]
49
+ extra_headers["X-CHC-ClaimSubmission-Pwd"] = self[:headers][:password]
50
+ extra_headers
51
+ else
52
+ nil
53
+ end
54
+ end
35
55
  end
36
56
  end
37
57
  end
@@ -0,0 +1,78 @@
1
+ module ChangeHealth
2
+ module Response
3
+ module Claim
4
+ # Methods only return meaningful data for json reports
5
+ class Report277Data < ChangeHealth::Response::Claim::ReportData
6
+ def transactions
7
+ @raw['transactions']
8
+ end
9
+
10
+ # Only one payer per report
11
+ def payer_org_name
12
+ transactions&.first&.dig('payers')&.first&.dig('organizationName')
13
+ end
14
+
15
+ def claims
16
+ report_claims = []
17
+
18
+ transactions&.each do |transaction|
19
+ transaction_set_creation_date = ChangeHealth::Models::PARSE_DATE.call(transaction['transactionSetCreationDate'])
20
+ transaction['payers']&.each do |payer|
21
+ payer_org_name = payer['organizationName']
22
+ payer['claimStatusTransactions']&.each do |claim_status_txn|
23
+ claim_status_txn['claimStatusDetails']&.each do |claim_status_detail|
24
+ service_provider_npi = claim_status_detail.dig('serviceProvider', 'npi')
25
+ claim_status_detail['patientClaimStatusDetails']&.each do |patient_claim_status_detail|
26
+ subscriber_first_name = patient_claim_status_detail.dig('subscriber', 'firstName')
27
+ subscriber_last_name = patient_claim_status_detail.dig('subscriber', 'lastName')
28
+ patient_claim_status_detail['claims']&.each do |claim|
29
+ procedure_codes = []
30
+ claim['serviceLines']&.each do |service_line|
31
+ procedure_codes << service_line.dig('service', 'procedureCode')
32
+ end
33
+ claim_status = claim['claimStatus']
34
+ next if claim_status.nil?
35
+
36
+ service_begin_date = ChangeHealth::Models::PARSE_DATE.call(claim_status['claimServiceBeginDate'] || claim_status['claimServiceDate'])
37
+ service_end_date = ChangeHealth::Models::PARSE_DATE.call(claim_status['claimServiceEndDate'] || claim_status['claimServiceDate'])
38
+
39
+ info_claim_statuses = []
40
+ claim_status['informationClaimStatuses']&.each do |info_claim_status|
41
+ status_information_effective_date = ChangeHealth::Models::PARSE_DATE.call(info_claim_status['statusInformationEffectiveDate'])
42
+ total_charge_amount = info_claim_status['totalClaimChargeAmount']
43
+
44
+ status_category_codes = []
45
+ info_claim_status['informationStatuses']&.each do |info_status|
46
+ status_category_codes << info_status['healthCareClaimStatusCategoryCode']
47
+ end
48
+
49
+ info_claim_statuses << ReportInfoClaimStatus.new(
50
+ status_category_codes: status_category_codes,
51
+ total_charge_amount: total_charge_amount,
52
+ status_information_effective_date: status_information_effective_date
53
+ )
54
+ end
55
+ report_claims << ReportClaim.new(
56
+ transaction_set_creation_date: transaction_set_creation_date,
57
+ payer_org_name: payer_org_name,
58
+ service_provider_npi: service_provider_npi,
59
+ subscriber_first_name: subscriber_first_name,
60
+ subscriber_last_name: subscriber_last_name,
61
+ procedure_codes: procedure_codes,
62
+ service_begin_date: service_begin_date,
63
+ service_end_date: service_end_date,
64
+ info_claim_statuses: info_claim_statuses
65
+ )
66
+ end
67
+ end
68
+ end
69
+ end
70
+ end
71
+ end
72
+
73
+ report_claims
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,8 @@
1
+ module ChangeHealth
2
+ module Response
3
+ module Claim
4
+ class Report835Data < ChangeHealth::Response::Claim::ReportData
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,47 @@
1
+ module ChangeHealth
2
+ module Response
3
+ module Claim
4
+ class ReportClaim < Hashie::Trash
5
+ property :transaction_set_creation_date, required: false
6
+ property :payer_org_name, required: false
7
+ property :service_provider_npi, required: false
8
+ property :subscriber_first_name, required: false
9
+ property :subscriber_last_name, required: false
10
+ property :procedure_codes, required: false
11
+ property :service_begin_date, required: false
12
+ property :service_end_date, required: false
13
+ property :info_claim_statuses, required: false
14
+
15
+ def add_procedure_code(procedure_code)
16
+ self[:procedure_codes] ||= []
17
+ self[:procedure_codes] << procedure_code
18
+ end
19
+
20
+ def add_info_claim_status(info_claim_status)
21
+ self[:info_claim_statuses] ||= []
22
+ self[:info_claim_statuses] << info_claim_status
23
+ end
24
+
25
+ def latest_status_category_codes
26
+ latest_info_claim_status&.status_category_codes
27
+ end
28
+
29
+ def latest_total_charge_amount
30
+ latest_info_claim_status&.total_charge_amount
31
+ end
32
+
33
+ def latest_status_info_effective_date
34
+ latest_info_claim_status&.status_information_effective_date
35
+ end
36
+
37
+ def latest_info_claim_status
38
+ info_claim_statuses&.select do |info|
39
+ !info.status_information_effective_date.nil? &&
40
+ info.status_information_effective_date.is_a?(Date) &&
41
+ info.status_information_effective_date <= Date.today
42
+ end&.max_by(&:status_information_effective_date)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,45 @@
1
+ module ChangeHealth
2
+ module Response
3
+ module Claim
4
+ class ReportData < ChangeHealth::Response::ResponseData
5
+ attr_reader :report_name, :json
6
+ alias_method :json?, :json
7
+
8
+ def initialize(report_name, json, data: nil, response: nil)
9
+ super(data: data, response: response)
10
+ @report_name = report_name
11
+ @json = json
12
+ end
13
+
14
+ def edi?
15
+ !@json
16
+ end
17
+
18
+ def report_type
19
+ self.class.report_type(@report_name)
20
+ end
21
+
22
+ def self.report_type(report_name)
23
+ return '277' if is_277?(report_name)
24
+ return '835' if is_835?(report_name)
25
+ end
26
+
27
+ def is_277?
28
+ self.class.is_277?(@report_name)
29
+ end
30
+
31
+ def self.is_277?(report_name)
32
+ report_name.start_with?('X3')
33
+ end
34
+
35
+ def is_835?
36
+ self.class.is_835?(@report_name)
37
+ end
38
+
39
+ def self.is_835?(report_name)
40
+ report_name.start_with?('R5')
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,16 @@
1
+ module ChangeHealth
2
+ module Response
3
+ module Claim
4
+ class ReportInfoClaimStatus < Hashie::Trash
5
+ property :status_category_codes, required: false
6
+ property :total_charge_amount, required: false
7
+ property :status_information_effective_date, required: false
8
+
9
+ def add_status_category_code(status_category_code)
10
+ self[:status_category_codes] ||= []
11
+ self[:status_category_codes] << status_category_code
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ module ChangeHealth
2
+ module Response
3
+ module Claim
4
+ class ReportListData < ChangeHealth::Response::ResponseData
5
+
6
+ def report_names
7
+ @raw.dig('reports')
8
+ end
9
+
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module ChangeHealth
2
- VERSION = '2.0.0'.freeze
2
+ VERSION = '2.3.0'.freeze
3
3
  end
data/lib/change_health.rb CHANGED
@@ -18,9 +18,16 @@ require 'change_health/models/eligibility/subscriber'
18
18
  require 'change_health/models/trading_partner/trading_partner'
19
19
  require 'change_health/request/eligibility'
20
20
  require 'change_health/request/submission'
21
+ require 'change_health/request/report'
21
22
  require 'change_health/request/trading_partner'
22
23
  require 'change_health/response/response_data'
23
24
  require 'change_health/response/claim/submission/submission_data'
25
+ require 'change_health/response/claim/report/report_list_data'
26
+ require 'change_health/response/claim/report/report_data'
27
+ require 'change_health/response/claim/report/report_277_data'
28
+ require 'change_health/response/claim/report/report_835_data'
29
+ require 'change_health/response/claim/report/report_claim'
30
+ require 'change_health/response/claim/report/report_info_claim_status'
24
31
  require 'change_health/response/eligibility/eligibility_benefit'
25
32
  require 'change_health/response/eligibility/eligibility_benefits'
26
33
  require 'change_health/response/eligibility/eligibility_data'
@@ -42,11 +49,11 @@ module ChangeHealth
42
49
  end
43
50
 
44
51
  def api_endpoint
45
- return Connection.base_uri
52
+ Connection.base_uri
46
53
  end
47
54
 
48
55
  def to_h
49
- return {
56
+ {
50
57
  client_id: @client_id,
51
58
  client_secret: @client_secret,
52
59
  grant_type: @grant_type,
@@ -60,7 +67,7 @@ module ChangeHealth
60
67
  self.grant_type = h[:grant_type]
61
68
  self.api_endpoint = h[:api_endpoint]
62
69
 
63
- return self
70
+ self
64
71
  end
65
72
  end
66
73
 
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: 2.0.0
4
+ version: 2.3.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: 2021-10-11 00:00:00.000000000 Z
11
+ date: 2021-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -159,8 +159,15 @@ files:
159
159
  - lib/change_health/models/model.rb
160
160
  - lib/change_health/models/trading_partner/trading_partner.rb
161
161
  - lib/change_health/request/eligibility.rb
162
+ - lib/change_health/request/report.rb
162
163
  - lib/change_health/request/submission.rb
163
164
  - lib/change_health/request/trading_partner.rb
165
+ - lib/change_health/response/claim/report/report_277_data.rb
166
+ - lib/change_health/response/claim/report/report_835_data.rb
167
+ - lib/change_health/response/claim/report/report_claim.rb
168
+ - lib/change_health/response/claim/report/report_data.rb
169
+ - lib/change_health/response/claim/report/report_info_claim_status.rb
170
+ - lib/change_health/response/claim/report/report_list_data.rb
164
171
  - lib/change_health/response/claim/submission/submission_data.rb
165
172
  - lib/change_health/response/eligibility/eligibility_benefit.rb
166
173
  - lib/change_health/response/eligibility/eligibility_benefits.rb