openehr 1.2.16 → 1.2.999999

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 809f7e0499dba61d1d2997ab207c65cb4c505468
4
- data.tar.gz: b7d046f29a8fd2ebff8bb738621f291ef3d2c1d6
2
+ SHA256:
3
+ metadata.gz: 0b1262bf46aa8257e7bb3aded5078ca794a14febe4b60f258ad515f7b63fb372
4
+ data.tar.gz: 073635b1014bb231c543566532b6327b9e2c211a95eb0d8f85502e03530b5107
5
5
  SHA512:
6
- metadata.gz: db24ac16e6bdf90fc67480ae6bbb5e1e62d77ae22ffa4b8dfb397b16389cdb35d30a3855e26e629cad6a4c8c91ac8334b4ed1126c8d5ed12ebbdea0aa45ffc91
7
- data.tar.gz: 7f8a0cc6cee140e9edebf24a4bb45e5928752dd53835a26a9dad5a4cab642a297947f6498137bfa6913a3343414507d578d3c62922f77f1964680bea5c5ceb5c
6
+ metadata.gz: cd81e9d640e206637b9cc742294f079627699eb9d93abf243efc9e93141c16db987c5d5ebb7068a5f87cb56f378268ab5606f183646b98e6374f89f5f128e541
7
+ data.tar.gz: 3505875a5655d03b0657521dae3c657c33db22c0d61db91be7d559de6106d2f24429daa1b1ec9a54292e2d10922ec9d393052e5d5ff7bfcf8bf77d490ac99396
@@ -7,9 +7,9 @@ A Ruby implementation of the openEHR specifications
7
7
 
8
8
  = Requirements
9
9
 
10
- * Supports Ruby 1.9.3, 2.0.0, 2.1.0 or equivalents.
11
- * Developed with CRuby 2.1.0, 2.0.0, 1.9.3 on FreeBSD and Linux.
12
- * Ruby 1.8 or earlier are no longer supported.
10
+ * Supports CRuby 2.3.6, 2.4.3, 2.5.0 or equivalents.
11
+ * Developed with CRuby 2.5.0 on FreeBSD and Linux.
12
+ * Ruby 2.2 or earlier are no longer supported.
13
13
 
14
14
  =Description
15
15
 
@@ -66,7 +66,7 @@ All Rights Reserved.
66
66
 
67
67
  This product is released under Apache 2.0 license
68
68
 
69
- Copyright [2012,2013] openEHR Ruby implementation project.
69
+ Copyright [2012-2018] openEHR Ruby implementation project.
70
70
 
71
71
  Licensed under the Apache License, Version 2.0 (the "License");
72
72
  you may not use this file except in compliance with the License.
@@ -3,8 +3,11 @@ require_relative 'am/archetype'
3
3
  require_relative 'am/archetype/assertion'
4
4
  require_relative 'am/archetype/constraint_model'
5
5
  require_relative 'am/archetype/constraint_model/primitive'
6
+ # Archetype ontology module was renamed to terminology module
7
+ require_relative 'am/archetype/terminology'
6
8
  require_relative 'am/archetype/ontology'
7
9
 
10
+
8
11
  #openEHR Archetype Profile
9
12
  require_relative 'am/openehr_profile/data_types/basic'
10
13
  require_relative 'am/openehr_profile/data_types/text'
@@ -100,6 +100,12 @@ module OpenEHR
100
100
  return archetype
101
101
  end
102
102
 
103
+ def to_rm
104
+ ::OpenEHR::RM::Factory.create(definition.rm_type_name,
105
+ archetype_node_id: definition.archetype_node_id,
106
+ name: definition
107
+ )
108
+ end
103
109
  end # end of Archetype
104
110
  # original file:
105
111
  # ref_imple_eiffel/components/adl_parser/src/interface/adl_definition.e
@@ -1,6 +1,7 @@
1
1
  module OpenEHR
2
2
  module AM
3
3
  module Archetype
4
+ # Ontology module was renamed to Terminology at spec 1.1.0.
4
5
  module Ontology
5
6
  class ArchetypeOntology
6
7
  attr_accessor :specialisation_depth, :primary_language
@@ -0,0 +1,15 @@
1
+ require_relative './ontology'
2
+ # Archetype Ontology module was renamed to Terminology at spec 1.1.0
3
+ module OpenEHR
4
+ module AM
5
+ module Archetype
6
+ module Terminology
7
+ class ArchetypeTerminology < OpenEHR::AM::Archetype::Ontology::ArchetypeOntology
8
+ end
9
+
10
+ class ArchetypeTerm < OpenEHR::AM::Archetype::Ontology::ArchetypeTerm
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -2,14 +2,20 @@ module OpenEHR
2
2
  module AM
3
3
  module Template
4
4
  class OperationalTemplate
5
- attr_reader :concept, :language, :description, :template_id, :definition
5
+ attr_reader :uid, :concept, :language, :description, :template_id, :definition, :component_terminologies
6
6
 
7
7
  def initialize(args = {})
8
+ self.uid = args[:uid]
8
9
  self.concept = args[:concept]
9
10
  self.template_id = args[:template_id]
10
11
  self.language = args[:language]
11
12
  self.description = args[:description]
12
13
  self.definition = args[:definition]
14
+ self.component_terminologies = args[:component_terminologies]
15
+ end
16
+
17
+ def uid=(uid)
18
+ @uid = uid
13
19
  end
14
20
 
15
21
  def concept=(concept)
@@ -35,6 +41,10 @@ module OpenEHR
35
41
  raise ArgumentError if definition.nil?
36
42
  @definition = definition
37
43
  end
44
+
45
+ def component_terminologies=(component_terminologies)
46
+ @component_terminologies = component_terminologies
47
+ end
38
48
  end
39
49
  end
40
50
  end
@@ -30,7 +30,7 @@ module OpenEHR
30
30
  end
31
31
 
32
32
  def lower_included=(lower_included)
33
- if (lower == nil) && (lower_included != nil)
33
+ if (lower.nil?) && (!lower_included.nil?)
34
34
  raise ArgumentError, "lower is not set"
35
35
  end
36
36
  lower_included = true if !lower.nil? && lower_included.nil?
@@ -25,6 +25,10 @@ module OpenEHR
25
25
  arch_identification.adl_version
26
26
  end
27
27
 
28
+ def uid
29
+ arch_identification.uid
30
+ end
31
+
28
32
  def concept
29
33
  arch_concept.value
30
34
  end
@@ -61,6 +65,10 @@ module OpenEHR
61
65
  head.value[:adl_version]
62
66
  end
63
67
 
68
+ def uid
69
+ head.value[:uid]
70
+ end
71
+
64
72
  def is_controlled?
65
73
  head.value[:is_controlled?]
66
74
  end
@@ -89,11 +97,10 @@ module OpenEHR
89
97
  end
90
98
 
91
99
  rule arch_meta_data_items
92
- item:arch_meta_data_item other_item:(';' arch_meta_data_item)* {
100
+ item:arch_meta_data_item other_items:(';' white_space arch_meta_data_item)* {
93
101
  def value
94
102
  v = item.value
95
- other_item.elements.map {|i| i.arch_meta_data_item.value}
96
- v
103
+ other_items.elements.map {|m| m.arch_meta_data_item.value }.inject(v, :update)
97
104
  end
98
105
  }
99
106
  end
@@ -104,9 +111,14 @@ module OpenEHR
104
111
  {:adl_version => ver.value}
105
112
  end
106
113
  }
114
+ / SYM_UID SYM_EQ uid:V_HIER_OBJECT space {
115
+ def value
116
+ { :uid => uid.value }
117
+ end
118
+ }
107
119
  / SYM_IS_CONTROLED space {
108
120
  def value
109
- {:is_controled? => true} # if elements[0]
121
+ { :is_controled? => true } # If elements[0]
110
122
  end
111
123
  }
112
124
  end
@@ -562,7 +574,7 @@ module OpenEHR
562
574
  path = node.path + id.value
563
575
  elsif node.id
564
576
  path = node.path + "[#{node.id}]/" + id.value
565
- elsif
577
+ else
566
578
  path = node.path + '/' + id.value
567
579
  end
568
580
  OpenEHR::AM::Archetype::ConstraintModel::CMultipleAttribute.new(
@@ -578,7 +590,7 @@ module OpenEHR
578
590
  path = node.path + id.value
579
591
  elsif node.id
580
592
  path = node.path + "[#{node.id}]/" + id.value
581
- elsif
593
+ else
582
594
  path = node.path + '/' + id.value
583
595
  end
584
596
  OpenEHR::AM::Archetype::ConstraintModel::CSingleAttribute.new(
@@ -2133,6 +2145,11 @@ module OpenEHR
2133
2145
  [term_code.value]
2134
2146
  end
2135
2147
  }
2148
+ / SYM_LIST_CONTINUE {
2149
+ def value
2150
+ []
2151
+ end
2152
+ }
2136
2153
  end
2137
2154
 
2138
2155
  rule uri_value
@@ -2875,6 +2892,10 @@ module OpenEHR
2875
2892
  [a-zA-Z0-9]
2876
2893
  end
2877
2894
 
2895
+ rule HEXADECIMAL
2896
+ [a-fA-F0-9]
2897
+ end
2898
+
2878
2899
  rule IDCHAR
2879
2900
  [a-zA-Z0-9_]
2880
2901
  end
@@ -3139,6 +3160,10 @@ module OpenEHR
3139
3160
  [Aa] [Dd] [Ll] '_' [Vv] [Ee] [Rr] [Ss] [Ii] [Oo] [Nn] space
3140
3161
  end
3141
3162
 
3163
+ rule SYM_UID
3164
+ [Uu] [Ii] [Dd] space
3165
+ end
3166
+
3142
3167
  rule SYM_IS_CONTROLLED
3143
3168
  [Cc] [Oo] [Nn] [Tt] [Rr] [Oo] [Ll] [Ll] [Ee] [Dd] space
3144
3169
  end
@@ -3203,6 +3228,14 @@ module OpenEHR
3203
3228
  }
3204
3229
  end
3205
3230
 
3231
+ rule V_HIER_OBJECT
3232
+ HEXADECIMAL 8..8 '-' (HEXADECIMAL 4..4 '-') 3..3 HEXADECIMAL 12..12 {
3233
+ def value
3234
+ text_value
3235
+ end
3236
+ }
3237
+ end
3238
+
3206
3239
  rule V_URI
3207
3240
  [a-z]+ '://' [^<>|\\{}^~"\[\] ]* {
3208
3241
  def value
@@ -3348,7 +3381,7 @@ module OpenEHR
3348
3381
  end
3349
3382
  }
3350
3383
  end
3351
-
3384
+
3352
3385
  rule V_CHAR
3353
3386
  [^\\\n\"] {
3354
3387
  def value
@@ -1,16 +1,16 @@
1
1
  require 'treetop'
2
- require 'polyglot'
2
+ #require 'polyglot'
3
3
 
4
4
  require_relative '../parser'
5
+ #require_relative './adl_grammar'
5
6
 
6
7
  module OpenEHR
7
8
  module Parser
8
9
  class ADLParser < ::OpenEHR::Parser::Base
9
- require_relative './adl_grammar'
10
- # Treetop.load('adl_grammar')
10
+ Treetop.load(File.join(File.dirname(__FILE__), 'adl_grammar.tt'))
11
11
 
12
12
  def initialize(filename)
13
- super(filename)
13
+ super
14
14
  end
15
15
 
16
16
  def parse
@@ -24,13 +24,14 @@ module OpenEHR
24
24
  end
25
25
 
26
26
  def parsed_data
27
- filestream = File.open(filename, 'r:bom|utf-8')
28
- @parsed_data ||= adl_grammar_parser.parse(filestream.read)
27
+ filestream = File.open(@filename, 'rb:bom|utf-8')
28
+ @parsed_data ||= adl_grammar_parser.parse(filestream.read.scrub)
29
29
  filestream.close
30
30
  unless @parsed_data
31
31
  puts adl_grammar_parser.failure_reason
32
32
  puts adl_grammar_parser.failure_line
33
33
  puts adl_grammar_parser.failure_column
34
+ raise ParseError, 'Invalid ADL'
34
35
  end
35
36
  @parsed_data
36
37
  end
@@ -58,6 +59,10 @@ module OpenEHR
58
59
  parsed_data.adl_version
59
60
  end
60
61
 
62
+ def uid
63
+ OpenEHR::RM::Support::Identification::HierObjectID.new(value: parsed_data.uid) if parsed_data.uid
64
+ end
65
+
61
66
  def concept
62
67
  parsed_data.concept
63
68
  end
@@ -77,6 +82,7 @@ module OpenEHR
77
82
  def archetype
78
83
  OpenEHR::AM::Archetype::Archetype.new(:archetype_id => archetype_id,
79
84
  :adl_version => adl_version,
85
+ :uid => uid,
80
86
  :concept => concept,
81
87
  :original_language => original_language,
82
88
  :translations => translations,
@@ -3,19 +3,32 @@ require 'nokogiri'
3
3
  module OpenEHR
4
4
  module Parser
5
5
  class OPTParser < ::OpenEHR::Parser::Base
6
- TEMPLATE_LANGUAGE_CODE_PATH = '/template/language/code_string'
7
- TEMPLATE_LANGUAGE_TERM_ID_PATH = '/template/language/terminology_id/value'
6
+ TEMPLATE_LANGUAGE_CODE_PATH =
7
+ '/template/language/code_string'
8
+ TEMPLATE_LANGUAGE_TERM_ID_PATH =
9
+ '/template/language/terminology_id/value'
8
10
  TEMPLATE_ID_PATH = '/template/template_id/value'
11
+ UID_PATH = '/template/uid/value'
9
12
  CONCEPT_PATH = '/template/concept'
10
- DESC_ORIGINAL_AUTHOR_PATH = '/template/description/original_author'
11
- DESC_LIFECYCLE_STATE_PATH = '/template/description/lifecycle_state'
12
- DESC_DETAILS_LANGUAGE_TERM_ID_PATH = '/template/description/details/language/terminology_id/value'
13
- DESC_DETAILS_LANGUAGE_CODE_PATH = '/template/description/details/language/code_string'
14
- DESC_DETAILS_PURPOSE_PATH = '/template/description/details/purpose'
15
- DESC_DETAILS_KEYWORDS_PATH = '/template/description/details/keywords'
13
+ DESC_ORIGINAL_AUTHOR_PATH =
14
+ '/template/description/original_author'
15
+ DESC_LIFECYCLE_STATE_PATH =
16
+ '/template/description/lifecycle_state'
17
+ DESC_DETAILS_LANGUAGE_TERM_ID_PATH =
18
+ '/template/description/details/language/terminology_id/value'
19
+ DESC_DETAILS_LANGUAGE_CODE_PATH =
20
+ '/template/description/details/language/code_string'
21
+ DESC_DETAILS_PURPOSE_PATH =
22
+ '/template/description/details/purpose'
23
+ DESC_DETAILS_KEYWORDS_PATH =
24
+ '/template/description/details/keywords'
16
25
  DESC_DETAILS_USE_PATH = '/template/description/details/use'
17
- DESC_DETAILS_MISUSE_PATH = '/template/description/details/misuse'
18
- DESC_DETAILS_COPYRIGHT_PATH = '/template/description/details/copyright'
26
+ DESC_DETAILS_MISUSE_PATH =
27
+ '/template/description/details/misuse'
28
+ DESC_DETAILS_COPYRIGHT_PATH =
29
+ '/template/description/details/copyright'
30
+ DESC_OTHER_DETAILS_PATH =
31
+ '/template/description/other_details'
19
32
  DEFINITION_PATH = '/template/definition'
20
33
  OCCURRENCE_PATH = '/occurrences'
21
34
 
@@ -26,25 +39,29 @@ module OpenEHR
26
39
  def parse
27
40
  @opt = Nokogiri::XML::Document.parse(File.open(@filename))
28
41
  @opt.remove_namespaces!
29
- terminology_id = OpenEHR::RM::Support::Identification::TerminologyID.new(value: text_on_path(@opt,TEMPLATE_LANGUAGE_TERM_ID_PATH))
30
- language = OpenEHR::RM::DataTypes::Text::CodePhrase.new(code_string: text_on_path(@opt, TEMPLATE_LANGUAGE_CODE_PATH), terminology_id: terminology_id)
31
- OpenEHR::AM::Template::OperationalTemplate.new(concept: concept, language: language, description: description, template_id: template_id, definition: definition)
42
+ uid = OpenEHR::RM::Support::Identification::UIDBasedID.new(value: text_on_path(@opt, UID_PATH))
43
+ defs = definition
44
+ OpenEHR::AM::Template::OperationalTemplate.new(uid: uid, concept: concept, language: language, description: description, template_id: template_id, definition: defs, component_terminologies: @component_terminologies)
32
45
  end
33
46
 
34
47
  private
35
48
 
36
49
  def template_id
37
- OpenEHR::RM::Support::Identification::TemplateID.new(value: text_on_path(@opt, TEMPLATE_ID_PATH))
50
+ @template_id ||= OpenEHR::RM::Support::Identification::TemplateID.new(value: text_on_path(@opt, TEMPLATE_ID_PATH))
38
51
  end
39
52
 
40
53
  def concept
41
54
  text_on_path(@opt, CONCEPT_PATH)
42
55
  end
43
56
 
57
+ def language
58
+ @language ||= OpenEHR::RM::DataTypes::Text::CodePhrase.new(code_string: text_on_path(@opt, TEMPLATE_LANGUAGE_CODE_PATH), terminology_id: OpenEHR::RM::Support::Identification::TerminologyID.new(value: text_on_path(@opt,TEMPLATE_LANGUAGE_TERM_ID_PATH)))
59
+ end
60
+
44
61
  def description
45
62
  original_author = text_on_path(@opt, DESC_ORIGINAL_AUTHOR_PATH)
46
63
  lifecycle_state = text_on_path(@opt, DESC_LIFECYCLE_STATE_PATH)
47
- OpenEHR::RM::Common::Resource::ResourceDescription.new(original_author: original_author, lifecycle_state: lifecycle_state, details: [description_details])
64
+ OpenEHR::RM::Common::Resource::ResourceDescription.new(original_author: original_author, lifecycle_state: lifecycle_state, details: [description_details], other_details: description_other_details)
48
65
  end
49
66
 
50
67
  def description_details
@@ -58,20 +75,42 @@ module OpenEHR
58
75
  OpenEHR::RM::Common::Resource::ResourceDescriptionItem.new(language: language, purpose: purpose, keywords: keywords, use: use, misuse: misuse, copyright: copyright)
59
76
  end
60
77
 
78
+ def description_other_details
79
+ @opt.xpath(DESC_OTHER_DETAILS_PATH).inject({}) do |hash, detail|
80
+ hash[detail.attributes['id'].value] = detail.text
81
+ hash
82
+ end
83
+ end
84
+
61
85
  def definition
62
- root_rm_type = text_on_path(@opt, DEFINITION_PATH + '/rm_type_name')
63
- root_node = Node.new
64
- root_node.id = text_on_path(@opt, DEFINITION_PATH + '/node_id')
65
- root_occurrences = occurrences(@opt.xpath(DEFINITION_PATH + OCCURRENCE_PATH))
66
- root_archetype_id = OpenEHR::RM::Support::Identification::ArchetypeID.new(value: text_on_path(@opt, DEFINITION_PATH+'/archetype_id/value'))
67
- root_node.path = "/[#{root_archetype_id.value}]"
68
- OpenEHR::AM::Archetype::ConstraintModel::CArchetypeRoot.new(rm_type_name: root_rm_type, node_id: root_node.id, path: root_node.path, occurrences: root_occurrences, archetype_id: root_archetype_id, attributes: attributes(@opt.xpath(DEFINITION_PATH+'/attributes'), root_node))
86
+ c_archetype_root @opt.xpath(DEFINITION_PATH)
69
87
  end
70
88
 
71
- def children(children_xml, node)
72
- children_xml.map do |child|
73
- send child.attributes['type'].text.downcase, child, node
89
+ def component_terminologies(archetype_id, nodes)
90
+ @component_terminologies ||= Hash.new
91
+ @component_terminologies[archetype_id.value] =
92
+ archetype_terminology(nodes)
93
+ end
94
+
95
+ def archetype_terminology(nodes)
96
+ td = term_definitions(nodes)
97
+ concept_code = td[language.code_string][0]
98
+ OpenEHR::AM::Archetype::Terminology::
99
+ ArchetypeTerminology.new(
100
+ concept_code: concept_code,
101
+ original_language: language,
102
+ term_definitions: td)
103
+ end
104
+
105
+ def term_definitions(nodes)
106
+ term_definitions = nodes.xpath 'term_definitions'
107
+ term_items = term_definitions.map do |term|
108
+ code = term.attributes['code'].value
109
+ text = term.at('items[@id="text"]').text
110
+ description = term.at('items[@id="description"]').text
111
+ OpenEHR::AM::Archetype::Terminology::ArchetypeTerm.new(code: code, items: {'text' => text, 'description' => description})
74
112
  end
113
+ { language.code_string => term_items }
75
114
  end
76
115
 
77
116
  def c_archetype_root(xml, node = Node.new)
@@ -81,10 +120,11 @@ module OpenEHR
81
120
  occurrences = occurrences(xml.xpath('./occurrences'))
82
121
  archetype_id = OpenEHR::RM::Support::Identification::ArchetypeID.new(value: text_on_path(xml, './archetype_id/value'))
83
122
  if node.root? or node.id.nil?
84
- node.path = "/[#{archetype_id.value}]"
85
- else
86
- node.path += "/[#{archetype_id.value}]"
123
+ node.path = "/"
124
+ # else
125
+ # node.path += "/" #"/[#{archetype_id.value}]"
87
126
  end
127
+ component_terminologies(archetype_id, xml)
88
128
  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))
89
129
  end
90
130
 
@@ -93,55 +133,51 @@ module OpenEHR
93
133
  node_id = xml.xpath('./node_id').text
94
134
  unless node_id.nil? or node_id.empty?
95
135
  node.id = node_id
96
- node.path += "[#{node_id}]"
136
+ node.path = "#{node.path}[#{node.id}]"
97
137
  end
98
138
  OpenEHR::AM::Archetype::ConstraintModel::CComplexObject.new(rm_type_name: rm_type_name, node_id: node.id, path: node.path, occurrences: occurrences(xml.xpath('./occurrences')), attributes: attributes(xml.xpath('./attributes'), node))
99
139
  end
100
140
 
101
141
  def attributes(attributes_xml, node)
102
142
  attributes_xml.map do |attr|
103
- send attr.attributes['type'].text.downcase, attr, node
143
+ rm_attribute_name = attr.at('rm_attribute_name').text
144
+ if node.root?
145
+ path = "/#{rm_attribute_name}"
146
+ # elsif node.id
147
+ # path = "#{node.path}[#{node.id}]/#{rm_attribute_name}"
148
+ else
149
+ path = "#{node.path}/#{rm_attribute_name}"
150
+ end
151
+ child_node = Node.new(node)
152
+ child_node.path = path
153
+ child_node.id = node.id
154
+ send attr.attributes['type'].text.downcase, attr, child_node
155
+ end
156
+ end
157
+
158
+ def children(children_xml, node)
159
+ children_xml.map do |child|
160
+ send child.attributes['type'].text.downcase, child, node
104
161
  end
105
162
  end
106
163
 
107
164
  def c_single_attribute(attr_xml, node)
108
165
  rm_attribute_name = attr_xml.at('rm_attribute_name').text
109
166
  existence = occurrences(attr_xml.at('existence'))
110
- if node.root?
111
- path = "/#{rm_attribute_name}"
112
- elsif node.id
113
- path = "#{node.path}[#{node.id}]/#{rm_attribute_name}"
114
- else
115
- path = "#{node.path}/#{rm_attribute_name}"
116
- end
117
- child_node = Node.new(node)
118
- child_node.path = node.path
119
- child_node.id = node.id
120
- OpenEHR::AM::Archetype::ConstraintModel::CSingleAttribute.new(rm_attribute_name: rm_attribute_name, existence: existence, path: path, children: children(attr_xml.xpath('./children'), child_node))
167
+ OpenEHR::AM::Archetype::ConstraintModel::CSingleAttribute.new(rm_attribute_name: rm_attribute_name, existence: existence, path: node.path, children: children(attr_xml.xpath('./children'), node))
121
168
  end
122
169
 
123
170
  def c_multiple_attribute(attr_xml, node)
124
171
  rm_attribute_name = attr_xml.at('rm_attribute_name').text
125
172
  existence = occurrences(attr_xml.at('existence'))
126
- if node.root?
127
- path = "/#{rm_attribute_name}"
128
- elsif node.id
129
- path = "#{node.path}[#{node.id}]/#{rm_attribute_name}"
130
- else
131
- path = "#{node.path}/#{rm_attribute_name}"
132
- end
133
- child_node = Node.new(node)
134
- child_node.path = node.path
135
- child_node.id = node.id
136
- OpenEHR::AM::Archetype::ConstraintModel::CMultipleAttribute.new(rm_attribute_name: rm_attribute_name, existence: existence, path: path, children: children(attr_xml.xpath('./children'), child_node))
173
+ OpenEHR::AM::Archetype::ConstraintModel::CMultipleAttribute.new(rm_attribute_name: rm_attribute_name, existence: existence, path: node.path, cardinality: cardinality(attr_xml), children: children(attr_xml.xpath('./children'), node))
137
174
  end
138
175
 
139
176
  def c_code_phrase(attr_xml, node)
140
177
  terminology_id = OpenEHR::RM::Support::Identification::TerminologyID.new(value: attr_xml.at('terminology_id/value').text.strip)
141
- path = node.path
142
178
  code_list = attr_xml.xpath('code_list').text.strip
143
179
  occurrences = occurrences(attr_xml.at('occurrences'))
144
- OpenEHR::AM::OpenEHRProfile::DataTypes::Text::CCodePhrase.new(terminology_id: terminology_id, code_list: [code_list], path: path, occurrences: occurrences, rm_type_name: 'CodePhrase')
180
+ OpenEHR::AM::OpenEHRProfile::DataTypes::Text::CCodePhrase.new(terminology_id: terminology_id, code_list: [code_list], path: node.path, occurrences: occurrences, rm_type_name: 'CodePhrase')
145
181
  end
146
182
 
147
183
  def archetype_slot(attr_xml,node)
@@ -166,6 +202,13 @@ module OpenEHR
166
202
  OpenEHR::AssumedLibraryTypes::Interval.new(lower: lower, upper: upper, lower_included: lower_included, upper_included: upper_included)
167
203
  end
168
204
 
205
+ def cardinality(xml)
206
+ order = to_bool(xml.at('is_ordered').text)
207
+ unique = to_bool(xml.at('is_unique').text)
208
+ interval = occurrences(xml)
209
+ OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(is_ordered: order, is_unique: unique, interval: interval)
210
+ end
211
+
169
212
  def constraint_ref(attr_xml, node)
170
213
  rm_type_name = attr_xml.at('rm_type_name').text
171
214
  reference = attr_xml.at('reference').text
@@ -204,12 +247,19 @@ module OpenEHR
204
247
  def c_primitive_object(attr_xml, node)
205
248
  rm_type_name = attr_xml.at('rm_type_name').text
206
249
  occurrences = occurrences(attr_xml.at('occurrences'))
207
- OpenEHR::AM::Archetype::ConstraintModel::CPrimitiveObject.new(rm_type_name: rm_type_name, occurrences: occurrences, node_id: node.id)
250
+ item = send attr_xml.at('item')['type'].downcase, attr_xml.at('item')
251
+ OpenEHR::AM::Archetype::ConstraintModel::CPrimitiveObject.new(rm_type_name: rm_type_name, occurrences: occurrences, node_id: node.id, item: item)
208
252
  end
209
-
253
+
210
254
  def c_string(attr_xml)
211
- pattern = attr_xml.at('pattern').text
212
- OpenEHR::AM::Archetype::ConstraintModel::Primitive::CString.new(pattern: pattern)
255
+ if attr_xml.at('pattern')
256
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CString.new(pattern: attr_xml.at('pattern').text)
257
+ else
258
+ list = attr_xml.xpath('.//list').map do |str|
259
+ str.text
260
+ end
261
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CString.new(list: list)
262
+ end
213
263
  end
214
264
 
215
265
  def c_dv_quantity(attr_xml, node)
@@ -227,9 +277,25 @@ module OpenEHR
227
277
  OpenEHR::AM::OpenEHRProfile::DataTypes::Quantity::CDvQuantity.new(rm_type_name: rm_type_name, occurrences: occurrences, list: list, property: property)
228
278
  end
229
279
 
280
+ def c_date(xml)
281
+
282
+ end
283
+
284
+ def c_date_time(xml)
285
+
286
+ end
287
+
288
+ def c_integer(xml)
289
+
290
+ end
291
+
292
+ def c_boolean(xml)
293
+ end
294
+
230
295
  def string(attr_xml)
231
296
  attr_xml.text
232
297
  end
298
+
233
299
  def empty_then_nil(val)
234
300
  if val.empty?
235
301
  return nil
@@ -243,9 +309,9 @@ module OpenEHR
243
309
  end
244
310
 
245
311
  def to_bool(str)
246
- if str =~ /true/i
312
+ if /true/i =~ str
247
313
  return true
248
- elsif str =~ /false/i
314
+ elsif /false/i =~ str
249
315
  return false
250
316
  end
251
317
  return nil