trizetto-api 0.1.2 → 0.2.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/.travis.yml +2 -1
- data/.yardopts +1 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +3 -1
- data/README.md +55 -11
- data/lib/trizetto/api/eligibility/core2.rb +16 -15
- data/lib/trizetto/api/eligibility/web_service.rb +121 -59
- data/lib/trizetto/api/eligibility/web_service/benefit.rb +117 -0
- data/lib/trizetto/api/eligibility/web_service/benefit_entity.rb +54 -0
- data/lib/trizetto/api/eligibility/web_service/dependent.rb +72 -0
- data/lib/trizetto/api/eligibility/web_service/do_inquiry_response.rb +168 -0
- data/lib/trizetto/api/eligibility/web_service/extra_processing_info.rb +41 -0
- data/lib/trizetto/api/eligibility/web_service/info_reciever.rb +14 -0
- data/lib/trizetto/api/eligibility/web_service/info_source.rb +14 -0
- data/lib/trizetto/api/eligibility/web_service/node.rb +43 -0
- data/lib/trizetto/api/eligibility/web_service/patient.rb +36 -0
- data/lib/trizetto/api/eligibility/web_service/patient_name.rb +50 -0
- data/lib/trizetto/api/eligibility/web_service/rejectable.rb +62 -0
- data/lib/trizetto/api/eligibility/web_service/rejection.rb +31 -0
- data/lib/trizetto/api/eligibility/web_service/subscriber.rb +32 -0
- data/lib/trizetto/api/eligibility/web_service/validation_failure.rb +47 -0
- data/lib/trizetto/api/payer_list/web_service.rb +10 -8
- data/lib/trizetto/api/version.rb +1 -1
- data/trizetto-api.gemspec +4 -0
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60c7ed11ee2e04e48734c1e3b557c9e904d2e268
|
4
|
+
data.tar.gz: 3b35cbee1b0e2ffb45ae3e9533ec546983f4d130
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2471cf69c92ddac9b6b47d0d41c7dd8e020f7374418b9c08e2034907f783071ed052e45829c7fa3989c4ab5b6b32c1ea476d170de250868c2a7c995e602c4c91
|
7
|
+
data.tar.gz: 4888af1330a52c70b84535c44ae4c912866482109b5e853858390d1d156bf8236bcfd1ef3b4bc27ab5912a74d0c215daee47cd1ff644c8db253d3f24032f5df8
|
data/.travis.yml
CHANGED
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--no-private -r README.md lib/**/*.rb
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 0.2.1 (January 18, 2018) ##
|
2
|
+
|
3
|
+
* Sets required minimum version for ruby to 2.3
|
4
|
+
|
5
|
+
## 0.2.0 (January 18, 2018) ##
|
6
|
+
|
7
|
+
* Make it simple to answer the question: does this person have insurance
|
8
|
+
coverage via the WebService Eligibility check. The raw XML response is parsed
|
9
|
+
into plain old ruby objects.
|
10
|
+
* Added tests (woo hoo)
|
11
|
+
* Readme update with examples
|
12
|
+
* Documented the WebService Eligibility check
|
13
|
+
|
1
14
|
## 0.1.2 (January 12, 2018) ##
|
2
15
|
|
3
16
|
* Have the non-COR II Eligiblity check return an XML document. YAY! We can
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
trizetto-api (0.
|
4
|
+
trizetto-api (0.2.0)
|
5
5
|
savon (~> 2.0)
|
6
6
|
savon-multipart (~> 2.0)
|
7
7
|
|
@@ -12,6 +12,7 @@ GEM
|
|
12
12
|
gyoku (>= 0.4.0)
|
13
13
|
nokogiri
|
14
14
|
builder (3.2.3)
|
15
|
+
byebug (9.1.0)
|
15
16
|
diff-lcs (1.3)
|
16
17
|
gyoku (1.3.1)
|
17
18
|
builder (>= 2.1.2)
|
@@ -66,6 +67,7 @@ PLATFORMS
|
|
66
67
|
|
67
68
|
DEPENDENCIES
|
68
69
|
bundler (~> 1.16)
|
70
|
+
byebug (>= 9.0)
|
69
71
|
rake (~> 10.0)
|
70
72
|
rspec (~> 3.0)
|
71
73
|
trizetto-api!
|
data/README.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# Trizetto::Api
|
2
2
|
|
3
|
-
|
3
|
+
[](https://travis-ci.org/GoodMeasuresLLC/trizetto-api)
|
4
|
+
|
5
|
+
Ruby wrapper for Trizetto APIs for Ruby 2.3 and above.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
9
|
+
<b>Requires Ruby 2.3 or above</b>
|
10
|
+
|
7
11
|
Add this line to your application's Gemfile:
|
8
12
|
|
9
13
|
```ruby
|
@@ -18,12 +22,20 @@ Or install it yourself as:
|
|
18
22
|
|
19
23
|
$ gem install trizetto-api
|
20
24
|
|
25
|
+
|
21
26
|
## Usage
|
22
27
|
|
23
28
|
### Use the Eligibility Web Service with an XML payload to check eligibility in realtime
|
24
29
|
|
25
30
|
This uses name/value pairs in a request and returns an XML docunment as a response.
|
26
|
-
|
31
|
+
|
32
|
+
To simply check if the patient is covered by a health plan
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
GENERAL_HEALTH_PLAN_COVERAGE_CODE = "30"
|
36
|
+
response = client.do_inquiry({...})
|
37
|
+
response.active_coverage_for?(GENERAL_HEALTH_PLAN_COVERAGE_CODE) #=> true | false
|
38
|
+
```
|
27
39
|
|
28
40
|
```ruby
|
29
41
|
require 'trizetto/api'
|
@@ -33,12 +45,13 @@ Trizetto::Api.configure do |config|
|
|
33
45
|
config.password = 'Super Top Secret'
|
34
46
|
end
|
35
47
|
|
36
|
-
|
37
|
-
|
38
|
-
pretty_print_xml: true,
|
39
|
-
log: true,
|
40
|
-
log_level: :debug,
|
48
|
+
client = Trizetto::Api::Eligibility::WebService::Client.new({
|
49
|
+
# You probably don't want logging enable unless you are being very careful to protect PHI in logs
|
50
|
+
# pretty_print_xml: true,
|
51
|
+
# log: true,
|
52
|
+
# log_level: :debug,
|
41
53
|
})
|
54
|
+
|
42
55
|
response = client.do_inquiry({
|
43
56
|
'ProviderLastName': 'BLUE CROSS BLUE SHIELD OF MASSACHUSETTS',
|
44
57
|
'NPI': 'YOUR NPI HERE',
|
@@ -48,13 +61,44 @@ response = client.do_inquiry({
|
|
48
61
|
'GediPayerId': 'N4222',
|
49
62
|
})
|
50
63
|
|
51
|
-
|
64
|
+
# Were there validation errors with the request?
|
65
|
+
response.success? # => false
|
66
|
+
response.success_code # => "ValidationFailure"
|
67
|
+
response.errors.messages # => ["Please enter InsuranceNum."]response.errors.validation_failures.first.affected_fields # => ["InsuranceNum"]
|
68
|
+
response.errors.validation_failures.first.message # => "Please enter InsuranceNum."
|
69
|
+
|
70
|
+
|
71
|
+
# Did we successfully get back an eligibility response from the payer.
|
72
|
+
response.success? # => true
|
73
|
+
response.success_code # => "Success"
|
74
|
+
response.transaction_id # => "c6eb40c5584f0496be3f3a48d0ddfd"
|
75
|
+
response.payer_name # => "BLUE CROSS BLUE SHIELD OF MASSACHUSETTS"
|
76
|
+
response.active_coverage_for?("30") # => true
|
77
|
+
|
78
|
+
# Was the response rejected? We got back an eligibility response, but probably the patient wasn't found
|
79
|
+
response.success? # => true
|
80
|
+
response.success_code # => "Success"
|
81
|
+
response.active_coverage_for?("30") # => false
|
82
|
+
response.rejected? # => true
|
83
|
+
response.rejectsions.count # => 1
|
84
|
+
response.rejectsions.first.reason # => "Patient Birth Date Does Not Match That for the Patient on the Database"
|
85
|
+
response.rejectsions.first.follow_up_action # => "Please Correct and Resubmit"
|
86
|
+
|
87
|
+
# What active insurance coverages of service_type_code=30 does this patient have?
|
88
|
+
coverages = response.patient.benefits.select {|benefit| benefit.active_coverage? && benefit.service_type_codes.include?("30")}
|
89
|
+
coverages.count # => 2
|
90
|
+
coverages.first.insurance_type # => "Preferred Provider Organization (PPO)"
|
91
|
+
coverages.last.insurance_type # => "Medicare Part A"
|
92
|
+
coverages.first.messages # => nil
|
93
|
+
coverages.last.messages # => ["BCBSMA IS PRIME"]
|
94
|
+
|
95
|
+
# Find all the benefit information for service_type_code=30
|
96
|
+
benefits = response.patient.benefits.select {|benefit| benefit.service_type_codes.include?("30")}
|
97
|
+
|
98
|
+
benefits.map(&:info).uniq # => ["Active Coverage", "Deductible", "Coverage Basis", "Out of Pocket (Stop Loss)", "Services Restricted to Following Provider"]
|
52
99
|
|
53
|
-
source = response.to_hash[:do_inquiry_response][:do_inquiry_result][:response_as_xml]
|
54
|
-
puts Nokogiri::XML(source).to_xml
|
55
100
|
```
|
56
101
|
|
57
|
-
|
58
102
|
### Use the CORE2 API with an X12 payload to check eligibility in realtime
|
59
103
|
|
60
104
|
This returns an X12/271 response. You will need to understand how to build
|
@@ -11,10 +11,9 @@ module Trizetto
|
|
11
11
|
#
|
12
12
|
# As of right now, you have to generate the correct X12/271 payload.
|
13
13
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# - Eligibility 270/271 Companion Guide: https://mytools.gatewayedi.com/webcontent/Eligibility_Companion_Guide.pdf
|
14
|
+
# <b<References</b>
|
17
15
|
#
|
16
|
+
# - {https://mytools.gatewayedi.com/webcontent/Eligibility_Companion_Guide.pdf Eligibility 270/271 Companion Guide}
|
18
17
|
class Core2
|
19
18
|
def initialize(options={})
|
20
19
|
@client = Savon.client({
|
@@ -55,20 +54,22 @@ module Trizetto
|
|
55
54
|
}.merge(options))
|
56
55
|
end
|
57
56
|
|
58
|
-
|
59
|
-
#
|
57
|
+
# Performs an eligiblity check using the CORE II Eligibility API via X12/270
|
58
|
+
#
|
59
|
+
# <b>TODO</b>
|
60
|
+
# - Understand the X12 format and allow options to be passed in, then generate the X12 message
|
60
61
|
#
|
61
62
|
def check_eligibility(options = {})
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
63
|
+
@client.call(:real_time_transaction, message: {
|
64
|
+
'PayloadType': 'X12_270_Request_005010X279A1',
|
65
|
+
'ProcessingMode': 'RealTime',
|
66
|
+
'PayloadID': SecureRandom.uuid,
|
67
|
+
'TimeStamp': Time.now.utc.xmlschema,
|
68
|
+
'SenderID': Trizetto::Api.configuration.username,
|
69
|
+
'ReceiverID': 'GATEWAY EDI',
|
70
|
+
'CORERuleVersion': '2.2.0',
|
71
|
+
'Payload': options[:payload]
|
72
|
+
});
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|
@@ -1,74 +1,136 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + "/web_service/rejectable.rb"
|
4
|
+
require File.dirname(__FILE__) + "/web_service/node.rb"
|
5
|
+
require File.dirname(__FILE__) + "/web_service/patient.rb"
|
6
|
+
|
7
|
+
Dir[File.dirname(__FILE__) + '/web_service/*.rb'].each {|file| require file }
|
8
|
+
|
1
9
|
module Trizetto
|
2
10
|
module Api
|
3
11
|
module Eligibility
|
12
|
+
module WebService
|
4
13
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
#
|
11
|
-
# - +DoInquiry+
|
12
|
-
# - +DoInquiryByX12Data+
|
13
|
-
# - +DoInquiryByX12DataWith271Response+
|
14
|
-
#
|
15
|
-
# This API, currently, only uses the +DoInquiry+ check. For X12 requests
|
16
|
-
# the CORE II client is recommended instead.
|
17
|
-
#
|
18
|
-
# See Also:
|
19
|
-
#
|
20
|
-
# - Service Description: https://services.gatewayedi.com/eligibility/service.asmx
|
21
|
-
# - WSDL: https://services.gatewayedi.com/eligibility/service.asmx?WSDL
|
22
|
-
# - Realtime Eligibiliy Webservice Companion Guide: https://mytools.gatewayedi.com/Help/documents/Eligibility/Realtime%20Eligibility%20Webservice%20Companion%20Guide.pdf
|
23
|
-
# - Realtime Eligibiliy Webservice Vendor Toolkit: https://mytools.gatewayedi.com/Help/documents/Eligibility/Realtime%20Eligibility%20Webservice%20Vendor%20Toolkit.pdf
|
24
|
-
# - Eligibility Companion Guide by Payer: https://mytools.gatewayedi.com/help/documents/Eligibility/Payer%20Specific%20Required%20Data%20Elements-2010.pdf
|
25
|
-
class WebService < Trizetto::Api::WebService
|
26
|
-
def initialize(options={})
|
27
|
-
super(options.merge({
|
28
|
-
wsdl: File.join( File.dirname(__FILE__), 'web_service.wsdl' ),
|
29
|
-
endpoint: Trizetto::Api.configuration.eligibiltiy_webservice_endpoint,
|
30
|
-
}))
|
31
|
-
end
|
14
|
+
# Raised when the response from Trizetto includes multiple subscribers
|
15
|
+
#
|
16
|
+
# If raised, please scrub the response for PHI and create an issue in
|
17
|
+
# github and include the scrubbed (NO PHI!!) reponse XML.
|
18
|
+
class MultipleSubscribersError < StandardError; end
|
32
19
|
|
33
|
-
#
|
34
|
-
# +GediPayerId+ - The Gateway EDI specific payer identifier
|
35
|
-
# +ProviderLastName+ - Provider Last Name/Organization Name
|
36
|
-
# +NPI+ - National Provider Identifier
|
20
|
+
# Raised when the response from Trizetto includes multiple dependents
|
37
21
|
#
|
38
|
-
#
|
22
|
+
# If raised, please scrub the response for PHI and create an issue in
|
23
|
+
# github and include the scrubbed (NO PHI!!) reponse XML.
|
24
|
+
class MultipleDependentsError < StandardError; end
|
25
|
+
|
26
|
+
|
27
|
+
# Ruby Wrapper for the Eligibility Web Service
|
39
28
|
#
|
40
|
-
#
|
41
|
-
# +InsuredFirstName+ - Subscriber First Name
|
42
|
-
# +InsuredLastName+ - Subscriber Last Name
|
43
|
-
# +InsuranceNum+ - Subscriber Id
|
44
|
-
# +InsuredDob+ - Subscriber DOB
|
45
|
-
# +InsuredGender+ - Subscriber Gender
|
46
|
-
# +DependentFirstName+ - Dependent First Name
|
47
|
-
# +DependentLastName+ - Dependent Last Name
|
48
|
-
# +DependentDob+ - Dependent DOB
|
49
|
-
# +DependentGender+ - Dependent Gender
|
29
|
+
# Performs a real time eligibility check using the non-CORE II Web Service
|
50
30
|
#
|
51
|
-
#
|
52
|
-
# companion guide for the additional parameters required by few payers. A valid inquiry submitted
|
53
|
-
# to those payers must also account for the additional payer specific parameters. “InsuranceNum,” in
|
54
|
-
# particular, is not a required field for all transactions, but is required by almost all payers.
|
31
|
+
# The webservice provides 3 eligibility checks:
|
55
32
|
#
|
56
|
-
#
|
33
|
+
# * <tt>DoInquiry</tt>
|
34
|
+
# * <tt>DoInquiryByX12Data</tt>
|
35
|
+
# * <tt>DoInquiryByX12DataWith271Response</tt>
|
57
36
|
#
|
58
|
-
#
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
37
|
+
# This API, currently, only uses the +DoInquiry+ check. For X12 requests
|
38
|
+
# the CORE II client is recommended instead.
|
39
|
+
#
|
40
|
+
# <b>Example</b>
|
41
|
+
#
|
42
|
+
# client = Trizetto::Api::Eligibility::WebService::Client.new
|
43
|
+
#
|
44
|
+
# response = client.do_inquiry({
|
45
|
+
# 'ProviderLastName': 'YOUR COMPANY NAME HERE',
|
46
|
+
# 'NPI': 'YOUR NPI HERE',
|
47
|
+
# 'InsuredFirstName': 'Mickey',
|
48
|
+
# 'InsuredLastName': 'Mouse',
|
49
|
+
# 'InsuredDob': '19281118',
|
50
|
+
# 'GediPayerId': 'N4222',
|
51
|
+
# })
|
52
|
+
#
|
53
|
+
# @see DoInquiryResponse
|
54
|
+
#
|
55
|
+
# *References*
|
56
|
+
# * {https://services.gatewayedi.com/eligibility/service.asmx ServiceDescription}
|
57
|
+
# * {https://services.gatewayedi.com/eligibility/service.asmx?WSDL WSDL}
|
58
|
+
# * {https://mytools.gatewayedi.com/Help/documents/Eligibility/Realtime%20Eligibility%20Webservice%20Companion%20Guide.pdf Realtime Eligibiliy Webservice Companion Guide}
|
59
|
+
# * {https://mytools.gatewayedi.com/Help/documents/Eligibility/Realtime%20Eligibility%20Webservice%20Vendor%20Toolkit.pdf Realtime Eligibiliy Webservice Vendor Toolkit}
|
60
|
+
# * {https://mytools.gatewayedi.com/help/documents/Eligibility/Payer%20Specific%20Required%20Data%20Elements-2010.pdf Eligibility Companion Guide by Payer}
|
61
|
+
class Client < Trizetto::Api::WebService
|
68
62
|
|
69
|
-
|
63
|
+
def initialize(options={})
|
64
|
+
super(
|
65
|
+
options.merge(
|
66
|
+
{
|
67
|
+
wsdl: File.join( File.dirname(__FILE__), 'web_service.wsdl' ),
|
68
|
+
endpoint: Trizetto::Api.configuration.eligibiltiy_webservice_endpoint,
|
69
|
+
}
|
70
|
+
))
|
71
|
+
end
|
72
|
+
|
73
|
+
# Performs an eligibility check using the trizetto eligibility SOAP API
|
74
|
+
#
|
75
|
+
# In this request, your company is the Provider, you are providing
|
76
|
+
# services to an individual. For the +ProviderLastName+, you should use
|
77
|
+
# you company's name. For the +NPI+, you should use your company's
|
78
|
+
# National Provider Identifier.
|
79
|
+
#
|
80
|
+
# The +GediPayerId+ is the insurance company. You want them to pay for the
|
81
|
+
# service you have or will provide. You will need to get these values
|
82
|
+
# from Trizetto.
|
83
|
+
#
|
84
|
+
# Required and optional fields will depend on the Payer being checked.
|
85
|
+
# Some payers require additional information than those listed below.
|
86
|
+
# Refer to the companion guide for the required additional parameters.
|
87
|
+
# A valid inquiry submitted to those payers must also account for the
|
88
|
+
# additional payer specific parameters. +InsuranceNum+ in particular,
|
89
|
+
# is not a required field for all transactions, but is required by
|
90
|
+
# almost all payers.
|
91
|
+
#
|
92
|
+
# <b>Always Required Fields</b>
|
93
|
+
#
|
94
|
+
# * <tt>GediPayerId</tt> - The Gateway EDI specific payer identifier
|
95
|
+
# * <tt>ProviderLastName</tt> - Provider Last Name/Organization Name.
|
96
|
+
# * <tt>NPI</tt> - National Provider Identifier
|
97
|
+
#
|
98
|
+
# <b>Situational Fields</b>
|
99
|
+
#
|
100
|
+
# * <tt>ProviderFirstName</tt> - Provider First Name
|
101
|
+
# * <tt>InsuredFirstName</tt> - Subscriber First Name
|
102
|
+
# * <tt>InsuredLastName</tt> - Subscriber Last Name
|
103
|
+
# * <tt>InsuranceNum</tt> - Subscriber Id
|
104
|
+
# * <tt>InsuredDob</tt> - Subscriber DOB
|
105
|
+
# * <tt>InsuredGender</tt> - Subscriber Gender
|
106
|
+
# * <tt>DependentFirstName</tt> - Dependent First Name
|
107
|
+
# * <tt>DependentLastName</tt> - Dependent Last Name
|
108
|
+
# * <tt>DependentDob</tt> - Dependent DOB
|
109
|
+
# * <tt>DependentGender</tt> - Dependent Gender
|
110
|
+
# * <tt>GroupNumber</tt> -
|
111
|
+
# * <tt>ServiceTypeCode</tt> - What type of provider service. 30 is Health Plan Benefit Coverage, "General healthcare benefits for the member's policy or contract"
|
112
|
+
#
|
113
|
+
# <b>References</b>
|
114
|
+
# * {https://services.gatewayedi.com/eligibility/service.asmx?op=DoInquiry Service Description}
|
115
|
+
# * {http://www.x12.org/codes/health-care-service-type-codes/ Service Type Codes}
|
116
|
+
#
|
117
|
+
# @return DoInquiryResponse
|
118
|
+
def do_inquiry(parameters={})
|
119
|
+
DoInquiryResponse.new(
|
120
|
+
@client.call( :do_inquiry, message: { 'Inquiry': {
|
121
|
+
'ResponseDataType': 'Xml',
|
122
|
+
'Parameters': {
|
123
|
+
'MyNameValue': parameters.map { |name, value|
|
124
|
+
{'Name': name, 'Value': value}
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}})
|
128
|
+
)
|
129
|
+
end
|
130
|
+
|
131
|
+
alias_method :check_eligibility, :do_inquiry
|
132
|
+
end
|
70
133
|
end
|
71
134
|
end
|
72
135
|
end
|
73
136
|
end
|
74
|
-
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module Trizetto
|
2
|
+
module Api
|
3
|
+
module Eligibility
|
4
|
+
module WebService
|
5
|
+
|
6
|
+
# A Benefit provided by the insurance.
|
7
|
+
#
|
8
|
+
# <b>Example XML</b>
|
9
|
+
#
|
10
|
+
# <benefit>
|
11
|
+
# <info>Out of Pocket (Stop Loss)</info>
|
12
|
+
# <coveragelevel>Family</coveragelevel>
|
13
|
+
# <servicetype>Health Benefit Plan Coverage</servicetype>
|
14
|
+
# <servicetypecode>30</servicetypecode>
|
15
|
+
# <time_period_qualifier>Remaining</time_period_qualifier>
|
16
|
+
# <benefitamount>13097.6</benefitamount>
|
17
|
+
# <plannetworkindicator>In Plan-Network</plannetworkindicator>
|
18
|
+
# <message>BUT NO MORE THAN INDIVIDUAL AMOUNT PER MEMBER (ACCUMULATES WITH OUT-OF-NETWORK AMOUNTS)</message>
|
19
|
+
# <message>CALCULATION INCLUDES DEDUCTIBLE, COPAYMENTS AND COINSURANCE FOR MEDICAL AND PRESCRIPTION DRUG BENEFITS.</message>
|
20
|
+
# </benefit>
|
21
|
+
#
|
22
|
+
# <b>Example</b>
|
23
|
+
#
|
24
|
+
# benefit.info # => "Out of Pocket (Stop Loss)"
|
25
|
+
# benefit.messages # => ["BUT NO MORE THAN...", "CALCULATION INCLUDES ...."]
|
26
|
+
#
|
27
|
+
# <b>Example XML</b>
|
28
|
+
#
|
29
|
+
# <benefit>
|
30
|
+
# <info>Active Coverage</info>
|
31
|
+
# <coveragelevel>Family</coveragelevel>
|
32
|
+
# <servicetype>Health Benefit Plan Coverage</servicetype>
|
33
|
+
# <servicetypecode>30</servicetypecode>
|
34
|
+
# <insurancetype>Preferred Provider Organization (PPO)</insurancetype>
|
35
|
+
# <insurancetypecode>PR</insurancetypecode>
|
36
|
+
# <plancoveragedescription>PPO - PREFERRED BLUE PPO SAVER</plancoveragedescription>
|
37
|
+
# </benefit>
|
38
|
+
#
|
39
|
+
# <b>Example</b>
|
40
|
+
#
|
41
|
+
# benefit.info # => "Active Coverage<"
|
42
|
+
# benefit.service_type_codes # => ["30"]
|
43
|
+
#
|
44
|
+
class Benefit < Node
|
45
|
+
REQUIRED_KEYS =
|
46
|
+
{
|
47
|
+
info: '',
|
48
|
+
service_type_codes: [],
|
49
|
+
messages: [],
|
50
|
+
}
|
51
|
+
|
52
|
+
KEY_CLEANUP =
|
53
|
+
{
|
54
|
+
benefitamount: :benefit_amount,
|
55
|
+
benefitentity: :entity,
|
56
|
+
coveragelevel: :coverage_level,
|
57
|
+
datequalifier: :date_qualifier,
|
58
|
+
insurancetype: :insurance_type,
|
59
|
+
insurancetypecode: :insurance_type_code,
|
60
|
+
plancoveragedescription: :plan_coverage_description,
|
61
|
+
plannetworkindicator: :plan_network_indicator,
|
62
|
+
quantityqualifier: :quantity_qualifier,
|
63
|
+
servicetype: :service_type,
|
64
|
+
servicetypecode: :service_type_code,
|
65
|
+
}
|
66
|
+
|
67
|
+
def initialize(raw_hash = {})
|
68
|
+
clean_hash = raw_hash.dup
|
69
|
+
|
70
|
+
# Convert message, which is either a single or multiple entry int
|
71
|
+
# the SOAP, which then gets turned into a string or an array by
|
72
|
+
# Nori into a messages aaray
|
73
|
+
clean_hash[:messages] = Array(clean_hash.delete(:message)) if clean_hash.has_key?(:message)
|
74
|
+
|
75
|
+
# Service type codes indicate the type of benefit.
|
76
|
+
# The magic decoder for ID => human meaning is here: http://www.x12.org/codes/health-care-service-type-codes/
|
77
|
+
# Multiple service type codes with the same benfit are combined with a ^
|
78
|
+
# so we turn a single servicetypecode entry into an array of service types
|
79
|
+
clean_hash[:service_type_codes] = (clean_hash.delete(:servicetypecode) || '').split("^")
|
80
|
+
|
81
|
+
super(clean_hash)
|
82
|
+
|
83
|
+
if self.entity.is_a?(Hash)
|
84
|
+
self.entity = BenefitEntity.new(self.entity)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Is this active insurance coverage?
|
89
|
+
def active_coverage?
|
90
|
+
info == "Active Coverage"
|
91
|
+
end
|
92
|
+
|
93
|
+
def inactive?
|
94
|
+
info == "Inactive"
|
95
|
+
end
|
96
|
+
|
97
|
+
def co_insurance?
|
98
|
+
info == "Co-Insurance"
|
99
|
+
end
|
100
|
+
|
101
|
+
def limitation?
|
102
|
+
info == "Limitations"
|
103
|
+
end
|
104
|
+
|
105
|
+
def non_covered?
|
106
|
+
info == "Non-Covered"
|
107
|
+
end
|
108
|
+
|
109
|
+
def primary_care_provider?
|
110
|
+
info == "Primary Care Provider"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|