Skip to content

Instantly share code, notes, and snippets.

@ebot
Created March 14, 2012 17:16
Show Gist options
  • Save ebot/2037992 to your computer and use it in GitHub Desktop.
Save ebot/2037992 to your computer and use it in GitHub Desktop.
Get List of EncounterNos, DocsType, and Dates from tag files.
#!/usr/bin/env ruby -wKU
out = File.new 'delete.csv', 'w'
encounters = []
doc_dates = []
doc_types = []
Dir.glob('*.tag').each do |tag|
input = File.new tag, 'r'
input.each_line do |line|
val = line.split(':')[1].strip
encounters << val if line.include?( 'Account' ) and (encounters.include?(val) == false)
doc_types << val if line.include?( 'DOC_VALUE' ) and (doc_types.include?(val) == false)
doc_dates << val if line.include?( 'DOC_DATE' ) and (doc_dates.include?(val) == false)
end
end
out << "WHERE EncounterNo in ('#{encounters.join( "', '" )}')\n"
out << " AND DocTypeName in ('#{doc_types.join( "', '" )}')\n"
out << " AND DocDateTime in ('#{doc_dates.join( "', '" )}')"
out.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment