Class: Patient

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

Direct Known Subclasses

Hl7Patient

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Patient

Returns a new instance of Patient.



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

def initialize(args={})
	set_sequence_number(args)
	set_patient_id(args)
	self.orders = []
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_response(options) ⇒ Object

patient id.



27
28
29
30
31
32
33
# File 'lib/ruby_astm/patient.rb', line 27

def build_response(options)
	if (options[:machine_name] && (options[:machine_name] == "cobas-e411"))
		"P|1\r"
	else
		"P|#{self.sequence_number}|#{self.patient_id}|||||||||||||||\r"
	end
end

#set_patient_id(args) ⇒ Object



16
17
18
# File 'lib/ruby_astm/patient.rb', line 16

def set_patient_id(args)
	self.patient_id = args[:patient_id]
end

#set_sequence_number(args) ⇒ Object



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

def set_sequence_number(args)
	if line = args[:line]
		self.sequence_number = line.fields[-1].to_i
	else
		self.sequence_number = args[:sequence_number]
	end
end

#to_jsonObject



35
36
37
38
39
40
41
# File 'lib/ruby_astm/patient.rb', line 35

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