hippo 0.0.5 → 0.0.6
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.
- data/CHANGELOG +11 -5
- data/LICENSE +24 -0
- data/README.md +6 -0
- data/lib/hippo/parser.rb +43 -58
- data/lib/hippo/segments/base.rb +12 -9
- data/lib/hippo/separator.rb +39 -0
- data/lib/hippo/transaction_sets/base.rb +8 -12
- data/lib/hippo/transaction_sets/component.rb +1 -1
- data/lib/hippo/version.rb +1 -1
- data/lib/hippo.rb +5 -3
- data/test/test_helper.rb +17 -11
- data/test/test_parser.rb +32 -12
- data/test/test_segments_base.rb +9 -9
- data/test/test_transaction_sets_base.rb +9 -10
- metadata +9 -9
- data/samples/835_4010.edi +0 -1
- data/samples/837_4010A1.edi +0 -1
data/CHANGELOG
CHANGED
@@ -1,8 +1,14 @@
|
|
1
|
+
0.0.6 - 2011/11/09
|
2
|
+
* Add Separator module for handling segment, field, composite, and
|
3
|
+
repetition separators the same.
|
4
|
+
* Respect 'parent's separators when building/initializing components.
|
5
|
+
* Fixed parsing logic to properly handle nested groups.
|
6
|
+
|
1
7
|
0.0.5 - 2011/09/16
|
2
|
-
|
8
|
+
* Add ability to parse transaction sets.
|
3
9
|
|
4
10
|
0.0.4
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
11
|
+
* Fix issue when no values are set in any subfield of a composite field.
|
12
|
+
* Add more segment tests.
|
13
|
+
* Import all segments and loops from the X12 CSV Table Data
|
14
|
+
* Intial version.
|
data/LICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
Copyright (c) 2011, ProMedical, Inc.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
6
|
+
* Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
* Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
* Neither the name of ProMedical, Inc. nor the
|
12
|
+
names of its contributors may be used to endorse or promote products
|
13
|
+
derived from this software without specific prior written permission.
|
14
|
+
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
16
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
17
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL PROMEDICAL, INC. BE LIABLE FOR ANY
|
19
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
20
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
21
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
22
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
23
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
24
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
CHANGED
@@ -230,3 +230,9 @@ The same technique can be used to reference fields within a segment that have th
|
|
230
230
|
```
|
231
231
|
|
232
232
|
For more example please review the test suite.
|
233
|
+
|
234
|
+
License
|
235
|
+
-------
|
236
|
+
Copyright 2011 by ProMedical, and licensed under the Modified BSD License. See included
|
237
|
+
[LICENSE](/promedical/hippo/blob/master/LICENSE) file for
|
238
|
+
details.
|
data/lib/hippo/parser.rb
CHANGED
@@ -1,88 +1,73 @@
|
|
1
|
-
require 'pp'
|
2
1
|
require 'hippo'
|
3
2
|
|
4
3
|
module Hippo
|
5
4
|
class Parser
|
6
|
-
|
7
|
-
|
5
|
+
include Hippo::Separator
|
6
|
+
|
7
|
+
attr_accessor :transaction_sets, :raw_data
|
8
|
+
|
9
|
+
def initialize(options={})
|
10
|
+
setup_separators(options)
|
8
11
|
end
|
9
12
|
|
10
13
|
def read_file(filename)
|
11
14
|
@raw_data = File.read(filename)
|
15
|
+
parse_separators(@raw_data)
|
12
16
|
end
|
13
17
|
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
# populate each field from the original input
|
37
|
-
fields.each_with_index do |value, index|
|
38
|
-
field = segment.class.fields[index]
|
39
|
-
|
40
|
-
# if the field is an array that means it is a
|
41
|
-
# composite field
|
42
|
-
if field.class == Array
|
43
|
-
composite_fields = value.split(Hippo::CompositeSeparator)
|
44
|
-
|
45
|
-
# initialize the values hash with a hash for this
|
46
|
-
# composite field
|
47
|
-
segment.values[index] = {}
|
48
|
-
|
49
|
-
# iterate through each value present in the composite field
|
50
|
-
# and save them to the appropriate sequence in the values
|
51
|
-
# hash
|
52
|
-
composite_fields.each_with_index do |comp_value, comp_index|
|
53
|
-
segment.values[index][field[comp_index].sequence] = comp_value
|
54
|
-
end
|
55
|
-
else
|
56
|
-
segment.values[field.sequence] = value
|
18
|
+
def initialize_segment(input)
|
19
|
+
fields = input.split(@field_separator)
|
20
|
+
|
21
|
+
segment_identifier = fields.shift
|
22
|
+
segment = Segments.const_get(segment_identifier.upcase).new
|
23
|
+
|
24
|
+
fields.each_with_index do |value, index|
|
25
|
+
field = segment.class.fields[index]
|
26
|
+
|
27
|
+
# if the field is an array that means it is a
|
28
|
+
# composite field
|
29
|
+
if field.class == Array
|
30
|
+
composite_fields = value.split(@composite_separator)
|
31
|
+
composite_sequence = field.first.composite_sequence
|
32
|
+
|
33
|
+
segment.values[composite_sequence] = {}
|
34
|
+
|
35
|
+
composite_fields.each_with_index do |comp_value, comp_index|
|
36
|
+
composite_field = field[comp_index]
|
37
|
+
|
38
|
+
segment.values[composite_sequence][composite_field.sequence] = comp_value
|
57
39
|
end
|
40
|
+
else
|
41
|
+
segment.values[field.sequence] = value
|
58
42
|
end
|
59
|
-
|
60
|
-
# save the newly created segment to the segments accessor
|
61
|
-
segments << segment
|
62
43
|
end
|
63
44
|
|
64
|
-
|
45
|
+
segment
|
65
46
|
end
|
66
47
|
|
67
48
|
def populate_transaction_sets
|
68
|
-
|
49
|
+
raw_transaction_sets = []
|
69
50
|
|
70
|
-
@
|
71
|
-
if
|
72
|
-
|
51
|
+
@raw_data.split(@segment_separator).each do |segment_string|
|
52
|
+
next if segment_string.strip.empty?
|
53
|
+
|
54
|
+
if segment_string =~ /\AST/
|
55
|
+
raw_transaction_sets << []
|
73
56
|
end
|
74
57
|
|
75
|
-
|
58
|
+
raw_transaction_sets.last << initialize_segment(segment_string)
|
76
59
|
end
|
77
60
|
|
78
|
-
|
79
|
-
|
61
|
+
raw_transaction_sets.collect do |segments|
|
62
|
+
transaction_set_id = segments.first.ST01
|
63
|
+
transaction_set = Hippo::TransactionSets.constants.select{|c| c.to_s.end_with?(transaction_set_id) }.first
|
64
|
+
|
65
|
+
Hippo::TransactionSets.const_get(transaction_set)::Base.new(separators.merge(:segments => segments))
|
80
66
|
end
|
81
67
|
end
|
82
68
|
|
83
69
|
def parse(filename)
|
84
70
|
read_file(filename)
|
85
|
-
populate_segments
|
86
71
|
populate_transaction_sets
|
87
72
|
end
|
88
73
|
end
|
data/lib/hippo/segments/base.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Hippo::Segments
|
2
2
|
class Base
|
3
|
+
include Hippo::Separator
|
4
|
+
|
3
5
|
class << self
|
4
6
|
attr_accessor :fields, :identifier, :fixed_width
|
5
7
|
|
@@ -20,7 +22,7 @@ module Hippo::Segments
|
|
20
22
|
f.maximum = field[:maximum]
|
21
23
|
f.options = field[:options]
|
22
24
|
f.restrictions = field[:restrictions]
|
23
|
-
f.separator = field[:separator] || @default_separator ||
|
25
|
+
f.separator = field[:separator] || @default_separator || :field_separator
|
24
26
|
|
25
27
|
if @composite_block
|
26
28
|
f.composite = true
|
@@ -34,10 +36,10 @@ module Hippo::Segments
|
|
34
36
|
|
35
37
|
def composite_field(field_name)
|
36
38
|
@composite_block = true
|
37
|
-
@default_separator =
|
39
|
+
@default_separator = :composite_separator
|
38
40
|
fields << []
|
39
41
|
yield
|
40
|
-
@default_separator =
|
42
|
+
@default_separator = :field_separator
|
41
43
|
@composite_block = false
|
42
44
|
end
|
43
45
|
|
@@ -59,6 +61,8 @@ module Hippo::Segments
|
|
59
61
|
|
60
62
|
def initialize(options = {})
|
61
63
|
@parent = options.delete(:parent)
|
64
|
+
|
65
|
+
setup_separators(options)
|
62
66
|
end
|
63
67
|
|
64
68
|
def values
|
@@ -84,7 +88,7 @@ module Hippo::Segments
|
|
84
88
|
end
|
85
89
|
|
86
90
|
def to_s
|
87
|
-
output = self.class.identifier +
|
91
|
+
output = self.class.identifier + @field_separator
|
88
92
|
|
89
93
|
self.class.fields.each_with_index do |field, index|
|
90
94
|
if field.class == Array # this is a composite field
|
@@ -98,15 +102,15 @@ module Hippo::Segments
|
|
98
102
|
end
|
99
103
|
field_value = field_value.ljust(comp_field.maximum) if self.class.fixed_width
|
100
104
|
|
101
|
-
output += field_value +
|
105
|
+
output += field_value + @composite_separator
|
102
106
|
end
|
103
107
|
|
104
|
-
output +=
|
108
|
+
output += @field_separator
|
105
109
|
else # standard field
|
106
110
|
field_value = values[field.sequence].to_s
|
107
111
|
field_value = field_value.ljust(field.maximum) if self.class.fixed_width
|
108
112
|
|
109
|
-
output += field_value +
|
113
|
+
output += field_value + @field_separator
|
110
114
|
end
|
111
115
|
end
|
112
116
|
|
@@ -115,11 +119,10 @@ module Hippo::Segments
|
|
115
119
|
output = output.gsub(/:{2,}\*/,'*').gsub(/:\*/,'*')
|
116
120
|
end
|
117
121
|
|
118
|
-
output +=
|
122
|
+
output += @segment_separator
|
119
123
|
output = output.gsub(/\*+~/,'~')
|
120
124
|
end
|
121
125
|
|
122
|
-
|
123
126
|
def identifier
|
124
127
|
self.class.identifier
|
125
128
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Hippo
|
2
|
+
module Separator
|
3
|
+
attr_accessor :field_separator, :composite_separator, :repetition_separator, :segment_separator
|
4
|
+
|
5
|
+
def setup_separators(options = {})
|
6
|
+
[:field_separator, :repetition_separator, :composite_separator, :segment_separator].each do |sym|
|
7
|
+
value = options[sym] || parent_or_default_separator(sym)
|
8
|
+
|
9
|
+
self.send(:"#{sym}=", value)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def parent_or_default_separator(separator_type)
|
14
|
+
if defined?(parent) && parent
|
15
|
+
parent.send(separator_type.to_sym)
|
16
|
+
else
|
17
|
+
Hippo.const_get(:"DEFAULT_#{separator_type.to_s.upcase}")
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def parse_separators(input)
|
22
|
+
if input =~ /\AISA/
|
23
|
+
@field_separator = input[3]
|
24
|
+
@repetition_separator = input[82]
|
25
|
+
@composite_separator = input[104]
|
26
|
+
@segment_separator = input[105]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def separators
|
31
|
+
{
|
32
|
+
:field_separator => @field_separator,
|
33
|
+
:composite_separator => @composite_separator,
|
34
|
+
:segment_separator => @segment_separator,
|
35
|
+
:repetition_separator => @repetition_separator
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Hippo::TransactionSets
|
2
2
|
class Base
|
3
|
+
include Hippo::Separator
|
4
|
+
|
3
5
|
class << self
|
4
6
|
attr_accessor :components, :identifier
|
5
7
|
|
@@ -21,12 +23,11 @@ module Hippo::TransactionSets
|
|
21
23
|
attr_accessor :values, :parent, :sequences
|
22
24
|
|
23
25
|
def initialize(options = {})
|
24
|
-
@parent = options
|
26
|
+
@parent = options[:parent]
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
28
|
+
setup_separators(options)
|
29
|
+
|
30
|
+
populate(options[:segments]) if options[:segments]
|
30
31
|
end
|
31
32
|
|
32
33
|
def populate(segments)
|
@@ -48,7 +49,7 @@ module Hippo::TransactionSets
|
|
48
49
|
segments_found << segment
|
49
50
|
end
|
50
51
|
|
51
|
-
|
52
|
+
segments_found.each {|s| segments.delete(s)}
|
52
53
|
else
|
53
54
|
# loops
|
54
55
|
while true do
|
@@ -84,12 +85,7 @@ module Hippo::TransactionSets
|
|
84
85
|
subcomponent = component.initialize_component(self)
|
85
86
|
subcomponent.populate(segments.slice!(starting_index, length))
|
86
87
|
|
87
|
-
|
88
|
-
values[component.sequence] = component.initialize_component(self)
|
89
|
-
values[component.sequence] << subcomponent
|
90
|
-
else
|
91
|
-
values[component.sequence] = subcomponent
|
92
|
-
end
|
88
|
+
values[component.sequence] = subcomponent
|
93
89
|
end
|
94
90
|
end
|
95
91
|
end
|
data/lib/hippo/version.rb
CHANGED
data/lib/hippo.rb
CHANGED
@@ -3,13 +3,15 @@ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
|
|
3
3
|
|
4
4
|
module Hippo
|
5
5
|
autoload :Exceptions, 'hippo/exceptions'
|
6
|
+
autoload :Separator, 'hippo/separator'
|
6
7
|
autoload :Segments, 'hippo/segments'
|
7
8
|
autoload :TransactionSets, 'hippo/transaction_sets'
|
8
9
|
autoload :Field, 'hippo/field'
|
9
10
|
autoload :CompositeField, 'hippo/composite_field'
|
10
11
|
autoload :Parser, 'hippo/parser'
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
DEFAULT_FIELD_SEPARATOR = '*'
|
14
|
+
DEFAULT_COMPOSITE_SEPARATOR = ':'
|
15
|
+
DEFAULT_SEGMENT_SEPARATOR = '~'
|
16
|
+
DEFAULT_REPETITION_SEPARATOR = '^'
|
15
17
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
gem 'minitest'
|
3
3
|
require 'minitest/autorun'
|
4
|
+
require 'pp'
|
5
|
+
require 'pry'
|
4
6
|
|
5
7
|
require File.expand_path(File.join('..','lib','hippo'), File.dirname(__FILE__))
|
6
|
-
require 'pp'
|
7
8
|
|
8
9
|
module Hippo::Segments
|
9
|
-
class
|
10
|
+
class TSS < Hippo::Segments::Base
|
10
11
|
segment_identifier 'TSS'
|
11
12
|
|
12
13
|
field :name => 'Field1'
|
@@ -17,7 +18,7 @@ module Hippo::Segments
|
|
17
18
|
field :name => 'CommonName'
|
18
19
|
end
|
19
20
|
|
20
|
-
class
|
21
|
+
class TCS < Hippo::Segments::Base
|
21
22
|
segment_identifier 'TCS'
|
22
23
|
|
23
24
|
composite_field 'CompositeField' do
|
@@ -43,7 +44,7 @@ module Hippo::TransactionSets
|
|
43
44
|
class L0001 < Hippo::TransactionSets::Base
|
44
45
|
loop_name 'L0001'
|
45
46
|
|
46
|
-
segment Hippo::Segments::
|
47
|
+
segment Hippo::Segments::TSS,
|
47
48
|
:name => 'Test Simple Segment #1',
|
48
49
|
:minimum => 1,
|
49
50
|
:maximum => 1,
|
@@ -53,16 +54,16 @@ module Hippo::TransactionSets
|
|
53
54
|
class L0002 < Hippo::TransactionSets::Base
|
54
55
|
loop_name 'L0002'
|
55
56
|
|
56
|
-
segment Hippo::Segments::
|
57
|
+
segment Hippo::Segments::TCS,
|
57
58
|
:name => 'Test Compound Segment #4',
|
58
59
|
:minimum => 1,
|
59
60
|
:maximum => 1,
|
60
61
|
:position => 100,
|
61
62
|
:identified_by => {
|
62
|
-
'Field7' => 'Preset Field 7'
|
63
|
+
'Field7' => ['Preset Field 7', 'Foo2']
|
63
64
|
}
|
64
65
|
|
65
|
-
segment Hippo::Segments::
|
66
|
+
segment Hippo::Segments::TSS,
|
66
67
|
:name => 'Test Simple Segment #5',
|
67
68
|
:minimum => 1,
|
68
69
|
:maximum => 1,
|
@@ -74,7 +75,12 @@ module Hippo::TransactionSets
|
|
74
75
|
|
75
76
|
class Base < Hippo::TransactionSets::Base
|
76
77
|
|
77
|
-
segment Hippo::Segments::
|
78
|
+
segment Hippo::Segments::ST,
|
79
|
+
:identified_by => {
|
80
|
+
'ST01' => 'Test'
|
81
|
+
}
|
82
|
+
|
83
|
+
segment Hippo::Segments::TSS,
|
78
84
|
:name => 'Test Simple Segment #1',
|
79
85
|
:minimum => 1,
|
80
86
|
:maximum => 5,
|
@@ -83,7 +89,7 @@ module Hippo::TransactionSets
|
|
83
89
|
'TSS01' => 'Blah'
|
84
90
|
}
|
85
91
|
|
86
|
-
segment Hippo::Segments::
|
92
|
+
segment Hippo::Segments::TCS,
|
87
93
|
:name => 'Test Compound Segment #2',
|
88
94
|
:minimum => 1,
|
89
95
|
:maximum => 1,
|
@@ -92,13 +98,13 @@ module Hippo::TransactionSets
|
|
92
98
|
'Field7' => 'Preset Field 7'
|
93
99
|
}
|
94
100
|
|
95
|
-
segment Hippo::Segments::
|
101
|
+
segment Hippo::Segments::TSS,
|
96
102
|
:name => 'Test Simple Segment #3',
|
97
103
|
:minimum => 1,
|
98
104
|
:maximum => 1,
|
99
105
|
:position => 50,
|
100
106
|
:identified_by => {
|
101
|
-
'TSS01' => 'Last Segment'
|
107
|
+
'TSS01' => 'Last Standalone Segment'
|
102
108
|
}
|
103
109
|
|
104
110
|
loop Hippo::TransactionSets::Test::L0001,
|
data/test/test_parser.rb
CHANGED
@@ -1,21 +1,12 @@
|
|
1
1
|
require File.expand_path('test_helper', File.dirname(__FILE__))
|
2
2
|
|
3
3
|
class TestParser < MiniTest::Unit::TestCase
|
4
|
-
def
|
5
|
-
parser = Hippo::Parser.new
|
6
|
-
parser.read_file('samples/005010X221A1_business_scenario_1.edi')
|
7
|
-
parser.populate_segments
|
8
|
-
|
9
|
-
assert_instance_of Array, parser.segments
|
10
|
-
|
11
|
-
parser.segments.each do |segment|
|
12
|
-
assert_kind_of Hippo::Segments::Base, segment
|
13
|
-
end
|
4
|
+
def setup
|
5
|
+
@parser = Hippo::Parser.new
|
14
6
|
end
|
15
7
|
|
16
8
|
def test_parse_returns_array_of_transaction_sets
|
17
|
-
|
18
|
-
transaction_sets = parser.parse('samples/005010X221A1_business_scenario_1.edi')
|
9
|
+
transaction_sets = @parser.parse('samples/005010X221A1_business_scenario_1.edi')
|
19
10
|
|
20
11
|
assert_instance_of Array, transaction_sets
|
21
12
|
|
@@ -23,4 +14,33 @@ class TestParser < MiniTest::Unit::TestCase
|
|
23
14
|
assert_kind_of Hippo::TransactionSets::Base, ts
|
24
15
|
end
|
25
16
|
end
|
17
|
+
|
18
|
+
def test_raises_error_on_extra_segments
|
19
|
+
ts = Hippo::TransactionSets::Test::Base.new
|
20
|
+
ts.ST
|
21
|
+
ts.TSS.Field2 = 'Bar'
|
22
|
+
ts.TSS.Field3 = 'Baz'
|
23
|
+
ts.TCS.Field1 = 'Blah'
|
24
|
+
ts.TCS.CompositeCommonName_02 = 'CNBlah'
|
25
|
+
ts.TSS_02.Field2 = 'Boo'
|
26
|
+
|
27
|
+
# test nested block syntax on non-looping component
|
28
|
+
ts.L0001.TSS.Field2 = 'SubBar'
|
29
|
+
|
30
|
+
# test nested block syntax on non-looping component
|
31
|
+
ts.L0002 do |l0002|
|
32
|
+
l0002.TCS.Field2 = 'SubBarBlah'
|
33
|
+
l0002.TSS.Field2 = 'SubBarRepeater'
|
34
|
+
end
|
35
|
+
|
36
|
+
#'TSS*Blah*Bar*Baz~TCS*Blah*:::CNBlah*Preset Field 7~TSS*Last Segment*Boo~TSS*Foo*SubBar~TCS*:SubBarBlah**Foo2~TSS*Last Segment*SubBarRepeater~', ts.to_s
|
37
|
+
|
38
|
+
@parser.raw_data = ts.to_s
|
39
|
+
ts_result = @parser.populate_transaction_sets.first
|
40
|
+
|
41
|
+
puts ts.inspect
|
42
|
+
puts ts_result.inspect
|
43
|
+
|
44
|
+
assert_equal ts.values.inspect, ts_result.values.inspect
|
45
|
+
end
|
26
46
|
end
|
data/test/test_segments_base.rb
CHANGED
@@ -5,13 +5,13 @@ class TestSegmentsBase < MiniTest::Unit::TestCase
|
|
5
5
|
def teardown; end;
|
6
6
|
|
7
7
|
def test_empty_segment
|
8
|
-
seg = Hippo::Segments::
|
8
|
+
seg = Hippo::Segments::TSS.new
|
9
9
|
|
10
10
|
assert_equal 'TSS~', seg.to_s
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_basic_populated_segment
|
14
|
-
seg = Hippo::Segments::
|
14
|
+
seg = Hippo::Segments::TSS.new
|
15
15
|
|
16
16
|
seg.Field1 = 'TestField1'
|
17
17
|
seg.Field2 = 'TestField2'
|
@@ -22,7 +22,7 @@ class TestSegmentsBase < MiniTest::Unit::TestCase
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def test_empty_field_in_segment
|
25
|
-
seg = Hippo::Segments::
|
25
|
+
seg = Hippo::Segments::TSS.new
|
26
26
|
|
27
27
|
seg.Field2 = 'TestField2'
|
28
28
|
seg.Field3 = 'TestField3'
|
@@ -30,7 +30,7 @@ class TestSegmentsBase < MiniTest::Unit::TestCase
|
|
30
30
|
|
31
31
|
assert_equal 'TSS**TestField2*TestField3*TestField4~', seg.to_s
|
32
32
|
|
33
|
-
seg = Hippo::Segments::
|
33
|
+
seg = Hippo::Segments::TSS.new
|
34
34
|
|
35
35
|
seg.Field2 = 'TestField2'
|
36
36
|
|
@@ -38,7 +38,7 @@ class TestSegmentsBase < MiniTest::Unit::TestCase
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_segment_orders_properly
|
41
|
-
seg = Hippo::Segments::
|
41
|
+
seg = Hippo::Segments::TSS.new
|
42
42
|
|
43
43
|
seg.Field3 = 'TestField3'
|
44
44
|
seg.Field2 = 'TestField2'
|
@@ -49,7 +49,7 @@ class TestSegmentsBase < MiniTest::Unit::TestCase
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def test_assign_values_with_same_field_names
|
52
|
-
seg = Hippo::Segments::
|
52
|
+
seg = Hippo::Segments::TSS.new
|
53
53
|
seg.CommonName = 'Value1'
|
54
54
|
seg.CommonName_02 = 'Value2'
|
55
55
|
|
@@ -62,7 +62,7 @@ class TestSegmentsBase < MiniTest::Unit::TestCase
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def test_compound_segment
|
65
|
-
seg = Hippo::Segments::
|
65
|
+
seg = Hippo::Segments::TCS.new
|
66
66
|
|
67
67
|
seg.Field1 = 'Comp1Field1'
|
68
68
|
seg.Field2 = 'Comp1Field2'
|
@@ -75,7 +75,7 @@ class TestSegmentsBase < MiniTest::Unit::TestCase
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def test_compound_segment_with_empty_initial_fields
|
78
|
-
seg = Hippo::Segments::
|
78
|
+
seg = Hippo::Segments::TCS.new
|
79
79
|
|
80
80
|
seg.Field2 = 'Comp1Field2'
|
81
81
|
|
@@ -84,7 +84,7 @@ class TestSegmentsBase < MiniTest::Unit::TestCase
|
|
84
84
|
|
85
85
|
def test_compound_segment_assign_values_with_same_field_names
|
86
86
|
|
87
|
-
seg = Hippo::Segments::
|
87
|
+
seg = Hippo::Segments::TCS.new
|
88
88
|
|
89
89
|
seg.CompositeCommonName = 'CompVal1'
|
90
90
|
seg.CompositeCommonName_02 = 'CompVal2'
|
@@ -29,7 +29,6 @@ class TestTransactionSetBase < MiniTest::Unit::TestCase
|
|
29
29
|
ts.L0001 {|l0001| }
|
30
30
|
|
31
31
|
assert_equal 'TSS*Foo~', ts.to_s
|
32
|
-
|
33
32
|
end
|
34
33
|
|
35
34
|
def test_accessing_sements_with_same_segment_id
|
@@ -38,7 +37,7 @@ class TestTransactionSetBase < MiniTest::Unit::TestCase
|
|
38
37
|
ts.TCS.Field1 = 'Foo'
|
39
38
|
ts.TSS_02.Field2 = 'Baz'
|
40
39
|
|
41
|
-
assert_equal 'TSS*Blah*Bar~TCS*Foo**Preset Field 7~TSS*Last Segment*Baz~', ts.to_s
|
40
|
+
assert_equal 'TSS*Blah*Bar~TCS*Foo**Preset Field 7~TSS*Last Standalone Segment*Baz~', ts.to_s
|
42
41
|
end
|
43
42
|
|
44
43
|
def test_assigning_segment_values_with_block_syntax
|
@@ -58,7 +57,7 @@ class TestTransactionSetBase < MiniTest::Unit::TestCase
|
|
58
57
|
tss.Field2 = 'Boo'
|
59
58
|
end
|
60
59
|
|
61
|
-
assert_equal 'TSS*Blah*Bar*Baz~TCS*Blah*:::CNBlah*Preset Field 7~TSS*Last Segment*Boo~', ts.to_s
|
60
|
+
assert_equal 'TSS*Blah*Bar*Baz~TCS*Blah*:::CNBlah*Preset Field 7~TSS*Last Standalone Segment*Boo~', ts.to_s
|
62
61
|
|
63
62
|
# test nexted block syntax on non-looping component
|
64
63
|
ts.L0001 do |l0001|
|
@@ -67,7 +66,7 @@ class TestTransactionSetBase < MiniTest::Unit::TestCase
|
|
67
66
|
end
|
68
67
|
end
|
69
68
|
|
70
|
-
assert_equal 'TSS*Blah*Bar*Baz~TCS*Blah*:::CNBlah*Preset Field 7~TSS*Last Segment*Boo~TSS*Foo*SubBar~', ts.to_s
|
69
|
+
assert_equal 'TSS*Blah*Bar*Baz~TCS*Blah*:::CNBlah*Preset Field 7~TSS*Last Standalone Segment*Boo~TSS*Foo*SubBar~', ts.to_s
|
71
70
|
|
72
71
|
# test nexted block syntax on non-looping component
|
73
72
|
ts.L0002 do |l0002|
|
@@ -80,21 +79,21 @@ class TestTransactionSetBase < MiniTest::Unit::TestCase
|
|
80
79
|
end
|
81
80
|
end
|
82
81
|
|
83
|
-
assert_equal 'TSS*Blah*Bar*Baz~TCS*Blah*:::CNBlah*Preset Field 7~TSS*Last Segment*Boo~TSS*Foo*SubBar~TCS*:SubBarBlah**Foo2~TSS*Last Segment*SubBarRepeater~', ts.to_s
|
82
|
+
assert_equal 'TSS*Blah*Bar*Baz~TCS*Blah*:::CNBlah*Preset Field 7~TSS*Last Standalone Segment*Boo~TSS*Foo*SubBar~TCS*:SubBarBlah**Foo2~TSS*Last Segment*SubBarRepeater~', ts.to_s
|
84
83
|
end
|
85
84
|
|
86
85
|
def test_intializing_with_segment_array_populates_transaction_set
|
87
|
-
tss = Hippo::Segments::
|
86
|
+
tss = Hippo::Segments::TSS.new
|
88
87
|
tss.TSS01 = 'Blah'
|
89
88
|
|
90
|
-
tcs = Hippo::Segments::
|
89
|
+
tcs = Hippo::Segments::TCS.new
|
91
90
|
tcs.Field7 = 'Preset Field 7'
|
92
91
|
|
93
|
-
tss2 = Hippo::Segments::
|
94
|
-
tss2.TSS01 = 'Last Segment'
|
92
|
+
tss2 = Hippo::Segments::TSS.new
|
93
|
+
tss2.TSS01 = 'Last Standalone Segment'
|
95
94
|
|
96
95
|
# start L0001 segments
|
97
|
-
tss3 = Hippo::Segments::
|
96
|
+
tss3 = Hippo::Segments::TSS.new
|
98
97
|
tss3.TSS01 = 'Foo'
|
99
98
|
|
100
99
|
segment_array = [tss, tcs, tss2, tss3]
|
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.0.
|
4
|
+
version: 0.0.6
|
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: 2011-09
|
13
|
+
date: 2011-11-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: minitest
|
17
|
-
requirement: &
|
17
|
+
requirement: &70266547233860 !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: *
|
25
|
+
version_requirements: *70266547233860
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: rake
|
28
|
-
requirement: &
|
28
|
+
requirement: &70266547233360 !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: *
|
36
|
+
version_requirements: *70266547233360
|
37
37
|
description: HIPAA Transaction Set Generator/Parser
|
38
38
|
email:
|
39
39
|
- robertj@promedicalinc.com
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- CHANGELOG
|
46
46
|
- Gemfile
|
47
47
|
- Guardfile
|
48
|
+
- LICENSE
|
48
49
|
- README.md
|
49
50
|
- Rakefile
|
50
51
|
- hippo.gemspec
|
@@ -138,6 +139,7 @@ files:
|
|
138
139
|
- lib/hippo/segments/TS3.rb
|
139
140
|
- lib/hippo/segments/UR.rb
|
140
141
|
- lib/hippo/segments/base.rb
|
142
|
+
- lib/hippo/separator.rb
|
141
143
|
- lib/hippo/transaction_sets.rb
|
142
144
|
- lib/hippo/transaction_sets/HIPAA_276.rb
|
143
145
|
- lib/hippo/transaction_sets/HIPAA_276/L2000A.rb
|
@@ -237,8 +239,6 @@ files:
|
|
237
239
|
- samples/005010X221A1_tmhp_example.edi
|
238
240
|
- samples/005010X222A1_anesthesia.edi
|
239
241
|
- samples/005010X222A1_commercial_health_insurance.edi
|
240
|
-
- samples/835_4010.edi
|
241
|
-
- samples/837_4010A1.edi
|
242
242
|
- test/test_helper.rb
|
243
243
|
- test/test_hipaa_835.rb
|
244
244
|
- test/test_hipaa_837.rb
|
@@ -265,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
265
|
version: '0'
|
266
266
|
requirements: []
|
267
267
|
rubyforge_project: hippo
|
268
|
-
rubygems_version: 1.8.
|
268
|
+
rubygems_version: 1.8.10
|
269
269
|
signing_key:
|
270
270
|
specification_version: 3
|
271
271
|
summary: HIPAA Transaction Set Generator/Parser
|
data/samples/835_4010.edi
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ISA*00* *00* *ZZ*EMEDNYBAT *ZZ*530 *080716*1801*U*00401*198000001*0*T*:~GS*HP*EMEDNYBAT*530*20080716*18011900*198000001*X*004010X091A1~ST*835*159900001~BPR*H*0*C*NON************20080716~TRN*1*NO PAYMENT*1141797357~REF*EV*530~REF*F2*004010X091A1~DTM*405*20080716~N1*PR*NYSDOH~N3*OFFICE OF MEDICAID MANAGEMENT*CORNING TOWER, EMPIRE STATE PLAZA~N4*ALBANY*NY*122370080~N1*PE*ST ELSEWARE HSP MED CTR NY*XX*1234567890~REF*TJ*111991234~LX*1~CLP*0711000004462420*22*-123.86*-134.7**MC*0712000000015920*13*7~CAS*CR*A2*10.84*0~NM1*QC*1*PATIENT*ANNIBEL*X***MI*AA00000Z~NM1*82*1******XX*1234567890~REF*EA*607887001~REF*9A*4303~DTM*232*20070413~DTM*233*20070413~PER*CX*RETRO RATE REVERSAL~CLP*0711000004462420*1*123.86*130.7**MC*0712000000015920*13*7~CAS*CO*A2*-6.84*0~NM1*QC*1*PATIENT*ANNIBEL*X***MI*AA00000Z~NM1*82*1******XX*1234567890~REF*EA*607887001~REF*9A*4303~DTM*232*20070413~DTM*233*20070413~PER*CX*RETRO RATE CORRECTION~PLB*1234567890*20081231*FB:000000000000000000000000000000*-4~SE*32*159900001~GE*1*198000001~IEA*1*198000001~
|
data/samples/837_4010A1.edi
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
ISA*00* *00* *ZZ*498 *ZZ*123456789 *070814*1741*U*00401*000001234*0*P*:~GS*HC*123*123456789*20070814*1741*2353*X*004010X098A1~ST*837*0001~BHT*0019*00*1*20070814*1741*CH~REF*87*004010X098A1~NM1*41*2*John Doe Clinic*****46*498~PER*IC*John Doe Clinic*TE*1305862479~NM1*40*2*NONEBLUE CROSS OF OKLAHOMA*****00*1301112222~HL*1**20*1~NM1*85*2*John Doe Clinic*****XX*1134125735~N3*12 MAIN STREET~N4*CITY*ST*56789~REF*EI*76053151601~HL*2*1*22*1~SBR*P**702510******CI~NM1*IL*1*DOE*JOHN****ST*123456789~N3*123 DOE ST~N4*CITY*ST*12345~DMG*D8*20020202*M~NM1*PR*2*NONEBLUE CROSS OF OKLAHOMA*****PI*12345~N3*P O BOX 000000~N4*CITY*ST*77210~HL*3*2*23*0~PAT*19******01*239~NM1*QC*1*SMITH*DOE Q****MI*123456789~N3*12 MAIN STREET~N4*CITY*ST*56789~CLM*968928879*45***12::1*Y*A*Y*Y*C~REF*9F*2417401094~REF*D9*26485~HI*BK:8489~NM1*DN*1*DOE*JANE~REF*1G*F01234~LX*1~SV1*HC:E0114:NU*45.00*UN*1***1~DTP*472*RD8*20070515-20070515~NM1*DK*1*DOE*JANE~N3*1234 NOWHERE SUITE 100~N4*CITY*ST*56789~REF*1G*F12345~PER*IC*JOHN DOLITTLE*TE*1301112222~SE*40*0001~GE*1*2353~IEA*1*000001234~
|