Class: UserRelationship

Inherits:
Object
  • Object
show all
Defined in:
app/models/user_relationship.rb

Constant Summary collapse

PERSON_TYPE_VETERAN =
'VET'

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#birth_dateObject

Returns the value of attribute birth_date.



4
5
6
# File 'app/models/user_relationship.rb', line 4

def birth_date
  @birth_date
end

#first_nameObject

Returns the value of attribute first_name.



4
5
6
# File 'app/models/user_relationship.rb', line 4

def first_name
  @first_name
end

#genderObject

Returns the value of attribute gender.



4
5
6
# File 'app/models/user_relationship.rb', line 4

def gender
  @gender
end

#icnObject

Returns the value of attribute icn.



4
5
6
# File 'app/models/user_relationship.rb', line 4

def icn
  @icn
end

#last_nameObject

Returns the value of attribute last_name.



4
5
6
# File 'app/models/user_relationship.rb', line 4

def last_name
  @last_name
end

#participant_idObject

Returns the value of attribute participant_id.



4
5
6
# File 'app/models/user_relationship.rb', line 4

def participant_id
  @participant_id
end

#ssnObject

Returns the value of attribute ssn.



4
5
6
# File 'app/models/user_relationship.rb', line 4

def ssn
  @ssn
end

#veteran_statusObject

Returns the value of attribute veteran_status.



4
5
6
# File 'app/models/user_relationship.rb', line 4

def veteran_status
  @veteran_status
end

Class Method Details

.from_bgs_dependent(bgs_dependent) ⇒ Object

Initializer with a single ‘person’ from a BGS get_dependents call



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/user_relationship.rb', line 10

def self.from_bgs_dependent(bgs_dependent)
  user_relationship = new
  # Profile attributes
  user_relationship.first_name = bgs_dependent[:first_name]
  user_relationship.last_name = bgs_dependent[:last_name]
  user_relationship.birth_date = Formatters::DateFormatter.format_date(bgs_dependent[:date_of_birth])
  user_relationship.ssn = bgs_dependent[:ssn]
  user_relationship.gender = bgs_dependent[:gender]
  user_relationship.veteran_status = bgs_dependent[:veteran_indicator] == 'Y'
  # ID attributes
  user_relationship.participant_id = bgs_dependent[:ptcpnt_id]
  user_relationship
end

.from_mpi_relationship(mpi_relationship) ⇒ Object

Initializer with a single ‘person’ from an MPI response RelationshipHolder stanza



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/user_relationship.rb', line 25

def self.from_mpi_relationship(mpi_relationship)
  user_relationship = new
  # Profile attributes
  user_relationship.first_name = mpi_relationship.given_names&.first
  user_relationship.last_name = mpi_relationship.family_name
  user_relationship.birth_date = Formatters::DateFormatter.format_date(mpi_relationship.birth_date)
  user_relationship.ssn = mpi_relationship.ssn
  user_relationship.gender = mpi_relationship.gender
  user_relationship.veteran_status = mpi_relationship.person_types.include? PERSON_TYPE_VETERAN
  # ID attributes
  user_relationship.icn = mpi_relationship.icn
  user_relationship.participant_id = mpi_relationship.participant_id
  user_relationship
end

Instance Method Details

#get_full_attributesObject

Full MPI Profile object



50
51
52
53
# File 'app/models/user_relationship.rb', line 50

def get_full_attributes
  user_identity = build_user_identity
  MPIData.for_user(user_identity)
end

#to_hashObject

Sparse hash to serialize to frontend



41
42
43
44
45
46
47
# File 'app/models/user_relationship.rb', line 41

def to_hash
  {
    first_name:,
    last_name:,
    birth_date:
  }
end