Class: CandidApiClient::InsurancePayments::V1::V1Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ CandidApiClient::InsurancePayments::V1::V1Client

Parameters:



22
23
24
# File 'lib/candidhealth/insurance_payments/v_1/client.rb', line 22

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientCandidApiClient::RequestClient (readonly)



18
19
20
# File 'lib/candidhealth/insurance_payments/v_1/client.rb', line 18

def request_client
  @request_client
end

Instance Method Details

#create(request:, request_options: nil) ⇒ CandidApiClient::InsurancePayments::V1::Types::InsurancePayment

Creates a new insurance payment record and returns the newly created

`InsurancePayment` object. This endpoint
should only be used for insurance payments that do not have a corresponding ERA
(for example: a settlement check
from a payer). If the payment is an ERA, then you should used the
insurance-adjudications API.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.insurance_payments.v_1.create(request: { amount_cents: 1, payment_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z), payment_note: "string", allocations: [{ amount_cents: 1 }] })

Parameters:

  • request (Hash)

    Request of type CandidApiClient::InsurancePayments::V1::Types::InsurancePaymentCreate, as a Hash

    • :payer_identifier (Hash)

    • :amount_cents (Integer)

    • :payment_timestamp (DateTime)

    • :payment_note (String)

    • :allocations (Array<CandidApiClient::Financials::Types::AllocationCreate>)

  • request_options (CandidApiClient::RequestOptions) (defaults to: nil)

Returns:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/candidhealth/insurance_payments/v_1/client.rb', line 119

def create(request:, request_options: nil)
  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 || {}), **(request_options&.additional_body_parameters || {}) }.compact
    req.url "#{@request_client.get_url(environment: CandidApi,
                                       request_options: request_options)}/api/insurance-payments/v1"
  end
  CandidApiClient::InsurancePayments::V1::Types::InsurancePayment.from_json(json_object: response.body)
end

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

Deletes the insurance payment record matching the provided

`insurance_payment_id`.
If the matching record's organization_id does not match the authenticated user's
current organization_id, then a response code of `403` will be returned.

Examples:

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

Parameters:

Returns:

  • (Void)


178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/candidhealth/insurance_payments/v_1/client.rb', line 178

def delete(insurance_payment_id:, request_options: nil)
  @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/insurance-payments/v1/#{insurance_payment_id}"
  end
end

#get(insurance_payment_id:, request_options: nil) ⇒ CandidApiClient::InsurancePayments::V1::Types::InsurancePayment

Retrieves a previously created insurance payment by its ‘insurance_payment_id`.

If the payment does not exist, a `403` will be thrown.

Examples:

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

Parameters:

Returns:



86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/candidhealth/insurance_payments/v_1/client.rb', line 86

def get(insurance_payment_id:, request_options: nil)
  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/insurance-payments/v1/#{insurance_payment_id}"
  end
  CandidApiClient::InsurancePayments::V1::Types::InsurancePayment.from_json(json_object: response.body)
end

#get_multi(limit: nil, payer_uuid: nil, claim_id: nil, service_line_id: nil, billing_provider_id: nil, sort: nil, sort_direction: nil, page_token: nil, request_options: nil) ⇒ CandidApiClient::InsurancePayments::V1::Types::InsurancePaymentsPage

Returns all non-ERA originated insurance payments satisfying the search criteria

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.insurance_payments.v_1.get_multi(
  limit: 1,
  payer_uuid: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  claim_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  service_line_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  billing_provider_id: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32",
  sort: AMOUNT_CENTS,
  sort_direction: ASC,
  page_token: "eyJ0b2tlbiI6IjEiLCJwYWdlX3Rva2VuIjoiMiJ9"
)

Parameters:

Returns:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/candidhealth/insurance_payments/v_1/client.rb', line 50

def get_multi(limit: nil, payer_uuid: nil, claim_id: nil, service_line_id: nil, billing_provider_id: nil,
              sort: nil, sort_direction: nil, page_token: nil, request_options: nil)
  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,
      "payer_uuid": payer_uuid,
      "claim_id": claim_id,
      "service_line_id": service_line_id,
      "billing_provider_id": billing_provider_id,
      "sort": sort,
      "sort_direction": sort_direction,
      "page_token": page_token
    }.compact
    req.url "#{@request_client.get_url(environment: CandidApi,
                                       request_options: request_options)}/api/insurance-payments/v1"
  end
  CandidApiClient::InsurancePayments::V1::Types::InsurancePaymentsPage.from_json(json_object: response.body)
end

#update(insurance_payment_id:, payment_timestamp: nil, payment_note: nil, request_options: nil) ⇒ CandidApiClient::InsurancePayments::V1::Types::InsurancePayment

Updates the patient payment record matching the provided insurance_payment_id.

If updating the payment amount,
then the allocations must be appropriately updated as well.

Examples:

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

Parameters:

Returns:



147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# File 'lib/candidhealth/insurance_payments/v_1/client.rb', line 147

def update(insurance_payment_id:, payment_timestamp: nil, payment_note: nil, request_options: nil)
  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 || {}),
      payment_timestamp: payment_timestamp,
      payment_note: payment_note
    }.compact
    req.url "#{@request_client.get_url(environment: CandidApi,
                                       request_options: request_options)}/api/insurance-payments/v1/#{insurance_payment_id}"
  end
  CandidApiClient::InsurancePayments::V1::Types::InsurancePayment.from_json(json_object: response.body)
end