fhir_models 1.6.4 → 1.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/Rakefile +3 -1
- data/bin/console +4 -4
- data/lib/fhir_models.rb +1 -0
- data/lib/fhir_models/bootstrap/hashable.rb +15 -18
- data/lib/fhir_models/bootstrap/model.rb +33 -31
- data/lib/fhir_models/fhir_ext/{StructureDefinition.rb → structure_definition.rb} +21 -21
- data/lib/fhir_models/fhir_ext/{StructureDefinitionFinding.rb → structure_definition_finding.rb} +6 -6
- data/lib/fhir_models/fluentpath/evaluate.rb +27 -24
- data/lib/fhir_models/tasks/tasks.rake +2 -2
- data/lib/fhir_models/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8d5ba026745d19e4eab57461d9df5dbf731b540
|
4
|
+
data.tar.gz: b5acd0da79199bb9ea202c56674b065f7ce94432
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e40b0e89ced0a5de56edcc4e637f99e3fa94abb3ccd6574398f34f3341075dfb807b6535ecbb0a317387dc22e3dde418a06a4c70264e347c02a12cb4570ff630
|
7
|
+
data.tar.gz: 589812ea7e6f30e2136c4270a895cef564e7775e12d2d0bc51109f9c16c9a0da4f48a4eb3ece0958f9f5533289653891bd210dee85fab687e487d4ded6bd1162
|
data/.rubocop.yml
CHANGED
data/Rakefile
CHANGED
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/lib/fhir_models.rb
CHANGED
@@ -50,27 +50,12 @@ module FHIR
|
|
50
50
|
value.map! do |child|
|
51
51
|
obj = child
|
52
52
|
unless [FHIR::RESOURCES, FHIR::TYPES].flatten.include? child.class.name.gsub('FHIR::', '')
|
53
|
-
|
54
|
-
klass = Module.const_get("FHIR::#{child['resourceType']}") rescue nil
|
55
|
-
end
|
56
|
-
begin
|
57
|
-
obj = klass.new(child)
|
58
|
-
rescue => e
|
59
|
-
FHIR.logger.error("Unable to inflate embedded class #{klass}\n#{e.backtrace}")
|
60
|
-
end
|
53
|
+
obj = make_child(child, klass)
|
61
54
|
end
|
62
55
|
obj
|
63
56
|
end
|
64
57
|
else # handle single object
|
65
|
-
|
66
|
-
klass = Module.const_get("FHIR::#{value['resourceType']}") rescue nil
|
67
|
-
end
|
68
|
-
begin
|
69
|
-
obj = klass.new(value)
|
70
|
-
value = obj
|
71
|
-
rescue => e
|
72
|
-
FHIR.logger.error("Unable to inflate embedded class #{klass}\n#{e.backtrace}")
|
73
|
-
end
|
58
|
+
value = make_child(value, klass)
|
74
59
|
# if there is only one of these, but cardinality allows more, we need to wrap it in an array.
|
75
60
|
value = [ value ] if(value && (meta['max'] > 1))
|
76
61
|
end
|
@@ -96,6 +81,18 @@ module FHIR
|
|
96
81
|
self
|
97
82
|
end
|
98
83
|
|
84
|
+
def make_child(child, klass)
|
85
|
+
if child['resourceType']
|
86
|
+
klass = Module.const_get("FHIR::#{child['resourceType']}") rescue nil
|
87
|
+
end
|
88
|
+
begin
|
89
|
+
obj = klass.new(child)
|
90
|
+
rescue => e
|
91
|
+
FHIR.logger.error("Unable to inflate embedded class #{klass}\n#{e.backtrace}")
|
92
|
+
end
|
93
|
+
obj
|
94
|
+
end
|
95
|
+
|
99
96
|
def convert_primitive(value, meta)
|
100
97
|
return value if !value.is_a?(String)
|
101
98
|
|
@@ -117,6 +114,6 @@ module FHIR
|
|
117
114
|
rval
|
118
115
|
end
|
119
116
|
|
120
|
-
private :convert_primitive
|
117
|
+
private :make_child, :convert_primitive
|
121
118
|
end
|
122
119
|
end
|
@@ -52,7 +52,7 @@ module FHIR
|
|
52
52
|
end
|
53
53
|
|
54
54
|
def to_reference
|
55
|
-
FHIR::Reference.new(reference: "#{self.class.name.
|
55
|
+
FHIR::Reference.new(reference: "#{self.class.name.split('::').last}/#{self.id}")
|
56
56
|
end
|
57
57
|
|
58
58
|
def equals?(other, exclude=[])
|
@@ -185,32 +185,7 @@ module FHIR
|
|
185
185
|
if klassname=='Reference'
|
186
186
|
validation = v.validate(contained_here)
|
187
187
|
errors[field] << validation if !validation.empty?
|
188
|
-
|
189
|
-
matches_one_profile = false
|
190
|
-
meta['type_profiles'].each do |p|
|
191
|
-
basetype = p.split('/').last
|
192
|
-
matches_one_profile = true if v.reference.include?(basetype)
|
193
|
-
# check profiled resources
|
194
|
-
profile_basetype = FHIR::Definitions.get_basetype(p)
|
195
|
-
matches_one_profile = true if profile_basetype && v.reference.include?(profile_basetype)
|
196
|
-
end
|
197
|
-
matches_one_profile = true if meta['type_profiles'].include?('http://hl7.org/fhir/StructureDefinition/Resource')
|
198
|
-
if !matches_one_profile && v.reference.start_with?('#')
|
199
|
-
# we need to look at the local contained resources
|
200
|
-
begin
|
201
|
-
r = contained_here.select{|x|x.id==v.reference[1..-1]}.first
|
202
|
-
rescue
|
203
|
-
FHIR.logger.warn "Unable to resolve reference #{v.reference}"
|
204
|
-
end
|
205
|
-
if !r.nil?
|
206
|
-
meta['type_profiles'].each do |p|
|
207
|
-
p = p.split('/').last
|
208
|
-
matches_one_profile = true if r.resourceType==p
|
209
|
-
end
|
210
|
-
end
|
211
|
-
end
|
212
|
-
errors[field] << "#{meta['path']}: incorrect Reference type, expected #{meta['type_profiles'].map{|x|x.split('/').last}.join('|')}" if !matches_one_profile
|
213
|
-
end
|
188
|
+
validate_reference_type(v, meta, contained_here, errors[field])
|
214
189
|
else
|
215
190
|
errors[field] << "#{meta['path']}: expected Reference, found #{klassname}"
|
216
191
|
end
|
@@ -260,6 +235,33 @@ module FHIR
|
|
260
235
|
errors.delete(field) if errors[field].empty?
|
261
236
|
end
|
262
237
|
|
238
|
+
def validate_reference_type(ref, meta, contained_here, errors)
|
239
|
+
if ref.reference && meta['type_profiles']
|
240
|
+
matches_one_profile = false
|
241
|
+
meta['type_profiles'].each do |p|
|
242
|
+
basetype = p.split('/').last
|
243
|
+
matches_one_profile = true if ref.reference.include?(basetype)
|
244
|
+
# check profiled resources
|
245
|
+
profile_basetype = FHIR::Definitions.get_basetype(p)
|
246
|
+
matches_one_profile = true if profile_basetype && ref.reference.include?(profile_basetype)
|
247
|
+
end
|
248
|
+
matches_one_profile = true if meta['type_profiles'].include?('http://hl7.org/fhir/StructureDefinition/Resource')
|
249
|
+
if !matches_one_profile && ref.reference.start_with?('#')
|
250
|
+
# we need to look at the local contained resources
|
251
|
+
r = contained_here.find{|x|x.id==ref.reference[1..-1]}
|
252
|
+
if !r.nil?
|
253
|
+
meta['type_profiles'].each do |p|
|
254
|
+
p = p.split('/').last
|
255
|
+
matches_one_profile = true if r.resourceType==p
|
256
|
+
end
|
257
|
+
else
|
258
|
+
FHIR.logger.warn "Unable to resolve reference #{ref.reference}"
|
259
|
+
end
|
260
|
+
end
|
261
|
+
errors << "#{meta['path']}: incorrect Reference type, expected #{meta['type_profiles'].map{|x|x.split('/').last}.join('|')}" if !matches_one_profile
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
263
265
|
def is_primitive?(datatype, value)
|
264
266
|
# Remaining data types: handle special cases before checking type StructureDefinitions
|
265
267
|
case datatype.downcase
|
@@ -299,16 +301,16 @@ module FHIR
|
|
299
301
|
json_or_xml = value.downcase.include?('xml') || value.downcase.include?('json')
|
300
302
|
known_weird = ['application/cql+text'].include?(value)
|
301
303
|
valid = json_or_xml || known_weird || (!matches.nil? && !matches.empty?)
|
302
|
-
elsif uri=='http://tools.ietf.org/html/bcp47'
|
303
|
-
|
304
|
-
valid = !BCP47::Language.identify(value.downcase).nil? && (!
|
304
|
+
elsif uri=='http://hl7.org/fhir/ValueSet/languages' || uri=='http://tools.ietf.org/html/bcp47'
|
305
|
+
has_region = (!(value =~ /-/).nil?)
|
306
|
+
valid = !BCP47::Language.identify(value.downcase).nil? && (!has_region || !BCP47::Region.identify(value.upcase).nil?)
|
305
307
|
else
|
306
308
|
FHIR.logger.warn "Unable to check_binding on unknown ValueSet: #{uri}"
|
307
309
|
end
|
308
310
|
valid
|
309
311
|
end
|
310
312
|
|
311
|
-
private :is_primitive?, :check_binding, :validate_field
|
313
|
+
private :validate_reference_type, :is_primitive?, :check_binding, :validate_field
|
312
314
|
|
313
315
|
end
|
314
316
|
end
|
@@ -412,10 +412,10 @@ module FHIR
|
|
412
412
|
end
|
413
413
|
|
414
414
|
resource_type = json['resourceType']
|
415
|
-
|
415
|
+
base_type = snapshot.element[0].path
|
416
416
|
snapshot.element.each do |element|
|
417
417
|
path = element.path
|
418
|
-
path = path[(
|
418
|
+
path = path[(base_type.size+1)..-1] if path.start_with? base_type
|
419
419
|
|
420
420
|
nodes = get_json_nodes(json, path)
|
421
421
|
|
@@ -546,18 +546,18 @@ module FHIR
|
|
546
546
|
if FHIR::RESOURCES.include?(data_type_code)
|
547
547
|
definition = FHIR::Definitions.get_resource_definition(data_type_code)
|
548
548
|
if !definition.nil?
|
549
|
-
|
549
|
+
ret_val = false
|
550
550
|
begin
|
551
551
|
klass = Module.const_get("FHIR::#{data_type_code}")
|
552
|
-
|
553
|
-
if !
|
552
|
+
ret_val = definition.validates_resource?(klass.new(deep_copy(value)))
|
553
|
+
if !ret_val
|
554
554
|
@errors += definition.errors
|
555
555
|
@warnings += definition.warnings
|
556
556
|
end
|
557
557
|
rescue
|
558
558
|
@errors << "Unable to verify #{data_type_code} as a FHIR Resource."
|
559
559
|
end
|
560
|
-
return
|
560
|
+
return ret_val
|
561
561
|
end
|
562
562
|
end
|
563
563
|
|
@@ -615,18 +615,18 @@ module FHIR
|
|
615
615
|
resource_type = value['resourceType']
|
616
616
|
definition = FHIR::Definitions.get_resource_definition(resource_type)
|
617
617
|
if !definition.nil?
|
618
|
-
|
618
|
+
ret_val = false
|
619
619
|
begin
|
620
620
|
klass = Module.const_get("FHIR::#{resource_type}")
|
621
|
-
|
622
|
-
if !
|
621
|
+
ret_val = definition.validates_resource?(klass.new(deep_copy(value)))
|
622
|
+
if !ret_val
|
623
623
|
@errors += definition.errors
|
624
624
|
@warnings += definition.warnings
|
625
625
|
end
|
626
626
|
rescue
|
627
627
|
@errors << "Unable to verify #{resource_type} as a FHIR Resource."
|
628
628
|
end
|
629
|
-
|
629
|
+
ret_val
|
630
630
|
else
|
631
631
|
@errors << "Unable to find base Resource definition: #{resource_type}"
|
632
632
|
false
|
@@ -638,18 +638,18 @@ module FHIR
|
|
638
638
|
definition = FHIR::Definitions.get_type_definition(data_type_code)
|
639
639
|
definition = FHIR::Definitions.get_resource_definition(data_type_code) if definition.nil?
|
640
640
|
if !definition.nil?
|
641
|
-
|
641
|
+
ret_val = false
|
642
642
|
begin
|
643
643
|
klass = Module.const_get("FHIR::#{data_type_code}")
|
644
|
-
|
645
|
-
if !
|
644
|
+
ret_val = definition.validates_resource?(klass.new(deep_copy(value)))
|
645
|
+
if !ret_val
|
646
646
|
@errors += definition.errors
|
647
647
|
@warnings += definition.warnings
|
648
648
|
end
|
649
649
|
rescue
|
650
650
|
@errors << "Unable to verify #{data_type_code} as a FHIR type."
|
651
651
|
end
|
652
|
-
|
652
|
+
ret_val
|
653
653
|
else
|
654
654
|
@errors << "Unable to find base type definition: #{data_type_code}"
|
655
655
|
false
|
@@ -659,26 +659,26 @@ module FHIR
|
|
659
659
|
|
660
660
|
def check_binding(element, value)
|
661
661
|
|
662
|
-
|
663
|
-
valueset = FHIR::Definitions.get_codes(
|
662
|
+
vs_uri = element.binding.valueSetUri || element.binding.valueSetReference.reference
|
663
|
+
valueset = FHIR::Definitions.get_codes(vs_uri)
|
664
664
|
|
665
665
|
matching_type = 0
|
666
666
|
|
667
|
-
if
|
667
|
+
if vs_uri=='http://hl7.org/fhir/ValueSet/content-type' || vs_uri=='http://www.rfc-editor.org/bcp/bcp13.txt'
|
668
668
|
matches = MIME::Types[value]
|
669
669
|
if (matches.nil? || matches.size==0) && !is_some_type_of_xml_or_json(value)
|
670
670
|
@errors << "#{element.path} has invalid mime-type: '#{value}'"
|
671
671
|
matching_type-=1 if element.binding.strength=='required'
|
672
672
|
end
|
673
|
-
elsif
|
674
|
-
|
675
|
-
valid = !BCP47::Language.identify(value.downcase).nil? && (!
|
673
|
+
elsif vs_uri=='http://hl7.org/fhir/ValueSet/languages' || vs_uri=='http://tools.ietf.org/html/bcp47'
|
674
|
+
has_region = (!(value =~ /-/).nil?)
|
675
|
+
valid = !BCP47::Language.identify(value.downcase).nil? && (!has_region || !BCP47::Region.identify(value.upcase).nil?)
|
676
676
|
if !valid
|
677
677
|
@errors << "#{element.path} has unrecognized language: '#{value}'"
|
678
678
|
matching_type-=1 if element.binding.strength=='required'
|
679
679
|
end
|
680
680
|
elsif valueset.nil?
|
681
|
-
@warnings << "#{element.path} has unknown ValueSet: '#{
|
681
|
+
@warnings << "#{element.path} has unknown ValueSet: '#{vs_uri}'"
|
682
682
|
matching_type-=1 if element.binding.strength=='required'
|
683
683
|
elsif !valueset.values.flatten.include?(value)
|
684
684
|
message = "#{element.path} has invalid code '#{value}' from #{valueset}"
|
data/lib/fhir_models/fhir_ext/{StructureDefinitionFinding.rb → structure_definition_finding.rb}
RENAMED
@@ -42,25 +42,25 @@ module FHIR
|
|
42
42
|
from_json(to_json)
|
43
43
|
end
|
44
44
|
|
45
|
-
def warning(path, attribute, message,
|
45
|
+
def warning(path, attribute, message, value_a, value_b)
|
46
46
|
obj = clone
|
47
47
|
obj.status = 'WARNING'
|
48
48
|
obj.path = path
|
49
49
|
obj.attribute = attribute
|
50
50
|
obj.message = message
|
51
|
-
obj.valueA =
|
52
|
-
obj.valueB =
|
51
|
+
obj.valueA = value_a
|
52
|
+
obj.valueB = value_b
|
53
53
|
obj
|
54
54
|
end
|
55
55
|
|
56
|
-
def error(path, attribute, message,
|
56
|
+
def error(path, attribute, message, value_a, value_b)
|
57
57
|
obj = clone
|
58
58
|
obj.status = 'ERROR'
|
59
59
|
obj.path = path
|
60
60
|
obj.attribute = attribute
|
61
61
|
obj.message = message
|
62
|
-
obj.valueA =
|
63
|
-
obj.valueB =
|
62
|
+
obj.valueA = value_a
|
63
|
+
obj.valueB = value_b
|
64
64
|
obj
|
65
65
|
end
|
66
66
|
|
@@ -64,6 +64,10 @@ module FluentPath
|
|
64
64
|
return true
|
65
65
|
end
|
66
66
|
|
67
|
+
def self.clean_index(tree, index)
|
68
|
+
tree[index] = nil if !index.nil?
|
69
|
+
end
|
70
|
+
|
67
71
|
# evaluate a parsed expression given some context data
|
68
72
|
def self.compute(tree, data)
|
69
73
|
tree = tree.tree if tree.is_a?(FluentPath::Expression)
|
@@ -104,7 +108,7 @@ module FluentPath
|
|
104
108
|
end
|
105
109
|
if previous_node.is_a?(Hash) || previous_node.is_a?(Array)
|
106
110
|
tree[index] = get(node, previous_node)
|
107
|
-
tree
|
111
|
+
clean_index(tree, previous_index)
|
108
112
|
elsif !previous_node.is_a?(FluentPath::Expression)
|
109
113
|
tree[index] = get(node, data)
|
110
114
|
end
|
@@ -131,16 +135,15 @@ module FluentPath
|
|
131
135
|
convert_to_boolean(sub)
|
132
136
|
end
|
133
137
|
tree[index] = previous_node
|
134
|
-
tree
|
138
|
+
clean_index(tree, previous_index)
|
135
139
|
elsif previous_node.is_a?(Hash)
|
136
140
|
sub = compute(block, previous_node)
|
137
141
|
if convert_to_boolean(sub)
|
138
142
|
tree[index] = previous_node
|
139
|
-
tree
|
143
|
+
clean_index(tree, previous_index)
|
140
144
|
else
|
141
145
|
tree[index] = {}
|
142
|
-
tree
|
143
|
-
|
146
|
+
clean_index(tree, previous_index)
|
144
147
|
end
|
145
148
|
else
|
146
149
|
raise "Where function not applicable to #{previous_node.class}: #{previous_node}"
|
@@ -162,10 +165,10 @@ module FluentPath
|
|
162
165
|
compute(block.clone, item)
|
163
166
|
end
|
164
167
|
tree[index] = previous_node
|
165
|
-
tree
|
168
|
+
clean_index(tree, previous_index)
|
166
169
|
elsif previous_node.is_a?(Hash)
|
167
170
|
tree[index] = compute(block, previous_node)
|
168
|
-
tree
|
171
|
+
clean_index(tree, previous_index)
|
169
172
|
else
|
170
173
|
raise "Select function not applicable to #{previous_node.class}: #{previous_node}"
|
171
174
|
end
|
@@ -191,7 +194,7 @@ module FluentPath
|
|
191
194
|
end
|
192
195
|
ext = exts.select{|x|x['url']==url}.first
|
193
196
|
tree[index] = ext
|
194
|
-
tree
|
197
|
+
clean_index(tree, previous_index)
|
195
198
|
else
|
196
199
|
raise "Extension function not applicable to #{exts.class}: #{exts}"
|
197
200
|
end
|
@@ -204,7 +207,7 @@ module FluentPath
|
|
204
207
|
# otherwise, use the context as data
|
205
208
|
if previous_node.is_a?(Hash)
|
206
209
|
tree[index] = previous_node.values
|
207
|
-
tree
|
210
|
+
clean_index(tree, previous_index)
|
208
211
|
substitutions+=1
|
209
212
|
elsif data.is_a?(Hash)
|
210
213
|
tree[index] = data.values
|
@@ -217,7 +220,7 @@ module FluentPath
|
|
217
220
|
# the previous node should be an Array of length > 1
|
218
221
|
if previous_node.is_a?(Array)
|
219
222
|
tree[index] = previous_node.first
|
220
|
-
tree
|
223
|
+
clean_index(tree, previous_index)
|
221
224
|
else
|
222
225
|
raise "First function is not applicable to #{previous_node.class}: #{previous_node}"
|
223
226
|
end
|
@@ -225,7 +228,7 @@ module FluentPath
|
|
225
228
|
# the previous node should be an Array of length > 1
|
226
229
|
if previous_node.is_a?(Array)
|
227
230
|
tree[index] = previous_node.last
|
228
|
-
tree
|
231
|
+
clean_index(tree, previous_index)
|
229
232
|
else
|
230
233
|
raise "Last function is not applicable to #{previous_node.class}: #{previous_node}"
|
231
234
|
end
|
@@ -233,7 +236,7 @@ module FluentPath
|
|
233
236
|
# the previous node should be an Array of length > 1
|
234
237
|
if previous_node.is_a?(Array)
|
235
238
|
tree[index] = previous_node.last(previous_node.length-1)
|
236
|
-
tree
|
239
|
+
clean_index(tree, previous_index)
|
237
240
|
else
|
238
241
|
raise "Tail function is not applicable to #{previous_node.class}: #{previous_node}"
|
239
242
|
end
|
@@ -268,28 +271,28 @@ module FluentPath
|
|
268
271
|
result = true
|
269
272
|
previous_node.each{|item| result = (result && convert_to_boolean(item))}
|
270
273
|
tree[index] = result
|
271
|
-
tree
|
274
|
+
clean_index(tree, previous_index)
|
272
275
|
else
|
273
276
|
tree[index] = convert_to_boolean(previous_node)
|
274
|
-
tree
|
277
|
+
clean_index(tree, previous_index)
|
275
278
|
end
|
276
279
|
when :not
|
277
280
|
tree[index] = !convert_to_boolean(previous_node)
|
278
|
-
tree
|
281
|
+
clean_index(tree, previous_index)
|
279
282
|
when :count
|
280
283
|
tree[index] = 0
|
281
284
|
tree[index] = 1 if !previous_node.nil?
|
282
285
|
tree[index] = previous_node.length if previous_node.is_a?(Array)
|
283
|
-
tree
|
286
|
+
clean_index(tree, previous_index)
|
284
287
|
when :empty
|
285
288
|
tree[index] = (previous_node==:null || previous_node.empty? rescue previous_node.nil?)
|
286
|
-
tree
|
289
|
+
clean_index(tree, previous_index)
|
287
290
|
when :exists
|
288
291
|
tree[index] = !previous_node.nil? && previous_node!=:null
|
289
|
-
tree
|
292
|
+
clean_index(tree, previous_index)
|
290
293
|
when :distinct
|
291
294
|
tree[index] = (previous_node.uniq rescue previous_node)
|
292
|
-
tree
|
295
|
+
clean_index(tree, previous_index)
|
293
296
|
when :startsWith
|
294
297
|
# the previous node should be a data (as String)
|
295
298
|
# the next node should be a block or subexpression (as FluentPath::Expression)
|
@@ -303,7 +306,7 @@ module FluentPath
|
|
303
306
|
FHIR.logger.debug 'Evaling StartsWith Block....'
|
304
307
|
prefix = compute(block, data)
|
305
308
|
tree[index] = previous_node.start_with?(prefix) rescue false
|
306
|
-
tree
|
309
|
+
clean_index(tree, previous_index)
|
307
310
|
else
|
308
311
|
raise "StartsWith function not applicable to #{previous_node.class}: #{previous_node}"
|
309
312
|
end
|
@@ -331,7 +334,7 @@ module FluentPath
|
|
331
334
|
length = previous_node.length - start
|
332
335
|
end
|
333
336
|
tree[index] = previous_node[start..(start+length)]
|
334
|
-
tree
|
337
|
+
clean_index(tree, previous_index)
|
335
338
|
else
|
336
339
|
raise "Substring function not applicable to #{previous_node.class}: #{previous_node}"
|
337
340
|
end
|
@@ -349,7 +352,7 @@ module FluentPath
|
|
349
352
|
FHIR.logger.debug 'Evaling Contains Block....'
|
350
353
|
substring = compute(block, data)
|
351
354
|
tree[index] = previous_node.include?(substring) rescue false
|
352
|
-
tree
|
355
|
+
clean_index(tree, previous_index)
|
353
356
|
else
|
354
357
|
raise "Contains function not applicable to #{previous_node.class}: #{previous_node}"
|
355
358
|
end
|
@@ -370,7 +373,7 @@ module FluentPath
|
|
370
373
|
end
|
371
374
|
if previous_node.is_a?(String) || previous_node==true || previous_node==false || previous_node.is_a?(Numeric)
|
372
375
|
tree[index] = array.include?(previous_node) rescue false
|
373
|
-
tree
|
376
|
+
clean_index(tree, previous_index)
|
374
377
|
else
|
375
378
|
raise "In function not applicable to #{previous_node.class}: #{previous_node}"
|
376
379
|
end
|
@@ -385,7 +388,7 @@ module FluentPath
|
|
385
388
|
tree[index] = 0
|
386
389
|
tree[index] = 1 if convert_to_boolean(previous_node)
|
387
390
|
end
|
388
|
-
tree
|
391
|
+
clean_index(tree, previous_index)
|
389
392
|
break
|
390
393
|
else
|
391
394
|
raise "Function not implemented: #{node}"
|
@@ -100,8 +100,8 @@ namespace :fhir do
|
|
100
100
|
d = FHIR::Definitions
|
101
101
|
defs = d.get_complex_types + d.get_resource_definitions
|
102
102
|
invariants = {}
|
103
|
-
defs.each do |
|
104
|
-
|
103
|
+
defs.each do |structure_definition|
|
104
|
+
structure_definition['snapshot']['element'].each do |element|
|
105
105
|
if element['constraint']
|
106
106
|
element['constraint'].each do |constraint|
|
107
107
|
if constraint['expression']
|
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: 1.6.
|
4
|
+
version: 1.6.6
|
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: 2016-10-
|
13
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: nokogiri
|
@@ -1293,8 +1293,8 @@ files:
|
|
1293
1293
|
- lib/fhir_models/fhir/types/Timing.rb
|
1294
1294
|
- lib/fhir_models/fhir/types/TriggerDefinition.rb
|
1295
1295
|
- lib/fhir_models/fhir/types/UsageContext.rb
|
1296
|
-
- lib/fhir_models/fhir_ext/
|
1297
|
-
- lib/fhir_models/fhir_ext/
|
1296
|
+
- lib/fhir_models/fhir_ext/structure_definition.rb
|
1297
|
+
- lib/fhir_models/fhir_ext/structure_definition_finding.rb
|
1298
1298
|
- lib/fhir_models/fluentpath/evaluate.rb
|
1299
1299
|
- lib/fhir_models/fluentpath/expression.rb
|
1300
1300
|
- lib/fhir_models/fluentpath/parse.rb
|