Class: Candid::PreEncounter::EligibilityChecks::V1::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/candid/pre_encounter/eligibility_checks/v_1/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:, base_url: nil, environment: nil) ⇒ void

Parameters:



13
14
15
16
17
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 13

def initialize(client:, base_url: nil, environment: nil)
  @client = client
  @base_url = base_url
  @environment = environment
end

Instance Method Details

#batch(request_options: {}, **params) ⇒ Candid::PreEncounter::EligibilityChecks::V1::Types::BatchEligibilityResponse

Sends a batch of eligibility checks to payers through Stedi.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 64

def batch(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:pre_encounter),
    method: "POST",
    path: "/eligibility-checks/v1/batch",
    body: params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::EligibilityChecks::V1::Types::BatchEligibilityResponse.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#coordination_of_benefits(request_options: {}, **params) ⇒ Candid::PreEncounter::EligibilityChecks::V1::Types::CoordinationOfBenefitsResponse

Sends a coordination of benefits check through Stedi to determine whether a patient has coverage overlap across multiple payers and, if so, which payer is primary. Medicare and Medicare Advantage plans are not supported.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 385

def coordination_of_benefits(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:pre_encounter),
    method: "POST",
    path: "/eligibility-checks/v1/coordination-of-benefits",
    body: Candid::PreEncounter::EligibilityChecks::V1::Types::CoordinationOfBenefitsRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::EligibilityChecks::V1::Types::CoordinationOfBenefitsResponse.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#create_recommendation(request_options: {}, **params) ⇒ Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityRecommendation

Create an eligibiilty recommendation based on the request.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 224

def create_recommendation(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:pre_encounter),
    method: "POST",
    path: "/eligibility-checks/v1/recommendation",
    body: Candid::PreEncounter::EligibilityChecks::V1::Types::PostEligibilityRecommendationRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityRecommendation.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_multi(request_options: {}, **params) ⇒ Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityCheckPage

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :page_token (String, nil)
  • :limit (Integer, nil)
  • :subscriber_member_id (String, nil)
  • :payer_id (String, nil)
  • :provider_npi (String, nil)
  • :date_of_service (String, nil)
  • :initiated_at_min (String, nil)
  • :initiated_at_max (String, nil)

Returns:



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 302

def get_multi(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[page_token limit subscriber_member_id payer_id provider_npi date_of_service initiated_at_min initiated_at_max]
  query_params = {}
  query_params["page_token"] = params[:page_token] if params.key?(:page_token)
  query_params["limit"] = params[:limit] if params.key?(:limit)
  query_params["subscriber_member_id"] = params[:subscriber_member_id] if params.key?(:subscriber_member_id)
  query_params["payer_id"] = params[:payer_id] if params.key?(:payer_id)
  query_params["provider_npi"] = params[:provider_npi] if params.key?(:provider_npi)
  query_params["date_of_service"] = params[:date_of_service] if params.key?(:date_of_service)
  query_params["initiated_at_min"] = params[:initiated_at_min] if params.key?(:initiated_at_min)
  query_params["initiated_at_max"] = params[:initiated_at_max] if params.key?(:initiated_at_max)
  params.except(*query_param_names)

  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:pre_encounter),
    method: "GET",
    path: "/eligibility-checks/v1/get-multi/",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityCheckPage.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#insurance_discovery(request_options: {}, **params) ⇒ Candid::PreEncounter::EligibilityChecks::V1::Types::InsuranceDiscoveryResponse

Sends an insurance discovery check to find potential coverage matches for a patient through Stedi. Given patient demographics, this endpoint discovers what insurance coverages exist for the patient.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 349

def insurance_discovery(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:pre_encounter),
    method: "POST",
    path: "/eligibility-checks/v1/insurance-discovery",
    body: Candid::PreEncounter::EligibilityChecks::V1::Types::InsuranceDiscoveryRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::EligibilityChecks::V1::Types::InsuranceDiscoveryResponse.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#payer_search(request_options: {}, **params) ⇒ Candid::PreEncounter::EligibilityChecks::V1::Types::PayerSearchResponse

Searches for payers that match the query parameters.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :page_size (Integer, nil)
  • :page_token (String, nil)
  • :query (String, nil)

Returns:



142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 142

def payer_search(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[page_size page_token query]
  query_params = {}
  query_params["page_size"] = params[:page_size] if params.key?(:page_size)
  query_params["page_token"] = params[:page_token] if params.key?(:page_token)
  query_params["query"] = params[:query] if params.key?(:query)
  params.except(*query_param_names)

  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:pre_encounter),
    method: "GET",
    path: "/eligibility-checks/v1/payer/search",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::EligibilityChecks::V1::Types::PayerSearchResponse.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#poll_batch(request_options: {}, **params) ⇒ Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityCheckPage

Polls the status of a batch eligibility check.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :batch_id (String)
  • :page_token (String, nil)

Returns:



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 100

def poll_batch(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[page_token]
  query_params = {}
  query_params["page_token"] = params[:page_token] if params.key?(:page_token)
  params = params.except(*query_param_names)

  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:pre_encounter),
    method: "GET",
    path: "/eligibility-checks/v1/batch/#{params[:batch_id]}",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityCheckPage.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#post(request_options: {}, **params) ⇒ Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityCheck

Sends real-time eligibility checks to payers through Stedi.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 30

def post(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:pre_encounter),
    method: "POST",
    path: "/eligibility-checks/v1",
    body: Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityResponse.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#recommendation(request_options: {}, **params) ⇒ Array[Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityRecommendation]

Gets recommendation for eligibility checks based on filters. This endpoint will retrieve all the latest eligibility recommendations for each eligibility recommendation type for the given filters. If you want to get a specific recommendation type, you can use the ‘type` query parameter.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :filters (String, nil)

Returns:

Raises:

  • (error_class)


187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 187

def recommendation(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  query_param_names = %i[filters]
  query_params = {}
  query_params["filters"] = params[:filters] if params.key?(:filters)
  params.except(*query_param_names)

  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:pre_encounter),
    method: "GET",
    path: "/eligibility-checks/v1/recommendation",
    query: query_params,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = response.code.to_i
  return if code.between?(200, 299)

  error_class = Candid::Errors::ResponseError.subclass_for_code(code)
  raise error_class.new(response.body, code: code)
end

#vote_recommendation(request_options: {}, **params) ⇒ Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityRecommendation

Submit user feedback on an eligibility recommendation. The path must contain the next version number to prevent race conditions. For example, if the current version of the recommendation is n, you will need to send a request to this endpoint with ‘/recommendation_id/n+1/vote` to update the vote.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :recommendation_id (String)
  • :version (String)

Returns:



262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/candid/pre_encounter/eligibility_checks/v_1/client.rb', line 262

def vote_recommendation(request_options: {}, **params)
  params = Candid::Internal::Types::Utils.normalize_keys(params)
  request = Candid::Internal::JSON::Request.new(
    base_url: request_options[:base_url] || @base_url || @environment&.dig(:pre_encounter),
    method: "PUT",
    path: "/eligibility-checks/v1/recommendation/#{params[:recommendation_id]}/#{params[:version]}/vote",
    body: Candid::PreEncounter::EligibilityChecks::V1::Types::Vote.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Candid::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Candid::PreEncounter::EligibilityChecks::V1::Types::EligibilityRecommendation.load(response.body)
  else
    error_class = Candid::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end