I'm using Ruby library STUPIDEDI to parse some X12 Files. I am not getting beyond this error in the title. Please help me
Code
input = if RUBY_VERSION > "1.8"
File.open(Rails.root.join('spec','fixtures','22.txt'), :encoding => "ISO-8859-1")
else
File.open(Rails.root.join('spec','fixtures','22.txt'))
end
p input
config = Stupidedi::Config.hipaa
parser = Stupidedi::Parser.build(config)
parser, result = parser.read(Stupidedi::Reader.build(input))
if result.fatal?
result.explain{|reason| raise reason " at #{result.position.inspect}" }
end
x = parser.first
.flatmap{|m| m.find(:GS) }
.flatmap{|m| m.find(:ST) }
.tap do |m|
el(m.find(:N1, "PR"), 2){|e| puts "Payer: #{e}" }
el(m.find(:N1, "PE"), 2){|e| puts "Payee: #{e}" }
end
p x
input.close
File
ISA*00* *00* *ZZ*CHEESE *12*VENDOR ISA*160321*1828*U*00400*000004970*0*T*>~
GS*PS*CHEESE*2018584966*20160321*1828*4970*X*004010~
ST*830*0001~
BFR*00*Forecast ID**DL*A*20131229*20140323*20140104****MN~
REF*IA*Vendor Code~
N1*DU*CHEESE US*15*1526642~
N1*VN*Vendor Name*92*123456789~
LIN*1*UP*123456789123456*B123456789~
UIT*EA~
FST*0*D*W*20131229~
FST*0*D*W*20140105~
FST*0*D*W*20140112~
FST*0*D*W*20140119~
FST*0*D*W*20140126~
FST*0*D*W*20140202~
FST*0*D*W*20140209~
FST*0*D*W*20140216~
FST*0*D*W*20140223~
FST*0*D*W*20140302~
FST*0*D*W*20140309~
FST*0*D*W*20140316~
FST*0*D*W*20140323~
SE*21*0001~
GE*1*4970~
IEA*1*000004970~
Please help me how to solve this. I really need your help! I am new to EDI
CodePudding user response:
You can use the Inspector tool by Stedi to see all of the errors at once. I took the liberty of pasting your file into the tool and looks like there are 3 errors. If you click on the error list, you'll see the guidance on how to fix them. (full disclaimer, I work at Stedi)
CodePudding user response:
Turns out Stupidedi::Config.contrib(Stupidedi::Config.hipaa(Stupidedi::Config.default)) solved the problem. For anyone who would use , stupidedi!