change_health 2.2.1 → 3.2.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: c125bdbe69dd6012d726e7ec54364c9535520520beeb4b7503dfc2b8eaf53a04
4
- data.tar.gz: 1645afbc96aed15798aab5603445c63892593924ae8fcac0c8490d166fa46919
3
+ metadata.gz: cb52acfb64f03d05c292cb41915ab6d686fae764d965e6df7df5533ad4c0e2e1
4
+ data.tar.gz: a3414ee7fe0a45c0aaf2432b83c6166ae2a07ba31a9105afee422c2189a3552c
5
5
  SHA512:
6
- metadata.gz: cb574a463704359781dbddee731ce6f298916bbbb37a95dd1f44790aa56e6ba730e916a67655266f1d80dc6a47924140b3ec53fde6425e982fc000ab2b259765
7
- data.tar.gz: 63162fe79c441191d1a73ebc3967d66bc9f20d1f7cfae7126771c17c08bed61905933e188a66d527835a32f2192a7d1e7246c220b34b06d043577e4fd6dc1a6e
6
+ metadata.gz: 4c82b12a74d6980409e7adcb968e4defee05679be768f61e294cacbdf03bdc3c2a4f9fa579d0b6b1086c135ef70ec16ebea3e3a5d77815bf5b8d5f39e755b315
7
+ data.tar.gz: 3a092daca4789cd9972ebfb37e0337d17a43abdb8f4d05672935190a606f0c75a1450aa4f8934aeba0a5d0b2f054bb58824a6215b945aed2ab0a5a831d001db8
data/CHANGELOG.md CHANGED
@@ -4,24 +4,74 @@ 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.2.1] - [2021-11-15-21]
7
+ ## [3.2.0] - 2021-12-23
8
+ ### Added
9
+ * Report835HealthCareCheckRemarkCode
10
+ * Report835Claim - added claim_payment_remark_codes
11
+
12
+ ## [3.1.0] - 2021-12-21
13
+ ### Added
14
+ #### Claim Submission
15
+ * ServiceLine - drugIdentification & renderingProvider
16
+ * Subscriber - groupNumber
17
+ * Address model w/ postalCode that is formatted to remove dashes, '-'
18
+ * Note: Using a plain hash for address still works
19
+ * Auto formatting of postal code fields
20
+
21
+ ## [3.0.0] - 2021-12-08
22
+ ### Added
23
+ * Report277Claim - specific to claims from 277 reports
24
+ * Report835Claim - specific to claims from 835 reports
25
+ * Report835ServiceAdjustment & Report835ServiceLine - helper classes for readability of claims from 835 reports
26
+
27
+ ### Changed
28
+ * ReportClaim - removed 277 report unique fields
29
+
30
+ #### Namespace
31
+ | Previous | Current |
32
+ |-|-|
33
+ | ChangeHealth::Models::Error | ChangeHealth::Response::Error |
34
+ | ChangeHealth::Response::Claim::ReportInfoClaimStatus | ChangeHealth::Response::Claim::Report277InfoClaimStatus|
35
+
36
+ #### Methods
37
+ | Previous | Current |
38
+ |-|-|
39
+ | Report277Data#payer_org_name | Report277Data#payer_name |
40
+ | ReportClaim#latest_total_charge_amount | ReportClaim#total_charge_amount |
41
+ | ReportClaim#payer_org_name | ReportClaim#payer_name |
42
+ | ReportClaim#service_begin_date | ReportClaim#service_date_begin |
43
+ | ReportClaim#service_end_date | ReportClaim#service_date_end |
44
+ | ReportClaim#subscriber_first_name | ReportClaim#patient_first_name |
45
+ | ReportClaim#subscriber_last_name | ReportClaim#patient_last_name |
46
+ | ReportClaim#transaction_set_creation_date | ReportClaim#report_creation_date |
47
+
48
+
49
+ ## [2.3.0] - 2021-11-18
50
+ ### Added
51
+ * Report277Data & Report835Data - Specific classes for 277 & 835 reports
52
+ * ReportClaim & ReportInfoClaimStatus - only works for json 277 reports
53
+
54
+ ### Fixed
55
+ * Headers can now be nil for requests
56
+
57
+ ## [2.2.1] - 2021-11-15
8
58
  ### Added
9
59
  Custom Headers for Reports API and Professional Claims API
10
60
  * Report
11
61
  * Submission
12
62
 
13
- ## [2.2.0] - [2021-11-04-21]
63
+ ## [2.2.0] - 2021-11-04
14
64
  ### Added
15
65
  Ability to hit [Claim Responses and Reports](https://developers.changehealthcare.com/eligibilityandclaims/docs/claims-responses-and-reports-getting-started)
16
66
  * Report
17
67
  * ReportListData
18
68
  * ReportData
19
69
 
20
- ## [2.1.0] - [2021-10-12]
70
+ ## [2.1.0] - 2021-10-12
21
71
  ### Changed
22
72
  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.
23
73
 
24
- ## [2.0.0] - [2021-10-08]
74
+ ## [2.0.0] - 2021-10-08
25
75
  ### Added
26
76
  #### Models
27
77
  * ResponseData - for responses from calling change healthcare api used by EligibilityData and SubmissionData
@@ -52,50 +102,50 @@ Added the ability to hit professional claim submission API. For more details, se
52
102
  ### Fixed
53
103
  * Eligibility#add_dependent actually works
54
104
 
55
- ## [1.0.3] - [2021-04-26]
105
+ ## [1.0.3] - 2021-04-26
56
106
  ### Added
57
107
  - Model::Error#represents_down? - adds ability to distinguish error representing down state
58
108
  - Model::Error#retryable? - retryable when down
59
109
  - EligibilityData#recommend_retry? - recommend retry when down
60
110
 
61
- ## [1.0.2] - [2021-04-06]
111
+ ## [1.0.2] - 2021-04-06
62
112
  ### Added
63
113
  - EligibilityData#recommend_retry? - fix a bug in the search statement
64
114
 
65
- ## [1.0.1] - [2021-03-24]
115
+ ## [1.0.1] - 2021-03-24
66
116
  ### Added
67
117
  - EligibilityData#plan_status - adds ability to select instead of find
68
118
  - EligibilityData#inactive? active? - use new plan_status select
69
119
 
70
- ## [1.0.0] - [2021-03-17]
120
+ ## [1.0.0] - 2021-03-17
71
121
  ### Added
72
122
  - Model::Error - help with error codes
73
123
  - EligibilityData#recommend_retry? - if it looks like you can retry the exact same request
74
124
  - EligibilityData#inactive? - looks for plan status 6
75
125
 
76
- ## [0.15.0] - [2020-06-12]
126
+ ## [0.15.0] - 2020-06-12
77
127
  ### Added
78
128
  - Extensions - InNetworkMissing for plans that don't provide in network indicators.
79
129
 
80
130
  ### Fixed
81
131
  - Bug where active codes with no service codes cause exception.
82
132
 
83
- ## [0.14.0] - [2020-05-07]
133
+ ## [0.14.0] - 2020-05-07
84
134
  ### Added
85
135
  - Extensions - mixins for common overrides
86
136
 
87
- ## [0.13.0] - [2020-05-05]
137
+ ## [0.13.0] - 2020-05-05
88
138
  ### Changed
89
139
  - Removed `alias_method` for `where` helpers so you can override a single method
90
140
  - Added type Year to Date type 24
91
141
  - Added type Day type 7
92
142
 
93
- ## [0.12.0] - [2020-04-30]
143
+ ## [0.12.0] - 2020-04-30
94
144
  ### Added
95
145
  - EligibilityData#errors
96
146
  - EligibilityData#errors?
97
147
 
98
- ## [0.11.0] - [2020-04-24]
148
+ ## [0.11.0] - 2020-04-24
99
149
  ### Added
100
150
  - EligibilityData#medicare?
101
151
  - EligibilityData#plan\_id
@@ -110,7 +160,7 @@ Added the ability to hit professional claim submission API. For more details, se
110
160
  - EligibilityData initialize now checks for sub-classes of EligibilityBenefits with trading partner responds to `factory` to choose sub-class
111
161
  - EligibilityBenefits initializes `self.class` type in case it's a subclass
112
162
 
113
- ## [0.10.0] - [2020-04-09]
163
+ ## [0.10.0] - 2020-04-09
114
164
  ### Added
115
165
  - Add Trading Partner API querying capability
116
166
  - Request::TradingPartner
@@ -118,7 +168,7 @@ Added the ability to hit professional claim submission API. For more details, se
118
168
  - Response::TradingPartnersData
119
169
  - Models::TradingPartner
120
170
 
121
- ## [0.9.0] - [2020-04-08]
171
+ ## [0.9.0] - 2020-04-08
122
172
  ### Added
123
173
  - Added EligibilityBenefit#medicare?
124
174
  - Added EligibilityData#medicare?
@@ -127,20 +177,20 @@ Added the ability to hit professional claim submission API. For more details, se
127
177
  - EligibilityBenefit(s)#individual returns true for medicare in benefit and queries that look for 'IND'
128
178
  - EligibilityBenefit(s)#in\_network returns true for medicare in benefit and queries that look for 'Y'
129
179
 
130
- ## [0.8.0] - [2020-04-04]
180
+ ## [0.8.0] - 2020-04-04
131
181
  ### Changed
132
182
  - Attempt to serialize all properties with 'date' in the name to ChangeHealth date format
133
183
 
134
- ## [0.7.0] - [2020-04-03]
184
+ ## [0.7.0] - 2020-04-03
135
185
  ### Changed
136
186
  - Fixed bug in serializing date on subscriber and encounter
137
187
 
138
- ## [0.6.0] - [2020-04-02]
188
+ ## [0.6.0] - 2020-04-02
139
189
  ### Changed
140
190
  - Added Indifferent Access to hashes
141
191
  - Fixed bug with Authentication endpoint
142
192
 
143
- ## [0.5.0] - [2020-03-11]
193
+ ## [0.5.0] - 2020-03-11
144
194
  ### Added
145
195
  - EligibilityBenefit Deductible information
146
196
  - EligibilityBenefit benefits date information
@@ -152,17 +202,17 @@ Added the ability to hit professional claim submission API. For more details, se
152
202
  ### Changed
153
203
  - Broke EligibilityBenefit and EligibilityBenefits into separate files
154
204
 
155
- ## [0.4.0] - [2020-03-10]
205
+ ## [0.4.0] - 2020-03-10
156
206
  ### Added
157
207
  - EligibilityBenefit(s) Employee information
158
208
  - EligibilityData plan date information
159
209
  - EligibilityData eligibility, plan and service date helpers on date info
160
210
 
161
- ## [0.3.0] - [2020-03-09]
211
+ ## [0.3.0] - 2020-03-09
162
212
  ### Added
163
213
  - Production endpoint
164
214
 
165
- ## [0.0.2] - [2020-03-09]
215
+ ## [0.0.2] - 2020-03-09
166
216
  ### Added
167
217
  - EligibilityData
168
218
  - EligibilityBenefit
@@ -180,6 +230,11 @@ Added the ability to hit professional claim submission API. For more details, se
180
230
  - Authentication
181
231
  - Configuration
182
232
 
233
+ [3.2.0]: https://github.com/WeInfuse/change_health/compare/v3.1.0...v3.2.0
234
+ [3.1.0]: https://github.com/WeInfuse/change_health/compare/v3.0.0...v3.1.0
235
+ [3.0.0]: https://github.com/WeInfuse/change_health/compare/v2.3.0...v3.0.0
236
+ [2.3.0]: https://github.com/WeInfuse/change_health/compare/v2.2.1...v2.3.0
237
+ [2.2.1]: https://github.com/WeInfuse/change_health/compare/v2.2.0...v2.2.1
183
238
  [2.2.0]: https://github.com/WeInfuse/change_health/compare/v2.1.0...v2.2.0
184
239
  [2.1.0]: https://github.com/WeInfuse/change_health/compare/v2.0.0...v2.1.0
185
240
  [2.0.0]: https://github.com/WeInfuse/change_health/compare/v1.0.3...v2.0.0
data/README.md CHANGED
@@ -1,9 +1,17 @@
1
1
  [![CircleCI](https://circleci.com/gh/WeInfuse/change_health.svg?style=svg)](https://circleci.com/gh/WeInfuse/change_health)
2
2
 
3
- # Change Health
3
+ ```
4
+ ____ _ _ _ _ _ _
5
+ / ___| |__ __ _ _ __ __ _ ___ | | | | ___ __ _| | |_| |__
6
+ | | | '_ \ / _` | '_ \ / _` |/ _ \ | |_| |/ _ \/ _` | | __| '_ \
7
+ | |___| | | | (_| | | | | (_| | __/ | _ | __/ (_| | | |_| | | |
8
+ \____|_| |_|\__,_|_| |_|\__, |\___| |_| |_|\___|\__,_|_|\__|_| |_|
9
+ |___/
10
+ ```
11
+
4
12
  Ruby API wrapper for [Change Health](https://developers.changehealthcare.com/api)
5
13
 
6
- ## Installation
14
+ # Installation
7
15
 
8
16
  Add this line to your application's Gemfile:
9
17
 
@@ -19,13 +27,13 @@ Or install it yourself as:
19
27
 
20
28
  $ gem install change_health
21
29
 
22
- ## Usage
30
+ # Usage
23
31
 
24
- ### Setup
32
+ ## Setup
25
33
 
26
34
  Make sure you're [configured](#configuration)!
27
35
 
28
- ### Eligibility
36
+ ## Eligibility
29
37
  [Change Healthcare Eligibility Guide](https://developers.changehealthcare.com/eligibilityandclaims/docs)
30
38
  ```ruby
31
39
  ChangeHealth::Request::Eligibility.ping # Test your connection
@@ -39,7 +47,7 @@ edata = ChangeHealth::Request::Eligibility.new(tradingPartnerServiceId: '000050'
39
47
  edata.raw # Raw Hash of JSON response
40
48
  ```
41
49
 
42
- #### Benefit(s) objects
50
+ ### Benefit(s) objects
43
51
  Benefits extends Array and provides a query-like interface.
44
52
 
45
53
  Benefit extends Hash and provides helpers for single-benefit.
@@ -58,7 +66,7 @@ edata.benefits.where(name: 'Co-Payment', code: 'B', benefitAmount: '30) # Generi
58
66
  edata.benefits.find_by(name: 'Co-Payment', code: 'B', benefitAmount: '30) # Generic 'find_by' api returns first object found
59
67
  ```
60
68
 
61
- #### Response
69
+ ### Response
62
70
 
63
71
  Response is EligibilityData object
64
72
 
@@ -67,16 +75,16 @@ edata.response
67
75
  #<HTTParty::Response:0x7fa354c1fbe8>
68
76
 
69
77
  edata.response.ok?
70
- true
78
+ # true
71
79
 
72
80
  edata.individual_oop_remaining(service_code: '30')
73
- 1344.88
81
+ # 1344.88
74
82
 
75
83
  edata.raw == edata.response.parsed_response
76
- true
84
+ # true
77
85
  ```
78
86
 
79
- ### Trading Partners
87
+ ## Trading Partners
80
88
  ```ruby
81
89
  # Query trading partners using a wildcard search
82
90
  # Returns Array of ChangeHealth::Models::TradingPartner Objects
@@ -89,7 +97,7 @@ trading_partners.first.service_id
89
97
  # "ABC123"
90
98
  ```
91
99
 
92
- ### Claim Submission
100
+ ## Claim Submission
93
101
  [Change Healthcare Claim Submission Guide](https://developers.changehealthcare.com/eligibilityandclaims/docs/professional-claims-v3-getting-started)
94
102
  ```ruby
95
103
  ChangeHealth::Request::Claim::Submission.ping # Test your connection
@@ -101,12 +109,13 @@ claim_submitter = ChangeHealth::Models::Claim::Submitter.new(
101
109
  )
102
110
 
103
111
  receiver = { organizationName: "EXTRA HEALTHY INSURANCE"}
104
- address = {
105
- "address1": "123 address1",
106
- "city": "city1",
107
- "state": "wa",
108
- "postalCode": "981010000"
109
- }
112
+ address = ChangeHealth::Models::Claim::Address.new(
113
+ address1: "123 address1",
114
+ city: "city1",
115
+ state: "wa",
116
+ postalCode: "98101-0000"
117
+ )
118
+
110
119
  subscriber = ChangeHealth::Models::Claim::Subscriber.new(
111
120
  member_id: "0000000001",
112
121
  payment_responsibility_level_code: "P",
@@ -118,45 +127,45 @@ subscriber = ChangeHealth::Models::Claim::Subscriber.new(
118
127
  )
119
128
  provider = ChangeHealth::Models::Claim::Provider.new(
120
129
  address: address,
121
- employer_id: "000000000",
122
- first_name: "johnone",
123
- last_name: "doetwo",
124
- npi: "1760854442",
125
- provider_type: "BillingProvider"
130
+ employer_id: "000000000",
131
+ first_name: "johnone",
132
+ last_name: "doetwo",
133
+ npi: "1760854442",
134
+ provider_type: "BillingProvider"
126
135
  )
127
136
 
128
137
  health_care_code_information1 = {
129
- "diagnosisTypeCode": "ABK",
130
- "diagnosisCode": "S93401A"
138
+ diagnosisTypeCode: "ABK",
139
+ diagnosisCode: "S93401A"
131
140
  }
132
141
  health_care_code_information2 = {
133
- "diagnosisTypeCode": "ABF",
134
- "diagnosisCode": "S72044G"
142
+ diagnosisTypeCode: "ABF",
143
+ diagnosisCode: "S72044G"
135
144
 
136
145
  }
137
146
  service_line1 = ChangeHealth::Models::Claim::ServiceLine.new(
138
147
  service_date: "2018-05-14",
139
148
  professional_service: {
140
- "procedureIdentifier": "HC",
141
- "lineItemChargeAmount": "25",
142
- "procedureCode": "E0570",
143
- "measurementUnit": "UN",
144
- "serviceUnitCount": "1",
145
- "compositeDiagnosisCodePointers": {
146
- "diagnosisCodePointers": ["1","2"]
149
+ procedureIdentifier: "HC",
150
+ lineItemChargeAmount: "25",
151
+ procedureCode: "E0570",
152
+ measurementUnit: "UN",
153
+ serviceUnitCount: "1",
154
+ compositeDiagnosisCodePointers: {
155
+ diagnosisCodePointers: ["1","2"]
147
156
  }
148
157
  }
149
158
  )
150
159
  service_line2 = ChangeHealth::Models::Claim::ServiceLine.new(
151
160
  service_date: "20180514",
152
161
  professional_service: {
153
- "procedureIdentifier": "HC",
154
- "lineItemChargeAmount": "3.75",
155
- "procedureCode": "A7003",
156
- "measurementUnit": "UN",
157
- "serviceUnitCount": "1",
158
- "compositeDiagnosisCodePointers": {
159
- "diagnosisCodePointers": ["1"]
162
+ procedureIdentifier: "HC",
163
+ lineItemChargeAmount: "3.75",
164
+ procedureCode: "A7003",
165
+ measurementUnit: "UN",
166
+ serviceUnitCount: "1",
167
+ compositeDiagnosisCodePointers: {
168
+ diagnosisCodePointers: ["1"]
160
169
  }
161
170
  }
162
171
  )
@@ -196,8 +205,10 @@ claim_submission_data = claim_submission.submission
196
205
  validation = claim_submission.validation
197
206
  ```
198
207
 
199
- ### Claim Reports
208
+ ## Claim Reports
200
209
  [Change Healthcare Claim Responses and Reports Guide](https://developers.changehealthcare.com/eligibilityandclaims/docs/claims-responses-and-reports-getting-started)
210
+
211
+ ### Get Reports
201
212
  ```ruby
202
213
  ChangeHealth::Request::Claim::Report.ping # Test your connection
203
214
 
@@ -211,10 +222,10 @@ report_list = ChangeHealth::Request::Claim::Report.report_list(headers: report_h
211
222
  report_list.report_names
212
223
  # ["X3000000.XX", "R5000000.XY", "R5000000.XX", "X3000000.AB", "X3000000.AC", "X3000000.ZZ", "R5000000.XZ", "R5000000.YZ", "R5000000.WA", "R5000000.WB", "R5000000.WC"]
213
224
 
214
- report1_edi = ChangeHealth::Request::Claim::Report.get_report(report_list.report_names.first, as_json_report: false, headers: report_headers)
225
+ report0_edi = ChangeHealth::Request::Claim::Report.get_report(report_list.report_names.first, as_json_report: false)
215
226
  # Report in edi format
216
227
 
217
- report1_json = ChangeHealth::Request::Claim::Report.get_report(report_list.report_names.first, as_json_report: true, headers: report_headers)
228
+ report0_json = ChangeHealth::Request::Claim::Report.get_report(report_list.report_names.first, as_json_report: true)
218
229
  # Report in json format
219
230
 
220
231
  reports_json = report_list.report_names.map {|report_name| ChangeHealth::Request::Claim::Report.get_report(report_name, headers: report_headers)}
@@ -224,7 +235,72 @@ reports_edi = report_list.report_names.map {|report_name| ChangeHealth::Request:
224
235
  # all reports in edi format
225
236
  ```
226
237
 
227
- ### Configuration
238
+ ### Inspect Reports
239
+ Currently only works for json 277 reports and json 835 reports. Not for EDI reports
240
+
241
+ From a report, you can get an array of claims
242
+
243
+ #### Report 277
244
+
245
+ ```ruby
246
+ report_277_data = ChangeHealth::Request::Claim::Report.get_report("X3000000.AB", as_json_report: true)
247
+
248
+ report_277_data.payer_name
249
+ # "PREMERA"
250
+
251
+ report_277_data.report_creation_date
252
+ # Tue, 01 Dec 2020
253
+
254
+ claim_277 = report_277_data.claims.first
255
+ claim_277.payer_name
256
+ # "PREMERA"
257
+
258
+ claim_277.patient_first_name
259
+ # "JOHNONE"
260
+
261
+ claim_277.report_creation_date
262
+ # Tue, 01 Dec 2020
263
+
264
+ # Report 277 specific below
265
+ claim_277.latest_status_category_codes
266
+ # ["F1"]
267
+
268
+ claim_277.total_charge_amount
269
+ # "100"
270
+
271
+ claim_277.procedure_codes
272
+ # ["97161"]
273
+ ```
274
+
275
+ #### Report 835
276
+
277
+ ```ruby
278
+ report_835_data = ChangeHealth::Request::Claim::Report.get_report("R5000000.XY", as_json_report: true)
279
+
280
+ report_835_data.payment_method_code
281
+ # "ACH"
282
+
283
+ report_835_data.total_actual_provider_payment_amount
284
+ # "2563.13"
285
+
286
+ claim_835 = report_835_data.claims.first
287
+ claim_835.payer_name
288
+ # "NATIONAL GOVERNMENT SERVICES, INC."
289
+
290
+ claim_835.patient_first_name
291
+ # "JANE"
292
+
293
+ claim_835.report_creation_date
294
+ # Wed, 22 Apr 2020
295
+
296
+ claim_835.procedure_codes
297
+ # ["21210", "21026", "21208", "30580"]
298
+
299
+ claim_835.service_lines.map(&:line_item_charge_amount)
300
+ # ["3600", "1890", "1836", "1680"]
301
+ ```
302
+
303
+ ## Configuration
228
304
 
229
305
  ```ruby
230
306
  ChangeHealth.configure do |c|
@@ -235,12 +311,12 @@ ChangeHealth.configure do |c|
235
311
  end
236
312
  ```
237
313
 
238
- ## Development
314
+ # Development
239
315
 
240
316
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
241
317
 
242
318
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
243
319
 
244
- ## Contributing
320
+ # Contributing
245
321
 
246
322
  Bug reports and pull requests are welcome on GitHub at https://github.com/WeInfuse/change\_health.
@@ -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
@@ -0,0 +1,13 @@
1
+ module ChangeHealth
2
+ module Models
3
+ module Claim
4
+ class Address < Model
5
+ property :address1, required: false
6
+ property :address2, required: false
7
+ property :city, required: false
8
+ property :postalCode, from: :postal_code, required: false
9
+ property :state, required: false
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ module ChangeHealth
2
+ module Models
3
+ module Claim
4
+ class DrugIdentification < Model
5
+ property :measurementUnitCode, from: :measurement_unit_code, required: false
6
+ property :nationalDrugCode, from: :national_drug_code, required: false
7
+ property :nationalDrugUnitCount, from: :national_drug_unit_count, required: false
8
+ property :serviceIdQualifier, from: :service_id_qualifier, required: false
9
+ end
10
+ end
11
+ end
12
+ end
@@ -2,10 +2,10 @@ module ChangeHealth
2
2
  module Models
3
3
  module Claim
4
4
  class ServiceLine < Model
5
-
5
+ property :drugIdentification, from: :drug_identification, required: false
6
6
  property :serviceDate, from: :service_date, required: false
7
7
  property :professionalService, from: :professional_service, required: false
8
-
8
+ property :renderingProvider, from: :rendering_provider, required: false
9
9
  end
10
10
  end
11
11
  end
@@ -6,6 +6,7 @@ module ChangeHealth
6
6
  property :dateOfBirth, from: :date_of_birth, required: false
7
7
  property :firstName, from: :first_name, required: false
8
8
  property :gender, required: false
9
+ property :groupNumber, from: :group_number, required: false
9
10
  property :lastName, from: :last_name, required: false
10
11
  property :memberId, from: :member_id, required: false
11
12
  property :paymentResponsibilityLevelCode, from: :payment_responsibility_level_code, required: false
@@ -1,7 +1,7 @@
1
1
  module ChangeHealth
2
2
  module Models
3
3
  DATE_FORMAT = '%Y%m%d'
4
- DATE_FORMATTER = ->(d) {
4
+ DATE_FORMATTER = lambda { |d|
5
5
  begin
6
6
  d = Date.parse(d) if d.is_a?(String)
7
7
  rescue ArgumentError
@@ -12,37 +12,65 @@ module ChangeHealth
12
12
  d
13
13
  }
14
14
 
15
- PARSE_DATE = ->(d) {
15
+ PARSE_DATE = lambda { |d|
16
16
  begin
17
17
  d = Date.strptime(d, ChangeHealth::Models::DATE_FORMAT)
18
- rescue
18
+ rescue StandardError
19
19
  end
20
20
 
21
21
  d
22
22
  }
23
23
 
24
- CONTROL_NUMBER = ->() { '%09d' % rand(1_000_000_000) }
24
+ POSTAL_CODE_FORMATTER = lambda { |postal_code|
25
+ begin
26
+ formatted_postal_code = postal_code&.to_s&.tr('-', '')
27
+ rescue StandardError
28
+ end
29
+ formatted_postal_code || postal_code
30
+ }
31
+
32
+ CONTROL_NUMBER = -> { '%09d' % rand(1_000_000_000) }
25
33
 
26
34
  class Model < Hashie::Trash
27
35
  def to_h
28
- result = super.to_h
36
+ self.class.hashify(self)
37
+ end
38
+
39
+ def self.hashify(model)
40
+ model.map do |key, value|
41
+ formatted_value = case value
42
+ when Hash
43
+ hashify(model[key])
44
+ when Array
45
+ value.map do |element|
46
+ if element.is_a?(Hash)
47
+ hashify(element)
48
+ else # if it's an array of arrays, can't handle it
49
+ format_value(key, element)
50
+ end
51
+ end
52
+ else
53
+ format_value(key, value)
54
+ end
55
+ [key, formatted_value]
56
+ end.to_h
57
+ end
58
+
59
+ def self.format_value(key, value)
60
+ return nil if value == ''
29
61
 
30
- self.each_pair do |key, value|
31
- if key.to_s.downcase.include?('date')
32
- result[key] = ChangeHealth::Models::DATE_FORMATTER.call(result[key])
33
- end
34
- result[key] = nil if value == ""
35
- end
62
+ return ChangeHealth::Models::DATE_FORMATTER.call(value) if key.to_s.downcase.include?('date')
63
+ return ChangeHealth::Models::POSTAL_CODE_FORMATTER.call(value) if key.to_s.downcase.include?('postalcode')
36
64
 
37
- result
65
+ value
38
66
  end
39
67
 
40
- def as_json(args = {})
41
- self.to_h
68
+ def as_json(_args = {})
69
+ to_h
42
70
  end
43
71
 
44
- def to_json
45
- self.to_h.to_json
72
+ def to_json(*_args)
73
+ to_h.to_json
46
74
  end
47
75
  end
48
76
  end