Class: CandidApiClient::Encounters::V4::Types::Lab

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/encounters/v_4/types/lab.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, code: OMIT, code_type: OMIT, additional_properties: nil) ⇒ CandidApiClient::Encounters::V4::Types::Lab

Parameters:



31
32
33
34
35
36
37
38
39
# File 'lib/candidhealth/encounters/v_4/types/lab.rb', line 31

def initialize(name:, code: OMIT, code_type: OMIT, additional_properties: nil)
  @name = name
  @code = code if code != OMIT
  @code_type = code_type if code_type != OMIT
  @additional_properties = additional_properties
  @_field_set = { "name": name, "code": code, "code_type": code_type }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    Additional properties unmapped to the current class definition



19
20
21
# File 'lib/candidhealth/encounters/v_4/types/lab.rb', line 19

def additional_properties
  @additional_properties
end

#codeString (readonly)

Returns:

  • (String)


15
16
17
# File 'lib/candidhealth/encounters/v_4/types/lab.rb', line 15

def code
  @code
end

#code_typeCandidApiClient::Encounters::V4::Types::LabCodeType (readonly)



17
18
19
# File 'lib/candidhealth/encounters/v_4/types/lab.rb', line 17

def code_type
  @code_type
end

#nameString (readonly)

Returns:

  • (String)


13
14
15
# File 'lib/candidhealth/encounters/v_4/types/lab.rb', line 13

def name
  @name
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::Encounters::V4::Types::Lab

Deserialize a JSON object to an instance of Lab

Parameters:

  • json_object (String)

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/candidhealth/encounters/v_4/types/lab.rb', line 45

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  name = struct["name"]
  code = struct["code"]
  code_type = struct["code_type"]
  new(
    name: name,
    code: code,
    code_type: code_type,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.

Parameters:

  • obj (Object)

Returns:

  • (Void)


71
72
73
74
75
# File 'lib/candidhealth/encounters/v_4/types/lab.rb', line 71

def self.validate_raw(obj:)
  obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.code&.is_a?(String) != false || raise("Passed value for field obj.code is not the expected type, validation failed.")
  obj.code_type&.is_a?(CandidApiClient::Encounters::V4::Types::LabCodeType) != false || raise("Passed value for field obj.code_type is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Lab to a JSON object

Returns:

  • (String)


61
62
63
# File 'lib/candidhealth/encounters/v_4/types/lab.rb', line 61

def to_json(*_args)
  @_field_set&.to_json
end