Created
January 17, 2011 18:29
-
-
Save ebot/783206 to your computer and use it in GitHub Desktop.
Searches adhocs for ICD Components
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "mongo" | |
connection = Mongo::Connection.new | |
connection.database_names.each do |name| | |
if name.include?('icd_') | |
puts "#{DateTime.now} - #{name}" | |
adhocs = connection.db(name).collection('adhocs') | |
scheduled = adhocs.find( { "schedule" => /.*/ } ) | |
icd_components = adhocs.find( { "instructions.instruction" => /(DX CD|DX DESC|PROC DESC)/ } ) | |
scheduled_icd = adhocs.find( { "schedule" => /.*/, "instructions.instruction" => /(DX CD|DX DESC|PROC DESC)/ } ) | |
download_data = adhocs.find( { "schedule" => /.*/, "report_type" => /(NETLIST|NETSTAT)/, "instructions.instruction" => /(DX CD|DX DESC|PROC DESC)/ } ) | |
puts " TOTAL ADHOCS: #{adhocs.count.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse}" | |
puts " SCHEDULED: #{scheduled.count.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse}" | |
puts " USING ICD: #{icd_components.count.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse}" | |
puts " SCHEDULED ICD: #{scheduled_icd.count.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse}" | |
puts " SCHEDULED DOWNLOAD DATA ICD: #{download_data.count.to_s.reverse.scan(/(?:\d*\.)?\d{1,3}-?/).join(',').reverse} - #{(download_data.count / scheduled_icd.count) * 100}%" | |
scheduled_icd.sort('name', 1).each do |row| | |
row["instructions"].each do |instruction| | |
comp_loc = instruction["instruction"].index(/(DX CD|DX DESC|PROC DESC)/) | |
puts " #{row["name"]} (#{row["report_type"]}) - #{instruction["name"]}: #{instruction["instruction"][comp_loc, 30]}..." unless comp_loc.nil? | |
end | |
end | |
puts "------------------------------------------------------------------\n\n" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "adhoc_store" | |
def get_hosp_region(name) | |
name = name.gsub('ADHOCSYN', '') | |
name = name.gsub('ADHOCFIL', '') | |
name = name.gsub('.TXT', '') | |
return "#{name}0" | |
#"#{name[2,1]}0#{name[0,2]}" | |
end | |
def build_key_stores | |
Dir.glob('ADHOCSYN*').each do |file_name| | |
hhrr = get_hosp_region file_name | |
puts "\nProcessing #{file_name} - #{hhrr}" | |
# Build the basic db | |
begin | |
adhoc_store = AdhocStore.new hhrr | |
adhoc_store.build_database file_name | |
rescue Exception => e | |
puts e.message | |
end | |
end | |
end | |
def add_schedule | |
Dir.glob('ADHOCFIL*').each do |file_name| | |
hhrr = get_hosp_region file_name | |
puts "\nProcessing #{file_name} - #{hhrr}" | |
begin | |
adhoc_store = AdhocStore.new hhrr | |
adhoc_store.add_schedules file_name | |
rescue Exception => e | |
puts e.message | |
end | |
end | |
end | |
def make_mongos | |
files = ['DYL0', 'GCB0', 'HKE0', 'LFK0', 'LNJ0', | |
'LWF0', 'M0S0', 'MJS0', 'MPN0', 'NSK0'] | |
files.each do |hhrr| | |
puts "#{Time.now} - Building #{hhrr}" | |
ah_store = AdhocStore.new hhrr | |
ah_store.to_mongo( { :name => "icd_#{hhrr}" } ) | |
end | |
end | |
build_key_stores | |
add_schedule | |
make_mongos |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment