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:



22
23
24
# File 'lib/candidhealth/pre_encounter/appointments/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/pre_encounter/appointments/v_1/client.rb', line 18

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: "patient_id", start_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z), service_duration: 1, services: [{  }, {  }] })

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)

        • :suffix (String)

      • :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)

      • :fax (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:



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 67

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: "id", version: "version")

Parameters:

Returns:

  • (Void)


275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 275

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: "id")

Parameters:

Returns:



128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 128

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: "id")

Parameters:

Returns:



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 152

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

#get_visits(page_token: nil, limit: nil, sort_field: nil, sort_direction: nil, filters: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Appointments::V1::Types::VisitsPage

Gets all Visits within a given time range. The return list is ordered by

start_time ascending.

Examples:

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

Parameters:

Returns:



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 96

def get_visits(page_token: nil, limit: nil, sort_field: nil, sort_direction: nil, filters: 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 || {}),
      "page_token": page_token,
      "limit": limit,
      "sort_field": sort_field,
      "sort_direction": sort_direction,
      "filters": filters
    }.compact
    req.url "#{@request_client.get_url(environment: PreEncounter,
                                       request_options: request_options)}/appointments/v1/visits"
  end
  CandidApiClient::PreEncounter::Appointments::V1::Types::VisitsPage.from_json(json_object: response.body)
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:



243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 243

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: "id",
  version: "version",
  request: { patient_id: "patient_id", start_timestamp: DateTime.parse(2024-01-15T09:30:00.000Z), service_duration: 1, services: [{  }, {  }] }
)

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)

        • :suffix (String)

      • :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)

      • :fax (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:



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 218

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