class X12edi::EightThirtyFive

X12Edi::EightThirtyFive.new(File.read(“test/sample.edi”)).to_h

{

payer_name: "Name of Payer",
payee_name: "Name of Payee",

…, }

Public Instance Methods

claims() click to toggle source
# File lib/x12edi.rb, line 94
def claims
  h = {}

  begin
    parser.first.flatmap do |isa|
      isa.iterate(:GS) do |gs|
        gs.iterate(:ST) do |st|
          st.iterate(:LX) do |lx|
            h[:claims] = []
            lx.iterate(:CLP) do |clp|
              claim = {}

              begin
              el(clp.find(:CLP), 1, 2, 3, 4) do |a,b,c,d|
                claim[:submitter_identifier]          = a
                claim[:status_code]                   = b
                claim[:amount_submitted]              = c # submitted amount
                claim[:amount_paid]                   = d # amount paid in this claim
              end
              rescue => e
                claim[:ERROR] = e.message
              end

              # Patient
              el(clp.find(:NM1), 1,2,3,4,5,6,7,8,9) do |a,b,c,d,e,f,g,h,i|
                  claim[:entity_identifier_code]        = a
                  claim[:entity_type_qualifier]         = b
                  claim[:last_name]                     = c
                  claim[:first_name]                    = d
                  claim[:middle_name]                   = e
                  claim[:name_prefix]                   = f
                  claim[:name_suffix]                   = g
                  claim[:identification_code_qualifier] = h
                  claim[:identification_code]           = i
              end

              h[:claims] << claim
            end
          end
        end
      end
    end
  rescue => e
    h[:ERROR] = e.message
  end

  h
end
payee() click to toggle source
# File lib/x12edi.rb, line 67
def payee
  h = {}
  begin
    parser.first.flatmap do |isa|
      isa.iterate(:GS) do |gs|
        gs.iterate(:ST) do |st|
          st.iterate(:N1, "PE") do |n1|
            el(n1, 1, 2, 3, 4) do |a, b, c, d|
              h[:entity_id_code]    = a
              h[:name]              = b
              h[:id_code_qualifier] = c
              h[:id_code]           = d
            end
            el(n1.find(:N4), 1, 2, 3) do |a, b, c|
              h[:city_name]         = a
              h[:state_or_provence] = b
              h[:postal_code]       = c
            end
          end
        end
      end
    end
  rescue
  end
  h
end
payer() click to toggle source
# File lib/x12edi.rb, line 40
def payer
  h = {}
  begin
    parser.first.flatmap do |isa|
      isa.iterate(:GS) do |gs|
        gs.iterate(:ST) do |st|
          st.iterate(:N1, "PR") do |n1|
            el(n1, 1, 2, 3, 4) do |a, b, c, d|
              h[:entity_id_code]    = a
              h[:name]              = b
              h[:id_code_qualifier] = c
              h[:id_code]           = d
            end
            el(n1.find(:N4), 1, 2, 3) do |a, b, c|
              h[:city_name]         = a
              h[:state_or_provence] = b
              h[:postal_code]       = c
            end
          end
        end
      end
    end
  rescue
  end
  h
end