ruby-hl7-extensions 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/VERSION.yml +1 -1
- data/lib/core_ext/message.rb +58 -30
- data/lib/core_ext/segment.rb +4 -0
- data/lib/core_ext/segments/pid.rb +4 -0
- data/lib/core_ext/segments/pv1.rb +0 -3
- data/lib/core_ext/segments/segments.rb +2 -1
- data/ruby-hl7-extensions.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6992498048c95d4b52e7619ebe459ddc0261146d
|
4
|
+
data.tar.gz: 26a6a7968434149415794b3294f18512d8bd8d81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d409e86076926f73e15ee305288dc01f455c1295a4b4c0eeb548cc72167562e9174d95df19da236f819f3aa9d28541728027895333613980e222f97df98ae0c0
|
7
|
+
data.tar.gz: ee2ac36a73294f8b5825ef66d236ffd7a4d6bd8fa793bb6ecf313a09c77dc0c99e91ca60325b8c67435b16f87aee8b0054df2401c01f9af87ed855253ffc7e12
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.5
|
data/VERSION.yml
CHANGED
data/lib/core_ext/message.rb
CHANGED
@@ -62,51 +62,79 @@ module Extensions
|
|
62
62
|
a.to_enum(:each)
|
63
63
|
end
|
64
64
|
|
65
|
+
def patient
|
66
|
+
patient = hash["message"]["content"]["PID"]
|
67
|
+
::HL7::Message::Segment.from_hash("PID", patient)
|
68
|
+
end
|
69
|
+
|
65
70
|
def patient_visit
|
66
71
|
patient_visit = hash["message"]["content"]["PV1"]
|
67
72
|
::HL7::Message::Segment.from_hash("PV1", patient_visit)
|
68
73
|
end
|
74
|
+
|
75
|
+
def orc_list
|
76
|
+
a = hash["message"]["content"]["ORC"]["array"].collect {|orc| ::HL7::Message::Segment.from_hash("ORC", orc)}
|
77
|
+
a.to_enum(:each)
|
78
|
+
end
|
69
79
|
|
70
80
|
def hash
|
71
81
|
to_hash
|
72
82
|
end
|
73
83
|
|
74
84
|
def to_hash
|
75
|
-
|
76
|
-
|
77
|
-
|
85
|
+
begin
|
86
|
+
return @hash unless @hash.blank?
|
87
|
+
@hash ||= HashWithIndifferentAccess.new
|
88
|
+
@hash[:message] = {content: {}}
|
78
89
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
90
|
+
last_segment = nil
|
91
|
+
self.each do |segment|
|
92
|
+
segment_name = segment.segment_name
|
93
|
+
if segment_name == "OBR"
|
94
|
+
@hash[:message][:content][segment_name.to_sym] ||= {}
|
95
|
+
@hash[:message][:content][segment_name.to_sym]["array"] ||= []
|
96
|
+
@hash[:message][:content][segment_name.to_sym]["array"] << segment.to_hash
|
86
97
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
98
|
+
@hash[:message][:content][segment_name.to_sym]["array"]
|
99
|
+
puts "last_segment = #{last_segment}"
|
100
|
+
if last_segment = "ORC"
|
101
|
+
@hash[:message][:content]["ORC"]["array"].last["OBR"] ||= {}
|
102
|
+
@hash[:message][:content]["ORC"]["array"].last["OBR"]["array"] ||= []
|
103
|
+
@hash[:message][:content]["ORC"]["array"].last["OBR"]["array"] << segment.to_hash
|
104
|
+
else
|
105
|
+
last_segment = segment_name
|
106
|
+
end
|
107
|
+
elsif segment_name == "OBX"
|
108
|
+
if last_segment == "OBR"
|
109
|
+
@hash[:message][:content]["OBR"]["array"].last[segment_name] ||= {}
|
110
|
+
@hash[:message][:content]["OBR"]["array"].last[segment_name]["array"] ||= []
|
111
|
+
@hash[:message][:content]["OBR"]["array"].last[segment_name]["array"] << segment.to_hash
|
112
|
+
end
|
113
|
+
elsif segment_name == "ORC"
|
114
|
+
@hash[:message][:content]["ORC"] ||= {}
|
115
|
+
@hash[:message][:content]["ORC"]["array"] ||= []
|
116
|
+
@hash[:message][:content]["ORC"]["array"] << segment.to_hash
|
117
|
+
last_segment = segment_name
|
118
|
+
elsif segment_name == "NTE"
|
119
|
+
if last_segment == "OBR"
|
120
|
+
@hash[:message][:content]["OBR"]["array"].last["OBX"] ||= {}
|
121
|
+
@hash[:message][:content]["OBR"]["array"].last["OBX"]["array"] ||= []
|
122
|
+
if @hash[:message][:content]["OBR"]["array"].last["OBX"]["array"].length>0
|
123
|
+
@hash[:message][:content]["OBR"]["array"].last["OBX"]["array"].last["notes"] ||= []
|
124
|
+
@hash[:message][:content]["OBR"]["array"].last["OBX"]["array"].last["notes"] << segment.to_hash
|
125
|
+
end
|
126
|
+
end
|
127
|
+
else
|
128
|
+
@hash[:message][:content][segment_name.to_sym] = segment.to_hash
|
102
129
|
end
|
103
|
-
|
104
|
-
@hash[:message][:content][segment_name.to_sym] = segment.to_hash
|
130
|
+
@hash[:message][:content]["EVN"] = @hash[:message][:content]["MSH"]["messageEvent"] if segment_name == "MSH"
|
105
131
|
end
|
106
|
-
@hash[:message][:content]["EVN"] = @hash[:message][:content]["MSH"]["messageEvent"] if segment_name == "MSH"
|
107
|
-
end
|
108
132
|
|
109
|
-
|
133
|
+
@hash
|
134
|
+
rescue => e
|
135
|
+
puts e.message
|
136
|
+
pp e.backtrace[0..10]
|
137
|
+
end
|
110
138
|
end
|
111
139
|
|
112
140
|
def to_json
|
data/lib/core_ext/segment.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'core_ext/segments/msh'
|
2
2
|
require 'core_ext/segments/pid'
|
3
|
+
require 'core_ext/segments/orc'
|
3
4
|
require 'core_ext/segments/obr'
|
4
5
|
require 'core_ext/segments/obx'
|
5
6
|
require 'core_ext/segments/nte'
|
6
7
|
require 'core_ext/segments/nk1'
|
7
8
|
require 'core_ext/segments/pv1'
|
8
9
|
|
9
|
-
segments = ["MSH","PID","OBR","OBX","NTE","NK1", "PV1"]
|
10
|
+
segments = ["MSH","PID","ORC","OBR","OBX","NTE","NK1", "PV1"]
|
10
11
|
segments.each do |segment_name|
|
11
12
|
|
12
13
|
eval("class HL7::Message::Segment::#{segment_name} < HL7::Message::Segment
|
data/ruby-hl7-extensions.gemspec
CHANGED