open_ehr 0.9.5 → 1.0.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.
Files changed (98) hide show
  1. data/History.txt +3 -0
  2. data/README.rdoc +35 -25
  3. data/VERSION +1 -1
  4. data/lib/open_ehr.rb +2 -3
  5. data/lib/open_ehr/am.rb +1 -2
  6. data/lib/open_ehr/am/openehr_profile.rb +0 -1
  7. data/lib/open_ehr/am/openehr_profile/data_types.rb +2 -1
  8. data/lib/open_ehr/am/openehr_profile/data_types/basic.rb +88 -1
  9. data/lib/open_ehr/am/openehr_profile/data_types/quantity.rb +51 -2
  10. data/lib/open_ehr/am/openehr_profile/data_types/text.rb +2 -2
  11. data/lib/open_ehr/assumed_library_types.rb +5 -0
  12. data/lib/open_ehr/parser/adl.rb +5 -5
  13. data/lib/open_ehr/parser/adl_grammar.tt +13 -16
  14. data/lib/open_ehr/parser/adl_parser.rb +13 -5
  15. data/lib/open_ehr/parser/cadl_grammar.tt +247 -31
  16. data/lib/open_ehr/parser/cadl_node.rb +25 -0
  17. data/lib/open_ehr/parser/dadl_grammar.tt +6 -6
  18. data/lib/open_ehr/parser/shared_token_grammar.tt +14 -5
  19. data/lib/open_ehr/rm.rb +1 -2
  20. data/lib/open_ehr/rm/composition/content/entry.rb +8 -1
  21. data/lib/open_ehr/rm/data_types.rb +2 -2
  22. data/lib/open_ehr/rm/data_types/quantity.rb +1 -2
  23. data/lib/open_ehr/rm/data_types/quantity/date_time.rb +8 -5
  24. data/lib/open_ehr/rm/data_types/text.rb +7 -6
  25. data/lib/open_ehr/rm/support/identification.rb +13 -9
  26. data/open_ehr.gemspec +34 -4
  27. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/c_dv_state_spec.rb +34 -0
  28. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/non_terminal_state_spec.rb +36 -0
  29. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/state_machine_spec.rb +34 -0
  30. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/state_spec.rb +26 -0
  31. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/terminal_state_spec.rb +18 -0
  32. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/transition_spec.rb +62 -0
  33. data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_dv_ordinal_spec.rb +41 -0
  34. data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_dv_quantity_spec.rb +50 -0
  35. data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_quantity_item_spec.rb +46 -0
  36. data/spec/lib/open_ehr/am/openehr_profile/data_types/text/c_code_phrase_spec.rb +0 -1
  37. data/spec/lib/open_ehr/assumed_library_types/interval_spec.rb +5 -0
  38. data/spec/lib/open_ehr/parser/adl14/adl-test-composition.dv_coded_text.test.adl +1 -1
  39. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_desc_missing_purpose.test.adl +1 -1
  40. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_ordinal.test.adl +1 -1
  41. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_empty.test.adl +1 -1
  42. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full.test.adl +1 -1
  43. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full2.test.adl +1 -1
  44. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full3.test.adl +1 -1
  45. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_item_units_only.test.adl +1 -1
  46. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_list.test.adl +1 -1
  47. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_property.test.adl +1 -1
  48. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_reversed.test.adl +1 -1
  49. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.constraint_binding.test.adl +1 -1
  50. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.constraint_ref.test.adl +1 -1
  51. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.empty_other_contributors.test.adl +1 -1
  52. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.missing_language.test.adl +1 -1
  53. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.mixed_node_types.draft.adl +1 -1
  54. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.most_minimal.test.adl +1 -1
  55. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.multi_language.test.adl +1 -1
  56. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.special_string.test.adl +1 -1
  57. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.structure_test1.test.adl +1 -1
  58. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.structure_test2.test.adl +1 -1
  59. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.term_binding.test.adl +1 -1
  60. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.term_binding2.test.adl +1 -1
  61. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.unicode_BOM_support.test.adl +1 -1
  62. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.unicode_support.test.adl +1 -1
  63. data/spec/lib/open_ehr/parser/adl_archetype_ontology_binding_spec.rb +3 -3
  64. data/spec/lib/open_ehr/parser/c_dv_quantity_any_allowed_spec.rb +34 -0
  65. data/spec/lib/open_ehr/parser/c_dv_quantity_shared_example_for_lacked_items_spec.rb +36 -0
  66. data/spec/lib/open_ehr/parser/c_dv_quantity_shared_example_spec.rb +146 -0
  67. data/spec/lib/open_ehr/parser/cdv_ordinal_parse_spec.rb +231 -0
  68. data/spec/lib/open_ehr/parser/code_phrase_spec.rb +7 -2
  69. data/spec/lib/open_ehr/parser/constraint_binding_spec.rb +26 -0
  70. data/spec/lib/open_ehr/parser/constraint_ref_spec.rb +32 -0
  71. data/spec/lib/open_ehr/parser/dv_coded_text_parse_spec.rb +27 -0
  72. data/spec/lib/open_ehr/parser/empty_other_contributors_spec.rb +19 -0
  73. data/spec/lib/open_ehr/parser/missing_language_spec.rb +20 -0
  74. data/spec/lib/open_ehr/parser/missing_purpose_spec.rb +23 -0
  75. data/spec/lib/open_ehr/parser/mixed_node_types_spec.rb +16 -0
  76. data/spec/lib/open_ehr/parser/most_minimal_adl_spec.rb +19 -0
  77. data/spec/lib/open_ehr/parser/multi_language_spec.rb +58 -0
  78. data/spec/lib/open_ehr/parser/path_based_terminology_binding_spec.rb +30 -0
  79. data/spec/lib/open_ehr/parser/special_string_spec.rb +20 -0
  80. data/spec/lib/open_ehr/parser/structure_comment_spec.rb +21 -0
  81. data/spec/lib/open_ehr/parser/structure_nested_comments_spec.rb +22 -0
  82. data/spec/lib/open_ehr/parser/structure_spec.rb +202 -0
  83. data/spec/lib/open_ehr/parser/term_binding_spec.rb +54 -0
  84. data/spec/lib/open_ehr/parser/unicode_bom_spec.rb +17 -0
  85. data/spec/lib/open_ehr/parser/unicode_support_spec.rb +46 -0
  86. data/spec/lib/open_ehr/rm/common/change_control/imported_version_spec.rb +0 -1
  87. data/spec/lib/open_ehr/rm/common/change_control/original_version_spec.rb +2 -2
  88. data/spec/lib/open_ehr/rm/common/change_control/version_spec.rb +0 -1
  89. data/spec/lib/open_ehr/rm/common/change_control/versioned_object_spec.rb +0 -1
  90. data/spec/lib/open_ehr/rm/common/generic/revision_history_item_spec.rb +3 -3
  91. data/spec/lib/open_ehr/rm/composition/content/entry/entry_spec.rb +12 -2
  92. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb +1 -0
  93. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/{dv_tempral_spec.rb → dv_temporal_spec.rb} +1 -0
  94. data/spec/lib/open_ehr/rm/data_types/text/dv_text_spec.rb +25 -3
  95. data/spec/lib/open_ehr/rm/demographic/party_spec.rb +1 -3
  96. data/spec/lib/open_ehr/rm/support/identification/access_group_ref_spec.rb +2 -2
  97. data/spec/lib/open_ehr/rm/support/identification/object_version_id_spec.rb +3 -4
  98. metadata +69 -39
@@ -1,3 +1,6 @@
1
+ === 1.0.0 2011-12-24
2
+ First stable release
3
+
1
4
  === 0.9.5 2011-12-02
2
5
  Bug fix around ADL parser, data types, constranit
3
6
 
@@ -5,7 +5,7 @@ Ruby openEHR implementation project.
5
5
 
6
6
  = Version
7
7
 
8
- Release-0.9.5
8
+ Release-1.0.0
9
9
 
10
10
  = Requirements
11
11
 
@@ -18,15 +18,24 @@ Release-0.9.5
18
18
 
19
19
  == DESCRIPTION:
20
20
 
21
- This is the beta version 0.9.4 release of Ruby openEHR implementation
22
- project. This release is still experimental preview of our work based
23
- on openEHR specification release 1.0.2. We implemented almost of the
24
- specifications of the openEHR. The work is still in progress. The
25
- intention is to have a sample EHR to utilize all over the world
26
- quickly with Ruby on Rails.
27
-
28
- Parser is nearly performing completely. We now consider to descrive
29
- archetype as another formalism such as YAML, instead of ADL.
21
+ This is the fist stable branch version 1.0.0 release of Ruby openEHR
22
+ implementation project. This release is based on openEHR specification
23
+ release 1.0.2. We implemented almost of the specifications of the openEHR.
24
+ The work is still in progress to implement related tools, such as
25
+ archetype validator or serializer.
26
+ The intention is to have a sample EHR to utilize all over the world
27
+ quickly with Ruby on Rails for many other porject.
28
+ From this release we changed license from MPL 1.1 to Apache 2.0 license,
29
+ as regards to the other openEHR aretefact license.
30
+
31
+ This package includes:
32
+ * ADL 1.4 parser
33
+ * AM/RM packages based on the openEHR specification 1.0.2
34
+
35
+ This package excludes:
36
+ * ADL serializer(in progress)
37
+ * ADL validator(in progress)
38
+ * Data store/retrieve would be separate to the other project.
30
39
 
31
40
  Almost all classes passed the test constructed by RSpec2 (formaly used
32
41
  test/unit). These spec files are under /spec.
@@ -35,7 +44,7 @@ Some specifications are not well determined yet, such as rm/security
35
44
  and so on. We postponed to implement such classes.
36
45
 
37
46
  Terminology and Demographic server will be implemented in other
38
- project.
47
+ project.
39
48
 
40
49
  = Authors
41
50
  * Main codes
@@ -54,17 +63,18 @@ All Rights Reserved.
54
63
 
55
64
  = License
56
65
 
57
- This product is under openEHR Open Source Software License
58
-
59
- The openEHR Foundation has used the Mozilla Tri-license 1.1 on all
60
- software copyrighted to the Foundation. Therefore, we release this
61
- product under Mozilla Tri-license at now, but the openEHR foundation
62
- is discussing about lincense for the resouces. We would change our
63
- license for this package after the decision. The Mozilla tri-licence
64
- essentially provides the user a choice of licence conditionsunder
65
- which to operate with any given piece of software, being: the Mozilla
66
- Public licence (MPL), and the Free Software Foundation GNU General
67
- Public Licence (GPL) and Lesser GNU General Public Licence (LGPL). See
68
- the Mozilla relicensing FAQ for details of this license. This in no
69
- way constrains the way in which software created by other
70
- organisations is licenced.
66
+ This product is under Apache 2.0 license
67
+
68
+ Copyright [2011] Shinji Kobayashi, Akimichi Tatsukawa, openEHR.jp
69
+
70
+ Licensed under the Apache License, Version 2.0 (the "License");
71
+ you may not use this file except in compliance with the License.
72
+ You may obtain a copy of the License at
73
+
74
+ http://www.apache.org/licenses/LICENSE-2.0
75
+
76
+ Unless required by applicable law or agreed to in writing, software
77
+ distributed under the License is distributed on an "AS IS" BASIS,
78
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
79
+ See the License for the specific language governing permissions and
80
+ limitations under the License.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.9.5
1
+ 1.0.0
@@ -1,8 +1,7 @@
1
- $:.unshift(File.dirname(__FILE__)) unless
2
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
1
+ $:.unshift(File.dirname(__FILE__))
3
2
 
4
3
  module OpenEHR
5
- VERSION = '0.9.5'
4
+ VERSION = '1.0.0'
6
5
  autoload :AssumedLibraryTypes, 'open_ehr/assumed_library_types'
7
6
  autoload :RM, 'open_ehr/rm'
8
7
  autoload :AM, 'open_ehr/am'
@@ -1,5 +1,4 @@
1
- $:.unshift(File.dirname(__FILE__)) unless
2
- $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
1
+ $:.unshift(File.dirname(__FILE__))
3
2
 
4
3
  module OpenEHR
5
4
  module AM
@@ -4,7 +4,6 @@ module OpenEHR
4
4
  module AM
5
5
  module OpenEHRProfile
6
6
  autoload :DataTypes, 'openehr_profile/data_types'
7
-
8
7
  end
9
8
  end
10
9
  end
@@ -5,7 +5,8 @@ module OpenEHR
5
5
  module OpenEHRProfile
6
6
  module DataTypes
7
7
  autoload :Text, 'data_types/text'
8
-
8
+ autoload :Quantity, 'data_types/quantity'
9
+ autoload :Basic, 'data_types/basic'
9
10
  end
10
11
  end
11
12
  end
@@ -3,22 +3,109 @@ module OpenEHR
3
3
  module OpenEHRProfile
4
4
  module DataTypes
5
5
  module Basic
6
- class CDvState
6
+ include OpenEHR::AM::Archetype::ConstraintModel
7
+
8
+ class CDvState < CDomainType
9
+ attr_reader :value
10
+
11
+ def initialize(args = { })
12
+ args[:rm_type_name] = 'DvState'
13
+ super
14
+ self.value = args[:value]
15
+ end
16
+
17
+ def value=(value)
18
+ raise ArgumentError, 'value is mandatory' if value.nil?
19
+ @value = value
20
+ end
7
21
  end
8
22
 
9
23
  class StateMachine
24
+ attr_reader :states
25
+
26
+ def initialize(args = { })
27
+ self.states = args[:states]
28
+ end
29
+
30
+ def states=(states)
31
+ if states.nil? or states.empty?
32
+ raise ArgumentError, 'states are mandatory'
33
+ end
34
+ @states = states
35
+ end
10
36
  end
11
37
 
12
38
  class State
39
+ attr_reader :name
40
+
41
+ def initialize(args = { })
42
+ self.name = args[:name]
43
+ end
44
+
45
+ def name=(name)
46
+ if name.nil? or name.empty?
47
+ raise ArgumentError, 'Invalid name'
48
+ end
49
+ @name = name
50
+ end
13
51
  end
14
52
 
15
53
  class TerminalState < State
54
+
16
55
  end
17
56
 
18
57
  class NonTerminalState < State
58
+ attr_reader :transitions
59
+ def initialize(args = { })
60
+ super
61
+ self.transitions = args[:transitions]
62
+ end
63
+
64
+ def transitions=(transitions)
65
+ if transitions.nil? or transitions.empty?
66
+ raise ArgumentError, 'transition should not be empty'
67
+ end
68
+ @transitions = transitions
69
+ end
19
70
  end
20
71
 
21
72
  class Transition
73
+ attr_reader :event, :action, :guard, :next_state
74
+
75
+ def initialize(args = { })
76
+ self.event = args[:event]
77
+ self.guard = args[:guard]
78
+ self.action = args[:action]
79
+ self.next_state = args[:next_state]
80
+ end
81
+
82
+ def event=(event)
83
+ if event.nil? or event.empty?
84
+ raise ArgumentError, 'event is mandatory'
85
+ end
86
+ @event = event
87
+ end
88
+
89
+ def guard=(guard)
90
+ if !guard.nil? && guard.empty?
91
+ raise ArgumentError, 'guard should not be empty'
92
+ end
93
+ @guard = guard
94
+ end
95
+
96
+ def action=(action)
97
+ if !action.nil? && action.empty?
98
+ raise ArgumentError, 'action should not be empty'
99
+ end
100
+ @action = action
101
+ end
102
+
103
+ def next_state=(next_state)
104
+ if next_state.nil?
105
+ raise ArgumentError, 'next state is mandatory'
106
+ end
107
+ @next_state = next_state
108
+ end
22
109
  end
23
110
  end
24
111
  end # of DataTypes
@@ -3,13 +3,62 @@ module OpenEHR
3
3
  module OpenEHRProfile
4
4
  module DataTypes
5
5
  module Quantity
6
- class CDvQuantity < OpenEHR::AM::Archetype::ConstraintModel::CDomainType
6
+ include OpenEHR::AM::Archetype::ConstraintModel
7
+
8
+ class CDvQuantity < CDomainType
9
+ attr_accessor :property, :list
10
+
11
+ def initialize(args = { })
12
+ super
13
+ self.property = args[:property]
14
+ self.list = args[:list]
15
+ end
16
+
17
+ def any_allowed?
18
+ if @property.nil? && @list.nil?
19
+ return true
20
+ else
21
+ return false
22
+ end
23
+ end
7
24
  end
8
25
 
9
- class CDvOrdinal < OpenEHR::AM::Archetype::ConstraintModel::CDomainType
26
+ class CDvOrdinal < CDomainType
27
+ attr_accessor :list
28
+ def initialize(args = { })
29
+ super
30
+ self.list = args[:list]
31
+ end
32
+
33
+ def any_allowed?
34
+ @list.nil?
35
+ end
10
36
  end
11
37
 
12
38
  class CQuantityItem
39
+ attr_accessor :magnitude, :precision
40
+ attr_reader :units
41
+
42
+ def initialize(args = { })
43
+ self.magnitude = args[:magnitude]
44
+ self.precision = args[:precision]
45
+ self.units = args[:units]
46
+ end
47
+
48
+ def units=(units)
49
+ if units.nil? or units.empty?
50
+ raise ArgumentError, 'units are mandatory'
51
+ end
52
+ @units = units
53
+ end
54
+
55
+ def precision_unconstrained?
56
+ if @precision.upper == -1 && @precision.lower == -1
57
+ return true
58
+ else
59
+ return false
60
+ end
61
+ end
13
62
  end
14
63
  end
15
64
  end # of DataTypes
@@ -1,10 +1,10 @@
1
- include OpenEHR::AM::Archetype::ConstraintModel
2
-
1
+ $:.unshift(File.dirname(__FILE__))
3
2
  module OpenEHR
4
3
  module AM
5
4
  module OpenEHRProfile
6
5
  module DataTypes
7
6
  module Text
7
+ include OpenEHR::AM::Archetype::ConstraintModel
8
8
  class CCodePhrase < CDomainType
9
9
  attr_accessor :terminology_id, :code_list
10
10
 
@@ -64,6 +64,11 @@ module OpenEHR
64
64
  end
65
65
  end
66
66
 
67
+ def ==(value)
68
+ return (@lower == value.lower) && (@upper == value.upper) &&
69
+ (@lower_included == value.lower_included?) &&
70
+ (@upper_included == value.upper_included?)
71
+ end
67
72
  private
68
73
 
69
74
  def check_lower_upper(lower, upper)
@@ -1,6 +1,6 @@
1
+ require 'open_ehr/rm/data_types/text'
1
2
  include OpenEHR::RM::Support::Identification
2
3
  include OpenEHR::RM::Common::Resource
3
- include OpenEHR::RM::DataTypes::Text
4
4
 
5
5
  module OpenEHR
6
6
  module Parser
@@ -11,12 +11,12 @@ module OpenEHR
11
11
 
12
12
  class ArchLanguage < Base
13
13
  def value
14
- Language.new(lang.value)
14
+ return Language.new(lang.value)
15
15
  end
16
16
  end
17
17
 
18
-
19
18
  class Language
19
+ include OpenEHR::RM::DataTypes::Text
20
20
  attr_reader :original_language, :translations
21
21
 
22
22
  def initialize(value)
@@ -25,7 +25,7 @@ module OpenEHR
25
25
  end
26
26
 
27
27
  def original_language=(original_language)
28
- @original_language = code2lang original_language
28
+ @original_language = original_language
29
29
  end
30
30
 
31
31
  def translations=(translations)
@@ -35,7 +35,7 @@ module OpenEHR
35
35
  tr = translations.inject({ }) do |trans, lang|
36
36
  code, details = lang
37
37
  td = TranslationDetails.new(
38
- :language => code2lang(details['language']),
38
+ :language => details['language'],
39
39
  :author => details['author'],
40
40
  :accreditation => details['accreditation'],
41
41
  :other_details => details['other_details'])
@@ -33,11 +33,11 @@ module OpenEHR
33
33
  end
34
34
 
35
35
  def original_language
36
- lang.value.original_language
36
+ lang.value.original_language unless lang.empty?
37
37
  end
38
38
 
39
39
  def translations
40
- lang.value.translations
40
+ lang.value.translations unless lang.empty?
41
41
  end
42
42
 
43
43
  def description
@@ -144,18 +144,13 @@ module OpenEHR
144
144
  params = desc.value
145
145
  details = { }
146
146
  params['details'].each do |lang, attrs|
147
- term_id, la = attrs['language'].split('::')
148
- terminology_id =
149
- OpenEHR::RM::Support::Identification::TerminologyID.new(
150
- :value => term_id)
151
147
  misuse = attrs['misuse']
152
148
  misuse = nil if misuse.nil? or misuse.empty?
149
+ purpose = attrs['purpose'] || '__unknown__' # for backward compat.
153
150
  item =
154
151
  OpenEHR::RM::Common::Resource::ResourceDescriptionItem.new(
155
- :language => OpenEHR::RM::DataTypes::Text::CodePhrase.new(
156
- :terminology_id => terminology_id,
157
- :code_string => la),
158
- :purpose => attrs["purpose"],
152
+ :language => attrs['language'],
153
+ :purpose => purpose,
159
154
  :keywords => attrs["keywords"],
160
155
  :use => attrs["use"],
161
156
  :misuse => misuse,
@@ -201,19 +196,21 @@ module OpenEHR
201
196
  if cd
202
197
  cd = itemizer(cd , arc_term)
203
198
  end
204
- tb = ao['term_bindings']
199
+ tb = ao['term_bindings'] || ao['term_binding']
205
200
  term_bind = Proc.new do |code, item|
206
- term_id, code_string = item.split '::'
207
- term_id = OpenEHR::RM::Support::Identification::TerminologyID.new(:value => term_id)
208
- OpenEHR::RM::DataTypes::Text::CodePhrase.new(:terminology_id => term_id, :code_string => code_string)
201
+ unless item.class == Array
202
+ [item]
203
+ else
204
+ item
205
+ end
209
206
  end
210
207
  if tb
211
208
  tb = itemizer(tb, term_bind)
212
209
  end
213
210
  cons_bind = Proc.new do |code, item|
214
- item
211
+ OpenEHR::RM::DataTypes::URI::DvUri.new(:value => item)
215
212
  end
216
- cb = ao['constraint_bindings']
213
+ cb = ao['constraint_bindings'] || ao['constraint_binding']
217
214
  if cb
218
215
  cb = itemizer(cb, cons_bind)
219
216
  end
@@ -2,22 +2,23 @@ $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
  require 'polyglot'
4
4
  require 'treetop'
5
-
6
5
  include OpenEHR::Parser
7
6
  include OpenEHR::AM::Archetype
8
- include OpenEHR::RM::DataTypes::Text
9
7
  include OpenEHR::RM::Support::Identification
8
+ include OpenEHR::RM::DataTypes::Text
10
9
 
11
10
  module OpenEHR
12
11
  module Parser
13
12
  class ADLParser < Base
14
13
  def initialize(filename)
15
14
  super(filename)
16
- data = File.read(filename)
15
+ file = File.open(filename, 'r:bom|utf-8')
16
+ data = file.read
17
17
  Treetop.load(File.dirname(__FILE__)+'/adl_grammar.tt')
18
18
  ap = ADLGrammarParser.new
19
19
  @result = ap.parse(data)
20
- if @result.nil?
20
+ file.close
21
+ unless @result
21
22
  puts ap.failure_reason
22
23
  puts ap.failure_line
23
24
  puts ap.failure_column
@@ -25,10 +26,17 @@ module OpenEHR
25
26
  end
26
27
 
27
28
  def parse
28
- original_language = @result.original_language
29
29
  archetype_id = ArchetypeID.new(:value => @result.archetype_id)
30
30
  definition = @result.definition
31
31
  ontology = @result.ontology
32
+ original_language = nil
33
+ if @result.original_language
34
+ original_language = @result.original_language
35
+ else
36
+ terminology_id = TerminologyID.new(:value => 'ISO639-1')
37
+ original_language = CodePhrase.new(:terminology_id => terminology_id,
38
+ :code_string =>ontology.primary_language)
39
+ end
32
40
  archetype = Archetype.new(:archetype_id => archetype_id,
33
41
  :adl_version => @result.adl_version,
34
42
  :concept => @result.concept,