Class: CandidApiClient::Encounters::V4::Types::Medication

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

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, rx_cui: OMIT, dosage: OMIT, dosage_form: OMIT, frequency: OMIT, as_needed: OMIT, additional_properties: nil) ⇒ CandidApiClient::Encounters::V4::Types::Medication

Parameters:

  • name (String)
  • rx_cui (String) (defaults to: OMIT)
  • dosage (String) (defaults to: OMIT)
  • dosage_form (String) (defaults to: OMIT)
  • frequency (String) (defaults to: OMIT)
  • as_needed (Boolean) (defaults to: OMIT)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 39

def initialize(name:, rx_cui: OMIT, dosage: OMIT, dosage_form: OMIT, frequency: OMIT, as_needed: OMIT,
               additional_properties: nil)
  @name = name
  @rx_cui = rx_cui if rx_cui != OMIT
  @dosage = dosage if dosage != OMIT
  @dosage_form = dosage_form if dosage_form != OMIT
  @frequency = frequency if frequency != OMIT
  @as_needed = as_needed if as_needed != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "name": name,
    "rx_cui": rx_cui,
    "dosage": dosage,
    "dosage_form": dosage_form,
    "frequency": frequency,
    "as_needed": as_needed
  }.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



24
25
26
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 24

def additional_properties
  @additional_properties
end

#as_neededBoolean (readonly)

Returns:

  • (Boolean)


22
23
24
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 22

def as_needed
  @as_needed
end

#dosageString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 16

def dosage
  @dosage
end

#dosage_formString (readonly)

Returns:

  • (String)


18
19
20
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 18

def dosage_form
  @dosage_form
end

#frequencyString (readonly)

Returns:

  • (String)


20
21
22
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 20

def frequency
  @frequency
end

#nameString (readonly)

Returns:

  • (String)


12
13
14
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 12

def name
  @name
end

#rx_cuiString (readonly)

Returns:

  • (String)


14
15
16
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 14

def rx_cui
  @rx_cui
end

Class Method Details

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

Deserialize a JSON object to an instance of Medication

Parameters:

  • json_object (String)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 64

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  name = struct["name"]
  rx_cui = struct["rx_cui"]
  dosage = struct["dosage"]
  dosage_form = struct["dosage_form"]
  frequency = struct["frequency"]
  as_needed = struct["as_needed"]
  new(
    name: name,
    rx_cui: rx_cui,
    dosage: dosage,
    dosage_form: dosage_form,
    frequency: frequency,
    as_needed: as_needed,
    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)


96
97
98
99
100
101
102
103
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 96

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.rx_cui&.is_a?(String) != false || raise("Passed value for field obj.rx_cui is not the expected type, validation failed.")
  obj.dosage&.is_a?(String) != false || raise("Passed value for field obj.dosage is not the expected type, validation failed.")
  obj.dosage_form&.is_a?(String) != false || raise("Passed value for field obj.dosage_form is not the expected type, validation failed.")
  obj.frequency&.is_a?(String) != false || raise("Passed value for field obj.frequency is not the expected type, validation failed.")
  obj.as_needed&.is_a?(Boolean) != false || raise("Passed value for field obj.as_needed is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of Medication to a JSON object

Returns:

  • (String)


86
87
88
# File 'lib/candidhealth/encounters/v_4/types/medication.rb', line 86

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