stupidedi 1.2.17 → 1.2.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/bin/edi-pp +1 -1
  4. data/lib/stupidedi/config.rb +3 -0
  5. data/lib/stupidedi/contrib/004010/guides.rb +1 -0
  6. data/lib/stupidedi/contrib/004010/transaction_set_defs.rb +3 -0
  7. data/lib/stupidedi/contrib/004010/transaction_set_defs/PR855.rb +35 -0
  8. data/lib/stupidedi/contrib/004010/transaction_set_defs/SH856.rb +26 -12
  9. data/lib/stupidedi/guides/005010.rb +4 -0
  10. data/lib/stupidedi/guides/005010/X212-HR276.rb +387 -0
  11. data/lib/stupidedi/guides/005010/guide_builder.rb +2 -2
  12. data/lib/stupidedi/version.rb +1 -1
  13. data/lib/stupidedi/versions/functional_groups/004010/element_defs.rb +6 -1
  14. data/lib/stupidedi/versions/functional_groups/004010/element_types/time_val.rb +1 -0
  15. data/lib/stupidedi/versions/functional_groups/004010/segment_defs.rb +9 -0
  16. data/lib/stupidedi/versions/functional_groups/004010/segment_defs/BAK.rb +24 -0
  17. data/lib/stupidedi/versions/functional_groups/004010/segment_defs/PRF.rb +20 -0
  18. data/lib/stupidedi/versions/functional_groups/004010/segment_defs/TD4.rb +26 -0
  19. data/lib/stupidedi/versions/functional_groups/004010/segment_defs/TD5.rb +2 -2
  20. data/lib/stupidedi/versions/functional_groups/005010/element_defs.rb +6 -3
  21. data/spec/examples/integration/parsing/005010/X091A1-HP835.example +94 -0
  22. data/spec/examples/integration/parsing/005010/X212-HR276.example +152 -0
  23. data/spec/examples/integration/parsing/005010/X221-HP835.example +386 -0
  24. data/spec/examples/integration/parsing/005010/X222-HC837.example +257 -0
  25. data/spec/fixtures/PR855/1-good-v4010.txt +11 -0
  26. data/spec/fixtures/PR855/2-good-v4010.txt +17 -0
  27. data/spec/fixtures/SH856/2-good.txt +31 -0
  28. data/spec/support/matchers/navigation_matchers.rb +0 -1
  29. metadata +17 -3
  30. data/spec/examples/integration/parsing.example +0 -674
@@ -0,0 +1,11 @@
1
+ ISA*00* *01*TMMC *ZZ*208781609-SHRAA*01*207046228P *170425*0805*U*00400*000002419*0*P*{~
2
+ GS*PR*208781609*207046228P*20170425*0805*365*X*004010~
3
+ ST*855*000002015~
4
+ BAK*00*AT*1D711419*20170502****338093*20170425*CJ~
5
+ N1*SU*SHRADER CANADA*92*SHRAA~
6
+ N3*830 PROGRESS CT~
7
+ N4*OAKVILLE*ON~
8
+ PO1*0001*72*EA*47.34*UM*BP*C000900237~
9
+ SE*7*000002015~
10
+ GE*1*365~
11
+ IEA*1*000002419~
@@ -0,0 +1,17 @@
1
+ ISA*00* *00* *ZZ*SUPPLIER001 *ZZ*EED1 NYIExxx *060814*213
2
+ 5*U*00401*702351422*0*P*>.
3
+ GS*PR*SUPPLIER001*NYIExxx*20060814*2135*48*X*004010.
4
+ ST*855*0001.
5
+ BAK*00*AC*8000000418*20060814****349037459001*20060814.
6
+ N1*BY*Hatrsville Compressor Station.
7
+ N1*SE*SUPPLIER 001.
8
+ PO1*1*2*DZN*13.84**VP*420525112.
9
+ PID*F****PEN,GEL,UNIBALL,.7MM,12/PK,BLK.
10
+ SCH*2*DZN***067*20060817.
11
+ PO1*2*6*BX*0.47**VP*221051.
12
+ PID*F****STAPLE,1/4",SF1,15-25SHT,5M/BX.
13
+ SCH*6*BX***067*20060817.
14
+ CTT*2.
15
+ SE*12*0001.
16
+ GE*1*48.
17
+ IEA*1*702351422.
@@ -0,0 +1,31 @@
1
+ ISA*00* *01* *ZZ*010020001-ABCINC*01*207046228T *180620*2130*U*00400*000000089*0*T*{$
2
+ GS*SH*010020001*207046228T*20180620*2130*000000089*X*004010$
3
+ ST*856*0000001$
4
+ BSN*00*861554*20180313*2130$
5
+ DTM*011*20180620*2120$
6
+ HL*1**S*1$
7
+ MEA*PD*G*3401*LB$
8
+ MEA*PD*N*3400*LB$
9
+ TD1*7239*40$
10
+ TD5*B*2*MATL*SR***DE*TORONTO$
11
+ TD3*TL**861554$
12
+ REF*BM*861554$
13
+ N1*SU*SUPPLIER ABC INC*92*010020001-ABCINC~
14
+
15
+ N3*123 MAIN ST.~
16
+
17
+ N4*BEAUPORT*QC*G1K 8Y2*CAN~
18
+ HL*2*1*O*1$
19
+ PRF*3D812906$
20
+ REF*MH*3D812906$
21
+ N1*ST*TORONTO PDC PARTS*92*207046228T$
22
+ N3*80 TEST AVE*$
23
+ N4*SCARBOROUGH*ON*G0X3A0*CAN$
24
+ HL*3*2*I*0$
25
+ LIN*1*BP*C0355UCAD8$
26
+ SN1**40*PC$
27
+ PID*F****GREY MET. PAINT$
28
+ CTT*1$
29
+ SE*25*0000001$
30
+ GE*1*000000089$
31
+ IEA*1*000000089$
@@ -244,5 +244,4 @@ module NavigationMatchers
244
244
  end
245
245
  end
246
246
  end
247
-
248
247
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stupidedi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.17
4
+ version: 1.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyle Putnam/Isi Robayna
@@ -156,6 +156,7 @@ files:
156
156
  - lib/stupidedi/contrib/004010/transaction_set_defs/IM210.rb
157
157
  - lib/stupidedi/contrib/004010/transaction_set_defs/OW940.rb
158
158
  - lib/stupidedi/contrib/004010/transaction_set_defs/PO850.rb
159
+ - lib/stupidedi/contrib/004010/transaction_set_defs/PR855.rb
159
160
  - lib/stupidedi/contrib/004010/transaction_set_defs/PS830.rb
160
161
  - lib/stupidedi/contrib/004010/transaction_set_defs/QM214.rb
161
162
  - lib/stupidedi/contrib/004010/transaction_set_defs/RE944.rb
@@ -204,6 +205,7 @@ files:
204
205
  - lib/stupidedi/guides/004010/guide_builder.rb
205
206
  - lib/stupidedi/guides/004010/segment_reqs.rb
206
207
  - lib/stupidedi/guides/005010.rb
208
+ - lib/stupidedi/guides/005010/X212-HR276.rb
207
209
  - lib/stupidedi/guides/005010/X214-HN277.rb
208
210
  - lib/stupidedi/guides/005010/X220-BE834.rb
209
211
  - lib/stupidedi/guides/005010/X220A1-BE834.rb
@@ -704,6 +706,7 @@ files:
704
706
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/B2.rb
705
707
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/B2A.rb
706
708
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/B3.rb
709
+ - lib/stupidedi/versions/functional_groups/004010/segment_defs/BAK.rb
707
710
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/BCT.rb
708
711
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/BEG.rb
709
712
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/BFR.rb
@@ -765,6 +768,7 @@ files:
765
768
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/PLD.rb
766
769
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/PO1.rb
767
770
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/PO4.rb
771
+ - lib/stupidedi/versions/functional_groups/004010/segment_defs/PRF.rb
768
772
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/QTY.rb
769
773
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/R3.rb
770
774
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/REF.rb
@@ -778,6 +782,7 @@ files:
778
782
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/SVC.rb
779
783
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/TD1.rb
780
784
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/TD3.rb
785
+ - lib/stupidedi/versions/functional_groups/004010/segment_defs/TD4.rb
781
786
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/TD5.rb
782
787
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/TRN.rb
783
788
  - lib/stupidedi/versions/functional_groups/004010/segment_defs/TS2.rb
@@ -968,7 +973,10 @@ files:
968
973
  - lib/stupidedi/zipper/root_cursor.rb
969
974
  - spec/examples/integration/generating.example
970
975
  - spec/examples/integration/navigating.example
971
- - spec/examples/integration/parsing.example
976
+ - spec/examples/integration/parsing/005010/X091A1-HP835.example
977
+ - spec/examples/integration/parsing/005010/X212-HR276.example
978
+ - spec/examples/integration/parsing/005010/X221-HP835.example
979
+ - spec/examples/integration/parsing/005010/X222-HC837.example
972
980
  - spec/examples/ruby/array.example
973
981
  - spec/examples/ruby/blank.example
974
982
  - spec/examples/ruby/count.example
@@ -998,11 +1006,14 @@ files:
998
1006
  - spec/fixtures/PO830/1-good.txt
999
1007
  - spec/fixtures/PO850/1-good-v3010.txt
1000
1008
  - spec/fixtures/PO850/1-good-v3050.txt
1009
+ - spec/fixtures/PR855/1-good-v4010.txt
1010
+ - spec/fixtures/PR855/2-good-v4010.txt
1001
1011
  - spec/fixtures/PS830/1-good.txt
1002
1012
  - spec/fixtures/RA820/1-good.txt
1003
1013
  - spec/fixtures/SC832/1-good.txt
1004
1014
  - spec/fixtures/SC832/2-good.txt
1005
1015
  - spec/fixtures/SH856/1-good.txt
1016
+ - spec/fixtures/SH856/2-good.txt
1006
1017
  - spec/fixtures/SQ866/1-good.txt
1007
1018
  - spec/fixtures/SS862/1-good.txt
1008
1019
  - spec/fixtures/WA142/1-good.txt
@@ -1221,9 +1232,12 @@ test_files:
1221
1232
  - spec/examples/stupidedi/zipper/abstract_cursor.example
1222
1233
  - spec/examples/stupidedi/reader.example
1223
1234
  - spec/examples/stupidedi/zipper.example
1224
- - spec/examples/integration/parsing.example
1225
1235
  - spec/examples/integration/generating.example
1226
1236
  - spec/examples/integration/navigating.example
1237
+ - spec/examples/integration/parsing/005010/X212-HR276.example
1238
+ - spec/examples/integration/parsing/005010/X091A1-HP835.example
1239
+ - spec/examples/integration/parsing/005010/X221-HP835.example
1240
+ - spec/examples/integration/parsing/005010/X222-HC837.example
1227
1241
  - spec/examples/ruby/to_d.example
1228
1242
  - spec/examples/ruby/object.example
1229
1243
  - spec/examples/ruby/blank.example
@@ -1,674 +0,0 @@
1
- require "spec_helper"
2
- using Stupidedi::Refinements
3
-
4
- describe "Parsing" do
5
- include NavigationMatchers
6
-
7
- context "X222-HC837" do
8
- let(:parser) { Fixtures.file("X222-HC837/1-good.txt") }
9
-
10
- it "parses 1-good.txt" do
11
- expect(parser).to be_deterministic
12
- expect(parser).to be_last
13
-
14
- parser.segment.tap do |iea|
15
- expect(iea.node.position.line).to eq(53)
16
- expect(iea.node.position.column).to eq(1)
17
- end
18
-
19
- expect(parser).to have_sequence(%w(ISA GS ST BHT NM1 PER NM1 HL PRV NM1 N3 N4
20
- REF NM1 N3 N4 HL SBR NM1 N3 N4 DMG NM1 N4 REF HL PAT NM1 N3 N4 DMG CLM
21
- REF HI LX SV1 DTP LX SV1 DTP LX SV1 DTP LX SV1 DTP SE GE IEA))
22
-
23
- expect(parser).to have_separators(:element => "*", :component => ":",
24
- :repetition => "^", :segment => "~")
25
-
26
- parser.parent.tap do |isa|
27
- # Should have 49 total segments in the parse tree
28
- expect(isa).to have_distance(48).to(parser)
29
-
30
- # See matchers/navigation_matchers.rb
31
- #
32
- # Ss: list of segment matchers
33
- # C: composite element
34
- #
35
- # S: the segment might be reachable, and /is/ reachable
36
- # R: the segment might be reachable, but didn't occur
37
- # X: the segment would never be reachable
38
- #
39
- expect(isa).to have_structure(
40
- Ss(X(:ST),
41
- R(:ISA), # No more ISAs
42
- S(:GS, "HC", nil, nil, nil, nil, 1) =>
43
- Ss(R(:GS), # No more GSs
44
- S(:ST) =>
45
- Ss(R(:ST), # No more STs
46
- X(:PRV),
47
- X(:NM1, "85"),
48
- X(:NM1, "87"),
49
- X(:SBR),
50
- X(:NM1, "IL"),
51
- X(:NM1, "PR"),
52
- S(:BHT) =>
53
- Ss(S(:NM1, "41"),
54
- S(:NM1, "40"),
55
- S(:HL, "1"),
56
- S(:HL, "2"),
57
- S(:HL, "3"),
58
- S(:SE),
59
- S(:GE),
60
- S(:IEA)),
61
- # 1000A SUBMITTER NAME
62
- S(:NM1, "41") =>
63
- Ss(S(:PER),
64
- S(:NM1, "40"),
65
- S(:HL, "1"),
66
- S(:HL, "2"),
67
- S(:HL, "3"),
68
- S(:SE),
69
- S(:GE),
70
- S(:IEA)),
71
- # 1000B RECEIVER NAME
72
- S(:NM1, "40") =>
73
- Ss(S(:HL, "1"),
74
- S(:HL, "2"),
75
- S(:HL, "3"),
76
- S(:SE),
77
- S(:GE),
78
- S(:IEA)),
79
- # 2000A BILLING PROVIDER HIERARCHICAL LEVEL
80
- S(:HL, "1") =>
81
- Ss(S(:PRV) =>
82
- Ss(S(:NM1, "85"),
83
- S(:NM1, "87"),
84
- S(:HL, "2"),
85
- S(:HL, "3"),
86
- S(:SE),
87
- S(:GE),
88
- S(:IEA)),
89
- # 2010AA BILLING PROVIDER NAME
90
- S(:NM1, "85") =>
91
- Ss(S(:NM1, "87") => Ss(),
92
- S(:N3) => Ss(S(:N4),
93
- S(:REF, "EI"),
94
- S(:NM1, "87")),
95
- S(:N4) => Ss(S(:REF, "EI"),
96
- S(:NM1, "87")),
97
- S(:REF, "EI") => Ss(S(:NM1, "87")),
98
- S(:SE) => Ss(),
99
- S(:GE) => Ss(),
100
- S(:IEA) => Ss()),
101
- # 2010AB PAY-TO ADDRESS NAME
102
- S(:NM1, "87") =>
103
- Ss(S(:N3) => Ss(S(:N4),
104
- S(:HL, "2")),
105
- S(:N4) => Ss(S(:HL, "2")),
106
- S(:SE) => Ss(),
107
- S(:GE) => Ss(),
108
- S(:IEA) => Ss()),
109
- S(:HL, "2") => Ss(),
110
- S(:HL, "3") => Ss(),
111
- S(:SE) => Ss(),
112
- S(:GE) => Ss(),
113
- S(:IEA) => Ss()),
114
- # 2000B SUBSCRIBER HIERARCHICAL LEVEL
115
- S(:HL, "2") =>
116
- Ss(S(:SBR) =>
117
- Ss(S(:NM1, "IL"),
118
- S(:NM1, "PR"),
119
- S(:HL, "3"),
120
- S(:SE),
121
- S(:GE),
122
- S(:IEA)),
123
- # 2010BA SUBSCRIBER NAME
124
- S(:NM1, "IL") =>
125
- Ss(S(:N3) => Ss(S(:N4),
126
- S(:DMG),
127
- S(:NM1, "PR"),
128
- S(:HL, "3")),
129
- S(:N4) => Ss(S(:DMG),
130
- S(:NM1, "PR"),
131
- S(:HL, "3")),
132
- S(:DMG) => Ss(S(:NM1, "PR"),
133
- S(:HL, "3")),
134
- S(:SE) => Ss(),
135
- S(:GE) => Ss(),
136
- S(:IEA) => Ss()),
137
- # 2010BB PAYER NAME
138
- S(:NM1, "PR") =>
139
- Ss(S(:N4) => Ss(S(:REF, "G2"),
140
- S(:HL, "3")),
141
- S(:REF, "G2") => Ss(S(:HL, "3")),
142
- S(:SE) => Ss(),
143
- S(:GE) => Ss(),
144
- S(:IEA) => Ss()),
145
- S(:HL, "3") => Ss(),
146
- S(:SE) => Ss(),
147
- S(:GE) => Ss(),
148
- S(:IEA) => Ss()),
149
- # 2000C PATIENT HIERARCHICAL LEVEL
150
- S(:HL, "3") =>
151
- Ss(S(:PAT) => Ss(S(:NM1, "QC"),
152
- S(:CLM),
153
- S(:SE),
154
- S(:GE),
155
- S(:IEA)),
156
- # 2010CA PATIENT NAME
157
- S(:NM1, "QC") =>
158
- Ss(S(:N3) => Ss(S(:N4),
159
- S(:DMG),
160
- S(:CLM)),
161
- S(:N4) => Ss(S(:DMG),
162
- S(:CLM)),
163
- S(:DMG) => Ss(S(:CLM)),
164
- S(:CLM) => Ss(),
165
- S(:SE) => Ss(),
166
- S(:GE) => Ss(),
167
- S(:IEA) => Ss()),
168
- # 2300 CLAIM INFORMATION
169
- S(:CLM) =>
170
- Ss(R(:CLM), # No more CLMs
171
- S(:REF, "D9"),
172
- S(:HI, C("BK", "0340"), C("BF", "V7389")),
173
- # 2400 SERVICE LINE NUMBER
174
- S(:LX, "1") =>
175
- Ss(R(:LX, "1"), # No more LX*1's
176
- S(:LX, "2"),
177
- S(:LX, "3"),
178
- S(:LX, "4"),
179
- S(:SV1, C(nil, "99213")) => Ss(S(:DTP, "472"),
180
- S(:LX, "2"),
181
- S(:LX, "3"),
182
- S(:LX, "4"),
183
- S(:SE),
184
- S(:GE),
185
- S(:IEA)),
186
- S(:DTP, "472") => Ss(S(:LX, "2"),
187
- S(:LX, "3"),
188
- S(:LX, "4"),
189
- S(:SE),
190
- S(:GE),
191
- S(:IEA))),
192
- # 2400 SERVICE LINE NUMBER
193
- S(:LX, "2") =>
194
- Ss(R(:LX, "1"),
195
- R(:LX, "2"), # No more LX*2's
196
- S(:LX, "3"),
197
- S(:LX, "4"),
198
- S(:SV1, C(nil, "87070")) => Ss(S(:DTP, "472"),
199
- S(:LX, "3"),
200
- S(:LX, "4"),
201
- S(:SE),
202
- S(:GE),
203
- S(:IEA)),
204
- S(:DTP, "472") => Ss(S(:LX, "3"),
205
- S(:LX, "4"),
206
- S(:SE),
207
- S(:GE),
208
- S(:IEA))),
209
- # 2400 SERVICE LINE NUMBER
210
- S(:LX, "3") =>
211
- Ss(R(:LX, "1"), # No more LX*1's
212
- R(:LX, "2"), # No more LX*2's
213
- R(:LX, "3"), # No more LX*3's
214
- S(:LX, "4"),
215
- S(:SV1, C(nil, "99214")) => Ss(S(:DTP, "472"),
216
- S(:LX, "4"),
217
- S(:SE),
218
- S(:GE),
219
- S(:IEA)),
220
- S(:DTP, "472") => Ss(S(:LX, "4"),
221
- S(:SE),
222
- S(:GE),
223
- S(:IEA))),
224
- # 2400 SERVICE LINE NUMBER
225
- S(:LX, "4") =>
226
- Ss(R(:LX, "1"),
227
- R(:LX, "2"),
228
- R(:LX, "3"),
229
- R(:LX, "4"),
230
- S(:SV1, C(nil, "86663")) => Ss(S(:DTP, "472"),
231
- S(:SE),
232
- S(:GE),
233
- S(:IEA)),
234
- S(:DTP, "472") => Ss(S(:SE),
235
- S(:GE),
236
- S(:IEA))))),
237
- S(:SE) => Ss(S(:GE),
238
- S(:IEA))),
239
- S(:GE) => Ss(S(:IEA)),
240
- S(:IEA) => Ss())))
241
- end
242
- end
243
- end
244
-
245
- context "X221-HP835" do
246
-
247
- it "parses 1-good.txt" do
248
- parser = Fixtures.file("X221-HP835/1-good.txt")
249
- expect(parser).to be_deterministic
250
- expect(parser).to be_last
251
-
252
- parser.segment.tap do |iea|
253
- expect(iea.node.position.line).to eq(40)
254
- expect(iea.node.position.column).to eq(1)
255
- end
256
-
257
- expect(parser).to have_sequence(%w(ISA GS ST BPR TRN DTM N1 N3 N4 REF REF
258
- N1 REF LX TS3 TS2 CLP CAS NM1 MIA DTM DTM AMT QTY LX TS3 CLP CAS
259
- NM1 MOA DTM AMT PLB SE GE IEA))
260
-
261
- expect(parser).to have_separators(:element => "+", :component => ">",
262
- :repetition => "~", :segment => "\r")
263
-
264
- parser.parent.tap do |isa|
265
- expect(isa).to have_distance(35).to(parser)
266
-
267
- # See matchers/navigation_matchers.rb
268
- #
269
- # Ss: list of segment matchers
270
- # C: composite element
271
- #
272
- # S: the segment might be reachable, and /is/ reachable
273
- # R: the segment might be reachable, but didn't occur
274
- # X: the segment would never be reachable
275
- #
276
- expect(isa).to have_structure(
277
- Ss(X(:ST),
278
- R(:ISA), # No more ISAs
279
- S(:GS, "HP", nil, nil, "19991231", nil, 1) =>
280
- Ss(R(:GS), # No more GSs
281
- S(:ST) =>
282
- Ss(R(:ST), # No more STs
283
- S(:BPR, nil, 150000) =>
284
- Ss(S(:TRN),
285
- S(:DTM),
286
- S(:N1, "PR"),
287
- S(:N1, "PE"),
288
- S(:LX, "110212"),
289
- S(:LX, "130212"),
290
- S(:PLB),
291
- S(:SE),
292
- S(:GE),
293
- S(:IEA)),
294
- S(:TRN, "1", "12345") =>
295
- Ss(X(:BPR)),
296
-
297
- S(:DTM, "405", Date.civil(2002, 9, 13)) =>
298
- Ss(X(:TRN)),
299
-
300
- # 1000A PAYER IDENTIFICATION
301
- S(:N1, "PR", "INSURANCE COMPANY OF TIMBUCKTU") =>
302
- Ss(S(:N3, "1 MAIN STREET"),
303
- S(:N4),
304
- S(:REF, "2U", "999"),
305
- S(:REF, "NF", "12345"),
306
- S(:SE),
307
- S(:GE),
308
- S(:IEA)),
309
-
310
- # 1000B PAYEE IDENTIFICATION
311
- S(:N1, "PE", nil, "XX", "1232343560") =>
312
- Ss(S(:REF, "TJ"),
313
- S(:SE),
314
- S(:GE),
315
- S(:IEA)),
316
-
317
- # 2000 HEADER NUMBER
318
- S(:LX, "110212") =>
319
- Ss(S(:LX, "130212"),
320
- S(:TS3),
321
- S(:TS2),
322
- S(:CLP) =>
323
- Ss(S(:CAS, "CO", 45, "73348.57"),
324
- S(:NM1, "QC", nil, "JONES"),
325
- S(:MIA, 0, nil, nil, "138018.4".to_d),
326
- S(:DTM, "232", "20020816"),
327
- S(:DTM, "233", "20020824"),
328
- S(:AMT, "AU", 150000),
329
- S(:QTY, "CA", 8))),
330
-
331
- # 2000 HEADER NUMBER
332
- S(:LX, "130212") =>
333
- Ss(R(:LX, "110212"),
334
- S(:TS3, "6543210909", "13", "1996/12/31", 1, 15000),
335
- S(:CLP, "777777") =>
336
- Ss(S(:CAS, "CO", "45", "3019.67"),
337
- S(:NM1, "QC"),
338
- S(:MOA, nil, nil, "MA02"),
339
- S(:DTM, "232", "2002-05-12"),
340
- S(:AMT, "AU", 17000))),
341
-
342
- S(:PLB, "6543210903") =>
343
- Ss(S(:SE, 32, 1234),
344
- S(:GE, 1, 1),
345
- S(:IEA, 1, 905)),
346
- S(:PLB, nil, "20021231") =>
347
- Ss(S(:SE, "32", "1234"),
348
- S(:GE, "1", "1"),
349
- S(:IEA, "1", "905")),
350
- S(:PLB, nil, nil, C("CV", "CP")) => Ss(),
351
- S(:PLB, nil, nil, nil, "-1.27") => Ss(),
352
-
353
- S(:SE) => Ss(S(:GE),
354
- S(:IEA))),
355
- S(:GE) => Ss(S(:IEA)),
356
- S(:IEA) => Ss())))
357
- end
358
- end
359
-
360
- context "issues with Table 3 (Summary)" do
361
- it "handles missing PLB" do
362
- parser = Fixtures.file("X221-HP835/2-good.txt")
363
- expect(parser).to be_deterministic
364
-
365
- parser.parent.tap do |isa|
366
- expect(isa).to have_structure(
367
- Ss(X(:SE),
368
- X(:PLB),
369
- S(:GS, "HP", nil, nil, "19991231", nil, 1) =>
370
- Ss(X(:SE),
371
- X(:PLB),
372
- S(:ST) =>
373
- Ss(R(:PLB),
374
- S(:LX) =>
375
- Ss(S(:SE),
376
- R(:PLB)),
377
- S(:SE) =>
378
- Ss(X(:PLB),
379
- X(:SE))))))
380
- end
381
- end
382
-
383
- it "handles single PLB" do
384
- parser = Fixtures.file("X221-HP835/1-good.txt")
385
- expect(parser).to be_deterministic
386
-
387
- parser.parent.tap do |isa|
388
- expect(isa).to have_structure(
389
- Ss(X(:SE),
390
- X(:PLB),
391
- S(:GS, "HP", nil, nil, "19991231", nil, 1) =>
392
- Ss(X(:SE),
393
- X(:PLB),
394
- S(:ST) =>
395
- Ss(S(:LX) =>
396
- Ss(S(:SE),
397
- S(:PLB)),
398
- S(:SE) =>
399
- Ss(X(:PLB),
400
- X(:SE)),
401
- S(:PLB) =>
402
- Ss(R(:PLB), # only one PLB
403
- S(:SE))))))
404
- end
405
- end
406
-
407
- it "handles multiple PLBs" do
408
- parser = Fixtures.file("X221-HP835/3a-good.txt")
409
- expect(parser).to be_deterministic
410
-
411
- parser.parent.tap do |isa|
412
- expect(isa).to have_structure(
413
- Ss(X(:SE),
414
- X(:PLB),
415
- S(:GS, "HP", nil, nil, "19991231", nil, 1) =>
416
- Ss(X(:SE),
417
- X(:PLB),
418
- S(:ST) =>
419
- Ss(S(:LX) =>
420
- Ss(S(:SE),
421
- S(:PLB),
422
- S(:PLB, "9876543210"),
423
- S(:PLB, "0123456789")),
424
- S(:SE) =>
425
- Ss(X(:PLB),
426
- X(:SE)),
427
- S(:PLB) =>
428
- Ss(S(:PLB),
429
- S(:PLB, "0123456789"),
430
- R(:PLB, "9876543210"),
431
- S(:SE)),
432
- S(:PLB, "0123456789") =>
433
- Ss(R(:PLB, "0123456789"),
434
- R(:PLB, "9876543210"),
435
- S(:SE)),
436
- S(:PLB, "9876543210") =>
437
- Ss(R(:PLB, "9876543210"),
438
- S(:PLB, "0123456789"),
439
- S(:SE))))))
440
- end
441
- end
442
- end
443
-
444
- context "table-level permutations" do
445
- # 837
446
- # Table 2A
447
- # 2000A HL*..*..*20
448
- # Table 2B
449
- # 2000B HL*..*..*22
450
- # Table 2C
451
- # 2000C HL*..*..*23
452
- let(:dsl) do
453
- c = Stupidedi::Config.hipaa
454
- b = Stupidedi::Builder::BuilderDsl.build(c, false)
455
- b.ISA("00", nil, "01", "SECRET", "ZZ", "SUBMITTER", "ZZ", "RECEIVER", Time.now.utc, Time.now.utc, nil, "00501", 123456789, "1", "T", nil)
456
- b. GS("HP", "SENDER", "RECEIVER", Time.now.utc, Time.now.utc, 1, "X", "005010X222")
457
- b. ST("837", "0001", b.default)
458
- b.BHT("0019", "00", "46X2A6", Time.now.utc, Time.now.utc, "CH")
459
- b.NM1("41", "2", "TERRIBLE BILLING", nil, nil, nil, nil, "46", "X82BJJ")
460
- b.PER("IC", nil, "TE", "5551212")
461
- b.NM1("40", "2", "TERRIBLE INSURAN", nil, nil, nil, nil, "46", "3057XK")
462
-
463
- b # return BuilderDsl instance
464
- end
465
-
466
- specify "HL*..*..20, HL*..*..*22, HL*..*..*23" do
467
- ss = [["1", nil, "20", "1"],
468
- ["2", nil, "20", "1"],
469
- ["3", "1", "22", "1"],
470
- ["4", "2", "22", "1"],
471
- ["5", "3", "23", "0"],
472
- ["6", "4", "23", "0"]]
473
-
474
- ss.permutation do |p|
475
- b = dsl.dup
476
- p.each{|es| b.send(:HL, *es) }
477
-
478
- m = b.machine.first.flatmap{|x| x.sequence(:GS, :ST) }
479
-
480
- expect(m.map{|x| x.count(:HL, nil, nil, "20") }).to be_success(2)
481
- expect(m.map{|x| x.count(:HL, nil, nil, "22") }).to be_success(2)
482
- expect(m.map{|x| x.count(:HL, nil, nil, "23") }).to be_success(2)
483
-
484
- expect(m.map{|x| x.count(:HL) }).to be_success(6)
485
-
486
- expect(m.flatmap{|x| x.sequence(:HL) }.
487
- map{|x| x.count(:HL) }).to be_success(5)
488
-
489
- expect(m.flatmap{|x| x.sequence(:HL, :HL) }.
490
- map{|x| x.count(:HL) }).to be_success(4)
491
-
492
- expect(m.flatmap{|x| x.sequence(:HL, :HL, :HL) }.
493
- map{|x| x.count(:HL) }).to be_success(3)
494
-
495
- expect(m.flatmap{|x| x.sequence(:HL, :HL, :HL, :HL) }.
496
- map{|x| x.count(:HL) }).to be_success(2)
497
-
498
- expect(m.flatmap{|x| x.sequence(:HL, :HL, :HL, :HL, :HL) }.
499
- map{|x| x.count(:HL) }).to be_success(1)
500
-
501
- expect(m.flatmap{|x| x.sequence(:HL, :HL, :HL, :HL, :HL, :HL) }.
502
- map{|x| x.count(:HL) }).to be_success(0)
503
- end if ss.respond_to?(:permutation)
504
- end
505
- end
506
-
507
- context "loop-level permutations" do
508
- # 837
509
- # Table 1
510
- # 1000A NM1*41
511
- # 1000B NM1*40
512
- let(:dsl) do
513
- c = Stupidedi::Config.hipaa
514
- b = Stupidedi::Builder::BuilderDsl.build(c, false)
515
- b.ISA("00", nil, "01", "SECRET", "ZZ", "SUBMITTER", "ZZ", "RECEIVER", Time.now.utc, Time.now.utc, nil, "00501", 123456789, "1", "T", nil)
516
- b. GS("HP", "SENDER", "RECEIVER", Time.now.utc, Time.now.utc, 1, "X", "005010X222")
517
- b. ST("837", "0001", b.default)
518
- b.BHT("0019", "00", "46X2A6", Time.now.utc, Time.now.utc, "CH")
519
-
520
- b # return BuilderDsl instance
521
- end
522
-
523
- specify "NM1*41, NM1*40" do
524
- ss = [["41", "2", "TERRIBLE BILLING", nil, nil, nil, nil, "46", "X82BJJ"],
525
- ["40", "2", "TERRIBLE INSURAN", nil, nil, nil, nil, "46", "3057XK"]]
526
-
527
- ss.permutation do |p|
528
- b = dsl.dup
529
- p.each{|es| b.send(:NM1, *es) }
530
-
531
- m = b.machine.parent
532
- expect(m.map{|x| x.count(:NM1) }).to be_success(2)
533
-
534
- expect(m.flatmap{|x| x.sequence(:NM1) }.
535
- map{|x| x.count(:NM1) }).to be_success(1)
536
-
537
- expect(m.flatmap{|x| x.sequence(:NM1, :NM1) }.
538
- map{|x| x.count(:NM1) }).to be_success(0)
539
- end if ss.respond_to?(:permutation)
540
- end
541
- end
542
-
543
- context "segment-level permutations" do
544
- # 835
545
- # Table 1
546
- # 1000A N1*PR
547
- # PER*CX
548
- # PER*BL
549
- # PER*IC
550
-
551
- let(:dsl) do
552
- c = Stupidedi::Config.hipaa
553
- b = Stupidedi::Builder::BuilderDsl.build(c)
554
- b.ISA("00", nil, "01", "SECRET", "ZZ", "SUBMITTER", "ZZ", "RECEIVER", Time.now.utc, Time.now.utc, nil, "00501", 123456789, "1", "T", nil)
555
- b. GS("HP", "SENDER", "RECEIVER", Time.now.utc, Time.now.utc, 1, "X", "005010X221")
556
- b. ST("835", "0001")
557
- b.BPR("C", 150000, "C", "ACH", "CTX", "01", "999999992", "DA", "123456", "1512345678", nil, "01", "999988880", "DA", "98765", "20020913")
558
- b.TRN("1", "12345", "1512345678")
559
- b.DTM("405", Time.now.utc)
560
- b. N1("PR", "INSURANCE COMPANY OF TIMBUCKTU")
561
- b. N3("1 MAIN STREET")
562
- b. N4("TIMBUCKTU", "AK", "99501")
563
- b.REF("2U", "999")
564
- b.REF("NF", "12345")
565
-
566
- b # return BuilderDsl instance
567
- end
568
-
569
- specify "PER*IC, PER*BL, PER*CX" do
570
- ss = [["IC", nil, "UR", "WEBSITE.COM"],
571
- ["BL", "COMPUTER PAT"],
572
- ["BL", "COMPUTER SAM"],
573
- ["CX", "BUSINESS KIM"]]
574
-
575
- ss.permutation do |p|
576
- b = dsl.dup
577
- p.each{|es| b.send(:PER, *es) }
578
-
579
- m = b.machine.parent
580
- expect(m.map{|x| x.count(:PER) }).to be_success(4)
581
-
582
- expect(m.flatmap{|x| x.sequence(:PER) }.
583
- map{|x| x.count(:PER) }).to be_success(3)
584
-
585
- expect(m.flatmap{|x| x.sequence(:PER, :PER) }.
586
- map{|x| x.count(:PER) }).to be_success(2)
587
-
588
- expect(m.flatmap{|x| x.sequence(:PER, :PER, :PER) }.
589
- map{|x| x.count(:PER) }).to be_success(1)
590
-
591
- expect(m.flatmap{|x| x.sequence(:PER, :PER, :PER, :PER) }.
592
- map{|x| x.count(:PER) }).to be_success(0)
593
- end if ss.respond_to?(:permutation)
594
- end
595
- end
596
-
597
- end
598
-
599
- context "X091A1-HP835" do
600
-
601
- it "parses 1-good.txt" do
602
- parser = Fixtures.file("X091A1-HP835/1-good.txt")
603
- expect(parser).to be_deterministic
604
- expect(parser).to be_last
605
-
606
- parser.segment.tap do |iea|
607
- expect(iea.node.position.line).to eq(1)
608
- expect(iea.node.position.column).to eq(606)
609
- end
610
-
611
- expect(parser).to have_sequence(%w(ISA GS ST BPR TRN REF N1 N3 N4 REF PER N1
612
- REF LX CLP CAS NM1 PLB SE GE IEA))
613
-
614
- expect(parser).to have_separators(:element => "|", :component => "^",
615
- :repetition => nil, :segment => "~")
616
-
617
- parser.parent.tap do |isa|
618
- expect(isa).to have_distance(20).to(parser)
619
- expect(isa).to have_structure(
620
- Ss(X(:ST),
621
- R(:ISA), # No more ISAs
622
- S(:GS, "HP", "MADE UP CLEARING HOUSE", "611358935", "20130508", nil, "3063") =>
623
- Ss(R(:GS), # No more GSs
624
- S(:ST) =>
625
- Ss(R(:ST), # No more STs
626
- S(:BPR, nil, nil) =>
627
- Ss(S(:TRN),
628
- S(:N1, "PR"),
629
- S(:N1, "PE"),
630
- S(:LX, "1"),
631
- S(:PLB),
632
- S(:SE),
633
- S(:GE),
634
- S(:IEA)),
635
- S(:TRN, "1", "74122910359") =>
636
- Ss(X(:BPR)),
637
-
638
- # 1000A PAYER IDENTIFICATION
639
- S(:N1, "PR", "MADE UP HEALTH CENTER") =>
640
- Ss(S(:N3, "123 FAKE ST."),
641
- S(:N4),
642
- S(:REF, "2U", "80214"),
643
- S(:SE),
644
- S(:GE),
645
- S(:IEA)),
646
-
647
- # 1000B PAYEE IDENTIFICATION
648
- S(:N1, "PE", nil, "XX", "1386672277") =>
649
- Ss(S(:REF, "TJ"),
650
- S(:SE),
651
- S(:GE),
652
- S(:IEA)),
653
-
654
- # 2000 HEADER NUMBER
655
- S(:LX, "1") =>
656
- Ss(
657
- S(:CLP) =>
658
- Ss(S(:CAS, "PI", 23, "157.39"),
659
- S(:NM1, "QC", nil, "DOE"))),
660
-
661
- S(:PLB, "341491692") =>
662
- Ss(S(:SE, 17, '0001'),
663
- S(:GE, 1, 3063),
664
- S(:IEA, 1, 3063)),
665
-
666
- S(:SE) => Ss(S(:GE),
667
- S(:IEA))),
668
- S(:GE) => Ss(S(:IEA)),
669
- S(:IEA) => Ss())))
670
- end
671
- end
672
- end
673
-
674
- end