fhir_models 1.8.2 → 1.8.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +1 -0
- data/.rspec +2 -0
- data/.rubocop.yml +5 -1156
- data/.rubocop_todo.yml +76 -0
- data/.travis.yml +9 -3
- data/Gemfile +1 -1
- data/Guardfile +50 -0
- data/Rakefile +4 -5
- data/bin/console +4 -4
- data/fhir_models.gemspec +6 -3
- data/lib/fhir_models.rb +2 -1
- data/lib/fhir_models/bootstrap/definitions.rb +100 -94
- data/lib/fhir_models/bootstrap/field.rb +1 -1
- data/lib/fhir_models/bootstrap/generator.rb +11 -11
- data/lib/fhir_models/bootstrap/hashable.rb +18 -5
- data/lib/fhir_models/bootstrap/json.rb +2 -1
- data/lib/fhir_models/bootstrap/model.rb +21 -39
- data/lib/fhir_models/bootstrap/preprocess.rb +21 -36
- data/lib/fhir_models/bootstrap/template.rb +5 -9
- data/lib/fhir_models/bootstrap/xml.rb +8 -5
- data/lib/fhir_models/deprecate.rb +22 -0
- data/lib/fhir_models/fhir.rb +58 -0
- data/lib/fhir_models/fhir/metadata.rb +1 -1
- data/lib/fhir_models/fhir_ext/element_definition.rb +47 -0
- data/lib/fhir_models/fhir_ext/structure_definition.rb +203 -524
- data/lib/fhir_models/fhir_ext/structure_definition_compare.rb +375 -0
- data/lib/fhir_models/fluentpath/evaluate.rb +9 -2
- data/lib/fhir_models/fluentpath/expression.rb +8 -1
- data/lib/fhir_models/fluentpath/parse.rb +2 -2
- data/lib/fhir_models/version.rb +1 -1
- metadata +62 -15
- data/lib/fhir_models/fhir/resources/MetadataResource.rb +0 -52
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2017-02-25 13:02:53 -0500 using RuboCop version 0.47.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 37
|
10
|
+
Metrics/AbcSize:
|
11
|
+
Max: 423
|
12
|
+
|
13
|
+
# Offense count: 10
|
14
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
15
|
+
Metrics/BlockLength:
|
16
|
+
Max: 96
|
17
|
+
|
18
|
+
# Offense count: 1
|
19
|
+
# Configuration parameters: CountBlocks.
|
20
|
+
Metrics/BlockNesting:
|
21
|
+
Max: 4
|
22
|
+
|
23
|
+
# Offense count: 5
|
24
|
+
# Configuration parameters: CountComments.
|
25
|
+
Metrics/ClassLength:
|
26
|
+
Max: 499
|
27
|
+
|
28
|
+
# Offense count: 26
|
29
|
+
Metrics/CyclomaticComplexity:
|
30
|
+
Max: 69
|
31
|
+
|
32
|
+
# Offense count: 40
|
33
|
+
# Configuration parameters: CountComments.
|
34
|
+
Metrics/MethodLength:
|
35
|
+
Max: 105
|
36
|
+
|
37
|
+
# Offense count: 1
|
38
|
+
# Configuration parameters: CountComments.
|
39
|
+
Metrics/ModuleLength:
|
40
|
+
Max: 120
|
41
|
+
|
42
|
+
|
43
|
+
# Offense count: 25
|
44
|
+
Metrics/PerceivedComplexity:
|
45
|
+
Max: 72
|
46
|
+
|
47
|
+
# Offense count: 16
|
48
|
+
Style/ClassVars:
|
49
|
+
Exclude:
|
50
|
+
- 'lib/fhir_models/bootstrap/definitions.rb'
|
51
|
+
- 'lib/fhir_models/fluentpath/parse.rb'
|
52
|
+
|
53
|
+
# Offense count: 14
|
54
|
+
Style/Documentation:
|
55
|
+
Exclude:
|
56
|
+
- 'spec/**/*'
|
57
|
+
- 'test/**/*'
|
58
|
+
- 'lib/fhir_models/bootstrap/definitions.rb'
|
59
|
+
- 'lib/fhir_models/bootstrap/field.rb'
|
60
|
+
- 'lib/fhir_models/bootstrap/generator.rb'
|
61
|
+
- 'lib/fhir_models/bootstrap/hashable.rb'
|
62
|
+
- 'lib/fhir_models/bootstrap/json.rb'
|
63
|
+
- 'lib/fhir_models/bootstrap/model.rb'
|
64
|
+
- 'lib/fhir_models/bootstrap/preprocess.rb'
|
65
|
+
- 'lib/fhir_models/bootstrap/template.rb'
|
66
|
+
- 'lib/fhir_models/bootstrap/xml.rb'
|
67
|
+
- 'lib/fhir_models/fhir.rb'
|
68
|
+
- 'lib/fhir_models/fhir_ext/structure_definition.rb'
|
69
|
+
- 'lib/fhir_models/fhir_ext/structure_definition_finding.rb'
|
70
|
+
- 'lib/fhir_models/fluentpath/expression.rb'
|
71
|
+
- 'lib/fhir_models/fluentpath/parse.rb'
|
72
|
+
|
73
|
+
# Offense count: 1
|
74
|
+
Style/MethodMissing:
|
75
|
+
Exclude:
|
76
|
+
- 'lib/fhir_models/bootstrap/model.rb'
|
data/.travis.yml
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
language: ruby
|
2
|
+
env:
|
3
|
+
- TESTMEMORY=0 GCDELAY=2.0
|
2
4
|
rvm:
|
3
5
|
- "2.1.10"
|
4
|
-
- "2.2.
|
5
|
-
- "2.3.
|
6
|
+
- "2.2.6"
|
7
|
+
- "2.3.3"
|
8
|
+
- "2.4.0"
|
6
9
|
script:
|
7
|
-
- bundle exec rake
|
10
|
+
- bundle exec rake
|
8
11
|
- bundle exec codeclimate-test-reporter
|
9
12
|
notifications:
|
10
13
|
email:
|
@@ -14,3 +17,6 @@ notifications:
|
|
14
17
|
addons:
|
15
18
|
code_climate:
|
16
19
|
repo_token: 0230b3379581b30743b7b4355d7394e427648e604d19a2aba987956201eee290
|
20
|
+
before_install:
|
21
|
+
- gem update --system
|
22
|
+
- gem update bundler
|
data/Gemfile
CHANGED
data/Guardfile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
28
|
+
require 'guard/rspec/dsl'
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
end
|
43
|
+
|
44
|
+
guard :test do
|
45
|
+
watch(%r{^test/.+_test\.rb$})
|
46
|
+
watch('test/test_helper.rb') { 'test' }
|
47
|
+
|
48
|
+
# Non-rails
|
49
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
50
|
+
end
|
data/Rakefile
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'bundler/gem_tasks'
|
2
2
|
require 'rake/testtask'
|
3
|
+
require 'rspec/core/rake_task'
|
3
4
|
require 'rubocop/rake_task'
|
4
5
|
|
5
6
|
Dir['lib/fhir_models/tasks/**/*.rake'].each do |file|
|
@@ -14,13 +15,11 @@ Rake::TestTask.new(:test) do |t|
|
|
14
15
|
t.warning = false
|
15
16
|
end
|
16
17
|
|
18
|
+
RSpec::Core::RakeTask.new
|
19
|
+
|
17
20
|
desc 'Run rubocop'
|
18
21
|
task :rubocop do
|
19
22
|
RuboCop::RakeTask.new
|
20
23
|
end
|
21
24
|
|
22
|
-
task
|
23
|
-
system('open coverage/index.html')
|
24
|
-
end
|
25
|
-
|
26
|
-
task default: [:test]
|
25
|
+
task default: %i[rubocop spec test]
|
data/bin/console
CHANGED
@@ -7,8 +7,8 @@ require 'fhir_models'
|
|
7
7
|
# with your gem easier. You can also use a different console, if you like.
|
8
8
|
|
9
9
|
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
|
11
|
-
|
10
|
+
require 'pry'
|
11
|
+
Pry.start
|
12
12
|
|
13
|
-
require 'irb'
|
14
|
-
IRB.start
|
13
|
+
# require 'irb'
|
14
|
+
# IRB.start
|
data/fhir_models.gemspec
CHANGED
@@ -25,12 +25,15 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_dependency 'bcp47', '>= 0.3'
|
26
26
|
spec.add_dependency 'mime-types', '>= 1.16', '< 3'
|
27
27
|
|
28
|
-
spec.add_development_dependency 'bundler'
|
29
|
-
spec.add_development_dependency 'rake'
|
28
|
+
spec.add_development_dependency 'bundler'
|
29
|
+
spec.add_development_dependency 'rake'
|
30
30
|
spec.add_development_dependency 'pry'
|
31
31
|
spec.add_development_dependency 'test-unit'
|
32
|
+
spec.add_development_dependency 'rspec'
|
32
33
|
spec.add_development_dependency 'simplecov'
|
33
34
|
spec.add_development_dependency 'nokogiri-diff'
|
34
|
-
spec.add_development_dependency 'rubocop'
|
35
|
+
spec.add_development_dependency 'rubocop'
|
35
36
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
37
|
+
spec.add_development_dependency 'guard-rspec'
|
38
|
+
spec.add_development_dependency 'guard-test'
|
36
39
|
end
|
data/lib/fhir_models.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
root = File.expand_path '..', File.dirname(File.absolute_path(__FILE__))
|
2
2
|
|
3
|
-
require File.join(root, 'lib', 'fhir_models', 'version
|
3
|
+
require File.join(root, 'lib', 'fhir_models', 'version')
|
4
|
+
require File.join(root, 'lib', 'fhir_models', 'deprecate')
|
4
5
|
|
5
6
|
# Need to require Hashable first
|
6
7
|
require File.join(root, 'lib', 'fhir_models', 'bootstrap', 'hashable.rb')
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'tempfile'
|
2
2
|
module FHIR
|
3
3
|
class Definitions
|
4
|
+
extend FHIR::Deprecate
|
4
5
|
@@defns = File.expand_path '../definitions', File.dirname(File.absolute_path(__FILE__))
|
5
6
|
@@types = nil
|
6
7
|
@@resources = nil
|
@@ -10,125 +11,127 @@ module FHIR
|
|
10
11
|
@@valuesets = nil
|
11
12
|
@@search_params = nil
|
12
13
|
|
14
|
+
@@cache = {}
|
15
|
+
|
13
16
|
# ----------------------------------------------------------------
|
14
17
|
# Types
|
15
18
|
# ----------------------------------------------------------------
|
16
19
|
|
17
|
-
def self.
|
18
|
-
|
20
|
+
def self.types
|
21
|
+
@@types ||= begin
|
19
22
|
# load the types
|
20
23
|
filename = File.join(@@defns, 'structures', 'profiles-types.json')
|
21
24
|
raw = File.open(filename, 'r:UTF-8', &:read)
|
22
|
-
|
25
|
+
JSON.parse(raw)['entry'].map { |e| e['resource'] }
|
23
26
|
end
|
24
27
|
end
|
28
|
+
deprecate :load_types, :types
|
29
|
+
private_class_method :types
|
25
30
|
|
26
|
-
def self.
|
27
|
-
load_types
|
31
|
+
def self.primitive_types
|
28
32
|
# primitive data types start with a lowercase letter
|
29
|
-
|
33
|
+
@primitive_types ||= types.select { |t| t['id'].start_with?(*('a'..'z').to_a) }
|
30
34
|
end
|
35
|
+
deprecate :get_primitive_types, :primitive_types
|
31
36
|
|
32
|
-
def self.
|
33
|
-
load_types
|
37
|
+
def self.complex_types
|
34
38
|
# complex data types start with an uppercase letter
|
35
39
|
# and we'll filter out profiles on types (for example, Age is a profile on Quantity)
|
36
|
-
|
40
|
+
@complex_types ||= types.select { |t| t['id'].start_with?(*('A'..'Z').to_a) && (t['id'] == t['snapshot']['element'].first['path']) }
|
37
41
|
end
|
42
|
+
deprecate :get_complex_types, :complex_types
|
38
43
|
|
39
|
-
def self.
|
44
|
+
def self.type_definition(type_name)
|
40
45
|
return nil if type_name.nil?
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
46
|
+
return @@cache[type_name] if @@cache[type_name]
|
47
|
+
definition = types.find { |x| x['xmlId'] == type_name || x['name'] == type_name || x['url'] == type_name }
|
48
|
+
@@cache[type_name] = FHIR::StructureDefinition.new(definition) if definition
|
49
|
+
@@cache[type_name]
|
45
50
|
end
|
51
|
+
deprecate :get_type_definition, :type_definition
|
46
52
|
|
47
53
|
# ----------------------------------------------------------------
|
48
54
|
# Resources, Profiles, Extensions
|
49
55
|
# ----------------------------------------------------------------
|
50
56
|
|
51
|
-
def self.
|
52
|
-
|
57
|
+
def self.resources
|
58
|
+
@@resources ||= begin
|
53
59
|
# load the resources
|
54
60
|
filename = File.join(@@defns, 'structures', 'profiles-resources.json')
|
55
61
|
raw = File.open(filename, 'r:UTF-8', &:read)
|
56
|
-
|
62
|
+
JSON.parse(raw)['entry'].map { |e| e['resource'] }
|
57
63
|
end
|
58
64
|
end
|
65
|
+
deprecate :load_resources, :resources
|
66
|
+
private_class_method :resources
|
59
67
|
|
60
|
-
def self.
|
61
|
-
|
62
|
-
@@resources
|
68
|
+
def self.resource_definitions
|
69
|
+
resources.select { |r| r['kind'] == 'resource' }
|
63
70
|
end
|
71
|
+
deprecate :get_resource_definitions, :resource_definitions
|
64
72
|
|
65
|
-
def self.
|
73
|
+
def self.resource_definition(resource_name)
|
66
74
|
return nil if resource_name.nil?
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
75
|
+
return @@cache[resource_name] if @@cache[resource_name]
|
76
|
+
definition = resources.find { |x| x['xmlId'] == resource_name || x['name'] == resource_name || x['url'] == resource_name }
|
77
|
+
@@cache[resource_name] = FHIR::StructureDefinition.new(definition) if definition
|
78
|
+
@@cache[resource_name]
|
71
79
|
end
|
80
|
+
deprecate :get_resource_definition, :resource_definition
|
72
81
|
|
73
|
-
def self.
|
74
|
-
|
82
|
+
def self.profiles
|
83
|
+
@@profiles ||= begin
|
75
84
|
# load the built-in profiles
|
76
85
|
filename = File.join(@@defns, 'structures', 'profiles-others.json')
|
77
86
|
raw = File.open(filename, 'r:UTF-8', &:read)
|
78
|
-
|
87
|
+
JSON.parse(raw)['entry'].map { |e| e['resource'] }
|
79
88
|
end
|
80
89
|
end
|
90
|
+
deprecate :load_profiles, :profiles
|
91
|
+
private_class_method :profiles
|
81
92
|
|
82
|
-
def self.
|
83
|
-
|
93
|
+
def self.extensions
|
94
|
+
@@extensions ||= begin
|
84
95
|
# load the built-in extensions
|
85
96
|
filename = File.join(@@defns, 'structures', 'extension-definitions.json')
|
86
97
|
raw = File.open(filename, 'r:UTF-8', &:read)
|
87
|
-
|
98
|
+
JSON.parse(raw)['entry'].map { |e| e['resource'] }
|
88
99
|
end
|
89
100
|
end
|
101
|
+
deprecate :load_extensions, :extensions
|
102
|
+
private_class_method :extensions
|
90
103
|
|
91
|
-
def self.
|
104
|
+
def self.extension_definition(extension_name)
|
92
105
|
return nil if extension_name.nil?
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
d
|
106
|
+
extension = extensions.find { |x| x['xmlId'] == extension_name || x['name'] == extension_name || x['url'] == extension_name }
|
107
|
+
return nil if extension.nil?
|
108
|
+
FHIR::StructureDefinition.new(extension)
|
97
109
|
end
|
110
|
+
deprecate :get_extension_definition, :extension_definition
|
98
111
|
|
99
112
|
# Get the basetype (String) for a given profile or extension.
|
100
|
-
def self.
|
113
|
+
def self.basetype(uri)
|
101
114
|
return nil if uri.nil?
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
defn = @@profiles.select { |x| x['url'] == uri }.first
|
106
|
-
defn = @@extensions.select { |x| x['url'] == uri }.first if defn.nil?
|
107
|
-
|
108
|
-
basetype = nil
|
109
|
-
basetype = defn['baseType'] unless defn.nil?
|
110
|
-
basetype
|
115
|
+
defn = profiles.detect { |x| x['url'] == uri } || extensions.detect { |x| x['url'] == uri }
|
116
|
+
return nil if defn.nil?
|
117
|
+
defn['baseType']
|
111
118
|
end
|
119
|
+
deprecate :get_basetype, :basetype
|
112
120
|
|
113
121
|
# Get the StructureDefinition for a given profile.
|
114
|
-
def self.
|
122
|
+
def self.profile(uri)
|
115
123
|
return nil if uri.nil?
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
defn = @@profiles.select { |x| x['url'] == uri }.first
|
120
|
-
defn = @@extensions.select { |x| x['url'] == uri }.first if defn.nil?
|
121
|
-
|
122
|
-
profile = nil
|
123
|
-
profile = FHIR::StructureDefinition.new(defn) unless defn.nil?
|
124
|
-
profile
|
124
|
+
defn = profiles.detect { |x| x['url'] == uri } || extensions.detect { |x| x['url'] == uri }
|
125
|
+
return nil if defn.nil?
|
126
|
+
FHIR::StructureDefinition.new(defn)
|
125
127
|
end
|
128
|
+
deprecate :get_profile, :profile
|
126
129
|
|
127
|
-
def self.
|
130
|
+
def self.profiles_for_resource(resource_name)
|
128
131
|
return nil if resource_name.nil?
|
129
|
-
|
130
|
-
@@profiles.select { |x| x['baseType'] == resource_name }.map { |x| FHIR::StructureDefinition.new(x) }
|
132
|
+
profiles.select { |x| x['baseType'] == resource_name }.map { |x| FHIR::StructureDefinition.new(x) }
|
131
133
|
end
|
134
|
+
deprecate :get_profiles_for_resource, :profile_for_resource
|
132
135
|
|
133
136
|
# Get a dynamically generated class for a given profile.
|
134
137
|
def self.get_profile_class(uri)
|
@@ -171,66 +174,69 @@ module FHIR
|
|
171
174
|
# ValueSet Code Expansions
|
172
175
|
# ----------------------------------------------------------------
|
173
176
|
|
174
|
-
def self.
|
175
|
-
|
177
|
+
def self.expansions
|
178
|
+
@@expansions ||= begin
|
176
179
|
# load the expansions
|
177
180
|
filename = File.join(@@defns, 'valuesets', 'expansions.json')
|
178
181
|
raw = File.open(filename, 'r:UTF-8', &:read)
|
179
|
-
|
182
|
+
JSON.parse(raw)['entry'].map { |e| e['resource'] }
|
180
183
|
end
|
181
|
-
|
184
|
+
end
|
185
|
+
deprecate :load_expansions, :expansions
|
186
|
+
|
187
|
+
def self.valuesets
|
188
|
+
@@valuesets ||= begin
|
182
189
|
# load the valuesets
|
183
190
|
filename = File.join(@@defns, 'valuesets', 'valuesets.json')
|
184
191
|
raw = File.open(filename, 'r:UTF-8', &:read)
|
185
|
-
|
192
|
+
JSON.parse(raw)['entry'].map { |e| e['resource'] }
|
186
193
|
end
|
187
194
|
end
|
188
195
|
|
189
196
|
# Get codes (Array of Strings) for a given expansion.
|
190
197
|
def self.get_codes(uri)
|
191
198
|
return nil if uri.nil?
|
192
|
-
|
193
|
-
|
194
|
-
valueset = @@expansions.select { |x| x['url'] == uri }.first
|
199
|
+
return @@cache[uri] if @@cache[uri]
|
200
|
+
valueset = expansions.select { |x| x['url'] == uri }.first
|
195
201
|
unless valueset.nil?
|
196
|
-
|
202
|
+
@@cache[uri] = {}
|
197
203
|
if !valueset['expansion'].nil? && !valueset['expansion']['contains'].nil?
|
198
204
|
keys = valueset['expansion']['contains'].map { |x| x['system'] }.uniq
|
199
|
-
keys.each { |x|
|
200
|
-
valueset['expansion']['contains'].each { |x|
|
205
|
+
keys.each { |x| @@cache[uri][x] = [] }
|
206
|
+
valueset['expansion']['contains'].each { |x| @@cache[uri][x['system']] << x['code'] }
|
201
207
|
end
|
202
208
|
if !valueset['compose'].nil? && !valueset['compose']['include'].nil?
|
203
209
|
included_systems = valueset['compose']['include'].map { |x| x['system'] }.uniq
|
204
|
-
included_systems.each { |x|
|
205
|
-
systems =
|
210
|
+
included_systems.each { |x| @@cache[uri][x] = [] unless @@cache[uri].keys.include?(x) }
|
211
|
+
systems = valuesets.select { |x| x['resourceType'] == 'CodeSystem' && included_systems.include?(x['url']) }
|
206
212
|
systems.each do |x|
|
207
|
-
x['concept'].each { |y|
|
213
|
+
x['concept'].each { |y| @@cache[uri][x['url']] << y['code'] } if x['concept']
|
208
214
|
end
|
209
215
|
end
|
210
216
|
end
|
211
|
-
|
217
|
+
@@cache[uri]
|
212
218
|
end
|
213
219
|
|
214
220
|
# Get the "display" (human-readable title) for a given code in a code system (uri)
|
215
221
|
# If one can't be found, return nil
|
216
222
|
def self.get_display(uri, code)
|
217
223
|
return nil if uri.nil? || code.nil?
|
218
|
-
|
219
|
-
|
220
|
-
valuesets += @@valuesets.select { |x| x['url'] == uri }
|
224
|
+
valuesets_and_expansions = expansions.select { |ex| ex['compose']['include'].detect { |i| i['system'] == uri } }
|
225
|
+
valuesets_and_expansions += valuesets.select { |vs| vs['url'] == uri }
|
221
226
|
code_hash = nil
|
222
|
-
|
223
|
-
if
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
code_hash =
|
227
|
+
valuesets_and_expansions.each do |valueset|
|
228
|
+
if valueset['expansion'] && valueset['expansion']['contains']
|
229
|
+
# This currently only matches 'expansions', not 'valuesets'
|
230
|
+
code_hash = valueset['expansion']['contains'].detect { |contained| contained['system'] == uri && contained['code'] == code }
|
231
|
+
elsif valueset['compose'] && valueset['compose']['include']
|
232
|
+
# This seems to only match 'valuesets'
|
233
|
+
valueset['compose']['include'].each do |code_system|
|
234
|
+
code_hash = code_system['concept'].detect { |con| con['code'] == code } if code_system['concept']
|
230
235
|
break if code_hash
|
231
236
|
end
|
232
237
|
elsif valueset['concept']
|
233
|
-
|
238
|
+
# This currently only matches 'valuesets', not 'expansions'
|
239
|
+
code_hash = valueset['concept'].detect { |vs| vs['code'] == code }
|
234
240
|
end
|
235
241
|
break if code_hash
|
236
242
|
end
|
@@ -241,21 +247,21 @@ module FHIR
|
|
241
247
|
# Search Params
|
242
248
|
# ----------------------------------------------------------------
|
243
249
|
|
244
|
-
def self.
|
245
|
-
|
250
|
+
def self.search_params
|
251
|
+
@@search_params ||= begin
|
246
252
|
# load the search parameters
|
247
253
|
filename = File.join(@@defns, 'structures', 'search-parameters.json')
|
248
254
|
raw = File.open(filename, 'r:UTF-8', &:read)
|
249
|
-
|
255
|
+
JSON.parse(raw)['entry'].map { |e| e['resource'] }
|
250
256
|
end
|
251
257
|
end
|
258
|
+
deprecate :load_search_params, :search_params
|
259
|
+
private_class_method :search_params
|
252
260
|
|
253
|
-
def self.
|
261
|
+
def self.search_parameters(type_name)
|
254
262
|
return nil if type_name.nil?
|
255
|
-
|
256
|
-
@@search_params.select { |p| p['base'].include?(type_name) && p['xpath'] && !p['xpath'].include?('extension') }.map { |p| p['code'] }
|
263
|
+
search_params.select { |p| p['base'].include?(type_name) && p['xpath'] && !p['xpath'].include?('extension') }.map { |p| p['code'] }
|
257
264
|
end
|
258
|
-
|
259
|
-
private_class_method :load_types, :load_extensions, :load_expansions, :load_profiles, :load_resources, :load_search_params
|
265
|
+
deprecate :get_search_parameters, :search_parameters
|
260
266
|
end
|
261
267
|
end
|