Skip to content

Instantly share code, notes, and snippets.

@jdee
Created September 14, 2010 22:23
Show Gist options
  • Save jdee/579894 to your computer and use it in GitHub Desktop.
Save jdee/579894 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'features/support/hl7_messages'
vt_results = {}
HL7MESSAGES.each do |name, msg|
begin
hl7_msg = HL7::Message.parse msg
hl7_msg.observation_requests.each do |obr|
obr.all_tests.each do |obx|
obx_segment = obx.obx_segment
value_type = obx_segment.value_type
vt_sym = value_type.to_sym
loinc_code = obx_segment.observation_id.split(obx_segment.item_delim)[0]
lc = LoincCode.find_by_loinc_code loinc_code
scale = lc ? lc.scale.the_code : '<nil>'
puts "#{name}: LOINC=#{loinc_code} (scale #{scale}) #{value_type} [#{obx.obx_segment.observation_value}]"
vt_results[vt_sym] ||= 0
vt_results[vt_sym] += 1
end
end
rescue
end
end
vt_results.each do |vt_sym, count|
puts "#{vt_sym}: #{count} occurrences"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment