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
File without changes
|
data/test/test_helper.rb
CHANGED
data/test/unit/cmd_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
require 'hquery-patient-api'
|
3
3
|
|
4
|
-
class CmdTest < Test
|
4
|
+
class CmdTest < Minitest::Test
|
5
5
|
|
6
6
|
def setup
|
7
7
|
@context = get_js_context(HQMF2JS::Generator::JS.library_functions)
|
@@ -27,44 +27,46 @@ class CmdTest < Test::Unit::TestCase
|
|
27
27
|
ebs = @context.eval(%{ var ebs = new hQuery.Fulfillment({"dispenseDate": #{Time.utc(2009,02,02).to_i} , "quantityDispensed" : {"value" :"30"}}) })
|
28
28
|
ece = @context.eval(%{ var ece = new hQuery.Fulfillment({"dispenseDate": #{Time.utc(2010,12,21).to_i} , "quantityDispensed" : {"value" :"30"}}) })
|
29
29
|
|
30
|
-
assert_equal 10 , @context.eval("during.daysInRange(range,
|
31
|
-
assert_equal 10 , @context.eval("scs.daysInRange(range,
|
32
|
-
assert_equal 3, @context.eval("sbs.daysInRange(range,
|
33
|
-
assert_equal 0, @context.eval("sae.daysInRange(range, perDay)"), "Should be 0 days starting after end"
|
34
|
-
assert_equal 6, @context.eval("eae.daysInRange(range, perDay)"), "Should be 6 days overlap ending after the end of date range"
|
35
|
-
assert_equal 0, @context.eval("ebs.daysInRange(range, perDay)"), "Should be 0 days overlap ending before the start of the date range"
|
36
|
-
assert_equal 10, @context.eval("ece.daysInRange(range, perDay)"), "Should be 10 days when ending concurrent with the end"
|
30
|
+
assert_equal 10 , @context.eval("during.daysInRange(range, 1, perDay)"), "Should be 10 days during"
|
31
|
+
assert_equal 10 , @context.eval("scs.daysInRange(range, 1, perDay)"), "Should be 10 days starting concurrent with the start range"
|
32
|
+
assert_equal 3, @context.eval("sbs.daysInRange(range, 1, perDay)"), "Should be 4 days overlap for starting before the start of the range"
|
33
|
+
assert_equal 0, @context.eval("sae.daysInRange(range, 1, perDay)"), "Should be 0 days starting after end"
|
34
|
+
assert_equal 6, @context.eval("eae.daysInRange(range, 1, perDay)"), "Should be 6 days overlap ending after the end of date range"
|
35
|
+
assert_equal 0, @context.eval("ebs.daysInRange(range, 1, perDay)"), "Should be 0 days overlap ending before the start of the date range"
|
36
|
+
assert_equal 10, @context.eval("ece.daysInRange(range, 1, perDay)"), "Should be 10 days when ending concurrent with the end"
|
37
37
|
|
38
38
|
@context.eval("var perDay = 1/3;") #every 3 days
|
39
39
|
|
40
|
-
assert_equal 90 , @context.eval("during.daysInRange(range, perDay)"), "Should be 10 days during"
|
41
|
-
assert_equal 90 , @context.eval("scs.daysInRange(range, perDay)"), "Should be 10 days starting concurrent with the start range"
|
42
|
-
assert_equal 90-7, @context.eval("sbs.daysInRange(range, perDay)"), "Should be 4 days overlap for starting before the start of the range"
|
43
|
-
assert_equal 0, @context.eval("sae.daysInRange(range, perDay)"), "Should be 0 days starting after end"
|
44
|
-
assert_equal 6, @context.eval("eae.daysInRange(range, perDay)"), "Should be 6 days overlap starting after the end of date range"
|
45
|
-
assert_equal 0, @context.eval("ebs.daysInRange(range, perDay)"), "Should be 0 days overlap ending before the start of the date range"
|
46
|
-
assert_equal 10, @context.eval("ece.daysInRange(range, perDay)"), "Should be 10 days when ending concurrent with the end"
|
40
|
+
assert_equal 90 , @context.eval("during.daysInRange(range, 1, perDay)"), "Should be 10 days during"
|
41
|
+
assert_equal 90 , @context.eval("scs.daysInRange(range, 1, perDay)"), "Should be 10 days starting concurrent with the start range"
|
42
|
+
assert_equal 90-7, @context.eval("sbs.daysInRange(range, 1, perDay)"), "Should be 4 days overlap for starting before the start of the range"
|
43
|
+
assert_equal 0, @context.eval("sae.daysInRange(range, 1, perDay)"), "Should be 0 days starting after end"
|
44
|
+
assert_equal 6, @context.eval("eae.daysInRange(range, 1, perDay)"), "Should be 6 days overlap starting after the end of date range"
|
45
|
+
assert_equal 0, @context.eval("ebs.daysInRange(range, 1, perDay)"), "Should be 0 days overlap ending before the start of the date range"
|
46
|
+
assert_equal 10, @context.eval("ece.daysInRange(range, 1, perDay)"), "Should be 10 days when ending concurrent with the end"
|
47
47
|
|
48
48
|
@context.eval("range = new IVL_TS(null, new TS('20101231'))")
|
49
|
-
assert_equal 90, @context.eval("during.daysInRange(range, perDay)"), "Should be 90 when not supplied a start date"
|
49
|
+
assert_equal 90, @context.eval("during.daysInRange(range, 1, perDay)"), "Should be 90 when not supplied a start date"
|
50
50
|
|
51
51
|
@context.eval("range = new IVL_TS(new TS('20100301'), null)")
|
52
|
-
assert_equal 63, @context.eval("during.daysInRange(range, perDay)"), "Should be 90 when not supplied an end date date"
|
52
|
+
assert_equal 63, @context.eval("during.daysInRange(range, 1, perDay)"), "Should be 90 when not supplied an end date date"
|
53
53
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def test_cumulativeMedicationDuration
|
57
57
|
medication1 = %{
|
58
58
|
{
|
59
|
+
"dose" : {"unit" : "mg", "value" : "5"},
|
59
60
|
"administrationTiming" :{'period' : {'unit': 'h' , 'value': 8 }},
|
60
61
|
"fulfillmentHistory": [
|
61
|
-
{"dispenseDate": #{Time.utc(2010,01,01).to_i} , "quantityDispensed" : {"value" :"
|
62
|
+
{"dispenseDate": #{Time.utc(2010,01,01).to_i} , "quantityDispensed" : {"value" :"150", "unit" : "mg"}}
|
62
63
|
]
|
63
64
|
}
|
64
65
|
}
|
65
66
|
|
66
67
|
medication2 = %{
|
67
68
|
{
|
69
|
+
"dose" : {"unit" : "mg", "value" : "1"},
|
68
70
|
"administrationTiming" :{'period' : {'unit': 'h' , 'value': 8 }},
|
69
71
|
"fulfillmentHistory": [
|
70
72
|
{"dispenseDate": #{Time.utc(2010,01,01).to_i} , "quantityDispensed" : {"value" :"30"}},
|
@@ -75,6 +77,7 @@ class CmdTest < Test::Unit::TestCase
|
|
75
77
|
|
76
78
|
no_history = %{
|
77
79
|
{
|
80
|
+
"dose" : {"unit" : "mg", "value" : "5"},
|
78
81
|
"administrationTiming" :{'period' : {'unit': 'h' , 'value': 8 }},
|
79
82
|
"fulfillmentHistory": []
|
80
83
|
}
|
@@ -89,4 +92,127 @@ class CmdTest < Test::Unit::TestCase
|
|
89
92
|
end
|
90
93
|
|
91
94
|
|
92
|
-
|
95
|
+
def test_fullfillment_based_cmd
|
96
|
+
medication1 = %{
|
97
|
+
{
|
98
|
+
"dose" : {"unit" : "mg", "value" : "5"},
|
99
|
+
"administrationTiming" :{'period' : {'unit': 'h' , 'value': 8 }},
|
100
|
+
"fulfillmentHistory": [
|
101
|
+
{"dispenseDate": #{Time.utc(2010,01,01).to_i} , "quantityDispensed" : {"value" :"150", "unit" : "mg"}}
|
102
|
+
]
|
103
|
+
}
|
104
|
+
}
|
105
|
+
|
106
|
+
medication2 = %{
|
107
|
+
{
|
108
|
+
"dose" : {"unit" : "mg", "value" : "1"},
|
109
|
+
"administrationTiming" :{'period' : {'unit': 'h' , 'value': 8 }},
|
110
|
+
"fulfillmentHistory": [
|
111
|
+
{"dispenseDate": #{Time.utc(2010,01,01).to_i} , "quantityDispensed" : {"value" :"30"}},
|
112
|
+
{"dispenseDate": #{Time.utc(2010,10,01).to_i} , "quantityDispensed" : {"value" :"90"}}
|
113
|
+
]
|
114
|
+
}
|
115
|
+
}
|
116
|
+
|
117
|
+
no_history = %{
|
118
|
+
{
|
119
|
+
"dose" : {"unit" : "mg", "value" : "5"},
|
120
|
+
"administrationTiming" :{'period' : {'unit': 'h' , 'value': 8 }},
|
121
|
+
"fulfillmentHistory": []
|
122
|
+
}
|
123
|
+
}
|
124
|
+
@context.eval("var med = new hQuery.Medication(#{medication1})")
|
125
|
+
@context.eval("var med2 = new hQuery.Medication(#{medication2})")
|
126
|
+
@context.eval("var no_meds = new hQuery.Medication(#{no_history})")
|
127
|
+
@context.eval("var range = new IVL_TS(new TS('20100101'), new TS('20101231'))")
|
128
|
+
@context.eval("var cmd1 = new CMD([med],'fullfillment')")
|
129
|
+
@context.eval("var cmd2 = new CMD([med2],'fullfillment')")
|
130
|
+
@context.eval("var cmd3 = new CMD([no_meds],'fullfillment')")
|
131
|
+
assert_equal 10, @context.eval("cmd1.days_active(range.low,range.high).length"), "CMD should be 10"
|
132
|
+
assert_equal 40, @context.eval("cmd2.days_active(range.low,range.high).length"), "CMD should be 40"
|
133
|
+
assert_equal 0, @context.eval("cmd3.days_active(range.low,range.high).length"), "CMD should be 0"
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
def test_order_based_cmd
|
138
|
+
medication1 = %{
|
139
|
+
{
|
140
|
+
"dose" : {"unit" : "mg", "value" : "5"},
|
141
|
+
"administrationTiming" :{'period' : {'unit': 'h' , 'value': 8 }},
|
142
|
+
"orderInformation": [
|
143
|
+
{"orderDateTime": #{Time.utc(2010,01,01).to_i} , "quantityOrdered" : {"value" :"150", "unit" : "mg"}, "fills": 2}
|
144
|
+
]
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
medication2 = %{
|
149
|
+
{
|
150
|
+
"dose" : {"unit" : "mg", "value" : "1"},
|
151
|
+
"administrationTiming" :{'period' : {'unit': 'h' , 'value': 8 }},
|
152
|
+
"orderInformation": [
|
153
|
+
{"orderDateTime": #{Time.utc(2010,01,01).to_i} , "quantityOrdered" : {"value" :"30"}},
|
154
|
+
{"orderDateTime": #{Time.utc(2010,10,01).to_i} , "quantityOrdered" : {"value" :"90"}}
|
155
|
+
]
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
no_history = %{
|
160
|
+
{
|
161
|
+
"dose" : {"unit" : "mg", "value" : "5"},
|
162
|
+
"administrationTiming" :{'period' : {'unit': 'h' , 'value': 8 }},
|
163
|
+
"orderInformation": []
|
164
|
+
}
|
165
|
+
}
|
166
|
+
@context.eval("var med = new hQuery.Medication(#{medication1})")
|
167
|
+
@context.eval("var med2 = new hQuery.Medication(#{medication2})")
|
168
|
+
@context.eval("var no_meds = new hQuery.Medication(#{no_history})")
|
169
|
+
@context.eval("var range = new IVL_TS(new TS('20100101'), new TS('20101231'))")
|
170
|
+
@context.eval("var cmd1 = new CMD([med],'order')")
|
171
|
+
@context.eval("var cmd2 = new CMD([med2],'order')")
|
172
|
+
@context.eval("var cmd3 = new CMD([no_meds],'order')")
|
173
|
+
assert_equal 20, @context.eval("cmd1.days_active(range.low,range.high).length"), "CMD should be 10"
|
174
|
+
assert_equal 40, @context.eval("cmd2.days_active(range.low,range.high).length"), "CMD should be 40"
|
175
|
+
assert_equal 0, @context.eval("cmd3.days_active(range.low,range.high).length"), "CMD should be 0"
|
176
|
+
end
|
177
|
+
|
178
|
+
def test_active_days
|
179
|
+
|
180
|
+
@context.eval("var active = new ActiveDays()")
|
181
|
+
@context.eval("var ivl = new IVL_TS(new TS('20101001'), new TS('20101031'))")
|
182
|
+
@context.eval("active.add_ivlts(ivl)")
|
183
|
+
assert_equal 31, @context.eval("active.days_active(ivl.low,ivl.high).length")
|
184
|
+
|
185
|
+
@context.eval(" ivl = new IVL_TS(new TS('20101001'), new TS('20101010'))")
|
186
|
+
assert_equal 10, @context.eval("active.days_active(ivl.low,ivl.high).length")
|
187
|
+
|
188
|
+
@context.eval(" ivl = new IVL_TS(new TS('20101001'), new TS('20101110'))")
|
189
|
+
assert_equal 31, @context.eval("active.days_active(ivl.low,ivl.high).length")
|
190
|
+
|
191
|
+
@context.eval(" ivl = new IVL_TS(new TS('20101031'), new TS('20101110'))")
|
192
|
+
assert_equal 1, @context.eval("active.days_active(ivl.low,ivl.high).length")
|
193
|
+
|
194
|
+
@context.eval(" ivl = new IVL_TS(new TS('20101110'), new TS('20110110'))")
|
195
|
+
@context.eval("active.add_ivlts(ivl)")
|
196
|
+
|
197
|
+
@context.eval(" ivl = new IVL_TS(new TS('20101031'), new TS('20101113'))")
|
198
|
+
assert_equal 5, @context.eval("active.days_active(ivl.low,ivl.high).length")
|
199
|
+
|
200
|
+
|
201
|
+
@context.eval(" ivl = new IVL_TS(new TS('20101102'), new TS('20101113'))")
|
202
|
+
assert_equal 4, @context.eval("active.days_active(ivl.low,ivl.high).length")
|
203
|
+
|
204
|
+
|
205
|
+
@context.eval(" ivl = new IVL_TS(new TS('20100101'), new TS('20110113'))")
|
206
|
+
assert_equal 93, @context.eval("active.days_active(ivl.low,ivl.high).length")
|
207
|
+
|
208
|
+
@context.eval("ivl = new IVL_TS(new TS('20101110'), new TS('20110110'))")
|
209
|
+
@context.eval("active.add_ivlts(ivl)")
|
210
|
+
|
211
|
+
@context.eval(" ivl = new IVL_TS(new TS('20100101'), new TS('20110113'))")
|
212
|
+
assert_equal 93, @context.eval("active.days_active(ivl.low,ivl.high).length")
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
end
|
217
|
+
|
218
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
|
-
class CodesToJsonTest < Test
|
3
|
+
class CodesToJsonTest < Minitest::Test
|
4
4
|
|
5
5
|
def setup
|
6
6
|
end
|
@@ -14,9 +14,9 @@ class CodesToJsonTest < Test::Unit::TestCase
|
|
14
14
|
|
15
15
|
@context = get_js_context("var dictionary = #{codes_json}")
|
16
16
|
|
17
|
-
@context.eval("dictionary").entries.length
|
18
|
-
@context.eval("dictionary['2.16.840.1.113883.3.464.1.42']").entries.first[0]
|
19
|
-
@context.eval("dictionary['2.16.840.1.113883.3.464.1.42']").entries.first[1].length
|
17
|
+
assert_equal 19, @context.eval("dictionary").entries.length
|
18
|
+
assert_equal "CPT", @context.eval("dictionary['2.16.840.1.113883.3.464.1.42']").entries.first[0]
|
19
|
+
assert_equal 19, @context.eval("dictionary['2.16.840.1.113883.3.464.1.42']").entries.first[1].length
|
20
20
|
|
21
21
|
end
|
22
22
|
|
@@ -24,13 +24,13 @@ class CodesToJsonTest < Test::Unit::TestCase
|
|
24
24
|
value_sets = JSON.parse(File.read(File.join('test','fixtures','codes','codes.json'))).map {|vs| HealthDataStandards::SVS::ValueSet.new(vs)}
|
25
25
|
oid_map = HQMF2JS::Generator::CodesToJson.from_value_sets(value_sets)
|
26
26
|
|
27
|
-
|
28
|
-
oid_map["1.2.3.4.5"].keys.sort
|
29
|
-
oid_map["1.2.3.4.5"]["ICD-9-CM"].sort
|
30
|
-
oid_map["1.2.3.4.5"]["SNOMED-CT"].sort
|
31
|
-
oid_map["1.2.3.4.6"].keys.sort
|
32
|
-
oid_map["1.2.3.4.6"]["CPT"].sort
|
33
|
-
oid_map["1.2.3.4.6"]["SNOMED-CT"].sort
|
27
|
+
assert_equal ["1.2.3.4.5","1.2.3.4.6"], oid_map.keys.sort
|
28
|
+
assert_equal ["ICD-9-CM","SNOMED-CT"], oid_map["1.2.3.4.5"].keys.sort
|
29
|
+
assert_equal ["126", "127"], oid_map["1.2.3.4.5"]["ICD-9-CM"].sort
|
30
|
+
assert_equal ["123", "124", "125"], oid_map["1.2.3.4.5"]["SNOMED-CT"].sort
|
31
|
+
assert_equal ["CPT","SNOMED-CT"], oid_map["1.2.3.4.6"].keys.sort
|
32
|
+
assert_equal ["125C", "126D", "127E"], oid_map["1.2.3.4.6"]["CPT"].sort
|
33
|
+
assert_equal ["123A", "124B"], oid_map["1.2.3.4.6"]["SNOMED-CT"].sort
|
34
34
|
|
35
35
|
# def self.from_value_sets(value_sets)
|
36
36
|
# # make sure we have a string keyed hash
|
@@ -53,4 +53,4 @@ class CodesToJsonTest < Test::Unit::TestCase
|
|
53
53
|
end
|
54
54
|
|
55
55
|
|
56
|
-
end
|
56
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
require 'hquery-patient-api'
|
3
3
|
|
4
|
-
class CustomCalculationsTest < Test
|
4
|
+
class CustomCalculationsTest < Minitest::Test
|
5
5
|
|
6
6
|
def setup
|
7
7
|
@context = get_js_context(HQMF2JS::Generator::JS.library_functions)
|
@@ -78,7 +78,7 @@ class CustomCalculationsTest < Test::Unit::TestCase
|
|
78
78
|
|
79
79
|
|
80
80
|
def test_inr_results
|
81
|
-
@context.eval("typeof(hqmf.CustomCalc.PercentTTREntries) === 'function'")
|
81
|
+
assert_equal true, @context.eval("typeof(hqmf.CustomCalc.PercentTTREntries) === 'function'")
|
82
82
|
assert @context.eval("Math.abs(list.calculateDaysInRange(inr1,inr2) - 3.714285714285717) < .001")
|
83
83
|
assert @context.eval("Math.abs(list.calculateDaysInRange(inr2,inr3)) == 0 ")
|
84
84
|
assert @context.eval("Math.abs(list.calculateDaysInRange(inr3,inr4)) == 0")
|
@@ -93,10 +93,6 @@ class CustomCalculationsTest < Test::Unit::TestCase
|
|
93
93
|
assert @context.eval("Math.abs(list.calculateDaysInRange(inr12,inr13) - 14) < .001")
|
94
94
|
|
95
95
|
end
|
96
|
-
|
97
|
-
def test_total_number_of_days
|
98
|
-
@context.eval("list.totalNumberOfDays()").must_equal 198
|
99
|
-
end
|
100
96
|
|
101
97
|
def test_calculate_ttr
|
102
98
|
assert @context.eval("Math.abs(list.calculateTTR() - 87.11113886) < .001")
|
@@ -1,11 +1,10 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
|
-
class EffectiveDateTest < Test
|
3
|
+
class EffectiveDateTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
# Open a path to all of our fixtures
|
6
|
-
|
7
|
-
|
8
|
-
doc = HQMF::Parser.parse(hqmf_contents, HQMF::Parser::HQMF_VERSION_2)
|
6
|
+
model = JSON.parse(File.open("test/fixtures/NQF59New.json").read)
|
7
|
+
doc = HQMF::Document.from_json(model)
|
9
8
|
|
10
9
|
# First compile the CoffeeScript that enables our converted HQMF JavaScript
|
11
10
|
ctx = Sprockets::Environment.new(File.expand_path("../../..", __FILE__))
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
|
-
class ErbContextTest < Test
|
3
|
+
class ErbContextTest < Minitest::Test
|
4
4
|
|
5
5
|
def setup
|
6
6
|
end
|
@@ -12,51 +12,51 @@ class ErbContextTest < Test::Unit::TestCase
|
|
12
12
|
criteria = HQMF::DataCriteria.from_json(nil, JSON.parse(File.read(File.join('test','fixtures','json','data_criteria','temporals_with_anynonnull.json'))))
|
13
13
|
|
14
14
|
get_codes = context.js_for_code_list(criteria)
|
15
|
-
|
15
|
+
assert_equal "getCodes(\"2.16.840.1.113883.3.117.1.7.1.23\")", get_codes
|
16
16
|
criteria.instance_variable_set(:@code_list_id, nil)
|
17
17
|
get_codes = context.js_for_code_list(criteria)
|
18
|
-
|
18
|
+
assert_equal "null", get_codes
|
19
19
|
|
20
20
|
date_bound = context.js_for_date_bound(criteria)
|
21
|
-
|
21
|
+
assert_equal "MeasurePeriod.high.asDate()", date_bound
|
22
22
|
|
23
23
|
criteria.temporal_references[0].instance_variable_set(:@type,"FOO")
|
24
|
-
exception =
|
24
|
+
exception = assert_raises RuntimeError do
|
25
25
|
context.js_for_date_bound(criteria)
|
26
26
|
end
|
27
|
-
|
27
|
+
assert_equal "do not know how to get a date for this type", exception.message
|
28
28
|
end
|
29
29
|
|
30
30
|
def test_value_js
|
31
31
|
context = HQMF2JS::Generator::ErbContext.new({})
|
32
32
|
value = HQMF::Value.from_json({"type" => "ANYNonNull"})
|
33
33
|
result = context.js_for_value(value)
|
34
|
-
|
34
|
+
assert_equal "new ANYNonNull()", result
|
35
35
|
|
36
36
|
|
37
37
|
value = HQMF::Value.from_json({"type"=>"SCALAR", "unit"=>"mm[Hg]", "value"=>"90", "inclusive?"=>false, "derived?"=>false } )
|
38
38
|
result = context.js_for_value(value)
|
39
|
-
|
39
|
+
assert_equal "new SCALAR(90, \"mm[Hg]\", false)", result
|
40
40
|
|
41
41
|
value = HQMF::Value.from_json({"type"=>"SCALAR", "unit"=>nil, "value"=>"90", "inclusive?"=>true, "derived?"=>false } )
|
42
42
|
result = context.js_for_value(value)
|
43
|
-
|
43
|
+
assert_equal "new SCALAR(\"90\", null, true)", result
|
44
44
|
|
45
45
|
value = HQMF::Value.from_json({"type"=>"SCALAR", "unit"=>nil, "value"=>"90", "inclusive?"=>nil, "derived?"=>false } )
|
46
46
|
value.instance_variable_set(:@inclusive, nil)
|
47
47
|
result = context.js_for_value(value)
|
48
|
-
|
48
|
+
assert_equal "new SCALAR(\"90\")", result
|
49
49
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def test_field_library_method
|
53
53
|
context = HQMF2JS::Generator::ErbContext.new({})
|
54
54
|
result = context.field_library_method('ADMISSION_DATETIME')
|
55
|
-
|
55
|
+
assert_equal "adjustBoundsForField", result
|
56
56
|
|
57
57
|
context = HQMF2JS::Generator::ErbContext.new({})
|
58
58
|
result = context.field_library_method('FACILITY_LOCATION_ARRIVAL_DATETIME')
|
59
|
-
|
59
|
+
assert_equal "denormalizeEventsByLocation", result
|
60
60
|
end
|
61
61
|
|
62
62
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../test_helper'
|
2
|
+
require 'hquery-patient-api'
|
3
|
+
|
4
|
+
class FilterByReferenceTest < Minitest::Test
|
5
|
+
|
6
|
+
def setup
|
7
|
+
@context = get_js_context(HQMF2JS::Generator::JS.library_functions)
|
8
|
+
@context.eval("hqmf.SpecificsManager.initialize()")
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_filter
|
12
|
+
@context.eval "var evts = [new hQuery.CodedEntry({'_id' : 'id1', 'references' : [{'referenced_id' : 'id4', 'type' : 'fulfills'}]}),
|
13
|
+
new hQuery.CodedEntry({'_id' : 'id2','references' : [{'referenced_id' : 'id5', 'type' : 'some_reference'}]}),
|
14
|
+
new hQuery.CodedEntry({'_id' : 'id3'})]
|
15
|
+
|
16
|
+
var pos = [new hQuery.CodedEntry({'_id' : 'id4'}),
|
17
|
+
new hQuery.CodedEntry({'_id' : 'id5'}),
|
18
|
+
new hQuery.CodedEntry({'_id' : 'id6'})]
|
19
|
+
|
20
|
+
"
|
21
|
+
|
22
|
+
assert_equal 1, @context.eval("filterEventsByReference(evts,'fulfills',pos).length")
|
23
|
+
assert_equal 'id1' , @context.eval("filterEventsByReference(evts,'fulfills',pos)[0].id")
|
24
|
+
assert_equal 1, @context.eval("filterEventsByReference(evts,'some_reference',pos).length")
|
25
|
+
assert_equal 'id2' , @context.eval("filterEventsByReference(evts,'some_reference',pos)[0].id")
|
26
|
+
assert_equal 0, @context.eval("filterEventsByReference(evts,'nonexistent_ref',pos).length")
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_communicationFilter
|
31
|
+
|
32
|
+
@context.eval "var communication_evts = [new hQuery.Communication({ 'direction' : 'communication_from_patient_to_provider' })]
|
33
|
+
|
34
|
+
"
|
35
|
+
|
36
|
+
assert_equal 1, @context.eval("filterEventsByCommunicationDirection(communication_evts,'communication_from_patient_to_provider').length")
|
37
|
+
assert_equal 0, @context.eval("filterEventsByCommunicationDirection(communication_evts,'communication_from_provider_to_patient').length")
|
38
|
+
end
|
39
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
|
3
|
-
class HqmfFromJsonJavascriptTest < Test
|
3
|
+
class HqmfFromJsonJavascriptTest < Minitest::Test
|
4
4
|
def setup
|
5
5
|
json_measure = File.open("test/fixtures/json/59New.json").read
|
6
6
|
measure_hash = JSON.parse(json_measure)
|
@@ -60,6 +60,7 @@ class HqmfFromJsonJavascriptTest < Test::Unit::TestCase
|
|
60
60
|
assert !@context.eval("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
|
61
61
|
assert !@context.eval("hqmfjs.deadBetween5and6MonthsDuringMeasurePeriod(numeratorPatient).isTrue()")
|
62
62
|
|
63
|
+
@context.eval("numeratorPatient.json['expired']=true")
|
63
64
|
@context.eval("numeratorPatient.json['deathdate']=#{Time.utc(2010,11).to_i}")
|
64
65
|
assert !@context.eval("hqmfjs.dead3MonthsBeforeMeasurePeriod(numeratorPatient).isTrue()")
|
65
66
|
assert !@context.eval("hqmfjs.dead3MonthsAfterMeasurePeriod(numeratorPatient).isTrue()")
|
@@ -1,13 +1,12 @@
|
|
1
1
|
require_relative '../test_helper'
|
2
2
|
require 'hquery-patient-api'
|
3
3
|
|
4
|
-
class HqmfJavascriptTest < Test
|
4
|
+
class HqmfJavascriptTest < Minitest::Test
|
5
5
|
def setup
|
6
6
|
# Open a path to all of our fixtures
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
model = JSON.parse(File.open("test/fixtures/NQF59New.json").read)
|
8
|
+
doc = HQMF::Document.from_json(model)
|
9
|
+
|
11
10
|
codes_file_path = File.expand_path("../../fixtures/codes/codes.xml", __FILE__)
|
12
11
|
|
13
12
|
# First compile the CoffeeScript that enables our converted HQMF JavaScript
|
@@ -49,11 +48,11 @@ class HqmfJavascriptTest < Test::Unit::TestCase
|
|
49
48
|
local_context.eval("#{hqmf_utils}
|
50
49
|
#{value}")
|
51
50
|
|
52
|
-
local_context.eval('typeof hqmfjs != undefined')
|
53
|
-
local_context.eval('typeof OidDictionary != undefined')
|
54
|
-
local_context.eval('typeof hqmfjs.IPP != undefined')
|
55
|
-
local_context.eval('typeof hqmfjs.NUMER != undefined')
|
56
|
-
local_context.eval('typeof hqmfjs.DENOM != undefined')
|
51
|
+
assert_equal true, local_context.eval('typeof hqmfjs != undefined')
|
52
|
+
assert_equal true, local_context.eval('typeof OidDictionary != undefined')
|
53
|
+
assert_equal true, local_context.eval('typeof hqmfjs.IPP != undefined')
|
54
|
+
assert_equal true, local_context.eval('typeof hqmfjs.NUMER != undefined')
|
55
|
+
assert_equal true, local_context.eval('typeof hqmfjs.DENOM != undefined')
|
57
56
|
end
|
58
57
|
|
59
58
|
def test_to_js_method_without_codes
|
@@ -185,8 +184,8 @@ class HqmfJavascriptTest < Test::Unit::TestCase
|
|
185
184
|
end
|
186
185
|
|
187
186
|
def test_map_reduce_generation
|
188
|
-
|
189
|
-
doc = HQMF::
|
187
|
+
model = JSON.parse(File.open("test/fixtures/NQF59New.json").read)
|
188
|
+
doc = HQMF::Document.from_json(model)
|
190
189
|
|
191
190
|
map_reduce = HQMF2JS::Converter.generate_map_reduce(doc)
|
192
191
|
|
@@ -206,7 +205,7 @@ class HqmfJavascriptTest < Test::Unit::TestCase
|
|
206
205
|
context = HQMF2JS::Generator::ErbContext.new({})
|
207
206
|
criteria = HQMF::DataCriteria.new(nil,nil,nil,nil,nil,nil,nil,'patient_characteristic',nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil)
|
208
207
|
|
209
|
-
exception =
|
208
|
+
exception = assert_raises RuntimeError do
|
210
209
|
n = context.js_name(criteria)
|
211
210
|
end
|
212
211
|
assert exception.message.match(/^No identifier for .*/)
|