hqmf2js 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -7,7 +7,7 @@ class SpecificsTest < Test::Unit::TestCase
7
7
  @context = get_js_context(HQMF2JS::Generator::JS.library_functions)
8
8
  test_initialize_js =
9
9
  "
10
- Specifics.initialize({},hqmfjs, {'id':'OccurrenceAEncounter', 'type':'Encounter', 'function':'SourceOccurrenceAEncounter'},{'id':'OccurrenceBEncounter', 'type':'Encounter', 'function':'SourceOccurrenceBEncounter'})
10
+ hqmf.SpecificsManager.initialize({},hqmfjs, {'id':'OccurrenceAEncounter', 'type':'Encounter', 'function':'SourceOccurrenceAEncounter'},{'id':'OccurrenceBEncounter', 'type':'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,24 +21,24 @@ class SpecificsTest < Test::Unit::TestCase
21
21
 
22
22
  def test_specifics_initialized_proper
23
23
 
24
- @context.eval('Specifics.KEY_LOOKUP[0]').must_equal 'OccurrenceAEncounter'
25
- @context.eval('Specifics.KEY_LOOKUP[1]').must_equal 'OccurrenceBEncounter'
26
- @context.eval("Specifics.INDEX_LOOKUP['OccurrenceAEncounter']").must_equal 0
27
- @context.eval("Specifics.INDEX_LOOKUP['OccurrenceBEncounter']").must_equal 1
28
- @context.eval('Specifics.FUNCTION_LOOKUP[0]').must_equal 'SourceOccurrenceAEncounter'
29
- @context.eval('Specifics.FUNCTION_LOOKUP[1]').must_equal 'SourceOccurrenceBEncounter'
30
- @context.eval("Specifics.TYPE_LOOKUP['Encounter'].length").must_equal 2
31
- @context.eval("Specifics.TYPE_LOOKUP['Encounter'][0]").must_equal 0
32
- @context.eval("Specifics.TYPE_LOOKUP['Encounter'][1]").must_equal 1
24
+ @context.eval('hqmf.SpecificsManager.keyLookup[0]').must_equal 'OccurrenceAEncounter'
25
+ @context.eval('hqmf.SpecificsManager.keyLookup[1]').must_equal 'OccurrenceBEncounter'
26
+ @context.eval("hqmf.SpecificsManager.indexLookup['OccurrenceAEncounter']").must_equal 0
27
+ @context.eval("hqmf.SpecificsManager.indexLookup['OccurrenceBEncounter']").must_equal 1
28
+ @context.eval('hqmf.SpecificsManager.functionLookup[0]').must_equal 'SourceOccurrenceAEncounter'
29
+ @context.eval('hqmf.SpecificsManager.functionLookup[1]').must_equal 'SourceOccurrenceBEncounter'
30
+ @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'].length").must_equal 2
31
+ @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'][0]").must_equal 0
32
+ @context.eval("hqmf.SpecificsManager.typeLookup['Encounter'][1]").must_equal 1
33
33
  end
34
34
 
35
35
  def test_specifics_row_union
36
36
 
37
37
  union_rows = "
38
38
  var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1}});
39
- var specific1 = new Specifics([row1]);
39
+ var specific1 = new hqmf.SpecificOccurrence([row1]);
40
40
  var row2 = new Row('OccurrenceAEncounter',{'OccurrenceBEncounter':{'id':2}});
41
- var specific2 = new Specifics([row2]);
41
+ var specific2 = new hqmf.SpecificOccurrence([row2]);
42
42
  result = specific1.union(specific2);
43
43
  result.rows.length;
44
44
  "
@@ -153,17 +153,17 @@ class SpecificsTest < Test::Unit::TestCase
153
153
  var row5 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':3},'OccurrenceBEncounter':{'id':3}});
154
154
  var row6 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':3}});
155
155
 
156
- var specific1 = new Specifics([row1]);
157
- var specific2 = new Specifics([row2]);
158
- var specific3 = new Specifics([row3,row4]);
159
- var specific4 = new Specifics([row3,row6]);
160
- var specific5 = new Specifics([row5,row6]);
156
+ var specific1 = new hqmf.SpecificOccurrence([row1]);
157
+ var specific2 = new hqmf.SpecificOccurrence([row2]);
158
+ var specific3 = new hqmf.SpecificOccurrence([row3,row4]);
159
+ var specific4 = new hqmf.SpecificOccurrence([row3,row6]);
160
+ var specific5 = new hqmf.SpecificOccurrence([row5,row6]);
161
161
 
162
- var allSpecific1 = new Specifics();
162
+ var allSpecific1 = new hqmf.SpecificOccurrence();
163
163
  allSpecific1.addIdentityRow();
164
164
  allSpecific1.addIdentityRow();
165
165
  allSpecific1.addIdentityRow();
166
- var allSpecific2 = new Specifics();
166
+ var allSpecific2 = new hqmf.SpecificOccurrence();
167
167
  allSpecific2.addIdentityRow();
168
168
  allSpecific2.addIdentityRow();
169
169
  allSpecific2.addIdentityRow();
@@ -202,6 +202,90 @@ class SpecificsTest < Test::Unit::TestCase
202
202
 
203
203
  end
204
204
 
205
+ def test_specifics_event_counting
206
+
207
+ init_rows = "
208
+ var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':20}});
209
+ var row2 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':2},'OccurrenceBEncounter':{'id':20}});
210
+ var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':3},'OccurrenceBEncounter':{'id':30}});
211
+
212
+ var specific = new hqmf.SpecificOccurrence([row1,row2,row3]);
213
+ specific.addIdentityRow();
214
+
215
+ var pop = new Boolean(true);
216
+ pop.specificContext = specific;
217
+ "
218
+
219
+ @context.eval(init_rows)
220
+ @context.eval("specific.uniqueEvents([0])").must_equal 3
221
+ @context.eval("specific.uniqueEvents([1])").must_equal 2
222
+ @context.eval('hqmf.SpecificsManager.indexLookup["OccurrenceAEncounter"]').must_equal 0
223
+ @context.eval('hqmf.SpecificsManager.indexLookup["OccurrenceBEncounter"]').must_equal 1
224
+ @context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceAEncounter")').must_equal 0
225
+ @context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceBEncounter")').must_equal 1
226
+ assert_raise V8::JSError do
227
+ @context.eval('hqmf.SpecificsManager.getColumnIndex("OccurrenceCEncounter")')
228
+ end
229
+ @context.eval('hqmf.SpecificsManager.validate(pop)').must_equal true
230
+ @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceAEncounter"], pop)').must_equal 3
231
+ @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceBEncounter"], pop)').must_equal 2
232
+ @context.eval('hqmf.SpecificsManager.countUnique(["OccurrenceAEncounter", "OccurrenceBEncounter"], pop)').must_equal 5
233
+ @context.eval('hqmf.SpecificsManager.countUnique(null, pop)').must_equal 1
234
+ end
235
+
236
+ def test_specifics_event_exclusion
237
+
238
+ init_rows = "
239
+ var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':20}});
240
+ var row2 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':2},'OccurrenceBEncounter':{'id':20}});
241
+ var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':3},'OccurrenceBEncounter':{'id':30}});
242
+
243
+ var specific1 = new hqmf.SpecificOccurrence([row1,row2,row3]);
244
+ var specific2 = new hqmf.SpecificOccurrence([row1]);
245
+ var specific3 = new hqmf.SpecificOccurrence([]);
246
+ specific3.addIdentityRow();
247
+
248
+ var pop1 = new Boolean(true);
249
+ pop1.specificContext = specific1;
250
+ var pop2 = new Boolean(true);
251
+ pop2.specificContext = specific2;
252
+ var pop3 = new Boolean(true);
253
+ pop3.specificContext = specific3;
254
+ var pop4 = new Boolean(false);
255
+ pop4.specificContext = specific3;
256
+ "
257
+
258
+ @context.eval(init_rows)
259
+ @context.eval('var resultSpecific = specific1.removeMatchingRows(0, specific2)')
260
+ @context.eval('resultSpecific.rows.length').must_equal 2
261
+ @context.eval('resultSpecific.rows[0].values[0].id').must_equal 2
262
+ @context.eval('resultSpecific.rows[1].values[0].id').must_equal 3
263
+ @context.eval('resultSpecific = specific1.removeMatchingRows(1, specific2)')
264
+ @context.eval('resultSpecific.rows.length').must_equal 1
265
+ @context.eval('resultSpecific.rows[0].values[0].id').must_equal 3
266
+ @context.eval('var result = hqmf.SpecificsManager.exclude(["OccurrenceAEncounter"], pop1, pop2)')
267
+ @context.eval('result.isTrue()').must_equal true
268
+ @context.eval('result.specificContext.rows.length').must_equal 2
269
+ @context.eval('result.specificContext.rows[0].values[0].id').must_equal 2
270
+ @context.eval('result.specificContext.rows[1].values[0].id').must_equal 3
271
+ @context.eval('result = hqmf.SpecificsManager.exclude(["OccurrenceBEncounter"], pop1, pop2)')
272
+ @context.eval('result.isTrue()').must_equal true
273
+ @context.eval('result.specificContext.rows.length').must_equal 1
274
+ @context.eval('result.specificContext.rows[0].values[0].id').must_equal 3
275
+ @context.eval('result = hqmf.SpecificsManager.exclude(["OccurrenceAEncounter","OccurrenceBEncounter"], pop1, pop2)')
276
+ @context.eval('result.isTrue()').must_equal true
277
+ @context.eval('result.specificContext.rows.length').must_equal 1
278
+ @context.eval('result.specificContext.rows[0].values[0].id').must_equal 3
279
+ @context.eval('result = hqmf.SpecificsManager.exclude(null, pop3, pop3)')
280
+ @context.eval('result.isTrue()').must_equal false
281
+ @context.eval('result = hqmf.SpecificsManager.exclude(null, pop3, pop4)')
282
+ @context.eval('result.isTrue()').must_equal true
283
+ @context.eval('result = hqmf.SpecificsManager.exclude(null, pop4, pop3)')
284
+ @context.eval('result.isTrue()').must_equal false
285
+ @context.eval('result = hqmf.SpecificsManager.exclude(null, pop4, pop4)')
286
+ @context.eval('result.isTrue()').must_equal false
287
+ end
288
+
205
289
  def test_negation
206
290
  rows = "
207
291
  var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1}});
@@ -211,12 +295,12 @@ class SpecificsTest < Test::Unit::TestCase
211
295
  var row5 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':3},'OccurrenceBEncounter':{'id':4}});
212
296
  var row6 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':3}});
213
297
 
214
- var specific1 = new Specifics([row1]);
215
- var specific2 = new Specifics([row2]);
216
- var specific3 = new Specifics([row3,row4]);
217
- var specific4 = new Specifics([row3,row6]);
218
- var specific5 = new Specifics([row5,row6]);
219
- var specific6 = new Specifics([row1,row2])
298
+ var specific1 = new hqmf.SpecificOccurrence([row1]);
299
+ var specific2 = new hqmf.SpecificOccurrence([row2]);
300
+ var specific3 = new hqmf.SpecificOccurrence([row3,row4]);
301
+ var specific4 = new hqmf.SpecificOccurrence([row3,row6]);
302
+ var specific5 = new hqmf.SpecificOccurrence([row5,row6]);
303
+ var specific6 = new hqmf.SpecificOccurrence([row1,row2])
220
304
  "
221
305
 
222
306
  # test negation single specific
@@ -232,14 +316,14 @@ class SpecificsTest < Test::Unit::TestCase
232
316
  @context.eval('specific1.hasRow(row5)').must_equal false
233
317
 
234
318
  # cartesian checks
235
- @context.eval('Specifics._generateCartisian([[1,2,3]]).length').must_equal 3
236
- @context.eval('Specifics._generateCartisian([[1,2,3],[5,6]]).length').must_equal 6
237
- @context.eval('Specifics._generateCartisian([[1,2,3],[5,6]])[0][0]').must_equal 1
238
- @context.eval('Specifics._generateCartisian([[1,2,3],[5,6]])[0][1]').must_equal 5
239
- @context.eval('Specifics._generateCartisian([[1,2,3],[5,6]])[1][0]').must_equal 1
240
- @context.eval('Specifics._generateCartisian([[1,2,3],[5,6]])[1][1]').must_equal 6
241
- @context.eval('Specifics._generateCartisian([[1,2,3],[5,6]])[2][0]').must_equal 2
242
- @context.eval('Specifics._generateCartisian([[1,2,3],[5,6]])[2][1]').must_equal 5
319
+ @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3]]).length').must_equal 3
320
+ @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]]).length').must_equal 6
321
+ @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[0][0]').must_equal 1
322
+ @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[0][1]').must_equal 5
323
+ @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[1][0]').must_equal 1
324
+ @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[1][1]').must_equal 6
325
+ @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[2][0]').must_equal 2
326
+ @context.eval('hqmf.SpecificsManager._generateCartisian([[1,2,3],[5,6]])[2][1]').must_equal 5
243
327
 
244
328
  # specificsWithValue on Row
245
329
  @context.eval('row1.specificsWithValues()[0]').must_equal 0
@@ -273,8 +357,8 @@ class SpecificsTest < Test::Unit::TestCase
273
357
  var row3 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':2}});
274
358
  var row3 = new Row(undefined, {});
275
359
 
276
- var specific1 = new Specifics();
277
- var specific2 = new Specifics([row2]);
360
+ var specific1 = new hqmf.SpecificOccurrence();
361
+ var specific2 = new hqmf.SpecificOccurrence([row2]);
278
362
  "
279
363
 
280
364
  # test negation single specific
@@ -303,7 +387,7 @@ class SpecificsTest < Test::Unit::TestCase
303
387
  @context.eval("x.specificContext = 'specificContext'")
304
388
  @context.eval("x.specific_occurrence = 'specific_occurrence'")
305
389
  @context.eval('var a = new Boolean(true)')
306
- @context.eval("a = Specifics.maintainSpecifics(a,x)")
390
+ @context.eval("a = hqmf.SpecificsManager.maintainSpecifics(a,x)")
307
391
  @context.eval("typeof(a.specificContext) != 'undefined'").must_equal true
308
392
  @context.eval("typeof(a.specific_occurrence) != 'undefined'").must_equal true
309
393
 
@@ -318,7 +402,7 @@ class SpecificsTest < Test::Unit::TestCase
318
402
  var row5 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':3},'OccurrenceBEncounter':{'id':3}});
319
403
  var row6 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':3}});
320
404
 
321
- var specific1 = new Specifics([row1,row2,row3,row4,row5,row6]);
405
+ var specific1 = new hqmf.SpecificOccurrence([row1,row2,row3,row4,row5,row6]);
322
406
  "
323
407
 
324
408
  @context.eval(rows)
@@ -327,6 +411,40 @@ class SpecificsTest < Test::Unit::TestCase
327
411
  @context.eval('specific1.compactReusedEvents().rows.length').must_equal 4
328
412
 
329
413
  end
414
+
415
+ def test_compact_reused_events_different_specifics
416
+
417
+ @context = get_js_context(HQMF2JS::Generator::JS.library_functions)
418
+
419
+ test_initialize_js =
420
+ "
421
+ hqmf.SpecificsManager.initialize({},hqmfjs, {'id':'OccurrenceAEncounter1', 'type':'Encounter1', 'function':'SourceOccurrenceAEncounter1'},{'id':'OccurrenceAEncounter2', 'type':'Encounter2', 'function':'SourceOccurrenceAEncounter2'})
422
+ hqmfjs.SourceOccurrenceAEncounter1 = function(patient) {
423
+ return [{'id':1},{'id':2},{'id':3},{'id':4},{'id':5}]
424
+ }
425
+ hqmfjs.SourceOccurrenceAEncounter2 = function(patient) {
426
+ return [{'id':1},{'id':2},{'id':3},{'id':4},{'id':5}]
427
+ }
428
+ "
429
+ @context.eval(test_initialize_js)
430
+
431
+ rows = "
432
+ var row1 = new Row('OccurrenceAEncounter1',{'OccurrenceAEncounter1':{'id':1}});
433
+ var row2 = new Row('OccurrenceAEncounter2',{'OccurrenceAEncounter2':{'id':2}});
434
+ var row3 = new Row('OccurrenceAEncounter1',{'OccurrenceAEncounter1':{'id':1},'OccurrenceAEncounter2':{'id':2}});
435
+ var row4 = new Row('OccurrenceAEncounter1',{'OccurrenceAEncounter1':{'id':2},'OccurrenceAEncounter2':{'id':2}});
436
+ var row5 = new Row('OccurrenceAEncounter1',{'OccurrenceAEncounter1':{'id':3},'OccurrenceAEncounter2':{'id':3}});
437
+ var row6 = new Row('OccurrenceAEncounter1',{'OccurrenceAEncounter1':{'id':1},'OccurrenceAEncounter2':{'id':3}});
438
+
439
+ var specific1 = new hqmf.SpecificOccurrence([row1,row2,row3,row4,row5,row6]);
440
+ "
441
+
442
+ @context.eval(rows)
443
+
444
+ @context.eval('specific1.rows.length').must_equal 6
445
+ @context.eval('specific1.compactReusedEvents().rows.length').must_equal 6
446
+
447
+ end
330
448
 
331
449
  def test_row_build_rows_for_matching
332
450
 
@@ -345,7 +463,7 @@ class SpecificsTest < Test::Unit::TestCase
345
463
  @context.eval('rows[0].values[1].id').must_equal 1
346
464
  @context.eval('rows[7].values[0].id').must_equal 3
347
465
  @context.eval('rows[7].values[1].id').must_equal 8
348
- @context.eval('var specific = new Specifics(rows)')
466
+ @context.eval('var specific = new hqmf.SpecificOccurrence(rows)')
349
467
  @context.eval('specific.rows.length').must_equal 8
350
468
  @context.eval('specific.compactReusedEvents().rows.length').must_equal 7
351
469
  @context.eval('var rows = Row.buildRowsForMatching(undefined,entry,boundsKey,bounds)')
@@ -386,9 +504,9 @@ class SpecificsTest < Test::Unit::TestCase
386
504
  var row7 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':5}});
387
505
  var row8 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':2},'OccurrenceBEncounter':{'id':4}});
388
506
 
389
- var specific1 = new Specifics([row1,row2]);
390
- var specific2 = new Specifics([row3,row4,row5]);
391
- var specific3 = new Specifics([row6,row7,row8]);
507
+ var specific1 = new hqmf.SpecificOccurrence([row1,row2]);
508
+ var specific2 = new hqmf.SpecificOccurrence([row3,row4,row5]);
509
+ var specific3 = new hqmf.SpecificOccurrence([row6,row7,row8]);
392
510
  "
393
511
  @context.eval(rows)
394
512
  @context.eval('var result = specific1.finalizeEvents(specific2,specific3)')
@@ -425,11 +543,11 @@ class SpecificsTest < Test::Unit::TestCase
425
543
 
426
544
  var row9 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':6}});
427
545
 
428
- var specific1 = new Specifics([row1,row2]);
429
- var specific2 = new Specifics([row3,row4,row5]);
430
- var specific3 = new Specifics([row6,row7,row8]);
431
- var specific4 = new Specifics([row9]);
432
- var specific5 = new Specifics();
546
+ var specific1 = new hqmf.SpecificOccurrence([row1,row2]);
547
+ var specific2 = new hqmf.SpecificOccurrence([row3,row4,row5]);
548
+ var specific3 = new hqmf.SpecificOccurrence([row6,row7,row8]);
549
+ var specific4 = new hqmf.SpecificOccurrence([row9]);
550
+ var specific5 = new hqmf.SpecificOccurrence();
433
551
 
434
552
  var pop1 = new Boolean(true)
435
553
  pop1.specificContext = specific1
@@ -452,10 +570,10 @@ class SpecificsTest < Test::Unit::TestCase
452
570
  "
453
571
  @context.eval(rows)
454
572
 
455
- @context.eval('Specifics.validate(pop1,pop2,pop3)').must_equal true
456
- @context.eval('Specifics.validate(pop1,pop2,pop4)').must_equal false
457
- @context.eval('Specifics.validate(pop1,pop2,pop5)').must_equal false
458
- @context.eval('Specifics.validate(pop3f,pop1,pop2)').must_equal false
573
+ @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,pop3))').must_equal true
574
+ @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,pop4))').must_equal false
575
+ @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop1,pop2,pop5))').must_equal false
576
+ @context.eval('hqmf.SpecificsManager.validate(hqmf.SpecificsManager.intersectSpecifics(pop3f,pop1,pop2))').must_equal false
459
577
 
460
578
  end
461
579
 
@@ -471,9 +589,9 @@ class SpecificsTest < Test::Unit::TestCase
471
589
  var row7 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':5}});
472
590
  var row8 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':2},'OccurrenceBEncounter':{'id':4}});
473
591
 
474
- var specific1 = new Specifics([row1,row2]);
475
- var specific2 = new Specifics([row3,row4,row5]);
476
- var specific3 = new Specifics([row6,row7,row8]);
592
+ var specific1 = new hqmf.SpecificOccurrence([row1,row2]);
593
+ var specific2 = new hqmf.SpecificOccurrence([row3,row4,row5]);
594
+ var specific3 = new hqmf.SpecificOccurrence([row6,row7,row8]);
477
595
 
478
596
  var pop1 = new Boolean(true)
479
597
  pop1.specificContext = specific1
@@ -488,7 +606,7 @@ class SpecificsTest < Test::Unit::TestCase
488
606
  "
489
607
  @context.eval(rows)
490
608
 
491
- @context.eval('var intersection = Specifics.intersectAll(new Boolean(true), [pop1,pop2,pop3])')
609
+ @context.eval('var intersection = hqmf.SpecificsManager.intersectAll(new Boolean(true), [pop1,pop2,pop3])')
492
610
  assert @context.eval('intersection.isTrue()')
493
611
  @context.eval('var result = intersection.specificContext')
494
612
 
@@ -501,7 +619,7 @@ class SpecificsTest < Test::Unit::TestCase
501
619
  @context.eval('result.rows[2].values[0].id').must_equal 2
502
620
  @context.eval('result.rows[2].values[1].id').must_equal 4
503
621
 
504
- @context.eval('var intersection = Specifics.intersectAll(new Boolean(true), [pop1,pop2,pop3], true)')
622
+ @context.eval('var intersection = hqmf.SpecificsManager.intersectAll(new Boolean(true), [pop1,pop2,pop3], true)')
505
623
  @context.eval('var result = intersection.specificContext')
506
624
 
507
625
  # 5*5 = 25 - 5 equal rows - 3 non-negated = 17
@@ -521,9 +639,9 @@ class SpecificsTest < Test::Unit::TestCase
521
639
  var row7 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1},'OccurrenceBEncounter':{'id':5}});
522
640
  var row8 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':2},'OccurrenceBEncounter':{'id':4}});
523
641
 
524
- var specific1 = new Specifics([row1,row2]);
525
- var specific2 = new Specifics([row3,row4,row5]);
526
- var specific3 = new Specifics([row6,row7,row8]);
642
+ var specific1 = new hqmf.SpecificOccurrence([row1,row2]);
643
+ var specific2 = new hqmf.SpecificOccurrence([row3,row4,row5]);
644
+ var specific3 = new hqmf.SpecificOccurrence([row6,row7,row8]);
527
645
 
528
646
  var pop1 = new Boolean(true)
529
647
  pop1.specificContext = specific1
@@ -538,13 +656,13 @@ class SpecificsTest < Test::Unit::TestCase
538
656
  "
539
657
  @context.eval(rows)
540
658
 
541
- @context.eval('var union = Specifics.unionAll(new Boolean(true), [pop1,pop2,pop3])')
659
+ @context.eval('var union = hqmf.SpecificsManager.unionAll(new Boolean(true), [pop1,pop2,pop3])')
542
660
  assert @context.eval('union.isTrue()')
543
661
  @context.eval('var result = union.specificContext')
544
662
 
545
663
  @context.eval('result.rows.length').must_equal 8
546
664
 
547
- @context.eval('var union = Specifics.unionAll(new Boolean(true), [pop1,pop2,pop3], true)')
665
+ @context.eval('var union = hqmf.SpecificsManager.unionAll(new Boolean(true), [pop1,pop2,pop3], true)')
548
666
  assert @context.eval('union.isTrue()')
549
667
  @context.eval('var result = union.specificContext')
550
668
 
@@ -558,7 +676,7 @@ class SpecificsTest < Test::Unit::TestCase
558
676
  def test_row_grouping_key
559
677
 
560
678
  rows = "
561
- Specifics.initialize({},hqmfjs, {'id':'OccurrenceAEncounter', 'type':'Encounter', 'function':'SourceOccurrenceAEncounter'},{'id':'OccurrenceBEncounter', 'type':'Encounter', 'function':'SourceOccurrenceBEncounter'},{'id':'OccurrenceAProcedure', 'type':'Procedure', 'function':'SourceOccurrenceAProcedure'})
679
+ hqmf.SpecificsManager.initialize({},hqmfjs, {'id':'OccurrenceAEncounter', 'type':'Encounter', 'function':'SourceOccurrenceAEncounter'},{'id':'OccurrenceBEncounter', 'type':'Encounter', 'function':'SourceOccurrenceBEncounter'},{'id':'OccurrenceAProcedure', 'type':'Procedure', 'function':'SourceOccurrenceAProcedure'})
562
680
 
563
681
  var row1 = new Row('OccurrenceAEncounter',{'OccurrenceAEncounter':{'id':1}});
564
682
  var row2 = new Row('OccurrenceBEncounter',{'OccurrenceBEncounter':{'id':2}});
@@ -599,8 +717,8 @@ class SpecificsTest < Test::Unit::TestCase
599
717
  new Row('OccurrenceAEncounter',{'OccurrenceAEncounter': {id:14}, 'OccurrenceBEncounter':{'id':2}}),
600
718
  new Row('OccurrenceAEncounter',{'OccurrenceAEncounter': {id:15}, 'OccurrenceBEncounter':{'id':3}})]
601
719
 
602
- var specific1 = new Specifics(non_specific_rows);
603
- var specific2 = new Specifics(specific_rows);
720
+ var specific1 = new hqmf.SpecificOccurrence(non_specific_rows);
721
+ var specific2 = new hqmf.SpecificOccurrence(specific_rows);
604
722
 
605
723
  "
606
724
  @context.eval(rows)
@@ -632,21 +750,21 @@ class SpecificsTest < Test::Unit::TestCase
632
750
  new Row('OccurrenceAEncounter',{'OccurrenceAEncounter': new hQuery.CodedEntry({_id:15}), 'OccurrenceBEncounter':new hQuery.CodedEntry({'_id':3})})]
633
751
  "
634
752
  @context.eval(rows)
635
- @context.eval('Specifics.extractEvents(undefined, non_specific_rows).length').must_equal 6
636
- @context.eval('Specifics.extractEvents(undefined, non_specific_rows)[0].id').must_equal 10
637
- @context.eval('Specifics.extractEvents(undefined, non_specific_rows)[1].id').must_equal 11
638
- @context.eval('Specifics.extractEvents(undefined, non_specific_rows)[2].id').must_equal 12
639
- @context.eval('Specifics.extractEvents(undefined, non_specific_rows)[3].id').must_equal 13
640
- @context.eval('Specifics.extractEvents(undefined, non_specific_rows)[4].id').must_equal 14
641
- @context.eval('Specifics.extractEvents(undefined, non_specific_rows)[5].id').must_equal 15
642
-
643
- @context.eval("Specifics.extractEvents('OccurrenceAEncounter', specific_rows).length").must_equal 6
644
- @context.eval("Specifics.extractEvents('OccurrenceAEncounter', specific_rows)[0].id").must_equal 10
645
- @context.eval("Specifics.extractEvents('OccurrenceAEncounter', specific_rows)[1].id").must_equal 11
646
- @context.eval("Specifics.extractEvents('OccurrenceAEncounter', specific_rows)[2].id").must_equal 12
647
- @context.eval("Specifics.extractEvents('OccurrenceAEncounter', specific_rows)[3].id").must_equal 13
648
- @context.eval("Specifics.extractEvents('OccurrenceAEncounter', specific_rows)[4].id").must_equal 14
649
- @context.eval("Specifics.extractEvents('OccurrenceAEncounter', specific_rows)[5].id").must_equal 15
753
+ @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows).length').must_equal 6
754
+ @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[0].id').must_equal 10
755
+ @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[1].id').must_equal 11
756
+ @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[2].id').must_equal 12
757
+ @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[3].id').must_equal 13
758
+ @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[4].id').must_equal 14
759
+ @context.eval('hqmf.SpecificsManager.extractEvents(undefined, non_specific_rows)[5].id').must_equal 15
760
+
761
+ @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows).length").must_equal 6
762
+ @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[0].id").must_equal 10
763
+ @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[1].id").must_equal 11
764
+ @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[2].id").must_equal 12
765
+ @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[3].id").must_equal 13
766
+ @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[4].id").must_equal 14
767
+ @context.eval("hqmf.SpecificsManager.extractEvents('OccurrenceAEncounter', specific_rows)[5].id").must_equal 15
650
768
 
651
769
  end
652
770
 
@@ -672,10 +790,10 @@ class SpecificsTest < Test::Unit::TestCase
672
790
  new Row('OccurrenceAEncounter',{'OccurrenceAEncounter': new hQuery.CodedEntry({_id:14,time:getTime(2010,0,2)}), 'OccurrenceBEncounter':new hQuery.CodedEntry({'_id':2})}),
673
791
  new Row('OccurrenceAEncounter',{'OccurrenceAEncounter': new hQuery.CodedEntry({_id:15,time:getTime(2010,0,2)}), 'OccurrenceBEncounter':new hQuery.CodedEntry({'_id':3})})]
674
792
 
675
- var specific1 = new Specifics(non_specific_rows);
676
- var specific2 = new Specifics(specific_rows);
677
- var specific3 = new Specifics([new Row(undefined)]);
678
- var specific4 = new Specifics()
793
+ var specific1 = new hqmf.SpecificOccurrence(non_specific_rows);
794
+ var specific2 = new hqmf.SpecificOccurrence(specific_rows);
795
+ var specific3 = new hqmf.SpecificOccurrence([new Row(undefined)]);
796
+ var specific4 = new hqmf.SpecificOccurrence()
679
797
 
680
798
  "
681
799
  @context.eval(rows)
metadata CHANGED
@@ -1,15 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hqmf2js
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Marc Hadley
9
+ - Andre Quina
10
+ - Andy Gregorowicz
9
11
  autorequire:
10
12
  bindir: bin
11
13
  cert_chain: []
12
- date: 2012-11-14 00:00:00.000000000 Z
14
+ date: 2012-12-19 00:00:00.000000000 Z
13
15
  dependencies:
14
16
  - !ruby/object:Gem::Dependency
15
17
  name: nokogiri
@@ -18,7 +20,7 @@ dependencies:
18
20
  requirements:
19
21
  - - ~>
20
22
  - !ruby/object:Gem::Version
21
- version: 1.5.2
23
+ version: 1.5.5
22
24
  type: :runtime
23
25
  prerelease: false
24
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +28,7 @@ dependencies:
26
28
  requirements:
27
29
  - - ~>
28
30
  - !ruby/object:Gem::Version
29
- version: 1.5.2
31
+ version: 1.5.5
30
32
  - !ruby/object:Gem::Dependency
31
33
  name: tilt
32
34
  requirement: !ruby/object:Gem::Requirement
@@ -66,7 +68,7 @@ dependencies:
66
68
  requirements:
67
69
  - - ~>
68
70
  - !ruby/object:Gem::Version
69
- version: 2.1.2
71
+ version: 2.2.2
70
72
  type: :runtime
71
73
  prerelease: false
72
74
  version_requirements: !ruby/object:Gem::Requirement
@@ -74,7 +76,7 @@ dependencies:
74
76
  requirements:
75
77
  - - ~>
76
78
  - !ruby/object:Gem::Version
77
- version: 2.1.2
79
+ version: 2.2.2
78
80
  - !ruby/object:Gem::Dependency
79
81
  name: awesome_print
80
82
  requirement: !ruby/object:Gem::Requirement
@@ -82,7 +84,7 @@ dependencies:
82
84
  requirements:
83
85
  - - ~>
84
86
  - !ruby/object:Gem::Version
85
- version: '0.3'
87
+ version: 1.1.0
86
88
  type: :development
87
89
  prerelease: false
88
90
  version_requirements: !ruby/object:Gem::Requirement
@@ -90,7 +92,7 @@ dependencies:
90
92
  requirements:
91
93
  - - ~>
92
94
  - !ruby/object:Gem::Version
93
- version: '0.3'
95
+ version: 1.1.0
94
96
  description: A library for converting HQMF files to executable JavaScript suitable
95
97
  for use with the hQuery Gateway
96
98
  email: hquery-talk@googlegroups.com
@@ -105,10 +107,12 @@ files:
105
107
  - README.md
106
108
  - Rakefile
107
109
  - VERSION
110
+ - app/assets/javascripts/custom_calculations.js.coffee
108
111
  - app/assets/javascripts/hqmf_util.js.coffee
109
112
  - app/assets/javascripts/logging_utils.js.coffee
110
113
  - app/assets/javascripts/patient_api_extension.js.coffee
111
114
  - app/assets/javascripts/specifics.js.coffee
115
+ - app/assets/javascripts/underscore.js
112
116
  - bin/hqmf2js.rb
113
117
  - config/warble.rb
114
118
  - hqmf2js.gemspec
@@ -145,11 +149,11 @@ files:
145
149
  - test/fixtures/json/0043_hqmf1.json
146
150
  - test/fixtures/json/0043_hqmf2.json
147
151
  - test/fixtures/json/59New.json
148
- - test/fixtures/patient_api.js
149
152
  - test/fixtures/patients/francis_drake.json
150
153
  - test/fixtures/patients/larry_vanderman.json
151
154
  - test/test_helper.rb
152
155
  - test/unit/codes_to_json_test.rb
156
+ - test/unit/custom_calculations_test.rb
153
157
  - test/unit/effective_date_test.rb
154
158
  - test/unit/hqmf_from_json_javascript_test.rb
155
159
  - test/unit/hqmf_javascript_test.rb