Class: CandidApiClient::PreEncounter::Appointments::V1::AsyncV1Client

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::AsyncV1Client

Parameters:



296
297
298
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 296

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientCandidApiClient::AsyncRequestClient (readonly)



292
293
294
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 292

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:



341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 341

def create(request:, 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 || {}), **(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
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)


561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 561

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



406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 406

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



432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 432

def get_history(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: 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
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:



372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 372

def get_visits(page_token: nil, limit: nil, sort_field: nil, sort_direction: nil, filters: 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 || {}),
        "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
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:



527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 527

def scan(since:, 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 || {}), "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
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:



500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/candidhealth/pre_encounter/appointments/v_1/client.rb', line 500

def update(id:, version:, request:, request_options: nil)
  Async do
    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
end