Class: X12edi::EightThirtyFive

Inherits:
Base
  • Object
show all
Defined in:
lib/x12edi.rb

Overview

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

{

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

…, }

Instance Method Summary collapse

Methods inherited from Base

#el, #initialize, #parser

Constructor Details

This class inherits a constructor from X12edi::Base

Instance Method Details

#claimsObject



94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# 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

#payeeObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# 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

#payerObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# 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