Class: Candid::PreEncounter::Appointments::V1::Client
- Inherits:
-
Object
- Object
- Candid::PreEncounter::Appointments::V1::Client
- Defined in:
- lib/candid/pre_encounter/appointments/v_1/client.rb
Instance Method Summary collapse
-
#create(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Adds an appointment.
-
#deactivate(request_options: {}, **params) ⇒ untyped
Sets an appointment as deactivated.
-
#get(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Gets an appointment.
-
#get_counts(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::CountsResponse
Gets aggregate counts for the visits matching the given filters.
-
#get_history(request_options: {}, **params) ⇒ Array[Candid::PreEncounter::Appointments::V1::Types::Appointment]
Gets an appointment along with it’s full history.
-
#get_visits(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::VisitsPage
Gets all Visits within a given time range.
- #initialize(client:, base_url: nil, environment: nil) ⇒ void constructor
-
#scan(request_options: {}, **params) ⇒ Array[Candid::PreEncounter::Appointments::V1::Types::Appointment]
Scans up to 100 appointment updates.
-
#update(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Updates an appointment.
Constructor Details
#initialize(client:, base_url: nil, environment: nil) ⇒ void
13 14 15 16 17 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 13 def initialize(client:, base_url: nil, environment: nil) @client = client @base_url = base_url @environment = environment end |
Instance Method Details
#create(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Adds an appointment. VersionConflictError is returned when the placer_appointment_id is already in use.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 30 def create(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:pre_encounter), method: "POST", path: "/appointments/v1", body: Candid::PreEncounter::Appointments::V1::Types::MutableAppointment.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Candid::PreEncounter::Appointments::V1::Types::Appointment.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#deactivate(request_options: {}, **params) ⇒ untyped
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.
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 318 def deactivate(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:pre_encounter), method: "DELETE", path: "/appointments/v1/#{params[:id]}/#{params[:version]}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#get(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Gets an appointment.
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 172 def get(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:pre_encounter), method: "GET", path: "/appointments/v1/#{params[:id]}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Candid::PreEncounter::Appointments::V1::Types::Appointment.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_counts(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::CountsResponse
Gets aggregate counts for the visits matching the given filters.
The counts respect all provided filters but are independent of pagination, so this can be fetched once when filters change instead of on every page of ‘get_visits`.
IMPORTANT: Like ‘get_visits`, this endpoint requires a date filter on `appointment.startTimestamp` to ensure acceptable query performance.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 132 def get_counts(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[filters] query_params = {} query_params["filters"] = params[:filters] if params.key?(:filters) params.except(*query_param_names) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:pre_encounter), method: "GET", path: "/appointments/v1/visits/counts", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Candid::PreEncounter::Appointments::V1::Types::CountsResponse.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_history(request_options: {}, **params) ⇒ Array[Candid::PreEncounter::Appointments::V1::Types::Appointment]
Gets an appointment along with it’s full history. The return list is ordered by version ascending.
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 206 def get_history(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:pre_encounter), method: "GET", path: "/appointments/v1/#{params[:id]}/history", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#get_visits(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::VisitsPage
Gets all Visits within a given time range. The return list is ordered by start_time ascending.
IMPORTANT: This endpoint requires a date filter on ‘appointment.startTimestamp` to ensure acceptable query performance. Without date filtering, the query can take 50+ seconds on large datasets due to grouping and aggregation operations.
Example filters:
-
‘appointment.startTimestamp|gt|2024-01-01` - appointments after January 1, 2024
-
‘appointment.startTimestamp|eq|2024-12-08` - appointments on December 8, 2024
-
‘appointment.startTimestamp|lt|2024-12-31` - appointments before December 31, 2024
You can combine the date filter with other filters using commas:
-
‘appointment.startTimestamp|gt|2024-01-01,appointment.status|eq|PENDING`
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 82 def get_visits(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[page_token limit sort_field sort_direction filters] query_params = {} query_params["page_token"] = params[:page_token] if params.key?(:page_token) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["sort_field"] = params[:sort_field] if params.key?(:sort_field) query_params["sort_direction"] = params[:sort_direction] if params.key?(:sort_direction) query_params["filters"] = params[:filters] if params.key?(:filters) params.except(*query_param_names) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:pre_encounter), method: "GET", path: "/appointments/v1/visits", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Candid::PreEncounter::Appointments::V1::Types::VisitsPage.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#scan(request_options: {}, **params) ⇒ Array[Candid::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.
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 277 def scan(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[since] query_params = {} query_params["since"] = params[:since] if params.key?(:since) params.except(*query_param_names) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:pre_encounter), method: "GET", path: "/appointments/v1/updates/scan", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i return if code.between?(200, 299) error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end |
#update(request_options: {}, **params) ⇒ Candid::PreEncounter::Appointments::V1::Types::Appointment
Updates an appointment. The path must contain the next version number to prevent race conditions. For example, if the current version of the appointment is n, you will need to send a request to this endpoint with ‘/id/n+1` to update the appointment. Updating historic versions is not supported.
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
# File 'lib/candid/pre_encounter/appointments/v_1/client.rb', line 241 def update(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:pre_encounter), method: "PUT", path: "/appointments/v1/#{params[:id]}/#{params[:version]}", body: Candid::PreEncounter::Appointments::V1::Types::MutableAppointment.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Candid::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Candid::PreEncounter::Appointments::V1::Types::Appointment.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |