fhir_models 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +10 -1
- data/fhir_models.gemspec +1 -1
- data/lib/fhir_models/bootstrap/definitions.rb +12 -5
- data/lib/fhir_models/bootstrap/model.rb +4 -4
- data/lib/fhir_models/fhir_ext/structure_definition.rb +27 -26
- data/lib/fhir_models/version.rb +1 -1
- metadata +3 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecf5c1936f2720e5d6bd078a8f90f04f1c893b92
|
4
|
+
data.tar.gz: f9e7defc1c7cffa0476e7cac9eb6ac24551df0bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 784aab30766ed214c764e9674bc66d91d62e870cc4fb89ae8b3eae89d5c45844c3a8c35e14a42ddd322e84137d3b3026b53a622f8d5d55bdbb7fdc8c7270fa12
|
7
|
+
data.tar.gz: 254312b628d5d818c4e6e42897b970e02dfb1142de6b88449057b3dde136d62be76fcec1f0187ee70a8ff30c3e3521fbf5f5367c6bf3687a671a0c826a271831
|
data/.rubocop_todo.yml
CHANGED
@@ -6,6 +6,15 @@
|
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
+
Performance/Caller:
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Style/MultipleComparison:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
Style/YodaCondition:
|
16
|
+
Enabled: false
|
17
|
+
|
9
18
|
# Offense count: 37
|
10
19
|
Metrics/AbcSize:
|
11
20
|
Max: 423
|
@@ -13,7 +22,7 @@ Metrics/AbcSize:
|
|
13
22
|
# Offense count: 10
|
14
23
|
# Configuration parameters: CountComments, ExcludedMethods.
|
15
24
|
Metrics/BlockLength:
|
16
|
-
Max:
|
25
|
+
Max: 120
|
17
26
|
|
18
27
|
# Offense count: 1
|
19
28
|
# Configuration parameters: CountBlocks.
|
data/fhir_models.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_dependency 'nokogiri', '>= 1.6'
|
24
24
|
spec.add_dependency 'date_time_precision', '>= 0.8'
|
25
25
|
spec.add_dependency 'bcp47', '>= 0.3'
|
26
|
-
spec.add_dependency 'mime-types', '>= 1.16'
|
26
|
+
spec.add_dependency 'mime-types', '>= 1.16'
|
27
27
|
|
28
28
|
spec.add_development_dependency 'bundler'
|
29
29
|
spec.add_development_dependency 'rake'
|
@@ -197,7 +197,7 @@ module FHIR
|
|
197
197
|
def self.get_codes(uri)
|
198
198
|
return nil if uri.nil?
|
199
199
|
return @@cache[uri] if @@cache[uri]
|
200
|
-
valueset = expansions.
|
200
|
+
valueset = expansions.find { |x| x['url'] == uri } || valuesets.find { |x| x['url'] == uri && x['resourceType'] == 'ValueSet' }
|
201
201
|
unless valueset.nil?
|
202
202
|
@@cache[uri] = {}
|
203
203
|
if !valueset['expansion'].nil? && !valueset['expansion']['contains'].nil?
|
@@ -206,11 +206,18 @@ module FHIR
|
|
206
206
|
valueset['expansion']['contains'].each { |x| @@cache[uri][x['system']] << x['code'] }
|
207
207
|
end
|
208
208
|
if !valueset['compose'].nil? && !valueset['compose']['include'].nil?
|
209
|
-
|
210
|
-
included_systems
|
209
|
+
# for each system, if codes are included add those, otherwise lookup the codesystem in the list
|
210
|
+
included_systems = []
|
211
|
+
valueset['compose']['include'].each do |code_group|
|
212
|
+
system_url = code_group['system']
|
213
|
+
@@cache[uri][system_url] ||= []
|
214
|
+
code_group['concept'].each { |y| @@cache[uri][system_url] << y['code'] } if code_group['concept']
|
215
|
+
included_systems << system_url
|
216
|
+
end
|
217
|
+
included_systems.each { |x| @@cache[uri][x] ||= [] }
|
211
218
|
systems = valuesets.select { |x| x['resourceType'] == 'CodeSystem' && included_systems.include?(x['url']) }
|
212
|
-
systems.each do |
|
213
|
-
|
219
|
+
systems.each do |included_system|
|
220
|
+
included_system['concept'].each { |y| @@cache[uri][included_system['url']] << y['code'] } if included_system['concept']
|
214
221
|
end
|
215
222
|
end
|
216
223
|
@@cache[uri].each { |_system, codes| codes.uniq! }
|
@@ -235,7 +235,7 @@ module FHIR
|
|
235
235
|
end
|
236
236
|
else
|
237
237
|
the_codes.each do |code|
|
238
|
-
has_valid_code = true if
|
238
|
+
has_valid_code = true if check_binding_uri(meta['binding']['uri'], code)
|
239
239
|
break if has_valid_code
|
240
240
|
end
|
241
241
|
end
|
@@ -277,7 +277,7 @@ module FHIR
|
|
277
277
|
end
|
278
278
|
deprecate :is_primitive?, :primitive?
|
279
279
|
|
280
|
-
def
|
280
|
+
def check_binding_uri(uri, value)
|
281
281
|
valid = false
|
282
282
|
if uri == 'http://hl7.org/fhir/ValueSet/content-type' || uri == 'http://www.rfc-editor.org/bcp/bcp13.txt'
|
283
283
|
matches = MIME::Types[value]
|
@@ -288,11 +288,11 @@ module FHIR
|
|
288
288
|
has_region = !(value =~ /-/).nil?
|
289
289
|
valid = !BCP47::Language.identify(value.downcase).nil? && (!has_region || !BCP47::Region.identify(value.upcase).nil?)
|
290
290
|
else
|
291
|
-
FHIR.logger.warn "Unable to
|
291
|
+
FHIR.logger.warn "Unable to check_binding_uri on unknown ValueSet: #{uri}"
|
292
292
|
end
|
293
293
|
valid
|
294
294
|
end
|
295
295
|
|
296
|
-
private :validate_reference_type, :
|
296
|
+
private :validate_reference_type, :check_binding_uri, :validate_field
|
297
297
|
end
|
298
298
|
end
|
@@ -113,9 +113,10 @@ module FHIR
|
|
113
113
|
path = element.local_name || element.path
|
114
114
|
path = path[(@hierarchy.path.size + 1)..-1] if path.start_with? @hierarchy.path
|
115
115
|
|
116
|
-
|
116
|
+
if element.type && !element.type.empty?
|
117
117
|
data_type_found = element.type.first.code
|
118
|
-
|
118
|
+
else
|
119
|
+
@warnings << "Unable to guess data type for #{describe_element(element)}"
|
119
120
|
data_type_found = nil
|
120
121
|
end
|
121
122
|
|
@@ -139,16 +140,12 @@ module FHIR
|
|
139
140
|
nodes = nodes.select { |x| extension_profile.profile == x['url'] }
|
140
141
|
end
|
141
142
|
|
142
|
-
|
143
|
-
min = element.min
|
144
|
-
max = element.max == '*' ? Float::INFINITY : element.max.to_i
|
145
|
-
if (nodes.size < min) || (nodes.size > max)
|
146
|
-
@errors << "#{describe_element(element)} failed cardinality test (#{min}..#{max}) -- found #{nodes.size}"
|
147
|
-
end
|
143
|
+
verify_cardinality(element, nodes)
|
148
144
|
|
149
145
|
return if nodes.empty?
|
150
146
|
# Check the datatype for each node, only if the element has one declared, and it isn't the root element
|
151
147
|
if !element.type.empty? && element.path != id
|
148
|
+
# element.type not being empty implies data_type_found != nil, for valid profiles
|
152
149
|
codeable_concept_pattern = element.pattern && element.pattern.is_a?(FHIR::CodeableConcept)
|
153
150
|
matching_pattern = false
|
154
151
|
nodes.each do |value|
|
@@ -165,18 +162,18 @@ module FHIR
|
|
165
162
|
# if extension_def
|
166
163
|
# verified_extension = extension_def.validates_resource?(FHIR::Extension.new(deep_copy(value)))
|
167
164
|
# end
|
168
|
-
|
165
|
+
else
|
169
166
|
temp = @errors
|
170
167
|
@errors = []
|
171
168
|
verified_data_type = data_type?(data_type_found, value)
|
172
|
-
temp_messages
|
169
|
+
temp_messages += @errors
|
173
170
|
@errors = temp
|
174
171
|
end
|
175
|
-
if
|
172
|
+
if verified_extension || verified_data_type
|
176
173
|
matching_type += 1
|
177
174
|
if data_type_found == 'code' # then check the binding
|
178
175
|
unless element.binding.nil?
|
179
|
-
matching_type +=
|
176
|
+
matching_type += check_binding_element(element, value)
|
180
177
|
end
|
181
178
|
elsif data_type_found == 'CodeableConcept' && codeable_concept_pattern
|
182
179
|
vcc = FHIR::CodeableConcept.new(value)
|
@@ -189,12 +186,8 @@ module FHIR
|
|
189
186
|
elsif data_type_found == 'String' && !element.maxLength.nil? && (value.size > element.maxLength)
|
190
187
|
@errors << "#{describe_element(element)} exceed maximum length of #{element.maxLength}: #{value}"
|
191
188
|
end
|
192
|
-
elsif data_type_found
|
193
|
-
temp_messages << "#{describe_element(element)} is not a valid #{data_type_found}: '#{value}'"
|
194
189
|
else
|
195
|
-
|
196
|
-
matching_type += 1
|
197
|
-
@warnings >> "Unable to guess data type for #{describe_element(element)}"
|
190
|
+
temp_messages << "#{describe_element(element)} is not a valid #{data_type_found}: '#{value}'"
|
198
191
|
end
|
199
192
|
|
200
193
|
if matching_type <= 0
|
@@ -203,9 +196,7 @@ module FHIR
|
|
203
196
|
else
|
204
197
|
@warnings += temp_messages
|
205
198
|
end
|
206
|
-
|
207
|
-
@errors << "#{describe_element(element)} value of '#{value}' did not match fixed value: #{element.fixed}"
|
208
|
-
end
|
199
|
+
verify_fixed_value(element, value)
|
209
200
|
end
|
210
201
|
if codeable_concept_pattern && matching_pattern == false
|
211
202
|
@errors << "#{describe_element(element)} CodeableConcept did not match defined pattern: #{element.pattern.to_hash}"
|
@@ -244,6 +235,17 @@ module FHIR
|
|
244
235
|
end
|
245
236
|
end
|
246
237
|
|
238
|
+
def verify_cardinality(element, nodes)
|
239
|
+
# Check the cardinality
|
240
|
+
min = element.min
|
241
|
+
max = element.max == '*' ? Float::INFINITY : element.max.to_i
|
242
|
+
@errors << "#{describe_element(element)} failed cardinality test (#{min}..#{max}) -- found #{nodes.size}" if (nodes.size < min) || (nodes.size > max)
|
243
|
+
end
|
244
|
+
|
245
|
+
def verify_fixed_value(element, value)
|
246
|
+
@errors << "#{describe_element(element)} value of '#{value}' did not match fixed value: #{element.fixed}" if !element.fixed.nil? && element.fixed != value
|
247
|
+
end
|
248
|
+
|
247
249
|
# data_type_code == a FHIR DataType code (see http://hl7.org/fhir/2015May/datatypes.html)
|
248
250
|
# value == the representation of the value
|
249
251
|
def data_type?(data_type_code, value)
|
@@ -322,7 +324,7 @@ module FHIR
|
|
322
324
|
end
|
323
325
|
deprecate :is_data_type?, :data_type?
|
324
326
|
|
325
|
-
def
|
327
|
+
def check_binding_element(element, value)
|
326
328
|
vs_uri = element.binding.valueSetUri || element.binding.valueSetReference.reference
|
327
329
|
valueset = FHIR::Definitions.get_codes(vs_uri)
|
328
330
|
|
@@ -353,7 +355,7 @@ module FHIR
|
|
353
355
|
end
|
354
356
|
end
|
355
357
|
elsif !valueset.values.flatten.include?(value)
|
356
|
-
message = "#{element.path} has invalid code '#{value}' from #{
|
358
|
+
message = "#{element.path} has invalid code '#{value}' from #{vs_uri}"
|
357
359
|
if element.binding.strength == 'required'
|
358
360
|
@errors << message
|
359
361
|
matching_type -= 1
|
@@ -368,13 +370,12 @@ module FHIR
|
|
368
370
|
def some_type_of_xml_or_json?(code)
|
369
371
|
m = code.downcase
|
370
372
|
return true if m == 'xml' || m == 'json'
|
371
|
-
return true if
|
372
|
-
return true if m.
|
373
|
-
return true if m.starts_with?('application/json') || m.starts_with?('text/json')
|
373
|
+
return true if m.start_with?('application/', 'text/') && m.end_with?('json', 'xml')
|
374
|
+
return true if m.start_with?('application/xml', 'text/xml', 'application/json', 'text/json')
|
374
375
|
false
|
375
376
|
end
|
376
377
|
deprecate :is_some_type_of_xml_or_json, :some_type_of_xml_or_json?
|
377
378
|
|
378
|
-
private :valid_json?, :get_json_nodes, :build_hierarchy, :verify_element, :
|
379
|
+
private :valid_json?, :get_json_nodes, :build_hierarchy, :verify_element, :check_binding_element
|
379
380
|
end
|
380
381
|
end
|
data/lib/fhir_models/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fhir_models
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Walonoski
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2017-
|
13
|
+
date: 2017-08-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -61,9 +61,6 @@ dependencies:
|
|
61
61
|
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '1.16'
|
64
|
-
- - "<"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '3'
|
67
64
|
type: :runtime
|
68
65
|
prerelease: false
|
69
66
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -71,9 +68,6 @@ dependencies:
|
|
71
68
|
- - ">="
|
72
69
|
- !ruby/object:Gem::Version
|
73
70
|
version: '1.16'
|
74
|
-
- - "<"
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
version: '3'
|
77
71
|
- !ruby/object:Gem::Dependency
|
78
72
|
name: bundler
|
79
73
|
requirement: !ruby/object:Gem::Requirement
|
@@ -1633,7 +1627,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1633
1627
|
version: '0'
|
1634
1628
|
requirements: []
|
1635
1629
|
rubyforge_project:
|
1636
|
-
rubygems_version: 2.6.
|
1630
|
+
rubygems_version: 2.6.12
|
1637
1631
|
signing_key:
|
1638
1632
|
specification_version: 4
|
1639
1633
|
summary: A Gem for handling FHIR models in ruby
|