Created
June 5, 2009 16:04
-
-
Save ebot/124347 to your computer and use it in GitHub Desktop.
ADD0 exit script for streamline
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 -wKU | |
#http://gist.github.com/124347 | |
require 'rubygems' | |
require 'fastercsv' | |
require 'yaml' | |
begin | |
# Load the config file | |
ops = YAML::load(File.new('config.yml')) | |
region_codes = ops['region_codes'] | |
doc_types = ops['document_types'] | |
csv_options = {:col_sep => ';', :headers => :first_row, | |
:write_headers => true} | |
index_file = FasterCSV.open '../index.txt', csv_options | |
new_index = [] | |
header = nil | |
index_file.each do |row| | |
puts "Creating index file for #{row['document_key']}" | |
# Document Type Conversion for Streamline Health | |
doc_type = doc_types[row['document_type'].downcase.chomp] | |
# Organization ID Conversion for Streamline Health | |
org_id = region_codes[row['organization_id'].chomp] | |
new_file_name = "#{row['document_key']}.001" | |
puts "Renaming #{row['file_name']} to #{new_file_name}." | |
File.rename("../data/#{row['file_name']}", "../data/#{new_file_name}") | |
csv = File.new "../data/#{row['document_key']}.idx", 'w' | |
csv.puts "Report Type|MRN|Account|Doctype|Facility Code|ToDate|FromDate|" << | |
"TotalDocFiles|IndexOverride|DocSeq|AppendLocation|" << | |
"CreatedId|ExternaIId" | |
csv.puts "M|#{row['medical_record_number']}|#{row['encounter_number']}|" << | |
"#{doc_type}|#{org_id}|||1|R||||#{row['document_key']}" | |
end | |
puts "Finished creating custom index files for Streamline Health." | |
rescue Exception => e | |
puts e.message | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment