Class: Sunnyside::ClaimParser

Inherits:
EdiReader show all
Defined in:
lib/sunnyside/ledger/edi.rb

Instance Attribute Summary collapse

Attributes inherited from EdiReader

#data

Instance Method Summary collapse

Methods inherited from EdiReader

#check_number, #check_total, #claims, #parse_claims

Constructor Details

#initialize(claim, payment_id) ⇒ ClaimParser

Returns a new instance of ClaimParser.



57
58
59
60
61
# File 'lib/sunnyside/ledger/edi.rb', line 57

def initialize(claim, payment_id)
  @claim_header = claim[0].split(/\*/)
  @service_data = claim.select { |clm| clm =~ /^SVC/ }
  @payment_id   = Payment[payment_id]
end

Instance Attribute Details

#claim_headerObject (readonly)

Returns the value of attribute claim_header.



55
56
57
# File 'lib/sunnyside/ledger/edi.rb', line 55

def claim_header
  @claim_header
end

#payment_idObject (readonly)

Returns the value of attribute payment_id.



55
56
57
# File 'lib/sunnyside/ledger/edi.rb', line 55

def payment_id
  @payment_id
end

#service_dataObject (readonly)

Returns the value of attribute service_data.



55
56
57
# File 'lib/sunnyside/ledger/edi.rb', line 55

def service_data
  @service_data
end

Instance Method Details

#headerObject



63
64
65
66
67
68
69
70
71
72
# File 'lib/sunnyside/ledger/edi.rb', line 63

def header
  {
    :invoice       => claim_header[0],
    :response_code => claim_header[1],
    :billed        => claim_header[2],
    :paid          => claim_header[3],
    :units         => claim_header[5], # 4 is not used - that is the patient responsibility amount
    :claim_number  => claim_header[6][/^\d+/]
  }
end

#parseObject



74
75
76
77
78
# File 'lib/sunnyside/ledger/edi.rb', line 74

def parse
  claim    = ClaimEntry.new(header)
  claim_id = claim.to_db(payment_id) 
  service_data.each { |service| ServiceParser.new(service, claim_id).parse }
end