bonnie_bundler 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/bonnie-bundler.gemspec +1 -1
- data/lib/measures/loading/cql_loader.rb +39 -13
- data/test/fixtures/CMS134v6.zip +0 -0
- data/test/fixtures/vcr_cassettes/valid_vsac_response_hospice.yml +4842 -0
- data/test/unit/cql_loader_test.rb +27 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61e2a56d536dfc98d6737d50c746798b94640bb6
|
4
|
+
data.tar.gz: 4b545b3b00f5daa2670da24798d9cfca0e35eaf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31322b05a378e3f5897f8ff193f78aef1565d5113d64238ea6ac13e5c28a510ebc0bcf47d4a109c48896c9563698d65cfb816e9ea0bc051d8bf4d1ea3f30c7a8
|
7
|
+
data.tar.gz: '00292a81e87be77bf7c05270ff902eb970a3f8a13253739d907fa8d503d804f88e1cc731a8dff3fdacc7a9d91f343a0a72dab09fbbd35caae0fd226028945797'
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
bonnie_bundler (2.0.
|
4
|
+
bonnie_bundler (2.0.1)
|
5
5
|
diffy (~> 3.0.0)
|
6
6
|
health-data-standards (~> 4.0)
|
7
7
|
hqmf2js (~> 1.4)
|
@@ -84,7 +84,7 @@ GEM
|
|
84
84
|
globalid (0.4.1)
|
85
85
|
activesupport (>= 4.2.0)
|
86
86
|
hashdiff (0.3.6)
|
87
|
-
health-data-standards (4.0.
|
87
|
+
health-data-standards (4.0.1)
|
88
88
|
activesupport (~> 4.2.0)
|
89
89
|
builder (~> 3.1)
|
90
90
|
erubis (~> 2.7.0)
|
data/bonnie-bundler.gemspec
CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.email = "pophealth-talk@googlegroups.com"
|
8
8
|
s.homepage = "http://github.com/projecttacoma/bonnie_bundler"
|
9
9
|
s.authors = ["The MITRE Corporation"]
|
10
|
-
s.version = '2.0.
|
10
|
+
s.version = '2.0.1'
|
11
11
|
s.license = 'Apache-2.0'
|
12
12
|
|
13
13
|
s.add_dependency 'health-data-standards', '~> 4.0'
|
@@ -324,44 +324,69 @@ module Measures
|
|
324
324
|
|
325
325
|
cql_statement_depencency_map[main_cql_library] = {}
|
326
326
|
main_library_elm['library']['statements']['def'].each { |statement|
|
327
|
-
cql_statement_depencency_map[main_cql_library][statement['name']] = retrieve_all_statements_in_population(statement, elms)
|
327
|
+
cql_statement_depencency_map[main_cql_library][statement['name']] = retrieve_all_statements_in_population(statement, main_library_elm, elms)
|
328
328
|
}
|
329
329
|
cql_statement_depencency_map
|
330
330
|
end
|
331
331
|
|
332
332
|
# Given a starting define statement, a starting library and all of the libraries,
|
333
333
|
# this will return an array of all nested define statements.
|
334
|
-
def self.retrieve_all_statements_in_population(statement, elms)
|
334
|
+
def self.retrieve_all_statements_in_population(statement, statement_library, elms, statement_library_name=nil)
|
335
335
|
all_results = []
|
336
336
|
if statement.is_a? String
|
337
|
-
statement = retrieve_sub_statement_for_expression_name(statement, elms)
|
337
|
+
statement = retrieve_sub_statement_for_expression_name(statement, elms, statement_library_name)
|
338
338
|
end
|
339
339
|
sub_statement_names = retrieve_expressions_from_statement(statement)
|
340
340
|
# Currently if sub_statement_name is another Population we do not remove it.
|
341
341
|
if sub_statement_names.length > 0
|
342
342
|
sub_statement_names.each do |sub_statement_name|
|
343
343
|
# Check if the statement is not a built in expression
|
344
|
-
|
345
|
-
|
346
|
-
all_results << { library_name:
|
344
|
+
if sub_statement_name[:name]
|
345
|
+
sub_statement_name[:library] = alias_to_library_name(sub_statement_name[:library], statement_library)
|
346
|
+
all_results << { library_name: sub_statement_name[:library], statement_name: sub_statement_name[:name] }
|
347
347
|
end
|
348
348
|
end
|
349
349
|
end
|
350
350
|
all_results
|
351
351
|
end
|
352
352
|
|
353
|
+
# Converts a Library alias to the actual Library name
|
354
|
+
# If no library_alias is provided, return the name of the library that is passed in
|
355
|
+
def self.alias_to_library_name(library_alias, statement_library)
|
356
|
+
if library_alias == nil
|
357
|
+
return statement_library['library']['identifier']['id']
|
358
|
+
end
|
359
|
+
|
360
|
+
if statement_library['library']['includes']
|
361
|
+
statement_library['library']['includes']['def'].each do |library_hash|
|
362
|
+
if library_alias == library_hash['localIdentifier']
|
363
|
+
return library_hash['path']
|
364
|
+
end
|
365
|
+
end
|
366
|
+
end
|
367
|
+
raise MeasureLoadingException.new 'Unexpected statement library structure encountered.'
|
368
|
+
end
|
369
|
+
|
353
370
|
# Finds which library the given define statement exists in.
|
354
371
|
# Returns the JSON statement that contains the given name.
|
355
372
|
# If given statement name is a built in expression, return nil.
|
356
|
-
def self.retrieve_sub_statement_for_expression_name(name, elms)
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
373
|
+
def self.retrieve_sub_statement_for_expression_name(name, elms, library_name)
|
374
|
+
# Search for elm with that name to look for definitions in.
|
375
|
+
if library_name
|
376
|
+
library_elm = elms.find { |elm| elm['library']['identifier']['id'] == library_name }
|
377
|
+
statement_definition = find_definition_in_elm(library_elm, name)
|
378
|
+
return statement_definition if statement_definition
|
361
379
|
end
|
362
380
|
nil
|
363
381
|
end
|
364
382
|
|
383
|
+
# Given an elm structure and a statment_name return the statement JSON structure.
|
384
|
+
def self.find_definition_in_elm(elm, statement_name)
|
385
|
+
elm['library']['statements']['def'].each do |statement|
|
386
|
+
return [elm['library']['identifier']['id'], statement] if statement['name'] == statement_name
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
365
390
|
# Traverses the given statement and returns all of the potential additional statements.
|
366
391
|
def self.retrieve_expressions_from_statement(statement)
|
367
392
|
expressions = []
|
@@ -374,7 +399,7 @@ module Measures
|
|
374
399
|
else
|
375
400
|
if k == 'type' && (v == 'ExpressionRef' || v == 'FunctionRef')
|
376
401
|
# We ignore the Patient expression because it isn't an actual define statment in the cql
|
377
|
-
expressions
|
402
|
+
expressions.push({name: statement['name'], library: statement['libraryName']}) unless statement['name'] == 'Patient'
|
378
403
|
end
|
379
404
|
end
|
380
405
|
end
|
@@ -406,7 +431,8 @@ module Measures
|
|
406
431
|
if !starting_hash.has_key?(key_statement[:library_name])
|
407
432
|
starting_hash[key_statement[:library_name]] = {}
|
408
433
|
end
|
409
|
-
|
434
|
+
library_elm = elms.find { |elm| elm['library']['identifier']['id'] == key_statement[:library_name] }
|
435
|
+
starting_hash[key_statement[:library_name]][key_statement[:statement_name]] = retrieve_all_statements_in_population(key_statement[:statement_name], library_elm, elms, key_statement[:library_name]).uniq
|
410
436
|
# If there are no statements return hash
|
411
437
|
return starting_hash if starting_hash[key_statement[:library_name]][key_statement[:statement_name]].empty?
|
412
438
|
# Loop over array of sub statements and build out hash keys for each.
|
Binary file
|