openehr 1.2.16 → 1.2.99

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
2
  SHA1:
3
- metadata.gz: 809f7e0499dba61d1d2997ab207c65cb4c505468
4
- data.tar.gz: b7d046f29a8fd2ebff8bb738621f291ef3d2c1d6
3
+ metadata.gz: 33791dffbc3bf04dff5496cc64ca0e757eb38599
4
+ data.tar.gz: f2f2e8a93f14cff344a74caecf233858bd6aa598
5
5
  SHA512:
6
- metadata.gz: db24ac16e6bdf90fc67480ae6bbb5e1e62d77ae22ffa4b8dfb397b16389cdb35d30a3855e26e629cad6a4c8c91ac8334b4ed1126c8d5ed12ebbdea0aa45ffc91
7
- data.tar.gz: 7f8a0cc6cee140e9edebf24a4bb45e5928752dd53835a26a9dad5a4cab642a297947f6498137bfa6913a3343414507d578d3c62922f77f1964680bea5c5ceb5c
6
+ metadata.gz: b96f14727386ccec7cbf358bae0762121a62d9f51a4f25b589928e205711784f0ab9c9c9353082571fad5d8bb27cfbecd482fa28af5f6926696e918c1514b58e
7
+ data.tar.gz: 58eaec7774dafb9635ab5b79f28c32ec27b1456d4d858a9c8b20d85d122d167e10ef6ca75ee676a345b99a8b9192738244dfc7c6b2b996df55818f53bd3c5cae
@@ -8,7 +8,7 @@ A Ruby implementation of the openEHR specifications
8
8
  = Requirements
9
9
 
10
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.
11
+ * Developed with CRuby 2.1.1, 2.0.0, 1.9.3 on FreeBSD and Linux.
12
12
  * Ruby 1.8 or earlier are no longer supported.
13
13
 
14
14
  =Description
@@ -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-2014] 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'
@@ -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
@@ -3,19 +3,30 @@ 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'
19
30
  DEFINITION_PATH = '/template/definition'
20
31
  OCCURRENCE_PATH = '/occurrences'
21
32
 
@@ -26,21 +37,25 @@ module OpenEHR
26
37
  def parse
27
38
  @opt = Nokogiri::XML::Document.parse(File.open(@filename))
28
39
  @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)
40
+ uid = OpenEHR::RM::Support::Identification::UIDBasedID.new(value: text_on_path(@opt, UID_PATH))
41
+ defs = definition
42
+ OpenEHR::AM::Template::OperationalTemplate.new(uid: uid, concept: concept, language: language, description: description, template_id: template_id, definition: defs, component_terminologies: @component_terminologies)
32
43
  end
33
44
 
34
45
  private
35
46
 
36
47
  def template_id
37
- OpenEHR::RM::Support::Identification::TemplateID.new(value: text_on_path(@opt, TEMPLATE_ID_PATH))
48
+ @template_id ||= OpenEHR::RM::Support::Identification::TemplateID.new(value: text_on_path(@opt, TEMPLATE_ID_PATH))
38
49
  end
39
50
 
40
51
  def concept
41
52
  text_on_path(@opt, CONCEPT_PATH)
42
53
  end
43
54
 
55
+ def language
56
+ @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)))
57
+ end
58
+
44
59
  def description
45
60
  original_author = text_on_path(@opt, DESC_ORIGINAL_AUTHOR_PATH)
46
61
  lifecycle_state = text_on_path(@opt, DESC_LIFECYCLE_STATE_PATH)
@@ -65,9 +80,37 @@ module OpenEHR
65
80
  root_occurrences = occurrences(@opt.xpath(DEFINITION_PATH + OCCURRENCE_PATH))
66
81
  root_archetype_id = OpenEHR::RM::Support::Identification::ArchetypeID.new(value: text_on_path(@opt, DEFINITION_PATH+'/archetype_id/value'))
67
82
  root_node.path = "/[#{root_archetype_id.value}]"
83
+ component_terminologies(root_archetype_id, @opt.xpath(DEFINITION_PATH))
68
84
  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))
69
85
  end
70
86
 
87
+ def component_terminologies(archetype_id, nodes)
88
+ @component_terminologies ||= Hash.new
89
+ @component_terminologies[archetype_id.value] =
90
+ archetype_terminology(nodes)
91
+ end
92
+
93
+ def archetype_terminology(nodes)
94
+ td = term_definitions(nodes)
95
+ concept_code = td[language.code_string][0]
96
+ OpenEHR::AM::Archetype::Terminology::
97
+ ArchetypeTerminology.new(
98
+ concept_code: concept_code,
99
+ original_language: language,
100
+ term_definitions: td)
101
+ end
102
+
103
+ def term_definitions(nodes)
104
+ term_definitions = nodes.xpath 'term_definitions'
105
+ term_items = term_definitions.map do |term|
106
+ code = term.attributes['code'].value
107
+ text = term.at('items[@id="text"]').text
108
+ description = term.at('items[@id="description"]').text
109
+ OpenEHR::AM::Archetype::Terminology::ArchetypeTerm.new(code: code, items: {'text' => text, 'description' => description})
110
+ end
111
+ { language.code_string => term_items }
112
+ end
113
+
71
114
  def children(children_xml, node)
72
115
  children_xml.map do |child|
73
116
  send child.attributes['type'].text.downcase, child, node
@@ -85,6 +128,7 @@ module OpenEHR
85
128
  else
86
129
  node.path += "/[#{archetype_id.value}]"
87
130
  end
131
+ component_terminologies(archetype_id, xml)
88
132
  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
133
  end
90
134
 
@@ -230,6 +274,7 @@ module OpenEHR
230
274
  def string(attr_xml)
231
275
  attr_xml.text
232
276
  end
277
+
233
278
  def empty_then_nil(val)
234
279
  if val.empty?
235
280
  return nil
@@ -1,3 +1,3 @@
1
1
  module OpenEHR
2
- VERSION = "1.2.16"
2
+ VERSION = "1.2.99"
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: 1.2.16
4
+ version: 1.2.99
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shinji KOBAYASHI
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-08-12 00:00:00.000000000 Z
15
+ date: 2014-08-22 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rake
@@ -168,6 +168,34 @@ dependencies:
168
168
  - - ">="
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
+ - !ruby/object:Gem::Dependency
172
+ name: rspec-expectations
173
+ requirement: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - ">="
176
+ - !ruby/object:Gem::Version
177
+ version: '0'
178
+ type: :development
179
+ prerelease: false
180
+ version_requirements: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ - !ruby/object:Gem::Dependency
186
+ name: rspec-collection_matchers
187
+ requirement: !ruby/object:Gem::Requirement
188
+ requirements:
189
+ - - ">="
190
+ - !ruby/object:Gem::Version
191
+ version: '0'
192
+ type: :development
193
+ prerelease: false
194
+ version_requirements: !ruby/object:Gem::Requirement
195
+ requirements:
196
+ - - ">="
197
+ - !ruby/object:Gem::Version
198
+ version: '0'
171
199
  - !ruby/object:Gem::Dependency
172
200
  name: simplecov
173
201
  requirement: !ruby/object:Gem::Requirement
@@ -197,6 +225,7 @@ files:
197
225
  - lib/openehr/am/archetype/constraint_model.rb
198
226
  - lib/openehr/am/archetype/constraint_model/primitive.rb
199
227
  - lib/openehr/am/archetype/ontology.rb
228
+ - lib/openehr/am/archetype/terminology.rb
200
229
  - lib/openehr/am/openehr_profile/data_types/basic.rb
201
230
  - lib/openehr/am/openehr_profile/data_types/quantity.rb
202
231
  - lib/openehr/am/openehr_profile/data_types/text.rb