Class: CandidApiClient::PreEncounter::Patients::V1::V1Client

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/pre_encounter/patients/v_1/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ CandidApiClient::PreEncounter::Patients::V1::V1Client

Parameters:



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_clientCandidApiClient::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.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.create(request: { name: { family: "family", given: ["given", "given"], use: USUAL }, other_names: [{ family: "family", given: ["given", "given"], use: USUAL }, { family: "family", given: ["given", "given"], use: USUAL }], birth_date: DateTime.parse(2023-01-15), biological_sex: FEMALE, primary_address: { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, other_addresses: [{ use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }], primary_telecom: { value: "value", use: HOME }, other_telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }], contacts: [{ relationship: [SELF, SELF], name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }], addresses: [{ use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }] }, { relationship: [SELF, SELF], name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }], addresses: [{ use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }] }], general_practitioners: [{ name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }] }, { name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }] }], filing_order: { coverages: ["d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"] } })

Parameters:

  • skip_duplicate_check (Boolean) (defaults to: nil)
  • request (Hash)

    Request of type CandidApiClient::PreEncounter::Patients::V1::Types::MutablePatient, as a Hash

    • :name (Hash)

      • :family (String)

      • :given (Array<String>)

      • :use (CandidApiClient::PreEncounter::Common::Types::NameUse)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

      • :suffix (String)

    • :other_names (Array<CandidApiClient::PreEncounter::Common::Types::HumanName>)

    • :other_identifiers (Array<CandidApiClient::PreEncounter::Common::Types::ExternalIdentifier>)

    • :gender (CandidApiClient::PreEncounter::Common::Types::Gender)

    • :birth_date (Date)

    • :social_security_number (String)

    • :biological_sex (CandidApiClient::PreEncounter::Common::Types::Sex)

    • :sexual_orientation (CandidApiClient::PreEncounter::Common::Types::SexualOrientation)

    • :pronouns (Array<String>)

    • :race (CandidApiClient::PreEncounter::Common::Types::Race)

    • :ethnicity (CandidApiClient::PreEncounter::Common::Types::Ethnicity)

    • :disability_status (CandidApiClient::PreEncounter::Common::Types::DisabilityStatus)

    • :marital_status (CandidApiClient::PreEncounter::Patients::V1::Types::MaritalStatus)

    • :deceased (DateTime)

    • :multiple_birth (Integer)

    • :primary_address (Hash)

      • :use (CandidApiClient::PreEncounter::Common::Types::AddressUse)

      • :line (Array<String>)

      • :city (String)

      • :state (String)

      • :postal_code (String)

      • :country (String)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

    • :other_addresses (Array<CandidApiClient::PreEncounter::Common::Types::Address>)

    • :primary_telecom (Hash)

      • :value (String)

      • :use (CandidApiClient::PreEncounter::Common::Types::ContactPointUse)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

    • :other_telecoms (Array<CandidApiClient::PreEncounter::Common::Types::ContactPoint>)

    • :email (String)

    • :electronic_communication_opt_in (Boolean)

    • :photo (String)

    • :language (String)

    • :external_provenance (Hash)

      • :external_id (String)

      • :system_name (String)

    • :contacts (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Contact>)

    • :general_practitioners (Array<CandidApiClient::PreEncounter::Common::Types::ExternalProvider>)

    • :filing_order (Hash)

      • :coverages (Array<String>)

    • :non_insurance_payers (Array<String>)

    • :non_insurance_payer_associations (Array<CandidApiClient::PreEncounter::Common::Types::CanonicalNonInsurancePayerAssociation>)

    • :guarantor (Hash)

      • :name (Hash)

        • :family (String)

        • :given (Array<String>)

        • :use (CandidApiClient::PreEncounter::Common::Types::NameUse)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

        • :suffix (String)

      • :telecom (Hash)

        • :value (String)

        • :use (CandidApiClient::PreEncounter::Common::Types::ContactPointUse)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

      • :email (String)

      • :birth_date (Date)

      • :address (Hash)

        • :use (CandidApiClient::PreEncounter::Common::Types::AddressUse)

        • :line (Array<String>)

        • :city (String)

        • :state (String)

        • :postal_code (String)

        • :country (String)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

    • :self_pay (Boolean)

    • :authorizations (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Authorization>)

    • :referrals (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Referral>)

    • :primary_service_facility_id (String)

    • :do_not_invoice_reason (CandidApiClient::PreEncounter::Patients::V1::Types::DoNotInvoiceReason)

    • :note_ids (Array<String>)

    • :tag_ids (Array<String>)

  • request_options (CandidApiClient::RequestOptions) (defaults to: nil)

Returns:



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.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 || {}),
      "skip_duplicate_check": skip_duplicate_check
    }.compact
    req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
    req.url "#{@request_client.get_url(environment: PreEncounter,
                                       request_options: 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.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.create_with_mrn(request: { name: { family: "family", given: ["given", "given"], use: USUAL }, other_names: [{ family: "family", given: ["given", "given"], use: USUAL }, { family: "family", given: ["given", "given"], use: USUAL }], birth_date: DateTime.parse(2023-01-15), biological_sex: FEMALE, primary_address: { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, other_addresses: [{ use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }], primary_telecom: { value: "value", use: HOME }, other_telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }], contacts: [{ relationship: [SELF, SELF], name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }], addresses: [{ use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }] }, { relationship: [SELF, SELF], name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }], addresses: [{ use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }] }], general_practitioners: [{ name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }] }, { name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }] }], filing_order: { coverages: ["d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"] }, mrn: "mrn" })

Parameters:

  • skip_duplicate_check (Boolean) (defaults to: nil)
  • request (Hash)

    Request of type CandidApiClient::PreEncounter::Patients::V1::Types::MutablePatientWithMrn, as a Hash

    • :mrn (String)

    • :name (Hash)

      • :family (String)

      • :given (Array<String>)

      • :use (CandidApiClient::PreEncounter::Common::Types::NameUse)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

      • :suffix (String)

    • :other_names (Array<CandidApiClient::PreEncounter::Common::Types::HumanName>)

    • :other_identifiers (Array<CandidApiClient::PreEncounter::Common::Types::ExternalIdentifier>)

    • :gender (CandidApiClient::PreEncounter::Common::Types::Gender)

    • :birth_date (Date)

    • :social_security_number (String)

    • :biological_sex (CandidApiClient::PreEncounter::Common::Types::Sex)

    • :sexual_orientation (CandidApiClient::PreEncounter::Common::Types::SexualOrientation)

    • :pronouns (Array<String>)

    • :race (CandidApiClient::PreEncounter::Common::Types::Race)

    • :ethnicity (CandidApiClient::PreEncounter::Common::Types::Ethnicity)

    • :disability_status (CandidApiClient::PreEncounter::Common::Types::DisabilityStatus)

    • :marital_status (CandidApiClient::PreEncounter::Patients::V1::Types::MaritalStatus)

    • :deceased (DateTime)

    • :multiple_birth (Integer)

    • :primary_address (Hash)

      • :use (CandidApiClient::PreEncounter::Common::Types::AddressUse)

      • :line (Array<String>)

      • :city (String)

      • :state (String)

      • :postal_code (String)

      • :country (String)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

    • :other_addresses (Array<CandidApiClient::PreEncounter::Common::Types::Address>)

    • :primary_telecom (Hash)

      • :value (String)

      • :use (CandidApiClient::PreEncounter::Common::Types::ContactPointUse)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

    • :other_telecoms (Array<CandidApiClient::PreEncounter::Common::Types::ContactPoint>)

    • :email (String)

    • :electronic_communication_opt_in (Boolean)

    • :photo (String)

    • :language (String)

    • :external_provenance (Hash)

      • :external_id (String)

      • :system_name (String)

    • :contacts (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Contact>)

    • :general_practitioners (Array<CandidApiClient::PreEncounter::Common::Types::ExternalProvider>)

    • :filing_order (Hash)

      • :coverages (Array<String>)

    • :non_insurance_payers (Array<String>)

    • :non_insurance_payer_associations (Array<CandidApiClient::PreEncounter::Common::Types::CanonicalNonInsurancePayerAssociation>)

    • :guarantor (Hash)

      • :name (Hash)

        • :family (String)

        • :given (Array<String>)

        • :use (CandidApiClient::PreEncounter::Common::Types::NameUse)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

        • :suffix (String)

      • :telecom (Hash)

        • :value (String)

        • :use (CandidApiClient::PreEncounter::Common::Types::ContactPointUse)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

      • :email (String)

      • :birth_date (Date)

      • :address (Hash)

        • :use (CandidApiClient::PreEncounter::Common::Types::AddressUse)

        • :line (Array<String>)

        • :city (String)

        • :state (String)

        • :postal_code (String)

        • :country (String)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

    • :self_pay (Boolean)

    • :authorizations (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Authorization>)

    • :referrals (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Referral>)

    • :primary_service_facility_id (String)

    • :do_not_invoice_reason (CandidApiClient::PreEncounter::Patients::V1::Types::DoNotInvoiceReason)

    • :note_ids (Array<String>)

    • :tag_ids (Array<String>)

  • request_options (CandidApiClient::RequestOptions) (defaults to: nil)

Returns:



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.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 || {}),
      "skip_duplicate_check": skip_duplicate_check
    }.compact
    req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
    req.url "#{@request_client.get_url(environment: PreEncounter,
                                       request_options: 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.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.deactivate(id: "id", version: "version")

Parameters:

Returns:

  • (Void)


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.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)}/patients/v1/#{id}/#{version}"
  end
end

#get(id:, request_options: nil) ⇒ CandidApiClient::PreEncounter::Patients::V1::Types::Patient

Gets a patient.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.get(id: "id")

Parameters:

Returns:



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.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)}/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.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.get_history(id: "id")

Parameters:

Returns:



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.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)}/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.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.get_multi

Parameters:

Returns:



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.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 || {}),
      "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: 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.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.reactivate(id: "id", version: "version")

Parameters:

Returns:

  • (Void)


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.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)}/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.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.scan(since: DateTime.parse(2024-01-15T09:30:00.000Z))

Parameters:

Returns:



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.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)}/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.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.search

Parameters:

  • mrn (String) (defaults to: nil)
  • similar_name_ordering (String) (defaults to: nil)

    A string that is used to order similar names in search results.

  • request_options (CandidApiClient::RequestOptions) (defaults to: nil)

Returns:



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.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 || {}),
      "mrn": mrn,
      "similar_name_ordering": similar_name_ordering
    }.compact
    req.url "#{@request_client.get_url(environment: PreEncounter,
                                       request_options: 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.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.search_providers(search_criteria: "search_criteria")

Parameters:

Returns:



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.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 || {}),
      "search_criteria": search_criteria
    }.compact
    req.url "#{@request_client.get_url(environment: PreEncounter,
                                       request_options: 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.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.pre_encounter.patients.v_1.update(
  id: "id",
  version: "version",
  request: { name: { family: "family", given: ["given", "given"], use: USUAL }, other_names: [{ family: "family", given: ["given", "given"], use: USUAL }, { family: "family", given: ["given", "given"], use: USUAL }], birth_date: DateTime.parse(2023-01-15), biological_sex: FEMALE, primary_address: { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, other_addresses: [{ use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }], primary_telecom: { value: "value", use: HOME }, other_telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }], contacts: [{ relationship: [SELF, SELF], name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }], addresses: [{ use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }] }, { relationship: [SELF, SELF], name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }], addresses: [{ use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }, { use: HOME, line: ["line", "line"], city: "city", state: "state", postal_code: "postal_code", country: "country" }] }], general_practitioners: [{ name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }] }, { name: { family: "family", given: ["given", "given"], use: USUAL }, telecoms: [{ value: "value", use: HOME }, { value: "value", use: HOME }] }], filing_order: { coverages: ["d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32"] } }
)

Parameters:

  • id (String)
  • version (String)
  • request (Hash)

    Request of type CandidApiClient::PreEncounter::Patients::V1::Types::MutablePatient, as a Hash

    • :name (Hash)

      • :family (String)

      • :given (Array<String>)

      • :use (CandidApiClient::PreEncounter::Common::Types::NameUse)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

      • :suffix (String)

    • :other_names (Array<CandidApiClient::PreEncounter::Common::Types::HumanName>)

    • :other_identifiers (Array<CandidApiClient::PreEncounter::Common::Types::ExternalIdentifier>)

    • :gender (CandidApiClient::PreEncounter::Common::Types::Gender)

    • :birth_date (Date)

    • :social_security_number (String)

    • :biological_sex (CandidApiClient::PreEncounter::Common::Types::Sex)

    • :sexual_orientation (CandidApiClient::PreEncounter::Common::Types::SexualOrientation)

    • :pronouns (Array<String>)

    • :race (CandidApiClient::PreEncounter::Common::Types::Race)

    • :ethnicity (CandidApiClient::PreEncounter::Common::Types::Ethnicity)

    • :disability_status (CandidApiClient::PreEncounter::Common::Types::DisabilityStatus)

    • :marital_status (CandidApiClient::PreEncounter::Patients::V1::Types::MaritalStatus)

    • :deceased (DateTime)

    • :multiple_birth (Integer)

    • :primary_address (Hash)

      • :use (CandidApiClient::PreEncounter::Common::Types::AddressUse)

      • :line (Array<String>)

      • :city (String)

      • :state (String)

      • :postal_code (String)

      • :country (String)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

    • :other_addresses (Array<CandidApiClient::PreEncounter::Common::Types::Address>)

    • :primary_telecom (Hash)

      • :value (String)

      • :use (CandidApiClient::PreEncounter::Common::Types::ContactPointUse)

      • :period (Hash)

        • :start (Date)

        • :end_ (Date)

    • :other_telecoms (Array<CandidApiClient::PreEncounter::Common::Types::ContactPoint>)

    • :email (String)

    • :electronic_communication_opt_in (Boolean)

    • :photo (String)

    • :language (String)

    • :external_provenance (Hash)

      • :external_id (String)

      • :system_name (String)

    • :contacts (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Contact>)

    • :general_practitioners (Array<CandidApiClient::PreEncounter::Common::Types::ExternalProvider>)

    • :filing_order (Hash)

      • :coverages (Array<String>)

    • :non_insurance_payers (Array<String>)

    • :non_insurance_payer_associations (Array<CandidApiClient::PreEncounter::Common::Types::CanonicalNonInsurancePayerAssociation>)

    • :guarantor (Hash)

      • :name (Hash)

        • :family (String)

        • :given (Array<String>)

        • :use (CandidApiClient::PreEncounter::Common::Types::NameUse)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

        • :suffix (String)

      • :telecom (Hash)

        • :value (String)

        • :use (CandidApiClient::PreEncounter::Common::Types::ContactPointUse)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

      • :email (String)

      • :birth_date (Date)

      • :address (Hash)

        • :use (CandidApiClient::PreEncounter::Common::Types::AddressUse)

        • :line (Array<String>)

        • :city (String)

        • :state (String)

        • :postal_code (String)

        • :country (String)

        • :period (Hash)

          • :start (Date)

          • :end_ (Date)

    • :self_pay (Boolean)

    • :authorizations (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Authorization>)

    • :referrals (Array<CandidApiClient::PreEncounter::Patients::V1::Types::Referral>)

    • :primary_service_facility_id (String)

    • :do_not_invoice_reason (CandidApiClient::PreEncounter::Patients::V1::Types::DoNotInvoiceReason)

    • :note_ids (Array<String>)

    • :tag_ids (Array<String>)

  • request_options (CandidApiClient::RequestOptions) (defaults to: nil)

Returns:



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.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)}/patients/v1/#{id}/#{version}"
  end
  CandidApiClient::PreEncounter::Patients::V1::Types::Patient.from_json(json_object: response.body)
end