Class: CandidApiClient::CustomSchemas::V1::V1Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ CandidApiClient::CustomSchemas::V1::V1Client

Parameters:



18
19
20
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 18

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientCandidApiClient::RequestClient (readonly)



14
15
16
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 14

def request_client
  @request_client
end

Instance Method Details

#create(name:, fields:, description: nil, request_options: nil) ⇒ CandidApiClient::CustomSchemas::V1::Types::Schema

Create custom schema with a set of typed keys. Schema keys can be referenced as

inputs in user-configurable rules in the Rules
Engine, and key-value pairs can be attached to claims via the Encounters API.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.custom_schemas.v_1.create(
  name: "General Medicine",
  description: "Values associated with a generic visit",
  fields: [{ key: "provider_category", type: STRING }, { key: "is_urgent_care", type: BOOLEAN }, { key: "bmi", type: DOUBLE }, { key: "age", type: INTEGER }]
)

Parameters:

  • name (String)
  • description (String) (defaults to: nil)
  • fields (Array<Hash>)

    Request of type Array<CandidApiClient::CustomSchemas::V1::Types::SchemaField>, as a Hash

    • :key (String)

    • :type (CandidApiClient::Commons::Types::Primitive)

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

Returns:



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 85

def create(name:, fields:, description: 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.body = {
      **(request_options&.additional_body_parameters || {}),
      name: name,
      description: description,
      fields: fields
    }.compact
    req.url "#{@request_client.get_url(environment: CandidApi,
                                       request_options: request_options)}/api/custom-schemas/v1"
  end
  CandidApiClient::CustomSchemas::V1::Types::Schema.from_json(json_object: response.body)
end

#get(schema_id:, request_options: nil) ⇒ CandidApiClient::CustomSchemas::V1::Types::Schema

Return a custom schema with a given ID.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.custom_schemas.v_1.get(schema_id: "ec096b13-f80a-471d-aaeb-54b021c9d582")

Parameters:

Returns:



52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 52

def get(schema_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: CandidApi,
                                       request_options: request_options)}/api/custom-schemas/v1/#{schema_id}"
  end
  CandidApiClient::CustomSchemas::V1::Types::Schema.from_json(json_object: response.body)
end

#get_multi(request_options: nil) ⇒ CandidApiClient::CustomSchemas::V1::Types::SchemaGetMultiResponse

Returns all custom schemas.

Examples:

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

Parameters:

Returns:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 29

def get_multi(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: CandidApi,
                                       request_options: request_options)}/api/custom-schemas/v1"
  end
  CandidApiClient::CustomSchemas::V1::Types::SchemaGetMultiResponse.from_json(json_object: response.body)
end

#update(schema_id:, name: nil, description: nil, fields_to_add: nil, request_options: nil) ⇒ CandidApiClient::CustomSchemas::V1::Types::Schema

Update the name, description, or keys on a preexisting schema.

Examples:

api = CandidApiClient::Client.new(base_url: "https://api.example.com", environment: CandidApiClient::Environment::PRODUCTION)
api.custom_schemas.v_1.update(
  schema_id: "ec096b13-f80a-471d-aaeb-54b021c9d582",
  name: "General Medicine and Health",
  description: "Values collected during all visits",
  fields_to_add: [{ key: "visit_type", type: STRING }]
)

Parameters:

  • schema_id (String)
  • name (String) (defaults to: nil)
  • description (String) (defaults to: nil)
  • fields_to_add (Array<Hash>) (defaults to: nil)

    A list of typed entries to add to schema. Only additive modifications are permitted.Request of type Array<CandidApiClient::CustomSchemas::V1::Types::SchemaField>, as a Hash

    * :key (String)
    * :type (CandidApiClient::Commons::Types::Primitive)
    
  • 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
144
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 125

def update(schema_id:, name: nil, description: nil, fields_to_add: nil, request_options: nil)
  response = @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.body = {
      **(request_options&.additional_body_parameters || {}),
      name: name,
      description: description,
      fields_to_add: fields_to_add
    }.compact
    req.url "#{@request_client.get_url(environment: CandidApi,
                                       request_options: request_options)}/api/custom-schemas/v1/#{schema_id}"
  end
  CandidApiClient::CustomSchemas::V1::Types::Schema.from_json(json_object: response.body)
end