Class: CandidApiClient::Financials::Types::AllocationTargetCreate

Inherits:
Object
  • Object
show all
Defined in:
lib/candidhealth/financials/types/allocation_target_create.rb

Overview

Allocation targets describe whether the portion of a payment is being applied

toward a specific service line,
claim, billing provider, or is unallocated.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(member:, discriminant:) ⇒ CandidApiClient::Financials::Types::AllocationTargetCreate

Parameters:

  • member (Object)
  • discriminant (String)


24
25
26
27
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 24

def initialize(member:, discriminant:)
  @member = member
  @discriminant = discriminant
end

Instance Attribute Details

#discriminantString (readonly)

Returns:

  • (String)


16
17
18
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 16

def discriminant
  @discriminant
end

#memberObject (readonly)

Returns:

  • (Object)


14
15
16
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 14

def member
  @member
end

Class Method Details

.appointment_by_id_and_patient_external_id(member:) ⇒ CandidApiClient::Financials::Types::AllocationTargetCreate



136
137
138
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 136

def self.appointment_by_id_and_patient_external_id(member:)
  new(member: member, discriminant: "appointment_by_id_and_patient_external_id")
end

.billing_provider_by_id(member:) ⇒ CandidApiClient::Financials::Types::AllocationTargetCreate

Parameters:

  • member (String)

Returns:



130
131
132
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 130

def self.billing_provider_by_id(member:)
  new(member: member, discriminant: "billing_provider_by_id")
end

.claim_by_encounter_external_id(member:) ⇒ CandidApiClient::Financials::Types::AllocationTargetCreate

Parameters:

  • member (String)

Returns:



124
125
126
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 124

def self.claim_by_encounter_external_id(member:)
  new(member: member, discriminant: "claim_by_encounter_external_id")
end

.claim_by_id(member:) ⇒ CandidApiClient::Financials::Types::AllocationTargetCreate

Parameters:

  • member (String)

Returns:



118
119
120
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 118

def self.claim_by_id(member:)
  new(member: member, discriminant: "claim_by_id")
end

.from_json(json_object:) ⇒ CandidApiClient::Financials::Types::AllocationTargetCreate

Deserialize a JSON object to an instance of AllocationTargetCreate

Parameters:

  • json_object (String)

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 33

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  member = case struct.type
           when "service_line_by_id"
             json_object.value
           when "claim_by_id"
             json_object.value
           when "claim_by_encounter_external_id"
             json_object.value
           when "billing_provider_by_id"
             json_object.value
           when "appointment_by_id_and_patient_external_id"
             CandidApiClient::Financials::Types::AppointmentByIdAndPatientExternalId.from_json(json_object: json_object)
           when "unattributed"
             nil
           else
             json_object
           end
  new(member: member, discriminant: struct.type)
end

.service_line_by_id(member:) ⇒ CandidApiClient::Financials::Types::AllocationTargetCreate

Parameters:

  • member (String)

Returns:



112
113
114
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 112

def self.service_line_by_id(member:)
  new(member: member, discriminant: "service_line_by_id")
end

.unattributedCandidApiClient::Financials::Types::AllocationTargetCreate



141
142
143
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 141

def self.unattributed
  new(member: nil, discriminant: "unattributed")
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)


83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 83

def self.validate_raw(obj:)
  case obj.type
  when "service_line_by_id"
    obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.")
  when "claim_by_id"
    obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.")
  when "claim_by_encounter_external_id"
    obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.")
  when "billing_provider_by_id"
    obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.")
  when "appointment_by_id_and_patient_external_id"
    CandidApiClient::Financials::Types::AppointmentByIdAndPatientExternalId.validate_raw(obj: obj)
  when "unattributed"
    # noop
  else
    raise("Passed value matched no type within the union, validation failed.")
  end
end

Instance Method Details

#is_a?(obj) ⇒ Boolean

For Union Types, is_a? functionality is delegated to the wrapped member.

Parameters:

  • obj (Object)

Returns:

  • (Boolean)


106
107
108
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 106

def is_a?(obj)
  @member.is_a?(obj)
end

#kind_of?Object



19
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 19

alias kind_of? is_a?

#to_json(*_args) ⇒ String

For Union Types, to_json functionality is delegated to the wrapped member.

Returns:

  • (String)


57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/candidhealth/financials/types/allocation_target_create.rb', line 57

def to_json(*_args)
  case @discriminant
  when "service_line_by_id"
    { "type": @discriminant, "value": @member }.to_json
  when "claim_by_id"
    { "type": @discriminant, "value": @member }.to_json
  when "claim_by_encounter_external_id"
    { "type": @discriminant, "value": @member }.to_json
  when "billing_provider_by_id"
    { "type": @discriminant, "value": @member }.to_json
  when "appointment_by_id_and_patient_external_id"
    { **@member.to_json, type: @discriminant }.to_json
  when "unattributed"
    { type: @discriminant }.to_json
  else
    { "type": @discriminant, value: @member }.to_json
  end
  @member.to_json
end