openehr 2.4.0 → 2.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d4cd8f720ac22f26e89145ebfd23cb474b2ad3e900c97fd6ff01c20a90bf638
4
- data.tar.gz: ac478e309b65a00d314d3bf425b8d3ce25a7f07dd196e76c223508eca7410619
3
+ metadata.gz: 836651a22b98dce0fc91c853b66dbeff914d71edf989c3423cf30f8280f95a8a
4
+ data.tar.gz: 5ac2010eb5569ce720d6117822e82dc8edff381cf0d2dd0a61f7dfcb86b92a61
5
5
  SHA512:
6
- metadata.gz: 4f72f3492c23d458ed840da441359318e03a58c4bc55ee2d35df060ff635f4ab98e9be5aafafd126d149d81dcc355620a5931f65b05ff6d9dee65666df371a62
7
- data.tar.gz: d4ca02374caaf65f3d6a29087fa788f4a6c57c9415d5c5ac576f9e746d56f4a6d25c4ef95fa3b2b56d905823f2ff7c08cb6bdb2f2f92944ab04d3b4f0734b97a
6
+ metadata.gz: 371bbfaef6c80ba39391305194d8fa6d056a2e416876b9cb4f190f51c984084d3653972fe4a53abaedac0bff4b13d83ca3c648facb264fc91a956c10bd9a4aab
7
+ data.tar.gz: 39be96359d230f4f007400c50a7f775a7e113b1e8a072a647858729de8fd2969acb5f61acce3642cbead966b255d3ac7c43381e38af62d8aea1ececf7dd6c154
@@ -11,11 +11,12 @@ module OpenEHR
11
11
  class ParseError < Error
12
12
  attr_reader :line, :column
13
13
 
14
- def initialize(message, line: nil, column: nil)
14
+ def initialize(message, line: nil, column: nil, hint: nil)
15
15
  @line = line
16
16
  @column = column
17
17
  location = line && column ? " (line #{line}, column #{column})" : ''
18
- super("#{message}#{location}")
18
+ hint_text = hint ? "\nnote: #{hint}" : ''
19
+ super("#{message}#{location}#{hint_text}")
19
20
  end
20
21
  end
21
22
 
@@ -48,6 +48,7 @@ module OpenEHR
48
48
  top = check(:top) ? parse_top : nil
49
49
  columns = [parse_select_expr]
50
50
  columns << parse_select_expr while match(:comma)
51
+ @select_aliases = columns.filter_map(&:alias_name).to_set
51
52
  Model::SelectClause.new(columns: columns, distinct: distinct, top: top)
52
53
  end
53
54
 
@@ -298,7 +299,11 @@ module OpenEHR
298
299
  elsif match(:matches)
299
300
  Model::MatchesExpr.new(path: path, operand: parse_matches_operand)
300
301
  else
301
- raise error("expected a comparison operator, LIKE or MATCHES, got #{describe(peek)}")
302
+ identifier = peek.type == :identifier ? peek.value : nil
303
+ hint = if identifier && @select_aliases.include?(identifier)
304
+ "'#{identifier}' is a SELECT alias; aliases cannot be used in WHERE -- repeat the identified path"
305
+ end
306
+ raise error("expected a comparison operator, LIKE or MATCHES, got #{describe(peek)}", hint: hint)
302
307
  end
303
308
  end
304
309
 
@@ -476,8 +481,8 @@ module OpenEHR
476
481
  token.type == :eof ? 'end of input' : "#{token.type} #{token.value.inspect}"
477
482
  end
478
483
 
479
- def error(message)
480
- ParseError.new(message, line: peek.line, column: peek.column)
484
+ def error(message, hint: nil)
485
+ ParseError.new(message, line: peek.line, column: peek.column, hint: hint)
481
486
  end
482
487
  end
483
488
  end
@@ -69,6 +69,7 @@ module OpenEHR
69
69
 
70
70
  def value=(value)
71
71
  if /\A([a-zA-Z]\w+)-([a-zA-Z]\w+)-([a-zA-Z]\w+)\.([a-zA-Z]\w+)(-([a-zA-Z]\w+))?\.(v\d+)\z/ =~ value
72
+ @value = value
72
73
  self.rm_originator = $1
73
74
  self.rm_name = $2
74
75
  self.rm_entity = $3
@@ -171,6 +172,7 @@ module OpenEHR
171
172
 
172
173
  def value=(value)
173
174
  raise ArgumentError, "value not valid" if value.nil? or value.empty?
175
+ @value = value
174
176
  if /(.*)\((.*)\)/ =~ value
175
177
  self.name = $1
176
178
  self.version_id = $2
@@ -24,9 +24,19 @@ module OpenEHR
24
24
  :@hour, :@minute, :@second, :@fractional_second, # DvTime, DvDateTime
25
25
  :@timezone, # DvTime (String), DvDateTime (Timezone)
26
26
  :@root, :@extension, # UIDBasedID, HierObjectID, ObjectVersionID
27
- :@oid, :@creating_system_id, :@version_tree_id # ObjectVersionID
27
+ :@oid, :@creating_system_id, :@version_tree_id, # ObjectVersionID
28
+ :@rm_originator, :@rm_name, :@rm_entity, # ArchetypeID
29
+ :@concept_name, :@specialisation, :@version_id, # ArchetypeID, TerminologyID
30
+ :@name # TerminologyID
28
31
  ].freeze
29
32
 
33
+ ARCHETYPE_ID_IVARS = [
34
+ :@rm_originator, :@rm_name, :@rm_entity,
35
+ :@concept_name, :@specialisation, :@version_id
36
+ ].freeze
37
+ TERMINOLOGY_ID_IVARS = [:@name, :@version_id].freeze
38
+ IDENTIFIER_IVARS = (ARCHETYPE_ID_IVARS + TERMINOLOGY_ID_IVARS).uniq.freeze
39
+
30
40
  def initialize(rm_instance)
31
41
  @rm_instance = rm_instance
32
42
  end
@@ -55,14 +65,27 @@ module OpenEHR
55
65
 
56
66
  seen << value
57
67
  hash = {'_type' => OpenEHR::RM.type_name_of(value)}
58
- (value.instance_variables - EXCLUDED_IVARS).each do |ivar|
68
+ (value.instance_variables - excluded_ivars(value)).each do |ivar|
59
69
  field = value.instance_variable_get(ivar)
60
70
  next if field.nil?
61
71
 
62
72
  hash[ivar.to_s.delete_prefix('@')] = to_value(field, seen)
63
73
  end
74
+ seen.delete(value)
64
75
  hash
65
76
  end
77
+
78
+ def excluded_ivars(value)
79
+ exclusions = EXCLUDED_IVARS - IDENTIFIER_IVARS
80
+ case value
81
+ when OpenEHR::RM::Support::Identification::ArchetypeID
82
+ exclusions + ARCHETYPE_ID_IVARS
83
+ when OpenEHR::RM::Support::Identification::TerminologyID
84
+ exclusions + TERMINOLOGY_ID_IVARS
85
+ else
86
+ exclusions
87
+ end
88
+ end
66
89
  end
67
90
 
68
91
  # RMJSONSerializer's reflection walker has no RM-specific logic
@@ -1,3 +1,3 @@
1
1
  module OpenEHR
2
- VERSION = "2.4.0"
2
+ VERSION = "2.4.2"
3
3
  end
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.0
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinji KOBAYASHI