Class: ChangeHealth::Request::Claim::Submission

Inherits:
Hashie::Trash
  • Object
show all
Defined in:
lib/change_health/request/submission.rb

Constant Summary collapse

PROFESSIONAL_ENDPOINT =
'/medicalnetwork/professionalclaims/v3'
INSTITUTIONAL_ENDPOINT =
'/medicalnetwork/institutionalclaims/v1'
HEALTH_CHECK_SUFFIX =
'/healthcheck'
SUBMISSION_SUFFIX =
'/submission'
VALIDATION_SUFFIX =
'/validation'
ENDPOINT =

Deprecated but still here for backwards compatibility

PROFESSIONAL_ENDPOINT
HEALTH_CHECK_ENDPOINT =
"#{ENDPOINT}/healthcheck"
SUBMISSION_ENDPOINT =
"#{ENDPOINT}/submission"
VALIDATION_ENDPOINT =
"#{ENDPOINT}/validation"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.endpoint(is_professional: true, suffix: '') ⇒ Object



89
90
91
92
93
94
95
96
97
# File 'lib/change_health/request/submission.rb', line 89

def self.endpoint(is_professional: true, suffix: '')
  default_endpoint = is_professional ? PROFESSIONAL_ENDPOINT : INSTITUTIONAL_ENDPOINT
  default_endpoint += suffix

  ChangeHealth::Connection.endpoint_for(
    ChangeHealth::Request::Claim::Submission,
    default_endpoint: default_endpoint
  )
end

.health_check(is_professional: true) ⇒ Object



75
76
77
78
79
80
81
82
83
# File 'lib/change_health/request/submission.rb', line 75

def self.health_check(is_professional: true)
  ChangeHealth::Connection.new.request(
    endpoint: endpoint(
      is_professional: is_professional,
      suffix: HEALTH_CHECK_SUFFIX
    ),
    verb: :get
  )
end

.ping(is_professional: true) ⇒ Object



85
86
87
# File 'lib/change_health/request/submission.rb', line 85

def self.ping(is_professional: true)
  health_check(is_professional: is_professional)
end

Instance Method Details

#add_provider(provider) ⇒ Object



40
41
42
43
# File 'lib/change_health/request/submission.rb', line 40

def add_provider(provider)
  self[:providers] ||= []
  self[:providers] << provider
end

#institutional_headersObject



110
111
112
113
114
115
116
117
118
119
# File 'lib/change_health/request/submission.rb', line 110

def institutional_headers
  return unless self[:headers]

  {
    'X-CHC-InstitutionalClaims-BillerId' => self[:headers][:biller_id],
    'X-CHC-InstitutionalClaims-Pwd' => self[:headers][:password],
    'X-CHC-InstitutionalClaims-SubmitterId' => self[:headers][:submitter_id],
    'X-CHC-InstitutionalClaims-Username' => self[:headers][:username]
  }
end

#professional_headersObject



99
100
101
102
103
104
105
106
107
108
# File 'lib/change_health/request/submission.rb', line 99

def professional_headers
  return unless self[:headers]

  {
    'X-CHC-ClaimSubmission-BillerId' => self[:headers][:biller_id],
    'X-CHC-ClaimSubmission-Pwd' => self[:headers][:password],
    'X-CHC-ClaimSubmission-SubmitterId' => self[:headers][:submitter_id],
    'X-CHC-ClaimSubmission-Username' => self[:headers][:username]
  }
end

#submission(is_professional: true, headers: nil, base_uri: nil, auth_headers: nil, endpoint: nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/change_health/request/submission.rb', line 45

def submission(is_professional: true, headers: nil, base_uri: nil, auth_headers: nil, endpoint: nil)
  headers ||= is_professional ? professional_headers : institutional_headers
  endpoint ||= self.class.endpoint(
    is_professional: is_professional,
    suffix: SUBMISSION_SUFFIX
  )
  ChangeHealth::Response::Claim::SubmissionData.new(
    response: ChangeHealth::Connection.new.request(
      endpoint: endpoint,
      base_uri: base_uri,
      body: to_h,
      headers: headers,
      auth_headers: auth_headers
    )
  )
end

#validation(is_professional: true) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/change_health/request/submission.rb', line 62

def validation(is_professional: true)
  ChangeHealth::Response::Claim::SubmissionData.new(
    response: ChangeHealth::Connection.new.request(
      endpoint: self.class.endpoint(
        is_professional: is_professional,
        suffix: VALIDATION_SUFFIX
      ),
      body: to_h,
      headers: is_professional ? professional_headers : institutional_headers
    )
  )
end