openehr 2.0.0 → 2.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/README.rdoc +3 -3
- data/lib/openehr/parser/adl_grammar.tt +0 -4
- data/lib/openehr/parser/adl_parser.rb +0 -1
- data/lib/openehr/rm/data_types/quantity/date_time.rb +3 -3
- data/lib/openehr/rm/data_types/text.rb +1 -1
- data/lib/openehr/rm/factory.rb +59 -6
- data/lib/openehr/serializer/adl_serializer.rb +1 -1
- 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: 3ee9bac169579e3747a7620ea835317f3c58c6eef05782d7ec3631c324bb4128
|
|
4
|
+
data.tar.gz: 51db4fef2f14ea1de6a472e2c3a876e4c48670d1a57c9385874c9ecd8623b8a6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dadd78aeb5e2ddbcaf042468ad6f25ac48e50887f78d9abe6513f2574d017451418fc43607529861fcc0f29a9fd0ba033ec7bfc9cac72ed3305b1c62683ec51d
|
|
7
|
+
data.tar.gz: b25f5f631f71b01d3de6941ec1bd8261c40a14366ac7f0ef43e333a41039a7b53e7a2d1172dc04093a4630ea38644089df1e433c16caa31aae82c3107d9ca888
|
data/README.rdoc
CHANGED
|
@@ -7,9 +7,9 @@ A Ruby implementation of the openEHR specifications
|
|
|
7
7
|
|
|
8
8
|
= Requirements
|
|
9
9
|
|
|
10
|
-
* Supports
|
|
11
|
-
* Developed with CRuby
|
|
12
|
-
*
|
|
10
|
+
* Supports the Ruby versions currently maintained upstream by Ruby core: 3.2, 3.4, and 4.0.
|
|
11
|
+
* Developed with CRuby 4.0.6 on Linux; CI covers 3.2, 3.4, and 4.0.
|
|
12
|
+
* Other versions, including 3.1 and 3.3, are not supported.
|
|
13
13
|
|
|
14
14
|
=Description
|
|
15
15
|
|
|
@@ -3140,10 +3140,6 @@ module OpenEHR
|
|
|
3140
3140
|
[Uu] [Nn] [Ii] [Qq] [Uu] [Ee] space
|
|
3141
3141
|
end
|
|
3142
3142
|
|
|
3143
|
-
rule SYM_INFINITY
|
|
3144
|
-
[Ii] [Nn] [Ff] [Ii] [Nn] [Ii] [Tt] [Yy] space
|
|
3145
|
-
end
|
|
3146
|
-
|
|
3147
3143
|
rule SYM_USE_NODE
|
|
3148
3144
|
[Uu] [Ss] [Ee] '_' [Nn] [Oo] [Dd] [Ee] space
|
|
3149
3145
|
end
|
|
@@ -116,7 +116,7 @@ module OpenEHR
|
|
|
116
116
|
diff = (other.magnitude - self.magnitude).abs
|
|
117
117
|
hour = (diff / 60 / 60).to_i
|
|
118
118
|
minute = ((diff - hour*60*60)/60).to_i
|
|
119
|
-
second = (diff - hour * 60 *60 - minute * 60).to_i
|
|
119
|
+
second = (diff - hour * 60 * 60 - minute * 60).to_i
|
|
120
120
|
fractional_second = ((diff - diff.to_i)*1000000.0).to_i/1000000.0
|
|
121
121
|
str = 'P0Y0M0W0DT' + hour.to_s + 'H' +
|
|
122
122
|
minute.to_s + 'M' + second.to_s
|
|
@@ -184,11 +184,11 @@ module OpenEHR
|
|
|
184
184
|
date_duration = past_date.diff(future_date)
|
|
185
185
|
hour = (time_diff / 60 / 60).to_i
|
|
186
186
|
minute = ((time_diff - hour*60*60)/60).to_i
|
|
187
|
-
second = (time_diff - hour * 60 *60 - minute * 60).to_i
|
|
187
|
+
second = (time_diff - hour * 60 * 60 - minute * 60).to_i
|
|
188
188
|
str = date_duration.value + 'T' + hour.to_s + 'H' +
|
|
189
189
|
minute.to_s + 'M' + second.to_s
|
|
190
190
|
if @fractional_second.nil?
|
|
191
|
-
return DvDuration.new(:value => str +'S')
|
|
191
|
+
return DvDuration.new(:value => str + 'S')
|
|
192
192
|
else
|
|
193
193
|
fractional_second =
|
|
194
194
|
((time_diff - time_diff.to_i)*1000000.0).to_i/1000000.0
|
data/lib/openehr/rm/factory.rb
CHANGED
|
@@ -3,6 +3,23 @@ require 'active_support/inflector'
|
|
|
3
3
|
module OpenEHR
|
|
4
4
|
module RM
|
|
5
5
|
class Factory
|
|
6
|
+
# Attribute keys whose openEHR RM type is always exactly one
|
|
7
|
+
# concrete class (never actually polymorphic), so a real-world
|
|
8
|
+
# canonical-JSON serializer may legally omit _type for them - e.g.
|
|
9
|
+
# openehr-rails's own CanonicalSerializer does. Consulted only as
|
|
10
|
+
# a fallback when _type is absent; see convert_hash below.
|
|
11
|
+
#
|
|
12
|
+
# Deliberately does NOT include attributes whose declared type is
|
|
13
|
+
# abstract (e.g. LOCATABLE.uid : UID_BASED_ID, which could be an
|
|
14
|
+
# ObjectVersionID or a HierObjectID; OBJECT_REF.id : OBJECT_ID,
|
|
15
|
+
# similarly abstract) - guessing there would silently build the
|
|
16
|
+
# wrong object instead of failing loudly.
|
|
17
|
+
NON_POLYMORPHIC_TYPE_FOR_KEY = {
|
|
18
|
+
archetype_id: 'ARCHETYPE_ID',
|
|
19
|
+
template_id: 'TEMPLATE_ID',
|
|
20
|
+
terminology_id: 'TERMINOLOGY_ID'
|
|
21
|
+
}.freeze
|
|
22
|
+
|
|
6
23
|
def initialize(cobject)
|
|
7
24
|
@cobject = cobject
|
|
8
25
|
end
|
|
@@ -21,13 +38,49 @@ module OpenEHR
|
|
|
21
38
|
param.each_with_object({}) do |item, parameters|
|
|
22
39
|
key = item.shift
|
|
23
40
|
value = item.shift
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
41
|
+
parameters[key] = convert_value(key, value)
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
# A canonical-JSON attribute value is either a typed sub-object
|
|
48
|
+
# (Hash, normally with _type - see convert_hash for the
|
|
49
|
+
# _type-less case), a List<...> of those (Array - openEHR RM
|
|
50
|
+
# multiplicity 0..*/1..* attributes, e.g. COMPOSITION.content,
|
|
51
|
+
# HISTORY.events, ITEM_TREE.items), or a plain value (String,
|
|
52
|
+
# Numeric, ...). Arrays recurse (passing the same attribute key
|
|
53
|
+
# down, since none of NON_POLYMORPHIC_TYPE_FOR_KEY's keys are
|
|
54
|
+
# ever Array-valued) so nested multiplicities (e.g. a CLUSTER's
|
|
55
|
+
# own items) convert too; non-Hash array elements (there is no
|
|
56
|
+
# List<String>/List<Numeric> attribute in this RM, but doubles/
|
|
57
|
+
# pre-built objects show up in specs) pass through unchanged.
|
|
58
|
+
def convert_value(key, value)
|
|
59
|
+
if value.instance_of? Hash
|
|
60
|
+
convert_hash(key, value)
|
|
61
|
+
elsif value.instance_of? Array
|
|
62
|
+
value.map { |element| convert_value(key, element) }
|
|
63
|
+
else
|
|
64
|
+
value
|
|
29
65
|
end
|
|
30
|
-
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# _type is how a Hash normally says what RM class to become;
|
|
69
|
+
# when it's absent, fall back to NON_POLYMORPHIC_TYPE_FOR_KEY.
|
|
70
|
+
# Anything else raises with the attribute name rather than
|
|
71
|
+
# silently guessing or passing a raw Hash through where an RM
|
|
72
|
+
# object is expected (downstream code - e.g. Locatable#concept
|
|
73
|
+
# calling archetype_id.concept_name - would then fail far from
|
|
74
|
+
# the real cause).
|
|
75
|
+
def convert_hash(key, value)
|
|
76
|
+
type = value[:_type] || NON_POLYMORPHIC_TYPE_FOR_KEY[key]
|
|
77
|
+
unless type
|
|
78
|
+
raise ArgumentError,
|
|
79
|
+
"cannot determine the RM type for attribute #{key.inspect}: its Hash value has no _type key " \
|
|
80
|
+
"and #{key.inspect} is not a known non-polymorphic attribute (keys: #{value.keys.inspect})"
|
|
81
|
+
end
|
|
82
|
+
Factory.create(type, **value)
|
|
83
|
+
end
|
|
31
84
|
end
|
|
32
85
|
|
|
33
86
|
def build
|
|
@@ -81,7 +81,7 @@ module OpenEHR
|
|
|
81
81
|
items.each do |code, item|
|
|
82
82
|
ontology << INDENT*4 + "[\"#{code}\"] = <" + NL
|
|
83
83
|
item.items.each do |name, desc|
|
|
84
|
-
ontology << INDENT*5 + "#{name} = <\"#{desc}\">" +NL
|
|
84
|
+
ontology << INDENT*5 + "#{name} = <\"#{desc}\">" + NL
|
|
85
85
|
end
|
|
86
86
|
ontology << INDENT*4 + '>'+NL
|
|
87
87
|
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.0.
|
|
4
|
+
version: 2.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Shinji KOBAYASHI
|
|
@@ -381,7 +381,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
381
381
|
requirements:
|
|
382
382
|
- - ">="
|
|
383
383
|
- !ruby/object:Gem::Version
|
|
384
|
-
version: '3.
|
|
384
|
+
version: '3.2'
|
|
385
385
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
386
386
|
requirements:
|
|
387
387
|
- - ">="
|