open_ehr 0.9.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/README.rdoc +35 -25
- data/VERSION +1 -1
- data/lib/open_ehr.rb +2 -3
- data/lib/open_ehr/am.rb +1 -2
- data/lib/open_ehr/am/openehr_profile.rb +0 -1
- data/lib/open_ehr/am/openehr_profile/data_types.rb +2 -1
- data/lib/open_ehr/am/openehr_profile/data_types/basic.rb +88 -1
- data/lib/open_ehr/am/openehr_profile/data_types/quantity.rb +51 -2
- data/lib/open_ehr/am/openehr_profile/data_types/text.rb +2 -2
- data/lib/open_ehr/assumed_library_types.rb +5 -0
- data/lib/open_ehr/parser/adl.rb +5 -5
- data/lib/open_ehr/parser/adl_grammar.tt +13 -16
- data/lib/open_ehr/parser/adl_parser.rb +13 -5
- data/lib/open_ehr/parser/cadl_grammar.tt +247 -31
- data/lib/open_ehr/parser/cadl_node.rb +25 -0
- data/lib/open_ehr/parser/dadl_grammar.tt +6 -6
- data/lib/open_ehr/parser/shared_token_grammar.tt +14 -5
- data/lib/open_ehr/rm.rb +1 -2
- data/lib/open_ehr/rm/composition/content/entry.rb +8 -1
- data/lib/open_ehr/rm/data_types.rb +2 -2
- data/lib/open_ehr/rm/data_types/quantity.rb +1 -2
- data/lib/open_ehr/rm/data_types/quantity/date_time.rb +8 -5
- data/lib/open_ehr/rm/data_types/text.rb +7 -6
- data/lib/open_ehr/rm/support/identification.rb +13 -9
- data/open_ehr.gemspec +34 -4
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/c_dv_state_spec.rb +34 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/non_terminal_state_spec.rb +36 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/state_machine_spec.rb +34 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/state_spec.rb +26 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/terminal_state_spec.rb +18 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/transition_spec.rb +62 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_dv_ordinal_spec.rb +41 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_dv_quantity_spec.rb +50 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_quantity_item_spec.rb +46 -0
- data/spec/lib/open_ehr/am/openehr_profile/data_types/text/c_code_phrase_spec.rb +0 -1
- data/spec/lib/open_ehr/assumed_library_types/interval_spec.rb +5 -0
- data/spec/lib/open_ehr/parser/adl14/adl-test-composition.dv_coded_text.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_desc_missing_purpose.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_ordinal.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_empty.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full2.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full3.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_item_units_only.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_list.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_property.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_reversed.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.constraint_binding.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.constraint_ref.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.empty_other_contributors.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.missing_language.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.mixed_node_types.draft.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.most_minimal.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.multi_language.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.special_string.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.structure_test1.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.structure_test2.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.term_binding.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.term_binding2.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.unicode_BOM_support.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl14/adl-test-entry.unicode_support.test.adl +1 -1
- data/spec/lib/open_ehr/parser/adl_archetype_ontology_binding_spec.rb +3 -3
- data/spec/lib/open_ehr/parser/c_dv_quantity_any_allowed_spec.rb +34 -0
- data/spec/lib/open_ehr/parser/c_dv_quantity_shared_example_for_lacked_items_spec.rb +36 -0
- data/spec/lib/open_ehr/parser/c_dv_quantity_shared_example_spec.rb +146 -0
- data/spec/lib/open_ehr/parser/cdv_ordinal_parse_spec.rb +231 -0
- data/spec/lib/open_ehr/parser/code_phrase_spec.rb +7 -2
- data/spec/lib/open_ehr/parser/constraint_binding_spec.rb +26 -0
- data/spec/lib/open_ehr/parser/constraint_ref_spec.rb +32 -0
- data/spec/lib/open_ehr/parser/dv_coded_text_parse_spec.rb +27 -0
- data/spec/lib/open_ehr/parser/empty_other_contributors_spec.rb +19 -0
- data/spec/lib/open_ehr/parser/missing_language_spec.rb +20 -0
- data/spec/lib/open_ehr/parser/missing_purpose_spec.rb +23 -0
- data/spec/lib/open_ehr/parser/mixed_node_types_spec.rb +16 -0
- data/spec/lib/open_ehr/parser/most_minimal_adl_spec.rb +19 -0
- data/spec/lib/open_ehr/parser/multi_language_spec.rb +58 -0
- data/spec/lib/open_ehr/parser/path_based_terminology_binding_spec.rb +30 -0
- data/spec/lib/open_ehr/parser/special_string_spec.rb +20 -0
- data/spec/lib/open_ehr/parser/structure_comment_spec.rb +21 -0
- data/spec/lib/open_ehr/parser/structure_nested_comments_spec.rb +22 -0
- data/spec/lib/open_ehr/parser/structure_spec.rb +202 -0
- data/spec/lib/open_ehr/parser/term_binding_spec.rb +54 -0
- data/spec/lib/open_ehr/parser/unicode_bom_spec.rb +17 -0
- data/spec/lib/open_ehr/parser/unicode_support_spec.rb +46 -0
- data/spec/lib/open_ehr/rm/common/change_control/imported_version_spec.rb +0 -1
- data/spec/lib/open_ehr/rm/common/change_control/original_version_spec.rb +2 -2
- data/spec/lib/open_ehr/rm/common/change_control/version_spec.rb +0 -1
- data/spec/lib/open_ehr/rm/common/change_control/versioned_object_spec.rb +0 -1
- data/spec/lib/open_ehr/rm/common/generic/revision_history_item_spec.rb +3 -3
- data/spec/lib/open_ehr/rm/composition/content/entry/entry_spec.rb +12 -2
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb +1 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/{dv_tempral_spec.rb → dv_temporal_spec.rb} +1 -0
- data/spec/lib/open_ehr/rm/data_types/text/dv_text_spec.rb +25 -3
- data/spec/lib/open_ehr/rm/demographic/party_spec.rb +1 -3
- data/spec/lib/open_ehr/rm/support/identification/access_group_ref_spec.rb +2 -2
- data/spec/lib/open_ehr/rm/support/identification/object_version_id_spec.rb +3 -4
- metadata +69 -39
data/History.txt
CHANGED
data/README.rdoc
CHANGED
@@ -5,7 +5,7 @@ Ruby openEHR implementation project.
|
|
5
5
|
|
6
6
|
= Version
|
7
7
|
|
8
|
-
Release-0.
|
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
|
22
|
-
project. This release is
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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.
|
1
|
+
1.0.0
|
data/lib/open_ehr.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
$:.unshift(File.dirname(__FILE__))
|
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.
|
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'
|
data/lib/open_ehr/am.rb
CHANGED
@@ -3,22 +3,109 @@ module OpenEHR
|
|
3
3
|
module OpenEHRProfile
|
4
4
|
module DataTypes
|
5
5
|
module Basic
|
6
|
-
|
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
|
-
|
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 <
|
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
|
-
|
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)
|
data/lib/open_ehr/parser/adl.rb
CHANGED
@@ -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 =
|
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 =>
|
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 =>
|
156
|
-
|
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
|
-
|
207
|
-
|
208
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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,
|