Class: Patient

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_astm/patient.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Patient



8
9
10
11
12
13
14
15
16
17
# File 'lib/ruby_astm/patient.rb', line 8

def initialize(args)
  if args[:line]
    line = args[:line]
    self.sequence_number = line.fields[1].to_i
    self.orders = []
  else
    self.sequence_number = args[:sequence_number]
    self.patient_id = args[:patient_id]
  end
end

Instance Attribute Details

#ordersObject

Returns the value of attribute orders.



6
7
8
# File 'lib/ruby_astm/patient.rb', line 6

def orders
  @orders
end

#patient_idObject

Returns the value of attribute patient_id.



5
6
7
# File 'lib/ruby_astm/patient.rb', line 5

def patient_id
  @patient_id
end

#sequence_numberObject

sequence number can only be from 0 – 9.



4
5
6
# File 'lib/ruby_astm/patient.rb', line 4

def sequence_number
  @sequence_number
end

Instance Method Details

#build_responseObject

patient id.



20
21
22
# File 'lib/ruby_astm/patient.rb', line 20

def build_response
  "P|#{self.sequence_number}|#{self.patient_id}|||||||||||||||\r"
end

#to_jsonObject



24
25
26
27
28
29
30
# File 'lib/ruby_astm/patient.rb', line 24

def to_json
    hash = {}
    self.instance_variables.each do |x|
        hash[x] = self.instance_variable_get x
    end
    return hash.to_json
end