Class: CandidApiClient::PatientRefunds::V1::AsyncV1Client

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/patient_refunds/v_1/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ CandidApiClient::PatientRefunds::V1::AsyncV1Client

Parameters:



233
234
235
# File 'lib/candidhealth/patient_refunds/v_1/client.rb', line 233

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientCandidApiClient::AsyncRequestClient (readonly)



229
230
231
# File 'lib/candidhealth/patient_refunds/v_1/client.rb', line 229

def request_client
  @request_client
end

Instance Method Details

#create(amount_cents:, patient_external_id:, allocations:, refund_timestamp: nil, refund_note: nil, invoice: nil, refund_reason: nil, request_options: nil) ⇒ CandidApiClient::PatientRefunds::V1::Types::PatientRefund

Creates a new patient refund record and returns the newly created PatientRefund

object.
The allocations can describe whether the refund is being applied toward a
specific service line,
claim, or billing provider.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.patient_refunds.v_1.create(
  amount_cents: 1,
  refund_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z),
  refund_note: "string",
  patient_external_id: "string",
  allocations: [{ amount_cents: 1 }],
  invoice: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  refund_reason: OVERCHARGED
)

Parameters:

  • amount_cents (Integer)
  • refund_timestamp (DateTime) (defaults to: nil)
  • refund_note (String) (defaults to: nil)
  • patient_external_id (String)
  • allocations (Array<Hash>)

    Request of type Array<CandidApiClient::Financials::Types::AllocationCreate>, as a Hash

    • :amount_cents (Integer)

    • :target (Hash)

  • invoice (String) (defaults to: nil)
  • refund_reason (CandidApiClient::Financials::Types::RefundReason) (defaults to: nil)
  • request_options (CandidApiClient::RequestOptions) (defaults to: nil)

Returns:



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/candidhealth/patient_refunds/v_1/client.rb', line 354

def create(amount_cents:, patient_external_id:, allocations:, refund_timestamp: nil, refund_note: nil,
           invoice: nil, refund_reason: nil, request_options: nil)
  Async do
    response = @request_client.conn.post do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.body = {
        **(request_options&.additional_body_parameters || {}),
        amount_cents: amount_cents,
        refund_timestamp: refund_timestamp,
        refund_note: refund_note,
        patient_external_id: patient_external_id,
        allocations: allocations,
        invoice: invoice,
        refund_reason: refund_reason
      }.compact
      req.url "#{@request_client.get_url(environment: CandidApi,
                                         request_options: request_options)}/api/patient-refunds/v1"
    end
    CandidApiClient::PatientRefunds::V1::Types::PatientRefund.from_json(json_object: response.body)
  end
end

#delete(patient_refund_id:, request_options: nil) ⇒ Void

Deletes the patient refund record matching the provided patient_refund_id.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.patient_refunds.v_1.delete(patient_refund_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")

Parameters:

Returns:

  • (Void)


427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
# File 'lib/candidhealth/patient_refunds/v_1/client.rb', line 427

def delete(patient_refund_id:, request_options: nil)
  Async do
    @request_client.conn.delete do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.url "#{@request_client.get_url(environment: CandidApi,
                                         request_options: request_options)}/api/patient-refunds/v1/#{patient_refund_id}"
    end
  end
end

#get(patient_refund_id:, request_options: nil) ⇒ CandidApiClient::PatientRefunds::V1::Types::PatientRefund

Retrieves a previously created patient refund by its ‘patient_refund_id`.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.patient_refunds.v_1.get(patient_refund_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32")

Parameters:

Returns:



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
# File 'lib/candidhealth/patient_refunds/v_1/client.rb', line 309

def get(patient_refund_id:, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.url "#{@request_client.get_url(environment: CandidApi,
                                         request_options: request_options)}/api/patient-refunds/v1/#{patient_refund_id}"
    end
    CandidApiClient::PatientRefunds::V1::Types::PatientRefund.from_json(json_object: response.body)
  end
end

#get_multi(limit: nil, patient_external_id: nil, claim_id: nil, service_line_id: nil, billing_provider_id: nil, unattributed: nil, invoice_id: nil, sources: nil, sort: nil, sort_direction: nil, page_token: nil, request_options: nil) ⇒ CandidApiClient::PatientRefunds::V1::Types::PatientRefundsPage

Returns all patient refunds satisfying the search criteria AND whose

organization_id matches
the current organization_id of the authenticated user.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.patient_refunds.v_1.get_multi(
  limit: 1,
  patient_external_id: "string",
  claim_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  service_line_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  billing_provider_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  unattributed: true,
  invoice_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  sources: MANUAL_ENTRY,
  sort: REFUND_SOURCE,
  sort_direction: ASC,
  page_token: "eyJ0b2tlbiI6IjEiLCJwYWdlX3Rva2VuIjoiMiJ9"
)

Parameters:

Returns:



269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/candidhealth/patient_refunds/v_1/client.rb', line 269

def get_multi(limit: nil, patient_external_id: nil, claim_id: nil, service_line_id: nil,
              billing_provider_id: nil, unattributed: nil, invoice_id: nil, sources: nil, sort: nil, sort_direction: nil, page_token: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.params = {
        **(request_options&.additional_query_parameters || {}),
        "limit": limit,
        "patient_external_id": patient_external_id,
        "claim_id": claim_id,
        "service_line_id": service_line_id,
        "billing_provider_id": billing_provider_id,
        "unattributed": unattributed,
        "invoice_id": invoice_id,
        "sources": sources,
        "sort": sort,
        "sort_direction": sort_direction,
        "page_token": page_token
      }.compact
      req.url "#{@request_client.get_url(environment: CandidApi,
                                         request_options: request_options)}/api/patient-refunds/v1"
    end
    CandidApiClient::PatientRefunds::V1::Types::PatientRefundsPage.from_json(json_object: response.body)
  end
end

#update(patient_refund_id:, refund_timestamp: nil, refund_note: nil, invoice: nil, refund_reason: nil, request_options: nil) ⇒ CandidApiClient::PatientRefunds::V1::Types::PatientRefund

Updates the patient refund record matching the provided patient_refund_id.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.patient_refunds.v_1.update(patient_refund_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", refund_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z))

Parameters:

Returns:



394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
# File 'lib/candidhealth/patient_refunds/v_1/client.rb', line 394

def update(patient_refund_id:, refund_timestamp: nil, refund_note: nil, invoice: nil, refund_reason: nil,
           request_options: nil)
  Async do
    response = @request_client.conn.patch do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.body = {
        **(request_options&.additional_body_parameters || {}),
        refund_timestamp: refund_timestamp,
        refund_note: refund_note,
        invoice: invoice,
        refund_reason: refund_reason
      }.compact
      req.url "#{@request_client.get_url(environment: CandidApi,
                                         request_options: request_options)}/api/patient-refunds/v1/#{patient_refund_id}"
    end
    CandidApiClient::PatientRefunds::V1::Types::PatientRefund.from_json(json_object: response.body)
  end
end