Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Parse and print output from a HIPAA 277CA file.
require 'pp'
require 'pry'
require 'hippo'
def wrap_text(text, max_width, wrap_string = "\n")
if text.length <= max_width
text
else
text.scan(/.{1,#{max_width}}/).join(wrap_string)
end
end
category_codes = Hippo::CodeLists::ClaimStatusCategoryCodes
status_codes = Hippo::CodeLists::ClaimStatusCodes
parser = Hippo::Parser.new
transaction_sets = parser.parse_file('sample_files/082627.EDI')
transaction_sets.each do |ts|
puts ''
puts '=' * 120
puts 'Confirmation for 837 transaction on ' + ts.L2000A.L2200A.DTP.DTP03 + " with a batch control number of '#{ts.L2000B.L2200B.TRN.TRN02}'."
puts " #{ts.L2000A.L2100A.NM1.NameLastOrOrganizationName}(#{ts.L2000A.L2100A.NM1.EntityIdentifierCode}) "
if ts.L2000B.L2200B.STC.STC03 == 'U'
puts " Entire batch REJECTED!!!!"
else
puts " Accepted: #{ts.L2000B.L2200B.find_by_name('Total Accepted Quantity').QTY02.to_s.rjust(4)}(#{ts.L2000B.L2200B.find_by_name('Total Accepted Amount').AMT02.to_s.rjust(9)}) " +
"Rejected: #{ts.L2000B.L2200B.find_by_name('Total Rejected Quantity').QTY02.to_s.rjust(4)}(#{ts.L2000B.L2200B.find_by_name('Total Rejected Amount').AMT02.to_s.rjust(9)})"
end
ts.L2000C.each do |l2000c|
puts '-----------------------------------------------------------------------------------------------------------------------'
puts " Billing Provider: #{l2000c.L2100C.NM1.NM103}(#{l2000c.L2100C.NM1.NM109})"
puts " Accepted: #{l2000c.L2200C.find_by_name('Total Accepted Quantity').QTY02.to_s.rjust(4)}(#{l2000c.L2200C.find_by_name('Total Accepted Amount').AMT02.to_s.rjust(9)}) " +
"Rejected: #{l2000c.L2200C.find_by_name('Total Rejected Quantity').QTY02.to_s.rjust(4)}(#{l2000c.L2200C.find_by_name('Total Rejected Amount').AMT02.to_s.rjust(9)})"
#TODO: need to handle/print out Provider level STC if present
l2000c.L2000D.each do |l2000d|
claim_number = ''
patient_name = ''
date_of_service = ''
claim_status = ''
claim_status_text = []
services = []
patient_name = (l2000d.L2100D.NM1.NM103 + ', ' + l2000d.L2100D.NM1.NM104)[0,30].ljust(30)
l2000d.L2200D.each do |l2200d|
claim_number = l2200d.TRN.TRN02
date_of_service = l2200d.DTP.DTP03
# claim level
claim_status = l2200d.STC.any?{|stc| stc.STC03 == 'U'} ? 'REJECTED' : 'ACCEPTED'
claim_status_text = []
l2200d.STC.each do |stc|
next if stc.STC03 != 'U'
claim_status_text << "Cat: #{stc.STC01_01} Stat: #{code = stc.STC01_02} - #{wrap_text(status_codes[code][:description], 65)}"
claim_status_text << "#{stc.STC12}" if stc.STC12
end
l2200d.L2220D.each do |l2220d|
next unless l2220d.STC.STC03 != 'U'
service_status_text = []
l2220d.STC.each do |stc|
next if stc.STC03 != 'U'
service_status_text << "Cat: #{stc.STC01_01} Stat: #{code = stc.STC01_02} - #{wrap_text(status_codes[code][:description], 65)}"
service_status_text << "#{stc.STC12}" if stc.STC12
end
services << {
:date_of_service => l2220d.DTP.DTP03,
:procedure_code => l2220d.SVC.SVC01_02,
:modifier_1 => l2220d.SVC.SVC01_03,
:modifier_2 => l2220d.SVC.SVC01_04,
:service_status_text => service_status_text
}
end
puts " CLM# #{claim_number} - #{patient_name} #{claim_status}"
puts " #{claim_status_text.join("\n ")}\n" if claim_status_text.length > 0
puts "" if claim_status == 'REJECTED'
services.each do |s|
puts " SVC - REJECTED DOS: #{s[:date_of_service]} - CPT: #{s[:procedure_code]}"
puts " #{s[:service_status_text].join("\n ")}" if s[:service_status_text].length > 0
puts ""
end
end #l2000d.L2200D.each
end #l2000c.L2000D.each
end #ts.L2000C.each
end
========================================================================================================================
Confirmation for 837 transaction on 20111222 with a batch control number of 'FX2LL9TCRD'.
FIRST COAST SERVICE OPTIONS(PR)
Accepted: 92( 63834.93) Rejected: 5( 6525.01)
------------------------------------------------------------------------------------------------------------------------
Billing Provider: RANDOM CORPORATION NAME(1234567890)
Accepted: 10( 2380.05) Rejected: ( )
CLM# 3635196 - FORD, CAROL ACCEPTED
CLM# 3635197 - FORD, CAROL ACCEPTED
CLM# 3635208 - WALKIN, JAMES ACCEPTED
CLM# 3635209 - WALKIN, JAMES ACCEPTED
CLM# 3635252 - STEWART, MARTHA ACCEPTED
CLM# 3635253 - STEWART, MARTHA ACCEPTED
CLM# 3635254 - WHITE, HORSE ACCEPTED
CLM# 3635255 - WHITE, HORSE ACCEPTED
CLM# 3635306 - ZICKSON, ROGER ACCEPTED
CLM# 3635307 - ZICKSON, ROGER ACCEPTED
------------------------------------------------------------------------------------------------------------------------
Billing Provider: TERRIBLY SPECIFIC CORPORATION(0987654321)
Accepted: 3( 3068.51) Rejected: ( )
CLM# 3634956 - JACKSON, BERNADINE ACCEPTED
CLM# 3634949 - SMITH, RUBY ACCEPTED
CLM# 3634958 - RODRIGUEZ, LINDA ACCEPTED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.