hqmf2js 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/.gitignore +10 -0
  2. data/.travis.yml +17 -0
  3. data/Gemfile +41 -0
  4. data/Gemfile.lock +202 -0
  5. data/README.md +7 -0
  6. data/Rakefile +22 -0
  7. data/VERSION +1 -0
  8. data/app/assets/javascripts/hqmf_util.js.coffee +776 -0
  9. data/app/assets/javascripts/logging_utils.js.coffee +150 -0
  10. data/app/assets/javascripts/patient_api_extension.js.coffee +36 -0
  11. data/app/assets/javascripts/specifics.js.coffee +462 -0
  12. data/bin/hqmf2js.rb +25 -0
  13. data/config/warble.rb +144 -0
  14. data/hqmf2js.gemspec +20 -0
  15. data/lib/config/codes.xml +1935 -0
  16. data/lib/generator/characteristic.js.erb +19 -0
  17. data/lib/generator/codes_to_json.rb +81 -0
  18. data/lib/generator/converter.rb +60 -0
  19. data/lib/generator/data_criteria.js.erb +47 -0
  20. data/lib/generator/derived_data.js.erb +5 -0
  21. data/lib/generator/js.rb +263 -0
  22. data/lib/generator/measure_period.js.erb +18 -0
  23. data/lib/generator/patient_data.js.erb +22 -0
  24. data/lib/generator/population_criteria.js.erb +4 -0
  25. data/lib/generator/precondition.js.erb +14 -0
  26. data/lib/hqmf2js.rb +20 -0
  27. data/lib/hquery/engine.rb +4 -0
  28. data/lib/tasks/codes.rake +12 -0
  29. data/lib/tasks/coffee.rake +15 -0
  30. data/lib/tasks/convert.rake +47 -0
  31. data/lib/tasks/cover_me.rake +8 -0
  32. data/test/fixtures/NQF59New.xml +1047 -0
  33. data/test/fixtures/codes/codes.xls +0 -0
  34. data/test/fixtures/codes/codes.xml +1941 -0
  35. data/test/fixtures/i2b2.xml +305 -0
  36. data/test/fixtures/invalid/missing_id.xml +18 -0
  37. data/test/fixtures/invalid/unknown_criteria_type.xml +16 -0
  38. data/test/fixtures/invalid/unknown_demographic_entry.xml +16 -0
  39. data/test/fixtures/invalid/unknown_population_type.xml +9 -0
  40. data/test/fixtures/invalid/unknown_value_type.xml +18 -0
  41. data/test/fixtures/js/59New.js +366 -0
  42. data/test/fixtures/js/test1.js +356 -0
  43. data/test/fixtures/js/test2.js +366 -0
  44. data/test/fixtures/json/0043.json +6 -0
  45. data/test/fixtures/json/0043_hqmf1.json +1 -0
  46. data/test/fixtures/json/0043_hqmf2.json +172 -0
  47. data/test/fixtures/json/59New.json +1352 -0
  48. data/test/fixtures/patient_api.js +2823 -0
  49. data/test/fixtures/patients/francis_drake.json +1180 -0
  50. data/test/fixtures/patients/larry_vanderman.json +645 -0
  51. data/test/test_helper.rb +58 -0
  52. data/test/unit/codes_to_json_test.rb +38 -0
  53. data/test/unit/effective_date_test.rb +48 -0
  54. data/test/unit/hqmf_from_json_javascript_test.rb +108 -0
  55. data/test/unit/hqmf_javascript_test.rb +175 -0
  56. data/test/unit/library_function_test.rb +553 -0
  57. data/test/unit/specifics_test.rb +757 -0
  58. metadata +183 -0
@@ -0,0 +1,645 @@
1
+ {
2
+ "addresses": null,
3
+ "allergies": [],
4
+ "birthdate": 160117200,
5
+ "care_goals": [
6
+ {
7
+ "codes": {
8
+ "CPT": [
9
+ "97804"
10
+ ],
11
+ "HCPCS": [
12
+ "S9470"
13
+ ],
14
+ "ICD-9-CM": [
15
+ "V65.3"
16
+ ],
17
+ "SNOMED-CT": [
18
+ "305849009"
19
+ ]
20
+ },
21
+ "description": "follow-up plan_BMI management",
22
+ "time": 1283313600
23
+ }
24
+ ],
25
+ "conditions": [
26
+ {
27
+ "codes": {
28
+ "ICD-10-CM": [
29
+ "E11.9"
30
+ ],
31
+ "ICD-9-CM": [
32
+ "250"
33
+ ],
34
+ "SNOMED-CT": [
35
+ "73211009"
36
+ ]
37
+ },
38
+ "description": "diabetes",
39
+ "status": "active",
40
+ "time": 1270094400
41
+ },
42
+ {
43
+ "codes": {
44
+ "ICD-10-CM": [
45
+ "J45"
46
+ ],
47
+ "ICD-9-CM": [
48
+ "493.92"
49
+ ],
50
+ "SNOMED-CT": [
51
+ "195979001"
52
+ ]
53
+ },
54
+ "description": "Asthma",
55
+ "status": "active",
56
+ "time": 1270094400
57
+ },
58
+ {
59
+ "codes": {
60
+ "ICD-10-CM": [
61
+ "I10"
62
+ ],
63
+ "ICD-9-CM": [
64
+ "401.9"
65
+ ],
66
+ "SNOMED-CT": [
67
+ "59621000"
68
+ ]
69
+ },
70
+ "description": "Hypertension",
71
+ "status": "active",
72
+ "time": 1270094400
73
+ },
74
+ {
75
+ "codes": {
76
+ "SNOMED-CT": [
77
+ "370202007"
78
+ ]
79
+ },
80
+ "description": "Asthma Daytime Symptoms Quantified",
81
+ "time": 1270094400
82
+ },
83
+ {
84
+ "codes": {
85
+ "SNOMED-CT": [
86
+ "370205009"
87
+ ]
88
+ },
89
+ "description": "Asthma Nighttime Symptoms Quantified",
90
+ "time": 1270094400
91
+ }
92
+ ],
93
+ "encounters": [
94
+ {
95
+ "codes": {
96
+ "CPT": [
97
+ "99213"
98
+ ],
99
+ "ICD-9-CM": [
100
+ "V70.0"
101
+ ]
102
+ },
103
+ "description": "Encounter Outpatient",
104
+ "end_time": 1291266000
105
+ },
106
+ {
107
+ "codes": {
108
+ "CPT": [
109
+ "99241"
110
+ ]
111
+ },
112
+ "description": "Encounter Office & Outpatient Consult",
113
+ "time": 1283313600
114
+ },
115
+ {
116
+ "codes": {
117
+ "CPT": [
118
+ "99213"
119
+ ],
120
+ "ICD-9-CM": [
121
+ "V70.0"
122
+ ]
123
+ },
124
+ "description": "Encounter Outpatient",
125
+ "time": 1277265600
126
+ },
127
+ {
128
+ "codes": {
129
+ "CPT": [
130
+ "99241"
131
+ ]
132
+ },
133
+ "description": "Encounter Office & Outpatient Consult",
134
+ "time": 1270094400
135
+ }
136
+ ],
137
+ "ethnicity": "Not Hispanic or Latino",
138
+ "first": "Larry",
139
+ "gender": "M",
140
+ "immunizations": [],
141
+ "languages": null,
142
+ "last": "Vanderman",
143
+ "medical_equipment": [],
144
+ "medications": [
145
+ {
146
+ "codes": {
147
+ "RxNorm": [
148
+ "847207"
149
+ ]
150
+ },
151
+ "description": "Insulin",
152
+ "time": 1278475200,
153
+ "cumulativeMedicationDuration" : {
154
+ "scalar": 6,
155
+ "unit": "d"
156
+ }
157
+ },
158
+ {
159
+ "codes": {
160
+ "RxNorm": [
161
+ "617314"
162
+ ]
163
+ },
164
+ "description": "Lipid Lowering Therapy",
165
+ "time": 1277265600
166
+ },
167
+ {
168
+ "codes": {
169
+ "RxNorm": [
170
+ "858828"
171
+ ]
172
+ },
173
+ "description": "Antihypertensive combinations",
174
+ "time": 1277265600
175
+ },
176
+ {
177
+ "codes": {
178
+ "RxNorm": [
179
+ "318142"
180
+ ]
181
+ },
182
+ "description": "Long acting inhaled beta 2 agonist",
183
+ "time": 1277265600
184
+ },
185
+ {
186
+ "codes": {
187
+ "RxNorm": [
188
+ "630208"
189
+ ]
190
+ },
191
+ "description": "Short acting beta 2 agonist",
192
+ "time": 1277265600
193
+ }
194
+ ],
195
+ "procedures": [
196
+ {
197
+ "codes": {
198
+ "SNOMED-CT": [
199
+ "401191002"
200
+ ]
201
+ },
202
+ "description": "Foot Exam",
203
+ "time": 1291266000,
204
+ "values": [
205
+ {
206
+ "scalar": "Normal",
207
+ "units": null
208
+ }
209
+ ]
210
+ },
211
+ {
212
+ "codes": {
213
+ "SNOMED-CT": [
214
+ "401191002"
215
+ ]
216
+ },
217
+ "description": "Foot Exam",
218
+ "time": 1283313600,
219
+ "values": [
220
+ {
221
+ "scalar": "Normal",
222
+ "units": null
223
+ }
224
+ ]
225
+ },
226
+ {
227
+ "codes": {
228
+ "SNOMED-CT": [
229
+ "401191002"
230
+ ]
231
+ },
232
+ "description": "Foot Exam",
233
+ "time": 1277265600,
234
+ "values": [
235
+ {
236
+ "scalar": "Normal",
237
+ "units": null
238
+ }
239
+ ]
240
+ },
241
+ {
242
+ "codes": {
243
+ "SNOMED-CT": [
244
+ "401191002"
245
+ ]
246
+ },
247
+ "description": "Foot Exam",
248
+ "time": 1270094400,
249
+ "values": [
250
+ {
251
+ "scalar": "Normal",
252
+ "units": null
253
+ }
254
+ ]
255
+ },
256
+ {
257
+ "codes": {
258
+ "CPT": [
259
+ "97802"
260
+ ],
261
+ "HCPCS": [
262
+ "S9470"
263
+ ],
264
+ "ICD-10-CM": [
265
+ "Z00.8"
266
+ ],
267
+ "ICD-9-CM": [
268
+ "V65.3"
269
+ ]
270
+ },
271
+ "description": "counseling for nutrition",
272
+ "time": 1277265600
273
+ },
274
+ {
275
+ "codes": {
276
+ "HCPCS": [
277
+ "S9451"
278
+ ],
279
+ "ICD-10-CM": [
280
+ "Z71.3"
281
+ ],
282
+ "ICD-9-CM": [
283
+ "V65.41"
284
+ ]
285
+ },
286
+ "description": "counseling for physical activity",
287
+ "time": 1277265600
288
+ },
289
+ {
290
+ "codes": {
291
+ "CPT": [
292
+ "92012"
293
+ ],
294
+ "HCPCS": [
295
+ "S0621"
296
+ ],
297
+ "ICD-9-CM": [
298
+ "95.03"
299
+ ],
300
+ "SNOMED-CT": [
301
+ "390735007"
302
+ ]
303
+ },
304
+ "description": "eye exam",
305
+ "time": 1278388800
306
+ }
307
+ ],
308
+ "race": "Black or African American",
309
+ "results": [
310
+ {
311
+ "codes": {
312
+ "CPT": [
313
+ "83036"
314
+ ],
315
+ "LOINC": [
316
+ "4548-4"
317
+ ],
318
+ "SNOMED-CT": [
319
+ "43396009"
320
+ ]
321
+ },
322
+ "description": "HbA1c test",
323
+ "time": 1285992000,
324
+ "values": [
325
+ {
326
+ "scalar": 9.5,
327
+ "units": null
328
+ }
329
+ ]
330
+ },
331
+ {
332
+ "codes": {
333
+ "CPT": [
334
+ "83036"
335
+ ],
336
+ "LOINC": [
337
+ "4548-4"
338
+ ],
339
+ "SNOMED-CT": [
340
+ "43396009"
341
+ ]
342
+ },
343
+ "description": "HbA1c test",
344
+ "time": 1283313600,
345
+ "values": [
346
+ {
347
+ "scalar": 9.2,
348
+ "units": null
349
+ }
350
+ ]
351
+ },
352
+ {
353
+ "codes": {
354
+ "CPT": [
355
+ "83036"
356
+ ],
357
+ "LOINC": [
358
+ "4548-4"
359
+ ],
360
+ "SNOMED-CT": [
361
+ "43396009"
362
+ ]
363
+ },
364
+ "description": "HbA1c test",
365
+ "time": 1277265600,
366
+ "values": [
367
+ {
368
+ "scalar": 8.9,
369
+ "units": null
370
+ }
371
+ ]
372
+ },
373
+ {
374
+ "codes": {
375
+ "CPT": [
376
+ "83721"
377
+ ],
378
+ "LOINC": [
379
+ "2089-1"
380
+ ],
381
+ "SNOMED-CT": [
382
+ "113079009"
383
+ ]
384
+ },
385
+ "description": "LDL",
386
+ "time": 1277265600,
387
+ "values": [
388
+ {
389
+ "scalar": 115,
390
+ "units": null
391
+ }
392
+ ]
393
+ },
394
+ {
395
+ "codes": {
396
+ "CPT": [
397
+ "83701"
398
+ ],
399
+ "LOINC": [
400
+ "14646-4"
401
+ ],
402
+ "SNOMED-CT": [
403
+ "28036006"
404
+ ]
405
+ },
406
+ "description": "High Density Lipoprotein (HDL)",
407
+ "time": 1277265600,
408
+ "values": [
409
+ {
410
+ "scalar": 51,
411
+ "units": null
412
+ }
413
+ ]
414
+ },
415
+ {
416
+ "codes": {
417
+ "CPT": [
418
+ "82465"
419
+ ],
420
+ "LOINC": [
421
+ "2093-3"
422
+ ],
423
+ "SNOMED-CT": [
424
+ "121868005"
425
+ ]
426
+ },
427
+ "description": "Total Cholesterol",
428
+ "time": 1277265600,
429
+ "values": [
430
+ {
431
+ "scalar": 186,
432
+ "units": null
433
+ }
434
+ ]
435
+ },
436
+ {
437
+ "codes": {
438
+ "CPT": [
439
+ "84478"
440
+ ],
441
+ "LOINC": [
442
+ "12951-0"
443
+ ],
444
+ "SNOMED-CT": [
445
+ "14740000"
446
+ ]
447
+ },
448
+ "description": "Triglycerides",
449
+ "time": 1277265600,
450
+ "values": [
451
+ {
452
+ "scalar": 143,
453
+ "units": null
454
+ }
455
+ ]
456
+ }
457
+ ],
458
+ "social_history": [
459
+ {
460
+ "codes": {
461
+ "SNOMED-CT": [
462
+ "160618006"
463
+ ]
464
+ },
465
+ "description": "Tobacco Non-User",
466
+ "time": 1270094400
467
+ }
468
+ ],
469
+ "vital_signs": [
470
+ {
471
+ "codes": {
472
+ "SNOMED-CT": [
473
+ "271649006"
474
+ ]
475
+ },
476
+ "description": "Systolic Blood Pressure",
477
+ "time": 1291266000,
478
+ "values": [
479
+ {
480
+ "scalar": 142,
481
+ "units": "mm[Hg]"
482
+ }
483
+ ]
484
+ },
485
+ {
486
+ "codes": {
487
+ "SNOMED-CT": [
488
+ "271650006"
489
+ ]
490
+ },
491
+ "description": "Diastolic Blood Pressure",
492
+ "time": 1291266000,
493
+ "values": [
494
+ {
495
+ "scalar": 92,
496
+ "units": "mm[Hg]"
497
+ }
498
+ ]
499
+ },
500
+ {
501
+ "codes": {
502
+ "SNOMED-CT": [
503
+ "271649006"
504
+ ]
505
+ },
506
+ "description": "Systolic Blood Pressure",
507
+ "time": 1283313600,
508
+ "values": [
509
+ {
510
+ "scalar": 138,
511
+ "units": "mm[Hg]"
512
+ }
513
+ ]
514
+ },
515
+ {
516
+ "codes": {
517
+ "SNOMED-CT": [
518
+ "271650006"
519
+ ]
520
+ },
521
+ "description": "Diastolic Blood Pressure",
522
+ "time": 1283313600,
523
+ "values": [
524
+ {
525
+ "scalar": 88,
526
+ "units": "mm[Hg]"
527
+ }
528
+ ]
529
+ },
530
+ {
531
+ "codes": {
532
+ "SNOMED-CT": [
533
+ "271649006"
534
+ ]
535
+ },
536
+ "description": "Systolic Blood Pressure",
537
+ "time": 1277265600,
538
+ "values": [
539
+ {
540
+ "scalar": 138,
541
+ "units": "mm[Hg]"
542
+ }
543
+ ]
544
+ },
545
+ {
546
+ "codes": {
547
+ "SNOMED-CT": [
548
+ "271650006"
549
+ ]
550
+ },
551
+ "description": "Diastolic Blood Pressure",
552
+ "time": 1277265600,
553
+ "values": [
554
+ {
555
+ "scalar": 86,
556
+ "units": "mm[Hg]"
557
+ }
558
+ ]
559
+ },
560
+ {
561
+ "codes": {
562
+ "SNOMED-CT": [
563
+ "271649006"
564
+ ]
565
+ },
566
+ "description": "Systolic Blood Pressure",
567
+ "time": 1270094400,
568
+ "values": [
569
+ {
570
+ "scalar": 136,
571
+ "units": "mm[Hg]"
572
+ }
573
+ ]
574
+ },
575
+ {
576
+ "codes": {
577
+ "SNOMED-CT": [
578
+ "271650006"
579
+ ]
580
+ },
581
+ "description": "Diastolic Blood Pressure",
582
+ "time": 1270094400,
583
+ "values": [
584
+ {
585
+ "scalar": 84,
586
+ "units": "mm[Hg]"
587
+ }
588
+ ]
589
+ },
590
+ {
591
+ "codes": {
592
+ "LOINC": [
593
+ "39156-5"
594
+ ],
595
+ "SNOMED-CT": [
596
+ "60621009"
597
+ ]
598
+ },
599
+ "description": "BMI",
600
+ "time": 1285992000,
601
+ "values": [
602
+ {
603
+ "scalar": 30.84591836734694,
604
+ "units": null
605
+ }
606
+ ]
607
+ },
608
+ {
609
+ "codes": {
610
+ "LOINC": [
611
+ "39156-5"
612
+ ],
613
+ "SNOMED-CT": [
614
+ "60621009"
615
+ ]
616
+ },
617
+ "description": "BMI",
618
+ "time": 1283313600,
619
+ "values": [
620
+ {
621
+ "scalar": 30.27204081632653,
622
+ "units": null
623
+ }
624
+ ]
625
+ },
626
+ {
627
+ "codes": {
628
+ "LOINC": [
629
+ "39156-5"
630
+ ],
631
+ "SNOMED-CT": [
632
+ "60621009"
633
+ ]
634
+ },
635
+ "description": "BMI",
636
+ "time": 1277265600,
637
+ "values": [
638
+ {
639
+ "scalar": 31.56326530612245,
640
+ "units": null
641
+ }
642
+ ]
643
+ }
644
+ ]
645
+ }
@@ -0,0 +1,58 @@
1
+ require 'cover_me'
2
+ require 'test/unit'
3
+ require 'turn'
4
+
5
+ if RUBY_PLATFORM=='java'
6
+ require 'rhino'
7
+ else
8
+ require 'v8'
9
+ end
10
+
11
+ # allows import of patient api without rails
12
+ module HqueryPatientApi
13
+ module Rails
14
+ class Engine
15
+
16
+ end
17
+ end
18
+ end
19
+
20
+
21
+ PROJECT_ROOT = File.expand_path("../../", __FILE__)
22
+ require File.join(PROJECT_ROOT, 'lib', 'hqmf2js')
23
+
24
+ def get_js_context(javascript)
25
+ if RUBY_PLATFORM=='java'
26
+ @context = Rhino::Context.new
27
+ else
28
+ @context = V8::Context.new
29
+ end
30
+ @context.eval(javascript)
31
+ @context
32
+ end
33
+
34
+ def initialize_javascript_context(hqmf_utils, codes_json, converted_hqmf)
35
+ patient_api = File.open('test/fixtures/patient_api.js').read
36
+ fixture_json = File.read('test/fixtures/patients/larry_vanderman.json')
37
+ initialize_patient = 'var numeratorPatient = new hQuery.Patient(larry);'
38
+
39
+ if RUBY_PLATFORM=='java'
40
+ @context = Rhino::Context.new
41
+ else
42
+ @context = V8::Context.new
43
+ end
44
+ @context.eval("#{patient_api}
45
+ #{hqmf_utils}
46
+ var OidDictionary = #{codes_json};
47
+ #{converted_hqmf}
48
+ var larry = #{fixture_json};
49
+ #{initialize_patient}")
50
+ @context.eval("Specifics.initialize()")
51
+ end
52
+
53
+ def compile_coffee_script
54
+ ctx = Sprockets::Environment.new(File.expand_path("../../..", __FILE__))
55
+ Tilt::CoffeeScriptTemplate.default_bare = true
56
+ ctx.append_path "app/assets/javascripts"
57
+ HQMF2JS::Generator::JS.library_functions
58
+ end