Created
February 26, 2009 13:14
-
-
Save ebot/70831 to your computer and use it in GitHub Desktop.
script to pull patient info from cobius xml files.
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 "rexml/document" | |
require 'FileUtils' | |
out = File.new 'patient_list.csv', 'w' | |
out << "medical_record_number,encounter_number,patient_last_name," | |
out << "patient_middle_name,patient_first_name\n" | |
Dir.glob( File.join( '.', '*.XML' ) ) do |cobius_file| | |
doc = REXML::Document.new(File.new(cobius_file, 'r')) | |
#medical_record_number = PID.3.1 | |
line = doc.elements['/COB_ADT_XML_R/PID_SHORT/PID.3/PID.3.1'].text << "," | |
#encounter_number = PID.18.1 | |
line << doc.elements['/COB_ADT_XML_R/PID_SHORT/PID.18/PID.18.1'].text << "," | |
#patient_last = PID.5.1 | |
line << doc.elements['/COB_ADT_XML_R/PID_SHORT/PID.5/PID.5.1'].text << "," | |
#patient_middle = PID.5.3 | |
mid_name = doc.elements['/COB_ADT_XML_R/PID_SHORT/PID.5/PID.5.3'].text | |
if mid_name.nil? | |
line << "," | |
else | |
line << "#{mid_name}," | |
end | |
#patient_first = PID.5.2 | |
line << doc.elements['/COB_ADT_XML_R/PID_SHORT/PID.5/PID.5.2'].text | |
out << "#{line}\n" | |
end | |
out.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment