Class: Candid::Encounters::V4::Client
- Inherits:
-
Object
- Object
- Candid::Encounters::V4::Client
- Defined in:
- lib/candid/encounters/v_4/client.rb
Instance Method Summary collapse
- #create(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
-
#create_from_pre_encounter_patient(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
Create an encounter from a pre-encounter patient and appointment.
-
#create_from_pre_encounter_patient_universal(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
Create an encounter from a pre-encounter patient and appointment.
-
#create_universal(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
Notice: The UB-04 Data File, 2025, is copyrighted by American Hospital Association (AHA), Chicago, Illinois.
- #get(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
- #get_all(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::EncounterPage
- #initialize(client:, base_url: nil, environment: nil) ⇒ void constructor
- #update(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
-
#update_universal(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
Notice: The UB-04 Data File, 2025, is copyrighted by American Hospital Association (AHA), Chicago, Illinois.
Constructor Details
#initialize(client:, base_url: nil, environment: nil) ⇒ void
12 13 14 15 16 |
# File 'lib/candid/encounters/v_4/client.rb', line 12 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::Encounters::V4::Types::Encounter
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'lib/candid/encounters/v_4/client.rb', line 166 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(:candid_api), method: "POST", path: "/api/encounters/v4", body: Candid::Encounters::V4::Types::EncounterCreate.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::Encounters::V4::Types::Encounter.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create_from_pre_encounter_patient(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
Create an encounter from a pre-encounter patient and appointment. This endpoint is intended to be used by consumers who are managing patients and appointments in the pre-encounter service and is currently under development. Consumers who are not taking advantage of the pre-encounter service should use the standard create endpoint.
The endpoint will create an encounter from the provided fields, pulling information from the provided patient and appointment objects where applicable. In particular, the following fields are populated from the patient and appointment objects:
- Patient
- Referring Provider
- Subscriber Primary
- Subscriber Secondary
- Referral Number
- Responsible Party
- Guarantor
Utilizing this endpoint opts you into automatic updating of the encounter when the patient or appointment is updated, assuming the encounter has not already been submitted or adjudicated.
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/candid/encounters/v_4/client.rb', line 277 def create_from_pre_encounter_patient(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(:candid_api), method: "POST", path: "/api/encounters/v4/create-from-pre-encounter", body: Candid::Encounters::V4::Types::EncounterCreateFromPreEncounter.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::Encounters::V4::Types::Encounter.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create_from_pre_encounter_patient_universal(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
Create an encounter from a pre-encounter patient and appointment. This endpoint is intended to be used by consumers who are managing patients and appointments in the pre-encounter service and is currently under development. Consumers who are not taking advantage of the pre-encounter service should use the standard create endpoint.
The endpoint will create an encounter from the provided fields, pulling information from the provided patient and appointment objects where applicable. In particular, the following fields are populated from the patient and appointment objects:
- Patient
- Referring Provider
- Subscriber Primary
- Subscriber Secondary
- Referral Number
- Responsible Party
- Guarantor
Utilizing this endpoint opts you into automatic updating of the encounter when the patient or appointment is updated, assuming the encounter has not already been submitted or adjudicated.
Notice: The UB-04 Data File, 2025, is copyrighted by American Hospital Association (AHA), Chicago, Illinois. No portion of the THE UB-04 Data File, may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior express, written consent of AHA.
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/candid/encounters/v_4/client.rb', line 224 def create_from_pre_encounter_patient_universal(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(:candid_api), method: "POST", path: "/api/encounters/v4/create-from-pre-encounter/universal", body: Candid::EncountersUniversal::Types::UniversalEncounterCreateFromPreEncounter.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::Encounters::V4::Types::Encounter.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create_universal(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
Notice: The UB-04 Data File, 2025, is copyrighted by American Hospital Association (AHA), Chicago, Illinois. No portion of the THE UB-04 Data File, may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior express, written consent of AHA.
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/candid/encounters/v_4/client.rb', line 134 def create_universal(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(:candid_api), method: "POST", path: "/api/encounters/v4/universal", body: Candid::EncountersUniversal::Types::UniversalEncounterCreate.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::Encounters::V4::Types::Encounter.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/candid/encounters/v_4/client.rb', line 98 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(:candid_api), method: "GET", path: "/api/encounters/v4/#{params[:encounter_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::Encounters::V4::Types::Encounter.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_all(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::EncounterPage
44 45 46 47 48 49 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 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/candid/encounters/v_4/client.rb', line 44 def get_all(request_options: {}, **params) params = Candid::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[limit claim_status sort page_token date_of_service_min date_of_service_max primary_payer_names search_term external_id diagnoses_updated_since tag_ids work_queue_id billable_status responsible_party owner_of_next_action patient_external_id include_merged_patient_data] query_params = {} query_params["limit"] = params[:limit] if params.key?(:limit) query_params["claim_status"] = params[:claim_status] if params.key?(:claim_status) query_params["sort"] = params[:sort] if params.key?(:sort) query_params["page_token"] = params[:page_token] if params.key?(:page_token) query_params["date_of_service_min"] = params[:date_of_service_min] if params.key?(:date_of_service_min) query_params["date_of_service_max"] = params[:date_of_service_max] if params.key?(:date_of_service_max) query_params["primary_payer_names"] = params[:primary_payer_names] if params.key?(:primary_payer_names) query_params["search_term"] = params[:search_term] if params.key?(:search_term) query_params["external_id"] = params[:external_id] if params.key?(:external_id) query_params["diagnoses_updated_since"] = params[:diagnoses_updated_since] if params.key?(:diagnoses_updated_since) query_params["tag_ids"] = params[:tag_ids] if params.key?(:tag_ids) query_params["work_queue_id"] = params[:work_queue_id] if params.key?(:work_queue_id) query_params["billable_status"] = params[:billable_status] if params.key?(:billable_status) query_params["responsible_party"] = params[:responsible_party] if params.key?(:responsible_party) query_params["owner_of_next_action"] = params[:owner_of_next_action] if params.key?(:owner_of_next_action) query_params["patient_external_id"] = params[:patient_external_id] if params.key?(:patient_external_id) query_params["include_merged_patient_data"] = params[:include_merged_patient_data] if params.key?(:include_merged_patient_data) params.except(*query_param_names) request = Candid::Internal::JSON::Request.new( base_url: [:base_url] || @base_url || @environment&.dig(:candid_api), method: "GET", path: "/api/encounters/v4", 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::Encounters::V4::Types::EncounterPage.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/candid/encounters/v_4/client.rb', line 348 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(:candid_api), method: "PATCH", path: "/api/encounters/v4/#{params[:encounter_id]}", body: Candid::Encounters::V4::Types::EncounterUpdate.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::Encounters::V4::Types::Encounter.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#update_universal(request_options: {}, **params) ⇒ Candid::Encounters::V4::Types::Encounter
Notice: The UB-04 Data File, 2025, is copyrighted by American Hospital Association (AHA), Chicago, Illinois. No portion of the THE UB-04 Data File, may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, electronic, mechanical, photocopying, recording, or otherwise, without prior express, written consent of AHA.
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 |
# File 'lib/candid/encounters/v_4/client.rb', line 315 def update_universal(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(:candid_api), method: "PATCH", path: "/api/encounters/v4/#{params[:encounter_id]}/universal", body: Candid::EncountersUniversal::Types::UniversalEncounterUpdate.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::Encounters::V4::Types::Encounter.load(response.body) else error_class = Candid::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |