Created
April 21, 2010 19:44
-
-
Save ebot/374311 to your computer and use it in GitHub Desktop.
Find documents that were not uploaded..
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 | |
require "FileUtils" | |
puts "#{Time.now} - Getting documents that were proccessd." | |
docs = File.new 'document_list.txt', 'w' | |
Dir.glob( '*.log' ) do |log_file| | |
puts " Reading #{log_file}" | |
docs << "#{log_file}\n" | |
input = File.new log_file, 'r' | |
input.each_line do |line| | |
doc_id = line[/ (P|Sk).*$/] | |
docs << " #{doc_id[/.{8}-.*\./].gsub('.', '')}\n" unless doc_id.nil? | |
end | |
end | |
docs.close | |
puts "#{Time.now} - Done." |
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
Select EnrolleeName, EncounterNo, DocTypeName, DocDateTime | |
From Documents as d | |
Inner Join DocTypes as dt on d.DocType = dt.DocType | |
Inner Join DocsOwners as do on d.DocId = do.DocId | |
Inner Join Encounters as e on do.OwnerId = e.EncntrOwnerId | |
Inner Join MedicalRecords as mr on e.MedRecOwnerId = mr.MedRecOwnerId | |
Inner Join Enrollees as enr on mr.EnrolleeOwnerId = enr.EnrolleeOwnerId | |
Where d.DocId = '' |
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 'SqlServer' | |
require 'progressbar' | |
require 'sqlite3' | |
puts "#{Time.now} - Begin" | |
qry = <<EOQ | |
SELECT dbo.Documents.DocID | |
FROM Documents | |
INNER JOIN DocsOwners ON dbo.Documents.DocId = dbo.DocsOwners.DocId | |
INNER JOIN Encounters as e ON DocsOwners.OwnerId = e.EncntrOwnerId | |
INNER JOIN MedicalRecords as mr ON e.MedRecOwnerId = mr.MedRecOwnerId | |
WHERE OrgOwnerId = 3 | |
AND ModifyDateTime >= '1/1/2006 12:00:00 AM' | |
AND ModifyDateTime < '7/1/2006 12:00:00 AM' | |
EOQ | |
begin | |
missing_docs = File.new 'missing_docs.txt', 'w' | |
missing_docs << "DocId\n" | |
ldb = SQLite3::Database.new( 'docs.sqlite3' ) | |
db = SqlServer.new( { :host => 'server_name_or_ip', | |
:user_name => 'user', | |
:password => 'pass', | |
:database => 'db', | |
:timeout => '120'} ) | |
puts "\n#{qry}\n" | |
documents = db.query(qry) | |
pbar = ProgressBar.new("docs checked", documents.length-1) | |
documents.each do |doc| | |
doc_id = doc.values[0].gsub(/(\{|\})/, '') | |
rows = ldb.execute( "select * from documents where doc_id = '#{doc_id}'" ) | |
missing_docs << "#{doc_id}\n" if rows.length != 0 | |
pbar.inc | |
end | |
pbar.finish | |
db.close | |
missing_docs.close | |
rescue Exception => e | |
puts e.message | |
ensure | |
puts "#{Time.now} - Done" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment