Skip to content

Commit

Permalink
Merge remote-tracking branch 'jm/refactor' into refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
rdingwell committed Aug 30, 2012
2 parents efb1428 + 74b1d2c commit 7f9c7c8
Show file tree
Hide file tree
Showing 5 changed files with 2,804 additions and 6 deletions.
50 changes: 50 additions & 0 deletions lib/cypress/qrda_utility.rb
@@ -0,0 +1,50 @@
module Cypress
class QrdaUtility


# Extract and return measure results from a PQRI document and add to the reported results
# for this test.
def self.extract_results(doc, id_map)
# the measure IDs in the report must be a subset of what the product is
# allowed to test (in the measure_map)
# reverse the hash of nqf#=>product-specific-measure-id
measure_map = id_map.invert if id_map
doc = (doc.kind_of? String )? Nokogiri::XML::Document.new(doc) : doc

#the nodes we want will have a child "templateId" with root = 2.16.840.1.113883.10.20.27.3.1
result_nodes = doc.xpath('/xmlns:ClinicalDocument/xmlns:component/xmlns:structuredBody/xmlns:component/xmlns:section/xmlns:entry/xmlns:organizer/xmlns:templateId[@root = "2.16.840.1.113883.10.20.27.3.1"]/parent::*')
results ||= {}
result_nodes.each do |result_node|
key = result_node.at_xpath('xmlns:reference/xmlns:externalDocument/xmlns:id[@root = "2.16.840.1.113883.3.560.1"]')['extension']
key = measure_map[key] if id_map

numerator = get_measure_attr(result_node,'NUMER')
denominator = get_measure_attr(result_node,'DENOM')
initial_population = get_measure_attr(result_node,'IPP')
measure_population = get_measure_attr(result_node,'MSRPOPL')
numerator_exclusions = get_measure_attr(result_node,'NUMEX')
denominator_exclusions = get_measure_attr(result_node,'DENEX')
denominator_exceptions = get_measure_attr(result_node,'EXCEP')

results[key] = {'measure_population' => measure_population, 'initial_population' => initial_population, \
'numerator' => numerator , 'numerator_exclusions' => numerator_exclusions, \
'denominator' => denominator, 'denominator_exclusions' => denominator_exclusions, 'denominator_exceptions' => denominator_exceptions \
} if key
end

return results
end

private
def self.get_measure_attr(node, name)
xpath = 'xmlns:component/xmlns:observation/xmlns:value[@code = "'+ name +'"]/following::xmlns:entryRelationship/xmlns:observation/xmlns:value'
result = node.at_xpath(xpath)
if !result.nil?
return result['value'].to_i
else
return '-'
end
end

end
end
8 changes: 4 additions & 4 deletions lib/measures/importer.rb
Expand Up @@ -18,10 +18,10 @@ def import(zip)

Zip::ZipFile.open(zip.path) do |zipfile|
zipfile.entries.each do |entry|
next if entry.directory?
entries_by_type[:libraries][entry_key(entry.name,"js")] = zipfile.read(entry.name) if entry.name.match /libraries/
entries_by_type[:json][entry_key(entry.name,"json")] = zipfile.read(entry.name) if entry.name.match /\/json\//
entries_by_type[:bundle] = zipfile.read(entry.name) if entry.name.match /bundle/
next if entry.directory?
entries_by_type[:libraries][entry_key(entry.name,"js")] = zipfile.read(entry.name) if entry.name.match /libraries\//
entries_by_type[:json][entry_key(entry.name,"json")] = zipfile.read(entry.name) if entry.name.match /json\//
entries_by_type[:bundle] = zipfile.read(entry.name) if entry.name.match /bundle/
end
end

Expand Down
3 changes: 1 addition & 2 deletions lib/tasks/measures.rake
Expand Up @@ -66,8 +66,7 @@ namespace :measures do
puts "ERROR: Unable to find measures #{@measures_version} for installation"
next
end
puts "Installing measures from #{measures_file} to database"

puts "Installing measures from #{measures_file} to database #{@loader.get_db.name}"

# Clear out all current measure data
@loader.get_db['bundles'].remove("name" => "Meaningful Use Stage 1 Clinical Quality Measures")
Expand Down

0 comments on commit 7f9c7c8

Please sign in to comment.