test/unit/hqmf_javascript_test.rb in hqmf2js-1.2.1 vs test/unit/hqmf_javascript_test.rb in hqmf2js-1.3.0
- old
+ new
@@ -1,6 +1,7 @@
require_relative '../test_helper'
+require 'hquery-patient-api'
class HqmfJavascriptTest < Test::Unit::TestCase
def setup
# Open a path to all of our fixtures
hqmf_contents = File.open("test/fixtures/NQF59New.xml").read
@@ -52,10 +53,15 @@
local_context.eval('typeof OidDictionary != undefined').must_equal true
local_context.eval('typeof hqmfjs.IPP != undefined').must_equal true
local_context.eval('typeof hqmfjs.NUMER != undefined').must_equal true
local_context.eval('typeof hqmfjs.DENOM != undefined').must_equal true
end
+
+ def test_to_js_method_without_codes
+ value = @converter.to_js(0,nil)
+ assert !value.match(/<%= oid_dictionary %>/).nil?
+ end
def test_converted_hqmf
# Unspecified time bounds should be nil
assert_equal nil, @context.eval("numeratorPatient.encounters()[0].asIVL_TS().low.asDate()")
assert_equal 2010, @context.eval("numeratorPatient.encounters()[0].asIVL_TS().high.asDate().getUTCFullYear()")
@@ -127,9 +133,21 @@
# XPRODUCTing
assert_equal 1, @context.eval("hqmfjs.allDiabetes(numeratorPatient).length")
end
+ def test_cached_access
+ eventCriteria = '{"type": "results", "statuses": [], "includeEventsWithoutStatus": true, "negated": false, "valueSet": getCodes("2.16.840.1.113883.3.464.1.72")}'
+ assert_equal 3, @context.eval("numeratorPatient.getEvents(#{eventCriteria}).length")
+ end
+
+ def test_measure_with_observ
+ measure = HQMF::Document.from_json(JSON.parse(File.read(File.join('test','fixtures','json','0495.json'))))
+ c = HQMF2JS::Generator::JS.new(measure)
+ result = c.js_for('OBSERV',HQMF::PopulationCriteria::OBSERV)
+ assert !result.match(/hqmfjs.OBSERV = function/).nil?
+ end
+
def test_converted_utils
# Filter events by value - HbA1C as an example
events = 'numeratorPatient.results().match(getCodes("2.16.840.1.113883.3.464.1.72"))'
assert_equal 2, @context.eval("filterEventsByValue(#{events}, new IVL_PQ(new PQ(9, '%'), null))").count
assert_equal 0, @context.eval("filterEventsByValue(#{events}, new IVL_PQ(new PQ(10, '%'), null))").count
\ No newline at end of file