Class: CandidApiClient::PreEncounter::Appointments::V1::V1Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ CandidApiClient::PreEncounter::Appointments::V1::V1Client

Parameters:



20
21
22
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 20

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientCandidApiClient::RequestClient (readonly)



16
17
18
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 16

def request_client
  @request_client
end

Instance Method Details

#create(request:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment

Adds an appointment. VersionConflictError is returned when the

placer_appointment_id is already in use.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.appointments.v_1.create(request: { patient_id: "string", start_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z), status: PENDING, service_duration: 1, services: [{ universal_service_identifier: MD_VISIT, start_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z) }], placer_appointment_id: "string", attending_doctor: { name: { family: "string", given: ["string"], use: USUAL, period: {  } }, type: PRIMARY, npi: "string", telecoms: [{ value: "string", use: HOME }], addresses: , period: {  }, canonical_id: "string" }, estimated_copay_cents: 1, estimated_patient_responsibility_cents: 1, patient_deposit_cents: 1, checked_in_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z), notes: "string", location_resource_id: "string", automated_eligibility_check_complete: true, work_queue: EMERGENT_ISSUE })

Parameters:

  • request (Hash)

    Request of type CandidApiClient::PreEncounter::Appointments::V1::Types::MutableAppointment, as a Hash

    • :patient_id (String)

    • :start_timestamp (DateTime)

    • :status (CandidApiClient::PreEncounter::Appointments::V1::Types::AppointmentStatus)

    • :service_duration (Integer)

    • :services (Array<CandidApiClient::PreEncounter::Appointments::V1::Types::Service>)

    • :placer_appointment_id (String)

    • :attending_doctor (Hash)

      • :name (Hash)

        • :family (String)

        • :given (Array<String>)

        • :use (CandidApiClient::PreEncounter::Common::Types::NameUse)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

      • :type (CandidApiClient::PreEncounter::Common::Types::ExternalProviderType)

      • :npi (String)

      • :telecoms (Array<CandidApiClient::PreEncounter::Common::Types::ContactPoint>)

      • :addresses (Array<CandidApiClient::PreEncounter::Common::Types::Address>)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

      • :canonical_id (String)

    • :estimated_copay_cents (Integer)

    • :estimated_patient_responsibility_cents (Integer)

    • :patient_deposit_cents (Integer)

    • :checked_in_timestamp (DateTime)

    • :notes (String)

    • :location_resource_id (String)

    • :automated_eligibility_check_complete (Boolean)

    • :work_queue (CandidApiClient::PreEncounter::Appointments::V1::Types::AppointmentWorkQueue)

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

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 63

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: PreEncounter,
                                       request_options: request_options)}/appointments/v1"
  end
  CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment.from_json(json_object: response.body)
end

#deactivate(id:, version:, request_options: nil) ⇒ Void

Sets an appointment as deactivated. The path must contain the most recent

version to prevent race conditions. Deactivating historic versions is not
supported. Subsequent updates via PUT to the appointment will "reactivate" the
appointment and set the deactivated flag to false.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.appointments.v_1.deactivate(id: "string", version: "string")

Parameters:

Returns:

  • (Void)


232
233
234
235
236
237
238
239
240
241
242
243
244
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 232

def deactivate(id:, version:, 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: PreEncounter,
                                       request_options: request_options)}/appointments/v1/#{id}/#{version}"
  end
end

#get(id:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment

Gets an appointment.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.appointments.v_1.get(id: "string")

Parameters:

Returns:



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

def get(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: PreEncounter,
                                       request_options: request_options)}/appointments/v1/#{id}"
  end
  CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment.from_json(json_object: response.body)
end

#get_history(id:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment>

Gets an appointment along with it’s full history. The return list is ordered by

version ascending.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.appointments.v_1.get_history(id: "string")

Parameters:

Returns:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 111

def get_history(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: PreEncounter,
                                       request_options: request_options)}/appointments/v1/#{id}/history"
  end
  parsed_json = JSON.parse(response.body)
  parsed_json&.map do |item|
    item = item.to_json
    CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment.from_json(json_object: item)
  end
end

#scan(since:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment>

Scans up to 100 appointment updates. The since query parameter is inclusive, and

the result list is ordered by updatedAt ascending.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.appointments.v_1.scan(since: DateTime.parse(2024-01-15T09:30:00.000Z))

Parameters:

Returns:



200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 200

def scan(since:, 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 || {}), "since": since }.compact
    req.url "#{@request_client.get_url(environment: PreEncounter,
                                       request_options: request_options)}/appointments/v1/updates/scan"
  end
  parsed_json = JSON.parse(response.body)
  parsed_json&.map do |item|
    item = item.to_json
    CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment.from_json(json_object: item)
  end
end

#update(id:, version:, request:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment

Updates an appointment. The path must contain the most recent version to prevent

race conditions. Updating historic versions is not supported.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.appointments.v_1.update(
  id: "string",
  version: "string",
  request: { patient_id: "string", start_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z), status: PENDING, service_duration: 1, services: [{ universal_service_identifier: MD_VISIT, start_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z) }], placer_appointment_id: "string", attending_doctor: { name: { family: "string", given: ["string"], use: USUAL, period: {  } }, type: PRIMARY, npi: "string", telecoms: [{ value: "string", use: HOME }], addresses: , period: {  }, canonical_id: "string" }, estimated_copay_cents: 1, estimated_patient_responsibility_cents: 1, patient_deposit_cents: 1, checked_in_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z), notes: "string", location_resource_id: "string", automated_eligibility_check_complete: true, work_queue: EMERGENT_ISSUE }
)

Parameters:

  • id (String)
  • version (String)
  • request (Hash)

    Request of type CandidApiClient::PreEncounter::Appointments::V1::Types::MutableAppointment, as a Hash

    • :patient_id (String)

    • :start_timestamp (DateTime)

    • :status (CandidApiClient::PreEncounter::Appointments::V1::Types::AppointmentStatus)

    • :service_duration (Integer)

    • :services (Array<CandidApiClient::PreEncounter::Appointments::V1::Types::Service>)

    • :placer_appointment_id (String)

    • :attending_doctor (Hash)

      • :name (Hash)

        • :family (String)

        • :given (Array<String>)

        • :use (CandidApiClient::PreEncounter::Common::Types::NameUse)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

      • :type (CandidApiClient::PreEncounter::Common::Types::ExternalProviderType)

      • :npi (String)

      • :telecoms (Array<CandidApiClient::PreEncounter::Common::Types::ContactPoint>)

      • :addresses (Array<CandidApiClient::PreEncounter::Common::Types::Address>)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

      • :canonical_id (String)

    • :estimated_copay_cents (Integer)

    • :estimated_patient_responsibility_cents (Integer)

    • :patient_deposit_cents (Integer)

    • :checked_in_timestamp (DateTime)

    • :notes (String)

    • :location_resource_id (String)

    • :automated_eligibility_check_complete (Boolean)

    • :work_queue (CandidApiClient::PreEncounter::Appointments::V1::Types::AppointmentWorkQueue)

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

Returns:



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 175

def update(id:, version:, request:, request_options: nil)
  response = @request_client.conn.put 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: PreEncounter,
                                       request_options: request_options)}/appointments/v1/#{id}/#{version}"
  end
  CandidApiClient::PreEncounter::Appointments::V1::Types::Appointment.from_json(json_object: response.body)
end