class Sunnyside::PageData

in PageData, the providers name is captured from the PDF::Reader raw_content, and the post date from the file name. the rest of the data (the invoices) gets split by newlines (filted by those lines that fit the criteria for invoice data) Then, the data gets finalized (via the InvoiceLine child class of PageData) and inserted into the database.

Attributes

invoice_data[R]
page_data[R]
post_date[R]
provider[R]

Public Class Methods

new(page_data, post_date) click to toggle source
# File lib/sunnyside/ledger/ledger.rb, line 73
def initialize(page_data, post_date)
  @provider  = page_data[/CUSTOMER:\s+(.+)(?=\)')/, 1]
  @post_date = post_date
  @page_data = page_data.split(/\n/).select { |line| line =~ /^\([0-9\/]{8}\s/ }
end

Public Instance Methods

formatted_provider() click to toggle source

Since the source data is somewhat unreliable in the format, there have been two different variations of AMERIGROUP and ELDERSERVE. This method accounts for the aberrations while still maintaining that any provider not recognized by the DB to be saved as a PRIVATE client.

# File lib/sunnyside/ledger/ledger.rb, line 82
def formatted_provider
  if provider_missing?
    case provider
    when 'ELDERSERVEHEALTH'
      Provider[5]
    when 'AMERIGROUP'
      Provider[1]
    else
      Provider[16]
    end
  else
    Provider.where(name: provider).first
  end
end
invoice_lines() click to toggle source
# File lib/sunnyside/ledger/ledger.rb, line 101
def invoice_lines
  page_data.map { |line|
    line.gsub!(/^\(|\)'/)
    line.gsub!("\x00", " ")
    client_name = line.slice!(20..45)
    line        = InvoiceLine.new(line, formatted_provider, post_date, client_name) 
  }
end
provider_missing?() click to toggle source
# File lib/sunnyside/ledger/ledger.rb, line 97
def provider_missing?
  Provider.where(name: provider).count == 0
end