Class: CandidApiClient::PreEncounter::Patients::V1::V1Client
- Inherits:
-
Object
- Object
- CandidApiClient::PreEncounter::Patients::V1::V1Client
- Defined in:
- lib/candidhealth/pre_encounter/patients/v_1/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(request:, skip_duplicate_check: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Adds a patient.
-
#create_with_mrn(request:, skip_duplicate_check: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Adds a patient and hydrates their MRN with a pre-existing MRN.
-
#deactivate(id:, version:, request_options: nil) ⇒ Void
Sets a patient as deactivated.
-
#get(id:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Gets a patient.
-
#get_history(id:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Gets a patient along with it’s full history.
-
#get_multi(limit: nil, mrn: nil, page_token: nil, sort_field: nil, sort_direction: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::PatientPage
Searches for patients that match the query parameters.
- #initialize(request_client:) ⇒ CandidApiClient::PreEncounter::Patients::V1::V1Client constructor
-
#reactivate(id:, version:, request_options: nil) ⇒ Void
Removes the deactivated flag for a patient.
-
#scan(since:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Scans up to 100 patient updates.
-
#search(mrn: nil, similar_name_ordering: nil, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Returns a list of Patients based on the search criteria.
-
#search_providers(search_criteria:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Common::Types::ExternalProvider>
Searches for referring providers that match the query parameters.
-
#update(id:, version:, request:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Updates a patient.
Constructor Details
#initialize(request_client:) ⇒ CandidApiClient::PreEncounter::Patients::V1::V1Client
24 25 26 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 24 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ CandidApiClient::RequestClient (readonly)
20 21 22 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 20 def request_client @request_client end |
Instance Method Details
#create(request:, skip_duplicate_check: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Adds a patient. VersionConflictError is returned when the patient’s external ID
is already in use.
125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 125 def create(request:, skip_duplicate_check: nil, request_options: nil) response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "skip_duplicate_check": skip_duplicate_check }.compact req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1" end CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body) end |
#create_with_mrn(request:, skip_duplicate_check: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Adds a patient and hydrates their MRN with a pre-existing MRN. Once this
patient is created their MRN will not be editable. BadRequestError is returned
when the MRN is greater than 20 characters. VersionConflictError is returned
when the patient's external ID is already in use.
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 245 def create_with_mrn(request:, skip_duplicate_check: nil, request_options: nil) response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "skip_duplicate_check": skip_duplicate_check }.compact req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/with_mrn" end CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body) end |
#deactivate(id:, version:, request_options: nil) ⇒ Void
Sets a patient as deactivated. The path must contain the most recent version
plus 1 to prevent race conditions. Deactivating historic versions is not
supported.
515 516 517 518 519 520 521 522 523 524 525 526 527 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 515 def deactivate(id:, version:, request_options: nil) @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/#{id}/#{version}" end end |
#get(id:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Gets a patient.
343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 343 def get(id:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/#{id}" end CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body) end |
#get_history(id:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Gets a patient along with it’s full history. The return list is ordered by
version ascending.
367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 367 def get_history(id:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/#{id}/history" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item) end end |
#get_multi(limit: nil, mrn: nil, page_token: nil, sort_field: nil, sort_direction: nil, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::PatientPage
Searches for patients that match the query parameters.
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 277 def get_multi(limit: nil, mrn: nil, page_token: nil, sort_field: nil, sort_direction: nil, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "limit": limit, "mrn": mrn, "page_token": page_token, "sort_field": sort_field, "sort_direction": sort_direction }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/get_multi" end CandidApiClient::PreEncounter::Patients::V1::Types::PatientPage.from_json(json_object: response.body) end |
#reactivate(id:, version:, request_options: nil) ⇒ Void
Removes the deactivated flag for a patient. The path must contain the most
recent version plus 1 to prevent race conditions. Reactivating historic
versions is not supported.
540 541 542 543 544 545 546 547 548 549 550 551 552 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 540 def reactivate(id:, version:, request_options: nil) @request_client.conn.patch do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/#{id}/#{version}" end end |
#scan(since:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Scans up to 100 patient updates. The since query parameter is inclusive, and
the result list is ordered by updatedAt ascending.
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 596 def scan(since:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "since": since }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/updates/scan" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item) end end |
#search(mrn: nil, similar_name_ordering: nil, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Patients::V1::Types::Patient>
Returns a list of Patients based on the search criteria.
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 563 def search(mrn: nil, similar_name_ordering: nil, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "mrn": mrn, "similar_name_ordering": similar_name_ordering }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: item) end end |
#search_providers(search_criteria:, request_options: nil) ⇒ Array<CandidApiClient::PreEncounter::Common::Types::ExternalProvider>
Searches for referring providers that match the query parameters. The search is
case-insensitive, supports fuzzy matching, and matches against provider name and
NPI. The search criteria must be an alphanumeric string, and the search is
limited to the first 20 results.
312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 312 def search_providers(search_criteria:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "search_criteria": search_criteria }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/search_providers" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json CandidApiClient::PreEncounter::Common::Types::ExternalProvider.from_json(json_object: item) end end |
#update(id:, version:, request:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient
Updates a patient. The path must contain the most recent version to prevent
race conditions. Updating historic versions is not supported.
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 488 def update(id:, version:, request:, request_options: nil) response = @request_client.conn.put do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.body = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(environment: PreEncounter, request_options: )}/patients/v1/#{id}/#{version}" end CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body) end |