hqmf2js 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.travis.yml +1 -1
- data/Gemfile +1 -25
- data/Gemfile.lock +170 -146
- data/app/assets/javascripts/crosswalk.js.coffee +17 -19
- data/app/assets/javascripts/custom_calculations.js.coffee +44 -17
- data/app/assets/javascripts/hqmf_util.js.coffee +559 -161
- data/app/assets/javascripts/logging_utils.js.coffee +6 -4
- data/app/assets/javascripts/patient_api_extension.js.coffee +41 -9
- data/app/assets/javascripts/specifics.js.coffee +163 -69
- data/hqmf2js.gemspec +7 -12
- data/lib/assets/javascripts/libraries/map_reduce_utils.js +151 -64
- data/lib/generator/characteristic.js.erb +23 -12
- data/lib/generator/codes_to_json.rb +1 -1
- data/lib/generator/data_criteria.js.erb +15 -3
- data/lib/generator/derived_data.js.erb +5 -0
- data/lib/generator/execution.rb +41 -11
- data/lib/generator/js.rb +74 -41
- data/lib/generator/patient_data.js.erb +1 -1
- data/lib/hqmf2js.rb +0 -1
- data/lib/hquery/engine.rb +3 -1
- data/lib/tasks/convert.rake +20 -12
- data/test/fixtures/NQF59New.json +1423 -0
- data/test/fixtures/fulfills.xml +917 -0
- data/test/fixtures/patients/larry_vanderman.json +573 -654
- data/test/{simplecov.rb → simplecov_init.rb} +0 -0
- data/test/test_helper.rb +2 -3
- data/test/unit/cmd_test.rb +145 -19
- data/test/unit/codes_to_json_test.rb +12 -12
- data/test/unit/custom_calculations_test.rb +2 -6
- data/test/unit/effective_date_test.rb +3 -4
- data/test/unit/erb_context_test.rb +12 -12
- data/test/unit/filter_by_reference_test.rb +39 -0
- data/test/unit/hqmf_from_json_javascript_test.rb +2 -1
- data/test/unit/hqmf_javascript_test.rb +12 -13
- data/test/unit/js_object_test.rb +2 -2
- data/test/unit/library_function_test.rb +210 -42
- data/test/unit/specifics_test.rb +402 -321
- metadata +57 -15
- data/config/warble.rb +0 -144
data/test/unit/js_object_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
require 'hquery-patient-api'
|
3
3
|
|
4
|
-
class JSObjectTest < Test
|
4
|
+
class JSObjectTest < Minitest::Test
|
5
5
|
|
6
6
|
def setup
|
7
7
|
end
|
@@ -17,7 +17,7 @@ class JSObjectTest < Test::Unit::TestCase
|
|
17
17
|
criteria = HQMF::DataCriteria.from_json(nil, JSON.parse(File.read(File.join('test','fixtures','json','data_criteria','specific_occurrence.json'))))
|
18
18
|
expected = "hqmfjs.initializeSpecifics = function(patient_api, hqmfjs) { hqmf.SpecificsManager.initialize(patient_api,hqmfjs,{\"id\":\"\",\"type\":\"ENCOUNTER_PERFORMED_INPATIENT_ENCOUNTER\",\"function\":\"OccurrenceAInpatientEncounter1\"}) }"
|
19
19
|
result = js.js_initialize_specifics([criteria])
|
20
|
-
|
20
|
+
assert_equal expected, result
|
21
21
|
end
|
22
22
|
|
23
23
|
def test_to_js_without_codes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
require 'hquery-patient-api'
|
3
3
|
|
4
|
-
class LibraryFunctionTest < Test
|
4
|
+
class LibraryFunctionTest < Minitest::Test
|
5
5
|
|
6
6
|
def setup
|
7
7
|
@context = get_js_context(HQMF2JS::Generator::JS.library_functions)
|
@@ -10,57 +10,57 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
10
10
|
|
11
11
|
|
12
12
|
def test_library_function_parses
|
13
|
-
@context.eval('hQuery == undefined')
|
14
|
-
@context.eval('typeof hQuery.Patient')
|
15
|
-
@context.eval('typeof allTrue')
|
16
|
-
@context.eval('typeof atLeastOneTrue')
|
13
|
+
assert_equal false, @context.eval('hQuery == undefined')
|
14
|
+
assert_equal "function", @context.eval('typeof hQuery.Patient')
|
15
|
+
assert_equal "function", @context.eval('typeof allTrue')
|
16
|
+
assert_equal "function", @context.eval('typeof atLeastOneTrue')
|
17
17
|
end
|
18
18
|
|
19
19
|
def test_all_true
|
20
|
-
@context.eval('allTrue(1,null,null,new Boolean(false),new Boolean(false),new Boolean(false))().isTrue()')
|
21
|
-
@context.eval('allTrue(1,null,null,new Boolean(false),new Boolean(true),new Boolean(false))().isTrue()')
|
22
|
-
@context.eval('allTrue(1,null,null,new Boolean(true),new Boolean(true),new Boolean(true))().isTrue()')
|
23
|
-
@context.eval('allTrue(1,null,null)().isTrue()')
|
20
|
+
assert_equal false, @context.eval('allTrue(1,null,null,new Boolean(false),new Boolean(false),new Boolean(false))().isTrue()')
|
21
|
+
assert_equal false, @context.eval('allTrue(1,null,null,new Boolean(false),new Boolean(true),new Boolean(false))().isTrue()')
|
22
|
+
assert_equal true, @context.eval('allTrue(1,null,null,new Boolean(true),new Boolean(true),new Boolean(true))().isTrue()')
|
23
|
+
assert_equal false, @context.eval('allTrue(1,null,null)().isTrue()')
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_at_least_one_true
|
27
|
-
@context.eval('atLeastOneTrue(1,null,null,new Boolean(true),new Boolean(false),new Boolean(false))().isTrue()')
|
28
|
-
@context.eval('atLeastOneTrue(1,null,null,new Boolean(true),new Boolean(true),new Boolean(true))().isTrue()')
|
29
|
-
@context.eval('atLeastOneTrue(1,null,null,new Boolean(false),new Boolean(false),new Boolean(false))().isTrue()')
|
30
|
-
@context.eval('atLeastOneTrue(1,null,null)().isTrue()')
|
27
|
+
assert_equal true, @context.eval('atLeastOneTrue(1,null,null,new Boolean(true),new Boolean(false),new Boolean(false))().isTrue()')
|
28
|
+
assert_equal true, @context.eval('atLeastOneTrue(1,null,null,new Boolean(true),new Boolean(true),new Boolean(true))().isTrue()')
|
29
|
+
assert_equal false, @context.eval('atLeastOneTrue(1,null,null,new Boolean(false),new Boolean(false),new Boolean(false))().isTrue()')
|
30
|
+
assert_equal false, @context.eval('atLeastOneTrue(1,null,null)().isTrue()')
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_all_false
|
34
|
-
@context.eval('allFalse(1,null,null,new Boolean(false),new Boolean(false),new Boolean(false))().isTrue()')
|
35
|
-
@context.eval('allFalse(1,null,null,new Boolean(false),new Boolean(true),new Boolean(false))().isTrue()')
|
36
|
-
@context.eval('allFalse(1,null,null,new Boolean(true),new Boolean(true),new Boolean(true))().isTrue()')
|
37
|
-
@context.eval('allFalse(1,null,null)().isTrue()')
|
34
|
+
assert_equal true, @context.eval('allFalse(1,null,null,new Boolean(false),new Boolean(false),new Boolean(false))().isTrue()')
|
35
|
+
assert_equal false, @context.eval('allFalse(1,null,null,new Boolean(false),new Boolean(true),new Boolean(false))().isTrue()')
|
36
|
+
assert_equal false, @context.eval('allFalse(1,null,null,new Boolean(true),new Boolean(true),new Boolean(true))().isTrue()')
|
37
|
+
assert_equal false, @context.eval('allFalse(1,null,null)().isTrue()')
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_at_least_one_false
|
41
|
-
@context.eval('atLeastOneFalse(1,null,null,new Boolean(true),new Boolean(false),new Boolean(false))().isTrue()')
|
42
|
-
@context.eval('atLeastOneFalse(1,null,null,new Boolean(true),new Boolean(true),new Boolean(true))().isTrue()')
|
43
|
-
@context.eval('atLeastOneFalse(1,null,null,new Boolean(false),new Boolean(false),new Boolean(false))().isTrue()')
|
44
|
-
@context.eval('atLeastOneFalse(1,null,null)().isTrue()')
|
41
|
+
assert_equal true, @context.eval('atLeastOneFalse(1,null,null,new Boolean(true),new Boolean(false),new Boolean(false))().isTrue()')
|
42
|
+
assert_equal false, @context.eval('atLeastOneFalse(1,null,null,new Boolean(true),new Boolean(true),new Boolean(true))().isTrue()')
|
43
|
+
assert_equal true, @context.eval('atLeastOneFalse(1,null,null,new Boolean(false),new Boolean(false),new Boolean(false))().isTrue()')
|
44
|
+
assert_equal false, @context.eval('atLeastOneFalse(1,null,null)().isTrue()')
|
45
45
|
end
|
46
46
|
|
47
47
|
def test_patient_extensions
|
48
|
-
@context.eval('typeof hQuery.Patient.prototype.procedureResults')
|
49
|
-
@context.eval('typeof hQuery.Patient.prototype.laboratoryTests')
|
50
|
-
@context.eval('typeof hQuery.Patient.prototype.allMedications')
|
51
|
-
@context.eval('typeof hQuery.Patient.prototype.allProblems')
|
52
|
-
@context.eval('typeof hQuery.Patient.prototype.allDevices')
|
53
|
-
@context.eval('typeof hQuery.Patient.prototype.activeDiagnoses')
|
54
|
-
@context.eval('typeof hQuery.Patient.prototype.inactiveDiagnoses')
|
55
|
-
@context.eval('typeof hQuery.Patient.prototype.resolvedDiagnoses')
|
56
|
-
@context.eval('typeof hQuery.Patient.prototype.getEvents')
|
48
|
+
assert_equal "function", @context.eval('typeof hQuery.Patient.prototype.procedureResults')
|
49
|
+
assert_equal "function", @context.eval('typeof hQuery.Patient.prototype.laboratoryTests')
|
50
|
+
assert_equal "function", @context.eval('typeof hQuery.Patient.prototype.allMedications')
|
51
|
+
assert_equal "function", @context.eval('typeof hQuery.Patient.prototype.allProblems')
|
52
|
+
assert_equal "function", @context.eval('typeof hQuery.Patient.prototype.allDevices')
|
53
|
+
assert_equal "function", @context.eval('typeof hQuery.Patient.prototype.activeDiagnoses')
|
54
|
+
assert_equal "function", @context.eval('typeof hQuery.Patient.prototype.inactiveDiagnoses')
|
55
|
+
assert_equal "function", @context.eval('typeof hQuery.Patient.prototype.resolvedDiagnoses')
|
56
|
+
assert_equal "function", @context.eval('typeof hQuery.Patient.prototype.getEvents')
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_code_list
|
60
|
-
@context.eval('(new CodeList({"foo": [10,11]})).match(10)')
|
61
|
-
@context.eval('(new CodeList({"foo": [10,11]})).match({"code": 10})')
|
62
|
-
@context.eval('(new CodeList({"foo": [10,11]})).match(12)')
|
63
|
-
@context.eval('(new CodeList({"foo": [10,11]})).match({"code": 12})')
|
60
|
+
assert_equal true, @context.eval('(new CodeList({"foo": [10,11]})).match(10)')
|
61
|
+
assert_equal true, @context.eval('(new CodeList({"foo": [10,11]})).match({"code": 10})')
|
62
|
+
assert_equal false, @context.eval('(new CodeList({"foo": [10,11]})).match(12)')
|
63
|
+
assert_equal false, @context.eval('(new CodeList({"foo": [10,11]})).match({"code": 12})')
|
64
64
|
end
|
65
65
|
|
66
66
|
def test_pq
|
@@ -86,6 +86,7 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
86
86
|
ts = 'new TS("20110101")'
|
87
87
|
ts2 = 'new TS("20100101")'
|
88
88
|
ts3 = 'new TS("20120101")'
|
89
|
+
ts4 = '(function(){var ts=new TS();ts.date=null;return ts;})()' # set up a null date
|
89
90
|
assert_equal 2011, @context.eval("#{ts}.asDate().getUTCFullYear()")
|
90
91
|
assert_equal 0, @context.eval("#{ts}.asDate().getUTCMonth()")
|
91
92
|
assert_equal 1, @context.eval("#{ts}.asDate().getUTCDate()")
|
@@ -101,6 +102,9 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
101
102
|
assert !@context.eval("#{ts}.after(#{ts3})")
|
102
103
|
assert @context.eval("#{ts}.beforeOrConcurrent(#{ts})")
|
103
104
|
assert @context.eval("#{ts}.afterOrConcurrent(#{ts})")
|
105
|
+
assert @context.eval("#{ts4}.equals(#{ts4})")
|
106
|
+
assert !@context.eval("#{ts3}.equals(#{ts4})")
|
107
|
+
assert !@context.eval("#{ts4}.equals(#{ts3})")
|
104
108
|
|
105
109
|
# The following tests are taken from the Joint Commission guidance on time difference
|
106
110
|
# calculations
|
@@ -269,8 +273,40 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
269
273
|
ivl1 = 'new IVL_TS(new TS("20120310"), new TS("20120320"))'
|
270
274
|
ivl2 = 'new IVL_TS(new TS("20120312"), new TS("20120320"))'
|
271
275
|
assert @context.eval("#{ivl2}.DURING(#{ivl1})")
|
276
|
+
assert !@context.eval("#{ivl1}.equals(#{ivl2})")
|
272
277
|
assert_equal 2010, @context.eval('getIVL(new Date(Date.UTC(2010,1,1))).low.asDate().getUTCFullYear()')
|
273
278
|
end
|
279
|
+
|
280
|
+
def test_ivl_ts_null
|
281
|
+
ts1 = 'new TS("20120310")'
|
282
|
+
ts2 = 'new TS("20120320")'
|
283
|
+
null_ts = '(function(){var ts=new TS();ts.date=null;return ts;})()'
|
284
|
+
ivl = "new IVL_TS(#{ts1}, #{ts2})"
|
285
|
+
ivl_null_low = "new IVL_TS(#{null_ts}, #{ts2})"
|
286
|
+
ivl_null_high = "new IVL_TS(#{ts1}, #{null_ts})"
|
287
|
+
ivl_null_both = "new IVL_TS(#{null_ts}, #{null_ts})"
|
288
|
+
|
289
|
+
assert @context.eval("#{ivl}.equals(#{ivl})")
|
290
|
+
assert @context.eval("#{ivl_null_low}.equals(#{ivl_null_low})")
|
291
|
+
assert @context.eval("#{ivl_null_high}.equals(#{ivl_null_high})")
|
292
|
+
assert @context.eval("#{ivl_null_both}.equals(#{ivl_null_both})")
|
293
|
+
|
294
|
+
assert !@context.eval("#{ivl}.equals(#{ivl_null_low})")
|
295
|
+
assert !@context.eval("#{ivl}.equals(#{ivl_null_high})")
|
296
|
+
assert !@context.eval("#{ivl}.equals(#{ivl_null_both})")
|
297
|
+
|
298
|
+
assert !@context.eval("#{ivl_null_low}.equals(#{ivl})")
|
299
|
+
assert !@context.eval("#{ivl_null_low}.equals(#{ivl_null_high})")
|
300
|
+
assert !@context.eval("#{ivl_null_low}.equals(#{ivl_null_both})")
|
301
|
+
|
302
|
+
assert !@context.eval("#{ivl_null_high}.equals(#{ivl})")
|
303
|
+
assert !@context.eval("#{ivl_null_high}.equals(#{ivl_null_low})")
|
304
|
+
assert !@context.eval("#{ivl_null_high}.equals(#{ivl_null_both})")
|
305
|
+
|
306
|
+
assert !@context.eval("#{ivl_null_both}.equals(#{ivl})")
|
307
|
+
assert !@context.eval("#{ivl_null_both}.equals(#{ivl_null_low})")
|
308
|
+
assert !@context.eval("#{ivl_null_both}.equals(#{ivl_null_high})")
|
309
|
+
end
|
274
310
|
|
275
311
|
def test_any_non_null
|
276
312
|
# ANYNonNull
|
@@ -340,12 +376,33 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
340
376
|
assert_equal 2, @context.eval("XPRODUCT(#{events0},#{events2}).length")
|
341
377
|
assert_equal 2, @context.eval("XPRODUCT(#{events0},#{events2}).eventLists.length")
|
342
378
|
end
|
379
|
+
|
380
|
+
def test_intersection
|
381
|
+
# XPRODUCT
|
382
|
+
events0 = '[]'
|
383
|
+
events1 = '[{id:1}]'
|
384
|
+
events2 = '[{id:2},{id:3},{id:4}]'
|
385
|
+
events3 = '[{id:3},{id:5}]'
|
386
|
+
assert_equal 0, @context.eval("INTERSECT().length")
|
387
|
+
assert_equal 0, @context.eval("INTERSECT(#{events0}).length")
|
388
|
+
assert_equal 3, @context.eval("INTERSECT(#{events2}).length")
|
389
|
+
assert_equal 0, @context.eval("INTERSECT(#{events1},#{events2}).length")
|
390
|
+
assert_equal 0, @context.eval("INTERSECT(#{events0},#{events2}).length")
|
391
|
+
assert_equal 1, @context.eval("INTERSECT(#{events2},#{events3}).length")
|
392
|
+
assert_equal 0, @context.eval("INTERSECT(#{events2},#{events3},#{events1}).length")
|
393
|
+
end
|
343
394
|
|
344
395
|
def test_temporal_operators
|
345
396
|
# Events and bounds for temporal operators
|
346
397
|
@context.eval('var events1 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105"), new TS("20120105"));}}]')
|
347
398
|
@context.eval('var events2 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120102"), new TS("20120105"));}}]')
|
348
399
|
@context.eval('var events3 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105203030"), new TS("20120105203030"));}}]')
|
400
|
+
@context.eval('var nullEndEvent = new IVL_TS(new TS("20110101"), new TS("20120105"));')
|
401
|
+
@context.eval('nullEndEvent.high.date = null;')
|
402
|
+
@context.eval('var events4 = [{"asIVL_TS": function() {return nullEndEvent;}}]')
|
403
|
+
@context.eval('var events5 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20140101"), new TS("20140201"));}}]')
|
404
|
+
@context.eval('var events6 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20101101"), new TS("20110101"));}}]')
|
405
|
+
@context.eval('var events7 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20110101"), new TS("20110201"));}}]')
|
349
406
|
@context.eval('var bound1 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105"), new TS("20120105"));}}]')
|
350
407
|
@context.eval('var bound2 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120107"), new TS("20120107"));}}]')
|
351
408
|
@context.eval('var bound3 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120103"), new TS("20120107"));}}]')
|
@@ -353,8 +410,11 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
353
410
|
@context.eval('var bound5 = {"asIVL_TS": function() {return new IVL_TS(new TS("20120106"), new TS("20120107"));}}')
|
354
411
|
@context.eval('var nullStartBound = new IVL_TS(new TS("20120105"), new TS("20120105"));')
|
355
412
|
@context.eval('nullStartBound.low.date = null;')
|
413
|
+
@context.eval('var nullEndBound = new IVL_TS(new TS("20140601"), new TS("20140601"));')
|
414
|
+
@context.eval('nullEndBound.high.date = null;')
|
356
415
|
@context.eval('var bound6 = {"asIVL_TS": function() {return nullStartBound;}}')
|
357
416
|
@context.eval('var bound7 = [{"asIVL_TS": function() {return new IVL_TS(new TS("20120105193030"), new TS("20120105193030"));}}]')
|
417
|
+
@context.eval('var bound8 = {"asIVL_TS": function() {return nullEndBound;}}')
|
358
418
|
@context.eval('var range1 = new IVL_PQ(null, new PQ(1, "d"))')
|
359
419
|
@context.eval('var range2 = new IVL_PQ(new PQ(1, "d"), null)')
|
360
420
|
@context.eval('var range3 = new IVL_PQ(new PQ(0, "d"), null)')
|
@@ -415,7 +475,18 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
415
475
|
assert_equal 0, @context.eval('OVERLAP(events2, XPRODUCT(bound6))').count
|
416
476
|
assert_equal 1, @context.eval('OVERLAP(events2, XPRODUCT(bound1))').count
|
417
477
|
assert_equal 0, @context.eval('OVERLAP(events2, XPRODUCT(bound2))').count
|
478
|
+
## Overlap with null ending
|
479
|
+
assert_equal 1, @context.eval('OVERLAP(events4, bound8)').count
|
480
|
+
assert_equal 1, @context.eval('OVERLAP(events4, bound1)').count
|
481
|
+
assert_equal 0, @context.eval('OVERLAP(events5, bound8)').count
|
482
|
+
assert_equal 1, @context.eval('OVERLAP(events6, events4)').count
|
483
|
+
assert_equal 1, @context.eval('OVERLAP(events4, events7)').count
|
418
484
|
|
485
|
+
# SCW
|
486
|
+
assert_equal 1, @context.eval('SCW(events1, bound1)').count
|
487
|
+
assert_equal 0, @context.eval('SCW(events1, bound6)').count
|
488
|
+
assert_equal 0, @context.eval('SCW(events1, bound2)').count
|
489
|
+
|
419
490
|
# SBS
|
420
491
|
assert_equal 0, @context.eval('SBS(events1, bound1)').count
|
421
492
|
assert_equal 0, @context.eval('SBS(events2, bound1, range1)').count
|
@@ -423,12 +494,38 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
423
494
|
assert_equal 1, @context.eval('SBS(events2, bound1, range2)').count
|
424
495
|
assert_equal 0, @context.eval('SBS(events3, bound7, range3)').count
|
425
496
|
|
497
|
+
#SBCW
|
498
|
+
assert_equal 1, @context.eval('SBCW(events1, bound1)').count
|
499
|
+
assert_equal 0, @context.eval('SBCW(events2, bound1, range1)').count
|
500
|
+
assert_equal 1, @context.eval('SBCW(events2, bound1)').count
|
501
|
+
assert_equal 1, @context.eval('SBCW(events2, bound1, range2)').count
|
502
|
+
assert_equal 0, @context.eval('SBCW(events3, bound7, range3)').count
|
503
|
+
assert_equal 0, @context.eval('SBCW(events1, bound6)').count
|
504
|
+
assert_equal 1, @context.eval('SBCW(events1, bound2)').count
|
505
|
+
|
426
506
|
# SAS
|
427
507
|
assert_equal 0, @context.eval('SAS(events1, bound1)').count
|
428
508
|
assert_equal 0, @context.eval('SAS(events2, bound1, range1)').count
|
429
509
|
assert_equal 0, @context.eval('SAS(events2, bound1)').count
|
430
510
|
assert_equal 0, @context.eval('SAS(events2, bound1, range2)').count
|
431
511
|
|
512
|
+
#SACW
|
513
|
+
assert_equal 1, @context.eval('SACW(events1, bound1)').count
|
514
|
+
assert_equal 0, @context.eval('SACW(events2, bound1, range1)').count
|
515
|
+
assert_equal 0, @context.eval('SACW(events2, bound1)').count
|
516
|
+
assert_equal 0, @context.eval('SACW(events2, bound1, range2)').count
|
517
|
+
assert_equal 0, @context.eval('SACW(events1, bound6)').count
|
518
|
+
assert_equal 0, @context.eval('SACW(events1, bound2)').count
|
519
|
+
|
520
|
+
|
521
|
+
# SBDU
|
522
|
+
assert_equal 0, @context.eval('SBDU(events2, bound1, range1)').count
|
523
|
+
assert_equal 1, @context.eval('SBDU(events2, bound1)').count
|
524
|
+
assert_equal 1, @context.eval('SBDU(events2, bound1, range2)').count
|
525
|
+
assert_equal 0, @context.eval('SBDU(events3, bound7, range3)').count
|
526
|
+
assert_equal 1, @context.eval('SBDU(events1, bound1)').count
|
527
|
+
assert_equal 1, @context.eval('SBDU(events1, bound2)').count
|
528
|
+
|
432
529
|
# SBE
|
433
530
|
assert_equal 0, @context.eval('SBE(events1, bound1)').count
|
434
531
|
assert_equal 1, @context.eval('SBE(events1, bound2)').count
|
@@ -466,10 +563,30 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
466
563
|
assert_equal 1, @context.eval('ECW(events1, bound6)').count
|
467
564
|
assert_equal 0, @context.eval('ECW(events1, bound2)').count
|
468
565
|
|
469
|
-
#
|
470
|
-
assert_equal 1, @context.eval('
|
471
|
-
assert_equal
|
472
|
-
assert_equal 0, @context.eval('
|
566
|
+
#EBCW
|
567
|
+
assert_equal 1, @context.eval('ECW(events1, bound1)').count
|
568
|
+
assert_equal 1, @context.eval('ECW(events1, bound6)').count
|
569
|
+
assert_equal 0, @context.eval('ECW(events1, bound2)').count
|
570
|
+
assert_equal 0, @context.eval('EBE(events1, bound1)').count
|
571
|
+
assert_equal 1, @context.eval('EBE(events1, bound2)').count
|
572
|
+
|
573
|
+
#EBCWS
|
574
|
+
assert_equal 0, @context.eval('EBS(events1, bound1)').count
|
575
|
+
assert_equal 1, @context.eval('EBS(events1, bound2)').count
|
576
|
+
|
577
|
+
#EACW
|
578
|
+
assert_equal 1, @context.eval('EACW(events1, bound1)').count
|
579
|
+
assert_equal 1, @context.eval('EACW(events1, bound6)').count
|
580
|
+
assert_equal 0, @context.eval('EACW(events1, bound2)').count
|
581
|
+
assert_equal 1, @context.eval('EACW(bound3, events2)').count
|
582
|
+
|
583
|
+
#EACWS
|
584
|
+
assert_equal 1, @context.eval('EACWS(events1, bound1)').count
|
585
|
+
assert_equal 1, @context.eval('EACWS(events1, bound3)').count
|
586
|
+
|
587
|
+
#EBDU
|
588
|
+
assert_equal 1, @context.eval('EBDU(events1, bound1)').count
|
589
|
+
assert_equal 1, @context.eval('EBDU(events1, bound2)').count
|
473
590
|
|
474
591
|
# ECWS
|
475
592
|
assert_equal 1, @context.eval('ECWS(events1, bound1)').count
|
@@ -481,6 +598,17 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
481
598
|
assert_equal 1, @context.eval('SCWE(events1, bound6)').count
|
482
599
|
assert_equal 0, @context.eval('SCWE(events1, bound2)').count
|
483
600
|
|
601
|
+
# SBCWE
|
602
|
+
assert_equal 1, @context.eval('SBCWE(events1, bound1)').count
|
603
|
+
assert_equal 1, @context.eval('SBCWE(events1, bound6)').count
|
604
|
+
assert_equal 1, @context.eval('SBCWE(events1, bound2)').count
|
605
|
+
|
606
|
+
# SACWE
|
607
|
+
assert_equal 1, @context.eval('SACWE(events1, bound1)').count
|
608
|
+
assert_equal 1, @context.eval('SACWE(events1, bound6)').count
|
609
|
+
assert_equal 0, @context.eval('SACWE(events1, bound2)').count
|
610
|
+
assert_equal 1, @context.eval('SACWE(bound2, events1)').count
|
611
|
+
|
484
612
|
# CONCURRENT
|
485
613
|
assert_equal 1, @context.eval('CONCURRENT(events1, bound1)').count
|
486
614
|
assert_equal 0, @context.eval('CONCURRENT(events1, bound2)').count
|
@@ -493,9 +621,28 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
493
621
|
assert_equal true, @context.eval('DATEDIFF([diffEvent1,diffEvent2],range4).isTrue()')
|
494
622
|
assert_equal true, @context.eval('DATEDIFF([diffEvent2,diffEvent1],range4).isTrue()')
|
495
623
|
assert_equal true, @context.eval('DATEDIFF([diffEvent1,diffEvent1],range4).isTrue()')
|
496
|
-
|
497
|
-
|
498
|
-
|
624
|
+
|
625
|
+
assert_equal true, @context.eval('DATETIMEDIFF([diffEvent1,diffEvent2],range4).isTrue()')
|
626
|
+
assert_equal true, @context.eval('DATETIMEDIFF([diffEvent2,diffEvent1],range4).isTrue()')
|
627
|
+
assert_equal true, @context.eval('DATETIMEDIFF([diffEvent1,diffEvent1],range4).isTrue()')
|
628
|
+
|
629
|
+
|
630
|
+
@context.eval("
|
631
|
+
var ts1 = new TS('20100101100000');
|
632
|
+
var ts2 = new TS('20100101101000');
|
633
|
+
var ts3 = new TS('20100101103000');
|
634
|
+
|
635
|
+
var ddEvents1 = [{'id': 1, 'asTS': function() {return ts1;}}];
|
636
|
+
var ddEvents2 = [{'id': 20, 'asTS': function() {return ts2;}}];
|
637
|
+
var ddEvents3 = [{'id': 30, 'asTS': function() {return ts3;}, 'timeStamp': function() {return ts3.date}}, {'id': 20, 'asTS': function() {return ts2;}, 'timeStamp': function() {return ts2.date}}];
|
638
|
+
");
|
639
|
+
|
640
|
+
assert_equal 1, @context.eval('DATETIMEDIFF(XPRODUCT(ddEvents1,ddEvents2)).length')
|
641
|
+
assert_equal 10, @context.eval('DATETIMEDIFF(XPRODUCT(ddEvents1,ddEvents2))[0]')
|
642
|
+
assert_equal 1, @context.eval('DATETIMEDIFF(XPRODUCT(ddEvents1,ddEvents3)).length')
|
643
|
+
assert_equal 30, @context.eval('DATETIMEDIFF(XPRODUCT(ddEvents1,ddEvents3))[0]')
|
644
|
+
assert_equal 1, @context.eval('DATETIMEDIFF(XPRODUCT(ddEvents2,ddEvents3)).length')
|
645
|
+
assert_equal 20, @context.eval('DATETIMEDIFF(XPRODUCT(ddEvents2,ddEvents3))[0]')
|
499
646
|
|
500
647
|
end
|
501
648
|
|
@@ -572,9 +719,30 @@ class LibraryFunctionTest < Test::Unit::TestCase
|
|
572
719
|
assert !@context.eval("MIN(#{events2},#{between15and25}).isTrue()")
|
573
720
|
assert @context.eval("MAX(#{events2},#{between15and25}).isTrue()")
|
574
721
|
end
|
722
|
+
|
723
|
+
def test_qdm_functions
|
724
|
+
# SUM and MEDIAN
|
725
|
+
@context.eval('var medications = [{"cumulativeMedicationDuration": function() { return 30;}}, {"cumulativeMedicationDuration": function() {return 40;}}, {"cumulativeMedicationDuration": function() {return 50;}}];')
|
726
|
+
v10 = '{"values": function() {return {"scalar": 10};}}'
|
727
|
+
v20 = '{"values": function() {return {"scalar": 20};}}'
|
728
|
+
events2 = "[#{v10},#{v20}]"
|
729
|
+
moreThan80 = 'new IVL_PQ(new PQ(81,"d"))'
|
730
|
+
exactly15 = 'new IVL_PQ(new PQ(15), new PQ(15))'
|
731
|
+
exactly30 = 'new IVL_PQ(new PQ(30), new PQ(30))'
|
732
|
+
exactly40 = 'new IVL_PQ(new PQ(40,"d"), new PQ(40,"d"))'
|
733
|
+
field_method = ['cumulativeMedicationDuration']
|
734
|
+
assert_equal true, @context.eval("SUM(medications,#{moreThan80},null,#{field_method}).isTrue()")
|
735
|
+
assert_equal true, @context.eval("MEDIAN(medications,#{exactly40},null,#{field_method}).isTrue()")
|
736
|
+
assert_equal false, @context.eval("SUM(medications,#{moreThan80},null,null).isTrue()")
|
737
|
+
assert_equal false, @context.eval("MEDIAN(medications,#{exactly40},null,null).isTrue()")
|
738
|
+
assert_equal true, @context.eval("MEDIAN(#{events2},#{exactly15},null,['result']).isTrue()")
|
739
|
+
assert_equal false, @context.eval("MEDIAN(#{events2},#{moreThan80},null,['result']).isTrue()")
|
740
|
+
assert_equal true, @context.eval("SUM(#{events2},#{exactly30},null,['result']).isTrue()")
|
741
|
+
assert_equal false, @context.eval("SUM(#{events2},#{exactly40},null,['result']).isTrue()")
|
742
|
+
end
|
575
743
|
|
576
744
|
def test_respond_to
|
577
745
|
assert @context.eval("(new hQuery.Allergy({})).respondTo('severity')")
|
578
746
|
assert !@context.eval("(new hQuery.Allergy({})).respondTo('canHasCheeseburger')")
|
579
747
|
end
|
580
|
-
end
|
748
|
+
end
|
data/test/unit/specifics_test.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
require 'hquery-patient-api'
|
3
3
|
|
4
|
-
class SpecificsTest < Test
|
4
|
+
class SpecificsTest < Minitest::Test
|
5
5
|
|
6
6
|
def setup
|
7
7
|
@context = get_js_context(HQMF2JS::Generator::JS.library_functions)
|
8
8
|
test_initialize_js =
|
9
9
|
"
|
10
|
-
hqmf.SpecificsManager.initialize({},hqmfjs, {'id':'OccurrenceAEncounter', 'type':'
|
10
|
+
hqmf.SpecificsManager.initialize({},hqmfjs, {'id':'OccurrenceAEncounter', 'type':'OccA_Encounter', 'function':'SourceOccurrenceAEncounter'},{'id':'OccurrenceBEncounter', 'type':'OccB_Encounter', 'function':'SourceOccurrenceBEncounter'})
|
11
11
|
hqmfjs.SourceOccurrenceAEncounter = function(patient) {
|
12
12
|
return [{'id':1},{'id':2},{'id':3},{'id':4},{'id':5}]
|
13
13
|
}
|
@@ -21,15 +21,15 @@ class SpecificsTest < Test::Unit::TestCase
|
|
21
21
|
|
22
22
|
def test_specifics_initialized_properly
|
23
23
|
|
24
|
-
@context.eval('hqmf.SpecificsManager.keyLookup[0]')
|
25
|
-
@context.eval('hqmf.SpecificsManager.keyLookup[1]')
|
26
|
-
@context.eval("hqmf.SpecificsManager.indexLookup['OccurrenceAEncounter']")
|
27
|
-
@context.eval("hqmf.SpecificsManager.indexLookup['OccurrenceBEncounter']")
|
28
|
-
@context.eval('hqmf.SpecificsManager.functionLookup[0]')
|
29
|
-
@context.eval('hqmf.SpecificsManager.functionLookup[1]')
|
30
|
-
@context.eval("hqmf.SpecificsManager.typeLookup['Encounter'].length")
|
31
|
-
@context.eval("hqmf.SpecificsManager.typeLookup['Encounter'][0]")
|
32
|
-
@context.eval("hqmf.SpecificsManager.typeLookup['Encounter'][1]")
|
24
|
+
assert_equal 'OccurrenceAEncounter', @context.eval('hqmf.SpecificsManager.keyLookup[0]')
|
25
|
+
assert_equal 'OccurrenceBEncounter', @context.eval('hqmf.SpecificsManager.keyLookup[1]')
|
26
|
+
assert_equal 0, @context.eval("hqmf.SpecificsManager.indexLookup['OccurrenceAEncounter']")
|
27
|
+
assert_equal 1, @context.eval("hqmf.SpecificsManager.indexLookup['OccurrenceBEncounter']")
|
28
|
+
assert_equal 'SourceOccurrenceAEncounter', @context.eval('hqmf.SpecificsManager.functionLookup[0]')
|
29
|
+
assert_equal 'SourceOccurrenceBEncounter', @context.eval('hqmf.SpecificsManager.functionLookup[1]')
|
30
|
+
assert_equal 2, @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'].length")
|
31
|
+
assert_equal 0, @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'][0]")
|
32
|
+
assert_equal 1, @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'][1]")
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_specifics_row_union
|
@@ -43,11 +43,11 @@ class SpecificsTest < Test::Unit::TestCase
|
|
43
43
|
result.rows.length;
|
44
44
|
"
|
45
45
|
|
46
|
-
@context.eval(union_rows)
|
47
|
-
@context.eval("result.rows[0].values[0].id")
|
48
|
-
@context.eval("result.rows[0].values[1]")
|
49
|
-
@context.eval("result.rows[1].values[0]")
|
50
|
-
@context.eval("result.rows[1].values[1].id")
|
46
|
+
assert_equal 2, @context.eval(union_rows)
|
47
|
+
assert_equal 1, @context.eval("result.rows[0].values[0].id")
|
48
|
+
assert_equal '*', @context.eval("result.rows[0].values[1]")
|
49
|
+
assert_equal '*', @context.eval("result.rows[1].values[0]")
|
50
|
+
assert_equal 2, @context.eval("result.rows[1].values[1].id")
|
51
51
|
|
52
52
|
end
|
53
53
|
|
@@ -61,14 +61,14 @@ class SpecificsTest < Test::Unit::TestCase
|
|
61
61
|
"
|
62
62
|
|
63
63
|
@context.eval(rows)
|
64
|
-
@context.eval("row1.values[0].id")
|
65
|
-
@context.eval("row1.values[1]")
|
66
|
-
@context.eval("row2.values[0]")
|
67
|
-
@context.eval("row2.values[1].id")
|
68
|
-
@context.eval("row3.values[0].id")
|
69
|
-
@context.eval("row3.values[1].id")
|
70
|
-
@context.eval("row4.values[0]")
|
71
|
-
@context.eval("row4.values[1]")
|
64
|
+
assert_equal 1, @context.eval("row1.values[0].id")
|
65
|
+
assert_equal '*', @context.eval("row1.values[1]")
|
66
|
+
assert_equal '*', @context.eval("row2.values[0]")
|
67
|
+
assert_equal 2, @context.eval("row2.values[1].id")
|
68
|
+
assert_equal 1, @context.eval("row3.values[0].id")
|
69
|
+
assert_equal 2, @context.eval("row3.values[1].id")
|
70
|
+
assert_equal '*', @context.eval("row4.values[0]")
|
71
|
+
assert_equal '*', @context.eval("row4.values[1]")
|
72
72
|
end
|
73
73
|
|
74
74
|
|
@@ -77,11 +77,11 @@ class SpecificsTest < Test::Unit::TestCase
|
|
77
77
|
var row1 = new Row(undefined, {});
|
78
78
|
"
|
79
79
|
@context.eval(rows)
|
80
|
-
@context.eval("Row.match('*', {'id':1}).id")
|
81
|
-
@context.eval("Row.match({'id':2}, '*').id")
|
82
|
-
@context.eval("Row.match({'id':1}, {'id':1}).id")
|
83
|
-
@context.eval("Row.match('*', '*')")
|
84
|
-
@context.eval("typeof(Row.match({'id':3}, {'id':2})) === 'undefined'")
|
80
|
+
assert_equal 1, @context.eval("Row.match('*', {'id':1}).id")
|
81
|
+
assert_equal 2, @context.eval("Row.match({'id':2}, '*').id")
|
82
|
+
assert_equal 1, @context.eval("Row.match({'id':1}, {'id':1}).id")
|
83
|
+
assert_equal '*', @context.eval("Row.match('*', '*')")
|
84
|
+
assert_equal true, @context.eval("typeof(Row.match({'id':3}, {'id':2})) === 'undefined'")
|
85
85
|
|
86
86
|
end
|
87
87
|
|
@@ -98,12 +98,12 @@ class SpecificsTest < Test::Unit::TestCase
|
|
98
98
|
"
|
99
99
|
|
100
100
|
@context.eval(rows)
|
101
|
-
@context.eval("row1.equals(row1)")
|
102
|
-
@context.eval("row1.equals(row2)")
|
103
|
-
@context.eval("row2.equals(row2)")
|
104
|
-
@context.eval("row3.equals(row4)")
|
105
|
-
@context.eval("row4.equals(row5)")
|
106
|
-
@context.eval("row6.equals(row6)")
|
101
|
+
assert_equal true, @context.eval("row1.equals(row1)")
|
102
|
+
assert_equal false, @context.eval("row1.equals(row2)")
|
103
|
+
assert_equal true, @context.eval("row2.equals(row2)")
|
104
|
+
assert_equal false, @context.eval("row3.equals(row4)")
|
105
|
+
assert_equal true, @context.eval("row4.equals(row5)")
|
106
|
+
assert_equal true, @context.eval("row6.equals(row6)")
|
107
107
|
|
108
108
|
end
|
109
109
|
|
@@ -120,26 +120,26 @@ class SpecificsTest < Test::Unit::TestCase
|
|
120
120
|
"
|
121
121
|
|
122
122
|
@context.eval(rows)
|
123
|
-
@context.eval("row1.intersect(row2).values[0].id")
|
124
|
-
@context.eval("row1.intersect(row2).values[1].id")
|
125
|
-
@context.eval("row2.intersect(row1).values[0].id")
|
126
|
-
@context.eval("row2.intersect(row1).values[1].id")
|
127
|
-
@context.eval("row1.intersect(row3).values[0].id")
|
128
|
-
@context.eval("row1.intersect(row3).values[1].id")
|
129
|
-
@context.eval("row2.intersect(row3).values[0].id")
|
130
|
-
@context.eval("row2.intersect(row3).values[1].id")
|
131
|
-
@context.eval("typeof(row1.intersect(row4)) === 'undefined'")
|
132
|
-
@context.eval("row2.intersect(row4).values[0].id")
|
133
|
-
@context.eval("row2.intersect(row4).values[1].id")
|
134
|
-
@context.eval("typeof(row1.intersect(row5)) === 'undefined'")
|
135
|
-
@context.eval("typeof(row2.intersect(row5)) === 'undefined'")
|
136
|
-
@context.eval("typeof(row3.intersect(row4)) === 'undefined'")
|
137
|
-
@context.eval("row1.intersect(row6).values[0].id")
|
138
|
-
@context.eval("row1.intersect(row6).values[1]")
|
139
|
-
@context.eval("row2.intersect(row6).values[0]")
|
140
|
-
@context.eval("row2.intersect(row6).values[1].id")
|
141
|
-
@context.eval("row6.intersect(row6).values[0]")
|
142
|
-
@context.eval("row6.intersect(row6).values[1]")
|
123
|
+
assert_equal 1, @context.eval("row1.intersect(row2).values[0].id")
|
124
|
+
assert_equal 2, @context.eval("row1.intersect(row2).values[1].id")
|
125
|
+
assert_equal 1, @context.eval("row2.intersect(row1).values[0].id")
|
126
|
+
assert_equal 2, @context.eval("row2.intersect(row1).values[1].id")
|
127
|
+
assert_equal 1, @context.eval("row1.intersect(row3).values[0].id")
|
128
|
+
assert_equal 2, @context.eval("row1.intersect(row3).values[1].id")
|
129
|
+
assert_equal 1, @context.eval("row2.intersect(row3).values[0].id")
|
130
|
+
assert_equal 2, @context.eval("row2.intersect(row3).values[1].id")
|
131
|
+
assert_equal true, @context.eval("typeof(row1.intersect(row4)) === 'undefined'")
|
132
|
+
assert_equal 2, @context.eval("row2.intersect(row4).values[0].id")
|
133
|
+
assert_equal 2, @context.eval("row2.intersect(row4).values[1].id")
|
134
|
+
assert_equal true, @context.eval("typeof(row1.intersect(row5)) === 'undefined'")
|
135
|
+
assert_equal true, @context.eval("typeof(row2.intersect(row5)) === 'undefined'")
|
136
|
+
assert_equal true, @context.eval("typeof(row3.intersect(row4)) === 'undefined'")
|
137
|
+
assert_equal 1, @context.eval("row1.intersect(row6).values[0].id")
|
138
|
+
assert_equal '*', @context.eval("row1.intersect(row6).values[1]")
|
139
|
+
assert_equal '*', @context.eval("row2.intersect(row6).values[0]")
|
140
|
+
assert_equal 2, @context.eval("row2.intersect(row6).values[1].id")
|
141
|
+
assert_equal '*', @context.eval("row6.intersect(row6).values[0]")
|
142
|
+
assert_equal '*', @context.eval("row6.intersect(row6).values[1]")
|
143
143
|
|
144
144
|
end
|
145
145
|
|
@@ -171,34 +171,34 @@ class SpecificsTest < Test::Unit::TestCase
|
|
171
171
|
"
|
172
172
|
|
173
173
|
@context.eval(intersect_rows)
|
174
|
-
@context.eval("specific1.intersect(specific2).rows.length")
|
175
|
-
@context.eval("specific1.intersect(specific2).rows[0].values[0].id")
|
176
|
-
@context.eval("specific1.intersect(specific2).rows[0].values[1].id")
|
174
|
+
assert_equal 1, @context.eval("specific1.intersect(specific2).rows.length")
|
175
|
+
assert_equal 1, @context.eval("specific1.intersect(specific2).rows[0].values[0].id")
|
176
|
+
assert_equal 2, @context.eval("specific1.intersect(specific2).rows[0].values[1].id")
|
177
177
|
|
178
|
-
@context.eval("specific1.intersect(specific3).rows.length")
|
179
|
-
@context.eval("specific1.intersect(specific3).rows[0].values[0].id")
|
180
|
-
@context.eval("specific1.intersect(specific3).rows[0].values[1].id")
|
178
|
+
assert_equal 1, @context.eval("specific1.intersect(specific3).rows.length")
|
179
|
+
assert_equal 1, @context.eval("specific1.intersect(specific3).rows[0].values[0].id")
|
180
|
+
assert_equal 2, @context.eval("specific1.intersect(specific3).rows[0].values[1].id")
|
181
181
|
|
182
|
-
@context.eval("specific1.intersect(specific4).rows.length")
|
183
|
-
@context.eval("specific1.intersect(specific4).rows[0].values[0].id")
|
184
|
-
@context.eval("specific1.intersect(specific4).rows[0].values[1].id")
|
185
|
-
@context.eval("specific1.intersect(specific4).rows[1].values[0].id")
|
186
|
-
@context.eval("specific1.intersect(specific4).rows[1].values[1].id")
|
182
|
+
assert_equal 2, @context.eval("specific1.intersect(specific4).rows.length")
|
183
|
+
assert_equal 1, @context.eval("specific1.intersect(specific4).rows[0].values[0].id")
|
184
|
+
assert_equal 2, @context.eval("specific1.intersect(specific4).rows[0].values[1].id")
|
185
|
+
assert_equal 1, @context.eval("specific1.intersect(specific4).rows[1].values[0].id")
|
186
|
+
assert_equal 3, @context.eval("specific1.intersect(specific4).rows[1].values[1].id")
|
187
187
|
|
188
|
-
@context.eval("specific2.intersect(specific3).rows.length")
|
189
|
-
@context.eval("specific2.intersect(specific3).rows[0].values[0].id")
|
190
|
-
@context.eval("specific2.intersect(specific3).rows[0].values[1].id")
|
191
|
-
@context.eval("specific2.intersect(specific3).rows[1].values[0].id")
|
192
|
-
@context.eval("specific2.intersect(specific3).rows[1].values[1].id")
|
188
|
+
assert_equal 2, @context.eval("specific2.intersect(specific3).rows.length")
|
189
|
+
assert_equal 1, @context.eval("specific2.intersect(specific3).rows[0].values[0].id")
|
190
|
+
assert_equal 2, @context.eval("specific2.intersect(specific3).rows[0].values[1].id")
|
191
|
+
assert_equal 2, @context.eval("specific2.intersect(specific3).rows[1].values[0].id")
|
192
|
+
assert_equal 2, @context.eval("specific2.intersect(specific3).rows[1].values[1].id")
|
193
193
|
|
194
|
-
@context.eval("specific2.intersect(specific5).rows.length")
|
194
|
+
assert_equal 0, @context.eval("specific2.intersect(specific5).rows.length")
|
195
195
|
|
196
|
-
@context.eval("specific4.intersect(specific5).rows.length")
|
197
|
-
@context.eval("specific4.intersect(specific5).rows[0].values[0].id")
|
198
|
-
@context.eval("specific4.intersect(specific5).rows[0].values[1].id")
|
196
|
+
assert_equal 1, @context.eval("specific4.intersect(specific5).rows.length")
|
197
|
+
assert_equal 1, @context.eval("specific4.intersect(specific5).rows[0].values[0].id")
|
198
|
+
assert_equal 3, @context.eval("specific4.intersect(specific5).rows[0].values[1].id")
|
199
199
|
|
200
200
|
|
201
|
-
@context.eval("allSpecific1.intersect(allSpecific2).rows.length")
|
201
|
+
assert_equal 1, @context.eval("allSpecific1.intersect(allSpecific2).rows.length")
|
202
202
|
|
203
203
|
end
|
204
204
|
|
@@ -221,8 +221,31 @@ class SpecificsTest < Test::Unit::TestCase
|
|
221
221
|
"
|
222
222
|
|
223
223
|
@context.eval(init_rows)
|
224
|
-
@context.eval("timediffs.length")
|
225
|
-
@context.eval("timediffs[0]")
|
224
|
+
assert_equal 1, @context.eval("timediffs.length")
|
225
|
+
assert_equal 10, @context.eval("timediffs[0]")
|
226
|
+
end
|
227
|
+
|
228
|
+
def test_specifics_datetimediff
|
229
|
+
init_rows = "
|
230
|
+
var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':20}});
|
231
|
+
var row2 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':2},'OccurrenceBEncounter':{'id':20}});
|
232
|
+
var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':3},'OccurrenceBEncounter':{'id':30}});
|
233
|
+
|
234
|
+
var specific = new hqmf.SpecificOccurrence([row1,row2,row3]);
|
235
|
+
|
236
|
+
var ts1 = new TS('20100101100000');
|
237
|
+
var ts2 = new TS('20100101101000');
|
238
|
+
|
239
|
+
var events1 = [{'id': 1, 'asTS': function() {return ts1;}}];
|
240
|
+
events1.specific_occurrence = 'OccurrenceAEncounter';
|
241
|
+
var events2 = [{'id': 20, 'asTS': function() {return ts2;}},{'id': 30, 'asTS': function() {return ts2;}}];
|
242
|
+
events2.specific_occurrence = 'OccurrenceBEncounter';
|
243
|
+
var timediffs = DATETIMEDIFF(XPRODUCT(events1, events2), null, specific);
|
244
|
+
"
|
245
|
+
|
246
|
+
@context.eval(init_rows)
|
247
|
+
assert_equal 1, @context.eval("timediffs.length")
|
248
|
+
assert_equal 10, @context.eval("timediffs[0]")
|
226
249
|
end
|
227
250
|
|
228
251
|
def test_specifics_event_counting
|
@@ -243,22 +266,22 @@ class SpecificsTest < Test::Unit::TestCase
|
|
243
266
|
"
|
244
267
|
|
245
268
|
@context.eval(init_rows)
|
246
|
-
@context.eval("specific.uniqueEvents([0])")
|
247
|
-
@context.eval("specific.uniqueEvents([1])")
|
248
|
-
@context.eval('hqmf.SpecificsManager.indexLookup["OccurrenceAEncounter"]')
|
249
|
-
@context.eval('hqmf.SpecificsManager.indexLookup["OccurrenceBEncounter"]')
|
250
|
-
@context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceAEncounter")')
|
251
|
-
@context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceBEncounter")')
|
252
|
-
|
269
|
+
assert_equal 3, @context.eval("specific.uniqueEvents([0])")
|
270
|
+
assert_equal 2, @context.eval("specific.uniqueEvents([1])")
|
271
|
+
assert_equal 0, @context.eval('hqmf.SpecificsManager.indexLookup["OccurrenceAEncounter"]')
|
272
|
+
assert_equal 1, @context.eval('hqmf.SpecificsManager.indexLookup["OccurrenceBEncounter"]')
|
273
|
+
assert_equal 0, @context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceAEncounter")')
|
274
|
+
assert_equal 1, @context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceBEncounter")')
|
275
|
+
assert_raises V8::JSError do
|
253
276
|
@context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceCEncounter")')
|
254
277
|
end
|
255
|
-
@context.eval('hqmf.SpecificsManager.validate(pop)')
|
256
|
-
@context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceAEncounter"], pop)')
|
257
|
-
@context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceBEncounter"], pop)')
|
278
|
+
assert_equal true, @context.eval('hqmf.SpecificsManager.validate(pop)')
|
279
|
+
assert_equal 3, @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceAEncounter"], pop)')
|
280
|
+
assert_equal 2, @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceBEncounter"], pop)')
|
258
281
|
# this should be 3 and not 5 because we are doing a multiple encounter episode check. The OccurrenceB rows should be dropped since
|
259
282
|
# we cannot have multiple values defined on a single row for a multi encounter episode check for unique.
|
260
|
-
@context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceAEncounter", "OccurrenceBEncounter"], pop)')
|
261
|
-
@context.eval('hqmf.SpecificsManager.countUnique(null, pop)')
|
283
|
+
assert_equal 3, @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceAEncounter", "OccurrenceBEncounter"], pop)')
|
284
|
+
assert_equal 1, @context.eval('hqmf.SpecificsManager.countUnique(null, pop)')
|
262
285
|
end
|
263
286
|
|
264
287
|
def test_specifics_event_exclusion
|
@@ -285,33 +308,33 @@ class SpecificsTest < Test::Unit::TestCase
|
|
285
308
|
|
286
309
|
@context.eval(init_rows)
|
287
310
|
@context.eval('var resultSpecific = specific1.removeMatchingRows(0, specific2)')
|
288
|
-
@context.eval('resultSpecific.rows.length')
|
289
|
-
@context.eval('resultSpecific.rows[0].values[0].id')
|
290
|
-
@context.eval('resultSpecific.rows[1].values[0].id')
|
311
|
+
assert_equal 2, @context.eval('resultSpecific.rows.length')
|
312
|
+
assert_equal 2, @context.eval('resultSpecific.rows[0].values[0].id')
|
313
|
+
assert_equal 3, @context.eval('resultSpecific.rows[1].values[0].id')
|
291
314
|
@context.eval('resultSpecific = specific1.removeMatchingRows(1, specific2)')
|
292
|
-
@context.eval('resultSpecific.rows.length')
|
293
|
-
@context.eval('resultSpecific.rows[0].values[0].id')
|
315
|
+
assert_equal 1, @context.eval('resultSpecific.rows.length')
|
316
|
+
assert_equal 3, @context.eval('resultSpecific.rows[0].values[0].id')
|
294
317
|
@context.eval('var result = hqmf.SpecificsManager.exclude(["OccurrenceAEncounter"], pop1, pop2)')
|
295
|
-
@context.eval('result.isTrue()')
|
296
|
-
@context.eval('result.specificContext.rows.length')
|
297
|
-
@context.eval('result.specificContext.rows[0].values[0].id')
|
298
|
-
@context.eval('result.specificContext.rows[1].values[0].id')
|
318
|
+
assert_equal true, @context.eval('result.isTrue()')
|
319
|
+
assert_equal 2, @context.eval('result.specificContext.rows.length')
|
320
|
+
assert_equal 2, @context.eval('result.specificContext.rows[0].values[0].id')
|
321
|
+
assert_equal 3, @context.eval('result.specificContext.rows[1].values[0].id')
|
299
322
|
@context.eval('result = hqmf.SpecificsManager.exclude(["OccurrenceBEncounter"], pop1, pop2)')
|
300
|
-
@context.eval('result.isTrue()')
|
301
|
-
@context.eval('result.specificContext.rows.length')
|
302
|
-
@context.eval('result.specificContext.rows[0].values[0].id')
|
323
|
+
assert_equal true, @context.eval('result.isTrue()')
|
324
|
+
assert_equal 1, @context.eval('result.specificContext.rows.length')
|
325
|
+
assert_equal 3, @context.eval('result.specificContext.rows[0].values[0].id')
|
303
326
|
@context.eval('result = hqmf.SpecificsManager.exclude(["OccurrenceAEncounter","OccurrenceBEncounter"], pop1, pop2)')
|
304
|
-
@context.eval('result.isTrue()')
|
305
|
-
@context.eval('result.specificContext.rows.length')
|
306
|
-
@context.eval('result.specificContext.rows[0].values[0].id')
|
327
|
+
assert_equal true, @context.eval('result.isTrue()')
|
328
|
+
assert_equal 1, @context.eval('result.specificContext.rows.length')
|
329
|
+
assert_equal 3, @context.eval('result.specificContext.rows[0].values[0].id')
|
307
330
|
@context.eval('result = hqmf.SpecificsManager.exclude(null, pop3, pop3)')
|
308
|
-
@context.eval('result.isTrue()')
|
331
|
+
assert_equal false, @context.eval('result.isTrue()')
|
309
332
|
@context.eval('result = hqmf.SpecificsManager.exclude(null, pop3, pop4)')
|
310
|
-
@context.eval('result.isTrue()')
|
333
|
+
assert_equal true, @context.eval('result.isTrue()')
|
311
334
|
@context.eval('result = hqmf.SpecificsManager.exclude(null, pop4, pop3)')
|
312
|
-
@context.eval('result.isTrue()')
|
335
|
+
assert_equal false, @context.eval('result.isTrue()')
|
313
336
|
@context.eval('result = hqmf.SpecificsManager.exclude(null, pop4, pop4)')
|
314
|
-
@context.eval('result.isTrue()')
|
337
|
+
assert_equal false, @context.eval('result.isTrue()')
|
315
338
|
end
|
316
339
|
|
317
340
|
def test_negation
|
@@ -337,44 +360,44 @@ class SpecificsTest < Test::Unit::TestCase
|
|
337
360
|
@context.eval(rows)
|
338
361
|
|
339
362
|
# has row checks
|
340
|
-
@context.eval('specific1.hasRow(row1)')
|
341
|
-
@context.eval('specific1.hasRow(row2)')
|
342
|
-
@context.eval('specific1.hasRow(row3)')
|
343
|
-
@context.eval('specific1.hasRow(row4)')
|
344
|
-
@context.eval('specific1.hasRow(row5)')
|
363
|
+
assert_equal true, @context.eval('specific1.hasRow(row1)')
|
364
|
+
assert_equal true, @context.eval('specific1.hasRow(row2)')
|
365
|
+
assert_equal true, @context.eval('specific1.hasRow(row3)')
|
366
|
+
assert_equal false, @context.eval('specific1.hasRow(row4)')
|
367
|
+
assert_equal false, @context.eval('specific1.hasRow(row5)')
|
345
368
|
|
346
369
|
# cartesian checks
|
347
|
-
@context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3]]).length')
|
348
|
-
@context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]]).length')
|
349
|
-
@context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[0][0]')
|
350
|
-
@context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[0][1]')
|
351
|
-
@context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[1][0]')
|
352
|
-
@context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[1][1]')
|
353
|
-
@context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[2][0]')
|
354
|
-
@context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[2][1]')
|
370
|
+
assert_equal 3, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3]]).length')
|
371
|
+
assert_equal 6, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]]).length')
|
372
|
+
assert_equal 1, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[0][0]')
|
373
|
+
assert_equal 5, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[0][1]')
|
374
|
+
assert_equal 1, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[1][0]')
|
375
|
+
assert_equal 6, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[1][1]')
|
376
|
+
assert_equal 2, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[2][0]')
|
377
|
+
assert_equal 5, @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[2][1]')
|
355
378
|
|
356
379
|
# specificsWithValue on Row
|
357
|
-
@context.eval('row1.specificsWithValues()[0]')
|
358
|
-
@context.eval('row2.specificsWithValues()[0]')
|
359
|
-
@context.eval('row3.specificsWithValues()[0]')
|
360
|
-
@context.eval('row3.specificsWithValues()[1]')
|
380
|
+
assert_equal 0, @context.eval('row1.specificsWithValues()[0]')
|
381
|
+
assert_equal 1, @context.eval('row2.specificsWithValues()[0]')
|
382
|
+
assert_equal 0, @context.eval('row3.specificsWithValues()[0]')
|
383
|
+
assert_equal 1, @context.eval('row3.specificsWithValues()[1]')
|
361
384
|
|
362
385
|
# specificsWithValue on Specific
|
363
|
-
@context.eval('specific1.specificsWithValues()[0]')
|
364
|
-
@context.eval('specific2.specificsWithValues()[0]')
|
365
|
-
@context.eval('specific3.specificsWithValues()[0]')
|
366
|
-
@context.eval('specific3.specificsWithValues()[1]')
|
367
|
-
@context.eval('specific6.specificsWithValues()[0]')
|
368
|
-
@context.eval('specific6.specificsWithValues()[1]')
|
369
|
-
|
370
|
-
@context.eval('specific1.negate().rows.length')
|
371
|
-
@context.eval('specific1.negate().rows[0].values[0].id')
|
372
|
-
@context.eval('specific1.negate().rows[1].values[0].id')
|
373
|
-
@context.eval('specific1.negate().rows[2].values[0].id')
|
374
|
-
@context.eval('specific1.negate().rows[3].values[0].id')
|
386
|
+
assert_equal 0, @context.eval('specific1.specificsWithValues()[0]')
|
387
|
+
assert_equal 1, @context.eval('specific2.specificsWithValues()[0]')
|
388
|
+
assert_equal 0, @context.eval('specific3.specificsWithValues()[0]')
|
389
|
+
assert_equal 1, @context.eval('specific3.specificsWithValues()[1]')
|
390
|
+
assert_equal 0, @context.eval('specific6.specificsWithValues()[0]')
|
391
|
+
assert_equal 1, @context.eval('specific6.specificsWithValues()[1]')
|
392
|
+
|
393
|
+
assert_equal 4, @context.eval('specific1.negate().rows.length')
|
394
|
+
assert_equal 2, @context.eval('specific1.negate().rows[0].values[0].id')
|
395
|
+
assert_equal 3, @context.eval('specific1.negate().rows[1].values[0].id')
|
396
|
+
assert_equal 4, @context.eval('specific1.negate().rows[2].values[0].id')
|
397
|
+
assert_equal 5, @context.eval('specific1.negate().rows[3].values[0].id')
|
375
398
|
|
376
399
|
# 5*5 values = 25 in the cartesian - 2 in the non-negated = 23 negated - 5 rows with OccurrA and OccurrB equal = 18!
|
377
|
-
@context.eval('specific5.negate().rows.length')
|
400
|
+
assert_equal 18, @context.eval('specific5.negate().rows.length')
|
378
401
|
|
379
402
|
end
|
380
403
|
|
@@ -394,19 +417,19 @@ class SpecificsTest < Test::Unit::TestCase
|
|
394
417
|
|
395
418
|
@context.eval(rows)
|
396
419
|
|
397
|
-
@context.eval('specific1.hasRows()')
|
398
|
-
@context.eval('specific2.hasRows()')
|
399
|
-
@context.eval('specific1.hasSpecifics()')
|
400
|
-
@context.eval('specific2.hasSpecifics()')
|
401
|
-
@context.eval('row3.hasSpecifics()')
|
402
|
-
@context.eval('row2.hasSpecifics()')
|
420
|
+
assert_equal false, @context.eval('specific1.hasRows()')
|
421
|
+
assert_equal true, @context.eval('specific2.hasRows()')
|
422
|
+
assert_equal false, @context.eval('specific1.hasSpecifics()')
|
423
|
+
assert_equal true, @context.eval('specific2.hasSpecifics()')
|
424
|
+
assert_equal false, @context.eval('row3.hasSpecifics()')
|
425
|
+
assert_equal true, @context.eval('row2.hasSpecifics()')
|
403
426
|
|
404
|
-
@context.eval('specific1.rows.length')
|
427
|
+
assert_equal 0, @context.eval('specific1.rows.length')
|
405
428
|
@context.eval('specific1.addRows([row2])')
|
406
|
-
@context.eval('specific1.rows.length')
|
407
|
-
@context.eval('specific2.rows.length')
|
429
|
+
assert_equal 1, @context.eval('specific1.rows.length')
|
430
|
+
assert_equal 1, @context.eval('specific2.rows.length')
|
408
431
|
@context.eval('specific2.addRows([row3])')
|
409
|
-
@context.eval('specific2.rows.length')
|
432
|
+
assert_equal 2, @context.eval('specific2.rows.length')
|
410
433
|
|
411
434
|
end
|
412
435
|
|
@@ -416,8 +439,8 @@ class SpecificsTest < Test::Unit::TestCase
|
|
416
439
|
@context.eval("x.specific_occurrence = 'specific_occurrence'")
|
417
440
|
@context.eval('var a = new Boolean(true)')
|
418
441
|
@context.eval("a = hqmf.SpecificsManager.maintainSpecifics(a,x)")
|
419
|
-
@context.eval("typeof(a.specificContext) != 'undefined'")
|
420
|
-
@context.eval("typeof(a.specific_occurrence) != 'undefined'")
|
442
|
+
assert_equal true, @context.eval("typeof(a.specificContext) != 'undefined'")
|
443
|
+
assert_equal true, @context.eval("typeof(a.specific_occurrence) != 'undefined'")
|
421
444
|
|
422
445
|
end
|
423
446
|
|
@@ -435,8 +458,8 @@ class SpecificsTest < Test::Unit::TestCase
|
|
435
458
|
|
436
459
|
@context.eval(rows)
|
437
460
|
|
438
|
-
@context.eval('specific1.rows.length')
|
439
|
-
@context.eval('specific1.compactReusedEvents().rows.length')
|
461
|
+
assert_equal 6, @context.eval('specific1.rows.length')
|
462
|
+
assert_equal 4, @context.eval('specific1.compactReusedEvents().rows.length')
|
440
463
|
|
441
464
|
end
|
442
465
|
|
@@ -469,11 +492,69 @@ class SpecificsTest < Test::Unit::TestCase
|
|
469
492
|
|
470
493
|
@context.eval(rows)
|
471
494
|
|
472
|
-
@context.eval('specific1.rows.length')
|
473
|
-
@context.eval('specific1.compactReusedEvents().rows.length')
|
495
|
+
assert_equal 6, @context.eval('specific1.rows.length')
|
496
|
+
assert_equal 6, @context.eval('specific1.compactReusedEvents().rows.length')
|
474
497
|
|
475
498
|
end
|
476
|
-
|
499
|
+
|
500
|
+
def test_remove_duplicate_rows
|
501
|
+
|
502
|
+
rows = "
|
503
|
+
var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1}});
|
504
|
+
var row2 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1}});
|
505
|
+
var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2}});
|
506
|
+
var row4 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2}});
|
507
|
+
|
508
|
+
var specific = new hqmf.SpecificOccurrence([row1,row2,row3,row4]);
|
509
|
+
"
|
510
|
+
|
511
|
+
@context.eval(rows)
|
512
|
+
|
513
|
+
assert_equal 4, @context.eval('specific.rows.length')
|
514
|
+
assert_equal 2, @context.eval('specific.removeDuplicateRows().rows.length')
|
515
|
+
|
516
|
+
end
|
517
|
+
|
518
|
+
def test_remove_duplicate_rows_no_duplicates
|
519
|
+
|
520
|
+
rows = "
|
521
|
+
var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1}});
|
522
|
+
var row2 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2}});
|
523
|
+
var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':3}});
|
524
|
+
var row4 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':4}});
|
525
|
+
|
526
|
+
var specific = new hqmf.SpecificOccurrence([row1,row2,row3,row4]);
|
527
|
+
"
|
528
|
+
|
529
|
+
@context.eval(rows)
|
530
|
+
|
531
|
+
assert_equal 4, @context.eval('specific.rows.length')
|
532
|
+
assert_equal 4, @context.eval('specific.removeDuplicateRows().rows.length')
|
533
|
+
|
534
|
+
end
|
535
|
+
|
536
|
+
def test_remove_duplicate_rows_temp_value
|
537
|
+
|
538
|
+
rows = "
|
539
|
+
var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1},undefined:{'id':1}});
|
540
|
+
var row2 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1},undefined:{'id':2}});
|
541
|
+
var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2},undefined:{'id':1}});
|
542
|
+
var row4 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2},undefined:{'id':2}});
|
543
|
+
var row5 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1},undefined:{'id':1}});
|
544
|
+
var row6 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':1},undefined:{'id':2}});
|
545
|
+
var row7 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2},undefined:{'id':1}});
|
546
|
+
var row8 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2},undefined:{'id':2}});
|
547
|
+
|
548
|
+
var specific = new hqmf.SpecificOccurrence([row1,row2,row3,row4,row5,row6,row7,row8]);
|
549
|
+
"
|
550
|
+
|
551
|
+
@context.eval(rows)
|
552
|
+
|
553
|
+
assert_equal 8, @context.eval('specific.rows.length')
|
554
|
+
assert_equal 4, @context.eval('specific.removeDuplicateRows().rows.length')
|
555
|
+
|
556
|
+
end
|
557
|
+
|
477
558
|
def test_row_build_rows_for_matching
|
478
559
|
|
479
560
|
events = "
|
@@ -485,22 +566,22 @@ class SpecificsTest < Test::Unit::TestCase
|
|
485
566
|
|
486
567
|
@context.eval(events)
|
487
568
|
@context.eval('var rows = Row.buildRowsForMatching(entryKey,entry,boundsKey,bounds)')
|
488
|
-
@context.eval('rows.length')
|
489
|
-
@context.eval('rows[0].values.length')
|
490
|
-
@context.eval('rows[0].values[0].id')
|
491
|
-
@context.eval('rows[0].values[1].id')
|
492
|
-
@context.eval('rows[7].values[0].id')
|
493
|
-
@context.eval('rows[7].values[1].id')
|
569
|
+
assert_equal 8, @context.eval('rows.length')
|
570
|
+
assert_equal 2, @context.eval('rows[0].values.length')
|
571
|
+
assert_equal 3, @context.eval('rows[0].values[0].id')
|
572
|
+
assert_equal 1, @context.eval('rows[0].values[1].id')
|
573
|
+
assert_equal 3, @context.eval('rows[7].values[0].id')
|
574
|
+
assert_equal 8, @context.eval('rows[7].values[1].id')
|
494
575
|
@context.eval('var specific = new hqmf.SpecificOccurrence(rows)')
|
495
|
-
@context.eval('specific.rows.length')
|
496
|
-
@context.eval('specific.compactReusedEvents().rows.length')
|
576
|
+
assert_equal 8, @context.eval('specific.rows.length')
|
577
|
+
assert_equal 7, @context.eval('specific.compactReusedEvents().rows.length')
|
497
578
|
@context.eval('var rows = Row.buildRowsForMatching(undefined,entry,boundsKey,bounds)')
|
498
|
-
@context.eval('rows.length')
|
499
|
-
@context.eval("rows[0].
|
500
|
-
@context.eval("rows[5].
|
501
|
-
@context.eval("rows[0].
|
502
|
-
@context.eval("rows[0].values[1].id")
|
503
|
-
@context.eval("rows[5].values[1].id")
|
579
|
+
assert_equal 8, @context.eval('rows.length')
|
580
|
+
assert_equal 3, @context.eval("rows[0].nonSpecificLeftMost.id")
|
581
|
+
assert_equal 3, @context.eval("rows[5].nonSpecificLeftMost.id")
|
582
|
+
assert_equal 3, @context.eval("rows[0].nonSpecificLeftMost.id")
|
583
|
+
assert_equal 1, @context.eval("rows[0].values[1].id")
|
584
|
+
assert_equal 6, @context.eval("rows[5].values[1].id")
|
504
585
|
end
|
505
586
|
|
506
587
|
def test_row_build_for_data_criteria
|
@@ -512,12 +593,12 @@ class SpecificsTest < Test::Unit::TestCase
|
|
512
593
|
|
513
594
|
@context.eval(events)
|
514
595
|
@context.eval('var rows = Row.buildForDataCriteria(entryKey,entries)')
|
515
|
-
@context.eval('rows.length')
|
516
|
-
@context.eval('rows[0].values.length')
|
517
|
-
@context.eval('rows[0].values[0].id')
|
518
|
-
@context.eval('rows[0].values[1]')
|
519
|
-
@context.eval('rows[7].values[0].id')
|
520
|
-
@context.eval('rows[7].values[1]')
|
596
|
+
assert_equal 8, @context.eval('rows.length')
|
597
|
+
assert_equal 2, @context.eval('rows[0].values.length')
|
598
|
+
assert_equal 1, @context.eval('rows[0].values[0].id')
|
599
|
+
assert_equal '*', @context.eval('rows[0].values[1]')
|
600
|
+
assert_equal 8, @context.eval('rows[7].values[0].id')
|
601
|
+
assert_equal '*', @context.eval('rows[7].values[1]')
|
521
602
|
|
522
603
|
end
|
523
604
|
|
@@ -538,23 +619,23 @@ class SpecificsTest < Test::Unit::TestCase
|
|
538
619
|
"
|
539
620
|
@context.eval(rows)
|
540
621
|
@context.eval('var result = specific1.finalizeEvents(specific2,specific3)')
|
541
|
-
@context.eval('result.rows.length')
|
542
|
-
@context.eval('result.rows[0].values[0].id')
|
543
|
-
@context.eval('result.rows[0].values[1].id')
|
544
|
-
@context.eval('result.rows[1].values[0].id')
|
545
|
-
@context.eval('result.rows[1].values[1].id')
|
546
|
-
@context.eval('result.rows[2].values[0].id')
|
547
|
-
@context.eval('result.rows[2].values[1].id')
|
622
|
+
assert_equal 3, @context.eval('result.rows.length')
|
623
|
+
assert_equal 1, @context.eval('result.rows[0].values[0].id')
|
624
|
+
assert_equal 4, @context.eval('result.rows[0].values[1].id')
|
625
|
+
assert_equal 1, @context.eval('result.rows[1].values[0].id')
|
626
|
+
assert_equal 5, @context.eval('result.rows[1].values[1].id')
|
627
|
+
assert_equal 2, @context.eval('result.rows[2].values[0].id')
|
628
|
+
assert_equal 4, @context.eval('result.rows[2].values[1].id')
|
548
629
|
|
549
630
|
@context.eval('var result = specific2.finalizeEvents(specific1,specific3)')
|
550
|
-
@context.eval('result.rows.length')
|
631
|
+
assert_equal 3, @context.eval('result.rows.length')
|
551
632
|
|
552
633
|
@context.eval('var result = specific1.finalizeEvents(null,specific3)')
|
553
|
-
@context.eval('result.rows.length')
|
634
|
+
assert_equal 3, @context.eval('result.rows.length')
|
554
635
|
|
555
636
|
# result if 5 and not 6 becasue the 2/2 row gets dropped
|
556
637
|
@context.eval('var result = specific1.finalizeEvents(specific2, null)')
|
557
|
-
@context.eval('result.rows.length')
|
638
|
+
assert_equal 5, @context.eval('result.rows.length')
|
558
639
|
|
559
640
|
end
|
560
641
|
|
@@ -598,10 +679,10 @@ class SpecificsTest < Test::Unit::TestCase
|
|
598
679
|
"
|
599
680
|
@context.eval(rows)
|
600
681
|
|
601
|
-
@context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop3)))')
|
602
|
-
@context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop4)))')
|
603
|
-
@context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop5)))')
|
604
|
-
@context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop3f,hqmf.SpecificsManager.intersectSpecifics(pop1,pop2)))')
|
682
|
+
assert_equal true, @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop3)))')
|
683
|
+
assert_equal false, @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop4)))')
|
684
|
+
assert_equal false, @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1, hqmf.SpecificsManager.intersectSpecifics(pop2,pop5)))')
|
685
|
+
assert_equal false, @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop3f,hqmf.SpecificsManager.intersectSpecifics(pop1,pop2)))')
|
605
686
|
|
606
687
|
end
|
607
688
|
|
@@ -634,62 +715,62 @@ class SpecificsTest < Test::Unit::TestCase
|
|
634
715
|
@context.eval(rows)
|
635
716
|
|
636
717
|
# test allValuesAny
|
637
|
-
@context.eval('row1.allValuesAny([0,1,2])')
|
638
|
-
@context.eval('row1.allValuesAny([1,2])')
|
639
|
-
@context.eval('row1.allValuesAny([2])')
|
640
|
-
@context.eval('row1.allValuesAny([1])')
|
641
|
-
@context.eval('row1.allValuesAny([])')
|
642
|
-
@context.eval('identityRow.allValuesAny([0,1,2])')
|
718
|
+
assert_equal false, @context.eval('row1.allValuesAny([0,1,2])')
|
719
|
+
assert_equal true, @context.eval('row1.allValuesAny([1,2])')
|
720
|
+
assert_equal true, @context.eval('row1.allValuesAny([2])')
|
721
|
+
assert_equal true, @context.eval('row1.allValuesAny([1])')
|
722
|
+
assert_equal true, @context.eval('row1.allValuesAny([])')
|
723
|
+
assert_equal true, @context.eval('identityRow.allValuesAny([0,1,2])')
|
643
724
|
|
644
725
|
# test checkEpisodeOfCare
|
645
|
-
@context.eval('Row.checkEpisodeOfCare({id: 1}, true) == hqmf.SpecificsManager.any')
|
646
|
-
@context.eval('Row.checkEpisodeOfCare({id: 1}, false) == hqmf.SpecificsManager.any')
|
647
|
-
@context.eval('Row.checkEpisodeOfCare({id: 1}, false).id == 1')
|
726
|
+
assert_equal true, @context.eval('Row.checkEpisodeOfCare({id: 1}, true) == hqmf.SpecificsManager.any')
|
727
|
+
assert_equal false, @context.eval('Row.checkEpisodeOfCare({id: 1}, false) == hqmf.SpecificsManager.any')
|
728
|
+
assert_equal true, @context.eval('Row.checkEpisodeOfCare({id: 1}, false).id == 1')
|
648
729
|
|
649
730
|
# test intersect
|
650
|
-
@context.eval('row1.intersect(row2,[0,1]).allValuesAny([0,1,2])')
|
651
|
-
@context.eval('row1.intersect(row2,[0]).allValuesAny([2])')
|
652
|
-
@context.eval('row1.intersect(row2,[0]).values[0].id == 1')
|
653
|
-
@context.eval('row1.intersect(row2,[0]).values[1].id == 3')
|
654
|
-
@context.eval('row1.intersect(row2,[1]).allValuesAny([2])')
|
655
|
-
@context.eval('row1.intersect(row2,[1]).values[0].id == 1')
|
656
|
-
@context.eval('row1.intersect(row2,[1]).values[1].id == 3')
|
657
|
-
|
658
|
-
@context.eval('identityRow.intersect(row1,[0]).values[0].id == 1')
|
659
|
-
@context.eval('identityRow.intersect(row1,[0]).allValuesAny([1,2])')
|
660
|
-
@context.eval('row1.intersect(identityRow,[0]).values[0].id == 1')
|
661
|
-
@context.eval('row1.intersect(identityRow,[0]).allValuesAny([1,2])')
|
731
|
+
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
|
732
|
+
assert_equal true, @context.eval('row1.intersect(row2,[0]).allValuesAny([2])')
|
733
|
+
assert_equal true, @context.eval('row1.intersect(row2,[0]).values[0].id == 1')
|
734
|
+
assert_equal true, @context.eval('row1.intersect(row2,[0]).values[1].id == 3')
|
735
|
+
assert_equal true, @context.eval('row1.intersect(row2,[1]).allValuesAny([2])')
|
736
|
+
assert_equal true, @context.eval('row1.intersect(row2,[1]).values[0].id == 1')
|
737
|
+
assert_equal true, @context.eval('row1.intersect(row2,[1]).values[1].id == 3')
|
738
|
+
|
739
|
+
assert_equal true, @context.eval('identityRow.intersect(row1,[0]).values[0].id == 1')
|
740
|
+
assert_equal true, @context.eval('identityRow.intersect(row1,[0]).allValuesAny([1,2])')
|
741
|
+
assert_equal true, @context.eval('row1.intersect(identityRow,[0]).values[0].id == 1')
|
742
|
+
assert_equal true, @context.eval('row1.intersect(identityRow,[0]).allValuesAny([1,2])')
|
662
743
|
|
663
744
|
# make sure we drop a bad strggler for encounter 2
|
664
|
-
@context.eval('row1.intersect(row3,[0,1]).allValuesAny([1,2])')
|
665
|
-
@context.eval('row1.intersect(row3,[0,1]).values[0].id == 1')
|
745
|
+
assert_equal true, @context.eval('row1.intersect(row3,[0,1]).allValuesAny([1,2])')
|
746
|
+
assert_equal true, @context.eval('row1.intersect(row3,[0,1]).values[0].id == 1')
|
666
747
|
|
667
748
|
# test intersectSpecifics
|
668
749
|
|
669
|
-
@context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[0].id == 1')
|
670
|
-
@context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[1].id == 3')
|
671
|
-
@context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[2] == hqmf.SpecificsManager.any')
|
672
|
-
@context.eval("hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,['OccurrenceAEncounter1','OccurrenceAEncounter2','OccurrenceAEncounter3']).specificContext.rows[0].allValuesAny([0,1,2])")
|
750
|
+
assert_equal true, @context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[0].id == 1')
|
751
|
+
assert_equal true, @context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[1].id == 3')
|
752
|
+
assert_equal true, @context.eval('hqmf.SpecificsManager.intersectSpecifics(pop1,pop2).specificContext.rows[0].values[2] == hqmf.SpecificsManager.any')
|
753
|
+
assert_equal true, @context.eval("hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,['OccurrenceAEncounter1','OccurrenceAEncounter2','OccurrenceAEncounter3']).specificContext.rows[0].allValuesAny([0,1,2])")
|
673
754
|
@context.eval("result = hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,['OccurrenceAEncounter1']).specificContext.rows[0]")
|
674
|
-
@context.eval('result.allValuesAny([2])')
|
675
|
-
@context.eval('result.values[0].id == 1')
|
676
|
-
@context.eval('result.values[1].id == 3')
|
755
|
+
assert_equal true, @context.eval('result.allValuesAny([2])')
|
756
|
+
assert_equal true, @context.eval('result.values[0].id == 1')
|
757
|
+
assert_equal true, @context.eval('result.values[1].id == 3')
|
677
758
|
@context.eval("result = hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,['OccurrenceAEncounter2']).specificContext.rows[0]")
|
678
|
-
@context.eval('result.allValuesAny([2])')
|
679
|
-
@context.eval('result.values[0].id == 1')
|
680
|
-
@context.eval('result.values[1].id == 3')
|
759
|
+
assert_equal true, @context.eval('result.allValuesAny([2])')
|
760
|
+
assert_equal true, @context.eval('result.values[0].id == 1')
|
761
|
+
assert_equal true, @context.eval('result.values[1].id == 3')
|
681
762
|
|
682
763
|
@context.eval("result = hqmf.SpecificsManager.intersectSpecifics(pop1,pop4,['OccurrenceAEncounter1']).specificContext.rows[0]")
|
683
|
-
@context.eval('result.values[0].id == 1')
|
684
|
-
@context.eval('result.allValuesAny([1,2])')
|
764
|
+
assert_equal true, @context.eval('result.values[0].id == 1')
|
765
|
+
assert_equal true, @context.eval('result.allValuesAny([1,2])')
|
685
766
|
|
686
767
|
@context.eval("result = hqmf.SpecificsManager.intersectSpecifics(pop4,pop1,['OccurrenceAEncounter1']).specificContext.rows[0]")
|
687
|
-
@context.eval('result.values[0].id == 1')
|
688
|
-
@context.eval('result.allValuesAny([1,2])')
|
768
|
+
assert_equal true, @context.eval('result.values[0].id == 1')
|
769
|
+
assert_equal true, @context.eval('result.allValuesAny([1,2])')
|
689
770
|
|
690
771
|
@context.eval("result = hqmf.SpecificsManager.intersectSpecifics(pop1,pop3,['OccurrenceAEncounter1','OccurrenceAEncounter2']).specificContext.rows[0]")
|
691
|
-
@context.eval('result.allValuesAny([1,2])')
|
692
|
-
@context.eval('result.values[0].id == 1')
|
772
|
+
assert_equal true, @context.eval('result.allValuesAny([1,2])')
|
773
|
+
assert_equal true, @context.eval('result.values[0].id == 1')
|
693
774
|
|
694
775
|
end
|
695
776
|
|
@@ -726,20 +807,20 @@ class SpecificsTest < Test::Unit::TestCase
|
|
726
807
|
assert @context.eval('intersection.isTrue()')
|
727
808
|
@context.eval('var result = intersection.specificContext')
|
728
809
|
|
729
|
-
@context.eval('result.rows.length')
|
810
|
+
assert_equal 3, @context.eval('result.rows.length')
|
730
811
|
|
731
|
-
@context.eval('result.rows[0].values[0].id')
|
732
|
-
@context.eval('result.rows[0].values[1].id')
|
733
|
-
@context.eval('result.rows[1].values[0].id')
|
734
|
-
@context.eval('result.rows[1].values[1].id')
|
735
|
-
@context.eval('result.rows[2].values[0].id')
|
736
|
-
@context.eval('result.rows[2].values[1].id')
|
812
|
+
assert_equal 1, @context.eval('result.rows[0].values[0].id')
|
813
|
+
assert_equal 4, @context.eval('result.rows[0].values[1].id')
|
814
|
+
assert_equal 1, @context.eval('result.rows[1].values[0].id')
|
815
|
+
assert_equal 5, @context.eval('result.rows[1].values[1].id')
|
816
|
+
assert_equal 2, @context.eval('result.rows[2].values[0].id')
|
817
|
+
assert_equal 4, @context.eval('result.rows[2].values[1].id')
|
737
818
|
|
738
819
|
@context.eval('var intersection = hqmf.SpecificsManager.intersectAll(new Boolean(true), [pop1,pop2,pop3], true)')
|
739
820
|
@context.eval('var result = intersection.specificContext')
|
740
821
|
|
741
822
|
# 5*5 = 25 - 5 equal rows - 3 non-negated = 17
|
742
|
-
@context.eval('result.rows.length')
|
823
|
+
assert_equal 17, @context.eval('result.rows.length')
|
743
824
|
|
744
825
|
end
|
745
826
|
|
@@ -776,7 +857,7 @@ class SpecificsTest < Test::Unit::TestCase
|
|
776
857
|
assert @context.eval('union.isTrue()')
|
777
858
|
@context.eval('var result = union.specificContext')
|
778
859
|
|
779
|
-
@context.eval('result.rows.length')
|
860
|
+
assert_equal 8, @context.eval('result.rows.length')
|
780
861
|
|
781
862
|
@context.eval('var union = hqmf.SpecificsManager.unionAll(new Boolean(true), [pop1,pop2,pop3], true)')
|
782
863
|
assert @context.eval('union.isTrue()')
|
@@ -785,7 +866,7 @@ class SpecificsTest < Test::Unit::TestCase
|
|
785
866
|
# originally 5*5, but we remove 1,2 from the left and 2,4,5 from the right
|
786
867
|
# that leaves [3,4,5] x [1,3] which is 6 rows... minus the 3,3 row we get 5 rows
|
787
868
|
|
788
|
-
@context.eval('result.rows.length')
|
869
|
+
assert_equal 5, @context.eval('result.rows.length')
|
789
870
|
|
790
871
|
end
|
791
872
|
|
@@ -802,17 +883,17 @@ class SpecificsTest < Test::Unit::TestCase
|
|
802
883
|
"
|
803
884
|
@context.eval(rows)
|
804
885
|
|
805
|
-
@context.eval("row1.groupKey()")
|
806
|
-
@context.eval("row1.groupKey('OccurrenceAEncounter')")
|
807
|
-
@context.eval("row1.groupKey('OccurrenceAProcedure')")
|
808
|
-
@context.eval("row2.groupKey()")
|
809
|
-
@context.eval("row2.groupKey('OccurrenceAProcedure')")
|
810
|
-
@context.eval("row3.groupKey()")
|
811
|
-
@context.eval("row3.groupKey('OccurrenceAEncounter')")
|
812
|
-
@context.eval("row3.groupKey('OccurrenceBEncounter')")
|
813
|
-
@context.eval("row3.groupKey('OccurrenceAProcedure')")
|
814
|
-
@context.eval("row4.groupKey()")
|
815
|
-
@context.eval("row4.groupKey('OccurrenceBEncounter')")
|
886
|
+
assert_equal "1_*_*_", @context.eval("row1.groupKey()")
|
887
|
+
assert_equal "X_*_*_", @context.eval("row1.groupKey('OccurrenceAEncounter')")
|
888
|
+
assert_equal "1_*_X_", @context.eval("row1.groupKey('OccurrenceAProcedure')")
|
889
|
+
assert_equal "*_2_*_", @context.eval("row2.groupKey()")
|
890
|
+
assert_equal "*_2_X_", @context.eval("row2.groupKey('OccurrenceAProcedure')")
|
891
|
+
assert_equal "1_4_*_", @context.eval("row3.groupKey()")
|
892
|
+
assert_equal "X_4_*_", @context.eval("row3.groupKey('OccurrenceAEncounter')")
|
893
|
+
assert_equal "1_X_*_", @context.eval("row3.groupKey('OccurrenceBEncounter')")
|
894
|
+
assert_equal "1_4_X_", @context.eval("row3.groupKey('OccurrenceAProcedure')")
|
895
|
+
assert_equal "*_*_*_", @context.eval("row4.groupKey()")
|
896
|
+
assert_equal "*_X_*_", @context.eval("row4.groupKey('OccurrenceBEncounter')")
|
816
897
|
|
817
898
|
end
|
818
899
|
|
@@ -839,13 +920,13 @@ class SpecificsTest < Test::Unit::TestCase
|
|
839
920
|
"
|
840
921
|
@context.eval(rows)
|
841
922
|
|
842
|
-
@context.eval("specific1.group()['1_*_'].length")
|
843
|
-
@context.eval("specific1.group()['2_*_'].length")
|
844
|
-
@context.eval("specific1.group()['3_*_'].length")
|
923
|
+
assert_equal 2, @context.eval("specific1.group()['1_*_'].length")
|
924
|
+
assert_equal 3, @context.eval("specific1.group()['2_*_'].length")
|
925
|
+
assert_equal 1, @context.eval("specific1.group()['3_*_'].length")
|
845
926
|
|
846
|
-
@context.eval("specific2.group('OccurrenceAEncounter')['X_1_'].length")
|
847
|
-
@context.eval("specific2.group('OccurrenceAEncounter')['X_2_'].length")
|
848
|
-
@context.eval("specific2.group('OccurrenceAEncounter')['X_3_'].length")
|
927
|
+
assert_equal 2, @context.eval("specific2.group('OccurrenceAEncounter')['X_1_'].length")
|
928
|
+
assert_equal 3, @context.eval("specific2.group('OccurrenceAEncounter')['X_2_'].length")
|
929
|
+
assert_equal 1, @context.eval("specific2.group('OccurrenceAEncounter')['X_3_'].length")
|
849
930
|
|
850
931
|
end
|
851
932
|
|
@@ -866,21 +947,21 @@ class SpecificsTest < Test::Unit::TestCase
|
|
866
947
|
new Row('OccurrenceAEncounter',{'OccurrenceAEncounter': new hQuery.CodedEntry({_id:15}), 'OccurrenceBEncounter':new hQuery.CodedEntry({'_id':3})})]
|
867
948
|
"
|
868
949
|
@context.eval(rows)
|
869
|
-
@context.eval('hqmf.SpecificsManager.
|
870
|
-
@context.eval('hqmf.SpecificsManager.
|
871
|
-
@context.eval('hqmf.SpecificsManager.
|
872
|
-
@context.eval('hqmf.SpecificsManager.
|
873
|
-
@context.eval('hqmf.SpecificsManager.
|
874
|
-
@context.eval('hqmf.SpecificsManager.
|
875
|
-
@context.eval('hqmf.SpecificsManager.
|
876
|
-
|
877
|
-
@context.eval("hqmf.SpecificsManager.
|
878
|
-
@context.eval("hqmf.SpecificsManager.
|
879
|
-
@context.eval("hqmf.SpecificsManager.
|
880
|
-
@context.eval("hqmf.SpecificsManager.
|
881
|
-
@context.eval("hqmf.SpecificsManager.
|
882
|
-
@context.eval("hqmf.SpecificsManager.
|
883
|
-
@context.eval("hqmf.SpecificsManager.
|
950
|
+
assert_equal 6, @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows).length')
|
951
|
+
assert_equal '10', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[0].id')
|
952
|
+
assert_equal '11', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[1].id')
|
953
|
+
assert_equal '12', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[2].id')
|
954
|
+
assert_equal '13', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[3].id')
|
955
|
+
assert_equal '14', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[4].id')
|
956
|
+
assert_equal '15', @context.eval('hqmf.SpecificsManager.extractEventsForLeftMost(non_specific_rows)[5].id')
|
957
|
+
|
958
|
+
assert_equal 6, @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows).length")
|
959
|
+
assert_equal '10', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[0].id")
|
960
|
+
assert_equal '11', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[1].id")
|
961
|
+
assert_equal '12', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[2].id")
|
962
|
+
assert_equal '13', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[3].id")
|
963
|
+
assert_equal '14', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[4].id")
|
964
|
+
assert_equal '15', @context.eval("hqmf.SpecificsManager.extractEventsForLeftMost(specific_rows)[5].id")
|
884
965
|
|
885
966
|
end
|
886
967
|
|
@@ -922,68 +1003,68 @@ class SpecificsTest < Test::Unit::TestCase
|
|
922
1003
|
lessThanThree = 'new IVL_PQ(null, new PQ(2))'
|
923
1004
|
exactly1 = 'new IVL_PQ(new PQ(1), new PQ(1))'
|
924
1005
|
|
925
|
-
@context.eval("specific1.COUNT(#{moreThanOne}).rows.length")
|
926
|
-
@context.eval("specific1.COUNT(#{moreThanOne}).rows[0].
|
927
|
-
@context.eval("specific1.COUNT(#{moreThanOne}).rows[1].
|
928
|
-
@context.eval("specific1.COUNT(#{moreThanOne}).rows[2].
|
929
|
-
@context.eval("specific1.COUNT(#{moreThanOne}).rows[3].
|
930
|
-
@context.eval("specific1.COUNT(#{moreThanOne}).rows[4].
|
931
|
-
@context.eval("specific1.COUNT(#{lessThanThree}).rows.length")
|
932
|
-
@context.eval("specific1.COUNT(#{lessThanThree}).rows[0].
|
933
|
-
@context.eval("specific1.COUNT(#{lessThanThree}).rows[1].
|
934
|
-
@context.eval("specific1.COUNT(#{lessThanThree}).rows[2].
|
935
|
-
@context.eval("specific1.COUNT(#{exactly1}).rows.length")
|
936
|
-
@context.eval("specific1.COUNT(#{exactly1}).rows[0].
|
937
|
-
|
938
|
-
@context.eval("specific2.COUNT(#{moreThanOne}).rows.length")
|
939
|
-
@context.eval("specific2.COUNT(#{moreThanOne}).rows[0].values[0].id")
|
940
|
-
@context.eval("specific2.COUNT(#{moreThanOne}).rows[1].values[0].id")
|
941
|
-
@context.eval("specific2.COUNT(#{moreThanOne}).rows[2].values[0].id")
|
942
|
-
@context.eval("specific2.COUNT(#{moreThanOne}).rows[3].values[0].id")
|
943
|
-
@context.eval("specific2.COUNT(#{moreThanOne}).rows[4].values[0].id")
|
944
|
-
@context.eval("specific2.COUNT(#{lessThanThree}).rows.length")
|
945
|
-
@context.eval("specific2.COUNT(#{lessThanThree}).rows[0].values[0].id")
|
946
|
-
@context.eval("specific2.COUNT(#{lessThanThree}).rows[1].values[0].id")
|
947
|
-
@context.eval("specific2.COUNT(#{lessThanThree}).rows[2].values[0].id")
|
948
|
-
@context.eval("specific2.COUNT(#{exactly1}).rows.length")
|
949
|
-
@context.eval("specific2.COUNT(#{exactly1}).rows[0].values[0].id")
|
950
|
-
|
951
|
-
@context.eval("specific3.COUNT(#{exactly1}).rows.length")
|
952
|
-
@context.eval("specific4.COUNT(#{moreThanOne}).rows.length")
|
1006
|
+
assert_equal 5, @context.eval("specific1.COUNT(#{moreThanOne}).rows.length")
|
1007
|
+
assert_equal '10', @context.eval("specific1.COUNT(#{moreThanOne}).rows[0].nonSpecificLeftMost.id")
|
1008
|
+
assert_equal '11', @context.eval("specific1.COUNT(#{moreThanOne}).rows[1].nonSpecificLeftMost.id")
|
1009
|
+
assert_equal '12', @context.eval("specific1.COUNT(#{moreThanOne}).rows[2].nonSpecificLeftMost.id")
|
1010
|
+
assert_equal '13', @context.eval("specific1.COUNT(#{moreThanOne}).rows[3].nonSpecificLeftMost.id")
|
1011
|
+
assert_equal '14', @context.eval("specific1.COUNT(#{moreThanOne}).rows[4].nonSpecificLeftMost.id")
|
1012
|
+
assert_equal 3, @context.eval("specific1.COUNT(#{lessThanThree}).rows.length")
|
1013
|
+
assert_equal '10', @context.eval("specific1.COUNT(#{lessThanThree}).rows[0].nonSpecificLeftMost.id")
|
1014
|
+
assert_equal '11', @context.eval("specific1.COUNT(#{lessThanThree}).rows[1].nonSpecificLeftMost.id")
|
1015
|
+
assert_equal '15', @context.eval("specific1.COUNT(#{lessThanThree}).rows[2].nonSpecificLeftMost.id")
|
1016
|
+
assert_equal 1, @context.eval("specific1.COUNT(#{exactly1}).rows.length")
|
1017
|
+
assert_equal '15', @context.eval("specific1.COUNT(#{exactly1}).rows[0].nonSpecificLeftMost.id")
|
1018
|
+
|
1019
|
+
assert_equal 5, @context.eval("specific2.COUNT(#{moreThanOne}).rows.length")
|
1020
|
+
assert_equal '10', @context.eval("specific2.COUNT(#{moreThanOne}).rows[0].values[0].id")
|
1021
|
+
assert_equal '11', @context.eval("specific2.COUNT(#{moreThanOne}).rows[1].values[0].id")
|
1022
|
+
assert_equal '12', @context.eval("specific2.COUNT(#{moreThanOne}).rows[2].values[0].id")
|
1023
|
+
assert_equal '13', @context.eval("specific2.COUNT(#{moreThanOne}).rows[3].values[0].id")
|
1024
|
+
assert_equal '14', @context.eval("specific2.COUNT(#{moreThanOne}).rows[4].values[0].id")
|
1025
|
+
assert_equal 3, @context.eval("specific2.COUNT(#{lessThanThree}).rows.length")
|
1026
|
+
assert_equal '10', @context.eval("specific2.COUNT(#{lessThanThree}).rows[0].values[0].id")
|
1027
|
+
assert_equal '11', @context.eval("specific2.COUNT(#{lessThanThree}).rows[1].values[0].id")
|
1028
|
+
assert_equal '15', @context.eval("specific2.COUNT(#{lessThanThree}).rows[2].values[0].id")
|
1029
|
+
assert_equal 1, @context.eval("specific2.COUNT(#{exactly1}).rows.length")
|
1030
|
+
assert_equal '15', @context.eval("specific2.COUNT(#{exactly1}).rows[0].values[0].id")
|
1031
|
+
|
1032
|
+
assert_equal 1, @context.eval("specific3.COUNT(#{exactly1}).rows.length")
|
1033
|
+
assert_equal 0, @context.eval("specific4.COUNT(#{moreThanOne}).rows.length")
|
953
1034
|
|
954
1035
|
|
955
1036
|
###
|
956
1037
|
##### FIRST
|
957
1038
|
###
|
958
|
-
@context.eval("specific1.FIRST().rows.length")
|
959
|
-
@context.eval("specific1.FIRST().rows[0].
|
960
|
-
@context.eval("specific1.FIRST().rows[1].
|
961
|
-
@context.eval("specific1.FIRST().rows[2].
|
962
|
-
|
963
|
-
@context.eval("specific2.FIRST().rows.length")
|
964
|
-
@context.eval("specific2.FIRST().rows[0].values[0].id")
|
965
|
-
@context.eval("specific2.FIRST().rows[1].values[0].id")
|
966
|
-
@context.eval("specific2.FIRST().rows[2].values[0].id")
|
1039
|
+
assert_equal 3, @context.eval("specific1.FIRST().rows.length")
|
1040
|
+
assert_equal '11', @context.eval("specific1.FIRST().rows[0].nonSpecificLeftMost.id")
|
1041
|
+
assert_equal '12', @context.eval("specific1.FIRST().rows[1].nonSpecificLeftMost.id")
|
1042
|
+
assert_equal '15', @context.eval("specific1.FIRST().rows[2].nonSpecificLeftMost.id")
|
1043
|
+
|
1044
|
+
assert_equal 3, @context.eval("specific2.FIRST().rows.length")
|
1045
|
+
assert_equal '11', @context.eval("specific2.FIRST().rows[0].values[0].id")
|
1046
|
+
assert_equal '12', @context.eval("specific2.FIRST().rows[1].values[0].id")
|
1047
|
+
assert_equal '15', @context.eval("specific2.FIRST().rows[2].values[0].id")
|
967
1048
|
|
968
|
-
@context.eval("specific3.FIRST().rows.length")
|
969
|
-
@context.eval("specific4.FIRST().rows.length")
|
1049
|
+
assert_equal 1, @context.eval("specific3.FIRST().rows.length")
|
1050
|
+
assert_equal 0, @context.eval("specific4.FIRST().rows.length")
|
970
1051
|
|
971
1052
|
###
|
972
1053
|
##### MOST RECENT
|
973
1054
|
###
|
974
1055
|
|
975
|
-
@context.eval("specific1.RECENT().rows.length")
|
976
|
-
@context.eval("specific1.RECENT().rows[0].
|
977
|
-
@context.eval("specific1.RECENT().rows[1].
|
978
|
-
@context.eval("specific1.RECENT().rows[2].
|
979
|
-
|
980
|
-
@context.eval("specific2.RECENT().rows.length")
|
981
|
-
@context.eval("specific2.RECENT().rows[0].values[0].id")
|
982
|
-
@context.eval("specific2.RECENT().rows[1].values[0].id")
|
983
|
-
@context.eval("specific2.RECENT().rows[2].values[0].id")
|
1056
|
+
assert_equal 3, @context.eval("specific1.RECENT().rows.length")
|
1057
|
+
assert_equal '10', @context.eval("specific1.RECENT().rows[0].nonSpecificLeftMost.id")
|
1058
|
+
assert_equal '13', @context.eval("specific1.RECENT().rows[1].nonSpecificLeftMost.id")
|
1059
|
+
assert_equal '15', @context.eval("specific1.RECENT().rows[2].nonSpecificLeftMost.id")
|
1060
|
+
|
1061
|
+
assert_equal 3, @context.eval("specific2.RECENT().rows.length")
|
1062
|
+
assert_equal '10', @context.eval("specific2.RECENT().rows[0].values[0].id")
|
1063
|
+
assert_equal '13', @context.eval("specific2.RECENT().rows[1].values[0].id")
|
1064
|
+
assert_equal '15', @context.eval("specific2.RECENT().rows[2].values[0].id")
|
984
1065
|
|
985
|
-
@context.eval("specific3.RECENT().rows.length")
|
986
|
-
@context.eval("specific4.RECENT().rows.length")
|
1066
|
+
assert_equal 1, @context.eval("specific3.RECENT().rows.length")
|
1067
|
+
assert_equal 0, @context.eval("specific4.RECENT().rows.length")
|
987
1068
|
|
988
1069
|
|
989
1070
|
end
|