x12 0.1.0

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.
@@ -0,0 +1,102 @@
1
+ [LOOPS]
2
+ ISA
3
+ GS
4
+ ST
5
+ 1000A
6
+ 1000B
7
+ 2000A
8
+ 2000B
9
+ SE
10
+ GE
11
+ IEA
12
+
13
+ #--- start of loop details ---#
14
+
15
+ [ISA]
16
+ segment=ISA:::ISA:R:1
17
+
18
+ [GS]
19
+ segment=GS:::GS:R:1
20
+
21
+ #LOOP ID - HEADER
22
+ [ST]
23
+ segment=ST:::820 Header:R:1
24
+ segment=BPR:::Financial Information:R:1
25
+ segment=TRN:::Reassociation Key:R:1
26
+ segment=CUR:::Non-US Dollars Currency:S:1
27
+ segment=REF:::Premium Receivers Identification Key:S:>1
28
+ segment=DTM:::Process Date:S:1
29
+ segment=DTM:::Delivery Date:S:1
30
+ segment=DTM:::Coverage Period:S:1
31
+
32
+ #LOOP ID - 1000A PREMIUM RECEIVER�S NAME 1
33
+ [1000A]
34
+ segment=N1:1:PE:Premium Receiver�s Name:R:1
35
+ segment=N2:::Premium Receiver Additional Name:S:1
36
+ segment=N3:::Premium Receiver�s Address:S:1
37
+ segment=N4:::Premium Receiver�s City, State, Zip:S:1
38
+
39
+ #LOOP ID - 1000B PREMIUM PAYER�S NAME 1
40
+ [1000B]
41
+ segment=N1:1:PR:Premium Payer�s Name:R:1
42
+ segment=N2:::Premium Payer Additional Name:S:1
43
+ segment=N3:::Premium Payer�s Address:S:1
44
+ segment=N4:::Premium Payer�s City, State, Zip:S:1
45
+ segment=PER:::Premium Payer�s Administrative Contact:S:>1
46
+
47
+ #LOOP ID - 2000A ORGANIZATION SUMMARY REMITTANCE 1
48
+ [2000A]
49
+ segment=ENT:::Organization Summary Remittance:S:1
50
+ loop=2300A
51
+
52
+ #LOOP ID - 2300A ORGANIZATION SUMMARY REMITTANCE DETAIL >1
53
+ [2300A]
54
+ segment=RMR:::Organization Summary Remittance Detail:R:1
55
+ loop=2310A
56
+ loop=2320A
57
+
58
+ #LOOP ID - 2310A SUMMARY LINE ITEM 1
59
+ [2310A]
60
+ segment=IT1:::Summary Line Item:S:1
61
+ loop=2315A
62
+
63
+ #LOOP ID - 2315A MEMBER COUNT >1
64
+ [2315A]
65
+ segment=SLN:::Member Count:S:1
66
+
67
+ #LOOP ID - 2320A ORGANIZATION SUMMARY REMITTANCE LEVEL ADJUSTMENT >1
68
+ [2320A]
69
+ segment=ADX:::Organization Summary Remittance Level Adjustment:S:1
70
+
71
+ #LOOP ID - 2000B INDIVIDUAL REMITTANCE >1
72
+ [2000B]
73
+ segment=ENT:::Individual Remittance:S:1
74
+ loop=2100B
75
+ loop=2300B
76
+
77
+ #LOOP ID - 2100B INDIVIDUAL NAME >1
78
+ [2100B]
79
+ segment=NM1:1:EY:Individual Name:S:1
80
+
81
+ #LOOP ID - 2300B INDIVIDUAL PREMIUM REMITTANCE DETAIL >1
82
+ [2300B]
83
+ segment=RMR:::Individual Premium Remittance Detail:S:1
84
+ segment=DTM:::Individual Coverage Period:S:1
85
+ loop=2320B
86
+
87
+ #LOOP ID - 2320B INDIVIDUAL PREMIUM ADJUSTMENT >1
88
+ [2320B]
89
+ segment=ADX:::Individual Premium Adjustment:S:1
90
+
91
+ #LOOP ID - TRAILER
92
+ [SE]
93
+ segment=SE:::820 Trailer:R:1
94
+
95
+ [GE]
96
+ segment=GE:::GE:R:1
97
+
98
+ [IEA]
99
+ segment=IEA:::IEA:R:1
100
+
101
+
102
+
@@ -0,0 +1,88 @@
1
+ [LOOPS]
2
+ ISA
3
+ GS
4
+ ST-H
5
+ BCT-H
6
+ N1-H
7
+ LIN-D
8
+ CTT-S
9
+ SE-S
10
+ GE
11
+ IEA
12
+
13
+ [ISA]
14
+ segment=ISA:::ISA:R:1
15
+
16
+ [GS]
17
+ segment=GS:::GE:R:1
18
+
19
+ [ST-H]
20
+ segment=ST:1:832:Transaction set header:R:1
21
+
22
+ [BCT-H]
23
+ segment=BCT:1:PC:Beginning segment for price sales catalog:R:1
24
+
25
+ [N1-H]
26
+ segment=N1:1:VN:Name:S:1
27
+ loop=REF-H
28
+
29
+ [REF-H]
30
+ segment=REF:::Reference identification:S:1
31
+
32
+ [N1-H]
33
+ segment=N1:::Name:S:1
34
+
35
+ [LIN-D]
36
+ segment=LIN:2:VN:Item identification:S:1
37
+ loop=G53-D
38
+ loop=REF-D
39
+ loop=YNQ-D
40
+ loop=PID-D
41
+ loop=MEA-D
42
+ loop=PKG-D
43
+ loop=CTP-D
44
+ loop=SLN-D
45
+
46
+ [G53-D]
47
+ segment=G53:1:001,002,003,CEP,PRI:Maitenance type:S:1
48
+
49
+ [REF-D]
50
+ segment=REF:1:BD,MR,SU,XX,S6:Reference identification:S:1
51
+
52
+ [YNQ-D]
53
+ segment=YNQ:1:IO:Yes no question:S:1
54
+
55
+ [PID-D]
56
+ segment=PID:::Product item description:S:1
57
+
58
+ [MEA-D]
59
+ segment=MEA:1:WT,PS,SD:Measurements:S:1
60
+
61
+ [PKG-D]
62
+ segment=PKG:::Marketing packaging loading:S:1
63
+
64
+ [CTP-D]
65
+ segment=CTP:1:IN:Pricing information:S:1
66
+ loop=DTM-D
67
+
68
+ [DTM-D]
69
+ segment=DTM:1:007:Date time reference:S:1
70
+
71
+ [SLN-D]
72
+ segment=SLN:::Subline item detail:S:1
73
+ loop=MTX-D
74
+
75
+ [MTX-D]
76
+ segment=MTX:::Text:S:1
77
+
78
+ [CTT-S]
79
+ segment=CTT:::Transaction Totals:S:1
80
+
81
+ [SE-S]
82
+ segment=SE:::Transaction set trailer:S:1
83
+
84
+ [GE]
85
+ segment=GE:::GE:R:1
86
+
87
+ [IEA]
88
+ segment=IEA:::IEA:R:1
@@ -0,0 +1,86 @@
1
+ [LOOPS]
2
+ ISA
3
+ GS
4
+ ST
5
+ 1000A
6
+ 1000B
7
+ 2000
8
+ SE
9
+ GE
10
+ IEA
11
+
12
+ #--- start of loop details ---#
13
+
14
+ [ISA]
15
+ segment=ISA:::ISA:R:1
16
+
17
+ [GS]
18
+ segment=GS:::GE:R:1
19
+
20
+ [ST]
21
+ segment=ST:1:835:Transaction Set Header:R:1
22
+ segment=BPR:::Financial Information:R:1
23
+ segment=TRN:::Reassociation Trace Number:R:1
24
+ segment=CUR:::Foreign Currency Information:S:1
25
+ segment=REF:1:EV:Receiver Identification:S:1
26
+ segment=REF:1:F2:Version Identification:S:1
27
+ segment=DTM:1:405:Production Date:S:1
28
+
29
+ [1000A]
30
+ segment=N1:1:PR:Payer Identification:R:1
31
+ segment=N3:::Payer Address:R:1
32
+ segment=N4:::Payer City, State, ZIP Code:R:1
33
+ segment=REF:1:2U,EO,HI,NF:Additional Payer Identification:S:4
34
+ segment=PER:1:CX:Payer Contact Information:S:1
35
+
36
+ [1000B]
37
+ segment=N1:1:PE:Payee Identification:R:1
38
+ segment=N3:::Payee Address:S:1
39
+ segment=N4:::Payee City, State, ZIP Code:S:1
40
+ segment=REF:::Payee Additional Identification:S:>1
41
+
42
+ [2000]
43
+ segment=LX:::Header Number:S:1
44
+ segment=TS3:::Provider Summary Information:S:1
45
+ segment=TS2:::Provider Supplemental Summary Information:S:1
46
+ loop=2100
47
+
48
+ [2100]
49
+ segment=CLP:::Claim Payment Information:R:1
50
+ segment=CAS:1:PR:Claim Adjustment:S:99
51
+ segment=NM1:1:QC:Patient Name:R:1
52
+ segment=NM1:1:IL:Insured Name:S:1
53
+ segment=NM1:1:74:Corrected Patient/Insured Name:S:1
54
+ segment=NM1:1:82:Service Provider Name:S:1
55
+ segment=NM1:1:TT:Crossover Carrier Name:S:1
56
+ segment=NM1:1:PR:Corrected Priority Payer Name:S:2
57
+ segment=MIA:::Inpatient Adjudication Information:S:1
58
+ segment=MOA:::Outpatient Adjudication Information:S:1
59
+ segment=REF:::Other Claim Related Identification:S:5
60
+ segment=REF:::Rendering Provider Identification:S:10
61
+ segment=DTM:::Claim Date:S:4
62
+ segment=PER:::Claim Contact Information:S:3
63
+ segment=AMT:::Claim Supplemental Information:S:14
64
+ segment=QTY:::Claim Supplemental Information Quantity:S:15
65
+ loop=2110
66
+
67
+ [2110]
68
+ segment=SVC:::Service Payment Information:S:1
69
+ segment=DTM:::Service Date:S:3
70
+ segment=CAS:::Service Adjustment:S:99
71
+ segment=REF:::Service Identification:S:7
72
+ segment=REF:::Rendering Provider Information:S:10
73
+ segment=AMT:::Service Supplemental Amount:S:12
74
+ segment=QTY:::Service Supplemental Quantity:S:6
75
+ segment=LQ:::Health Care Remark Codes:S:99
76
+ segment=PLB:::Provider Adjustment:S:>1
77
+
78
+ [SE]
79
+ segment=SE:::Transaction Set Trailer:R:1
80
+
81
+ [GE]
82
+ segment=GE:::GE:R:1
83
+
84
+ [IEA]
85
+ segment=IEA:::IEA:R:1
86
+
@@ -0,0 +1,60 @@
1
+ [LOOPS]
2
+ ISA
3
+ GS
4
+ ST-H
5
+ BAK-H
6
+ DTM-H
7
+ N1-H
8
+ PO1-D
9
+ CTT-S
10
+ SE-S
11
+ GE
12
+ IEA
13
+
14
+ [ISA]
15
+ segment=ISA:::ISA:R:1
16
+
17
+ [GS]
18
+ segment=GS:::GE:R:1
19
+
20
+ [ST-H]
21
+ segment=ST:1:855:R:1
22
+
23
+ [BAK-H]
24
+ segment=BAK:1:00,04:R:1
25
+
26
+ [DTM-H]
27
+ segment=DTM:::Date Time Reference
28
+
29
+ [N1-H]
30
+ segment=N1:1:ST:O:1
31
+ segment=N3:::Address Information:S:1
32
+ segment=N4:::Geographic Location:S:1
33
+
34
+ [PO1-D]
35
+ segment=PO1:::Purchase Order Ack:S:1
36
+ loop=PID-D
37
+ loop=ACK-D
38
+ loop=N1-D
39
+
40
+ [PID-D]
41
+ segment=PID:::Product Item Description:S:1
42
+
43
+ [ACK-D]
44
+ segment=ACK:1:IA,IC,ID,IR:Line item ack:S:1
45
+
46
+ [N1-D]
47
+ segment=N1:1:QC:Name:S:1
48
+
49
+ [CTT-S]
50
+ segment=CTT:::Transaction Totals:S:1
51
+
52
+ [SE-S]
53
+ segment=SE:::Transaction Set Trailer:R:1
54
+
55
+ [GE]
56
+ segment=GE:::GE:R:1
57
+
58
+ [IEA]
59
+ segment=IEA:::IEA:R:1
60
+
@@ -0,0 +1,57 @@
1
+ [LOOPS]
2
+ ISA
3
+ GS
4
+ ST
5
+ AK1
6
+ AK2
7
+ AK2/AK3
8
+ AK5
9
+ AK9
10
+ SE
11
+ GE
12
+ IEA
13
+
14
+ #--- start of loop details ---#
15
+
16
+ [ISA]
17
+ segment=ISA:::ISA:R:1
18
+
19
+ [GS]
20
+ segment=GS:::GS:R:1
21
+
22
+ #LOOP ID - HEADER
23
+ [ST]
24
+ segment=ST:::Transaction Set Header:R:1
25
+
26
+ #LOOP ID - AK1
27
+ [AK1]
28
+ segment=AK1:::Functional Group Response Header:S:1
29
+
30
+ #LOOP ID - AK2 999999
31
+ [AK2]
32
+ segment=AK2:::Transaction Set Response Header:S:1
33
+ loop=AK2/AK3
34
+
35
+ #LOOP ID - AK2/AK3 999999
36
+ [AK2/AK3]
37
+ segment=AK3:::Data Segment Note:S:99
38
+ segment=AK4:::Data Element Note:S:99
39
+
40
+ #LOOP ID - AK5
41
+ [AK5]
42
+ segment=AK5:::Transaction Set Response Trailer:R:1
43
+
44
+ #LOOP ID - AK9
45
+ [AK9]
46
+ segment=AK9:::Functional Group Response Trailer:R:1
47
+
48
+ #LOOP ID - TRAILER
49
+ [SE]
50
+ segment=SE:::Transaction Set Trailer:R:1
51
+
52
+ [GE]
53
+ segment=GE:::GE:R:1
54
+
55
+ [IEA]
56
+ segment=IEA:::IEA:R:1
57
+
@@ -0,0 +1,24 @@
1
+ # This file is part of Ruby X12-Parser (x12-parser)
2
+ #
3
+ # Copyright (C) 2008 Chris Parker
4
+ # All rights reserved
5
+ #
6
+ # Based on Perl X12::Parser by
7
+ # Prasad Poruporuthan
8
+ # http://search.cpan.org/src/PRASAD/X12-0.09
9
+ #
10
+ # x12-parser is free software: you can redistribute it and/or modify
11
+ # it under the terms of the GNU Lesser General Public License as published by
12
+ # the Free Software Foundation, either version 3 of the License, or
13
+ # (at your option) any later version.
14
+ #
15
+ # x12-parser is distributed in the hope that it will be useful,
16
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ # GNU General Public License for more details.
19
+ #
20
+ # You should have received a copy of the GNU Lesser General Public License
21
+ # along with x12-parser. If not, see <http://www.gnu.org/licenses/>.
22
+
23
+ require 'x12/cf'
24
+ require 'x12/parser'
@@ -0,0 +1,203 @@
1
+ # This file is part of Ruby X12-Parser (x12-parser)
2
+ #
3
+ # Copyright (C) 2008 Chris Parker
4
+ # All rights reserved
5
+ #
6
+ # Based on Perl X12::Parser by
7
+ # Prasad Poruporuthan
8
+ # http://search.cpan.org/src/PRASAD/X12-0.09
9
+ #
10
+ # x12-parser is free software: you can redistribute it and/or modify
11
+ # it under the terms of the GNU Lesser General Public License as published by
12
+ # the Free Software Foundation, either version 3 of the License, or
13
+ # (at your option) any later version.
14
+ #
15
+ # x12-parser is distributed in the hope that it will be useful,
16
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
17
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
+ # GNU General Public License for more details.
19
+ #
20
+ # You should have received a copy of the GNU Lesser General Public License
21
+ # along with x12-parser. If not, see <http://www.gnu.org/licenses/>.
22
+
23
+
24
+ module X12
25
+
26
+ class LoopTree
27
+ attr_accessor :loop
28
+ attr_accessor :level
29
+ end
30
+
31
+ class CF
32
+
33
+ attr_accessor :loop_trees
34
+ attr_accessor :segmentstart
35
+ attr_accessor :file_contents
36
+ attr_accessor :loops
37
+ attr_accessor :level
38
+
39
+ def initialize
40
+ @loop_trees = []
41
+ @segmentstart = {}
42
+ @file_contents = []
43
+ @loops = []
44
+ end
45
+
46
+ def load(file)
47
+
48
+ load_file = nil
49
+
50
+ local_path = File.dirname(__FILE__).to_s + "/../../cf/#{file}"
51
+
52
+ if File.exist?(file)
53
+ load_file = file
54
+ end
55
+
56
+ if File.exist?(local_path)
57
+ load_file = local_path
58
+ end
59
+
60
+ return false if not load_file
61
+
62
+ File.open(load_file, 'r') { |file|
63
+ file.each do |line|
64
+ @file_contents << line.strip
65
+ end
66
+ }
67
+
68
+ self._find_loops
69
+ self._parse_loops
70
+ end
71
+
72
+ def _find_loops
73
+
74
+ in_loops = false
75
+
76
+ @file_contents.each do |line|
77
+ if line == '[LOOPS]'
78
+ in_loops = true
79
+ next
80
+ end
81
+
82
+ return if line == ''
83
+
84
+ @loops << line if in_loops == true
85
+
86
+ end
87
+ end
88
+
89
+ def _parse_loops
90
+
91
+ @loops.each { |loop|
92
+ @level = 0
93
+ _parse_loop(loop)
94
+ }
95
+ @loops.each { |loop|
96
+ _parse_segment(loop)
97
+ }
98
+ end
99
+
100
+ def _parse_loop(loop)
101
+
102
+ in_loop = false
103
+
104
+ @level += 1
105
+
106
+ @file_contents.each { |line|
107
+
108
+ if line == "[#{loop}]"
109
+
110
+ loop_tree = LoopTree.new
111
+ loop_tree.loop = loop
112
+ loop_tree.level = @level
113
+ @loop_trees << loop_tree
114
+ in_loop = true
115
+
116
+ elsif in_loop == true and line =~ /^loop=/
117
+ tmp = line.split('=')
118
+ _parse_loop(tmp[1])
119
+ @level -= 1
120
+ end
121
+
122
+ return if in_loop and line == ''
123
+ }
124
+
125
+ end
126
+
127
+ def _parse_segment(loop)
128
+
129
+ in_loop = false
130
+
131
+ @file_contents.each { |line|
132
+
133
+ if line == "[#{loop}]"
134
+ in_loop = true
135
+ end
136
+
137
+ if in_loop == true
138
+
139
+ if line =~ /^segment=/
140
+ tmp = line.split('=')
141
+ @segmentstart[loop] = [] if not @segmentstart[loop]
142
+ @segmentstart[loop] << tmp[1]
143
+ end
144
+
145
+ if line =~ /^loop=/
146
+ tmp = line.split('=')
147
+ _parse_segment(tmp[1])
148
+ end
149
+ end
150
+
151
+ return if in_loop == true and line == ''
152
+
153
+ }
154
+ end
155
+
156
+ def get_level_one
157
+
158
+ tmp = []
159
+
160
+ i = 0
161
+
162
+ @loop_trees.each do |lt|
163
+ if lt.level == 1
164
+ tmp.push(i)
165
+ end
166
+
167
+ i += 1
168
+ end
169
+ tmp
170
+
171
+ end
172
+
173
+ def get_next_level(current_pos)
174
+ current_level = @loop_trees[current_pos].level || 0
175
+
176
+ if @loop_trees[current_pos + 1]
177
+ next_level = @loop_trees[current_pos + 1].level
178
+ else
179
+ next_level = 0
180
+ end
181
+
182
+ tmp = []
183
+
184
+ if current_level < next_level
185
+ current_pos += 1
186
+
187
+ while @loop_trees[current_pos].level > current_level
188
+ if @loop_trees[current_pos].level == next_level
189
+ tmp.push(current_pos)
190
+ end
191
+ current_pos += 1
192
+ end
193
+ else
194
+ tmp.push('END')
195
+ end
196
+
197
+ tmp
198
+
199
+ end
200
+
201
+ end
202
+
203
+ end