source: ruby/trunk/lib/open_ehr/am/archetype/ontology.rb@ 411

Last change on this file since 411 was 411, checked in by KOBAYASHI, Shinji, 14 years ago

fixed archetype ontology bugs

File size: 2.7 KB
Line 
1module OpenEHR
2 module AM
3 module Archetype
4 module Ontology
5 class ArchetypeOntology
6 attr_accessor :constraint_definitions, :specialisation_depth
7 attr_accessor :term_attribute_names, :term_bindings
8 attr_reader :terminologies_available, :term_definitions
9
10 def initialize(args = { })
11 self.specialisation_depth = args[:specialisation_depth]
12 self.term_definitions = args[:term_definitions]
13 self.constraint_definitions = args[:constraint_definitions]
14 self.term_bindings = args[:term_bindings]
15 end
16
17 # def terminologies_available=(terminologies_available)
18 # if terminologies_available.nil?
19 # raise ArgumentError, 'terminologies_available is mandatory'
20 # end
21 # @terminologies_available = terminologies_available
22 # end
23
24 def term_definitions=(term_definitions)
25 if term_definitions.nil?
26 raise ArgumentError, 'term_definitions is mandatory'
27 end
28 @term_definitions = term_definitions
29 end
30
31 def term_codes
32 return @term_definitions.values.collect {|value|
33 value.collect {|term| term.code}}.flatten.uniq
34 end
35
36 def constraint_codes
37 if @constraint_definitions.nil?
38 return nil
39 else
40 return @constraint_definitions.values.collect {|value|
41 value.collect {|term| term.code}}.flatten.uniq
42 end
43 end
44
45 def constraint_binding(a_terminology, a_code)
46 end
47
48 def constraint_definition(a_lang, a_code)
49 end
50
51 def has_language?(a_lang)
52 end
53
54 def has_terminology?(a_terminology)
55 end
56
57 def term_binding(a_terminology, a_code)
58 end
59
60 def term_definition(a_lang, a_code)
61 end
62 end
63
64 class ARCHETYPE_ONTOLOGY < ArchetypeOntology
65
66 end
67
68 class ArchetypeTerm
69 attr_accessor :items
70 attr_reader :code
71
72 def initialize(args = { })
73 self.code = args[:code]
74 self.items =args[:items]
75 end
76
77 def code=(code)
78 if code.nil? or code.empty?
79 raise ArgumentError, 'code is mandatory'
80 end
81 @code = code
82 end
83
84 def keys
85 if items.nil?
86 return Set.new
87 else
88 return Set.new(@items.keys)
89 end
90 end
91 end
92
93 class ARCHETYPE_TERM < ArchetypeTerm
94
95 end
96 end # end of Ontology
97 end # end of Archetype
98 end # end of AM
99end # end of OpenEHR
100
Note: See TracBrowser for help on using the repository browser.