test/unit/specifics_test.rb in hqmf2js-1.3.0 vs test/unit/specifics_test.rb in hqmf2js-1.4.0
- old
+ new
@@ -1,15 +1,15 @@
require_relative '../test_helper'
require 'hquery-patient-api'
-class SpecificsTest < Test::Unit::TestCase
+class SpecificsTest < Minitest::Test
def setup
@context = get_js_context(HQMF2JS::Generator::JS.library_functions)
test_initialize_js =
"
- hqmf.SpecificsManager.initialize({},hqmfjs, {'id':'OccurrenceAEncounter', 'type':'Encounter', 'function':'SourceOccurrenceAEncounter'},{'id':'OccurrenceBEncounter', 'type':'Encounter', 'function':'SourceOccurrenceBEncounter'})
+ hqmf.SpecificsManager.initialize({},hqmfjs, {'id':'OccurrenceAEncounter', 'type':'OccA_Encounter', 'function':'SourceOccurrenceAEncounter'},{'id':'OccurrenceBEncounter', 'type':'OccB_Encounter', 'function':'SourceOccurrenceBEncounter'})
hqmfjs.SourceOccurrenceAEncounter = function(patient) {
return [{'id':1},{'id':2},{'id':3},{'id':4},{'id':5}]
}
hqmfjs.SourceOccurrenceBEncounter = function(patient) {
return [{'id':1},{'id':2},{'id':3},{'id':4},{'id':5}]
@@ -19,19 +19,19 @@
end
def test_specifics_initialized_properly
- @context.eval('hqmf.SpecificsManager.keyLookup[0]').must_equal 'OccurrenceAEncounter'
- @context.eval('hqmf.SpecificsManager.keyLookup[1]').must_equal 'OccurrenceBEncounter'
- @context.eval("hqmf.SpecificsManager.indexLookup['OccurrenceAEncounter']").must_equal 0
- @context.eval("hqmf.SpecificsManager.indexLookup['OccurrenceBEncounter']").must_equal 1
- @context.eval('hqmf.SpecificsManager.functionLookup[0]').must_equal 'SourceOccurrenceAEncounter'
- @context.eval('hqmf.SpecificsManager.functionLookup[1]').must_equal 'SourceOccurrenceBEncounter'
- @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'].length").must_equal 2
- @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'][0]").must_equal 0
- @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'][1]").must_equal 1
+ assert_equal 'OccurrenceAEncounter', @context.eval('hqmf.SpecificsManager.keyLookup[0]')
+ assert_equal 'OccurrenceBEncounter', @context.eval('hqmf.SpecificsManager.keyLookup[1]')
+ assert_equal 0, @context.eval("hqmf.SpecificsManager.indexLookup['OccurrenceAEncounter']")
+ assert_equal 1, @context.eval("hqmf.SpecificsManager.indexLookup['OccurrenceBEncounter']")
+ assert_equal 'SourceOccurrenceAEncounter', @context.eval('hqmf.SpecificsManager.functionLookup[0]')
+ assert_equal 'SourceOccurrenceBEncounter', @context.eval('hqmf.SpecificsManager.functionLookup[1]')
+ assert_equal 2, @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'].length")
+ assert_equal 0, @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'][0]")
+ assert_equal 1, @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'][1]")
end
def test_specifics_row_union
union_rows = "
@@ -41,15 +41,15 @@
var specific2 = new hqmf.SpecificOccurrence([row2]);
result = specific1.union(specific2);
result.rows.length;
"
- @context.eval(union_rows).must_equal 2
- @context.eval("result.rows[0].values[0].id").must_equal 1
- @context.eval("result.rows[0].values[1]").must_equal '*'
- @context.eval("result.rows[1].values[0]").must_equal '*'
- @context.eval("result.rows[1].values[1].id").must_equal 2
+ assert_equal 2, @context.eval(union_rows)
+ assert_equal 1, @context.eval("result.rows[0].values[0].id")
+ assert_equal '*', @context.eval("result.rows[0].values[1]")
+ assert_equal '*', @context.eval("result.rows[1].values[0]")
+ assert_equal 2, @context.eval("result.rows[1].values[1].id")
end
def test_row_creation
@@ -59,31 +59,31 @@
var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2}});
var row4 = new Row(undefined, {});
"
@context.eval(rows)
- @context.eval("row1.values[0].id").must_equal 1
- @context.eval("row1.values[1]").must_equal '*'
- @context.eval("row2.values[0]").must_equal '*'
- @context.eval("row2.values[1].id").must_equal 2
- @context.eval("row3.values[0].id").must_equal 1
- @context.eval("row3.values[1].id").must_equal 2
- @context.eval("row4.values[0]").must_equal '*'
- @context.eval("row4.values[1]").must_equal '*'
+ assert_equal 1, @context.eval("row1.values[0].id")
+ assert_equal '*', @context.eval("row1.values[1]")
+ assert_equal '*', @context.eval("row2.values[0]")
+ assert_equal 2, @context.eval("row2.values[1].id")
+ assert_equal 1, @context.eval("row3.values[0].id")
+ assert_equal 2, @context.eval("row3.values[1].id")
+ assert_equal '*', @context.eval("row4.values[0]")
+ assert_equal '*', @context.eval("row4.values[1]")
end
def test_row_match
rows = "
var row1 = new Row(undefined, {});
"
@context.eval(rows)
- @context.eval("Row.match('*', {'id':1}).id").must_equal 1
- @context.eval("Row.match({'id':2}, '*').id").must_equal 2
- @context.eval("Row.match({'id':1}, {'id':1}).id").must_equal 1
- @context.eval("Row.match('*', '*')").must_equal '*'
- @context.eval("typeof(Row.match({'id':3}, {'id':2})) === 'undefined'").must_equal true
+ assert_equal 1, @context.eval("Row.match('*', {'id':1}).id")
+ assert_equal 2, @context.eval("Row.match({'id':2}, '*').id")
+ assert_equal 1, @context.eval("Row.match({'id':1}, {'id':1}).id")
+ assert_equal '*', @context.eval("Row.match('*', '*')")
+ assert_equal true, @context.eval("typeof(Row.match({'id':3}, {'id':2})) === 'undefined'")
end
def test_row_equal
@@ -96,16 +96,16 @@
var row5 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':2},'OccurrenceBEncounter':{'id':3}});
var row6 = new Row(undefined,{});
"
@context.eval(rows)
- @context.eval("row1.equals(row1)").must_equal true
- @context.eval("row1.equals(row2)").must_equal false
- @context.eval("row2.equals(row2)").must_equal true
- @context.eval("row3.equals(row4)").must_equal false
- @context.eval("row4.equals(row5)").must_equal true
- @context.eval("row6.equals(row6)").must_equal true
+ assert_equal true, @context.eval("row1.equals(row1)")
+ assert_equal false, @context.eval("row1.equals(row2)")
+ assert_equal true, @context.eval("row2.equals(row2)")
+ assert_equal false, @context.eval("row3.equals(row4)")
+ assert_equal true, @context.eval("row4.equals(row5)")
+ assert_equal true, @context.eval("row6.equals(row6)")
end
def test_row_intersect
@@ -118,30 +118,30 @@
var row5 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':3},'OccurrenceBEncounter':{'id':3}});
var row6 = new Row(undefined,{});
"
@context.eval(rows)
- @context.eval("row1.intersect(row2).values[0].id").must_equal 1
- @context.eval("row1.intersect(row2).values[1].id").must_equal 2
- @context.eval("row2.intersect(row1).values[0].id").must_equal 1
- @context.eval("row2.intersect(row1).values[1].id").must_equal 2
- @context.eval("row1.intersect(row3).values[0].id").must_equal 1
- @context.eval("row1.intersect(row3).values[1].id").must_equal 2
- @context.eval("row2.intersect(row3).values[0].id").must_equal 1
- @context.eval("row2.intersect(row3).values[1].id").must_equal 2
- @context.eval("typeof(row1.intersect(row4)) === 'undefined'").must_equal true
- @context.eval("row2.intersect(row4).values[0].id").must_equal 2
- @context.eval("row2.intersect(row4).values[1].id").must_equal 2
- @context.eval("typeof(row1.intersect(row5)) === 'undefined'").must_equal true
- @context.eval("typeof(row2.intersect(row5)) === 'undefined'").must_equal true
- @context.eval("typeof(row3.intersect(row4)) === 'undefined'").must_equal true
- @context.eval("row1.intersect(row6).values[0].id").must_equal 1
- @context.eval("row1.intersect(row6).values[1]").must_equal '*'
- @context.eval("row2.intersect(row6).values[0]").must_equal '*'
- @context.eval("row2.intersect(row6).values[1].id").must_equal 2
- @context.eval("row6.intersect(row6).values[0]").must_equal '*'
- @context.eval("row6.intersect(row6).values[1]").must_equal '*'
+ assert_equal 1, @context.eval("row1.intersect(row2).values[0].id")
+ assert_equal 2, @context.eval("row1.intersect(row2).values[1].id")
+ assert_equal 1, @context.eval("row2.intersect(row1).values[0].id")
+ assert_equal 2, @context.eval("row2.intersect(row1).values[1].id")
+ assert_equal 1, @context.eval("row1.intersect(row3).values[0].id")
+ assert_equal 2, @context.eval("row1.intersect(row3).values[1].id")
+ assert_equal 1, @context.eval("row2.intersect(row3).values[0].id")
+ assert_equal 2, @context.eval("row2.intersect(row3).values[1].id")
+ assert_equal true, @context.eval("typeof(row1.intersect(row4)) === 'undefined'")
+ assert_equal 2, @context.eval("row2.intersect(row4).values[0].id")
+ assert_equal 2, @context.eval("row2.intersect(row4).values[1].id")
+ assert_equal true, @context.eval("typeof(row1.intersect(row5)) === 'undefined'")
+ assert_equal true, @context.eval("typeof(row2.intersect(row5)) === 'undefined'")
+ assert_equal true, @context.eval("typeof(row3.intersect(row4)) === 'undefined'")
+ assert_equal 1, @context.eval("row1.intersect(row6).values[0].id")
+ assert_equal '*', @context.eval("row1.intersect(row6).values[1]")
+ assert_equal '*', @context.eval("row2.intersect(row6).values[0]")
+ assert_equal 2, @context.eval("row2.intersect(row6).values[1].id")
+ assert_equal '*', @context.eval("row6.intersect(row6).values[0]")
+ assert_equal '*', @context.eval("row6.intersect(row6).values[1]")
end
def test_specifics_row_intersection
@@ -169,38 +169,38 @@
allSpecific2.addIdentityRow();
"
@context.eval(intersect_rows)
- @context.eval("specific1.intersect(specific2).rows.length").must_equal 1
- @context.eval("specific1.intersect(specific2).rows[0].values[0].id").must_equal 1
- @context.eval("specific1.intersect(specific2).rows[0].values[1].id").must_equal 2
+ assert_equal 1, @context.eval("specific1.intersect(specific2).rows.length")
+ assert_equal 1, @context.eval("specific1.intersect(specific2).rows[0].values[0].id")
+ assert_equal 2, @context.eval("specific1.intersect(specific2).rows[0].values[1].id")
- @context.eval("specific1.intersect(specific3).rows.length").must_equal 1
- @context.eval("specific1.intersect(specific3).rows[0].values[0].id").must_equal 1
- @context.eval("specific1.intersect(specific3).rows[0].values[1].id").must_equal 2
+ assert_equal 1, @context.eval("specific1.intersect(specific3).rows.length")
+ assert_equal 1, @context.eval("specific1.intersect(specific3).rows[0].values[0].id")
+ assert_equal 2, @context.eval("specific1.intersect(specific3).rows[0].values[1].id")
- @context.eval("specific1.intersect(specific4).rows.length").must_equal 2
- @context.eval("specific1.intersect(specific4).rows[0].values[0].id").must_equal 1
- @context.eval("specific1.intersect(specific4).rows[0].values[1].id").must_equal 2
- @context.eval("specific1.intersect(specific4).rows[1].values[0].id").must_equal 1
- @context.eval("specific1.intersect(specific4).rows[1].values[1].id").must_equal 3
+ assert_equal 2, @context.eval("specific1.intersect(specific4).rows.length")
+ assert_equal 1, @context.eval("specific1.intersect(specific4).rows[0].values[0].id")
+ assert_equal 2, @context.eval("specific1.intersect(specific4).rows[0].values[1].id")
+ assert_equal 1, @context.eval("specific1.intersect(specific4).rows[1].values[0].id")
+ assert_equal 3, @context.eval("specific1.intersect(specific4).rows[1].values[1].id")
- @context.eval("specific2.intersect(specific3).rows.length").must_equal 2
- @context.eval("specific2.intersect(specific3).rows[0].values[0].id").must_equal 1
- @context.eval("specific2.intersect(specific3).rows[0].values[1].id").must_equal 2
- @context.eval("specific2.intersect(specific3).rows[1].values[0].id").must_equal 2
- @context.eval("specific2.intersect(specific3).rows[1].values[1].id").must_equal 2
+ assert_equal 2, @context.eval("specific2.intersect(specific3).rows.length")
+ assert_equal 1, @context.eval("specific2.intersect(specific3).rows[0].values[0].id")
+ assert_equal 2, @context.eval("specific2.intersect(specific3).rows[0].values[1].id")
+ assert_equal 2, @context.eval("specific2.intersect(specific3).rows[1].values[0].id")
+ assert_equal 2, @context.eval("specific2.intersect(specific3).rows[1].values[1].id")
- @context.eval("specific2.intersect(specific5).rows.length").must_equal 0
+ assert_equal 0, @context.eval("specific2.intersect(specific5).rows.length")
- @context.eval("specific4.intersect(specific5).rows.length").must_equal 1
- @context.eval("specific4.intersect(specific5).rows[0].values[0].id").must_equal 1
- @context.eval("specific4.intersect(specific5).rows[0].values[1].id").must_equal 3
+ assert_equal 1, @context.eval("specific4.intersect(specific5).rows.length")
+ assert_equal 1, @context.eval("specific4.intersect(specific5).rows[0].values[0].id")
+ assert_equal 3, @context.eval("specific4.intersect(specific5).rows[0].values[1].id")
- @context.eval("allSpecific1.intersect(allSpecific2).rows.length").must_equal 1
+ assert_equal 1, @context.eval("allSpecific1.intersect(allSpecific2).rows.length")
end
def test_specifics_timediff
init_rows = "
@@ -219,13 +219,36 @@
events2.specific_occurrence = 'OccurrenceBEncounter';
var timediffs = TIMEDIFF(XPRODUCT(events1, events2), null, specific);
"
@context.eval(init_rows)
- @context.eval("timediffs.length").must_equal 1
- @context.eval("timediffs[0]").must_equal 10
+ assert_equal 1, @context.eval("timediffs.length")
+ assert_equal 10, @context.eval("timediffs[0]")
end
+
+ def test_specifics_datetimediff
+ init_rows = "
+ var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':20}});
+ var row2 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':2},'OccurrenceBEncounter':{'id':20}});
+ var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':3},'OccurrenceBEncounter':{'id':30}});
+
+ var specific = new hqmf.SpecificOccurrence([row1,row2,row3]);
+
+ var ts1 = new TS('20100101100000');
+ var ts2 = new TS('20100101101000');
+
+ var events1 = [{'id': 1, 'asTS': function() {return ts1;}}];
+ events1.specific_occurrence = 'OccurrenceAEncounter';
+ var events2 = [{'id': 20, 'asTS': function() {return ts2;}},{'id': 30, 'asTS': function() {return ts2;}}];
+ events2.specific_occurrence = 'OccurrenceBEncounter';
+ var timediffs = DATETIMEDIFF(XPRODUCT(events1, events2), null, specific);
+ "
+
+ @context.eval(init_rows)
+ assert_equal 1, @context.eval("timediffs.length")
+ assert_equal 10, @context.eval("timediffs[0]")
+ end
def test_specifics_event_counting
init_rows = "
var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':20}});
@@ -241,26 +264,26 @@
var pop = new Boolean(true);
pop.specificContext = specific;
"
@context.eval(init_rows)
- @context.eval("specific.uniqueEvents([0])").must_equal 3
- @context.eval("specific.uniqueEvents([1])").must_equal 2
- @context.eval('hqmf.SpecificsManager.indexLookup["OccurrenceAEncounter"]').must_equal 0
- @context.eval('hqmf.SpecificsManager.indexLookup["OccurrenceBEncounter"]').must_equal 1
- @context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceAEncounter")').must_equal 0
- @context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceBEncounter")').must_equal 1
- assert_raise V8::JSError do
+ assert_equal 3, @context.eval("specific.uniqueEvents([0])")
+ assert_equal 2, @context.eval("specific.uniqueEvents([1])")
+ assert_equal 0, @context.eval('hqmf.SpecificsManager.indexLookup["OccurrenceAEncounter"]')
+ assert_equal 1, @context.eval('hqmf.SpecificsManager.indexLookup["OccurrenceBEncounter"]')
+ assert_equal 0, @context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceAEncounter")')
+ assert_equal 1, @context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceBEncounter")')
+ assert_raises V8::JSError do
@context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceCEncounter")')
end
- @context.eval('hqmf.SpecificsManager.validate(pop)').must_equal true
- @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceAEncounter"], pop)').must_equal 3
- @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceBEncounter"], pop)').must_equal 2
+ assert_equal true, @context.eval('hqmf.SpecificsManager.validate(pop)')
+ assert_equal 3, @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceAEncounter"], pop)')
+ assert_equal 2, @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceBEncounter"], pop)')
# this should be 3 and not 5 because we are doing a multiple encounter episode check. The OccurrenceB rows should be dropped since
# we cannot have multiple values defined on a single row for a multi encounter episode check for unique.
- @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceAEncounter", "OccurrenceBEncounter"], pop)').must_equal 3
- @context.eval('hqmf.SpecificsManager.countUnique(null, pop)').must_equal 1
+ assert_equal 3, @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceAEncounter", "OccurrenceBEncounter"], pop)')
+ assert_equal 1, @context.eval('hqmf.SpecificsManager.countUnique(null, pop)')
end
def test_specifics_event_exclusion
init_rows = "
@@ -283,37 +306,37 @@
pop4.specificContext = specific3;
"
@context.eval(init_rows)
@context.eval('var resultSpecific = specific1.removeMatchingRows(0, specific2)')
- @context.eval('resultSpecific.rows.length').must_equal 2
- @context.eval('resultSpecific.rows[0].values[0].id').must_equal 2
- @context.eval('resultSpecific.rows[1].values[0].id').must_equal 3
+ assert_equal 2, @context.eval('resultSpecific.rows.length')
+ assert_equal 2, @context.eval('resultSpecific.rows[0].values[0].id')
+ assert_equal 3, @context.eval('resultSpecific.rows[1].values[0].id')
@context.eval('resultSpecific = specific1.removeMatchingRows(1, specific2)')
- @context.eval('resultSpecific.rows.length').must_equal 1
- @context.eval('resultSpecific.rows[0].values[0].id').must_equal 3
+ assert_equal 1, @context.eval('resultSpecific.rows.length')
+ assert_equal 3, @context.eval('resultSpecific.rows[0].values[0].id')
@context.eval('var result = hqmf.SpecificsManager.exclude(["OccurrenceAEncounter"], pop1, pop2)')
- @context.eval('result.isTrue()').must_equal true
- @context.eval('result.specificContext.rows.length').must_equal 2
- @context.eval('result.specificContext.rows[0].values[0].id').must_equal 2
- @context.eval('result.specificContext.rows[1].values[0].id').must_equal 3
+ assert_equal true, @context.eval('result.isTrue()')
+ assert_equal 2, @context.eval('result.specificContext.rows.length')
+ assert_equal 2, @context.eval('result.specificContext.rows[0].values[0].id')
+ assert_equal 3, @context.eval('result.specificContext.rows[1].values[0].id')
@context.eval('result = hqmf.SpecificsManager.exclude(["OccurrenceBEncounter"], pop1, pop2)')
- @context.eval('result.isTrue()').must_equal true
- @context.eval('result.specificContext.rows.length').must_equal 1
- @context.eval('result.specificContext.rows[0].values[0].id').must_equal 3
+ assert_equal true, @context.eval('result.isTrue()')
+ assert_equal 1, @context.eval('result.specificContext.rows.length')
+ assert_equal 3, @context.eval('result.specificContext.rows[0].values[0].id')
@context.eval('result = hqmf.SpecificsManager.exclude(["OccurrenceAEncounter","OccurrenceBEncounter"], pop1, pop2)')
- @context.eval('result.isTrue()').must_equal true
- @context.eval('result.specificContext.rows.length').must_equal 1
- @context.eval('result.specificContext.rows[0].values[0].id').must_equal 3
+ assert_equal true, @context.eval('result.isTrue()')
+ assert_equal 1, @context.eval('result.specificContext.rows.length')
+ assert_equal 3, @context.eval('result.specificContext.rows[0].values[0].id')
@context.eval('result = hqmf.SpecificsManager.exclude(null, pop3, pop3)')
- @context.eval('result.isTrue()').must_equal false
+ assert_equal false, @context.eval('result.isTrue()')
@context.eval('result = hqmf.SpecificsManager.exclude(null, pop3, pop4)')
- @context.eval('result.isTrue()').must_equal true
+ assert_equal true, @context.eval('result.isTrue()')
@context.eval('result = hqmf.SpecificsManager.exclude(null, pop4, pop3)')
- @context.eval('result.isTrue()').must_equal false
+ assert_equal false, @context.eval('result.isTrue()')
@context.eval('result = hqmf.SpecificsManager.exclude(null, pop4, pop4)')
- @context.eval('result.isTrue()').must_equal false
+ assert_equal false, @context.eval('result.isTrue()')
end
def test_negation
rows = "
var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1}});
@@ -335,48 +358,48 @@
# test negation multiple specifics
@context.eval(rows)
# has row checks
- @context.eval('specific1.hasRow(row1)').must_equal true
- @context.eval('specific1.hasRow(row2)').must_equal true
- @context.eval('specific1.hasRow(row3)').must_equal true
- @context.eval('specific1.hasRow(row4)').must_equal false
- @context.eval('specific1.hasRow(row5)').must_equal false
+ assert_equal true, @context.eval('specific1.hasRow(row1)')
+ assert_equal true, @context.eval('specific1.hasRow(row2)')
+ assert_equal true, @context.eval('specific1.hasRow(row3)')
+ assert_equal false, @context.eval('specific1.hasRow(row4)')
+ assert_equal false, @context.eval('specific1.hasRow(row5)')
# cartesian checks
- @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3]]).length').must_equal 3
- @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]]).length').must_equal 6
- @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[0][0]').must_equal 1
- @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[0][1]').must_equal 5
- @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[1][0]').must_equal 1
- @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[1][1]').must_equal 6
- @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[2][0]').must_equal 2
- @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[2][1]').must_equal 5
+ assert_equal 3, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3]]).length')
+ assert_equal 6, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]]).length')
+ assert_equal 1, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[0][0]')
+ assert_equal 5, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[0][1]')
+ assert_equal 1, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[1][0]')
+ assert_equal 6, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[1][1]')
+ assert_equal 2, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[2][0]')
+ assert_equal 5, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[2][1]')
# specificsWithValue on Row
- @context.eval('row1.specificsWithValues()[0]').must_equal 0
- @context.eval('row2.specificsWithValues()[0]').must_equal 1
- @context.eval('row3.specificsWithValues()[0]').must_equal 0
- @context.eval('row3.specificsWithValues()[1]').must_equal 1
+ assert_equal 0, @context.eval('row1.specificsWithValues()[0]')
+ assert_equal 1, @context.eval('row2.specificsWithValues()[0]')
+ assert_equal 0, @context.eval('row3.specificsWithValues()[0]')
+ assert_equal 1, @context.eval('row3.specificsWithValues()[1]')
# specificsWithValue on Specific
- @context.eval('specific1.specificsWithValues()[0]').must_equal 0
- @context.eval('specific2.specificsWithValues()[0]').must_equal 1
- @context.eval('specific3.specificsWithValues()[0]').must_equal 0
- @context.eval('specific3.specificsWithValues()[1]').must_equal 1
- @context.eval('specific6.specificsWithValues()[0]').must_equal 0
- @context.eval('specific6.specificsWithValues()[1]').must_equal 1
+ assert_equal 0, @context.eval('specific1.specificsWithValues()[0]')
+ assert_equal 1, @context.eval('specific2.specificsWithValues()[0]')
+ assert_equal 0, @context.eval('specific3.specificsWithValues()[0]')
+ assert_equal 1, @context.eval('specific3.specificsWithValues()[1]')
+ assert_equal 0, @context.eval('specific6.specificsWithValues()[0]')
+ assert_equal 1, @context.eval('specific6.specificsWithValues()[1]')
- @context.eval('specific1.negate().rows.length').must_equal 4
- @context.eval('specific1.negate().rows[0].values[0].id').must_equal 2
- @context.eval('specific1.negate().rows[1].values[0].id').must_equal 3
- @context.eval('specific1.negate().rows[2].values[0].id').must_equal 4
- @context.eval('specific1.negate().rows[3].values[0].id').must_equal 5
+ assert_equal 4, @context.eval('specific1.negate().rows.length')
+ assert_equal 2, @context.eval('specific1.negate().rows[0].values[0].id')
+ assert_equal 3, @context.eval('specific1.negate().rows[1].values[0].id')
+ assert_equal 4, @context.eval('specific1.negate().rows[2].values[0].id')
+ assert_equal 5, @context.eval('specific1.negate().rows[3].values[0].id')
# 5*5 values = 25 in the cartesian - 2 in the non-negated = 23 negated - 5 rows with OccurrA and OccurrB equal = 18!
- @context.eval('specific5.negate().rows.length').must_equal 18
+ assert_equal 18, @context.eval('specific5.negate().rows.length')
end
def test_add_rows_has_rows_has_specifics
rows = "
@@ -392,34 +415,34 @@
# test negation single specific
# test negation multiple specifics
@context.eval(rows)
- @context.eval('specific1.hasRows()').must_equal false
- @context.eval('specific2.hasRows()').must_equal true
- @context.eval('specific1.hasSpecifics()').must_equal false
- @context.eval('specific2.hasSpecifics()').must_equal true
- @context.eval('row3.hasSpecifics()').must_equal false
- @context.eval('row2.hasSpecifics()').must_equal true
+ assert_equal false, @context.eval('specific1.hasRows()')
+ assert_equal true, @context.eval('specific2.hasRows()')
+ assert_equal false, @context.eval('specific1.hasSpecifics()')
+ assert_equal true, @context.eval('specific2.hasSpecifics()')
+ assert_equal false, @context.eval('row3.hasSpecifics()')
+ assert_equal true, @context.eval('row2.hasSpecifics()')
- @context.eval('specific1.rows.length').must_equal 0
+ assert_equal 0, @context.eval('specific1.rows.length')
@context.eval('specific1.addRows([row2])')
- @context.eval('specific1.rows.length').must_equal 1
- @context.eval('specific2.rows.length').must_equal 1
+ assert_equal 1, @context.eval('specific1.rows.length')
+ assert_equal 1, @context.eval('specific2.rows.length')
@context.eval('specific2.addRows([row3])')
- @context.eval('specific2.rows.length').must_equal 2
+ assert_equal 2, @context.eval('specific2.rows.length')
end
def test_maintain_specfics
@context.eval('var x = new Boolean(true)')
@context.eval("x.specificContext = 'specificContext'")
@context.eval("x.specific_occurrence = 'specific_occurrence'")
@context.eval('var a = new Boolean(true)')
@context.eval("a = hqmf.SpecificsManager.maintainSpecifics(a,x)")
- @context.eval("typeof(a.specificContext) != 'undefined'").must_equal true
- @context.eval("typeof(a.specific_occurrence) != 'undefined'").must_equal true
+ assert_equal true, @context.eval("typeof(a.specificContext) != 'undefined'")
+ assert_equal true, @context.eval("typeof(a.specific_occurrence) != 'undefined'")
end
def test_compact_reused_events
rows = "
@@ -433,12 +456,12 @@
var specific1 = new hqmf.SpecificOccurrence([row1,row2,row3,row4,row5,row6]);
"
@context.eval(rows)
- @context.eval('specific1.rows.length').must_equal 6
- @context.eval('specific1.compactReusedEvents().rows.length').must_equal 4
+ assert_equal 6, @context.eval('specific1.rows.length')
+ assert_equal 4, @context.eval('specific1.compactReusedEvents().rows.length')
end
def test_compact_reused_events_different_specifics
@@ -467,15 +490,73 @@
var specific1 = new hqmf.SpecificOccurrence([row1,row2,row3,row4,row5,row6]);
"
@context.eval(rows)
- @context.eval('specific1.rows.length').must_equal 6
- @context.eval('specific1.compactReusedEvents().rows.length').must_equal 6
+ assert_equal 6, @context.eval('specific1.rows.length')
+ assert_equal 6, @context.eval('specific1.compactReusedEvents().rows.length')
end
-
+
+ def test_remove_duplicate_rows
+
+ rows = "
+ var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1}});
+ var row2 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1}});
+ var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2}});
+ var row4 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2}});
+
+ var specific = new hqmf.SpecificOccurrence([row1,row2,row3,row4]);
+ "
+
+ @context.eval(rows)
+
+ assert_equal 4, @context.eval('specific.rows.length')
+ assert_equal 2, @context.eval('specific.removeDuplicateRows().rows.length')
+
+ end
+
+ def test_remove_duplicate_rows_no_duplicates
+
+ rows = "
+ var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1}});
+ var row2 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2}});
+ var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':3}});
+ var row4 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':4}});
+
+ var specific = new hqmf.SpecificOccurrence([row1,row2,row3,row4]);
+ "
+
+ @context.eval(rows)
+
+ assert_equal 4, @context.eval('specific.rows.length')
+ assert_equal 4, @context.eval('specific.removeDuplicateRows().rows.length')
+
+ end
+
+ def test_remove_duplicate_rows_temp_value
+
+ rows = "
+ var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1},undefined:{'id':1}});
+ var row2 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1},undefined:{'id':2}});
+ var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2},undefined:{'id':1}});
+ var row4 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2},undefined:{'id':2}});
+ var row5 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1},undefined:{'id':1}});
+ var row6 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1},undefined:{'id':2}});
+ var row7 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2},undefined:{'id':1}});
+ var row8 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2},undefined:{'id':2}});
+
+ var specific = new hqmf.SpecificOccurrence([row1,row2,row3,row4,row5,row6,row7,row8]);
+ "
+
+ @context.eval(rows)
+
+ assert_equal 8, @context.eval('specific.rows.length')
+ assert_equal 4, @context.eval('specific.removeDuplicateRows().rows.length')
+
+ end
+
def test_row_build_rows_for_matching
events = "
var entryKey = 'OccurrenceAEncounter';
var boundsKey = 'OccurrenceBEncounter';
@@ -483,26 +564,26 @@
var bounds = [{'id':1},{'id':2},{'id':3},{'id':4},{'id':5},{'id':6},{'id':7},{'id':8}];
"
@context.eval(events)
@context.eval('var rows = Row.buildRowsForMatching(entryKey,entry,boundsKey,bounds)')
- @context.eval('rows.length').must_equal 8
- @context.eval('rows[0].values.length').must_equal 2
- @context.eval('rows[0].values[0].id').must_equal 3
- @context.eval('rows[0].values[1].id').must_equal 1
- @context.eval('rows[7].values[0].id').must_equal 3
- @context.eval('rows[7].values[1].id').must_equal 8
+ assert_equal 8, @context.eval('rows.length')
+ assert_equal 2, @context.eval('rows[0].values.length')
+ assert_equal 3, @context.eval('rows[0].values[0].id')
+ assert_equal 1, @context.eval('rows[0].values[1].id')
+ assert_equal 3, @context.eval('rows[7].values[0].id')
+ assert_equal 8, @context.eval('rows[7].values[1].id')
@context.eval('var specific = new hqmf.SpecificOccurrence(rows)')
- @context.eval('specific.rows.length').must_equal 8
- @context.eval('specific.compactReusedEvents().rows.length').must_equal 7
+ assert_equal 8, @context.eval('specific.rows.length')
+ assert_equal 7, @context.eval('specific.compactReusedEvents().rows.length')
@context.eval('var rows = Row.buildRowsForMatching(undefined,entry,boundsKey,bounds)')
- @context.eval('rows.length').must_equal 8
- @context.eval("rows[0].tempValue.id").must_equal 3
- @context.eval("rows[5].tempValue.id").must_equal 3
- @context.eval("rows[0].tempValue.id").must_equal 3
- @context.eval("rows[0].values[1].id").must_equal 1
- @context.eval("rows[5].values[1].id").must_equal 6
+ assert_equal 8, @context.eval('rows.length')
+ assert_equal 3, @context.eval("rows[0].nonSpecificLeftMost.id")
+ assert_equal 3, @context.eval("rows[5].nonSpecificLeftMost.id")
+ assert_equal 3, @context.eval("rows[0].nonSpecificLeftMost.id")
+ assert_equal 1, @context.eval("rows[0].values[1].id")
+ assert_equal 6, @context.eval("rows[5].values[1].id")
end
def test_row_build_for_data_criteria
events = "
@@ -510,16 +591,16 @@
var entries = [{'id':1},{'id':2},{'id':3},{'id':4},{'id':5},{'id':6},{'id':7},{'id':8}];
"
@context.eval(events)
@context.eval('var rows = Row.buildForDataCriteria(entryKey,entries)')
- @context.eval('rows.length').must_equal 8
- @context.eval('rows[0].values.length').must_equal 2
- @context.eval('rows[0].values[0].id').must_equal 1
- @context.eval('rows[0].values[1]').must_equal '*'
- @context.eval('rows[7].values[0].id').must_equal 8
- @context.eval('rows[7].values[1]').must_equal '*'
+ assert_equal 8, @context.eval('rows.length')
+ assert_equal 2, @context.eval('rows[0].values.length')
+ assert_equal 1, @context.eval('rows[0].values[0].id')
+ assert_equal '*', @context.eval('rows[0].values[1]')
+ assert_equal 8, @context.eval('rows[7].values[0].id')
+ assert_equal '*', @context.eval('rows[7].values[1]')
end
def test_finalize_events
rows = "
@@ -536,27 +617,27 @@
var specific2 = new hqmf.SpecificOccurrence([row3,row4,row5]);
var specific3 = new hqmf.SpecificOccurrence([row6,row7,row8]);
"
@context.eval(rows)
@context.eval('var result = specific1.finalizeEvents(specific2,specific3)')
- @context.eval('result.rows.length').must_equal 3
- @context.eval('result.rows[0].values[0].id').must_equal 1
- @context.eval('result.rows[0].values[1].id').must_equal 4
- @context.eval('result.rows[1].values[0].id').must_equal 1
- @context.eval('result.rows[1].values[1].id').must_equal 5
- @context.eval('result.rows[2].values[0].id').must_equal 2
- @context.eval('result.rows[2].values[1].id').must_equal 4
+ assert_equal 3, @context.eval('result.rows.length')
+ assert_equal 1, @context.eval('result.rows[0].values[0].id')
+ assert_equal 4, @context.eval('result.rows[0].values[1].id')
+ assert_equal 1, @context.eval('result.rows[1].values[0].id')
+ assert_equal 5, @context.eval('result.rows[1].values[1].id')
+ assert_equal 2, @context.eval('result.rows[2].values[0].id')
+ assert_equal 4, @context.eval('result.rows[2].values[1].id')
@context.eval('var result = specific2.finalizeEvents(specific1,specific3)')
- @context.eval('result.rows.length').must_equal 3
+ assert_equal 3, @context.eval('result.rows.length')
@context.eval('var result = specific1.finalizeEvents(null,specific3)')
- @context.eval('result.rows.length').must_equal 3
+ assert_equal 3, @context.eval('result.rows.length')
# result if 5 and not 6 becasue the 2/2 row gets dropped
@context.eval('var result = specific1.finalizeEvents(specific2, null)')
- @context.eval('result.rows.length').must_equal 5
+ assert_equal 5, @context.eval('result.rows.length')
end
def test_validate
rows = "
@@ -596,14 +677,14 @@
pop3f.specificContext = specific3
"
@context.eval(rows)
- @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop3)))').must_equal true
- @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop4)))').must_equal false
- @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop5)))').must_equal false
- @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop3f,hqmf.SpecificsManager.intersectSpecifics(pop1,pop2)))').must_equal false
+ assert_equal true, @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop3)))')
+ assert_equal false, @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop4)))')
+ assert_equal false, @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop5)))')
+ assert_equal false, @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop3f,hqmf.SpecificsManager.intersectSpecifics(pop1,pop2)))')
end
def test_episode_of_care_restrictions
@@ -632,66 +713,66 @@
"
@context.eval(rows)
# test allValuesAny
- @context.eval('row1.allValuesAny([0,1,2])').must_equal false
- @context.eval('row1.allValuesAny([1,2])').must_equal true
- @context.eval('row1.allValuesAny([2])').must_equal true
- @context.eval('row1.allValuesAny([1])').must_equal true
- @context.eval('row1.allValuesAny([])').must_equal true
- @context.eval('identityRow.allValuesAny([0,1,2])').must_equal true
+ assert_equal false, @context.eval('row1.allValuesAny([0,1,2])')
+ assert_equal true, @context.eval('row1.allValuesAny([1,2])')
+ assert_equal true, @context.eval('row1.allValuesAny([2])')
+ assert_equal true, @context.eval('row1.allValuesAny([1])')
+ assert_equal true, @context.eval('row1.allValuesAny([])')
+ assert_equal true, @context.eval('identityRow.allValuesAny([0,1,2])')
# test checkEpisodeOfCare
- @context.eval('Row.checkEpisodeOfCare({id: 1}, true) == hqmf.SpecificsManager.any').must_equal true
- @context.eval('Row.checkEpisodeOfCare({id: 1}, false) == hqmf.SpecificsManager.any').must_equal false
- @context.eval('Row.checkEpisodeOfCare({id: 1}, false).id == 1').must_equal true
+ assert_equal true, @context.eval('Row.checkEpisodeOfCare({id: 1}, true) == hqmf.SpecificsManager.any')
+ assert_equal false, @context.eval('Row.checkEpisodeOfCare({id: 1}, false) == hqmf.SpecificsManager.any')
+ assert_equal true, @context.eval('Row.checkEpisodeOfCare({id: 1}, false).id == 1')
# test intersect
- @context.eval('row1.intersect(row2,[0,1]).allValuesAny([0,1,2])').must_equal true # this is the critical check. Make sure we drop bad episode of care intersections
- @context.eval('row1.intersect(row2,[0]).allValuesAny([2])').must_equal true
- @context.eval('row1.intersect(row2,[0]).values[0].id == 1').must_equal true
- @context.eval('row1.intersect(row2,[0]).values[1].id == 3').must_equal true
- @context.eval('row1.intersect(row2,[1]).allValuesAny([2])').must_equal true
- @context.eval('row1.intersect(row2,[1]).values[0].id == 1').must_equal true
- @context.eval('row1.intersect(row2,[1]).values[1].id == 3').must_equal true
+ assert_equal true, @context.eval('row1.intersect(row2,[0,1]).allValuesAny([0,1,2])') # this is the critical check. Make sure we drop bad episode of care intersections
+ assert_equal true, @context.eval('row1.intersect(row2,[0]).allValuesAny([2])')
+ assert_equal true, @context.eval('row1.intersect(row2,[0]).values[0].id == 1')
+ assert_equal true, @context.eval('row1.intersect(row2,[0]).values[1].id == 3')
+ assert_equal true, @context.eval('row1.intersect(row2,[1]).allValuesAny([2])')
+ assert_equal true, @context.eval('row1.intersect(row2,[1]).values[0].id == 1')
+ assert_equal true, @context.eval('row1.intersect(row2,[1]).values[1].id == 3')
- @context.eval('identityRow.intersect(row1,[0]).values[0].id == 1').must_equal true
- @context.eval('identityRow.intersect(row1,[0]).allValuesAny([1,2])').must_equal true
- @context.eval('row1.intersect(identityRow,[0]).values[0].id == 1').must_equal true
- @context.eval('row1.intersect(identityRow,[0]).allValuesAny([1,2])').must_equal true
+ assert_equal true, @context.eval('identityRow.intersect(row1,[0]).values[0].id == 1')
+ assert_equal true, @context.eval('identityRow.intersect(row1,[0]).allValuesAny([1,2])')
+ assert_equal true, @context.eval('row1.intersect(identityRow,[0]).values[0].id == 1')
+ assert_equal true, @context.eval('row1.intersect(identityRow,[0]).allValuesAny([1,2])')
# make sure we drop a bad strggler for encounter 2
- @context.eval('row1.intersect(row3,[0,1]).allValuesAny([1,2])').must_equal true
- @context.eval('row1.intersect(row3,[0,1]).values[0].id == 1').must_equal true
+ assert_equal true, @context.eval('row1.intersect(row3,[0,1]).allValuesAny([1,2])')
+ assert_equal true, @context.eval('row1.intersect(row3,[0,1]).values[0].id == 1')
# test intersectSpecifics
- @context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[0].id == 1').must_equal true
- @context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[1].id == 3').must_equal true
- @context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[2] == hqmf.SpecificsManager.any').must_equal true
- @context.eval("hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,['OccurrenceAEncounter1','OccurrenceAEncounter2','OccurrenceAEncounter3']).specificContext.rows[0].allValuesAny([0,1,2])").must_equal true
+ assert_equal true, @context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[0].id == 1')
+ assert_equal true, @context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[1].id == 3')
+ assert_equal true, @context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[2] == hqmf.SpecificsManager.any')
+ assert_equal true, @context.eval("hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,['OccurrenceAEncounter1','OccurrenceAEncounter2','OccurrenceAEncounter3']).specificContext.rows[0].allValuesAny([0,1,2])")
@context.eval("result = hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,['OccurrenceAEncounter1']).specificContext.rows[0]")
- @context.eval('result.allValuesAny([2])').must_equal true
- @context.eval('result.values[0].id == 1').must_equal true
- @context.eval('result.values[1].id == 3').must_equal true
+ assert_equal true, @context.eval('result.allValuesAny([2])')
+ assert_equal true, @context.eval('result.values[0].id == 1')
+ assert_equal true, @context.eval('result.values[1].id == 3')
@context.eval("result = hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,['OccurrenceAEncounter2']).specificContext.rows[0]")
- @context.eval('result.allValuesAny([2])').must_equal true
- @context.eval('result.values[0].id == 1').must_equal true
- @context.eval('result.values[1].id == 3').must_equal true
+ assert_equal true, @context.eval('result.allValuesAny([2])')
+ assert_equal true, @context.eval('result.values[0].id == 1')
+ assert_equal true, @context.eval('result.values[1].id == 3')
@context.eval("result = hqmf.SpecificsManager.intersectSpecifics(pop1,pop4,['OccurrenceAEncounter1']).specificContext.rows[0]")
- @context.eval('result.values[0].id == 1').must_equal true
- @context.eval('result.allValuesAny([1,2])').must_equal true
+ assert_equal true, @context.eval('result.values[0].id == 1')
+ assert_equal true, @context.eval('result.allValuesAny([1,2])')
@context.eval("result = hqmf.SpecificsManager.intersectSpecifics(pop4,pop1,['OccurrenceAEncounter1']).specificContext.rows[0]")
- @context.eval('result.values[0].id == 1').must_equal true
- @context.eval('result.allValuesAny([1,2])').must_equal true
+ assert_equal true, @context.eval('result.values[0].id == 1')
+ assert_equal true, @context.eval('result.allValuesAny([1,2])')
@context.eval("result = hqmf.SpecificsManager.intersectSpecifics(pop1,pop3,['OccurrenceAEncounter1','OccurrenceAEncounter2']).specificContext.rows[0]")
- @context.eval('result.allValuesAny([1,2])').must_equal true
- @context.eval('result.values[0].id == 1').must_equal true
+ assert_equal true, @context.eval('result.allValuesAny([1,2])')
+ assert_equal true, @context.eval('result.values[0].id == 1')
end
def test_intersect_all
@@ -724,24 +805,24 @@
@context.eval('var intersection = hqmf.SpecificsManager.intersectAll(new Boolean(true), [pop1,pop2,pop3])')
assert @context.eval('intersection.isTrue()')
@context.eval('var result = intersection.specificContext')
- @context.eval('result.rows.length').must_equal 3
+ assert_equal 3, @context.eval('result.rows.length')
- @context.eval('result.rows[0].values[0].id').must_equal 1
- @context.eval('result.rows[0].values[1].id').must_equal 4
- @context.eval('result.rows[1].values[0].id').must_equal 1
- @context.eval('result.rows[1].values[1].id').must_equal 5
- @context.eval('result.rows[2].values[0].id').must_equal 2
- @context.eval('result.rows[2].values[1].id').must_equal 4
+ assert_equal 1, @context.eval('result.rows[0].values[0].id')
+ assert_equal 4, @context.eval('result.rows[0].values[1].id')
+ assert_equal 1, @context.eval('result.rows[1].values[0].id')
+ assert_equal 5, @context.eval('result.rows[1].values[1].id')
+ assert_equal 2, @context.eval('result.rows[2].values[0].id')
+ assert_equal 4, @context.eval('result.rows[2].values[1].id')
@context.eval('var intersection = hqmf.SpecificsManager.intersectAll(new Boolean(true), [pop1,pop2,pop3], true)')
@context.eval('var result = intersection.specificContext')
# 5*5 = 25 - 5 equal rows - 3 non-negated = 17
- @context.eval('result.rows.length').must_equal 17
+ assert_equal 17, @context.eval('result.rows.length')
end
def test_union_all
@@ -774,20 +855,20 @@
@context.eval('var union = hqmf.SpecificsManager.unionAll(new Boolean(true), [pop1,pop2,pop3])')
assert @context.eval('union.isTrue()')
@context.eval('var result = union.specificContext')
- @context.eval('result.rows.length').must_equal 8
+ assert_equal 8, @context.eval('result.rows.length')
@context.eval('var union = hqmf.SpecificsManager.unionAll(new Boolean(true), [pop1,pop2,pop3], true)')
assert @context.eval('union.isTrue()')
@context.eval('var result = union.specificContext')
# originally 5*5, but we remove 1,2 from the left and 2,4,5 from the right
# that leaves [3,4,5] x [1,3] which is 6 rows... minus the 3,3 row we get 5 rows
- @context.eval('result.rows.length').must_equal 5
+ assert_equal 5, @context.eval('result.rows.length')
end
def test_row_grouping_key
@@ -800,21 +881,21 @@
var row4 = new Row(undefined, {});
"
@context.eval(rows)
- @context.eval("row1.groupKey()").must_equal "1_*_*_"
- @context.eval("row1.groupKey('OccurrenceAEncounter')").must_equal "X_*_*_"
- @context.eval("row1.groupKey('OccurrenceAProcedure')").must_equal "1_*_X_"
- @context.eval("row2.groupKey()").must_equal "*_2_*_"
- @context.eval("row2.groupKey('OccurrenceAProcedure')").must_equal "*_2_X_"
- @context.eval("row3.groupKey()").must_equal "1_4_*_"
- @context.eval("row3.groupKey('OccurrenceAEncounter')").must_equal "X_4_*_"
- @context.eval("row3.groupKey('OccurrenceBEncounter')").must_equal "1_X_*_"
- @context.eval("row3.groupKey('OccurrenceAProcedure')").must_equal "1_4_X_"
- @context.eval("row4.groupKey()").must_equal "*_*_*_"
- @context.eval("row4.groupKey('OccurrenceBEncounter')").must_equal "*_X_*_"
+ assert_equal "1_*_*_", @context.eval("row1.groupKey()")
+ assert_equal "X_*_*_", @context.eval("row1.groupKey('OccurrenceAEncounter')")
+ assert_equal "1_*_X_", @context.eval("row1.groupKey('OccurrenceAProcedure')")
+ assert_equal "*_2_*_", @context.eval("row2.groupKey()")
+ assert_equal "*_2_X_", @context.eval("row2.groupKey('OccurrenceAProcedure')")
+ assert_equal "1_4_*_", @context.eval("row3.groupKey()")
+ assert_equal "X_4_*_", @context.eval("row3.groupKey('OccurrenceAEncounter')")
+ assert_equal "1_X_*_", @context.eval("row3.groupKey('OccurrenceBEncounter')")
+ assert_equal "1_4_X_", @context.eval("row3.groupKey('OccurrenceAProcedure')")
+ assert_equal "*_*_*_", @context.eval("row4.groupKey()")
+ assert_equal "*_X_*_", @context.eval("row4.groupKey('OccurrenceBEncounter')")
end
def test_group_specifics
@@ -837,17 +918,17 @@
var specific2 = new hqmf.SpecificOccurrence(specific_rows);
"
@context.eval(rows)
- @context.eval("specific1.group()['1_*_'].length").must_equal 2
- @context.eval("specific1.group()['2_*_'].length").must_equal 3
- @context.eval("specific1.group()['3_*_'].length").must_equal 1
+ assert_equal 2, @context.eval("specific1.group()['1_*_'].length")
+ assert_equal 3, @context.eval("specific1.group()['2_*_'].length")
+ assert_equal 1, @context.eval("specific1.group()['3_*_'].length")
- @context.eval("specific2.group('OccurrenceAEncounter')['X_1_'].length").must_equal 2
- @context.eval("specific2.group('OccurrenceAEncounter')['X_2_'].length").must_equal 3
- @context.eval("specific2.group('OccurrenceAEncounter')['X_3_'].length").must_equal 1
+ assert_equal 2, @context.eval("specific2.group('OccurrenceAEncounter')['X_1_'].length")
+ assert_equal 3, @context.eval("specific2.group('OccurrenceAEncounter')['X_2_'].length")
+ assert_equal 1, @context.eval("specific2.group('OccurrenceAEncounter')['X_3_'].length")
end
def test_extract_events
rows = "
@@ -864,26 +945,26 @@
new Row('OccurrenceAEncounter',{'OccurrenceAEncounter': new hQuery.CodedEntry({_id:13}), 'OccurrenceBEncounter':new hQuery.CodedEntry({'_id':2})}),
new Row('OccurrenceAEncounter',{'OccurrenceAEncounter': new hQuery.CodedEntry({_id:14}), 'OccurrenceBEncounter':new hQuery.CodedEntry({'_id':2})}),
new Row('OccurrenceAEncounter',{'OccurrenceAEncounter': new hQuery.CodedEntry({_id:15}), 'OccurrenceBEncounter':new hQuery.CodedEntry({'_id':3})})]
"
@context.eval(rows)
- @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows).length').must_equal 6
- @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[0].id').must_equal '10'
- @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[1].id').must_equal '11'
- @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[2].id').must_equal '12'
- @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[3].id').must_equal '13'
- @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[4].id').must_equal '14'
- @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[5].id').must_equal '15'
+ assert_equal 6, @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows).length')
+ assert_equal '10', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[0].id')
+ assert_equal '11', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[1].id')
+ assert_equal '12', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[2].id')
+ assert_equal '13', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[3].id')
+ assert_equal '14', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[4].id')
+ assert_equal '15', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[5].id')
+
+ assert_equal 6, @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows).length")
+ assert_equal '10', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[0].id")
+ assert_equal '11', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[1].id")
+ assert_equal '12', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[2].id")
+ assert_equal '13', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[3].id")
+ assert_equal '14', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[4].id")
+ assert_equal '15', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[5].id")
- @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows).length").must_equal 6
- @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[0].id").must_equal '10'
- @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[1].id").must_equal '11'
- @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[2].id").must_equal '12'
- @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[3].id").must_equal '13'
- @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[4].id").must_equal '14'
- @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[5].id").must_equal '15'
-
end
def test_specifics_subset_operators
rows = "
@@ -920,71 +1001,71 @@
moreThanOne = 'new IVL_PQ(new PQ(2))'
lessThanThree = 'new IVL_PQ(null, new PQ(2))'
exactly1 = 'new IVL_PQ(new PQ(1), new PQ(1))'
- @context.eval("specific1.COUNT(#{moreThanOne}).rows.length").must_equal 5
- @context.eval("specific1.COUNT(#{moreThanOne}).rows[0].tempValue.id").must_equal '10'
- @context.eval("specific1.COUNT(#{moreThanOne}).rows[1].tempValue.id").must_equal '11'
- @context.eval("specific1.COUNT(#{moreThanOne}).rows[2].tempValue.id").must_equal '12'
- @context.eval("specific1.COUNT(#{moreThanOne}).rows[3].tempValue.id").must_equal '13'
- @context.eval("specific1.COUNT(#{moreThanOne}).rows[4].tempValue.id").must_equal '14'
- @context.eval("specific1.COUNT(#{lessThanThree}).rows.length").must_equal 3
- @context.eval("specific1.COUNT(#{lessThanThree}).rows[0].tempValue.id").must_equal '10'
- @context.eval("specific1.COUNT(#{lessThanThree}).rows[1].tempValue.id").must_equal '11'
- @context.eval("specific1.COUNT(#{lessThanThree}).rows[2].tempValue.id").must_equal '15'
- @context.eval("specific1.COUNT(#{exactly1}).rows.length").must_equal 1
- @context.eval("specific1.COUNT(#{exactly1}).rows[0].tempValue.id").must_equal '15'
+ assert_equal 5, @context.eval("specific1.COUNT(#{moreThanOne}).rows.length")
+ assert_equal '10', @context.eval("specific1.COUNT(#{moreThanOne}).rows[0].nonSpecificLeftMost.id")
+ assert_equal '11', @context.eval("specific1.COUNT(#{moreThanOne}).rows[1].nonSpecificLeftMost.id")
+ assert_equal '12', @context.eval("specific1.COUNT(#{moreThanOne}).rows[2].nonSpecificLeftMost.id")
+ assert_equal '13', @context.eval("specific1.COUNT(#{moreThanOne}).rows[3].nonSpecificLeftMost.id")
+ assert_equal '14', @context.eval("specific1.COUNT(#{moreThanOne}).rows[4].nonSpecificLeftMost.id")
+ assert_equal 3, @context.eval("specific1.COUNT(#{lessThanThree}).rows.length")
+ assert_equal '10', @context.eval("specific1.COUNT(#{lessThanThree}).rows[0].nonSpecificLeftMost.id")
+ assert_equal '11', @context.eval("specific1.COUNT(#{lessThanThree}).rows[1].nonSpecificLeftMost.id")
+ assert_equal '15', @context.eval("specific1.COUNT(#{lessThanThree}).rows[2].nonSpecificLeftMost.id")
+ assert_equal 1, @context.eval("specific1.COUNT(#{exactly1}).rows.length")
+ assert_equal '15', @context.eval("specific1.COUNT(#{exactly1}).rows[0].nonSpecificLeftMost.id")
- @context.eval("specific2.COUNT(#{moreThanOne}).rows.length").must_equal 5
- @context.eval("specific2.COUNT(#{moreThanOne}).rows[0].values[0].id").must_equal '10'
- @context.eval("specific2.COUNT(#{moreThanOne}).rows[1].values[0].id").must_equal '11'
- @context.eval("specific2.COUNT(#{moreThanOne}).rows[2].values[0].id").must_equal '12'
- @context.eval("specific2.COUNT(#{moreThanOne}).rows[3].values[0].id").must_equal '13'
- @context.eval("specific2.COUNT(#{moreThanOne}).rows[4].values[0].id").must_equal '14'
- @context.eval("specific2.COUNT(#{lessThanThree}).rows.length").must_equal 3
- @context.eval("specific2.COUNT(#{lessThanThree}).rows[0].values[0].id").must_equal '10'
- @context.eval("specific2.COUNT(#{lessThanThree}).rows[1].values[0].id").must_equal '11'
- @context.eval("specific2.COUNT(#{lessThanThree}).rows[2].values[0].id").must_equal '15'
- @context.eval("specific2.COUNT(#{exactly1}).rows.length").must_equal 1
- @context.eval("specific2.COUNT(#{exactly1}).rows[0].values[0].id").must_equal '15'
+ assert_equal 5, @context.eval("specific2.COUNT(#{moreThanOne}).rows.length")
+ assert_equal '10', @context.eval("specific2.COUNT(#{moreThanOne}).rows[0].values[0].id")
+ assert_equal '11', @context.eval("specific2.COUNT(#{moreThanOne}).rows[1].values[0].id")
+ assert_equal '12', @context.eval("specific2.COUNT(#{moreThanOne}).rows[2].values[0].id")
+ assert_equal '13', @context.eval("specific2.COUNT(#{moreThanOne}).rows[3].values[0].id")
+ assert_equal '14', @context.eval("specific2.COUNT(#{moreThanOne}).rows[4].values[0].id")
+ assert_equal 3, @context.eval("specific2.COUNT(#{lessThanThree}).rows.length")
+ assert_equal '10', @context.eval("specific2.COUNT(#{lessThanThree}).rows[0].values[0].id")
+ assert_equal '11', @context.eval("specific2.COUNT(#{lessThanThree}).rows[1].values[0].id")
+ assert_equal '15', @context.eval("specific2.COUNT(#{lessThanThree}).rows[2].values[0].id")
+ assert_equal 1, @context.eval("specific2.COUNT(#{exactly1}).rows.length")
+ assert_equal '15', @context.eval("specific2.COUNT(#{exactly1}).rows[0].values[0].id")
- @context.eval("specific3.COUNT(#{exactly1}).rows.length").must_equal 1
- @context.eval("specific4.COUNT(#{moreThanOne}).rows.length").must_equal 0
+ assert_equal 1, @context.eval("specific3.COUNT(#{exactly1}).rows.length")
+ assert_equal 0, @context.eval("specific4.COUNT(#{moreThanOne}).rows.length")
###
##### FIRST
###
- @context.eval("specific1.FIRST().rows.length").must_equal 3
- @context.eval("specific1.FIRST().rows[0].tempValue.id").must_equal '11'
- @context.eval("specific1.FIRST().rows[1].tempValue.id").must_equal '12'
- @context.eval("specific1.FIRST().rows[2].tempValue.id").must_equal '15'
+ assert_equal 3, @context.eval("specific1.FIRST().rows.length")
+ assert_equal '11', @context.eval("specific1.FIRST().rows[0].nonSpecificLeftMost.id")
+ assert_equal '12', @context.eval("specific1.FIRST().rows[1].nonSpecificLeftMost.id")
+ assert_equal '15', @context.eval("specific1.FIRST().rows[2].nonSpecificLeftMost.id")
- @context.eval("specific2.FIRST().rows.length").must_equal 3
- @context.eval("specific2.FIRST().rows[0].values[0].id").must_equal '11'
- @context.eval("specific2.FIRST().rows[1].values[0].id").must_equal '12'
- @context.eval("specific2.FIRST().rows[2].values[0].id").must_equal '15'
+ assert_equal 3, @context.eval("specific2.FIRST().rows.length")
+ assert_equal '11', @context.eval("specific2.FIRST().rows[0].values[0].id")
+ assert_equal '12', @context.eval("specific2.FIRST().rows[1].values[0].id")
+ assert_equal '15', @context.eval("specific2.FIRST().rows[2].values[0].id")
- @context.eval("specific3.FIRST().rows.length").must_equal 1
- @context.eval("specific4.FIRST().rows.length").must_equal 0
+ assert_equal 1, @context.eval("specific3.FIRST().rows.length")
+ assert_equal 0, @context.eval("specific4.FIRST().rows.length")
###
##### MOST RECENT
###
- @context.eval("specific1.RECENT().rows.length").must_equal 3
- @context.eval("specific1.RECENT().rows[0].tempValue.id").must_equal '10'
- @context.eval("specific1.RECENT().rows[1].tempValue.id").must_equal '13'
- @context.eval("specific1.RECENT().rows[2].tempValue.id").must_equal '15'
+ assert_equal 3, @context.eval("specific1.RECENT().rows.length")
+ assert_equal '10', @context.eval("specific1.RECENT().rows[0].nonSpecificLeftMost.id")
+ assert_equal '13', @context.eval("specific1.RECENT().rows[1].nonSpecificLeftMost.id")
+ assert_equal '15', @context.eval("specific1.RECENT().rows[2].nonSpecificLeftMost.id")
- @context.eval("specific2.RECENT().rows.length").must_equal 3
- @context.eval("specific2.RECENT().rows[0].values[0].id").must_equal '10'
- @context.eval("specific2.RECENT().rows[1].values[0].id").must_equal '13'
- @context.eval("specific2.RECENT().rows[2].values[0].id").must_equal '15'
+ assert_equal 3, @context.eval("specific2.RECENT().rows.length")
+ assert_equal '10', @context.eval("specific2.RECENT().rows[0].values[0].id")
+ assert_equal '13', @context.eval("specific2.RECENT().rows[1].values[0].id")
+ assert_equal '15', @context.eval("specific2.RECENT().rows[2].values[0].id")
- @context.eval("specific3.RECENT().rows.length").must_equal 1
- @context.eval("specific4.RECENT().rows.length").must_equal 0
+ assert_equal 1, @context.eval("specific3.RECENT().rows.length")
+ assert_equal 0, @context.eval("specific4.RECENT().rows.length")
end
end