Skip to content

Instantly share code, notes, and snippets.

@lenagroeger
Created April 14, 2016 14:51
Show Gist options
  • Save lenagroeger/f30ab72dbbdf56965f4f349aa36afd3a to your computer and use it in GitHub Desktop.
Save lenagroeger/f30ab72dbbdf56965f4f349aa36afd3a to your computer and use it in GitHub Desktop.
PartB Referral
##IMPORT ALL THE REFERRALS FROM 4 FILES
task :referralsimport => :environment do
Reference.delete_all
f = CSV.open("#{Rails.root.to_s}/db/initial/referrals/REFEREE_INDIV_RANK_TOP5.csv", :headers => true)
f.each do |row|
s = Reference.new
s.doctor_id = row["referee_NPI"]
s.doc_npi = row["referee_NPI"]
s.ref_npi = row["referrer_NPI"]
s.direction = 'IN'
s.ref_type = 'INDV'
s.name = row["ReferrerProviderLast"]
s.first_name = row["ReferrerProviderFirst"]
puts "Reference #{s.doc_npi}"
s.save
end
end
task :referralsimport2 => :environment do
f = CSV.open("#{Rails.root.to_s}/db/initial/referrals/REFEREE_ORG_RANK_TOP5.csv", :headers => true)
f.each do |row|
s = Reference.new
s.doctor_id = row["referee_NPI"]
s.doc_npi = row["referee_NPI"]
s.ref_npi = row["referrer_NPI"]
s.direction = 'IN'
s.ref_type = 'ORG'
s.org_name = row["ReferrerProviderOrg"]
puts "Reference #{s.doc_npi}"
s.save
end
end
task :referralsimport3 => :environment do
f = CSV.open("#{Rails.root.to_s}/db/initial/referrals/REFERRER_INDIV_RANK_TOP5.csv", :headers => true)
f.each do |row|
s = Reference.new
s.doctor_id = row["Referrer_NPI"]
s.doc_npi = row["Referrer_NPI"]
s.ref_npi = row["Referee_NPI"]
s.direction = 'OUT'
s.ref_type = 'INDV'
s.name = row["RefereeLast"]
s.first_name = row["RefereeFirst"]
puts "Reference #{s.doc_npi}"
s.save
end
end
task :referralsimport4 => :environment do
f = CSV.open("#{Rails.root.to_s}/db/initial/referrals/REFERRER_ORG_RANK_TOP5.csv", :headers => true)
f.each do |row|
s = Reference.new
s.doctor_id = row["Referrer_NPI"]
s.doc_npi = row["Referrer_NPI"]
s.ref_npi = row["Referee_NPI"]
s.direction = 'OUT'
s.ref_type = 'ORG'
s.org_name = row["RefereeOrg"]
puts "Reference #{s.doc_npi}"
s.save
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment