Index: ruby/branches/0.5/lib/open_ehr/rm/data_types/text.rb
===================================================================
--- ruby/branches/0.5/lib/open_ehr/rm/data_types/text.rb	(revision 224)
+++ ruby/branches/0.5/lib/open_ehr/rm/data_types/text.rb	(revision 226)
@@ -10,37 +10,49 @@
         class TermMapping
           attr_reader :match, :purpose, :target
-          def initialize(match, purpose, target)
-            match_valid(match)
-            purpose_valid(purpose)
-            target_valid(target)
-            @match, @purpose, @target = match, purpose, target
+
+          def initialize(args ={})
+            self.match = args[:match]
+            self.purpose = args[:purpose]
+            self.target = args[:target]
           end
+
+          def match=(match)
+            unless TermMapping.is_valid_mach_code? match
+              raise ArgumentError, 'invalid match character'
+            end
+            @match = match
+          end
+
+          def purpose=(purpose)
+#            if !purpose.nil? and !purpose.instance_of?(DvCodedText)
+#              raise ArgumentError, "purpose is not valid"
+#            end
+            # should be settled after terminology service implemented
+            @purpose = purpose
+          end
+
+          def target=(target)
+            raise ArgumentError, "target must not be nil" if target.nil?
+            @target = target
+          end
+
           def broader?
             match == '>'
           end
+
           def equivalent?
             match == '='
           end
+
           def narrower?
             match == '<'
           end
+
           def unknown?
             match == '?'
           end
+
           def TermMapping.is_valid_mach_code?(c)
             c == '>' or c == '=' or c == '<' or c == '?'
-          end
-          private
-          def match_valid(match)
-            raise ArgumentError, "match is not valid" if !TermMapping.is_valid_mach_code? match
-          end
-          def purpose_valid(purpose)
-            if purpose.nil? or !purpose.instance_of? DvCodedText
-              raise ArgumentError, "purpose is not valid"
-            end
-            # should be settled after terminology service implemented
-          end
-          def target_valid(target)
-            raise ArgumentError, "target must not be nil" if target.nil?
           end
         end
Index: ruby/branches/0.5/lib/open_ehr/rm/support/terminology.rb
===================================================================
--- ruby/branches/0.5/lib/open_ehr/rm/support/terminology.rb	(revision 224)
+++ ruby/branches/0.5/lib/open_ehr/rm/support/terminology.rb	(revision 226)
@@ -8,14 +8,18 @@
             raise NotImplementedError, "all_codes must be implemented"
           end
+
           def has_code(a_code)
             raise NotImplementedError, "has_code must be implemented"
           end
+
           def has_lang(a_lang)
             raise NotImplementedError, "has_lang must be implemented"
           end
+
           def id
             raise NotImplementedError, "id must be returned"
           end
         end
+
         module OpenEHRCodeSetIdentifier
           CODE_SET_ID_CHARACER_SETS = "character sets".freeze
@@ -29,4 +33,5 @@
           end
         end
+
         module OpenEHRTerminologyGroupIdentifiers
           GROUP_ID_ATTESTATION_REASON = "attestation reason".freeze
@@ -46,23 +51,38 @@
           TERMINOLOGY_ID = "openehr".freeze
         end
+
         class TerminologyAccess
+          attr_reader :id
+
+          def initialize(args = {})
+            self.id = args[:id]
+          end
+
           def all_codes
             raise NotImplementedError, "all_codes is not implemented"
           end
+
           def codes_for_group_id(group_id)
             raise NotImplementedError, "codes_for_group_id is not implemented"
           end
+
           def codes_for_group_name(name, lang)
             raise NotImplementedError, "codes_for_group_name is not implemented"
           end
+
           def has_code_for_group_id(group_id, a_code)
-            raise NotImplementedError, "has_code_for_group_id is not implemented"
+            
           end
-          def id
-            raise NotImplementedError, "id is not implemented"
+
+          def id=(id)
+            @terminology = Terminology.find_all_by_name(id)
+            @id = id
           end
+
           def rubric_for_code(code, lang)
-            raise NotImplementedError, "rubic_for_code is not implemented"
+            return Terminology.find(:first, :conditions => {:code => code,
+                                      :lang => lang})
           end
+
           private
           def id_exists
@@ -74,27 +94,36 @@
           end
         end
+
         class TerminologyService
           include OpenEHRCodeSetIdentifier, OpenEHRTerminologyGroupIdentifiers
+
           def code_set(name)
             raise NotImplementedError, "code_set is not implemented"
           end
+
           def code_set_for_id(id)
             raise NotImplementedError, "code_set_for_id is not implemented"
           end
+
           def code_set_identifiers
             raise NotImplementedError, "code_set_for_identifiers is not implemented"
           end
+
           def has_code_set(name)
             raise NotImplementedError, "has_code_set is not implemented"
           end
+
           def has_terminology?(name)
             raise NotImplementedError, "has_terminology is not implemented"
           end
+
           def openehr_code_sets
             raise NotImplementedError, "openehr_code_set is not implemented"
           end
+
           def terminology(name)
-            raise NotImplementedError, "terminology is not implemented"
+            return TerminologyAccess.new(:id => name)
           end
+          
           def terminology_identifiers
             raise NotImplementedError, "terminology_identiferes is not implemented"
