sunnyside 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,16 @@
1
1
  module Sunnyside
2
+
2
3
  class << self
4
+
5
+ def create_folders
6
+ folders = ['db', '835', '837', 'summary', 'cash_receipts', 'new-ledger', 'private', 'private/archive',
7
+ 'summary/archive', '837/archive', '835/archive', 'ftp', 'ftp/837', 'ftp/837/GUILDNET', 'ftp/837/CPHL', 'ftp/837/ELDERSERVE',
8
+ 'ftp/835', 'ftp/835/GUILDNET', 'ftp/835/CPHL', 'ftp/835/ELDERSERVE', 'pdf-reports'
9
+ ]
10
+ Dir.mkdir("#{DRIVE}/sunnyside-files")
11
+ folders.each { |folder| Dir.mkdir("#{DRIVE}/sunnyside-files/#{folder}") }
12
+ end
13
+
3
14
  def create_tables
4
15
  DB.create_table :logins do
5
16
  primary_key :id
@@ -28,6 +39,7 @@ module Sunnyside
28
39
  foreign_key :client_id, :clients
29
40
  foreign_key :provider_id, :providers
30
41
  foreign_key :filelib_id, :filelibs
42
+ Integer :service_number
31
43
  String :auth
32
44
  String :client_name
33
45
  Float :rate
@@ -80,7 +92,8 @@ module Sunnyside
80
92
  String :fund_id
81
93
  String :recipient_id
82
94
  foreign_key :provider_id, :providers
83
- String :type, :default=>'MLTC'
95
+ String :prov_type, :default=>'MLTC'
96
+ Date :dob
84
97
  end
85
98
 
86
99
  DB.create_table :providers do
@@ -90,7 +103,7 @@ module Sunnyside
90
103
  Integer :debit_account
91
104
  String :name
92
105
  String :abbreviation
93
- String :type
106
+ String :prov_type
94
107
  String :edi_identifier
95
108
  end
96
109
 
@@ -128,42 +141,35 @@ module Sunnyside
128
141
  end
129
142
  end
130
143
 
131
- def add_clients
132
- TT[:clients].all.each { |client|
133
- if DB[:clients].where(client_number: client[:med_id]).count == 0
134
- DB[:clients].insert(client_number: client[:med_id])
135
- end
136
- }
137
- end
138
-
139
- def add_ftp_data
144
+ def add_denial_data
145
+ CSV.foreach('examples/denial_data.csv', 'r') { |row| DB[:denials].insert(denial_code: row[0], denial_explanation: row[1]) }
140
146
  end
141
147
 
142
148
  def add_providers
143
- DB[:providers].insert(:credit_account=>1206, :fund=>500, :debit_account=>5005, :name=>"AMERIGROUP 2", :abbreviation=>"AMG", :type=>"MCO")
144
- DB[:providers].insert(:credit_account=>1207, :fund=>300, :debit_account=>5007, :name=>"CHILDREN'S AID SOCIETY", :abbreviation=>"CAS", :type=>"MLTC")
145
- DB[:providers].insert(:credit_account=>1226, :fund=>300, :debit_account=>5026, :name=>"COMPREHENSIVE CARE MANAGEMENT", :abbreviation=>"CCM", :type=>"MLTC")
146
- DB[:providers].insert(:credit_account=>1203, :fund=>300, :debit_account=>5002, :name=>"DOMINICAN SISTERS FAM HLTH", :abbreviation=>"DSF", :type=>"MLTC")
147
- DB[:providers].insert(:credit_account=>1209, :fund=>300, :debit_account=>5009, :name=>"ELDERSERVE HEALTH", :abbreviation=>"ELD", :type=>"MLTC")
148
- DB[:providers].insert(:credit_account=>1212, :fund=>300, :debit_account=>5012, :name=>"EMBLEM HEALTH", :abbreviation=>"EMB", :type=>"MLTC")
149
- DB[:providers].insert(:credit_account=>1201, :fund=>300, :debit_account=>5001, :name=>"GUILDNET", :abbreviation=>"G", :type=>"MLTC")
150
- DB[:providers].insert(:credit_account=>1227, :fund=>500, :debit_account=>5027, :name=>"HEALTH CARE PARTNERS", :abbreviation=>"HCP", :type=>"MCO")
151
- DB[:providers].insert(:credit_account=>1218, :fund=>500, :debit_account=>5018, :name=>"HEALTH FIRST", :abbreviation=>"HFS", :type=>"MCO")
152
- DB[:providers].insert(:credit_account=>1216, :fund=>500, :debit_account=>5016, :name=>"HEALTH INSURANCE PLAN OF NY", :abbreviation=>"HIP", :type=>"MCO")
153
- DB[:providers].insert(:credit_account=>1223, :fund=>300, :debit_account=>5023, :name=>"HHH LONG TERM HOME HLTH CARE", :abbreviation=>"HHH", :type=>"MLTC")
154
- DB[:providers].insert(:credit_account=>1228, :fund=>300, :debit_account=>5028, :name=>"INDEPENDENCE CARE SYSTEMS", :abbreviation=>"ICS", :type=>"MLTC")
155
- DB[:providers].insert(:credit_account=>1217, :fund=>500, :debit_account=>5017, :name=>"METROPLUS HEALTH", :abbreviation=>"MPH", :type=>"MCO")
156
- DB[:providers].insert(:credit_account=>1219, :fund=>500, :debit_account=>5019, :name=>"NEIGHBORHOOD HEALTH PROVIDERS", :abbreviation=>"NHP", :type=>"MCO")
157
- DB[:providers].insert(:credit_account=>1221, :fund=>500, :debit_account=>5021, :name=>"NYS CATHOLIC/FIDELIS", :abbreviation=>"FID", :type=>"MCO")
158
- DB[:providers].insert(:credit_account=>1200, :fund=>300, :debit_account=>5000, :name=>"PRIVATE", :abbreviation=>"P", :type=>"MLTC")
159
- DB[:providers].insert(:credit_account=>1204, :fund=>300, :debit_account=>5004, :name=>"SENIOR HEALTH PARTNERS", :abbreviation=>"SHP", :type=>"MLTC")
160
- DB[:providers].insert(:credit_account=>1202, :fund=>300, :debit_account=>5003, :name=>"SUNNYSIDE COMMUNITY SERVICES", :abbreviation=>"SCS", :type=>"MLTC")
161
- DB[:providers].insert(:credit_account=>1213, :fund=>500, :debit_account=>5013, :name=>"UNITED HEALTH CARE", :abbreviation=>"UHC", :type=>"MCO")
162
- DB[:providers].insert(:credit_account=>1229, :fund=>500, :debit_account=>5029, :name=>"VNSNY CHOICE SELECT HEALTH", :abbreviation=>"VCS", :type=>"MCO")
163
- DB[:providers].insert(:credit_account=>1224, :fund=>500, :debit_account=>5024, :name=>"WELCARE OF NEW YORK, INC.", :abbreviation=>"WEL", :type=>"MCO")
164
- DB[:providers].insert(:credit_account=>1310, :fund=>300, :debit_account=>5030, :name=>"VILLAGE CARE MAX", :abbreviation=>"VIL", :type=>"MLTC")
165
- DB[:providers].insert(:credit_account=>1222, :fund=>500, :debit_account=>5022, :name=>"AFFINITY HEALTH PLUS", :abbreviation=>"AFF", :type=>"MCO")
166
- DB[:providers].insert(:credit_account=>1218, :fund=>500, :debit_account=>5018, :name=>"HEALTH PLUS PHSP,INC", :abbreviation=>"HFS", :type=>"MCO")
149
+ DB[:providers].insert(:credit_account=>1206, :fund=>500, :debit_account=>5005, :name=>"AMERIGROUP 2", :abbreviation=>"AMG", :prov_type=>"MCO")
150
+ DB[:providers].insert(:credit_account=>1207, :fund=>300, :debit_account=>5007, :name=>"CHILDREN'S AID SOCIETY", :abbreviation=>"CAS", :prov_type=>"MLTC")
151
+ DB[:providers].insert(:credit_account=>1226, :fund=>300, :debit_account=>5026, :name=>"COMPREHENSIVE CARE MANAGEMENT", :abbreviation=>"CCM", :prov_type=>"MLTC")
152
+ DB[:providers].insert(:credit_account=>1203, :fund=>300, :debit_account=>5002, :name=>"DOMINICAN SISTERS FAM HLTH", :abbreviation=>"DSF", :prov_type=>"MLTC")
153
+ DB[:providers].insert(:credit_account=>1209, :fund=>300, :debit_account=>5009, :name=>"ELDERSERVE HEALTH", :abbreviation=>"ELD", :prov_type=>"MLTC")
154
+ DB[:providers].insert(:credit_account=>1212, :fund=>300, :debit_account=>5012, :name=>"EMBLEM HEALTH", :abbreviation=>"EMB", :prov_type=>"MLTC")
155
+ DB[:providers].insert(:credit_account=>1201, :fund=>300, :debit_account=>5001, :name=>"GUILDNET", :abbreviation=>"G", :prov_type=>"MLTC")
156
+ DB[:providers].insert(:credit_account=>1227, :fund=>500, :debit_account=>5027, :name=>"HEALTH CARE PARTNERS", :abbreviation=>"HCP", :prov_type=>"MCO")
157
+ DB[:providers].insert(:credit_account=>1218, :fund=>500, :debit_account=>5018, :name=>"HEALTH FIRST", :abbreviation=>"HFS", :prov_type=>"MCO")
158
+ DB[:providers].insert(:credit_account=>1216, :fund=>500, :debit_account=>5016, :name=>"HEALTH INSURANCE PLAN OF NY", :abbreviation=>"HIP", :prov_type=>"MCO")
159
+ DB[:providers].insert(:credit_account=>1223, :fund=>300, :debit_account=>5023, :name=>"HHH LONG TERM HOME HLTH CARE", :abbreviation=>"HHH", :prov_type=>"MLTC")
160
+ DB[:providers].insert(:credit_account=>1228, :fund=>300, :debit_account=>5028, :name=>"INDEPENDENCE CARE SYSTEMS", :abbreviation=>"ICS", :prov_type=>"MLTC")
161
+ DB[:providers].insert(:credit_account=>1217, :fund=>500, :debit_account=>5017, :name=>"METROPLUS HEALTH", :abbreviation=>"MPH", :prov_type=>"MCO")
162
+ DB[:providers].insert(:credit_account=>1219, :fund=>500, :debit_account=>5019, :name=>"NEIGHBORHOOD HEALTH PROVIDERS", :abbreviation=>"NHP", :prov_type=>"MCO")
163
+ DB[:providers].insert(:credit_account=>1221, :fund=>500, :debit_account=>5021, :name=>"NYS CATHOLIC/FIDELIS", :abbreviation=>"FID", :prov_type=>"MCO")
164
+ DB[:providers].insert(:credit_account=>1200, :fund=>300, :debit_account=>5000, :name=>"PRIVATE", :abbreviation=>"P", :prov_type=>"MLTC")
165
+ DB[:providers].insert(:credit_account=>1204, :fund=>300, :debit_account=>5004, :name=>"SENIOR HEALTH PARTNERS", :abbreviation=>"SHP", :prov_type=>"MLTC")
166
+ DB[:providers].insert(:credit_account=>1202, :fund=>300, :debit_account=>5003, :name=>"SUNNYSIDE COMMUNITY SERVICES", :abbreviation=>"SCS", :prov_type=>"MLTC")
167
+ DB[:providers].insert(:credit_account=>1213, :fund=>500, :debit_account=>5013, :name=>"UNITED HEALTH CARE", :abbreviation=>"UHC", :prov_type=>"MCO")
168
+ DB[:providers].insert(:credit_account=>1229, :fund=>500, :debit_account=>5029, :name=>"VNSNY CHOICE SELECT HEALTH", :abbreviation=>"VCS", :prov_type=>"MCO")
169
+ DB[:providers].insert(:credit_account=>1224, :fund=>500, :debit_account=>5024, :name=>"WELCARE OF NEW YORK, INC.", :abbreviation=>"WEL", :prov_type=>"MCO")
170
+ DB[:providers].insert(:credit_account=>1310, :fund=>300, :debit_account=>5030, :name=>"VILLAGE CARE MAX", :abbreviation=>"VIL", :prov_type=>"MLTC")
171
+ DB[:providers].insert(:credit_account=>1222, :fund=>500, :debit_account=>5022, :name=>"AFFINITY HEALTH PLUS", :abbreviation=>"AFF", :prov_type=>"MCO")
172
+ DB[:providers].insert(:credit_account=>1218, :fund=>500, :debit_account=>5018, :name=>"HEALTH PLUS PHSP,INC", :abbreviation=>"HFS", :prov_type=>"MCO")
167
173
  end
168
174
  end
169
175
  end
@@ -9,4 +9,5 @@ module Sunnyside
9
9
  class Service < Sequel::Model; end
10
10
  class Provider < Sequel::Model; end
11
11
  class Visit < Sequel::Model; end
12
+ class Denial < Sequel::Model; end
12
13
  end
@@ -0,0 +1,29 @@
1
+ # definitely a work in progress.
2
+
3
+ module Sunnyside
4
+
5
+ def self.query
6
+ puts "1.) Rerun Ledger/CSV file creation"
7
+ case gets.chomp
8
+ when '1'
9
+ Query.new.ledger_file
10
+ # puts 'Type in post date (YYYY-MM-DD)'
11
+ # date = Date.parse(gets.chomp)
12
+ # if date.is_a?(Date)
13
+ # Invoice.where(post_date: date).all.each { |invoice| Sunnyside.payable_csv(invoice, date) }
14
+ # end
15
+ end
16
+ end
17
+
18
+ class Query
19
+ include Sunnyside
20
+
21
+ def ledger_file
22
+ puts 'Type in post date (YYYY-MM-DD)'
23
+ date = Date.parse(gets.chomp)
24
+ if date.is_a?(Date)
25
+ Invoice.where(post_date: date).all.each { |invoice| self.payable_csv(invoice, date) }
26
+ end
27
+ end
28
+ end
29
+ end
@@ -3,160 +3,105 @@ require "pp"
3
3
  module Sunnyside
4
4
 
5
5
  def self.run_report
6
- print "Type in the check number in order to create the PDF file: "
7
- check = gets.chomp
8
- print "Now enter the date the check was posted to FUND EZ: "
9
- postted = gets.chomp
10
- Reporter.new(check, posted).pdf_report
6
+ print "Type in the post date (YYYY-MM-DD): "
7
+ post_date = Date.parse(gets.chomp)
8
+ self.check_prompt { |payment|
9
+ provider = Provider[payment.provider_id]
10
+ report = Reporter.new(payment, post_date, provider)
11
+ report.check_header
12
+ }
11
13
  end
14
+
12
15
  class Reporter
13
16
  include Sunnyside
14
- attr_reader :check, :posted, :check_number
15
-
16
- def initialize(check, posted)
17
- @check_number = check
18
- @check = Claim.where(check_number: check)
19
- @posted = posted
17
+ attr_reader :payment, :claims, :post_date, :provider, :pdf, :total
18
+
19
+ def initialize(payment, post_date, provider)
20
+ @provider = provider
21
+ @payment = payment
22
+ @post_date = post_date
23
+ @claims = Claim.where(payment_id: payment.id)
24
+ @pdf = Prawn::Document.new(:page_layout => :landscape) # generate("#{DRIVE}/sunnyside-files/pdf-reports/#{provider.name}-#{payment.check_number}.PDF", :page_layout => :landscape)
25
+ @total = Money.new(payment.check_total * 100, 'USD').format
20
26
  end
21
27
 
22
- def pdf_report
23
- if check.count == 0
24
- puts "No claims were found with this check number. Please re-enter."
25
- self.run_report
26
- else
27
- create_pdf
28
+ def check_header
29
+ puts "creating report for #{provider.name} - Check Number: #{payment.check_number} - posted on: #{post_date}"
30
+ pdf.text "CLAIMS FOR #{provider.name} - CHECK NUMBER: #{payment.check_number} - CHECK TOTAL: #{total}"
31
+ pdf.move_down 50
32
+
33
+ pdf.text "Claims with payments."
34
+
35
+ paid_claims do |clm|
36
+ pdf.move_down 10
37
+ claim = ClaimEOP.new(clm, post_date, pdf, clm.paid, clm.billed)
38
+ claim.create_block
39
+ end
40
+
41
+ if claims.where(status: '4').count > 0
42
+ pdf.start_new_page
43
+ pdf.text "Claims with denials."
44
+
45
+ denied_claims do |clm|
46
+ pdf.move_down 10
47
+ claim = ClaimEOP.new(clm, post_date, pdf, clm.paid, clm.billed)
48
+ claim.create_block
49
+ end
50
+ end
51
+
52
+ if claims.where(status: '22').count > 0
53
+ pdf.start_new_page
54
+ pdf.text "Claims with takebacks."
55
+
56
+ takeback_claims do |clm|
57
+ pdf.move_down 10
58
+ claim = ClaimEOP.new(clm, post_date, pdf, clm.paid, clm.billed)
59
+ claim.create_block
60
+ end
28
61
  end
62
+
63
+ page_numbering
64
+
65
+ pdf.render_file("#{DRIVE}/sunnyside-files/pdf-reports/#{provider.name}-#{payment.check_number}.PDF")
66
+ end
67
+
68
+ def page_numbering
69
+ pdf.number_pages('Page <page> of <total>', { :at => [pdf.bounds.right - 150, - 10], :width => 150, :align => :center, :start_count_at => 1 } )
29
70
  end
30
71
 
31
- def provider
32
- Provider[check.get(:provider_id)].name
72
+ def denied_claims
73
+ claims.where(status: '4').order(:invoice_id).all.each { |claim| yield claim if !claim.nil?}
33
74
  end
34
75
 
35
- def create_pdf
36
- puts "creating report for #{provider} - Check Number: #{check.get(:check_number)} - posted on: #{posted}"
37
- report.collate_services
76
+ def paid_claims
77
+ claims.where(status: '1').order(:invoice_id).all.each { |claim| yield claim if !claim.nil?}
38
78
  end
39
79
 
40
- def report
41
- CheckEOP.new(check, posted, provider, check_number)
80
+ def takeback_claims
81
+ claims.where(status: '22').order(:invoice_id).all.each { |claim| yield claim if !claim.nil?}
42
82
  end
43
83
  end
44
84
 
45
- class CheckEOP < Reporter
46
- attr_reader :posted, :check_number, :claims, :pdf
85
+ class ClaimEOP < Reporter
86
+ attr_reader :claim, :post_date, :pdf, :claim_row, :opts, :services
47
87
 
48
- def initialize(claims, posted, provider, check_number)
49
- @claims = claims
50
- @posted = posted
51
- @provider = provider
52
- @check_number = check_number
53
- @pdf = Prawn::Document.generate("#{LOCAL_FILES}/#{provider}-#{check_number}.PDF")
88
+ def initialize(claim, post_date, pdf, paid, billed)
89
+ @claim = claim
90
+ @claim_row = [claim.invoice_id, 'Date', Client[claim.client_id].client_name, 'Units', currency(billed), currency(paid), claim.control_number]
91
+ @post_date = post_date
92
+ @pdf = pdf
93
+ @services = Service.where(claim_id: claim.id).all.map { |svc| ['', svc.dos, svc.service_code, svc.units, currency(svc.paid), currency(svc.billed), svc.denial_reason] }
94
+ @opts = { :column_widths => [85, 75, 75, 75, 75, 145], :cell_style => {:align => :center, :overflow => :shrink_to_fit, :size => 12, :height => 30 } }
54
95
  end
55
96
 
56
- def collate_services
57
-
97
+ def create_block
98
+ pdf.table([claim_row], opts)
99
+ pdf.move_down 10
100
+ pdf.table(services, opts)
58
101
  end
59
- end
60
-
61
102
 
62
- # def create_pdf
63
- # puts "#{Provider[@provider_id].name}: #{Payment[check].check_number}"
64
- # provider = Provider[@provider_id].name.gsub(/\/|\\/, '')
65
- # Prawn::Document.generate("./PDF-REPORTS/#{provider}_CHECK_#{Payment[@check].check_number}.pdf", opts) do |pdf|
66
- # pdf.move_down 50
67
- # pdf.text "CLAIMS FOR #{Provider[@provider_id].name} - CHECK NUMBER: #{Payment[@check].check_number} - CHECK TOTAL: #{currency(total)}"
68
- # insert_claim_table(pdf)
69
- # pdf.move_down 10
70
- # if !@takeback.empty?
71
- # pdf.start_new_page
72
- # pdf.text "TAKE BACK CLAIMS"
73
- # takeback_claims(pdf)
74
- # end
75
- # page_numbering(pdf)
76
- # end
77
- # @takeback = []
78
- # @claim_data = []
79
- # end
80
-
81
- # def page_numbering(pdf)
82
- # pdf.number_pages('Page <page> of <total>', { :at => [pdf.bounds.right - 150, 0],
83
- # :width => 150,
84
- # :align => :center,
85
- # :start_count_at => 1
86
- # }
87
- # )
88
- # end
89
-
90
- # def insert_claim_table(pdf)
91
- # @claim_data.each do |c|
92
- # pdf.move_down 10
93
- # pdf.table([c],
94
- # :column_widths => [65, 75, 65, 65, 65, 150],
95
- # :cell_style => {
96
- # :align => :center,
97
- # :overflow => :shrink_to_fit,
98
- # :size => 10,
99
- # :height => 30
100
- # }) # SHOULD ONLY HAVE ONE CLAIM
101
- # insert_service_table(c[0], pdf)
102
- # end
103
- # end
104
-
105
- # def insert_service_table(claim_id, pdf)
106
- # make_service_table(claim_id)
107
- # pdf.table(@service_data, table_opts)
108
- # end
109
-
110
- # def table_opts
111
- # {
112
- # :column_widths => [65, 75, 65, 65, 65, 150],
113
- # :header => true,
114
- # :cell_style => {
115
- # :align => :center,
116
- # :overflow => :shrink_to_fit,
117
- # :size => 8,
118
- # :height => 20
119
- # }
120
- # }
121
- # end
122
-
123
- # def claim_table(inv)
124
- # claims(inv).all.each do |clm|
125
- # @claim_data << [clm.id, client(inv), inv, currency(clm.billed), currency(clm.paid), response_msg(clm.status), clm.control_number]
126
- # end
127
- # end
128
-
129
- # def response_msg(msg)
130
- # case msg
131
- # when '1' then 'CASH PAYMENT'
132
- # when '4' then 'CLAIM DENIED'
133
- # when '22' then 'TAKE BACK'
134
- # else
135
- # 'oop'
136
- # end
137
- # end
138
-
139
- # def make_service_table(claim_id)
140
- # @service_data = []
141
- # total = 0.0
142
- # @service_data << ['DATE OF SERVICE', 'SERVICE CODE', 'UNITS', 'BILLED', 'PAID', 'DENIAL REASON']
143
- # services(claim_id).all.each {|svc|
144
- # @service_data << [svc.dos, svc.service_code, svc.units, currency(svc.billed), currency(svc.paid), svc.denial_reason]
145
- # total += svc.paid
146
- # }
147
- # @service_data << ['TOTAL', '', '', '', currency(total), '']
148
- # end
149
-
150
- # def currency(amt)
151
- # Money.new(amt*100, 'USD').format
152
- # end
153
-
154
- # def services(claim_id)
155
- # Service.where(claim_id: claim_id)
156
- # end
157
-
158
- # def client(invoice_number)
159
- # Invoice.where(invoice_number: invoice_number).get(:client_name)
160
- # end
161
- # end
103
+ def currency(amt)
104
+ Money.new(amt*100, 'USD').format
105
+ end
106
+ end
162
107
  end
@@ -2,7 +2,7 @@ module Sunnyside
2
2
  PRIVATE_CLIENTS = ['TABICKMAN', 'JIBAJA', 'SUNNYSIDE COMMUNITY', 'BARROW', 'JENSEN']
3
3
 
4
4
  def self.private_clients
5
- Dir['private/*.PDF'].each { |file| PrivateClient.new(file).create_pdfS }
5
+ Dir['private/*.PDF'].each { |file| PrivateClient.new(file).create_pdfs }
6
6
  end
7
7
 
8
8
  class PrivateClient
@@ -1,74 +1,116 @@
1
1
  module Sunnyside
2
- def receivable_csv(invoice, payment_id, check_number, post_date)
3
- total = Service.where(invoice_id: invoice.invoice_number).sum(:paid)
4
- prov = Provider[invoice.provider_id]
5
- fund_id = Client[invoice.client_id].fund_id
6
- CSV.open("#{LOCAL_FILES}/cash_receipts/EDI-citywide-import.csv", "a+") do |row| # #{post_date.gsub(/\//, '-')}-
7
- row << [1, check_number,
2
+ def receivable_csv(claim, payment, post_date)
3
+ total = claim.paid
4
+ prov = Provider[claim.provider_id]
5
+ if Client[claim.client_id].fund_id.empty?
6
+ puts "Whoops! It appears #{Client[claim.client_id].client_name} doesn't have a fund id. Please retrieve it from FUND EZ and type it in now."
7
+ Client.where(client_number: claim.client_id).update(:fund_id => gets.chomp)
8
+ end
9
+ fund_id = Client[claim.client_id].fund_id
10
+ puts "#{total.round(2)} #{Client[claim.client_id].client_name} "
11
+ CSV.open("#{DRIVE}/sunnyside-files/cash_receipts/EDI-citywide-import.csv", "a+") do |row| # #{post_date.gsub(/\//, '-')}-
12
+ row << [1, payment.check_number,
8
13
  post_date,
9
14
  fund_id,
10
- invoice.invoice_number,
11
- invoice.invoice_number,
12
- "#{post_date[0..1]}/#{post_date[8..9]}#{prov.abbreviation}",
15
+ claim.invoice_id,
16
+ claim.invoice_id,
17
+ "#{post_date.strftime('%m')}/#{post_date.strftime('%y')}#{prov.abbreviation}",
13
18
  post_date,
14
- invoice.invoice_number,
19
+ claim.invoice_id,
15
20
  prov.fund, prov.credit_account,'','','', 0, total]
16
- row << [2, check_number,
21
+ row << [2, payment.check_number,
17
22
  post_date,
18
23
  fund_id,
19
- invoice.invoice_number,
20
- invoice.invoice_number,
21
- "#{post_date[0..1]}/#{post_date[8..9]}#{prov.abbreviation}",
24
+ claim.invoice_id,
25
+ claim.invoice_id,
26
+ "#{post_date.strftime('%m')}/#{post_date.strftime('%y')}#{prov.abbreviation}",
22
27
  post_date,
23
- invoice.invoice_number,
28
+ claim.invoice_id,
24
29
  100, 1000,'','','', total, 0]
25
- row << [3, check_number,
30
+ row << [3, payment.check_number,
26
31
  post_date,
27
32
  fund_id,
28
- invoice.invoice_number,
29
- invoice.invoice_number,
30
- "#{post_date[0..1]}/#{post_date[8..9]}#{prov.abbreviation}",
33
+ claim.invoice_id,
34
+ claim.invoice_id,
35
+ "#{post_date.strftime('%m')}/#{post_date.strftime('%y')}#{prov.abbreviation}",
31
36
  post_date,
32
- invoice.invoice_number,
37
+ claim.invoice_id,
33
38
  prov.fund, 3990, '', '', '', total, 0]
34
- row << [4, check_number,
39
+ row << [4, payment.check_number,
35
40
  post_date,
36
41
  fund_id,
37
- invoice.invoice_number,
38
- invoice.invoice_number,
39
- "#{post_date[0..1]}/#{post_date[8..9]}#{prov.abbreviation}",
42
+ claim.invoice_id,
43
+ claim.invoice_id,
44
+ "#{post_date.strftime('%m')}/#{post_date.strftime('%y')}#{prov.abbreviation}",
40
45
  post_date,
41
- invoice.invoice_number,
46
+ claim.invoice_id,
42
47
  100, 3990, '', '', '', 0, total]
43
48
  end
44
49
  end
45
50
 
46
- def payable_csv(inv, post_date, prov)
47
- fund_id = Client.where(client_number: invoice.client_id).get(:fund_id)
48
- CSV.open("#{LOCAL_FILES}/new-ledger/#{inv.post_date}-IMPORT-FUND-EZ-LEDGER.csv", "a+") do |row|
51
+ def payable_csv(inv, post_date)
52
+ prov = Provider[inv.provider_id]
53
+ if Client[inv.client_id].fund_id.empty?
54
+ puts "Whoops! It appears #{Client[inv.client_id].client_name} for #{prov.name} doesn't have a fund id. Please retrieve it from FUND EZ and type it in now."
55
+ Client.where(client_number: inv.client_id).update(:fund_id => gets.chomp)
56
+ end
57
+
58
+ prov_name = if prov.name == 'AMERIGROUP 2'
59
+ 'AMERIGROUP'
60
+ else
61
+ prov.name
62
+ end
63
+
64
+ fund_id = Client[inv.client_id].fund_id
65
+ CSV.open("#{DRIVE}/sunnyside-files/new-ledger/#{inv.post_date}-IMPORT-FUND-EZ-LEDGER.csv", "a+") do |row|
49
66
  row << [1,
50
67
  inv.invoice_number,
51
68
  post_date.strftime('%m/%d/%y'),
52
- fund_id, prov.name, post_date.strftime('%m/%d/%y'),
69
+ fund_id, prov_name, post_date.strftime('%m/%d/%y'),
53
70
  "To Record #{post_date.strftime('%m/%d/%y')} Billing",
54
- "#{post_date[5..6]}/#{post_date[8..9]}#{prov.abbrev}",
55
- post_date.strftime('%m/%d/%y'), "To Rec for W/E #{post_date - 6} Billing",
56
- prov.fund, prov.credit_account,
71
+ "#{post_date.strftime('%m')}/#{post_date.strftime('%y')}#{prov.abbreviation}",
72
+ post_date.strftime('%m/%d/%y'),
73
+ "To Rec for W/E #{post_date - 6} Billing",
74
+ prov.fund,
75
+ prov.credit_account,
57
76
  '', '', '', inv.amount, '']
58
77
  row << [2,
59
78
  inv.invoice_number,
60
79
  post_date.strftime('%m/%d/%y'),
61
80
  fund_id,
62
- prov.name,
81
+ prov_name,
63
82
  post_date.strftime('%m/%d/%y'),
64
83
  "To Record #{post_date.strftime('%m/%d/%y')} Billing",
65
- "#{post_date[5..6]}/#{post_date[8..9]}#{prov.abbrev}",
84
+ "#{post_date.strftime('%m')}/#{post_date.strftime('%y')}#{prov.abbreviation}",
66
85
  post_date.strftime('%m/%d/%y'),
67
86
  "To Rec for W/E #{post_date - 6} Billing",
68
87
  prov.fund,
69
88
  prov.debit_account,
70
- prov.fund, '', prov.type, '', inv.amount]
89
+ prov.fund, '', prov.prov_type, '', inv.amount]
71
90
  end
72
91
  end
92
+
93
+ def self.check_prompt
94
+
95
+ Provider.all.each { |prov| puts "#{prov.id}: #{prov.name}"}
96
+ print "Type in the Provider ID: "
97
+
98
+ provider = Provider[gets.chomp]
99
+
100
+ Payment.where(provider_id: provider.id).all.each { |check| puts "#{check.id}: Number - #{check.check_number} Amount - #{check.check_total}"}
101
+ print "Type in the Check ID: "
102
+
103
+ payment = Payment[gets.chomp]
104
+
105
+ # For ICS checks, since for some reason the check number doesn't match the EDI TRN field.
106
+
107
+ if payment.provider_id == 12
108
+ print "type in the correct ICS check #: "
109
+ Payment.update(:check_number => gets.chomp)
110
+ end
111
+
112
+ yield payment
113
+ end
114
+
73
115
  end
74
116
 
@@ -1,3 +1,3 @@
1
1
  module Sunnyside
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.7" # stupid, no-good, lousy rubygems not letting me yank my bad install. grumble grumble...
3
3
  end
data/lib/sunnyside.rb CHANGED
@@ -4,7 +4,6 @@ require 'csv'
4
4
  require 'fileutils'
5
5
  require "sunnyside/version"
6
6
  require 'sunnyside/cash_receipts/cash_receipt'
7
- require 'sunnyside/cash_receipts/ics'
8
7
  require 'sunnyside/ledger/ledger'
9
8
  require 'sunnyside/ledger/edi'
10
9
  require 'sunnyside/ledger/auth_report'
@@ -12,24 +11,24 @@ require 'sunnyside/ledger/private'
12
11
  require 'sunnyside/reports/pdf_report'
13
12
  require 'sunnyside/reports/private'
14
13
  require 'sunnyside/reports/report'
14
+ require 'sunnyside/query/query'
15
15
  require 'sunnyside/ftp'
16
16
  require 'sunnyside/menu'
17
17
  require 'sunnyside/expiring_auth'
18
+ require 'sunnyside/models/db_setup'
18
19
 
19
20
  module Sunnyside
20
- # doesn't work on some Windows machines
21
- LOCAL_FILES = ENV["HOME"] + "/sunnyside-files"
22
- DB = Sequel.connect("sqlite:/#{LOCAL_FILES}/db/sunnyside.db")
23
-
24
- # Second database for copying old data
21
+ DRIVE = ENV["HOMEDRIVE"]
22
+
23
+ Sunnyside.create_folders if !Dir.exist?("#{DRIVE}/sunnyside-files")
24
+
25
+ DB = Sequel.connect("sqlite:/#{DRIVE}/sunnyside-files/db/sunnyside.db")
25
26
 
26
27
  if DB.tables.empty?
27
- require 'sunnyside/models/db_setup'
28
- TT = Sequel.connect("sqlite:/#{LOCAL_FILES}/db/project.db")
29
28
  Sunnyside.create_tables
30
29
  Sunnyside.add_providers
31
- Sunnyside.add_ftp_data
32
- Sunnyside.add_clients
30
+ Sunnyside.add_denial_data
33
31
  end
32
+
34
33
  require 'sunnyside/models/sequel_classes'
35
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sunnyside
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-27 00:00:00.000000000 Z
12
+ date: 2014-01-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
@@ -116,7 +116,6 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - lib/sunnyside/cash_receipts/cash_receipt.rb
119
- - lib/sunnyside/cash_receipts/ics.rb
120
119
  - lib/sunnyside/expiring_auth.rb
121
120
  - lib/sunnyside/ftp.rb
122
121
  - lib/sunnyside/ledger/auth_report.rb
@@ -126,6 +125,7 @@ files:
126
125
  - lib/sunnyside/menu.rb
127
126
  - lib/sunnyside/models/db_setup.rb
128
127
  - lib/sunnyside/models/sequel_classes.rb
128
+ - lib/sunnyside/query/query.rb
129
129
  - lib/sunnyside/reports/mco_mltc.rb
130
130
  - lib/sunnyside/reports/pdf_report.rb
131
131
  - lib/sunnyside/reports/pdf_report_draft.rb