Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Suuport for MeasurePeriod control variable in HQMF

  • Loading branch information...
commit 8f857b2c2bc0cf8aa0f945cacdbcb9d78a31c986 1 parent abf1414
@hadleynet authored
View
1  lib/generator/data_criteria.js.erb
@@ -1,4 +1,5 @@
// Measure variables
+var MeasurePeriod = <%= measure_period.to_hash.to_json %>;
<%- all_criteria.select {|c| c.type == :variable}.each do |criteria| -%>
var <%= criteria.js_name %> = <%= js_for_value(criteria.value) %>;
<%- end -%>
View
2  lib/generator/js.rb
@@ -103,7 +103,7 @@ def js_for(criteria_code)
def js_for_data_criteria
template_str = File.read(File.expand_path("../data_criteria.js.erb", __FILE__))
template = ERB.new(template_str, nil, '-', "_templ#{TemplateCounter.instance.new_id}")
- params = {'all_criteria' => @doc.all_data_criteria}
+ params = {'all_criteria' => @doc.all_data_criteria, 'measure_period' => @doc.measure_period}
context = ErbContext.new(params)
template.result(context.get_binding)
end
View
6 lib/hqmf/document.rb
@@ -1,10 +1,16 @@
module HQMF
# Class representing an HQMF document
class Document
+ attr_reader :measure_period
+
# Create a new HQMF::Document instance by parsing at file at the supplied path
# @param [String] path the path to the HQMF document
def initialize(hqmf_contents)
@doc = Document.parse(hqmf_contents)
+ measure_period_def = @doc.at_xpath('cda:QualityMeasureDocument/cda:controlVariable/cda:measurePeriod/cda:value')
+ if measure_period_def
+ @measure_period = EffectiveTime.new(measure_period_def)
+ end
@data_criteria = @doc.xpath('cda:QualityMeasureDocument/cda:component/cda:dataCriteriaSection/cda:entry').collect do |entry|
DataCriteria.new(entry)
end
View
27 lib/hqmf/types.rb
@@ -4,19 +4,21 @@ module HQMF
class Value
include HQMF::Utilities
- attr_reader :type
+ attr_reader :type, :unit, :value
def initialize(entry, default_type='PQ')
@entry = entry
@type = attr_val('./@xsi:type') || default_type
+ @unit = attr_val('./@unit')
+ @value = attr_val('./@value')
end
- def value
- attr_val('./@value')
- end
-
- def unit
- attr_val('./@unit')
+ def to_hash
+ val = {}
+ val[:type] = @type if @type
+ val[:unit] = @unit if @unit
+ val[:value] = @value if @value
+ val
end
def inclusive?
@@ -49,13 +51,14 @@ def expression
# Represents a HQMF physical quantity which can have low and high bounds
class Range
include HQMF::Utilities
- attr_reader :low, :high
+ attr_reader :low, :high, :width
def initialize(entry)
@entry = entry
if @entry
@low = optional_value('./cda:low')
@high = optional_value('./cda:high')
+ @width = optional_value('./cda:width')
end
end
@@ -63,6 +66,14 @@ def type
attr_val('./@xsi:type')
end
+ def to_hash
+ val = {}
+ val[:low] = @low.to_hash if @low
+ val[:high] = @high.to_hash if @high
+ val[:width] = @width.to_hash if @width
+ val
+ end
+
private
def optional_value(xpath)
View
11 test/fixtures/NQF59New.xml
@@ -17,6 +17,17 @@
<custodian typeCode="CST">
<assignedPerson classCode="ASSIGNED"/>
</custodian>
+ <controlVariable>
+ <localVariableName>MeasurePeriod</localVariableName>
+ <measurePeriod>
+ <id extension="StartDate" root="0"/>
+ <value>
+ <low value="20110101"/>
+ <high value="20111231"/>
+ <width value="1" unit="a"/>
+ </value>
+ </measurePeriod>
+ </controlVariable>
<component>
<measureDescriptionSection>
<code code="34089-3" codeSystem="2.16.840.1.113883.6.1"/>
View
5 test/unit/document_test.rb
@@ -15,6 +15,11 @@ def test_parse
def test_metadata
assert_equal "Sample Quality Measure Document", @doc.title
assert_equal "This is the measure description.", @doc.description
+ assert @doc.measure_period
+ assert_equal '20110101', @doc.measure_period.low.value
+ assert_equal '20111231', @doc.measure_period.high.value
+ assert_equal '1', @doc.measure_period.width.value
+ assert_equal 'a', @doc.measure_period.width.unit
end
def test_population_criteria
View
8 test/unit/hqmf_javascript_test.rb
@@ -52,7 +52,13 @@ def test_codes
assert_equal 9, @context.eval('OidDictionary["2.16.840.1.113883.3.464.1.72"]["SNOMED-CT"]').size
end
- def test_converted_hqmf
+ def test_converted_hqmf
+ # Measure variables
+ assert @context.eval("MeasurePeriod.low.value=='20110101'")
+ assert @context.eval("MeasurePeriod.high.value=='20111231'")
+ assert @context.eval("MeasurePeriod.width.value=='1'")
+ assert @context.eval("MeasurePeriod.width.unit=='a'")
+
# Age functions - Fixture is 37.1
assert @context.eval("ageBetween17and64(numeratorPatient)")
assert @context.eval("ageBetween30and39(numeratorPatient)")
Please sign in to comment.
Something went wrong with that request. Please try again.