ruby-hl7-extensions 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: efaf834a166b854120c702029aa602d790d678c5
4
- data.tar.gz: 9b19a36fe05d084582a06437d9e4391079fe7ab2
3
+ metadata.gz: 6992498048c95d4b52e7619ebe459ddc0261146d
4
+ data.tar.gz: 26a6a7968434149415794b3294f18512d8bd8d81
5
5
  SHA512:
6
- metadata.gz: b00d846b27efe17b7c287a370b67937775842cc4d438fd2e33851084909b4aa31725291dccd7df6ecc606da3b943266d927d4b13de0f15c9ff95a2f4aa9477a7
7
- data.tar.gz: 8a844fa42b3a0150da77f52781e4050626abf3489fbac46eea5005cc7b85f1baed16d4929b6e3f4dee77e9e622264ea28e18c327b85191d62a67063e4f855778
6
+ metadata.gz: d409e86076926f73e15ee305288dc01f455c1295a4b4c0eeb548cc72167562e9174d95df19da236f819f3aa9d28541728027895333613980e222f97df98ae0c0
7
+ data.tar.gz: ee2ac36a73294f8b5825ef66d236ffd7a4d6bd8fa793bb6ecf313a09c77dc0c99e91ca60325b8c67435b16f87aee8b0054df2401c01f9af87ed855253ffc7e12
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.4
1
+ 0.0.5
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 0
4
- :patch: 4
4
+ :patch: 5
@@ -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
- return @hash unless @hash.blank?
76
- @hash ||= HashWithIndifferentAccess.new
77
- @hash[:message] = {content: {}}
85
+ begin
86
+ return @hash unless @hash.blank?
87
+ @hash ||= HashWithIndifferentAccess.new
88
+ @hash[:message] = {content: {}}
78
89
 
79
- last_segment = nil
80
- self.each do |segment|
81
- segment_name = segment.segment_name
82
- if segment_name == "OBR"
83
- @hash[:message][:content][segment_name.to_sym] ||= {}
84
- @hash[:message][:content][segment_name.to_sym]["array"] ||= []
85
- @hash[:message][:content][segment_name.to_sym]["array"] << segment.to_hash
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
- @hash[:message][:content][segment_name.to_sym]["array"]
88
-
89
- last_segment = segment_name
90
- elsif segment_name == "OBX"
91
- if last_segment == "OBR"
92
- @hash[:message][:content]["OBR"]["array"].last[segment_name] ||= {}
93
- @hash[:message][:content]["OBR"]["array"].last[segment_name]["array"] ||= []
94
- @hash[:message][:content]["OBR"]["array"].last[segment_name]["array"] << segment.to_hash
95
- end
96
- elsif segment_name == "NTE"
97
- if last_segment == "OBR"
98
- @hash[:message][:content]["OBR"]["array"].last["OBX"] ||= {}
99
- @hash[:message][:content]["OBR"]["array"].last["OBX"]["array"] ||= []
100
- @hash[:message][:content]["OBR"]["array"].last["OBX"]["array"].last["notes"] ||= [] if @hash[:message][:content]["OBR"]["array"].last["OBX"]["array"].length>0
101
- @hash[:message][:content]["OBR"]["array"].last["OBX"]["array"].last["notes"] << segment.to_hash
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
- else
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
- @hash
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
@@ -9,6 +9,10 @@ module Extensions
9
9
  end
10
10
 
11
11
  module InstanceMethods
12
+
13
+ def [](key)
14
+ to_hash[key]
15
+ end
12
16
 
13
17
  def segment_name
14
18
  self.class.to_s.split("::").last
@@ -13,6 +13,10 @@ module Extensions
13
13
  to_hash["internalId"]["id"]
14
14
  end
15
15
 
16
+ def gender
17
+ to_hash["sex"]
18
+ end
19
+
16
20
  def to_hash
17
21
  return @hash if @hash
18
22
 
@@ -9,9 +9,6 @@ module Extensions
9
9
  end
10
10
 
11
11
  module InstanceMethods
12
- def [](key)
13
- to_hash[key]
14
- end
15
12
 
16
13
  def account_number
17
14
  to_hash["visit"]["id"]
@@ -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
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ruby-hl7-extensions"
6
- s.version = "0.0.4"
6
+ s.version = "0.0.5"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-hl7-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Lega