hippo 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/CHANGELOG +8 -0
  2. data/lib/hippo/field.rb +10 -1
  3. data/lib/hippo/segments/AAA.rb +39 -0
  4. data/lib/hippo/segments/EB.rb +207 -0
  5. data/lib/hippo/segments/EM.rb +63 -0
  6. data/lib/hippo/segments/EQ.rb +135 -0
  7. data/lib/hippo/segments/III.rb +195 -0
  8. data/lib/hippo/segments/INS.rb +171 -0
  9. data/lib/hippo/segments/LE.rb +15 -0
  10. data/lib/hippo/segments/LS.rb +15 -0
  11. data/lib/hippo/segments/MPI.rb +63 -0
  12. data/lib/hippo/segments/MSG.rb +31 -0
  13. data/lib/hippo/segments/PCT.rb +23 -0
  14. data/lib/hippo/segments/PDP.rb +31 -0
  15. data/lib/hippo/segments/PDR.rb +39 -0
  16. data/lib/hippo/segments/PID.rb +79 -0
  17. data/lib/hippo/segments/PKD.rb +47 -0
  18. data/lib/hippo/segments/SD1.rb +71 -0
  19. data/lib/hippo/segments/VEH.rb +159 -0
  20. data/lib/hippo/segments/base.rb +8 -0
  21. data/lib/hippo/segments.rb +16 -0
  22. data/lib/hippo/transaction_sets/HIPAA_270/L2000A.rb +32 -0
  23. data/lib/hippo/transaction_sets/HIPAA_270/L2000B.rb +32 -0
  24. data/lib/hippo/transaction_sets/HIPAA_270/L2000C.rb +41 -0
  25. data/lib/hippo/transaction_sets/HIPAA_270/L2000D.rb +41 -0
  26. data/lib/hippo/transaction_sets/HIPAA_270/L2100A.rb +21 -0
  27. data/lib/hippo/transaction_sets/HIPAA_270/L2100B.rb +55 -0
  28. data/lib/hippo/transaction_sets/HIPAA_270/L2100C.rb +97 -0
  29. data/lib/hippo/transaction_sets/HIPAA_270/L2100D.rb +97 -0
  30. data/lib/hippo/transaction_sets/HIPAA_270/L2110C.rb +67 -0
  31. data/lib/hippo/transaction_sets/HIPAA_270/L2110D.rb +47 -0
  32. data/lib/hippo/transaction_sets/HIPAA_270/base.rb +80 -0
  33. data/lib/hippo/transaction_sets/HIPAA_270.rb +17 -0
  34. data/lib/hippo/transaction_sets/HIPAA_271/L2000A.rb +44 -0
  35. data/lib/hippo/transaction_sets/HIPAA_271/L2000B.rb +32 -0
  36. data/lib/hippo/transaction_sets/HIPAA_271/L2000C.rb +41 -0
  37. data/lib/hippo/transaction_sets/HIPAA_271/L2000D.rb +41 -0
  38. data/lib/hippo/transaction_sets/HIPAA_271/L2100A.rb +43 -0
  39. data/lib/hippo/transaction_sets/HIPAA_271/L2100B.rb +67 -0
  40. data/lib/hippo/transaction_sets/HIPAA_271/L2100C.rb +124 -0
  41. data/lib/hippo/transaction_sets/HIPAA_271/L2100D.rb +124 -0
  42. data/lib/hippo/transaction_sets/HIPAA_271/L2110C.rb +98 -0
  43. data/lib/hippo/transaction_sets/HIPAA_271/L2110D.rb +98 -0
  44. data/lib/hippo/transaction_sets/HIPAA_271/L2115C.rb +16 -0
  45. data/lib/hippo/transaction_sets/HIPAA_271/L2115D.rb +16 -0
  46. data/lib/hippo/transaction_sets/HIPAA_271/L2120C.rb +54 -0
  47. data/lib/hippo/transaction_sets/HIPAA_271/L2120D.rb +54 -0
  48. data/lib/hippo/transaction_sets/HIPAA_271/base.rb +80 -0
  49. data/lib/hippo/transaction_sets/HIPAA_271.rb +21 -0
  50. data/lib/hippo/transaction_sets/base.rb +75 -21
  51. data/lib/hippo/transaction_sets/component.rb +6 -1
  52. data/lib/hippo/transaction_sets.rb +2 -0
  53. data/lib/hippo/version.rb +1 -1
  54. data/samples/837_L2000A_01.edi +1 -0
  55. data/samples/837_L2000A_02.edi +1 -0
  56. data/test/test_parser.rb +5 -0
  57. metadata +55 -7
@@ -21,6 +21,32 @@ module Hippo::TransactionSets
21
21
  end
22
22
  alias segment add_component
23
23
  alias loop add_component
24
+
25
+
26
+ def grouped_components
27
+ return @grouped_components if @grouped_components
28
+
29
+ initial_components = components.dup
30
+ @grouped_components = []
31
+ last_entry = nil
32
+
33
+ while initial_components.length > 0
34
+ component = initial_components.first
35
+
36
+ if component.segment?
37
+ @grouped_components << [] if last_entry != :segment
38
+ @grouped_components.last << component
39
+ last_entry = :segment
40
+ else
41
+ @grouped_components << component
42
+ last_entry = :transaction_set
43
+ end
44
+
45
+ initial_components.delete(component)
46
+ end
47
+
48
+ @grouped_components
49
+ end
24
50
  end
25
51
 
26
52
  attr_accessor :values, :parent, :sequences, :ISA, :GS, :GE, :IEA
@@ -38,25 +64,37 @@ module Hippo::TransactionSets
38
64
  end
39
65
 
40
66
  def populate(segments)
41
- self.class.components.each_with_index do |component, component_index|
42
- if component.klass.ancestors.include? Hippo::Segments::Base
67
+ grouped_components = self.class.grouped_components
68
+
69
+ grouped_components.each_with_index do |component, component_index|
70
+ if component.class == Array
71
+ #binding.pry
43
72
  # segments
44
- while true do
45
- segment = segments.first
73
+ starting_segment_count = segments.count
74
+ ending_segment_count = 0
46
75
 
47
- break unless segment
48
- break unless component.valid?(segment)
76
+ while starting_segment_count > ending_segment_count
77
+ starting_segment_count = segments.count
49
78
 
50
- segment.parent = self
79
+ component.each do |individual_component|
80
+ segment = segments.first
51
81
 
52
- if component.repeating?
53
- values[component.sequence] ||= component.initialize_component(self)
54
- values[component.sequence] << segment
55
- else
56
- values[component.sequence] = segment
82
+ break unless segment
83
+ next unless individual_component.valid?(segment)
84
+
85
+ segment.parent = self
86
+
87
+ if individual_component.repeating?
88
+ values[individual_component.sequence] ||= individual_component.initialize_component(self)
89
+ values[individual_component.sequence] << segment
90
+ else
91
+ values[individual_component.sequence] = segment
92
+ end
93
+
94
+ segments.delete(segment)
57
95
  end
58
96
 
59
- segments.delete(segment)
97
+ ending_segment_count = segments.count
60
98
  end
61
99
  else
62
100
  # loops
@@ -66,16 +104,24 @@ module Hippo::TransactionSets
66
104
  break unless initial_segment
67
105
  break unless component.valid?(initial_segment)
68
106
 
69
- ending_index = nil
70
- starting_index = component.repeating? ? component_index : component_index + 1
71
- remaining_components = self.class.components.slice(starting_index, self.class.components.length - starting_index)
72
- remaining_components.each do |next_component|
73
- break if ending_index
74
-
75
- ending_index = segments.find_index{|segment| segment != segments.first && next_component.valid?(segment)}
107
+ component_matches_found = []
108
+ starting_index = component.repeating? ? component_index : component_index + 1
109
+
110
+ grouped_components.slice(starting_index, grouped_components.length - starting_index).each do |next_component|
111
+ index = segments.find_index do |segment|
112
+ if segment == segments.first
113
+ false
114
+ elsif next_component.class == Array
115
+ next_component.any?{|subcomponent| subcomponent.valid?(segment)}
116
+ else
117
+ next_component.valid?(segment)
118
+ end
119
+ end
120
+
121
+ component_matches_found << index if index
76
122
  end
77
123
 
78
- child_segments = segments.slice!(0, ending_index || segments.length)
124
+ child_segments = segments.slice!(0, component_matches_found.min || segments.length)
79
125
  values[component.sequence] ||= component.initialize_component(self)
80
126
  if component.repeating?
81
127
  values[component.sequence].build {|comp| comp.populate(child_segments) }
@@ -101,6 +147,14 @@ module Hippo::TransactionSets
101
147
  @sequences[segment_identifier] += 1
102
148
  end
103
149
 
150
+ def segment?
151
+ false
152
+ end
153
+
154
+ def transaction_set?
155
+ true
156
+ end
157
+
104
158
  def segments
105
159
  values.values.collect(&:segments).flatten
106
160
  end
@@ -15,9 +15,14 @@ module Hippo::TransactionSets
15
15
  @maximum > 1
16
16
  end
17
17
 
18
- def loop?
18
+ def transaction_set?
19
19
  @klass.ancestors.include? Hippo::TransactionSets::Base
20
20
  end
21
+ alias :loop? :transaction_set?
22
+
23
+ def segment?
24
+ @klass.ancestors.include? Hippo::Segments::Base
25
+ end
21
26
 
22
27
  def identifier
23
28
  @klass.identifier
@@ -4,6 +4,8 @@ require_relative 'transaction_sets/repeating_component'
4
4
 
5
5
  module Hippo
6
6
  module TransactionSets
7
+ autoload_relative :HIPAA_270, 'transaction_sets/HIPAA_270'
8
+ autoload_relative :HIPAA_271, 'transaction_sets/HIPAA_271'
7
9
  autoload_relative :HIPAA_276, 'transaction_sets/HIPAA_276'
8
10
  autoload_relative :HIPAA_277, 'transaction_sets/HIPAA_277'
9
11
  autoload_relative :HIPAA_835, 'transaction_sets/HIPAA_835'
data/lib/hippo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hippo
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -0,0 +1 @@
1
+ HL*1**20*1~PRV*BI*PXC*193200000X~NM1*85*2*ACME CORP*****XX*0123456789~N3*1234 NOWHERE~N4*Testington*CO*1234556789~REF*EI*55801234~NM1*87*2~N3*ACME ADDRESS 1~N4*Testbason*CO*123456789~HL*2*1*22*1~SBR*P**170105M002******BL~NM1*IL*1*FLINSTONE*FRED*D***MI*SABLAD1249~NM1*PR*2*RUBBLE CORP*****PI*RC0201~HL*3*2*23*0~PAT*01~NM1*QC*1*FLINSTONE*WILMA*A~N3*17 RUBBLE WAY~N4*Ancient*WD*000010001~DMG*D8*19000101*F~CLM*3670078*983***21:B:1*Y*A*Y*Y~DTP*435*D8*19000101~REF*G1*NA~HI*BK:65231~NM1*DN*1*NUGGS JR MD*BETTY****XX*9876543210~NM1*82*1*BILLING MD*NAME****XX*6758493021~PRV*PE*PXC*207L00000X~NM1*77*2*HOSPITAL - OB*****XX*930284756~N3*1400 EAST STREET~N4*RANDOM CITY*CO*1234556789~LX*1~SV1*HC:01961:AA*787*MJ*57***1**Y~DTP*472*D8*20120102~REF*6R*3866045~LX*2~SV1*HC:99140*196*UN*1***1**Y~DTP*472*D8*20120102~REF*6R*3866046~
@@ -0,0 +1 @@
1
+ HL*1**20*1~PRV*BI*PXC*193200000X~NM1*85*2*ACME*****XX*1234567789~N3*1400 ST~N4*SPRINGS*CA*857363900~REF*EI*999125555~NM1*87*2~N3*1234 TEST ST~N4*SPRINGS*CA*01732898~HL*2*1*22*0~SBR*P*18*108000******CI~NM1*IL*1*KELLEY*GRACE*M***MI*JK134324~N3*3825 TERMINAL~N4*SPRINGS*CA*988775801~DMG*D8*19791120*F~NM1*PR*2*UNITED HEALTHCARE*****PI*87726~CLM*3670206*1615***22:B:1*Y*A*Y*Y~HI*BK:7244*BF:72210*BF:E9293~NM1*DN*1*OKEENEN MD*JAMES*S***XX~NM1*82*1*WILL MD*JOSE****XX*0998865412~PRV*PE*PXC*207L00000X~NM1*77*2*MEMORIAL*****XX*12314143423~N3*4050 PARKWAY~N4*SPRINGS*CA*09786653~LX*1~SV1*HC:99201:25*190*UN*1***1:2:3~DTP*472*D8*20120104~REF*6R*3866711~NM1*DN*1*OKEENEN MD*JAMES*S***XX~LX*2~SV1*HC:64483*760*UN*1***1:2:3~DTP*472*D8*20120104~REF*6R*3866712~NM1*DN*1*OKEENEN MD*JAMES*S***XX~LX*3~SV1*HC:64484*475*UN*1***1:2:3~DTP*472*D8*20120104~REF*6R*3866713~NM1*DN*1*OKEENEN MD*JAMES*S***XX~LX*4~SV1*HC:99144*190*UN*1***1:2:3~DTP*472*D8*20120104~REF*6R*3866714~NM1*DN*1*OKEENEN MD*JAMES*S***XX~
data/test/test_parser.rb CHANGED
@@ -97,4 +97,9 @@ class TestParser < MiniTest::Unit::TestCase
97
97
 
98
98
  assert_equal ts_01.L0002.values.to_s, ts_02.values.to_s
99
99
  end
100
+
101
+ def test_parse_l2000a
102
+ l2000a = Hippo::TransactionSets::HIPAA_837::L2000A.new.parse(File.read('samples/837_L2000A_01.edi'))
103
+ l2000a = Hippo::TransactionSets::HIPAA_837::L2000A.new.parse(File.read('samples/837_L2000A_02.edi'))
104
+ end
100
105
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hippo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-01-25 00:00:00.000000000 Z
13
+ date: 2012-07-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest
17
- requirement: &2182290180 !ruby/object:Gem::Requirement
17
+ requirement: &70276877883480 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :development
24
24
  prerelease: false
25
- version_requirements: *2182290180
25
+ version_requirements: *70276877883480
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rake
28
- requirement: &2182289680 !ruby/object:Gem::Requirement
28
+ requirement: &70276877882460 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,7 +33,7 @@ dependencies:
33
33
  version: 0.9.2
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2182289680
36
+ version_requirements: *70276877882460
37
37
  description: HIPAA Transaction Set Generator/Parser
38
38
  email:
39
39
  - robertj@promedicalinc.com
@@ -67,6 +67,7 @@ files:
67
67
  - lib/hippo/parser/segment.rb
68
68
  - lib/hippo/parser/transaction_set.rb
69
69
  - lib/hippo/segments.rb
70
+ - lib/hippo/segments/AAA.rb
70
71
  - lib/hippo/segments/AK1.rb
71
72
  - lib/hippo/segments/AK2.rb
72
73
  - lib/hippo/segments/AK3.rb
@@ -99,6 +100,9 @@ files:
99
100
  - lib/hippo/segments/DSB.rb
100
101
  - lib/hippo/segments/DTM.rb
101
102
  - lib/hippo/segments/DTP.rb
103
+ - lib/hippo/segments/EB.rb
104
+ - lib/hippo/segments/EM.rb
105
+ - lib/hippo/segments/EQ.rb
102
106
  - lib/hippo/segments/FRM.rb
103
107
  - lib/hippo/segments/GE.rb
104
108
  - lib/hippo/segments/GS.rb
@@ -107,18 +111,24 @@ files:
107
111
  - lib/hippo/segments/HL.rb
108
112
  - lib/hippo/segments/HSD.rb
109
113
  - lib/hippo/segments/IEA.rb
114
+ - lib/hippo/segments/III.rb
110
115
  - lib/hippo/segments/IK3.rb
111
116
  - lib/hippo/segments/IK4.rb
112
117
  - lib/hippo/segments/IK5.rb
113
118
  - lib/hippo/segments/IMM.rb
119
+ - lib/hippo/segments/INS.rb
114
120
  - lib/hippo/segments/ISA.rb
115
121
  - lib/hippo/segments/K3.rb
122
+ - lib/hippo/segments/LE.rb
116
123
  - lib/hippo/segments/LIN.rb
117
124
  - lib/hippo/segments/LQ.rb
125
+ - lib/hippo/segments/LS.rb
118
126
  - lib/hippo/segments/LX.rb
119
127
  - lib/hippo/segments/MEA.rb
120
128
  - lib/hippo/segments/MIA.rb
121
129
  - lib/hippo/segments/MOA.rb
130
+ - lib/hippo/segments/MPI.rb
131
+ - lib/hippo/segments/MSG.rb
122
132
  - lib/hippo/segments/N1.rb
123
133
  - lib/hippo/segments/N2.rb
124
134
  - lib/hippo/segments/N3.rb
@@ -127,7 +137,12 @@ files:
127
137
  - lib/hippo/segments/NTE.rb
128
138
  - lib/hippo/segments/OI.rb
129
139
  - lib/hippo/segments/PAT.rb
140
+ - lib/hippo/segments/PCT.rb
141
+ - lib/hippo/segments/PDP.rb
142
+ - lib/hippo/segments/PDR.rb
130
143
  - lib/hippo/segments/PER.rb
144
+ - lib/hippo/segments/PID.rb
145
+ - lib/hippo/segments/PKD.rb
131
146
  - lib/hippo/segments/PLB.rb
132
147
  - lib/hippo/segments/PRV.rb
133
148
  - lib/hippo/segments/PS1.rb
@@ -136,6 +151,7 @@ files:
136
151
  - lib/hippo/segments/RDM.rb
137
152
  - lib/hippo/segments/REF.rb
138
153
  - lib/hippo/segments/SBR.rb
154
+ - lib/hippo/segments/SD1.rb
139
155
  - lib/hippo/segments/SE.rb
140
156
  - lib/hippo/segments/ST.rb
141
157
  - lib/hippo/segments/STC.rb
@@ -154,9 +170,38 @@ files:
154
170
  - lib/hippo/segments/TS2.rb
155
171
  - lib/hippo/segments/TS3.rb
156
172
  - lib/hippo/segments/UR.rb
173
+ - lib/hippo/segments/VEH.rb
157
174
  - lib/hippo/segments/base.rb
158
175
  - lib/hippo/separator.rb
159
176
  - lib/hippo/transaction_sets.rb
177
+ - lib/hippo/transaction_sets/HIPAA_270.rb
178
+ - lib/hippo/transaction_sets/HIPAA_270/L2000A.rb
179
+ - lib/hippo/transaction_sets/HIPAA_270/L2000B.rb
180
+ - lib/hippo/transaction_sets/HIPAA_270/L2000C.rb
181
+ - lib/hippo/transaction_sets/HIPAA_270/L2000D.rb
182
+ - lib/hippo/transaction_sets/HIPAA_270/L2100A.rb
183
+ - lib/hippo/transaction_sets/HIPAA_270/L2100B.rb
184
+ - lib/hippo/transaction_sets/HIPAA_270/L2100C.rb
185
+ - lib/hippo/transaction_sets/HIPAA_270/L2100D.rb
186
+ - lib/hippo/transaction_sets/HIPAA_270/L2110C.rb
187
+ - lib/hippo/transaction_sets/HIPAA_270/L2110D.rb
188
+ - lib/hippo/transaction_sets/HIPAA_270/base.rb
189
+ - lib/hippo/transaction_sets/HIPAA_271.rb
190
+ - lib/hippo/transaction_sets/HIPAA_271/L2000A.rb
191
+ - lib/hippo/transaction_sets/HIPAA_271/L2000B.rb
192
+ - lib/hippo/transaction_sets/HIPAA_271/L2000C.rb
193
+ - lib/hippo/transaction_sets/HIPAA_271/L2000D.rb
194
+ - lib/hippo/transaction_sets/HIPAA_271/L2100A.rb
195
+ - lib/hippo/transaction_sets/HIPAA_271/L2100B.rb
196
+ - lib/hippo/transaction_sets/HIPAA_271/L2100C.rb
197
+ - lib/hippo/transaction_sets/HIPAA_271/L2100D.rb
198
+ - lib/hippo/transaction_sets/HIPAA_271/L2110C.rb
199
+ - lib/hippo/transaction_sets/HIPAA_271/L2110D.rb
200
+ - lib/hippo/transaction_sets/HIPAA_271/L2115C.rb
201
+ - lib/hippo/transaction_sets/HIPAA_271/L2115D.rb
202
+ - lib/hippo/transaction_sets/HIPAA_271/L2120C.rb
203
+ - lib/hippo/transaction_sets/HIPAA_271/L2120D.rb
204
+ - lib/hippo/transaction_sets/HIPAA_271/base.rb
160
205
  - lib/hippo/transaction_sets/HIPAA_276.rb
161
206
  - lib/hippo/transaction_sets/HIPAA_276/L2000A.rb
162
207
  - lib/hippo/transaction_sets/HIPAA_276/L2000B.rb
@@ -263,6 +308,8 @@ files:
263
308
  - samples/005010X231A1_01.edi
264
309
  - samples/005010X231A1_02.edi
265
310
  - samples/200823.EDI
311
+ - samples/837_L2000A_01.edi
312
+ - samples/837_L2000A_02.edi
266
313
  - test/test_helper.rb
267
314
  - test/test_hipaa_835.rb
268
315
  - test/test_hipaa_837.rb
@@ -290,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
337
  version: '0'
291
338
  requirements: []
292
339
  rubyforge_project: hippo
293
- rubygems_version: 1.8.11
340
+ rubygems_version: 1.8.17
294
341
  signing_key:
295
342
  specification_version: 3
296
343
  summary: HIPAA Transaction Set Generator/Parser
@@ -302,3 +349,4 @@ test_files:
302
349
  - test/test_parser.rb
303
350
  - test/test_segments_base.rb
304
351
  - test/test_transaction_sets_base.rb
352
+ has_rdoc: