openehr 2.4.2 → 2.5.0
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/README.rdoc +1 -1
- data/lib/openehr/am/archetype/constraint_model.rb +11 -0
- data/lib/openehr/aql/engine/contains_resolver.rb +16 -1
- data/lib/openehr/aql/engine/path_evaluator.rb +16 -2
- data/lib/openehr/aql/model/predicate.rb +8 -0
- data/lib/openehr/parser/adl_grammar.tt +7 -1
- data/lib/openehr/parser/adl_helper.rb +1 -1
- data/lib/openehr/parser/opt_parser.rb +44 -1
- data/lib/openehr/parser/xml_constraint_parsing.rb +7 -1
- data/lib/openehr/serializer/rm_json_serializer.rb +6 -0
- data/lib/openehr/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: 1182edb39c044e8dff2459c540f9216e511b7f404008498aab658a4a1e37999f
|
|
4
|
+
data.tar.gz: 9d7c892108c4de275b8c6beaf6699ddbe5be1bb4d3c3fc7315fb67ed4fd271fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8477cd032861a008bba3f3fc3ecdf18516235c64c634cb845c598c29875f6ee4b2feb24b96599f2c1d5a0d0d52b0c6bc7e18faf22adf97836ace83375ba8c3df
|
|
7
|
+
data.tar.gz: 68f7cdf8a37e7707934a438b1e231d6894c64e63daf069e35a288dff0c76719058798277210cbfed31493456f03e3586678a83cf65cbc87187407d85342eb743
|
data/README.rdoc
CHANGED
|
@@ -8,7 +8,7 @@ A Ruby implementation of the openEHR specifications
|
|
|
8
8
|
= Requirements
|
|
9
9
|
|
|
10
10
|
* Supports the Ruby versions currently maintained upstream by Ruby core: 3.3, 3.4, and 4.0.
|
|
11
|
-
* Developed with CRuby 4.0.
|
|
11
|
+
* Developed with CRuby 4.0.7 on Linux; CI covers 3.3, 3.4, and 4.0.
|
|
12
12
|
* Other versions, including 3.1 and 3.2, are not supported (both reached EOL).
|
|
13
13
|
|
|
14
14
|
=Description
|
|
@@ -487,11 +487,22 @@ module OpenEHR
|
|
|
487
487
|
|
|
488
488
|
class CArchetypeRoot <CComplexObject
|
|
489
489
|
attr_reader :slot_node_id, :archetype_id
|
|
490
|
+
# The terms and external bindings this one root carries in an
|
|
491
|
+
# operational template. An OPT repeats them under every
|
|
492
|
+
# C_ARCHETYPE_ROOT, and a template may rename them per root, so
|
|
493
|
+
# they differ between two roots that embed the same archetype.
|
|
494
|
+
# term_definitions: { language => { code => ArchetypeTerm } }
|
|
495
|
+
# term_bindings: { terminology => { code => [CodePhrase] } }
|
|
496
|
+
# Both are nil when not populated (e.g. a root not built by
|
|
497
|
+
# OPTParser, or a root without term_bindings).
|
|
498
|
+
attr_accessor :term_definitions, :term_bindings
|
|
490
499
|
|
|
491
500
|
def initialize(args = {})
|
|
492
501
|
super
|
|
493
502
|
self.slot_node_id = args[:slot_node_id]
|
|
494
503
|
self.archetype_id = args[:archetype_id]
|
|
504
|
+
self.term_definitions = args[:term_definitions]
|
|
505
|
+
self.term_bindings = args[:term_bindings]
|
|
495
506
|
end
|
|
496
507
|
|
|
497
508
|
def slot_node_id=(slot_node_id)
|
|
@@ -148,7 +148,7 @@ module OpenEHR
|
|
|
148
148
|
when nil
|
|
149
149
|
true
|
|
150
150
|
when Model::ArchetypePredicate
|
|
151
|
-
|
|
151
|
+
archetype_predicate_matches?(candidate, predicate)
|
|
152
152
|
when Model::NodePredicate
|
|
153
153
|
node_predicate_matches?(candidate, predicate)
|
|
154
154
|
when Model::StandardPredicate
|
|
@@ -162,6 +162,21 @@ module OpenEHR
|
|
|
162
162
|
end
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
+
# archetypePredicate "[archetype_id]" matches by archetype_node_id
|
|
166
|
+
# alone; "[archetype_id, 'Name']" additionally requires the node's
|
|
167
|
+
# own `name` DV_TEXT to equal the given display name - the same
|
|
168
|
+
# rule as a nodePredicate's name value (issue #60).
|
|
169
|
+
def archetype_predicate_matches?(candidate, predicate)
|
|
170
|
+
return false unless candidate.respond_to?(:archetype_node_id) && candidate.archetype_node_id == predicate.archetype_id
|
|
171
|
+
return true unless predicate.value
|
|
172
|
+
|
|
173
|
+
unless predicate.value.is_a?(String)
|
|
174
|
+
raise ExecutionError, "cannot evaluate a #{predicate.value.class} archetype predicate value yet"
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
node_name_matches?(candidate, predicate.value)
|
|
178
|
+
end
|
|
179
|
+
|
|
165
180
|
# nodePredicate "[atNNNN]" matches by archetype_node_id alone;
|
|
166
181
|
# "[atNNNN, 'Name']" additionally requires the node's own `name`
|
|
167
182
|
# DV_TEXT to equal the given display name.
|
|
@@ -20,7 +20,7 @@ module OpenEHR
|
|
|
20
20
|
# Attribute hops not reachable through the path_attribute DSL.
|
|
21
21
|
# Expand only when a real query needs another one - see the
|
|
22
22
|
# project's "no arbitrary send" rule in the class comment above.
|
|
23
|
-
ALLOWED_TERMINAL_HOPS = %w[magnitude name value].freeze
|
|
23
|
+
ALLOWED_TERMINAL_HOPS = %w[code_string defining_code magnitude name time value].freeze
|
|
24
24
|
|
|
25
25
|
# Dataset::EHRRecord#ehr_id is already an unwrapped String (see
|
|
26
26
|
# Dataset's own header comment), but AQL's "e/ehr_id/value" syntax
|
|
@@ -115,7 +115,7 @@ module OpenEHR
|
|
|
115
115
|
def predicate_path_text(predicate)
|
|
116
116
|
case predicate
|
|
117
117
|
when Model::ArchetypePredicate
|
|
118
|
-
predicate
|
|
118
|
+
archetype_predicate_path_text(predicate)
|
|
119
119
|
when Model::NodePredicate
|
|
120
120
|
node_predicate_path_text(predicate)
|
|
121
121
|
else
|
|
@@ -123,6 +123,20 @@ module OpenEHR
|
|
|
123
123
|
end
|
|
124
124
|
end
|
|
125
125
|
|
|
126
|
+
# "[archetype_id, 'Name']" carries its name value into the PATHABLE
|
|
127
|
+
# path text the same way a node predicate does, so
|
|
128
|
+
# Pathable.select_by_predicate can tell apart siblings that share
|
|
129
|
+
# one archetype id (issue #60).
|
|
130
|
+
def archetype_predicate_path_text(predicate)
|
|
131
|
+
return predicate.archetype_id unless predicate.value
|
|
132
|
+
|
|
133
|
+
unless predicate.value.is_a?(String)
|
|
134
|
+
raise ExecutionError, "cannot evaluate a #{predicate.value.class} archetype predicate value yet"
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
"#{predicate.archetype_id}, '#{predicate.value}'"
|
|
138
|
+
end
|
|
139
|
+
|
|
126
140
|
def node_predicate_path_text(predicate)
|
|
127
141
|
return predicate.code unless predicate.value
|
|
128
142
|
|
|
@@ -29,6 +29,14 @@ module OpenEHR
|
|
|
29
29
|
@value = value
|
|
30
30
|
freeze
|
|
31
31
|
end
|
|
32
|
+
|
|
33
|
+
# Query-text form, used in error messages that quote a path
|
|
34
|
+
# segment (see PathPart#to_s).
|
|
35
|
+
def to_s
|
|
36
|
+
return archetype_id if value.nil?
|
|
37
|
+
|
|
38
|
+
value.is_a?(String) ? "#{archetype_id}, '#{value}'" : "#{archetype_id}, $#{value.name}"
|
|
39
|
+
end
|
|
32
40
|
end
|
|
33
41
|
|
|
34
42
|
# nodePredicate : (ID_CODE | AT_CODE) (SYM_COMMA (STRING | PARAMETER | TERM_CODE | AT_CODE | ID_CODE))? | ... ;
|
|
@@ -449,6 +449,12 @@ module OpenEHR
|
|
|
449
449
|
OpenEHR::AM::Archetype::ConstraintModel::ArchetypeSlot.new(args)
|
|
450
450
|
end
|
|
451
451
|
}
|
|
452
|
+
/ c_archetype_slot_head SYM_MATCHES SYM_START_CBLOCK SYM_END_CBLOCK space {
|
|
453
|
+
# empty slot block (neither include nor exclude): any archetype allowed (#51)
|
|
454
|
+
def value(node)
|
|
455
|
+
OpenEHR::AM::Archetype::ConstraintModel::ArchetypeSlot.new(c_archetype_slot_head.value(node))
|
|
456
|
+
end
|
|
457
|
+
}
|
|
452
458
|
end
|
|
453
459
|
|
|
454
460
|
rule c_archetype_slot_head
|
|
@@ -3225,7 +3231,7 @@ module OpenEHR
|
|
|
3225
3231
|
end
|
|
3226
3232
|
|
|
3227
3233
|
rule V_ARCHETYPE_ID
|
|
3228
|
-
NAMESTR ('-' NAMESTR) 2..2 '.' NAMESTR ('-' NAMESTR)* '.v' [
|
|
3234
|
+
NAMESTR ('-' NAMESTR) 2..2 '.' NAMESTR ('-' NAMESTR)* '.v' [0-9]+ {
|
|
3229
3235
|
def value
|
|
3230
3236
|
text_value
|
|
3231
3237
|
end
|
|
@@ -37,7 +37,7 @@ module OpenEHR
|
|
|
37
37
|
code, details = lang
|
|
38
38
|
td = OpenEHR::RM::Common::Resource::TranslationDetails.new(
|
|
39
39
|
:language => details['language'],
|
|
40
|
-
:author => details['author'],
|
|
40
|
+
:author => details['author'] || { },
|
|
41
41
|
:accreditation => details['accreditation'],
|
|
42
42
|
:other_details => details['other_details'])
|
|
43
43
|
trans.update Hash[code, td]
|
|
@@ -155,7 +155,39 @@ module OpenEHR
|
|
|
155
155
|
ArchetypeTerminology.new(
|
|
156
156
|
concept_code: concept_code,
|
|
157
157
|
original_language: language,
|
|
158
|
-
term_definitions: td
|
|
158
|
+
term_definitions: td,
|
|
159
|
+
term_bindings: opt_term_bindings(nodes))
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# An OPT writes term_bindings as
|
|
163
|
+
# <term_bindings terminology="T"><items code="atNNNN"><value>
|
|
164
|
+
# <terminology_id><value>T</value></terminology_id>
|
|
165
|
+
# <code_string>[T::code]</code_string></value></items></term_bindings>
|
|
166
|
+
# (a serialized CODE_PHRASE per item), not the flat
|
|
167
|
+
# attribute-plus-text shape XMLArchetypeParser#ontology_bindings
|
|
168
|
+
# reads. The result has the same in-memory shape on both paths:
|
|
169
|
+
# { terminology => { code => [CodePhrase] } }. code_string is kept
|
|
170
|
+
# exactly as written. nil (not {}) when the archetype has no
|
|
171
|
+
# term_bindings, so "not populated" stays distinguishable.
|
|
172
|
+
# The method name is deliberately not one openehr-rails'
|
|
173
|
+
# OpenehrRails::Opt::Parser subclass already defines.
|
|
174
|
+
def opt_term_bindings(nodes)
|
|
175
|
+
bindings = nodes.xpath('term_bindings').each_with_object({}) do |binding, by_terminology|
|
|
176
|
+
codes = (by_terminology[binding['terminology']] ||= {})
|
|
177
|
+
binding.xpath('items').each do |item|
|
|
178
|
+
(codes[item['code']] ||= []) << opt_binding_code_phrase(item)
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
bindings.empty? ? nil : bindings
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def opt_binding_code_phrase(item)
|
|
185
|
+
OpenEHR::RM::DataTypes::Text::CodePhrase.new(
|
|
186
|
+
code_string: text_on_path(item, './value/code_string'),
|
|
187
|
+
terminology_id: OpenEHR::RM::Support::Identification::TerminologyID.new(
|
|
188
|
+
value: text_on_path(item, './value/terminology_id/value')
|
|
189
|
+
)
|
|
190
|
+
)
|
|
159
191
|
end
|
|
160
192
|
|
|
161
193
|
def term_definitions(nodes)
|
|
@@ -169,6 +201,17 @@ module OpenEHR
|
|
|
169
201
|
{ language.code_string => term_items }
|
|
170
202
|
end
|
|
171
203
|
|
|
204
|
+
# One C_ARCHETYPE_ROOT's own terms, for CArchetypeRoot#term_definitions:
|
|
205
|
+
# { language => { code => ArchetypeTerm } }. Unlike
|
|
206
|
+
# component_terminologies (keyed by archetype id, last root wins,
|
|
207
|
+
# { language => [ArchetypeTerm] }), this is kept per root, so a
|
|
208
|
+
# template's per-root renames survive (issue #58).
|
|
209
|
+
def opt_root_term_definitions(nodes)
|
|
210
|
+
term_definitions(nodes).transform_values do |terms|
|
|
211
|
+
terms.to_h { |term| [term.code, term] }
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
|
|
172
215
|
def empty_then_nil(val)
|
|
173
216
|
if val.empty?
|
|
174
217
|
return nil
|
|
@@ -21,11 +21,17 @@ module OpenEHR
|
|
|
21
21
|
node.id = id unless id.nil? or id.empty?
|
|
22
22
|
occurrences = occurrences(xml.xpath('./occurrences'))
|
|
23
23
|
archetype_id = OpenEHR::RM::Support::Identification::ArchetypeID.new(value: text_on_path(xml, './archetype_id/value'))
|
|
24
|
+
# The top-level definition's path is "/". An embedded root is
|
|
25
|
+
# addressed by its archetype id, the way RM data paths and AQL
|
|
26
|
+
# address it - its node_id is "at0000" for nearly every embedded
|
|
27
|
+
# archetype, so it cannot tell sibling roots apart (issue #43).
|
|
24
28
|
if node.root? or node.id.nil?
|
|
25
29
|
node.path = "/"
|
|
30
|
+
else
|
|
31
|
+
node.path = "#{node.path}[#{archetype_id.value}]"
|
|
26
32
|
end
|
|
27
33
|
component_terminologies(archetype_id, xml)
|
|
28
|
-
OpenEHR::AM::Archetype::ConstraintModel::CArchetypeRoot.new(rm_type_name: rm_type_name, node_id: node.id, path: node.path, occurrences: occurrences, archetype_id: archetype_id, attributes: attributes(xml.xpath('./attributes'), node))
|
|
34
|
+
OpenEHR::AM::Archetype::ConstraintModel::CArchetypeRoot.new(rm_type_name: rm_type_name, node_id: node.id, path: node.path, occurrences: occurrences, archetype_id: archetype_id, term_definitions: opt_root_term_definitions(xml), term_bindings: opt_term_bindings(xml), attributes: attributes(xml.xpath('./attributes'), node))
|
|
29
35
|
end
|
|
30
36
|
|
|
31
37
|
def c_complex_object(xml, node)
|
|
@@ -36,6 +36,10 @@ module OpenEHR
|
|
|
36
36
|
].freeze
|
|
37
37
|
TERMINOLOGY_ID_IVARS = [:@name, :@version_id].freeze
|
|
38
38
|
IDENTIFIER_IVARS = (ARCHETYPE_ID_IVARS + TERMINOLOGY_ID_IVARS).uniq.freeze
|
|
39
|
+
# CArchetypeRoot only (issue #58): its per-root terminology is
|
|
40
|
+
# scoped per class here, not added to EXCLUDED_IVARS, because
|
|
41
|
+
# ArchetypeOntology legitimately has ivars of the same two names.
|
|
42
|
+
ARCHETYPE_ROOT_IVARS = [:@term_definitions, :@term_bindings].freeze
|
|
39
43
|
|
|
40
44
|
def initialize(rm_instance)
|
|
41
45
|
@rm_instance = rm_instance
|
|
@@ -82,6 +86,8 @@ module OpenEHR
|
|
|
82
86
|
exclusions + ARCHETYPE_ID_IVARS
|
|
83
87
|
when OpenEHR::RM::Support::Identification::TerminologyID
|
|
84
88
|
exclusions + TERMINOLOGY_ID_IVARS
|
|
89
|
+
when OpenEHR::AM::Archetype::ConstraintModel::CArchetypeRoot
|
|
90
|
+
exclusions + ARCHETYPE_ROOT_IVARS
|
|
85
91
|
else
|
|
86
92
|
exclusions
|
|
87
93
|
end
|
data/lib/openehr/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: openehr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.5.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shinji KOBAYASHI
|
|
@@ -253,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
253
253
|
- !ruby/object:Gem::Version
|
|
254
254
|
version: '0'
|
|
255
255
|
requirements: []
|
|
256
|
-
rubygems_version: 4.0.
|
|
256
|
+
rubygems_version: 4.0.20
|
|
257
257
|
specification_version: 4
|
|
258
258
|
summary: Ruby implementation of the openEHR specification
|
|
259
259
|
test_files: []
|