Class: CandidApiClient::Individual::Types::PatientBase

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/individual/types/patient_base.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(external_id:, date_of_birth:, address:, first_name:, last_name:, gender:, additional_properties: nil) ⇒ CandidApiClient::Individual::Types::PatientBase

Parameters:

  • external_id (String)

    The ID used to identify this individual in your system. For example, your internal patient ID or an EHR patient ID.

  • date_of_birth (Date)

    Box 3 on the CMS-1500 claim form. The date format should be in ISO 8601 date; formatted YYYY-MM-DD (i.e. 2012-02-01)

  • address (CandidApiClient::Commons::Types::StreetAddressShortZip)

    Box 5 on the CMS-1500 claim form.

  • first_name (String)
  • last_name (String)
  • gender (CandidApiClient::Individual::Types::Gender)
  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/candidhealth/individual/types/patient_base.rb', line 45

def initialize(external_id:, date_of_birth:, address:, first_name:, last_name:, gender:,
               additional_properties: nil)
  @external_id = external_id
  @date_of_birth = date_of_birth
  @address = address
  @first_name = first_name
  @last_name = last_name
  @gender = gender
  @additional_properties = additional_properties
  @_field_set = {
    "external_id": external_id,
    "date_of_birth": date_of_birth,
    "address": address,
    "first_name": first_name,
    "last_name": last_name,
    "gender": gender
  }
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



28
29
30
# File 'lib/candidhealth/individual/types/patient_base.rb', line 28

def additional_properties
  @additional_properties
end

#addressCandidApiClient::Commons::Types::StreetAddressShortZip (readonly)

Returns Box 5 on the CMS-1500 claim form.

Returns:



20
21
22
# File 'lib/candidhealth/individual/types/patient_base.rb', line 20

def address
  @address
end

#date_of_birthDate (readonly)

Returns Box 3 on the CMS-1500 claim form. The date format should be in ISO 8601 date; formatted YYYY-MM-DD (i.e. 2012-02-01).

Returns:

  • (Date)

    Box 3 on the CMS-1500 claim form. The date format should be in ISO 8601 date; formatted YYYY-MM-DD (i.e. 2012-02-01)



18
19
20
# File 'lib/candidhealth/individual/types/patient_base.rb', line 18

def date_of_birth
  @date_of_birth
end

#external_idString (readonly)

Returns The ID used to identify this individual in your system. For example, your internal patient ID or an EHR patient ID.

Returns:

  • (String)

    The ID used to identify this individual in your system. For example, your internal patient ID or an EHR patient ID.



15
16
17
# File 'lib/candidhealth/individual/types/patient_base.rb', line 15

def external_id
  @external_id
end

#first_nameString (readonly)

Returns:

  • (String)


22
23
24
# File 'lib/candidhealth/individual/types/patient_base.rb', line 22

def first_name
  @first_name
end

#genderCandidApiClient::Individual::Types::Gender (readonly)



26
27
28
# File 'lib/candidhealth/individual/types/patient_base.rb', line 26

def gender
  @gender
end

#last_nameString (readonly)

Returns:

  • (String)


24
25
26
# File 'lib/candidhealth/individual/types/patient_base.rb', line 24

def last_name
  @last_name
end

Class Method Details

.from_json(json_object:) ⇒ CandidApiClient::Individual::Types::PatientBase

Deserialize a JSON object to an instance of PatientBase

Parameters:

  • json_object (String)

Returns:



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/candidhealth/individual/types/patient_base.rb', line 68

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  external_id = struct["external_id"]
  date_of_birth = (Date.parse(parsed_json["date_of_birth"]) unless parsed_json["date_of_birth"].nil?)
  if parsed_json["address"].nil?
    address = nil
  else
    address = parsed_json["address"].to_json
    address = CandidApiClient::Commons::Types::StreetAddressShortZip.from_json(json_object: address)
  end
  first_name = struct["first_name"]
  last_name = struct["last_name"]
  gender = struct["gender"]
  new(
    external_id: external_id,
    date_of_birth: date_of_birth,
    address: address,
    first_name: first_name,
    last_name: last_name,
    gender: gender,
    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)


106
107
108
109
110
111
112
113
# File 'lib/candidhealth/individual/types/patient_base.rb', line 106

def self.validate_raw(obj:)
  obj.external_id.is_a?(String) != false || raise("Passed value for field obj.external_id is not the expected type, validation failed.")
  obj.date_of_birth.is_a?(Date) != false || raise("Passed value for field obj.date_of_birth is not the expected type, validation failed.")
  CandidApiClient::Commons::Types::StreetAddressShortZip.validate_raw(obj: obj.address)
  obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.")
  obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.")
  obj.gender.is_a?(CandidApiClient::Individual::Types::Gender) != false || raise("Passed value for field obj.gender is not the expected type, validation failed.")
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of PatientBase to a JSON object

Returns:

  • (String)


96
97
98
# File 'lib/candidhealth/individual/types/patient_base.rb', line 96

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