Skip to content

Instantly share code, notes, and snippets.

@blakewest
Last active September 19, 2016 21:11
Show Gist options
  • Save blakewest/31765703a521a53eca6e5bdad96d94bd to your computer and use it in GitHub Desktop.
Save blakewest/31765703a521a53eca6e5bdad96d94bd to your computer and use it in GitHub Desktop.
A place to write down snippets of the process we go through when naming things.
# 1
# Method name history was...
# nil (did both things in one method) --> generate_csv_for_revenue_lines
def generate_csv_for_revenue_lines(revenue_lines)
# name history...
# res -> pg_result
pg_result = execute_sql("SELECT * FROM recognized_revenue WHERE" +
+ " revenue_line_id IN (?)", revenue_lines.pluck(:id).join(",")
)
pg_result.values
generate_csv_from_results(array_of_deferred_revenue_results)
end
# previous name history
# nil -> generate_csv -> generate_csv_from_results
def generate_csv_from_results(array_of_deferred_revenue_results)
array_of_deferred_revenue_results
u.row_errors.each{|r| rows[r[:row]] = [r[:row], r[:field], r[:value], r[:message]] }
puts CSV.new('', col_sep: "\t").tap { |csv| rows.each {|r| csv << r} }.string
end
=begin
# This filtering of amount in cents seemed like a good idea at the time.
# Why would we want that? But then my instincts had a voice that said "don't filter
# results in a way that no one asked for". All the other filters come from a parameter. It's
# clear what's going on. This was the right call, because there are negative revenue amounts (discounts)
# that are critical for the report.
SELECT * FROM recognized_revenue WHERE" +
" month IN (#{month_numbers})" +
" AND year = #{year}" +
" AND practice_id = #{practice_id} " +
" AND recognized_revenue.amount_in_cents > 0" +
" LIMIT #{limit}",
=end
# Original name
def correct_name_if_diff_in_dots_and_spaces
if prod_pat.name.gsub(/[\s\.\,]/, '').downcase == correct_patient.name.gsub(/[\s\.\,]/, '').downcase
puts "Updating name from '#{prod_pat.name}' to '#{correct_patient.name}'" if verbose
prod_pat.first_name = correct_patient.first_name
prod_pat.last_name = correct_patient.last_name
end
end
def correct_name_if_name_has_dots_and_spaces
if prod_patient.name.gsub(/[\s\.\,]/, '').downcase == correct_patient.name.gsub(/[\s\.\,]/, '').downcase
puts "Updating name from '#{prod_patient.name}' to '#{correct_patient.name}'" if verbose
prod_patient.first_name = correct_patient.first_name
prod_patient.last_name = correct_patient.last_name
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment