Class: ChangeHealthcare::ProfessionalClaims::Wrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/change_healthcare/professional_claims/wrapper.rb

Overview

Wrapper module, wraps the auto-generated swagger code in a slightly nicer-to-use format.

This is a semi-stateful, thread-safe wrapper. It will get auth tokens for you when needed.

Defined Under Namespace

Classes: AuthToken, BadAuthRequestError, BadAuthorizationError, UnknownAuthError

Instance Method Summary collapse

Constructor Details

#initialize(client_id:, client_secret:) ⇒ Wrapper

Returns a new instance of Wrapper.



15
16
17
18
19
20
21
22
# File 'lib/change_healthcare/professional_claims/wrapper.rb', line 15

def initialize(client_id:, client_secret:)
  @client_id = client_id
  @client_secret = client_secret
  @api = SwaggerClient::ProfessionalClaimsApi.new
  # fake auth token that is expired
  @auth_token = AuthToken.new('', Time.at(0))
  @mutex = Mutex.new
end

Instance Method Details

#auth_tokenObject

Obtain a valid authentication token. This method may request a new token if the in-use token is expired. It will do this in a thread-safe manner.

Raises:



84
85
86
87
88
89
90
# File 'lib/change_healthcare/professional_claims/wrapper.rb', line 84

def auth_token
  @mutex.synchronize do
    fetch_new_token! unless @auth_token.valid?

    @auth_token
  end
end

#health_checkChangeHealthcare::ProfessionalClaims::SwaggerClient::HealthCheck

Check health of the API

Returns:

  • (ChangeHealthcare::ProfessionalClaims::SwaggerClient::HealthCheck)


58
59
60
# File 'lib/change_healthcare/professional_claims/wrapper.rb', line 58

def health_check
  @api.health_check_using_get(auth_token.auth)
end

#process_claim(request, opts = {}) ⇒ ChangeHealthcare::ProfessionalClaims::SwaggerClient::Response

Submits a claim to the payer.

Parameters:

Returns:

Raises:



35
36
37
# File 'lib/change_healthcare/professional_claims/wrapper.rb', line 35

def process_claim(request, opts = {})
  @api.process_claim_using_post(auth_token.auth, request, opts)
end

#validate_claim(request, opts = {}) ⇒ ChangeHealthcare::ProfessionalClaims::SwaggerClient::Response

Validate the syntax of a claim without submitting it to the payor.

Parameters:

Returns:

Raises:



50
51
52
# File 'lib/change_healthcare/professional_claims/wrapper.rb', line 50

def validate_claim(request, opts = {})
  @api.validate_claim_using_post(auth_token.auth, request, opts)
end