Class: Hl7Header

Inherits:
Header show all
Defined in:
lib/ruby_astm/HL7/hl7_header.rb

Instance Attribute Summary collapse

Attributes inherited from Header

#machine_name, #patients, #protocol, #queries, #response_sent

Instance Method Summary collapse

Methods inherited from Header

#build_one_response, #build_responses, #commit, #get_header_response, #is_astm?, #is_hl7?, #to_json

Constructor Details

#initialize(args) ⇒ Hl7Header

Returns a new instance of Hl7Header.



12
13
14
15
16
17
18
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 12

def initialize(args)
	super
	set_machine_name(args)
	set_date_time(args)
	set_message_type(args)
	set_message_control_id(args)
end

Instance Attribute Details

#date_timeObject

overriding from header.



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

def date_time
  @date_time
end

#message_control_idObject

Returns the value of attribute message_control_id.



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

def message_control_id
  @message_control_id
end

#message_typeObject

Returns the value of attribute message_type.



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

def message_type
  @message_type
end

Instance Method Details

#ack_messageObject



84
85
86
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 84

def ack_message
	"ACK"
end

#field_seperatorsObject



68
69
70
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 68

def field_seperators
	"^~\\&"
end

#generate_ack_failure_responseObject



124
125
126
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 124

def generate_ack_failure_response

end

#generate_ack_success_responseObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 96

def generate_ack_success_response
	
	ack_msg = ""
	ack_msg += header + seperator
	ack_msg += field_seperators + seperator
	ack_msg += sending_application_name + seperator
	ack_msg += sending_facility_name + seperator
	ack_msg += seperator
	ack_msg += seperator
	ack_msg += sending_date_time + seperator
	ack_msg += seperator
	ack_msg += ack_msg + seperator
	ack_msg += self.message_control_id + seperator
	ack_msg += seperator
	ack_msg += hl7_version + seperator
	ack_msg += seperator
	ack_msg += seperator
	ack_msg += seperator
	ack_msg += seperator
	ack_msg += seperator
	ack_msg += seperator
	ack_msg += seperator
	ack_msg += "AA" + seperator
	ack_msg += sending_date_time + seperator
	ack_msg

end

#headerObject



64
65
66
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 64

def header
	"MSH"
end

#hl7_versionObject



92
93
94
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 92

def hl7_version
	"2.4"
end

#nack_messageObject



88
89
90
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 88

def nack_message
	"NACK"
end

#sending_application_nameObject



72
73
74
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 72

def sending_application_name
	"Pathofast_LIS"
end

#sending_date_timeObject



80
81
82
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 80

def sending_date_time
	Time.now.strftime("%Y%m%d%H%M%S")		
end

#sending_facility_nameObject



76
77
78
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 76

def sending_facility_name
	"Pathofast"
end

#seperatorObject

METHODS FOR generating the acknowledgement to an HL7 Message



60
61
62
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 60

def seperator
	"|"
end

#set_date_time(args) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 28

def set_date_time(args)
	if line = args[:line]
		unless line.fields[7].blank?
			self.date_time = line.fields[7]
		end
	end
end

#set_machine_name(args) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 20

def set_machine_name(args)
	if line = args[:line]
		unless line.fields[2].blank?
			self.machine_name = line.fields[2]
		end
	end
end

#set_message_control_id(args) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 44

def set_message_control_id(args)
	if line = args[:line]
		unless line.fields[9].blank?
			self.message_control_id = line.fields[9]
		end
	end
end

#set_message_type(args) ⇒ Object



36
37
38
39
40
41
42
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 36

def set_message_type(args)
	if line = args[:line]
		unless line.fields[8].blank?
			line.fields[8].strip.scan(/(?<message_type>[A-Z]+)\^/) { |message_type|  self.message_type = message_type[0] }
		end
	end
end

#set_protocol(args) ⇒ Object



8
9
10
# File 'lib/ruby_astm/HL7/hl7_header.rb', line 8

def set_protocol(args)
	self.protocol = "HL7"
end