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
-
#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.
-
#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
23 24 25 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 23 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ CandidApiClient::RequestClient (readonly)
19 20 21 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 19 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.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 118 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. InvalidMRNError is returned when the
MRN is greater than 20 characters. VersionConflictError is returned when the
patient's external ID is already in use.
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 232 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 to
prevent race conditions. Deactivating historic versions is not supported.
Subsequent updates via PUT to the patient will "reactivate" the patient and set
the deactivated flag to false.
469 470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 469 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.
302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 302 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.
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 326 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.
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 270 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 |
#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.
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 525 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.
492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 492 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 |
#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.
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
# File 'lib/candidhealth/pre_encounter/patients/v_1/client.rb', line 441 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 |