Skip to content

Commit

Permalink
Merge pull request #76 from fhir-crucible/uscore-invariant-fix
Browse files Browse the repository at this point in the history
Uscore invariant fix
  • Loading branch information
arscan authored Nov 16, 2020
2 parents c1fa5bc + 115244b commit d3975bb
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ language: ruby
env:
- TESTMEMORY=0 GCDELAY=2.0
rvm:
- 2.4
- 2.5
- 2.6
- 2.7
before_script:
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
Expand Down
90 changes: 44 additions & 46 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
fhir_models (4.1.0)
fhir_models (4.1.1)
bcp47 (>= 0.3)
date_time_precision (>= 0.8)
mime-types (>= 3.0)
Expand All @@ -10,19 +10,19 @@ PATH
GEM
remote: https://rubygems.org/
specs:
ast (2.4.0)
ast (2.4.1)
bcp47 (0.3.3)
i18n
coderay (1.1.2)
concurrent-ruby (1.1.6)
coderay (1.1.3)
concurrent-ruby (1.1.7)
coolline (0.5.0)
unicode_utils (~> 1.4)
date_time_precision (0.8.1)
diff-lcs (1.3)
diff-lcs (1.4.4)
docile (1.3.2)
ffi (1.11.1)
ffi (1.13.1)
formatador (0.2.5)
guard (2.15.0)
guard (2.16.2)
formatador (>= 0.2.4)
listen (>= 2.7, < 4.0)
lumberjack (>= 1.0.12, < 2.0)
Expand All @@ -39,57 +39,56 @@ GEM
guard-test (2.0.8)
guard-compat (~> 1.2)
test-unit (~> 3.0)
i18n (1.8.2)
i18n (1.8.5)
concurrent-ruby (~> 1.0)
jaro_winkler (1.5.3)
json (2.2.0)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
ruby_dep (~> 1.2)
lumberjack (1.0.13)
method_source (0.9.2)
jaro_winkler (1.5.4)
json (2.3.1)
listen (3.3.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
lumberjack (1.2.8)
method_source (1.0.0)
mime-types (3.3.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2019.1009)
mime-types-data (3.2020.1104)
mini_portile2 (2.4.0)
nenv (0.3.0)
nokogiri (1.10.8)
nokogiri (1.10.10)
mini_portile2 (~> 2.4.0)
nokogiri-diff (0.2.0)
nokogiri (~> 1.5)
tdiff (~> 0.3, >= 0.3.2)
notiffany (0.1.3)
nenv (~> 0.1)
shellany (~> 0.0)
parallel (1.17.0)
parser (2.6.3.0)
ast (~> 2.4.0)
power_assert (1.1.5)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
parallel (1.20.0)
parser (2.7.2.0)
ast (~> 2.4.1)
power_assert (1.2.0)
pry (0.13.1)
coderay (~> 1.1)
method_source (~> 1.0)
pry-coolline (0.2.5)
coolline (~> 0.5)
psych (3.1.0)
psych (3.2.0)
rainbow (3.0.0)
rake (12.3.3)
rb-fsevent (0.10.3)
rb-inotify (0.10.0)
rake (13.0.1)
rb-fsevent (0.10.4)
rb-inotify (0.10.1)
ffi (~> 1.0)
rspec (3.8.0)
rspec-core (~> 3.8.0)
rspec-expectations (~> 3.8.0)
rspec-mocks (~> 3.8.0)
rspec-core (3.8.2)
rspec-support (~> 3.8.0)
rspec-expectations (3.8.4)
rspec (3.10.0)
rspec-core (~> 3.10.0)
rspec-expectations (~> 3.10.0)
rspec-mocks (~> 3.10.0)
rspec-core (3.10.0)
rspec-support (~> 3.10.0)
rspec-expectations (3.10.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-mocks (3.8.1)
rspec-support (~> 3.10.0)
rspec-mocks (3.10.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.8.0)
rspec-support (3.8.2)
rspec-support (~> 3.10.0)
rspec-support (3.10.0)
rubocop (0.67.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
Expand All @@ -99,17 +98,16 @@ GEM
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 1.6)
ruby-progressbar (1.10.1)
ruby_dep (1.5.0)
shellany (0.0.1)
simplecov (0.17.0)
simplecov (0.17.1)
docile (~> 1.1)
json (>= 1.8, < 3)
simplecov-html (~> 0.10.0)
simplecov-html (0.10.2)
tdiff (0.3.4)
test-unit (3.3.3)
test-unit (3.3.6)
power_assert
thor (0.20.3)
thor (1.0.1)
unicode-display_width (1.5.0)
unicode_utils (1.4.0)

Expand All @@ -131,7 +129,7 @@ DEPENDENCIES
test-unit

RUBY VERSION
ruby 2.5.1p57
ruby 2.5.8p224

BUNDLED WITH
2.0.1
2.1.4
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ $ bundle exec rake fhir:console
```
# License

Copyright 2014-2019 The MITRE Corporation
Copyright 2014-2020 The MITRE Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
2 changes: 1 addition & 1 deletion lib/fhir_models/fhirpath/evaluate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def self.compute(tree, data)
tree[index] = (previous_node == :null || previous_node.empty? rescue previous_node.nil?)
clean_index(tree, previous_index)
when :exists
tree[index] = !previous_node.nil? && previous_node != :null
tree[index] = !previous_node.nil? && previous_node != :null && previous_node != []
clean_index(tree, previous_index)
when :distinct
tree[index] = (previous_node.uniq rescue previous_node)
Expand Down
2 changes: 1 addition & 1 deletion lib/fhir_models/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module FHIR
module Models
VERSION = '4.1.0'.freeze
VERSION = '4.1.1'.freeze
end
end
44 changes: 44 additions & 0 deletions test/unit/fhirpath/invariants_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,4 +288,48 @@ def test_sdf9_false
result = FHIRPath.evaluate(expression, data)
assert result == false, 'Failed sdf-9 test.'
end

def test_us_core_8_v311_true
expression = "(family.exists() or given.exists()) xor extension.where(url='http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists()"
data = {
'use' => 'official',
'family'=>'Becker968',
'given'=>['Sadie426'],
'prefix'=>['Mrs.']
}
result = FHIRPath.evaluate(expression, data)
assert result == true, 'Failed us-core-8 (v3.1.1) test.'
end

def test_us_core_8_v311_true2
expression = "(family.exists() or given.exists()) xor extension.where(url='http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists()"
data = {
'use' => 'official',
'extension' => [
{
'url' => 'http://hl7.org/fhir/StructureDefinition/data-absent-reason',
'valueCode' => 'unknown'
}
]
}
result = FHIRPath.evaluate(expression, data)
assert result == true, 'Failed us-core-8 (v3.1.1) test.'
end

def test_us_core_8_v311_false
expression = "(family.exists() or given.exists()) xor extension.where(url='http://hl7.org/fhir/StructureDefinition/data-absent-reason').exists()"
data = {
'use' => 'official',
'family'=>'Becker968',
'extension' => [
{
'url' => 'http://hl7.org/fhir/StructureDefinition/data-absent-reason',
'valueCode' => 'unknown'
}
]
}
result = FHIRPath.evaluate(expression, data)
assert result == false, 'Failed us-core-8 (v3.1.1) test.'
end

end

0 comments on commit d3975bb

Please sign in to comment.