Class: CandidApiClient::CustomSchemas::V1::AsyncV1Client

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::AsyncV1Client

Parameters:



153
154
155
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 153

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientCandidApiClient::AsyncRequestClient (readonly)



149
150
151
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 149

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:



224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 224

def create(name:, fields:, description: nil, request_options: nil)
  Async do
    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
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:



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 189

def get(schema_id:, request_options: nil)
  Async do
    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
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:



164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 164

def get_multi(request_options: nil)
  Async do
    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
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:



266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/candidhealth/custom_schemas/v_1/client.rb', line 266

def update(schema_id:, name: nil, description: nil, fields_to_add: nil, request_options: nil)
  Async do
    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
end