era_835_parser 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/era_835_parser/parser.rb +51 -8
- data/lib/era_835_parser/version.rb +1 -1
- data/spec/era_835_parser_spec.rb +1 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea38eaeef52c3f1cde616b4691ec56b7cf8ee4162c28616da3719e6d22e66784
|
4
|
+
data.tar.gz: 40cfc3e0d4450234d550b0c46b15fffb8f3e30813bcd751b75af2349584929cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14b8691233df6d0ca59b76fca3e773357654870b1db678451c481d6d4dba0cd4b503c614419441d8ffb06e2049f50d9bc9b40aa40e54c05defaf117950e5f4a1
|
7
|
+
data.tar.gz: ef3eb716b7c846a79e07daf88552dfa069ebcbecdb99e20cd91c33ac00f4a16a66efc6da594108e514df1e97df9be785b9d6cf2647671c9710761dc1570f4b7c
|
@@ -60,6 +60,7 @@ module Era835Parser
|
|
60
60
|
claim_date_start = false
|
61
61
|
claim_date_end = false
|
62
62
|
service_date = false
|
63
|
+
floating_adjustment_group_code = nil
|
63
64
|
|
64
65
|
open(file_path).readlines.each do |line|
|
65
66
|
if line.include?("ISA")
|
@@ -131,8 +132,14 @@ module Era835Parser
|
|
131
132
|
individual_line_item[:total_adjustment_amount] = (/\d+\/\d+\/\d+\s\d+\s+\-?\d+\.\d+\s+\-?\d+\.\d+\s+\-?\d+\.\d+/.match(line)[0].strip.split(" ")[4].to_f * 100).round().to_i if !/\d+\/\d+\/\d+\s\d+\s+\-?\d+\.\d+\s+\-?\d+\.\d+\s+\-?\d+\.\d+/.match(line).nil?
|
132
133
|
individual_line_item[:remarks] = line.gsub(/\d+\/\d+\/\d+\s\d+\s+\-?\d+\.\d+\s+\-?\d+\.\d+\s+\-?\d+\.\d+/, "").strip if !/\d+\/\d+\/\d+\s\d+\s+\-?\d+\.\d+\s+\-?\d+\.\d+\s+\-?\d+\.\d+/.match(line).nil?
|
133
134
|
if line_items.nil?
|
135
|
+
if individual_line_item[:service_date].nil?
|
136
|
+
individual_line_item[:service_date] = individual_era[:claim_statement_period_start]
|
137
|
+
end
|
134
138
|
line_items[0] = individual_line_item
|
135
139
|
else
|
140
|
+
if individual_line_item[:service_date].nil?
|
141
|
+
individual_line_item[:service_date] = individual_era[:claim_statement_period_start]
|
142
|
+
end
|
136
143
|
line_items[line_items.count] = individual_line_item
|
137
144
|
end
|
138
145
|
next_line_line_item = false
|
@@ -502,6 +509,8 @@ module Era835Parser
|
|
502
509
|
# puts "Date Time Qualifier: #{element}"
|
503
510
|
if element == "050"
|
504
511
|
receive_date = true
|
512
|
+
elsif element == "150"
|
513
|
+
service_date = true
|
505
514
|
elsif element == "232"
|
506
515
|
claim_date_start = true
|
507
516
|
elsif element == "233"
|
@@ -596,8 +605,14 @@ module Era835Parser
|
|
596
605
|
when 1
|
597
606
|
if individual_line_item != {}
|
598
607
|
if line_items.nil?
|
608
|
+
if individual_line_item[:service_date].nil?
|
609
|
+
individual_line_item[:service_date] = individual_era[:claim_statement_period_start]
|
610
|
+
end
|
599
611
|
line_items[0] = individual_line_item
|
600
612
|
else
|
613
|
+
if individual_line_item[:service_date].nil?
|
614
|
+
individual_line_item[:service_date] = individual_era[:claim_statement_period_start]
|
615
|
+
end
|
601
616
|
line_items[line_items.count] = individual_line_item
|
602
617
|
end
|
603
618
|
individual_era[:line_items] = line_items
|
@@ -787,16 +802,23 @@ module Era835Parser
|
|
787
802
|
individual_adjustment_group_item = Hash.new
|
788
803
|
individual_adjustment_group_item[:adjustment_group_code] = element.strip
|
789
804
|
individual_adjustment_group_item[:adjustment_group] = ADJUSTMENT_GROUP_CODES[element.strip]
|
790
|
-
|
805
|
+
floating_adjustment_group_code = element.strip
|
806
|
+
when 2,5,8,11,14,17
|
791
807
|
# Adjustment Reason Code
|
808
|
+
if index > 2
|
809
|
+
individual_adjustment_group_item = Hash.new
|
810
|
+
individual_adjustment_group_item[:adjustment_group_code] = floating_adjustment_group_code
|
811
|
+
individual_adjustment_group_item[:adjustment_group] = ADJUSTMENT_GROUP_CODES[floating_adjustment_group_code]
|
812
|
+
end
|
792
813
|
# puts "Adjustment Reason Code: #{element}"
|
793
814
|
individual_adjustment_group_item[:reason_code] = element.strip
|
794
815
|
individual_adjustment_group_item[:translated_reason_code] = ADJUSTMENT_CODES[element.strip]
|
795
|
-
when 3
|
816
|
+
when 3,6,9,12,15,18
|
796
817
|
# Adjustment Amount
|
797
818
|
# puts "Adjustment Amount: #{element}"
|
798
819
|
#
|
799
820
|
individual_adjustment_group_item[:adjustment_amount] = (element.to_f * 100).round().to_i
|
821
|
+
# puts individual_adjustment_group_item
|
800
822
|
if adjustment_groups.nil?
|
801
823
|
adjustment_groups[0] = individual_adjustment_group_item
|
802
824
|
else
|
@@ -808,7 +830,7 @@ module Era835Parser
|
|
808
830
|
adjustment_amount_tally += v[:adjustment_amount]
|
809
831
|
end
|
810
832
|
individual_line_item[:total_adjustment_amount] = adjustment_amount_tally
|
811
|
-
when 4
|
833
|
+
when 4,7,10,13,16,19
|
812
834
|
# QUANTITY
|
813
835
|
# puts "QUANTITY: #{element}"
|
814
836
|
end
|
@@ -884,8 +906,14 @@ module Era835Parser
|
|
884
906
|
svc_counter += 1
|
885
907
|
if individual_line_item != {} && svc_counter > 1
|
886
908
|
if line_items.nil?
|
909
|
+
if individual_line_item[:service_date].nil?
|
910
|
+
individual_line_item[:service_date] = individual_era[:claim_statement_period_start]
|
911
|
+
end
|
887
912
|
line_items[0] = individual_line_item
|
888
913
|
else
|
914
|
+
if individual_line_item[:service_date].nil?
|
915
|
+
individual_line_item[:service_date] = individual_era[:claim_statement_period_start]
|
916
|
+
end
|
889
917
|
line_items[line_items.count] = individual_line_item
|
890
918
|
end
|
891
919
|
individual_era[:line_items] = line_items
|
@@ -959,8 +987,14 @@ module Era835Parser
|
|
959
987
|
else
|
960
988
|
if individual_line_item != {}
|
961
989
|
if line_items.nil?
|
990
|
+
if individual_line_item[:service_date].nil?
|
991
|
+
individual_line_item[:service_date] = individual_era[:claim_statement_period_start]
|
992
|
+
end
|
962
993
|
line_items[0] = individual_line_item
|
963
994
|
else
|
995
|
+
if individual_line_item[:service_date].nil?
|
996
|
+
individual_line_item[:service_date] = individual_era[:claim_statement_period_start]
|
997
|
+
end
|
964
998
|
line_items[line_items.count] = individual_line_item
|
965
999
|
end
|
966
1000
|
individual_era[:line_items] = line_items
|
@@ -977,16 +1011,19 @@ module Era835Parser
|
|
977
1011
|
line_items = ''
|
978
1012
|
if !individual_era[:line_items].nil?
|
979
1013
|
individual_era[:line_items].each do |line_item_counter, line_item|
|
980
|
-
if line_item[:
|
981
|
-
|
1014
|
+
if line_item[:remarks].nil?
|
1015
|
+
remark = "NO REMARKS"
|
982
1016
|
else
|
983
|
-
|
1017
|
+
remark = truncate(line_item[:remarks], 82)
|
984
1018
|
end
|
1019
|
+
line_items += "#{" " * (22)}#{line_item[:service_date]} #{line_item[:cpt_code]}#{" " * (7 - get_length(line_item[:cpt_code]))}#{'%.2f' % (line_item[:charge_amount].to_f / 100)}#{" " * (13 - get_length('%.2f' % (line_item[:charge_amount].to_f / 100)))}#{'%.2f' % (line_item[:payment_amount].to_f / 100)}#{" " * (13 - get_length('%.2f' % (line_item[:payment_amount].to_f / 100)))}#{'%.2f' % (line_item[:total_adjustment_amount].to_f / 100)}#{" " * (15 - get_length('%.2f' % (line_item[:total_adjustment_amount].to_f / 100)))}#{remark}\n\n"
|
1020
|
+
|
985
1021
|
if !line_item[:adjustment_groups].nil?
|
986
1022
|
line_item[:adjustment_groups].each do |adjustment_group_counter, adjustment_group|
|
987
|
-
line_items += " Adjustment Group Adj Amt Translated Reason Code\n"
|
1023
|
+
line_items += " Adjustment Group Adj Amt Translated Reason Code\n" if adjustment_group_counter == 0
|
988
1024
|
reason_code = adjustment_group[:translated_reason_code].nil? ? '' : adjustment_group[:translated_reason_code].upcase
|
989
1025
|
line_items += " #{adjustment_group[:adjustment_group].upcase}#{" " * (28 - get_length(adjustment_group[:adjustment_group]))}#{'%.2f' % (adjustment_group[:adjustment_amount].to_f / 100)}#{" " * (8 - get_length('%.2f' % (adjustment_group[:adjustment_amount].to_f / 100)))}#{truncate(reason_code, 84)}\n"
|
1026
|
+
line_items += "\n" if line_item[:adjustment_groups].length == (adjustment_group_counter + 1)
|
990
1027
|
end
|
991
1028
|
end
|
992
1029
|
end
|
@@ -997,7 +1034,13 @@ module Era835Parser
|
|
997
1034
|
era_text += "#{" " * (126 + [14, get_length(individual_era[:account_number]) + 1].max)}#{check[:payer_address]}\n"
|
998
1035
|
era_text += "#{" " * (126 + [14, get_length(individual_era[:account_number]) + 1].max)}#{check[:payer_city]},#{check[:payer_state]} #{check[:payer_zip_code]}\n"
|
999
1036
|
era_text += "#{" " * (126 + [14, get_length(individual_era[:account_number]) + 1].max)}Tax ID: #{check[:payer_tax_id]}\n"
|
1000
|
-
|
1037
|
+
|
1038
|
+
if !individual_era[:claim_statement_period_end].nil? && !individual_era[:claim_statement_period_start].nil?
|
1039
|
+
era_text += "#{" " * (96)}Payer Claim Control Number: #{individual_era[:payer_claim_control_number]}\n"
|
1040
|
+
era_text += "#{" " * (96)}Claim Statement Period: #{individual_era[:claim_statement_period_start]} - #{individual_era[:claim_statement_period_end]}\n\n"
|
1041
|
+
else
|
1042
|
+
era_text += "#{" " * (96)}Payer Claim Control Number: #{individual_era[:payer_claim_control_number]}\n\n"
|
1043
|
+
end
|
1001
1044
|
if line_items.length > 0
|
1002
1045
|
era_text += "#{" " * (10)}Line Item: Svc Date CPT Charge Amt Payment Amt Total Adj Amt Remarks\n"
|
1003
1046
|
era_text += line_items
|
data/spec/era_835_parser_spec.rb
CHANGED
@@ -3,7 +3,6 @@ require 'spec_helper'
|
|
3
3
|
RSpec.describe Era835Parser::Parser do
|
4
4
|
|
5
5
|
describe '#parse' do
|
6
|
-
|
7
6
|
context 'Machine readable' do
|
8
7
|
context 'example_1.835' do
|
9
8
|
# https://www.bluecrossnc.com/sites/default/files/document/attachment/providers/public/pdfs/835_5010_v2.6%20Claim%20Payment%20Advice.pdf
|
@@ -109,7 +108,7 @@ RSpec.describe Era835Parser::Parser do
|
|
109
108
|
|
110
109
|
context 'Line item #0' do
|
111
110
|
it 'returns the Date of service (string mm/dd/yyyy)' do
|
112
|
-
expect(@era[:checks]['70408535'][:eras][0][:line_items][0][:service_date]).to eq(
|
111
|
+
expect(@era[:checks]['70408535'][:eras][0][:line_items][0][:service_date]).to eq("03/07/2010")
|
113
112
|
end
|
114
113
|
it 'returns the CPT code' do
|
115
114
|
expect(@era[:checks]['70408535'][:eras][0][:line_items][0][:cpt_code]).to eq(nil)
|