fhir_models 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +8 -12
- data/Gemfile.lock +1 -1
- data/lib/fhir_models/bootstrap/hashable.rb +3 -8
- data/lib/fhir_models/bootstrap/json.rb +4 -2
- data/lib/fhir_models/bootstrap/xml.rb +2 -2
- data/lib/fhir_models/fhir_ext/structure_definition.rb +35 -24
- data/lib/fhir_models/fhir_ext/structure_definition_finding.rb +2 -2
- data/lib/fhir_models/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2b2f1ce045f2f9bd1c15b6768091ca4c754997f6af10485428d23a85bf7a433
|
4
|
+
data.tar.gz: 17f3457b9d076f56ee03de4494736ac2df7081b876ec7dc2a5e753259a186751
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df265c49e13ba86273cdad361299bddd927d4256115bd8d0f654663d79b59f80de9fc3263df75f3ff9f6bd64f973648b7d1d19085415d26225f0f890103a4ab7
|
7
|
+
data.tar.gz: 054f76a7de1a789353ff47a3c8feab7cf34a8c8bc9a5693468eee2e3a7c94318e4bc8397dd0b4dd5250670abcb2d34e839760459270078840d1970efb555e299
|
data/.rubocop_todo.yml
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2019-
|
3
|
+
# on 2019-07-01 12:11:28 -0400 using RuboCop version 0.67.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
@@ -43,9 +43,9 @@ Metrics/AbcSize:
|
|
43
43
|
# Configuration parameters: CountComments, ExcludedMethods.
|
44
44
|
# ExcludedMethods: refine
|
45
45
|
Metrics/BlockLength:
|
46
|
-
Max:
|
46
|
+
Max: 78
|
47
47
|
|
48
|
-
# Offense count:
|
48
|
+
# Offense count: 10
|
49
49
|
# Configuration parameters: CountBlocks.
|
50
50
|
Metrics/BlockNesting:
|
51
51
|
Max: 5
|
@@ -53,7 +53,7 @@ Metrics/BlockNesting:
|
|
53
53
|
# Offense count: 7
|
54
54
|
# Configuration parameters: CountComments.
|
55
55
|
Metrics/ClassLength:
|
56
|
-
Max:
|
56
|
+
Max: 358
|
57
57
|
|
58
58
|
# Offense count: 23
|
59
59
|
Metrics/CyclomaticComplexity:
|
@@ -62,7 +62,7 @@ Metrics/CyclomaticComplexity:
|
|
62
62
|
# Offense count: 44
|
63
63
|
# Configuration parameters: CountComments, ExcludedMethods.
|
64
64
|
Metrics/MethodLength:
|
65
|
-
Max:
|
65
|
+
Max: 135
|
66
66
|
|
67
67
|
# Offense count: 2
|
68
68
|
# Configuration parameters: CountComments.
|
@@ -73,15 +73,11 @@ Metrics/ModuleLength:
|
|
73
73
|
Metrics/PerceivedComplexity:
|
74
74
|
Max: 68
|
75
75
|
|
76
|
-
# Offense count:
|
76
|
+
# Offense count: 1
|
77
77
|
# Configuration parameters: PreferredName.
|
78
78
|
Naming/RescuedExceptionsVariableName:
|
79
79
|
Exclude:
|
80
80
|
- 'lib/fhir_models/bootstrap/hashable.rb'
|
81
|
-
- 'lib/fhir_models/bootstrap/json.rb'
|
82
|
-
- 'lib/fhir_models/bootstrap/xml.rb'
|
83
|
-
- 'lib/fhir_models/fhir_ext/structure_definition.rb'
|
84
|
-
- 'lib/fhir_models/fhir_ext/structure_definition_finding.rb'
|
85
81
|
|
86
82
|
# Offense count: 4
|
87
83
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
@@ -140,7 +136,7 @@ Style/Documentation:
|
|
140
136
|
- 'lib/fhir_models/fluentpath/expression.rb'
|
141
137
|
- 'lib/fhir_models/fluentpath/parse.rb'
|
142
138
|
|
143
|
-
# Offense count:
|
139
|
+
# Offense count: 28
|
144
140
|
# Cop supports --auto-correct.
|
145
141
|
Style/IfUnlessModifier:
|
146
142
|
Exclude:
|
@@ -202,7 +198,7 @@ Style/RescueStandardError:
|
|
202
198
|
- 'lib/fhir_models/fluentpath/expression.rb'
|
203
199
|
- 'lib/fhir_models/fluentpath/parse.rb'
|
204
200
|
|
205
|
-
# Offense count:
|
201
|
+
# Offense count: 4
|
206
202
|
# Cop supports --auto-correct.
|
207
203
|
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, Whitelist.
|
208
204
|
# Whitelist: present?, blank?, presence, try, try!
|
data/Gemfile.lock
CHANGED
@@ -68,13 +68,7 @@ module FHIR
|
|
68
68
|
if !klass.nil? && !value.nil?
|
69
69
|
# handle array of objects
|
70
70
|
if value.is_a?(Array)
|
71
|
-
value = value.map
|
72
|
-
obj = child
|
73
|
-
unless [FHIR::RESOURCES, FHIR::TYPES].flatten.include? child.class.name.gsub('FHIR::', '')
|
74
|
-
obj = make_child(child, klass)
|
75
|
-
end
|
76
|
-
obj
|
77
|
-
end
|
71
|
+
value = value.map { |child| make_child(child, klass) }
|
78
72
|
else # handle single object
|
79
73
|
value = make_child(value, klass)
|
80
74
|
# if there is only one of these, but cardinality allows more, we need to wrap it in an array.
|
@@ -99,6 +93,8 @@ module FHIR
|
|
99
93
|
end
|
100
94
|
|
101
95
|
def make_child(child, klass)
|
96
|
+
return child if child.is_a?(FHIR::Model)
|
97
|
+
|
102
98
|
if child['resourceType'] && !klass::METADATA['resourceType']
|
103
99
|
klass = begin
|
104
100
|
FHIR.const_get(child['resourceType'])
|
@@ -112,7 +108,6 @@ module FHIR
|
|
112
108
|
begin
|
113
109
|
obj = klass.new(child)
|
114
110
|
rescue => exception
|
115
|
-
# TODO: this appears to be a dead code branch
|
116
111
|
# TODO: should this re-raise the exception if encountered instead of silently swallowing it?
|
117
112
|
FHIR.logger.error("Unable to inflate embedded class #{klass}\n#{exception.backtrace}")
|
118
113
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module FHIR
|
2
4
|
module Json
|
3
5
|
#
|
@@ -15,8 +17,8 @@ module FHIR
|
|
15
17
|
resource_type = hash['resourceType']
|
16
18
|
klass = Module.const_get("FHIR::#{resource_type}")
|
17
19
|
resource = klass.new(hash)
|
18
|
-
rescue =>
|
19
|
-
FHIR.logger.error("Failed to deserialize JSON:\n#{
|
20
|
+
rescue => ex
|
21
|
+
FHIR.logger.error("Failed to deserialize JSON:\n#{ex.backtrace}")
|
20
22
|
FHIR.logger.debug("JSON:\n#{json}")
|
21
23
|
resource = nil
|
22
24
|
end
|
@@ -78,8 +78,8 @@ module FHIR
|
|
78
78
|
resource_type = doc.root.name
|
79
79
|
klass = Module.const_get("FHIR::#{resource_type}")
|
80
80
|
resource = klass.new(hash)
|
81
|
-
rescue =>
|
82
|
-
FHIR.logger.error("Failed to deserialize XML:\n#{
|
81
|
+
rescue => ex
|
82
|
+
FHIR.logger.error("Failed to deserialize XML:\n#{ex.backtrace}")
|
83
83
|
FHIR.logger.debug("XML:\n#{xml}")
|
84
84
|
resource = nil
|
85
85
|
end
|
@@ -59,8 +59,8 @@ module FHIR
|
|
59
59
|
if json.is_a? String
|
60
60
|
begin
|
61
61
|
json = JSON.parse(json)
|
62
|
-
rescue =>
|
63
|
-
@errors << "Failed to parse JSON: #{
|
62
|
+
rescue => ex
|
63
|
+
@errors << "Failed to parse JSON: #{ex.message} %n #{h} %n #{ex.backtrace.join("\n")}"
|
64
64
|
return false
|
65
65
|
end
|
66
66
|
end
|
@@ -198,38 +198,49 @@ module FHIR
|
|
198
198
|
matching_pattern = true if vcoding.system == pcoding.system && vcoding.code == pcoding.code
|
199
199
|
end
|
200
200
|
end
|
201
|
-
elsif
|
202
|
-
|
203
|
-
|
204
|
-
@warnings
|
205
|
-
elsif element.binding.strength == 'required'
|
206
|
-
@errors
|
207
|
-
else # e.g., example-strength or unspecified
|
208
|
-
[] # Drop issues errors on the floor, in throwaway array
|
209
|
-
end
|
201
|
+
elsif %w[CodeableConcept Coding Quantity].include? data_type_found
|
202
|
+
required_strength = element&.binding&.strength == 'required'
|
203
|
+
binding_issues = required_strength ? @errors : @warnings
|
210
204
|
|
211
|
-
valueset_uri = element
|
212
|
-
if valueset_uri
|
205
|
+
valueset_uri = element&.binding&.valueSet
|
206
|
+
if valueset_uri&.include?('|')
|
213
207
|
x = valueset_uri.index('|')
|
214
208
|
valueset_uri = valueset_uri[0..x - 1]
|
215
209
|
end
|
216
|
-
|
217
|
-
|
210
|
+
check_code = lambda do |coding|
|
211
|
+
# Can't validate if both code and system are not given
|
212
|
+
if coding['code'].nil? || coding['system'].nil?
|
213
|
+
@warnings << "#{describe_element(element)} code: #{coding.to_json} missing code" if coding['code'].nil?
|
214
|
+
@warnings << "#{describe_element(element)} code: #{coding.to_json} missing system" if coding['system'].nil?
|
215
|
+
return
|
216
|
+
end
|
217
|
+
|
218
|
+
# ValueSet Validation
|
218
219
|
check_fn = self.class.vs_validators[valueset_uri]
|
219
|
-
has_valid_code =
|
220
|
+
has_valid_code = false
|
221
|
+
if check_fn
|
222
|
+
has_valid_code = check_fn.call(coding)
|
223
|
+
binding_issues << "#{describe_element(element)} has no codings from #{valueset_uri}. Codings evaluated: #{coding.to_json}" unless has_valid_code
|
224
|
+
end
|
225
|
+
|
226
|
+
# CodeSystem Validation
|
220
227
|
unless has_valid_code
|
221
|
-
|
228
|
+
check_fn = self.class.vs_validators[coding['system']]
|
229
|
+
if check_fn && !check_fn.call(coding)
|
230
|
+
binding_issues << "#{describe_element(element)} has no codings from it's specified system: #{coding['system']}. "\
|
231
|
+
"Codings evaluated: #{coding.to_json}"
|
232
|
+
end
|
222
233
|
end
|
223
234
|
end
|
224
235
|
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
if check_fn && !check_fn.call(c)
|
229
|
-
binding_issues << "#{describe_element(element)} has no codings from it's specified system: #{c.system}. "\
|
230
|
-
"Codings evaluated: #{vcc.to_json}"
|
231
|
-
end
|
236
|
+
if data_type_found == 'CodeableConcept'
|
237
|
+
value['coding']&.each do |coding|
|
238
|
+
check_code.call(coding)
|
232
239
|
end
|
240
|
+
else
|
241
|
+
# avoid checking Codings twice if they are already checked as part of a CodeableConcept
|
242
|
+
# The CodeableConcept should contain the binding for the children Codings
|
243
|
+
check_code.call(value) unless element.path == 'CodeableConcept.coding'
|
233
244
|
end
|
234
245
|
|
235
246
|
elsif data_type_found == 'String' && !element.maxLength.nil? && (value.size > element.maxLength)
|
@@ -30,8 +30,8 @@ module FHIR
|
|
30
30
|
hash.each do |key, value|
|
31
31
|
obj.send("#{key}=".to_sym, value) if value
|
32
32
|
end
|
33
|
-
rescue =>
|
34
|
-
FHIR.logger.error "Failed to parse JSON: #{
|
33
|
+
rescue => ex
|
34
|
+
FHIR.logger.error "Failed to parse JSON: #{ex.message}"
|
35
35
|
return nil
|
36
36
|
end
|
37
37
|
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: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Walonoski
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: exe
|
14
14
|
cert_chain: []
|
15
|
-
date: 2019-
|
15
|
+
date: 2019-09-27 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: nokogiri
|