Index: ruby/branches/TRY-open_ehr_gem/am.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am.rb	(revision 302)
@@ -0,0 +1,57 @@
+#! /usr/bin/env ruby
+# component: openEHR Ruby reference implementation
+# description: This file includes Archetype 
+#      class that contains Archetype values.
+#      Main concept is based on Java ref impl.
+#      We should make refactoring to suit for Ruby way.
+# keywords: archetype
+# author: Akimichi TATSUKAWA, Shinji KOBAYASHI
+# support: openEHR.jp
+# license: openEHR open source license
+#
+
+$:.unshift File.join(File.dirname(__FILE__))
+require 'rm/common/resource.rb'
+#require 'rm/support/terminology/openehr_code_set_identifier.rb'
+module OpenEhr
+  module AM
+    module Archetype
+      autoload :ARCHETYPE, "am/archetype/archetype.rb"
+      autoload :Constraint_Model, "am/archetype/constraint_model/archetype_constraint.rb"
+      autoload :Ontology, "am/archetype/ontology.rb"
+      
+      module Archetype_Description
+        autoload :ARCHETYPE_DESCRIPTION, "am/archetype/archetype_description/archetype_description.rb"
+      end
+
+      module Constraint_Model
+        autoload :ARCHETYPE_CONSTRAINT, "am/archetype/constraint_model/archetype_constraint.rb"
+        autoload :ARCHETYPE_SLOT, "am/archetype/constraint_model/archetype_constraint.rb"
+        autoload :Primitive, "am/archetype/constraint_model/primitive.rb"
+      end #end of ConstraintModel
+
+      module Assertion
+        autoload :ASSERTION, "am/archetype/constraint_model/assertion.rb"
+      end
+
+    end # of Archetype
+
+    module OpenEHR_Profile
+      module DataTypes
+        module Basic
+          autoload :C_DV_STATE, "am/openehr_profile/data_types/basic.rb"
+        end
+
+        module Text
+          autoload :C_CODE_PHASE, "am/openehr_profile/data_types/text.rb"
+        end
+
+        module Quantity
+          autoload :C_DV_QUANTITY, "am/openehr_profile/data_types/quantity.rb"
+          autoload :C_DV_ORDINAL, "am/openehr_profile/data_types/quantity.rb"
+          autoload :C_QUANTITY_ITEM, "am/openehr_profile/data_types/quantity.rb"
+        end
+      end
+    end
+  end # of AM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/am/archetype/archetype.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am/archetype/archetype.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am/archetype/archetype.rb	(revision 302)
@@ -0,0 +1,85 @@
+require 'rm/support/terminology.rb'
+
+module OpenEhr
+  module AM
+    module Archetype
+      module ADL_Definition
+#        include OpenEHR::RM::Support::Terminology::OpenEHR_Code_Set_Identifier
+        include OpenEhr::RM::Support::Terminology
+        CURRENT_ADL_VERSION = "1.4"
+      end
+
+      class ARCHETYPE < OpenEhr::RM::Common::Resource::AuthoredResource
+        include ADL_Definition
+        attr_accessor :archetype_id, :concept_code, :is_controlled, :original_language, :parent_archtype_id, :uid
+
+        attr_reader :parent_id,:concept, :definition, :ontology
+        attr_accessor :adl_version,:description,:original_language
+        attr_accessor :revision_history, :translation
+
+        def initialize(args = {})
+          @adl_version = args[:adl_version] if args[:adl_version]
+          @archetype_id = args[:archetype_id] ? args[:archetype_id] : nil
+          @parent_id = args[:parent_id] if args[:parent_id]
+          @concept = args[:concept] if args[:concept]
+          @is_controled = args[:is_controled] if args[:is_controled]
+          @definition = args[:definition] if args[:definition]
+          @ontology = args[:ontology] if args[:ontology]
+ #         loadMaps(definition)
+          super
+        end
+
+        def self.create(args ={}, &block)
+          archetype = new(args)
+          if block_given?
+            yield archetype
+          end
+          return archetype
+        end
+
+        def concept_name(a_lang)
+        end
+
+        def constraint_references_valid?
+        end
+
+        def internal_references_valid?
+        end
+
+        def is_specialised?
+        end
+
+        def is_valid?
+        end
+
+        def logical_paths(a_lang)          
+        end
+
+        def node_ids_vaild?
+        end
+
+        def physical_paths
+        end
+
+        def previous_version
+        end
+
+        def short_concept_name
+        end
+
+        def specialisation_depth
+        end
+        
+        def version
+        end
+      end # end of ARCHETYPE
+      # original file:
+      # ref_imple_eiffel/components/adl_parser/src/interface/adl_definition.e
+
+      class VALIDITY_KIND
+      end
+    end
+
+
+  end # end of AM
+end # end of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/am/archetype/archetype_description/archetype_description.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am/archetype/archetype_description/archetype_description.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am/archetype/archetype_description/archetype_description.rb	(revision 302)
@@ -0,0 +1,21 @@
+
+module OpenEhr
+  module AM
+    module Archetype
+      module Archetype_Description
+        class ARCHETYPE_DESCRIPTION
+          attr_accessor :archetype_package_uri, :lifecycle_state, :original_author, :other_contributors, :other_details, :details
+          def initialize(args ={ })
+            @details = args[:details] ? args[:details] : []
+          end
+        end
+
+        class ARCHETYPE_DESCRIPTION_ITEM
+          attr_accessor :archetype_package_uri, :lifecycle_state, :original_author, :other_contributors, :other_details
+        end
+      end
+    end
+  end
+end
+
+
Index: ruby/branches/TRY-open_ehr_gem/am/archetype/constraint_model/archetype_constraint.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am/archetype/constraint_model/archetype_constraint.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am/archetype/constraint_model/archetype_constraint.rb	(revision 302)
@@ -0,0 +1,144 @@
+
+module OpenEhr
+  module AM
+    module Archetype
+      module Constraint_Model
+        class ARCHETYPE_CONSTRAINT
+          
+        end
+
+        class CARDINALITY
+          attr_accessor :interval, :is_ordered, :is_unique
+
+          def initialize(args = { })
+            @interval = args[:interval]
+            @is_ordered = args[:is_ordered]
+            @is_unique = args[:is_unique]
+          end
+        end
+
+        class C_OBJECT < ARCHETYPE_CONSTRAINT
+          attr_accessor :node_id, :occurrences, :rm_type_name
+
+          def initialize(args = { })
+            @node_id = args[:node_id] if args[:node_id]
+            @occurrences = args[:occurrences] if args[:occurrences]
+            @rm_type_name = args[:rm_type_name] if args[:rm_type_name]
+          end
+
+          def self.create(args = { }, &block)
+            c_object = new(args)
+            if block_given?
+              yield c_object
+            end
+            return c_object
+          end
+        end
+
+        class C_ATTRIBUTE < ARCHETYPE_CONSTRAINT
+          attr_accessor :rm_attribute_name, :existence, :children
+
+          def initialize(args = { })
+            @rm_attribute_name = args[:rm_attribute_name] if args[:rm_attribute_name]
+            @existence = args[:existence] if args[:existence]
+            @children = args[:children] ? args[:children] : []
+            
+          end
+        end
+
+        class C_DEFINED_OBJECT < C_OBJECT
+          attr_accessor :assumed_value
+          
+          def initialize(args = { })
+            @assumed_value = args[:assumed_value] if args[:assumed_value]
+            super
+          end
+        end
+
+        class C_PRIMITIVE_OBJECT < C_DEFINED_OBJECT
+          attr_accessor :item
+
+          def initialize(args = { })
+            @attributes = args[:item] if args[:item]
+            super
+          end
+        end
+
+        class C_COMPLEX_OBJECT < C_DEFINED_OBJECT
+          attr_accessor :attributes, :attributes_valid
+
+          def initialize(args = { })
+            @attributes = args[:attributes] ? args[:attributes] : []
+            super
+          end
+
+          def self.create(args = { }, &block)
+            c_complex_object = new(args)
+            if block_given?
+              yield c_complex_object
+            end
+            return c_complex_object
+          end
+        end
+
+        class C_DOMAIN_TYPE < C_DEFINED_OBJECT
+          
+        end
+
+        class C_REFERENCE_OBJECT < C_OBJECT
+        end
+
+        class ARCHETYPE_INTERNAL_REF < C_REFERENCE_OBJECT
+          attr_accessor :target_path
+        end
+
+        class ARCHETYPE_SLOT < C_REFERENCE_OBJECT
+          attr_accessor :includes, :excludes
+
+          def self.create(args = { }, &block)
+            archetype_slot = new(args)
+            archetype_slot.includes = args[:includes]
+            archetype_slot.excludes = args[:excludes]
+            if block_given?
+              yield archetype_slot
+            end
+            return archetype_slot
+          end
+        end
+
+        class CONSTRAINT_REF < C_REFERENCE_OBJECT
+          attr_accessor :reference
+
+          def self.create(args = { }, &block)
+            constraint_ref = new(args)
+            constraint_ref.reference = args[:reference]
+            if block_given?
+              yield constraint_ref
+            end
+            return constraint_ref
+          end
+        end
+
+        class C_SINGLE_ATTRIBUTE < C_ATTRIBUTE
+          attr_accessor :alternatives
+
+          def initialize(args = { })
+            @alternatives = args[:alternatives] ? args[:alternatives] : []
+            super
+          end
+        end
+
+        class C_MULTIPLE_ATTRIBUTE < C_ATTRIBUTE
+          attr_accessor :members, :cardinality
+          
+          def initialize(args = { })
+            @members = args[:members] ? args[:members] : []
+            @cardinality = args[:cardinality] if args[:cardinality]
+            super
+          end
+        end
+      end
+    end
+  end
+end
+  
Index: ruby/branches/TRY-open_ehr_gem/am/archetype/constraint_model/assertion.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am/archetype/constraint_model/assertion.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am/archetype/constraint_model/assertion.rb	(revision 302)
@@ -0,0 +1,31 @@
+module OpenEhr
+  module AM
+    module Archetype
+      module Assertion
+        class ASSERTION
+        end
+
+        class ASSERTION_VARIABLE
+        end
+
+        class OPERATOR_KIND
+        end
+
+        class EXPR_ITEM
+        end
+
+        class EXPR_LEAF < EXPR_ITEM
+        end
+
+        class EXPR_OPERATOR < EXPR_ITEM
+        end
+
+        class EXPR_UNARY_OPERATOR < EXPR_OPERATOR
+        end
+
+        class EXPR_BINARY_OPERATOR < EXPR_OPERATOR
+        end
+      end
+    end
+  end
+end
Index: ruby/branches/TRY-open_ehr_gem/am/archetype/constraint_model/primitive.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am/archetype/constraint_model/primitive.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am/archetype/constraint_model/primitive.rb	(revision 302)
@@ -0,0 +1,150 @@
+module OpenEhr
+  module AM
+    module Archetype
+      module Constraint_Model
+
+        module Primitive
+
+          class C_PRIMITIVE
+
+            def initialize
+              raise "abstract class"
+            end
+
+            def self.create(args = {})
+              instance = new(args)
+
+              if block_given?
+                yield instance
+              end
+              return instance
+            end
+
+
+            def assumed_value
+              raise NotImplementedError, "assumed_value should be implemented"
+            end
+
+            def default_value
+              raise NotImplementedError, "assumed_value should be implemented"
+            end
+
+            def has_assumed_value?
+              assumed_value != nil
+            end
+
+            def valid_value?
+              raise NotImplementedError, "valid_value? should be implemented"
+            end
+          end
+
+          class C_BOOLEAN < C_PRIMITIVE
+            attr_reader :true_valid, :false_valid, :assumed_value
+
+            def initialize(args = { })
+              @true_valid = args[:true_valid] ? args[:true_valid] : false
+              @false_valid = args[:false_valid] ? args[:false_valid] : false
+              @assumed_value = args[:assumed_value] ? args[:assumed_value] : false
+              binary_consistency(@true_valid, @false_valid)
+            end
+
+            def true_valid=(true_valid)
+              binary_consistency(true_valid, @false_valid)
+              @true_valid = true_valid
+            end
+
+            def false_valid=(false_valid)
+              binary_consistency(@true_valid,false_valid)
+              @false_valid = false_valid 
+            end
+
+            def valid_value?
+              
+            end
+
+            def default_value(a_value = nil)
+              if a_value == nil
+                @true_valid
+              else
+                (a_value && @true_valid) || (!a_value && @false_valid) 
+              end
+            end
+
+            private 
+
+            def binary_consistency(true_valid, false_valid)
+              if !true_valid && !false_valid
+                raise ArgumentError, "Either true_valid or false_valid must be true"
+              end
+            end
+          end # of C_Boolean
+
+          class C_STRING < C_PRIMITIVE
+            attr_accessor :list, :assumed_value, :list_open, :pattern
+
+            def initialize(args = { })
+              @list, @assumed_value, @list_open, @pattern = args[:list], args[:assumed_value], args[:list_open], args[:pattern]
+            end
+          end
+
+          class C_INTEGER < C_PRIMITIVE
+            attr_accessor :list, :range, :assumed_value
+
+            def initialize(args = { })
+              @list, @range, @assumed_value = args[:list], args[:range], args[:assumed_value]
+            end
+
+            def self.create(args = {})
+              c_primitive = new(args)
+
+              if block_given?
+                yield c_primitive
+              end
+              return c_primitive
+            end
+          end
+
+          class C_REAL < C_PRIMITIVE
+            attr_accessor :list, :range, :assumed_value
+
+            def initialize(args = { })
+              @list, @range, @assumed_value = args[:list], args[:range], args[:assumed_value]
+            end
+          end
+
+          class C_TIME < C_PRIMITIVE
+            attr_accessor :assumed_value, :milli_second_validity, :minute_validity, :range, :second_validity, :timezone_validity
+            def initialize(args = { })
+              @assumed_value, @milli_second_validity, @minute_validity, @month_validity, @range, @second_validity, @timezone_validity = args[:assumed_value], args[:milli_second_validity], args[:minute_validity], args[:range], args[:second_validity], args[:timezone_validity]
+            end
+          end
+
+          class C_DATE < C_PRIMITIVE
+            attr_accessor :assumed_value, :day_validity, :hour_validity, :month_validity, :range, :timezone_validity
+            def initialize(args = { })
+              @assumed_value, @day_validity, @hour_validity,  @month_validity, @range,  @timezone_validity = args[:assumed_value], args[:day_validity], args[:hour_validity], args[:month_validity], args[:range], args[:timezone_validity]
+            end
+          end
+
+          class C_DATE_TIME < C_PRIMITIVE
+            attr_accessor :assumed_value, :day_validity, :hour_validity, :milli_second_validity, :minute_validity, :month_validity, :range, :second_validity, :timezone_validity
+            def initialize(args = { })
+              @assumed_value, @day_validity, @hour_validity, @milli_second_validity, @minute_validity, @month_validity, @range, @second_validity, @timezone_validity = args[:assumed_value], args[:day_validity], args[:hour_validity], args[:milli_second_validity], args[:minute_validity], args[:month_validity], args[:range], args[:second_validity], args[:timezone_validity]
+            end
+          end
+
+          class C_DURATION < C_PRIMITIVE
+            attr_accessor :years_allowed, :months_allowed, :weeks_allowed, :days_allowed, :hours_allowed, :minutes_allowed, :seconds_allowed, :fractional_seconds_allowed, :range, :assumed_value
+
+            def initialize(args = { })
+              @years_allowed, @months_allowed, @weeks_allowed, @days_allowed, @hours_allowed, @minutes_allowed, @seconds_allowed, @fractional_seconds_allowed, @range, @assumed_value = args[:years_allowed], args[:months_allowed], args[:weeks_allowed], args[:days_allowed], args[:hours_allowed], args[:minutes_allowed], args[:seconds_allowed], args[:fractional_seconds_allowed], args[:range], args[:assumed_value]
+            end
+          end
+
+
+
+        end # of Primitive
+      end # of Constraint_Model
+    end # of Archetype
+  end # of AM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/am/archetype/ontology.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am/archetype/ontology.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am/archetype/ontology.rb	(revision 302)
@@ -0,0 +1,54 @@
+module OpenEhr
+  module AM
+    module Archetype
+      module Ontology
+        class ARCHETYPE_ONTOLOGY
+          attr_accessor :constraint_codes, :specialisation_depth
+          attr_accessor :term_attribute_names, :term_codes
+          attr_accessor :terminologies_available
+
+          def constraint_binding(a_terminology, a_code)
+          end
+
+          def constraint_definition(a_lang, a_code)
+          end
+
+          def has_language?(a_lang)
+          end
+
+          def has_terminology?(a_terminology)
+          end
+
+          def term_binding(a_terminology, a_code)
+          end
+
+          def term_definition(a_lang, a_code)
+          end
+        end
+
+        class ARCHETYPE_TERM
+          attr_accessor :code, :items
+
+          def initialize(args = { })
+                         
+            @code = if args[:code]
+                      args[:code]
+                    else
+                      raise ArgumentError, "Code is empty"
+                    end
+            @items = if args[:items]
+                       args[:items]
+                     else
+                       raise ArgumentError, "Items is empty"
+                     end
+          end
+
+          def keys
+            @items.keys
+          end
+        end
+      end # end of Ontology
+    end # end of Archetype
+  end # end of AM
+end # end of OpenEHR
+
Index: ruby/branches/TRY-open_ehr_gem/am/archetype/validity_kind.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am/archetype/validity_kind.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am/archetype/validity_kind.rb	(revision 302)
@@ -0,0 +1,20 @@
+module OpenEhr
+  module AM
+    module Archetype
+      class VALIDITY_KIND
+        attr_accessor :value
+        MANDATORY = 1001
+        OPTIONAL = 1002
+        DISALLOWED = 1003
+        
+        def initialize(arg)
+          @value = arg
+        end
+        
+        def valid_validity
+          
+        end
+      end
+    end # of Archetype
+  end # of AM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/am/open_ehr_profile/data_types/basic.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am/open_ehr_profile/data_types/basic.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am/open_ehr_profile/data_types/basic.rb	(revision 302)
@@ -0,0 +1,29 @@
+module OpenEhr
+  module AM
+    module OpenEHR_Profile
+      module DataTypes
+        module Basic
+          class C_DV_STATE
+          end
+
+          class STATE_MACHINE
+          end
+
+          class STATE
+          end
+
+          class TERMINAL_STATE < STATE
+          end
+
+          class NON_TERMINAL_STATE < STATE
+          end
+
+          class TRANSITION
+          end
+        end
+
+        
+      end # of Data_Types
+    end # of OpenEHR Profile
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/am/open_ehr_profile/data_types/quantity.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am/open_ehr_profile/data_types/quantity.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am/open_ehr_profile/data_types/quantity.rb	(revision 302)
@@ -0,0 +1,19 @@
+module OpenEhr
+  module AM
+    module OpenEHR_Profile
+      module DataTypes
+
+        module Quantity
+          class C_DV_QUANTITY < OpenEhr::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE
+          end
+          
+          class C_DV_ORDINAL < OpenEhr::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE
+          end
+
+          class C_QUANTITY_ITEM
+          end
+        end
+      end # of Data_Types
+    end # of OpenEHR Profile
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/am/open_ehr_profile/data_types/text.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/am/open_ehr_profile/data_types/text.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/am/open_ehr_profile/data_types/text.rb	(revision 302)
@@ -0,0 +1,12 @@
+module OpenEhr
+  module AM
+    module OpenEHR_Profile
+      module DataTypes
+        module Text
+          class C_CODE_PHASE < OpenEhr::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE
+          end
+        end
+      end # of Data_Types
+    end # of OpenEHR Profile
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/assumed_library_types.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/assumed_library_types.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/assumed_library_types.rb	(revision 302)
@@ -0,0 +1,589 @@
+# This module is related to the ticket #36
+require 'date'
+require 'time'
+
+module OpenEHR
+  module AssumedLibraryTypes
+    class Any < Object
+      
+    end # of Any
+
+    class Interval < Any
+      attr_reader :lower, :upper
+      
+      def initialize(args = {})
+        check_lower_upper(args[:lower], args[:upper])
+        self.lower_included = args[:lower_included]
+        self.upper_included = args[:upper_included]
+      end
+
+      def lower=(lower)
+        check_lower_upper(lower, @upper)
+      end
+
+      def upper=(upper)
+        check_lower_upper(@lower, upper)
+      end
+
+      def lower_included?
+        return @lower_included
+      end
+
+      def lower_included=(lower_included)
+        if (lower == nil) && (lower_included != nil)
+          raise ArgumentError, "lower is not set"
+        end
+        @lower_included = lower_included
+      end
+      
+      def lower_unbounded?
+        return @lower.nil?
+      end
+
+      def upper_included?
+        return @upper_included
+      end
+
+      def upper_included=(upper_included)
+        if (@upper.nil?) && (upper_included != nil)
+          raise ArgumentError, "upper is not set"
+        end
+        @upper_included = upper_included
+      end
+
+      def upper_unbounded?
+        return @upper.nil?
+      end
+
+      def has?(value)
+        if ((@lower.nil?||@lower < value||((@lower_included == true) && (@lower == value)))&&
+            (@upper.nil?||value < @upper||((@upper_included == true) && (@upper == value))))
+          true
+        else
+          false
+        end
+      end
+
+      private
+
+      def check_lower_upper(lower, upper)
+        if lower.nil? && upper.nil?
+          raise ArgumentError, "Either lower or upper must be assigned"
+        end
+        unless (lower.nil? || upper.nil?)
+          if lower > upper
+            raise ArgumentError, "Upper must be larger than lower."
+          end
+        end
+        @lower = lower
+        @upper = upper
+      end
+    end # end of Interval
+  
+    class TimeDefinitions < Any
+      DAYS_IN_LEAP_YEAR = 366
+      DAYS_IN_WEEK = 7
+      DAYS_IN_YEAR = 365
+      HOURS_IN_DAY = 24
+      MAX_DAYS_IN_MONTH = 31
+      MAX_DAYS_IN_YEAR = 366
+      MINUTES_IN_HOUR = 60
+      MONTH_IN_YEAR = 12
+      NOMINAL_DAYS_IN_MONTH = 30.42
+      NOMINAL_DAYS_IN_YEAR = 365.24
+      SECONDS_IN_MINUTE = 60
+
+      def self.valid_year?(year)
+        return !year.nil? && year >= 0
+      end
+
+      def self.valid_day?(y, m, d)
+        unless y.nil? || m.nil? || d.nil?
+          return Date.valid_date?(y,m,d)
+        end
+        if (y.nil?) || (m.nil? && !d.nil?)
+          return false
+        end
+        return self.valid_year?(y) && self.valid_month?(m)
+      end
+
+      def self.valid_hour?(h,m = nil, s = nil)
+        if h.nil?
+          return false
+        end
+        if !m.nil? and !valid_minute?(m)
+          return false
+        end
+        if !s.nil? and (!m.nil? and !valid_second?(s))
+          return false
+        end
+        (h >= 0 and h < HOURS_IN_DAY) or (h == HOURS_IN_DAY and m == 0 and s == 0)
+      end
+
+      def self.valid_minute?(mi)
+        mi >= 0 and mi < MINUTES_IN_HOUR
+      end
+
+      def self.valid_second?(s)
+        s >= 0 and s < SECONDS_IN_MINUTE
+      end
+
+      def self.valid_month?(mo)
+        mo >= 1 and mo <= MONTH_IN_YEAR
+      end
+    end # end of TimeDefinitions
+
+    module ISO8601DateModule
+      attr_reader :year, :month, :day
+
+      def year=(year)
+        unless ISO8601Date.valid_year?(year)
+          raise ArgumentError, "Year is not valid"
+        end
+        @year = year
+      end
+
+      def month=(month)
+        raise ArgumentError, "Month is not valid" unless month.nil? or ISO8601Date.valid_month?(month)
+        @month = month
+      end
+
+      def day=(day)
+        
+        raise ArgumentError, "Day is not valid" unless day.nil? or ISO8601Date.valid_day?(@year, @month, day)
+        @day = day
+      end
+
+      def as_string
+        if (!@year.nil? and !@month.nil? and !@day.nil?)
+          Date.new(@year, @month, @day).to_s
+        elsif (!@year.nil? and !@month.nil? and @day.nil?)
+          Date.new(@year, @month).to_s[0,7]
+        elsif (!@year.nil? and @month.nil? and @day.nil?)
+          Date.new(@year).to_s[0,4]
+        end          
+      end
+
+      def month_unknown?
+        @month.nil?
+      end
+
+      def day_unknown?
+        @day.nil?
+      end
+
+      def is_extended?
+        true
+      end
+
+      def is_partial?
+        month_unknown? or day_unknown?
+      end
+
+      protected
+      def leapyear?(year)
+        case
+        when year % 400 == 0: true
+        when year % 100 == 0: false
+        else year % 4 == 0
+        end
+      end
+    end
+
+    class ISO8601Date < TimeDefinitions
+      include ISO8601DateModule
+      def initialize(string)
+        /(\d{4})(?:-(\d{2})(?:-(\d{2})?)?)?/ =~ string
+        if $1.nil?
+          raise ArgumentError, 'data invalid'
+        else
+          self.year = $1.to_i
+        end
+        if $2.nil?
+          self.month = nil
+        else
+          self.month = $2.to_i
+        end
+        if $3.nil?
+          self.day = nil
+        else
+          self.day = $3.to_i
+        end
+      end
+
+      def self.valid_iso8601_date?(string)
+        begin
+          Date.parse(string)
+        rescue
+          return false
+        end
+        true
+      end
+    end # end of ISO8601_DATE
+
+    module ISO8601TimeModule
+      attr_reader :hour, :minute, :second, :fractional_second, :timezone
+
+      def hour=(hour)
+        unless ISO8601Time.valid_hour?(hour, @minute, @second)
+          raise ArgumentError, "hour is not valid"
+        end
+        @hour = hour
+      end
+
+      def minute_unknown?
+        @minute.nil?
+      end
+
+      def minute=(minute)
+        raise ArgumentError, "minute is not valid" if !minute.nil? and !ISO8601Time.valid_minute?(minute)
+        @minute = minute
+      end
+
+      def second_unknown?
+        @second.nil?
+      end
+
+      def second=(second)
+        raise ArgumentError, "minute not defined" if @minute.nil? and !second.nil?
+        raise ArgumentError, "second is not valid" if !second.nil? and !ISO8601Time.valid_second?(second)
+        @second = second
+      end
+
+      def fractional_second=(fractional_second)
+        raise ArgumentError, "minute not defined" if minute_unknown? and !fractional_second.nil?
+        raise ArgumentError, "second not defined" if second_unknown? and !fractional_second.nil?
+        if !fractional_second.nil? &&
+            (fractional_second < 0.0 || fractional_second >= 1.0)
+          raise ArgumentError, 'fractional second should be between 0.0 - 1.0'
+        end
+        @fractional_second = fractional_second
+      end
+
+      def has_fractional_second?
+        return !@fractional_second.nil?
+      end
+
+      def timezone=(timezone)
+        unless timezone.nil? or timezone == 'Z'
+          if /[+-](\d{2}):?(\d{2})/ =~ timezone
+            @timezone = timezone
+          else
+            raise ArgumentError, "timezone invalid"
+          end
+        else
+          @timezone = nil
+        end
+      end
+
+      def is_decimal_sign_comma?
+        false
+      end
+
+      def is_extended?
+        true
+      end
+
+      def is_partial?
+        second_unknown? or minute_unknown?
+      end
+
+      def as_string
+        s = sprintf("%02d", @hour)
+        if !@minute.nil?
+          s += ":" + sprintf("%02d",@minute)
+          if !@second.nil?
+            s += ":" + sprintf("%02d", @second)
+            if !@fractional_second.nil?
+              s += "." + @fractional_second.to_s[2..-1]
+              if !@timezone.nil?
+                s += @timezone
+              end
+            end
+          end
+        end
+        return s
+      end
+    end
+
+    class ISO8601Time < TimeDefinitions
+      include ISO8601TimeModule
+      def initialize(string)
+        /(\d{2}):?(\d{2})?(:?)(\d{2})?((\.|,)(\d+))?(Z|([+-](\d{2}):?(\d{2})))?/ =~ string
+        if $2.nil?
+          self.minute = nil
+        else
+          self.minute = $2.to_i
+        end
+        if $4.nil?
+          self.second = nil
+        else
+          self.second = $4.to_i
+        end
+        if $1.nil?
+          raise ArgumentError, 'data invalid'
+        else
+          self.hour = $1.to_i
+        end
+        if $7.nil?
+          self.fractional_second = nil
+        else
+          self.fractional_second = ("0." + $7).to_f
+        end
+        if $8.nil?
+          self.timezone = nil
+        else
+          self.timezone = $8
+        end
+      end
+
+      def self.valid_iso8601_time?(s)
+        if /^(\d{2}):?(\d{2})?(:?)(\d{2})?((\.|,)(\d+))?(Z|([+-](\d{2}):?(\d{2})))?$/ =~ s
+# ISO 8601 regular expression by H. Yuki
+#  http://digit.que.ne.jp/work/wiki.cgi?Perl%E3%83%A1%E3%83%A2%2FW3C%E5%BD%A2%E5%BC%8F%E3%81%AE%E6%97%A5%E6%99%82%E3%81%AE%E8%A7%A3%E6%9E%90
+# (\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d))?)?(Z|([+-]\d{2}):(\d{2}))?)?)?)?
+          hh = $1; mm = $2; ss = $4; msec = $7; tz = $8
+          if hh.to_i == HOURS_IN_DAY and (mm.nil? or mm.to_i == 0) and (ss.nil? or ss.to_i == 0) and (msec.nil? or msec.to_i==0)
+            return true
+          end
+          if hh.nil? or (hh.to_i < 0 or hh.to_i >= HOURS_IN_DAY)
+            return false
+          end
+          if !mm.nil? 
+            if !self.valid_minute?(mm.to_i)
+              return false
+            end
+          end
+          if !ss.nil? 
+            if !self.valid_second?(ss.to_i)
+              return false
+            end
+          end
+          if !tz.nil? and tz != "Z"
+            if /[+-](\d{2}):?(\d{2})/ =~ tz
+              h = $1; m = $2
+              if h.to_i < 0 or h.to_i >= HOURS_IN_DAY
+                return false
+              end
+              if m.to_i < 0 or m.to_i >= MINUTES_IN_HOUR
+                return false
+              end
+            end
+          end
+          return true
+        else
+          return false
+        end
+      end
+    end # end of ISO8601_TIME
+
+    module ISO8601DateTimeModule
+      include ISO8601DateModule, ISO8601TimeModule
+      def as_string
+        if (!@year.nil? and !@month.nil? and !@day.nil?)
+          s = Date.new(@year, @month, @day).to_s
+        elsif (!@year.nil? and !@month.nil? and @day.nil?)
+          return Date.new(@year, @month).to_s[0,7]
+        elsif (!@year.nil? and @month.nil? and @day.nil?)
+          return Date.new(@year).to_s[0,4]
+        end
+        unless hour.nil?
+          s += sprintf("T%02d", @hour)
+          unless @minute.nil?
+            s += ":" + sprintf("%02d",@minute)
+            unless @second.nil?
+              s += ":" + sprintf("%02d", @second)
+              unless @fractional_second.nil?
+                s += "." + @fractional_second.to_s[2..-1]
+                unless @timezone.nil?
+                  s += @timezone
+                end
+              end
+            end
+          end
+        end
+        return s
+      end
+    end
+
+    class ISO8601DateTime < ISO8601Date
+      include ISO8601DateTimeModule
+      def initialize(string)
+        unless /(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|([+-]\d{2}):?(\d{2}))?)?)?)?/ =~ string
+          raise ArgumentError, 'format invalid'
+        else
+          self.year = $1.to_i
+        end
+        if $2.nil?
+          self.month = nil
+        else
+          self.month = $2.to_i
+        end
+        if $3.nil?
+          self.day = nil
+        else
+          self.day = $3.to_i
+        end
+        if $5.nil?
+          self.minute = nil
+        else
+          self.minute = $5.to_i
+        end
+        if $6.nil?
+          self.second = nil
+        else
+          self.second = $6.to_i
+        end
+        if $4.nil?
+          self.hour = nil
+        else
+          self.hour = $4.to_i
+        end
+        if $7.nil? or $7.empty?
+          self.fractional_second = nil
+        else
+          self.fractional_second = ("0."+$7).to_f
+        end
+        if $8.nil?
+          self.timezone = nil
+        else
+          self.timezone = $9+$10
+        end
+      end
+    end
+  
+    class ISO8601Timezone
+      attr_accessor :sign, :hour, :minute
+
+      def initialize(string)
+        unless /(Z|(([+-])(\d{2}):?(\d{2})))/ =~ string
+          raise ArgumentError, 'invaild format'
+        end
+        if $1 == 'Z'
+          @sign, @hour, @minute = +1, 0, 0
+        else
+          @sign, @hour, @minute = ($3+'1').to_i, $4.to_i , $5.to_i
+        end
+      end
+
+      def is_gmt?
+        @sign == +1 and @hour == 0 and @minute == 0
+      end
+
+      def as_string
+        if @sign == +1
+          s = "+"
+        elsif @sign == -1
+          s = "-"
+        end
+        sprintf("%s%02d%02d", s, @hour, @minute)
+      end
+    end # end of ISO8601Timezone
+
+    module ISO8601DurationModule
+      attr_reader :years, :months, :weeks, :days
+      attr_reader :hours, :minutes, :seconds, :fractional_second
+
+      def years=(years)
+        unless years.nil? || years >= 0
+          raise ArgumentError, 'years must be above zero'
+        end
+        @years = years
+      end
+
+      def months=(months)
+        unless months.nil? || months >= 0
+          raise ArgumentError, 'months must be above zero'
+        end
+        @months = months
+      end
+
+      def weeks=(weeks)
+        unless weeks.nil? || weeks >= 0
+          raise ArgumentError, 'weeks must be above zero'
+        end
+        @weeks = weeks
+      end
+
+      def days=(days)
+        unless days.nil? || days >= 0
+          raise ArgumentError, 'days must be above zero'
+        end
+        @days = days
+      end
+
+      def hours=(hours)
+        unless hours.nil? || hours >= 0
+          raise ArgumentError, 'hours must be above zero'
+        end
+        @hours = hours
+      end
+
+      def minutes=(minutes)
+        unless minutes.nil? || minutes >= 0
+          raise ArgumentError, 'minutes must be above zero'
+        end
+        @minutes = minutes
+      end
+
+      def seconds=(seconds)
+        unless seconds.nil? || seconds >= 0
+          raise ArgumentError, 'seconds must be above zero'
+        end
+        @seconds = seconds
+      end
+
+      def fractional_second=(fractional_second)
+        unless fractional_second.nil? || (fractional_second >= 0 && fractional_second < 1.0)
+          raise ArgumentError, 'fractional_second must be between 0.0 and 1.0'
+        end
+        @fractional_second = fractional_second
+      end
+
+      def as_string
+        str = 'P'
+        unless @years.nil?
+          str += @years.to_s + 'Y'
+        end
+        unless @months.nil?
+          str += @months.to_s + 'M'
+        end
+        unless @weeks.nil?
+          str += @weeks.to_s + 'W'
+        end
+        unless @days.nil?
+          str += @days.to_s + 'D'
+        end
+        unless @hours.nil?
+          str += 'T' + @hours.to_s + 'H'
+          unless @minutes.nil?
+            str += @minutes.to_s + 'M'
+            unless @seconds.nil?
+              str += @seconds.to_s
+              unless @fractional_second.nil?
+                str += @fractional_second.to_s[1 .. -1]
+              end
+              str += 'S'
+            end
+          end
+        end
+        return str
+      end
+    end
+
+    class ISO8601Duration < TimeDefinitions
+      include ISO8601DurationModule
+      def initialize(str)
+        /^P((\d+)Y)?((\d+)M)?((\d+)W)?((\d)D)?(T((\d+)H)?((\d+)M)?((\d+)(\.\d+)?S)?)?$/ =~ str
+        self.years = $2.to_i
+        self.months = $4.to_i
+        self.weeks = $6.to_i
+        self.days = $8.to_i
+        self.hours = $11.to_i
+        self.minutes = $13.to_i
+        self.seconds = $15.to_i
+        self.fractional_second = $16.to_f
+      end
+    end # end of ISO8601Duration
+  end # end of Assumed_Types
+end # end of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/common/archetyped.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/common/archetyped.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/common/archetyped.rb	(revision 302)
@@ -0,0 +1,184 @@
+# This module is based on the UML,
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109318114715_211173_0Report.html
+# Ticket refs #65
+module OpenEHR
+  module RM
+    module Common
+      module Archetyped
+        module LocaterConstants
+          CURRENT_TRANSACTION_ID = "current"
+          FRAGMENT_SEPARATOR = "#"
+          CONTENT_PATH_SEPARATOR = "|"
+          ORGANIZER_PATH_SEPARATOR = "/"
+          MULTIPART_ID_DELIMITER = "::"
+        end
+
+        class Pathable
+          attr_accessor :parent
+
+          def initialize(args = { })
+            self.parent = args[:parent]
+          end
+
+          def item_at_path(path)
+            raise NotImplementedError, "item_at_path must be implemented"
+          end
+
+          def items_at_path(path)
+            raise NotImplementedError, "items_at_path must be implemented"
+          end
+
+          def path_exists?(path)
+            raise NotImplementedError, "path_exists? must be implemented"
+          end
+
+          def path_of_item(item)
+            raise NotImplementedError, "path_of_item must be implemented"
+          end
+
+          def path_unique?(path)
+            raise NotImplementedError, "path_unique? must be implemented"
+          end
+        end
+
+        class Locatable < Pathable
+          include LocaterConstants
+          attr_reader :archetype_node_id, :name, :links
+          attr_accessor :uid, :archetype_details, :feeder_audit
+
+          def initialize(args = { })
+            super(args)
+            self.archetype_node_id = args[:archetype_node_id]
+            self.name = args[:name]
+            self.links = args[:links]
+            self.uid = args[:uid]
+            self.archetype_details = args[:archetype_details]
+            self.feeder_audit = args[:feeder_audit]
+          end
+          
+          def archetype_node_id=(archetype_node_id)
+            if archetype_node_id.nil? or archetype_node_id.empty?
+              raise ArgumentError, 'archetype_node_id should not be nil'
+            end
+            @archetype_node_id = archetype_node_id
+          end
+
+          def name=(name)
+            raise ArgumentError, 'name should not be empty' if name.nil? or name.value.empty?
+            @name = name
+          end
+          def links=(links)
+            raise ArgumentError, "links shoud not be empty" if !links.nil? and links.empty?
+            @links = links
+          end
+
+          def item_at_path(path)
+            if !@path.nil?
+              if @path == ""
+                raise ArgumentError, "path is not valid"
+              end
+            end
+          end
+
+          def items_at_path(path)
+            raise NotImplementError, "items_at_path must be implemented"
+          end
+
+          def path_exists?
+            raise NotImplementError, "path_exists? must be implemented"
+          end
+
+          def path_unique
+            raise NotImplementError, "path_unique must be implemented"
+          end
+
+          def concept
+          end
+
+          def is_archetype_root?
+            !archetype_details.nil?
+          end
+        end
+
+        class Archetyped
+          attr_reader :archetype_id, :rm_version
+          attr_accessor :template_id
+          def initialize(archetype_id, rm_version, template_id = nil)            
+            self.archetype_id = archetype_id
+            self.rm_version = rm_version
+            self.template_id = template_id
+          end
+          def archetype_id=(archetype_id)
+            raise ArgumentError, "invalid archetype_id" if archetype_id.nil?
+            @archetype_id = archetype_id
+          end
+          def rm_version=(rm_version)
+            raise ArgumentError, "invalid rm_version" if rm_version.nil? or rm_version.empty?
+            @rm_version = rm_version
+          end
+        end
+
+        class Link
+          attr_reader :meaning, :target, :type
+          def initialize(meaning, target, type)
+            self.meaning = meaning
+            self.target = target
+            self.type = type
+          end
+          def meaning=(meaning)
+            raise ArgumentError, "meaning should not be nil" if meaning.nil?
+            @meaning = meaning
+          end
+          def target=(target)
+            raise ArgumentError, "target should not be nil" if target.nil?
+            @target = target
+          end
+          def type=(type)
+            raise ArgumentError, "type should not be nil" if type.nil?
+            @type = type
+          end
+        end # of Link
+
+        class FeederAudit
+          attr_reader :originating_system_audit
+          attr_accessor :originating_system_item_ids, :feeder_system_audit,
+                        :feeder_system_item_ids, :original_content
+
+          def initialize(args = { })
+            self.originating_system_audit = args[:originating_system_audit]
+            self.originating_system_item_ids = args[:originating_system_item_ids]
+            self.feeder_system_audit = args[:feeder_system_audit]
+            self.feeder_system_item_ids = args[:feeder_system_item_ids]
+            self.original_content = args[:original_content]
+          end
+
+          def originating_system_audit=(originating_system_audit)
+            if originating_system_audit.nil?
+              raise ArgumentError, 'originating_system_audit must be not nil'
+            end
+            @originating_system_audit = originating_system_audit
+          end
+        end # of FeederAudit
+
+        class FeederAuditDetails
+          attr_reader :system_id
+          attr_accessor :provider, :location, :time, :subject, :version_id
+
+          def initialize(args ={ })
+            self.system_id = args[:system_id]
+            self.provider = args[:provider]
+            self.location = args[:location]
+            self.time = args[:time]
+            self.subject = args[:subject]
+            self.version_id = args[:version_id]
+          end
+
+          def system_id=(system_id)
+            raise ArgumentError, 'system_id invalid' if system_id.nil? or system_id.empty?
+            @system_id = system_id
+          end
+        end # of FeederAudit_Details
+      end # of Archetyped
+    end # of Common
+  end # of RM
+end # OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/common/change_control.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/common/change_control.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/common/change_control.rb	(revision 302)
@@ -0,0 +1,324 @@
+# This module is based on the UML,
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109326589721_134411_997Report.html
+# Ticket refs #64
+
+module OpenEhr
+  module RM
+    module Common
+      module ChangeControl
+        class Contribution
+          attr_reader :uid, :versions, :audit
+
+          def initialize(args = { })
+            self.uid = args[:uid]
+            self.versions = args[:versions]
+            self.audit = args[:audit]
+          end
+
+          def uid=(uid)
+            if uid.nil?
+              raise ArgumentError, "uid should not be nil."
+            end
+            @uid = uid
+          end
+
+          def versions=(versions)
+            unless versions.nil?
+              if versions.empty?
+                raise ArgumentError, 'versions shoud not be nil or empty.'
+              end
+            end
+            @versions = versions
+          end
+
+          def audit=(audit)
+            if audit.nil?
+              raise ArgumentError, 'audit should not be nil.'
+            end
+            if audit.description.nil?
+              raise ArgumentError, 'audit.description should not be nil.'
+            end
+            @audit = audit
+          end
+        end
+
+        class Version
+          attr_reader :uid, :preceding_version_uid, :lifecycle_state,
+                      :commit_audit, :contribution
+          attr_accessor :data, :signature
+
+          def initialize(args = { })
+            self.uid = args[:uid]
+            self.preceding_version_uid = args[:preceding_version_uid]
+            self.data = args[:data]
+            self.lifcycle_state = args[:lifecycle_state]
+            self.commit_audit = args[:commit_audit]
+            self.contribution = args[:contribution]
+            self.signature = args[:signature]
+          end
+
+          def uid=(uid)
+            raise ArgumentError, "uid should not be nil" if uid.nil?
+            @uid = uid
+          end
+
+          def preceding_version_uid=(preceding_version_uid)
+            if (!preceding_version_uid.nil?) ==  @uid.version_tree_id.is_first?
+              raise ArgumentError, 'preceding version is invalid'
+            end
+            @preceding_version_uid = preceding_version_uid
+          end
+
+# remove hard coding of lifecycle
+          def lifcycle_state=(lifecycle_state)
+            if lifecycle_state.nil? ||
+                !%w[532 553 523].include?(
+                              lifecycle_state.defining_code.code_string)
+              raise ArgumentError, 'invalid lifecycle_state'
+            end
+            @lifecycle_state = lifecycle_state
+          end
+
+          def commit_audit=(commit_audit)
+            if commit_audit.nil?
+              raise ArgumentError,'commit_audit is mandatory'
+            end
+            @commit_audit = commit_audit
+          end
+
+          def contribution=(contribution)
+            raise ArgumentError, "contribution should not be nil" if contribution.nil? or contribution.type.empty?
+            @contribution = contribution
+          end
+
+          def owner_id
+            return HierObjectId.new(@uid.object_id.value)
+          end
+
+          def is_branch?
+            return @uid.is_branch?
+          end
+
+          def canonical_form
+            raise NotImplementedError, 'canonical form not implemented'
+          end
+        end
+
+        class ImportedVersion < Version
+          attr_reader :item
+
+          def initialize(args = { })
+            self.item = args[:item]
+            super(:uid => @item.uid,
+                  :preceding_version_uid => @item.preceding_version_uid,
+                  :data => @item.data, :commit_audit=> args[:commit_audit],
+                  :commit_audit => args[:commit_audit],
+                  :contribution => args[:contribution],
+                  :lifecycle_state => @item.lifecycle_state,
+                  :signature => args[:signature])
+                  
+          end
+
+          def item=(item)
+            raise ArgumentError, 'item is mandatory' if item.nil?
+            @item = item
+          end
+        end
+
+        class OriginalVersion < Version
+          attr_reader :attestations, :other_input_version_uids
+
+          def initialize(args = { })
+            super(args)
+            self.attestations = args[:attestations]
+            self.other_input_version_uids = args[:other_input_version_uids]
+          end
+
+          def attestations=(attestations)
+            if attestations.nil? || attestations.empty?
+              raise ArgumentError, 'attestations is mandatory'
+            end
+            @attestations = attestations
+          end
+
+          def other_input_version_uids=(other_input_version_uids)
+            if !other_input_version_uids.nil? && other_input_version_uids.empty?
+              raise ArgumentError, 'invaild other_input_version_uids'
+            end
+            @other_input_version_uids = other_input_version_uids
+          end
+
+          def is_merged?
+# Java implementation has is_merged attribute, Eiffel implementation does
+# nothing
+          end
+        end
+
+        class VersionedObject
+          attr_reader :uid, :owner_id, :time_created, :all_versions
+
+          def initialize(args = { })
+            self.uid = args[:uid]
+            self.owner_id = args[:owner_id]
+            self.time_created = args[:time_created]
+            self.all_versions = args[:all_versions]
+          end
+
+          def uid=(uid)
+            raise ArgumentError, 'uid is mandatory' if uid.nil?
+            @uid = uid
+          end
+
+          def owner_id=(owner_id)
+            raise ArgumentError, 'owner_id is mandatory' if owner_id.nil?
+            @owner_id = owner_id
+          end
+
+          def time_created=(time_created)
+            if time_created.nil?
+              raise ArgumentError, 'time_created is mandatory'
+            end
+            @time_created = time_created
+          end
+
+          def all_versions=(all_versions)
+            if all_versions.nil? || all_versions.size < 0
+              raise ArgumentError, 'version count invalid'
+            end
+            @all_versions = all_versions
+          end
+
+          def all_version_ids
+            ids = []
+            @all_versions.each{|id| ids << id.uid}
+            return ids
+          end
+
+          def version_count
+            return all_versions.size
+          end
+
+          def has_version_id?(a_ver_id)
+            raise ArgumentError, 'argument is mandatory' if a_ver_id.nil?
+            return self.all_version_ids.include?(a_ver_id)
+          end
+
+          def is_original_version?(a_ver_id)
+            if a_ver_id.nil? || !self.has_version_id?(a_ver_id)
+              raise ArgumentError, 'invalid a_ver_id'
+            end
+            return @all_versions[self.all_version_ids.index(a_ver_id)].instance_of? OriginalVersion
+          end
+
+          def has_version_at_time?(a_time)
+            raise ArgumentError, 'argument mandatory' if a_time.nil?
+            @all_versions.each do |ver|
+              if ver.commit_audit.time_committed == a_time
+                return true
+              end
+            end
+            return false
+          end
+
+          def version_with_id(a_ver_id)
+            if a_ver_id.nil? || !self.has_version_id?(a_ver_id)
+              raise ArgumentError, 'argument invalid'
+            end
+            return @all_versions[self.all_version_ids.index(a_ver_id)]
+          end
+
+          def version_at_time(a_time)
+            if a_time.nil? || !self.has_version_at_time?(a_time)
+              raise ArgumentError, 'argument invalid'
+            end
+            @all_versions.each do |ver|
+              if ver.commit_audit.time_committed == a_time
+                return ver
+              end
+            end
+          end
+
+          def latest_version
+            time_sorted_version = @all_versions.sort do |a,b|
+              a.commit_audit.time_committed <=> b.commit_audit.time_committed
+            end
+            return time_sorted_version.last
+          end
+
+          def latest_trunk_version
+            trunk_versions = [ ]
+            @all_versions.each do |ver|
+              if ver.uid.version_tree_id.trunk_version == '1'
+                trunk_versions << ver
+              end
+            end
+            sorted_trunk_version = trunk_versions.sort do |a,b|
+              a.commit_audit.time_committed <=> b.commit_audit.time_committed
+            end
+            return sorted_trunk_version.last
+          end
+
+          def trunk_lifecycle_state
+            return self.latest_trunk_version.lifecycle_state
+          end
+
+          def revision_history
+            revision_history_items = [ ]
+            @all_versions.each do |ver|
+              audits = [ ]
+              if ver.instance_of? OriginalVersion
+                audits << ver.attestations
+              end
+              audits << ver.commit_audit
+              revision_history_items << RevisionHistoryItem.new(
+                                          :audits => audits,
+                                          :version_id => ver.uid)
+            end
+            return RevisionHistory.new(revision_history_items)
+          end
+
+          def commit_original_version(args={ })
+            @all_versions << OriginalVersion.new(:uid => args[:uid],
+                                                  :preceding_version_uid => args[:preceding_version_uid],
+                                                  :contribution => args[:contribution],
+                                                  :commit_audit => args[:commit_audit],
+                                                  :lifecycle_state => args[:lifecycle_state],
+                                                  :data => args[:data],
+                                                  :attestations => args[:attestations],
+                                                  :signature => args[:signature])
+          end
+
+          def commit_original_merged_version(args = { })
+            @all_versions << OriginalVersion.new(:uid => args[:uid],
+                                                  :contribution => args[:contribution],
+                                              :preceding_version_uid => args[:preceding_version_uid],
+                                              :commit_audit => args[:commit_audit],
+                                              :lifecycle_state => args[:lifecycle_state],
+                                              :data => args[:data],
+                                              :attestations => args[:attestations],
+                                              :other_input_version_uids => args[:other_input_version_uids],
+                                              :signature => args[:signature])
+          end
+
+          def commit_imported_version(args = { })
+            @all_versions << ImportedVersion.new(:item => args[:item],
+                                                  :contribution => args[:contribution],
+                                                  :commit_audit => args[:commit_audit])
+          end
+
+          def commit_attestation(args = { })
+            if args[:attestation].nil?
+              raise ArgumentError, 'attestation is mandatory'
+            end
+            if self.has_version_id?(args[:uid]) && self.is_original_version?(args[:uid])
+              self.version_with_id(args[:uid]).attestations << args[:attestation]
+              self.version_with_id(args[:uid]).signature = args[:signature]
+            else
+              raise ArgumentError, 'uid invalid'
+            end
+          end
+        end
+      end # of ChangeControl
+    end # of Common
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/common/directory.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/common/directory.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/common/directory.rb	(revision 302)
@@ -0,0 +1,29 @@
+# This module is based on the UML,
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_1_76d0249_1140536622627_218703_7149Report.html
+# Ticket refs #63
+include OpenEHR::RM::DataTypes::Text
+module OpenEHR
+  module RM
+    module Common
+      module Directory
+        class Folder < OpenEHR::RM::Common::Archetyped::Locatable
+          attr_accessor :items
+          attr_reader :folders
+
+          def initialize(args = { })
+            super(args)
+            self.folders = args[:folders]
+            self.items = args[:items]
+          end
+
+          def folders=(folders)
+            raise ArgumentError, "empty subfolder" if !folders.nil? and folders.empty?
+            @folders = folders
+          end
+        end        
+        class VersionedFolder < OpenEHR::RM::Common::ChangeControl::VersionedObject
+        end
+      end # of Directory
+    end # of Common
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/common/generic.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/common/generic.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/common/generic.rb	(revision 302)
@@ -0,0 +1,195 @@
+# This module is a implementation of the bellow UML
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_1_76d0249_1140169202660_257304_813Report.html
+# Related to the ticket #62
+include OpenEhr::RM::Support::Identification
+include OpenEhr::RM::DataTypes::Basic
+module OpenEhr
+  module RM
+    module Common
+      module Generic
+        class AuditDetails
+          attr_reader :system_id, :committer, :time_committed, :change_type
+          attr_accessor :description
+
+          def initialize(args = { })
+            self.system_id = args[:system_id]
+            self.committer = args[:committer]
+            self.time_committed = args[:time_committed]
+            self.change_type = args[:change_type]
+            self.description = args[:description]
+          end
+
+          def system_id=(system_id)
+            if system_id.nil? or system_id.empty?
+              raise ArgumentError, 'system_id is mandatory'
+            end
+            @system_id = system_id
+          end
+
+          def committer=(committer)
+            raise ArgumentError, 'committer is mandatory' if committer.nil?
+            @committer = committer
+          end
+
+          def time_committed=(time_committed)
+            if time_committed.nil?
+              raise ArgumentError, 'time_commited is mandatory'
+            end
+            @time_committed = time_committed
+          end
+
+          def change_type=(change_type)
+            raise ArgumentError, 'change_type is mandatory' if change_type.nil?
+            @change_type = change_type
+          end
+        end
+
+        class RevisionHistory
+          attr_reader :items
+
+          def initialize(items)
+            self.items = items
+          end
+
+          def items=(items)
+            if items.nil? or items.empty?
+              raise ArgumentError, 'item(s) is/are mandatory'
+            end
+            @items  = items
+          end
+
+          def most_recent_version
+            return @items.last.version_id.value
+          end
+
+          def most_recent_version_time_committed
+            return @items.last.audits.first.time_committed.value
+          end
+        end # of RevisionHistory
+
+        class RevisionHistoryItem
+          attr_reader :version_id, :audits
+
+          def initialize(args = { })
+            self.version_id = args[:version_id]
+            self.audits = args[:audits]
+          end
+
+          def audits=(audits)
+            if audits.nil? or audits.empty?
+              raise ArgumentError, 'audits is mandatory'
+            end
+            @audits = audits
+          end
+
+          def version_id=(version_id)
+            raise ArgumentError, 'version_id is mandatory' if version_id.nil?
+            @version_id = version_id
+          end
+        end # of RevisionHistory_Item
+
+        class PartyProxy
+          attr_accessor :external_ref
+
+          def initialize(args = { })
+            self.external_ref = args[:external_ref]
+          end
+        end
+
+        class PartySelf < PartyProxy
+
+        end
+
+        class PartyIdentified < PartyProxy
+          attr_reader :name, :identifier
+          def initialize(args = { })
+            if args[:external_ref].nil? && args[:name].nil? &&
+                args[:identifier].nil?
+              raise ArgumentError, 'cannot identified'
+            end
+            super(:external_ref => args[:external_ref])
+            self.name = args[:name]
+            self.identifier = args[:identifier]
+          end
+
+          def name=(name)
+            if name.nil? && @external_ref.nil? && @identifier.nil?
+              raise ArgumentError, 'cannot identified'
+            end
+            raise ArgumentError, 'invaild name' unless name.nil? || !name.empty?
+            @name = name
+          end
+
+          def identifier=(identifier)
+            if @name.nil? && @external_ref.nil? && identifier.nil?
+              raise ArgumentError, 'cannot identified'
+            end
+            unless identifier.nil? || !identifier.empty?
+              raise ArgumentError, 'invaild identifier'
+            end
+            @identifier = identifier
+          end
+        end
+
+        class PartyRelated < PartyIdentified
+          attr_reader :relationship
+          def initialize(args = { })
+            super(args)
+            self.relationship = args[:relationship]
+          end
+
+          def relationship=(relationship)
+            if relationship.nil?
+              raise ArgumentError, 'relationship must not be nil'
+            end
+            @relationship = relationship
+          end
+        end
+
+        class Participation
+          attr_reader :performer, :function, :mode
+          attr_accessor :time
+
+          def initialize(args ={ })
+            self.performer = args[:performer]
+            self.function = args[:function]
+            self.mode = args[:mode]
+            self.time = args[:time]
+          end
+
+          def performer=(performer)
+            raise ArgumentError, 'performer is mandatory' if performer.nil?
+            @performer = performer
+          end
+
+          def function=(function)
+            raise ArgumentError, 'function is mandatory' if function.nil?
+            @function = function
+          end
+
+          def mode=(mode)
+            raise ArgumentError, 'mode is mandatory' if mode.nil?
+            @mode = mode
+          end
+        end
+
+        class Attestation < AuditDetails
+          attr_reader :reason
+          attr_accessor :proof, :items
+
+          def initialize(args = { })
+            super(args)
+            self.reason = args[:reason]
+            self.proof = args[:proof]
+            self.items = args[:items]
+          end
+
+          def reason=(reason)
+            raise ArgumentError, 'reason is mandatory' if reason.nil?
+            @reason = reason
+          end
+        end
+      end # of Generic
+    end # of Common
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/common/resource.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/common/resource.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/common/resource.rb	(revision 302)
@@ -0,0 +1,154 @@
+require 'set'
+module OpenEhr
+  module RM
+    module Common
+      module Resource
+        class AuthoredResource
+          attr_reader  :original_language, :translations
+          attr_accessor :description, :revision_history
+
+          def initialize(args = { })
+            self.original_language = args[:original_language]
+            self.translations = args[:translations]
+            self.revision_history = args[:revision_history]
+            self.description = args[:description]
+          end
+
+          def original_language=(original_language)
+            if original_language.nil?
+              raise ArgumentError, 'original language is mandatory'
+            end
+            @original_language = original_language
+          end
+
+          def translations=(translations)
+            if !translations.nil? && translations.empty?
+              raise ArgumentError, 'translation is empty'
+            end
+            @translations = translations
+          end
+
+          def current_version
+            @revision_history.most_recent_revision
+          end
+
+          def languages_available
+            return Set.new(@translations.keys)
+          end
+
+          def is_controlled?
+            return !@revision_history.nil?
+          end
+        end
+
+        class TranslationDetails
+          attr_reader :language, :author
+          attr_accessor :accreditation, :other_details
+
+          def initialize(args = {})
+            self.language = args[:language]
+            self.author = args[:author]
+            self.accreditation = args[:accreditation]
+            self.other_details = args[:other_details]
+          end
+
+          def language=(language)
+            raise ArgumentError, 'language is mandatory' if language.nil?
+            @language = language
+          end
+
+          def author=(author)
+            raise ArgumentError, 'author is mandatory' if author.nil?
+            @author = author
+          end
+        end
+
+        class ResourceDescription
+          attr_reader :original_author, :lifecycle_state, :details
+          attr_accessor :other_contributors, :resource_package_uri,
+                        :other_details, :parent_resource
+
+          def initialize(args = {})
+            self.original_author = args[:original_author]
+            self.lifecycle_state = args[:lifecycle_state]
+            self.details = args[:details]
+            self.other_contributors = args[:other_contributors]
+            self.resource_package_uri = args[:resource_package_uri]
+            self.other_details = args[:other_details]
+            self.parent_resource = args[:parent_resource]
+          end
+
+          def original_author=(original_author)
+            if original_author.nil? || original_author.empty?
+              raise ArgumentError, 'original_author is mandatory'
+            end
+            @original_author = original_author
+          end
+
+          def lifecycle_state=(lifecycle_state)
+            if lifecycle_state.nil? || lifecycle_state.empty?
+              raise ArgumentError, 'lifecycle_state is malformatted'
+            end
+            @lifecycle_state = lifecycle_state
+          end
+
+          def details=(details)
+            if details.nil? || details.empty?
+              raise ArgumentError, 'nil or empty details'
+            end
+            @details = details
+          end
+        end
+
+        class ResourceDescriptionItem
+          attr_reader :language, :purpose, :use, :misuse, :copyright
+          attr_accessor :keywords, :original_resource_uri, :other_details
+
+          def initialize(args = { })
+            self.language = args[:language]
+            self.purpose = args[:purpose]
+            self.keywords = args[:keywords]
+            self.use = args[:use]
+            self.misuse = args[:misuse]
+            self.copyright = args[:copyright]
+            self.original_resource_uri = args[:original_resource_uri]
+            self.other_details = args[:other_details]
+          end
+
+          def language=(language)
+            raise ArgumentError, 'language is mandatory' if language.nil?
+            @language = language
+          end
+
+          def purpose=(purpose)
+            if purpose.nil? || purpose.empty?
+              raise ArgumentError, 'purpose is mandatory'
+            end
+            @purpose = purpose
+          end
+
+          def use=(use)
+            if !use.nil? && use.empty?
+              raise ArgumentError, 'use is invalid'
+            end
+            @use = use
+          end
+
+          def misuse=(misuse)
+            if !misuse.nil? && misuse.empty?
+              raise ArgumentError, 'misuse is invalid'
+            end
+            @misuse = misuse
+          end
+
+          def copyright=(copyright)
+            if !copyright.nil? && copyright.empty?
+              raise ArgumentError, 'copyright is invalid'
+            end
+            @copyright = copyright
+          end
+        end
+      end # end of Resouce
+    end # end of module Common
+  end # end of module RM
+end # end of module OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/composition/content/entry.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/composition/content/entry.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/composition/content/entry.rb	(revision 302)
@@ -0,0 +1,23 @@
+module OpenEhr
+  module RM
+    module Content
+      module Entry
+        class Entry < Content_Item
+        end
+        class CareEntry < Entry
+        end
+        class Action < CareEntry
+          attr_accessor :description, :time
+          attr_accessor :ism_transition, :instruction_details
+          def initialize(description, time, ism_transition, instruction_details)
+            raise Exception.new("invalid argument") if description == nil || time == nil || ism_transition == nil
+            @description = description
+            @time = time
+            @ism_transition = ism_transition
+            @instruction_details = instruction_details if instruction_details != nil
+          end
+        end # end of Action
+      end # end of Entry
+    end # end of Content
+  end # end of RM
+end # end of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_structure.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_structure.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_structure.rb	(revision 302)
@@ -0,0 +1,20 @@
+# rm::data_structures
+# class DATA_STRUCTURE
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_1_76d0249_1140447518205_872539_864Report.html
+# refs #59
+
+module OpenEhr
+  module RM
+    module DataStructures
+      class DataStructure < OpenEhr::RM::Common::Archetyped::Locatable
+        def initialize(args = { })
+          super(args)
+        end
+
+        def as_hierarchy
+          raise NotImplementedError, "as_hirarchy must be implemented"
+        end
+      end
+    end # of Data_Structures
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_structures.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_structures.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_structures.rb	(revision 302)
@@ -0,0 +1,20 @@
+# rm::data_structures
+# class DATA_STRUCTURE
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_1_76d0249_1140447518205_872539_864Report.html
+# refs #59
+
+module OpenEHR
+  module RM
+    module DataStructures
+      class DataStructure < OpenEHR::RM::Common::Archetyped::Locatable
+        def initialize(args = { })
+          super(args)
+        end
+
+        def as_hierarchy
+          raise NotImplementedError, "as_hirarchy must be implemented"
+        end
+      end
+    end # of Data_Structures
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_structures/item_structure.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_structures/item_structure.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_structures/item_structure.rb	(revision 302)
@@ -0,0 +1,197 @@
+# rm::data_structures::item_structure
+# ItemStructure module
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109346709572_859750_3810Report.html
+# refs #54
+require 'set'
+include OpenEHR::RM::DataStructures
+module OpenEHR
+  module RM
+    module DataStructures
+      module ItemStructure
+        class ItemStructure < DataStructure
+        end
+
+        class ItemSingle < ItemStructure
+          attr_reader :item
+
+          def initialize(args = {})
+            super(args)
+            self.item = args[:item]
+          end
+
+          def as_hierarchy
+            return @item
+          end
+
+          def item=(item)
+            raise ArgumentError, 'item is mandatory' if item.nil?
+            @item = item
+          end
+        end
+
+        class ItemList < ItemStructure
+          attr_accessor :items
+
+          def initialize(args = {})
+            super(args)
+            self.items = args[:items]
+          end
+
+          def item_count
+            unless @items.nil?
+              return @items.size
+            else
+              return 0
+            end
+          end
+
+          def names
+            return @items.collect{|item| item.name}
+          end
+
+          def named_item(a_name)
+            @items.each do |item|
+              return item if item.name.value == a_name
+            end
+            retrun nil
+          end
+
+          def ith_item(i)
+            raise ArgumentError, 'index invalid' if i <= 0
+            return @items[i - 1]
+          end
+
+          def as_hierarchy
+            return Cluster.new(:name => @name,
+                               :archetype_node_id => @archetype_node_id,
+                               :items => @items)
+          end
+        end
+
+        class ItemTable < ItemStructure
+          attr_accessor :rows
+
+          def initialize(args = {})
+            super(args)
+            self.rows = args[:rows]
+          end
+
+          def row_count
+            if @rows.nil?
+              return 0
+            else
+              return @rows.size
+            end
+          end
+
+          def column_count
+            if @rows.nil?
+              return 0
+            else
+              return @rows[0].items.count
+            end
+          end
+
+          def row_names
+            if @rows.nil?
+              return []
+            else
+              return @rows.collect{|r| r.name}
+            end
+          end
+
+          def column_names
+            if @rows.nil?
+              return []
+            else
+              return @rows[0].items.collect{|i| i.name}
+            end
+          end
+
+          def ith_row(i)
+            raise ArgumentError, 'invalid index' if i<=0 or i>@rows.size
+            if @rows.nil?
+              return []
+            else
+              return @rows[i - 1]
+            end
+          end
+
+          def has_row_with_name?(key)
+            raise ArgumentError, 'invalid argument' if key.nil? or key.empty?
+            @rows.each do |row|
+              return true if row.items[0].name.value == key
+            end
+            return false
+          end
+
+          def has_column_with_name?(key)
+            raise ArgumentError, 'invalid argument' if key.nil? or key.empty?
+            self.column_names.each do |name|
+              return true if name.value == key
+            end
+            return false
+          end
+
+          def named_row(key)
+            raise ArgumentError, 'invalid argument' unless has_row_with_name?(key)
+            @rows.each do |row|
+              return row if row.items[0].name.value == key
+            end
+            return []
+          end
+
+          def has_row_with_key?(keys)
+            keys.each do |key|
+              @rows.each do |row|
+                return true if row.items[0].name.value == key
+              end
+            end
+            return false
+          end
+
+          def row_with_key(keys)
+            unless has_row_with_key?(keys)
+              raise ArgumentError, 'no row for key'
+            end
+            keys.each do |key|
+              @rows.each do |row|
+                return row if row.items[0].name.value == key
+              end
+            end
+          end
+
+          def element_at_cell_ij(i,j)
+            return @rows[i-1].items[j-1]
+          end
+
+          def element_at_named_cell(row_key, column_key)
+            i,j=0,0
+            @rows[0].items.each do |c|
+              break if c.name.value == column_key
+              i+=1
+            end
+            @rows.each do |row|
+              break if row.name.value == row_key
+              j+=1
+            end            
+            return element_at_cell_ij(i,j)
+          end
+
+          def as_hierarchy
+            return @rows[0]
+          end
+        end
+
+        class ItemTree < ItemStructure
+          attr_accessor :items
+
+          def initialize(args ={ })
+            super(args)
+            self.items = args[:items]
+          end
+        end
+      end # of ItemStructure
+    end # of DataStructures
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_structures/item_structure/representation.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_structures/item_structure/representation.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_structures/item_structure/representation.rb	(revision 302)
@@ -0,0 +1,63 @@
+# rm::data_structures::item_structure::representation
+# representation module
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109066789167_738055_2581Report.html
+# refs #53
+module OpenEHR
+  module RM
+    module DataStructures
+      module ItemStructure
+        module Representation
+          class Item < OpenEHR::RM::Common::Archetyped::Locatable
+            def initialize(args = {})
+              super(args)
+            end
+          end
+
+          class Element < Item
+            attr_accessor :value
+            attr_reader :null_flavor
+            def initialize(args = {})
+              super(args)
+              self.value = args[:value]
+              self.null_flavor= args[:null_flavor]
+            end
+
+            def null_flavor=(null_flavor)
+              sr = nil
+              if !null_flavor.nil? and
+                  null_flavor.defining_code.terminology_id.name == 'openehr'
+                sr = Terminology.find(:first,                                  
+                                      :conditions => "code = '#{null_flavor.defining_code.code_string}'")
+              end
+              if null_flavor.nil? or (!sr.nil? and sr.group == 'null flavours')
+                @null_flavor = null_flavor
+              else
+                raise ArgumentError, 'null_flavor is invalid'
+              end
+            end
+
+            def is_null?
+              return @value.nil?
+            end
+          end
+
+          class Cluster < Item
+            attr_reader :items
+
+            def initialize(args = {})
+              super(args)
+              self.items = args[:items]
+            end
+
+            def items=(items)
+              if !items.nil? and items.empty?
+                raise ArgumentError, 'items should not empty'
+              end
+              @items = items
+            end
+          end
+        end # of Representation
+      end # of ItemStructure
+    end # of DataStructures
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_types/basic.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_types/basic.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_types/basic.rb	(revision 302)
@@ -0,0 +1,108 @@
+# This module is implemented from this UML:
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109067591791_562382_3151Report.html
+# Ticket refs #52
+module OpenEHR
+  module RM
+    module DataTypes
+      module Basic
+        module CanonicalFragment
+        end
+
+        class DataValue
+          include OpenEHR::RM::Support::Definition::BasicDefinition
+          attr_accessor :value
+          alias :v :value
+
+          def initialize(args = {})
+            self.value = args[:value]
+          end
+
+          def ==(other)
+            return self.value == other.value
+          end
+        end
+
+        class DvBoolean < DataValue
+          def initialize(args)
+            super(args)
+          end
+
+          def value=(value)
+            raise ArgumentError, "value must not be nil" if value.nil?
+            if value == true or value =~ /TRUE/i
+              @value = true
+            else
+              @value = false
+            end
+          end
+
+          def value?
+            @value == true
+          end
+        end  # end of DvBoolean
+
+        class DvState < DataValue
+          attr_reader :is_terminal
+
+          def initialize(args)            
+            super(args)
+            self.is_terminal = args[:is_terminal]
+          end
+
+          def value=(v)
+            raise ArgumentError, "value should not be nil" if v.nil?
+            @value = v
+          end
+
+          def is_terminal?
+            @is_terminal
+          end
+
+          def is_terminal=(s)
+            raise ArgumentError, "terminal should not be nil" if s.nil?
+            @is_terminal = s
+          end
+        end # end of DvState
+
+        class DvIdentifier < DataValue
+          attr_reader :issuer, :assigner, :id, :type
+
+          def initialize(args = {})
+            self.issuer = args[:issuer]
+            self.assigner = args[:assigner]
+            self.id = args[:id]
+            self.type = args[:type]
+          end
+
+          def issuer=(issuer)
+            if issuer.nil? or issuer.empty?
+              raise ArgumentError, 'issuer is mandatory'
+            end
+            @issuer = issuer
+          end
+
+          def assigner=(assigner)
+            if assigner.nil? or assigner.empty?
+              raise ArgumentError, 'assigner is mandatory'
+            end
+            @assigner = assigner
+          end
+
+          def id=(id)
+            if id.nil? or id.empty?
+              raise ArgumentError, 'id is manadtory'
+            end
+            @id = id
+          end
+
+          def type=(type)
+            if type.nil? or type.empty?
+              raise ArgumentError, 'type is mandatory'
+            end
+            @type = type
+          end
+        end #end of DvIdentifier
+      end # end of Basic
+    end # end of DataTypes
+  end # end of RM
+end # end of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_types/charset.lst
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_types/charset.lst	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_types/charset.lst	(revision 302)
@@ -0,0 +1,818 @@
+ANSI_X3.4-1968
+iso-ir-6
+ANSI_X3.4-1986
+ISO_646.irv:1991
+ASCII
+ISO646-US
+US-ASCII
+us
+IBM367
+cp367
+csASCII
+ISO_8859-1:1987
+iso-ir-100
+ISO_8859-1
+ISO-8859-1
+latin1
+l1
+IBM819
+CP819
+csISOLatin1
+ISO_8859-2:1987
+iso-ir-101
+ISO_8859-2
+ISO-8859-2
+latin2
+l2
+csISOLatin2
+ISO_8859-3:1988
+iso-ir-109
+ISO_8859-3
+ISO-8859-3
+latin3
+l3
+csISOLatin3
+ISO_8859-4:1988
+iso-ir-110
+ISO_8859-4
+ISO-8859-4
+latin4
+l4
+csISOLatin4
+ISO_8859-5:1988
+iso-ir-144
+ISO_8859-5
+ISO-8859-5
+cyrillic
+csISOLatinCyrillic
+ISO_8859-6:1987
+iso-ir-127
+ISO_8859-6
+ISO-8859-6
+ECMA-114
+ASMO-708
+arabic
+csISOLatinArabic
+ISO_8859-7:1987
+iso-ir-126
+ISO_8859-7
+ISO-8859-7
+ELOT_928
+ECMA-118
+greek
+greek8
+csISOLatinGreek
+ISO_8859-8:1988
+iso-ir-138
+ISO_8859-8
+ISO-8859-8
+hebrew
+csISOLatinHebrew
+ISO_8859-9:1989
+iso-ir-148
+ISO_8859-9
+ISO-8859-9
+latin5
+l5
+csISOLatin5
+ISO-8859-10
+iso-ir-157
+l6
+ISO_8859-10:1992
+csISOLatin6
+latin6
+ISO_6937-2-add
+iso-ir-142
+csISOTextComm
+JIS_X0201
+X0201
+csHalfWidthKatakana
+JIS_Encoding
+csJISEncoding
+Shift_JIS
+MS_Kanji
+csShiftJIS
+Extended_UNIX_Code_Packed_Format_for_Japanese
+csEUCPkdFmtJapanese
+EUC-JP
+Extended_UNIX_Code_Fixed_Width_for_Japanese
+csEUCFixWidJapanese
+BS_4730
+iso-ir-4
+ISO646-GB
+gb
+uk
+csISO4UnitedKingdom
+SEN_850200_C
+iso-ir-11
+ISO646-SE2
+se2
+csISO11SwedishForNames
+IT
+iso-ir-15
+ISO646-IT
+csISO15Italian
+ES
+iso-ir-17
+ISO646-ES
+csISO17Spanish
+DIN_66003
+iso-ir-21
+de
+ISO646-DE
+csISO21German
+NS_4551-1
+iso-ir-60
+ISO646-NO
+no
+csISO60DanishNorwegian
+csISO60Norwegian1
+NF_Z_62-010
+iso-ir-69
+ISO646-FR
+fr
+csISO69French
+ISO-10646-UTF-1
+csISO10646UTF1
+ISO_646.basic:1983
+ref
+csISO646basic1983
+INVARIANT
+csINVARIANT
+ISO_646.irv:1983
+iso-ir-2
+irv
+csISO2IntlRefVersion
+NATS-SEFI
+iso-ir-8-1
+csNATSSEFI
+NATS-SEFI-ADD
+iso-ir-8-2
+csNATSSEFIADD
+NATS-DANO
+iso-ir-9-1
+csNATSDANO
+NATS-DANO-ADD
+iso-ir-9-2
+csNATSDANOADD
+SEN_850200_B
+iso-ir-10
+FI
+ISO646-FI
+ISO646-SE
+se
+csISO10Swedish
+KS_C_5601-1987
+iso-ir-149
+KS_C_5601-1989
+KSC_5601
+korean
+csKSC56011987
+ISO-2022-KR
+csISO2022KR
+EUC-KR
+csEUCKR
+ISO-2022-JP
+csISO2022JP
+ISO-2022-JP-2
+csISO2022JP2
+JIS_C6220-1969-jp
+JIS_C6220-1969
+iso-ir-13
+katakana
+x0201-7
+csISO13JISC6220jp
+JIS_C6220-1969-ro
+iso-ir-14
+jp
+ISO646-JP
+csISO14JISC6220ro
+PT
+iso-ir-16
+ISO646-PT
+csISO16Portuguese
+greek7-old
+iso-ir-18
+csISO18Greek7Old
+latin-greek
+iso-ir-19
+csISO19LatinGreek
+NF_Z_62-010_(1973)
+iso-ir-25
+ISO646-FR1
+csISO25French
+Latin-greek-1
+iso-ir-27
+csISO27LatinGreek1
+ISO_5427
+iso-ir-37
+csISO5427Cyrillic
+JIS_C6226-1978
+iso-ir-42
+csISO42JISC62261978
+BS_viewdata
+iso-ir-47
+csISO47BSViewdata
+INIS
+iso-ir-49
+csISO49INIS
+INIS-8
+iso-ir-50
+csISO50INIS8
+INIS-cyrillic
+iso-ir-51
+csISO51INISCyrillic
+ISO_5427:1981
+iso-ir-54
+ISO5427Cyrillic1981
+ISO_5428:1980
+iso-ir-55
+csISO5428Greek
+GB_1988-80
+iso-ir-57
+cn
+ISO646-CN
+csISO57GB1988
+GB_2312-80
+iso-ir-58
+chinese
+csISO58GB231280
+NS_4551-2
+ISO646-NO2
+iso-ir-61
+no2
+csISO61Norwegian2
+videotex-suppl
+iso-ir-70
+csISO70VideotexSupp1
+PT2
+iso-ir-84
+ISO646-PT2
+csISO84Portuguese2
+ES2
+iso-ir-85
+ISO646-ES2
+csISO85Spanish2
+MSZ_7795.3
+iso-ir-86
+ISO646-HU
+hu
+csISO86Hungarian
+JIS_C6226-1983
+iso-ir-87
+x0208
+JIS_X0208-1983
+csISO87JISX0208
+greek7
+iso-ir-88
+csISO88Greek7
+ASMO_449
+ISO_9036
+arabic7
+iso-ir-89
+csISO89ASMO449
+iso-ir-90
+csISO90
+JIS_C6229-1984-a
+iso-ir-91
+jp-ocr-a
+csISO91JISC62291984a
+JIS_C6229-1984-b
+iso-ir-92
+ISO646-JP-OCR-B
+jp-ocr-b
+csISO92JISC62991984b
+JIS_C6229-1984-b-add
+iso-ir-93
+jp-ocr-b-add
+csISO93JIS62291984badd
+JIS_C6229-1984-hand
+iso-ir-94
+jp-ocr-hand
+csISO94JIS62291984hand
+JIS_C6229-1984-hand-add
+iso-ir-95
+jp-ocr-hand-add
+csISO95JIS62291984handadd
+JIS_C6229-1984-kana
+iso-ir-96
+csISO96JISC62291984kana
+ISO_2033-1983
+iso-ir-98
+e13b
+csISO2033
+ANSI_X3.110-1983
+iso-ir-99
+CSA_T500-1983
+NAPLPS
+csISO99NAPLPS
+T.61-7bit
+iso-ir-102
+csISO102T617bit
+T.61-8bit
+T.61
+iso-ir-103
+csISO103T618bit
+ECMA-cyrillic
+iso-ir-111
+KOI8-E
+csISO111ECMACyrillic
+CSA_Z243.4-1985-1
+iso-ir-121
+ISO646-CA
+csa7-1
+ca
+csISO121Canadian1
+CSA_Z243.4-1985-2
+iso-ir-122
+ISO646-CA2
+csa7-2
+csISO122Canadian2
+CSA_Z243.4-1985-gr
+iso-ir-123
+csISO123CSAZ24341985gr
+ISO_8859-6-E
+csISO88596E
+ISO-8859-6-E
+ISO_8859-6-I
+csISO88596I
+ISO-8859-6-I
+T.101-G2
+iso-ir-128
+csISO128T101G2
+ISO_8859-8-E
+csISO88598E
+ISO-8859-8-E
+ISO_8859-8-I
+csISO88598I
+ISO-8859-8-I
+CSN_369103
+iso-ir-139
+csISO139CSN369103
+JUS_I.B1.002
+iso-ir-141
+ISO646-YU
+js
+yu
+csISO141JUSIB1002
+IEC_P27-1
+iso-ir-143
+csISO143IECP271
+JUS_I.B1.003-serb
+iso-ir-146
+serbian
+csISO146Serbian
+JUS_I.B1.003-mac
+macedonian
+iso-ir-147
+csISO147Macedonian
+greek-ccitt
+iso-ir-150
+csISO150
+csISO150GreekCCITT
+NC_NC00-10:81
+cuba
+iso-ir-151
+ISO646-CU
+csISO151Cuba
+ISO_6937-2-25
+iso-ir-152
+csISO6937Add
+GOST_19768-74
+ST_SEV_358-88
+iso-ir-153
+csISO153GOST1976874
+ISO_8859-supp
+iso-ir-154
+latin1-2-5
+csISO8859Supp
+ISO_10367-box
+iso-ir-155
+csISO10367Box
+latin-lap
+lap
+iso-ir-158
+csISO158Lap
+JIS_X0212-1990
+x0212
+iso-ir-159
+csISO159JISX02121990
+DS_2089
+DS2089
+ISO646-DK
+dk
+csISO646Danish
+us-dk
+csUSDK
+dk-us
+csDKUS
+KSC5636
+ISO646-KR
+csKSC5636
+UNICODE-1-1-UTF-7
+csUnicode11UTF7
+ISO-2022-CN
+ISO-2022-CN-EXT
+UTF-8
+ISO-8859-13
+ISO-8859-14
+iso-ir-199
+ISO_8859-14:1998
+ISO_8859-14
+latin8
+iso-celtic
+l8
+ISO-8859-15
+ISO_8859-15
+Latin-9
+ISO-8859-16
+iso-ir-226
+ISO_8859-16:2001
+ISO_8859-16
+latin10
+l10
+GBK
+CP936
+MS936
+windows-936
+GB18030
+ISO-11548-1
+ISO_11548-1
+ISO_TR_11548-1
+csISO115481
+KZ-1048
+STRK1048-2002
+RK1048
+csKZ1048
+ISO-10646-UCS-2
+csUnicode
+ISO-10646-UCS-4
+csUCS4
+ISO-10646-UCS-Basic
+csUnicodeASCII
+ISO-10646-Unicode-Latin1
+csUnicodeLatin1
+ISO-10646
+ISO-10646-J-1
+ISO-Unicode-IBM-1261
+csUnicodeIBM1261
+ISO-Unicode-IBM-1268
+csUnicodeIBM1268
+ISO-Unicode-IBM-1276
+csUnicodeIBM1276
+ISO-Unicode-IBM-1264
+csUnicodeIBM1264
+ISO-Unicode-IBM-1265
+csUnicodeIBM1265
+UNICODE-1-1
+csUnicode11
+SCSU
+UTF-7
+UTF-16BE
+UTF-16LE
+UTF-16
+CESU-8
+csCESU-8
+UTF-32
+UTF-32BE
+UTF-32LE
+BOCU-1
+csBOCU-1
+ISO-8859-1-Windows-3.0-Latin-1
+csWindows30Latin1
+ISO-8859-1-Windows-3.1-Latin-1
+csWindows31Latin1
+ISO-8859-2-Windows-Latin-2
+csWindows31Latin2
+ISO-8859-9-Windows-Latin-5
+csWindows31Latin5
+hp-roman8
+roman8
+r8
+csHPRoman8
+Adobe-Standard-Encoding
+csAdobeStandardEncoding
+Ventura-US
+csVenturaUS
+Ventura-International
+csVenturaInternational
+DEC-MCS
+dec
+csDECMCS
+IBM850
+cp850
+850
+csPC850Multilingual
+PC8-Danish-Norwegian
+csPC8DanishNorwegian
+IBM862
+cp862
+862
+csPC862LatinHebrew
+PC8-Turkish
+csPC8Turkish
+IBM-Symbols
+csIBMSymbols
+IBM-Thai
+csIBMThai
+HP-Legal
+csHPLegal
+HP-Pi-font
+csHPPiFont
+HP-Math8
+csHPMath8
+Adobe-Symbol-Encoding
+csHPPSMath
+HP-DeskTop
+csHPDesktop
+Ventura-Math
+csVenturaMath
+Microsoft-Publishing
+csMicrosoftPublishing
+Windows-31J
+csWindows31J
+GB2312
+csGB2312
+Big5
+csBig5
+macintosh
+mac
+csMacintosh
+IBM037
+cp037
+ebcdic-cp-us
+ebcdic-cp-ca
+ebcdic-cp-wt
+ebcdic-cp-nl
+csIBM037
+IBM038
+EBCDIC-INT
+cp038
+csIBM038
+IBM273
+CP273
+csIBM273
+IBM274
+EBCDIC-BE
+CP274
+csIBM274
+IBM275
+EBCDIC-BR
+cp275
+csIBM275
+IBM277
+EBCDIC-CP-DK
+EBCDIC-CP-NO
+csIBM277
+IBM278
+CP278
+ebcdic-cp-fi
+ebcdic-cp-se
+csIBM278
+IBM280
+CP280
+ebcdic-cp-it
+csIBM280
+IBM281
+EBCDIC-JP-E
+cp281
+csIBM281
+IBM284
+CP284
+ebcdic-cp-es
+csIBM284
+IBM285
+CP285
+ebcdic-cp-gb
+csIBM285
+IBM290
+cp290
+EBCDIC-JP-kana
+csIBM290
+IBM297
+cp297
+ebcdic-cp-fr
+csIBM297
+IBM420
+cp420
+ebcdic-cp-ar1
+csIBM420
+IBM423
+cp423
+ebcdic-cp-gr
+csIBM423
+IBM424
+cp424
+ebcdic-cp-he
+csIBM424
+IBM437
+cp437
+437
+csPC8CodePage437
+IBM500
+CP500
+ebcdic-cp-be
+ebcdic-cp-ch
+csIBM500
+IBM851
+cp851
+851
+csIBM851
+IBM852
+cp852
+852
+csPCp852
+IBM855
+cp855
+855
+csIBM855
+IBM857
+cp857
+857
+csIBM857
+IBM860
+cp860
+860
+csIBM860
+IBM861
+cp861
+861
+cp-is
+csIBM861
+IBM863
+cp863
+863
+csIBM863
+IBM864
+cp864
+csIBM864
+IBM865
+cp865
+865
+csIBM865
+IBM868
+CP868
+cp-ar
+csIBM868
+IBM869
+cp869
+869
+cp-gr
+csIBM869
+IBM870
+CP870
+ebcdic-cp-roece
+ebcdic-cp-yu
+csIBM870
+IBM871
+CP871
+ebcdic-cp-is
+csIBM871
+IBM880
+cp880
+EBCDIC-Cyrillic
+csIBM880
+IBM891
+cp891
+csIBM891
+IBM903
+cp903
+csIBM903
+IBM904
+cp904
+904
+csIBBM904
+IBM905
+CP905
+ebcdic-cp-tr
+csIBM905
+IBM918
+CP918
+ebcdic-cp-ar2
+csIBM918
+IBM1026
+CP1026
+csIBM1026
+EBCDIC-AT-DE
+csIBMEBCDICATDE
+EBCDIC-AT-DE-A
+csEBCDICATDEA
+EBCDIC-CA-FR
+csEBCDICCAFR
+EBCDIC-DK-NO
+csEBCDICDKNO
+EBCDIC-DK-NO-A
+csEBCDICDKNOA
+EBCDIC-FI-SE
+csEBCDICFISE
+EBCDIC-FI-SE-A
+csEBCDICFISEA
+EBCDIC-FR
+csEBCDICFR
+EBCDIC-IT
+csEBCDICIT
+EBCDIC-PT
+csEBCDICPT
+EBCDIC-ES
+csEBCDICES
+EBCDIC-ES-A
+csEBCDICESA
+EBCDIC-ES-S
+csEBCDICESS
+EBCDIC-UK
+csEBCDICUK
+EBCDIC-US
+csEBCDICUS
+UNKNOWN-8BIT
+csUnknown8BiT
+MNEMONIC
+csMnemonic
+MNEM
+csMnem
+VISCII
+csVISCII
+VIQR
+csVIQR
+KOI8-R
+csKOI8R
+HZ-GB-2312
+IBM866
+cp866
+866
+csIBM866
+IBM775
+cp775
+csPC775Baltic
+KOI8-U
+IBM00858
+CCSID00858
+CP00858
+PC-Multilingual-850+euro
+IBM00924
+CCSID00924
+CP00924
+ebcdic-Latin9--euro
+IBM01140
+CCSID01140
+CP01140
+ebcdic-us-37+euro
+IBM01141
+CCSID01141
+CP01141
+ebcdic-de-273+euro
+IBM01142
+CCSID01142
+CP01142
+ebcdic-dk-277+euro
+ebcdic-no-277+euro
+IBM01143
+CCSID01143
+CP01143
+ebcdic-fi-278+euro
+ebcdic-se-278+euro
+IBM01144
+CCSID01144
+CP01144
+ebcdic-it-280+euro
+IBM01145
+CCSID01145
+CP01145
+ebcdic-es-284+euro
+IBM01146
+CCSID01146
+CP01146
+ebcdic-gb-285+euro
+IBM01147
+CCSID01147
+CP01147
+ebcdic-fr-297+euro
+IBM01148
+CCSID01148
+CP01148
+ebcdic-international-500+euro
+IBM01149
+CCSID01149
+CP01149
+ebcdic-is-871+euro
+Big5-HKSCS
+IBM1047
+IBM-1047
+PTCP154
+csPTCP154
+PT154
+CP154
+Cyrillic-Asian
+BRF
+csBRF
+TSCII
+csTSCII
+windows-1250
+windows-1251
+windows-1252
+windows-1253
+windows-1254
+windows-1255
+windows-1256
+windows-1257
+windows-1258
+TIS-620
Index: ruby/branches/TRY-open_ehr_gem/rm/data_types/charset_extract.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_types/charset_extract.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_types/charset_extract.rb	(revision 302)
@@ -0,0 +1,24 @@
+#! /usr/bin/env ruby
+# charactor sets extraction from download file from
+# http://www.iana.org/assignments/character-sets
+# as character-sets
+
+class CharacterSets
+  def self.get_list
+    list = Array.new
+    open('character-sets') do |file|
+      while line = file.gets
+        if /^((Name:)|(Alias:)) (\S+)/ =~ line
+          list << $4 unless $4 == "None"
+        end
+      end
+    end
+    return list
+  end
+end
+
+open('charset.lst','w') do |f|
+  CharacterSets.get_list.each do |line|
+    f.puts(line)
+  end
+end
Index: ruby/branches/TRY-open_ehr_gem/rm/data_types/encapsulated.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_types/encapsulated.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_types/encapsulated.rb	(revision 302)
@@ -0,0 +1,98 @@
+# OpenEHR::RM::Data_Types::Encapsulated 
+# http://www.openehr.org/svn/specification/TAGS/Release-1.0.2/publishing/architecture/computable/UML/uml_start_view.html
+# refs #51
+require 'rubygems'
+require 'locale/info'
+
+module OpenEHR
+  module RM
+    module DataTypes
+      module Encapsulated
+        class DvEncapsulated  < OpenEHR::RM::DataTypes::Basic::DataValue
+          attr_reader :language, :charset
+
+          def initialize(args = {})
+            super(args)
+            self.charset = args[:charset]
+            self.language = args[:language]
+          end
+
+          def size
+            @value.size
+          end
+
+          def language=(language)
+            if !language.nil? &&
+                !Locale::Info.language_code?(language.code_string)
+              raise ArgumentError, 'invalid language code'
+            end
+            @language = language
+          end
+
+          def charset=(charset)
+            if !charset.nil? && !charset_valid?(charset.code_string)
+              raise ArgumentError, 'invalid charset'
+            end
+            @charset = charset
+          end
+
+          private
+
+          def charset_valid?(charset)
+            result = false
+            open('lib/open_ehr/rm/data_types/charset.lst') do |file|
+              while line = file.gets
+                if charset == line.chomp
+                  result = true
+                  break
+                end
+              end
+            end
+            return result
+          end
+        end
+
+# media type http://www.iana.org/assignments/media-types/text/
+        class DvMultimedia < DvEncapsulated
+          attr_reader :media_type
+          attr_accessor :uri, :data, :compression_algorithm,
+          :integrity_check, :integrity_check_algorithm, :alternate_text
+
+          def initialize(args = {})
+            super(args)
+            self.media_type = args[:media_type]
+            self.uri = args[:uri]
+            self.data = args[:data]
+            self.compression_algorithm = args[:compression_algorithm]
+            self.integrity_check = args[:integrity_check]
+            self.integrity_check_algorithm = args[:integrity_check_algorithm]
+            self.alternate_text = args[:alternate_text]
+          end
+
+          def media_type=(media_type)
+            if media_type.code_string.nil?
+              raise ArgumentError, 'media_type should not be nil'
+            end
+            @media_type = media_type
+          end
+        end
+
+        class DvParsable < DvEncapsulated
+          attr_reader :formalism
+
+          def initialize(args = {})
+            super(args)
+            self.formalism = args[:formalism]
+          end
+
+          def formalism=(formalism)
+            if formalism.nil? || formalism.empty?
+              raise ArgumentError, 'formalism is mandatory'
+            end
+            @formalism = formalism
+          end
+        end
+      end # of Encapsulated
+    end # of DataTypes
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_types/quantity.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_types/quantity.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_types/quantity.rb	(revision 302)
@@ -0,0 +1,397 @@
+# This modules are implemented from the UML shown bellow
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109599337877_94556_1510Report.html
+# Ticket refs #50
+#require 'assumed_library_types'
+module OpenEHR
+  module RM
+    module DataTypes
+      module Quantity
+        class DvOrdered < OpenEHR::RM::DataTypes::Basic::DataValue
+          include Comparable
+          attr_accessor :normal_range, :other_refference_ranges, :normal_status
+
+          def initialize(args = {})
+            super(args)
+            self.normal_range = args[:normal_range]
+            self.normal_status = args[:normal_status]
+            self.other_reference_ranges = args[:other_reference_ranges]
+          end          
+
+          def is_normal?
+            if @normal_range.nil? and @normal_status.nil?
+              return false
+            elsif !@normal_range.nil?
+              return @normal_range.has(@value)
+            elsif !@normal_status.nil?
+              return @normal_status.code_string == 'N'
+            end
+          end
+
+          def is_simple?
+            return @other_reference_ranges.nil?
+          end
+
+          def <=>(other)
+            raise NotImplementedError, 'This method should be implemented'
+          end
+
+          def other_reference_ranges=(other_reference_ranges)
+            if !other_reference_ranges.nil? && other_reference_ranges.empty?
+              raise ArgumentError, "Other reference ranges validity error"
+            end
+            @other_reference_ranges = other_reference_ranges
+          end
+
+          def is_strictly_comparable_to?(others)
+            if others.instance_of? self.class
+              return true
+            else
+              return false
+            end
+          end
+        end
+
+        class DvInterval < OpenEHR::AssumedLibraryTypes::Interval
+
+        end
+
+        class DvQuantified < DvOrdered
+          attr_reader :magnitude, :magnitude_status
+
+          def initialize(args = {})
+            super(args)
+            self.magnitude = args[:magnitude]
+            self.magnitude_status = args[:magnitude_status]
+          end
+
+          def <=>(others)
+            @magnitude <=> others.magnitude
+          end
+
+          def magnitude=(magnitude)
+            raise ArgumentError, 'magnitude should not be nil' if magnitude.nil?
+            @magnitude = magnitude
+          end
+
+          def magnitude_status=(magnitude_status)
+            if magnitude_status.nil?
+              @magnitude_status = '='
+            elsif DvQuantified.valid_magnitude_status?(magnitude_status)
+              @magnitude_status = magnitude_status
+            else
+              raise ArgumentError, 'magnitude_status invalid'
+            end
+          end
+
+          def accuracy_unknown?
+            return @accuracy.nil?
+          end
+
+          def self.valid_magnitude_status?(s)
+            if s == '=' || s == '>' || s == '<' || s == '<=' ||
+                s == '>=' || s == '~'
+              return true
+            else
+              return false
+            end
+          end
+        end
+
+        class DvOrdinal < DvOrdered
+          attr_reader :value, :symbol, :limits
+
+          def initialize(args = {})
+            super(args)
+            self.symbol = args[:symbol]
+            self.limits = args[:limits]
+          end
+
+          def value=(value)
+            raise ArgumentError, 'value should not be nil' if value.nil?
+            @value = value
+          end
+
+          def symbol=(symbol)
+            raise ArgumentError,'symbol should not be nil' if symbol.nil?
+            @symbol = symbol
+          end
+
+          def <=>(other)
+            @value <=> other.value
+          end
+
+          def limits=(limits)
+            unless limits.nil? or limits.meaning.value == 'limits'
+              raise ArgumentError, 'invalid limits'
+            else
+              @limits = limits
+            end
+          end
+          def is_strictly_comparable_to?(others)
+            unless super(others)
+              return false
+            end
+            unless others.symbol.defining_code.terminology_id.value ==
+                @symbol.defining_code.terminology_id.value
+              return false
+            else
+              return true
+            end
+          end
+        end
+
+        class DvAbsoluteQuantity < DvQuantified
+          attr_accessor :accuracy
+
+          def initialize(args = {})
+            super(args)
+            self.accuracy = args[:accuracy]
+          end
+
+          def add(a_diff)
+            type_check(a_diff)
+            return result_builder(DvAbsoluteQuantity,
+                                  @magnitude+a_diff.magnitude)
+          end
+
+          def diff(other)
+            type_check(other)
+            return result_builder(DvAmount,
+                                  (@magnitude-other.magnitude).abs)
+          end
+
+          def subtract(a_diff)
+            type_check(a_diff)
+            return result_builder(DvAbsoluteQuantity,
+                                  @magnitude-a_diff.magnitude)
+          end
+          private
+          def type_check(other)
+            unless self.is_strictly_comparable_to? other
+              raise ArgumentError, 'type mismatch'
+            end
+          end
+
+          def result_builder(klass, magnitude)
+            return klass.new(:magnitude => magnitude,
+                             :magnitude_status => @magnitude_status,
+                             :accuracy => @accuracy,
+                             :accuracy_percent => @accuracy_percent,
+                             :normal_range => @normal_range,
+                             :normal_status => @normal_status,
+                             :other_reference_ranges => @other_reference_ranges)
+          end
+        end
+
+        class DvAmount < DvQuantified
+          attr_reader :accuracy, :accuracy_percent
+
+          def initialize(args = {})
+            super(args)
+            unless args[:accuracy].nil?
+              set_accuracy(args[:accuracy], args[:accuracy_percent])
+            else
+              @accuracy, @accuracy_percent = nil, nil
+            end
+          end
+
+          def +(other)
+            unless self.is_strictly_comparable_to? other
+              raise ArgumentError, 'type mismatch'
+            end
+            result = self.dup
+            result.magnitude = @magnitude + other.magnitude
+            return result
+          end
+
+          def -(other)            
+            other.magnitude = - other.magnitude
+            self+(other)
+          end
+
+          def set_accuracy(accuracy, accuracy_percent)
+            if accuracy_percent
+              raise ArgumentError, 'accuracy invalid' if accuracy < 0.0 || accuracy > 100.0
+            else
+              raise ArgumentError, 'accuracy invaild' if accuracy < 0.0 || accuracy > 1.0
+            end
+            @accuracy, @accuracy_percent = accuracy, accuracy_percent
+          end
+
+          def accuracy_is_percent?
+            return @accuracy_percent
+          end
+        end
+
+        class DvQuantity < DvAmount
+          attr_reader :units, :precision
+
+          def initialize(args = {})
+            super(args)
+            self.units = args[:units]
+            self.precision = args[:precision]
+          end
+
+          def units=(units)
+            raise ArgumentError, 'units should not be nil' if units.nil?
+            @units = units
+          end
+
+          def precision=(precision)
+            unless precision.nil? || precision >= -1
+              raise ArgumentError, 'precision invalid'
+            end
+            @precision = precision
+          end
+
+          def is_strictly_comparable_to?(others)
+            unless super(others)
+              return false
+            end
+            if others.units == @units
+              return true
+            else
+              return false
+            end
+          end
+
+          def is_integral?
+            if @precision.nil? || precision != 0
+              return false
+            else
+              return true
+            end
+          end
+        end
+
+        class DvCount < DvAmount
+
+        end
+
+        class ReferenceRange
+          attr_reader :meaning, :range
+
+          def initialize(args = {})
+            self.meaning = args[:meaning]
+            self.range = args[:range]
+          end
+
+          def meaning=(meaning)
+            if meaning.nil?
+              raise ArgumentError, 'meaning should not be nil'
+            end
+            @meaning = meaning
+          end
+
+          def range=(range)
+            if range.nil?
+              raise ArgumentError, 'range should not be nil'
+            end
+            @range = range
+          end
+
+          def is_in_range?(val)
+            return @range.has?(val)
+          end
+        end
+
+        module ProportionKind
+          PK_RATIO = 0
+          PK_UNITARY = 1
+          PK_PERCENT = 2
+          PK_FRACTION = 3
+          PK_INTEGER_FRACTION = 4
+
+          def ProportionKind.valid_proportion_kind?(kind)
+            return true if kind >= 0 && kind <= 4
+            return false
+          end
+        end # end of ProportionKind
+
+        class DvProportion < DvAmount
+          include ProportionKind
+          attr_reader :numerator, :denominator, :type, :precision
+
+          def initialize(args = {})
+            self.type = args[:type]
+            self.numerator = args[:numerator]
+            self.denominator = args[:denominator]
+            self.precision = args[:precision]
+            self.magnitude_status =args[:magnitude_status]
+            unless args[:accuracy].nil?
+              set_accuracy(args[:accuracy], args[:accuracy_percent])
+            else
+              @accuracy, @accuracy_percent = nil, nil
+            end
+            self.normal_range = args[:normal_range]
+            self.normal_status = args[:normal_status]
+            self.other_reference_ranges = args[:other_reference_ranges]
+          end
+
+          def numerator=(numerator)
+            raise ArgumentError, 'numerator should not be nil' if numerator.nil?
+            if (@type == PK_FRACTION || @type == PK_INTEGER_FRACTION) &&
+                !numerator.integer?
+              raise ArgumentError, 'numerator invalid for type'
+            end
+            @numerator = numerator
+          end
+
+          def denominator=(denominator)
+            case @type
+            when PK_UNITARY
+              unless denominator == 1
+                raise ArgumentError, 'Unitary denominator must be 1'
+              end
+            when PK_PERCENT
+              unless denominator == 100
+                raise ArgumentError, 'Percent denominator must be 100'
+              end
+            when PK_FRACTION, PK_INTEGER_FRACTION
+              unless denominator.integer? and @numerator.integer?
+                raise ArgumentError, 'Fraction numerator/denominator must be integer'
+              end
+            end
+            @denominator = denominator
+          end
+
+          def type=(type)
+            if ProportionKind.valid_proportion_kind?(type)
+              @type = type
+            else
+              raise ArgumentError, 'type invalid'
+            end
+          end
+
+          def magnitude
+            return numerator.to_f/denominator.to_f
+          end
+
+          def precision=(precision)
+            unless precision.nil?
+              if (self.is_integral? && precision !=0)
+                raise ArgumentError, 'precision invalid'
+              end
+            end
+            @precision = precision
+          end
+
+          def is_integral?
+            return denominator.integer? && numerator.integer?
+          end
+
+          def is_strictly_comparable_to?(other)
+            unless super(other)
+              return false
+            end
+            if other.type == @type
+              return true
+            else
+              return false
+            end
+          end
+        end # end of DvProportion
+      end # of Quantity
+    end # of Data_Types
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_types/quantity/date_time.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_types/quantity/date_time.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_types/quantity/date_time.rb	(revision 302)
@@ -0,0 +1,240 @@
+# This module is implementation of the UML:
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109696321450_28117_5362Report.html
+# Ticket refs #49
+require 'assumed_library_types'
+require 'date'
+
+module OpenEhr
+  module RM
+    module DataTypes
+      module Quantity
+        module DateTime
+          class DvTemporal < OpenEhr::RM::DataTypes::Quantity::DvAbsoluteQuantity
+            include Comparable
+            attr_reader :value
+
+            def initialize(value, magnitude_status=nil, accuracy=nil,
+                         normal_range=nil, normal_status=nil,
+                         other_reference_ranges=nil)
+              self.value = value
+              self.magnitude_status = magnitude_status
+              self.accuracy = accuracy
+              self.normal_range = normal_range
+              self.normal_status = normal_status
+              self.other_reference_ranges = other_reference_ranges
+            end
+
+            def value=(value)
+              if value.nil? or value.empty?
+                raise ArgumentError, 'invalid value'
+              end
+              @value = value
+            end
+
+            def <=>(other)
+              self.magnitude <=> other.magnitude
+            end
+          end
+
+          class DvDate < DvTemporal
+            include OpenEhr::AssumedLibraryTypes::ISO8601_DATE_MODULE
+
+            DAYS_IN_MONTH = [0,31,28,31,30,31,30,31,31,30,31,30,31]
+
+            def initialize(value, magnitude_status=nil, accuracy=nil,
+                           normal_range=nil, normal_status=nil,
+                           other_reference_range=nil)
+              super(value, magnitude_status, accuracy, normal_range,
+                    normal_status, other_reference_range)
+            end
+
+            def value=(value)
+              super(value)
+              iso8601_date = AssumedLibraryTypes::ISO8601_DATE.new(value)
+              @year = iso8601_date.year
+              @month = iso8601_date.month
+              @day = iso8601_date.day
+            end
+
+            undef magnitude=
+
+            def magnitude
+              return Date.new(@year, @month, @day)-Date.new(0000,1,1)
+            end
+
+            def diff(other)
+              if self.magnitude > other.magnitude
+                past, future = other, self
+              else
+                past, future = self, other
+              end
+              year, month, day = 0, 0, 0
+              if (future.day >= past.day)
+                day = future.day - past.day
+              else
+                month -= 1
+                previous_month = future.month - 1
+                if previous_month <= 0
+                  previous_month = 12
+                end
+                day = DAYS_IN_MONTH[previous_month] + future.day - past.day
+                if leapyear?(future.year) && (previous_month == 2)
+                  day += 1
+                end
+              end
+              week = day / 7
+              if (future.month >= past.month)
+                month += future.month - past.month
+              else
+                year -= 1
+                month += future.month + 12 - past.month
+              end
+              year += future.year - past.year
+              return DvDuration.new(
+                   'P' + year.to_s + 'Y' + month.to_s + 'M' + 
+                         week.to_s + 'W' + day.to_s + 'D')
+            end
+          end
+          
+          class DvTime < DvTemporal
+            include OpenEhr::AssumedLibraryTypes::ISO8601_TIME_MODULE
+            def initialize(value, magnitude_status=nil, accuracy=nil,
+                           normal_range=nil, normal_status=nil,
+                           other_reference_range=nil)
+              super(value, magnitude_status, accuracy, normal_range,
+                    normal_status, other_reference_range)
+            end
+
+            def value=(value)
+              super(value)
+              iso8601_time = AssumedLibraryTypes::ISO8601_TIME.new(value)
+              @hour = iso8601_time.hour
+              @minute = iso8601_time.minute
+              @second = iso8601_time.second
+              @fractional_second = iso8601_time.fractional_second
+            end
+
+            def magnitude
+              return @hour * 60 * 60 + @minute * 60 + @second + @fractional_second
+            end
+
+            def diff(other)
+              diff = (other.magnitude - self.magnitude).abs
+              hour = (diff / 60 / 60).to_i
+              minute = ((diff - hour*60*60)/60).to_i
+              second = (diff - hour * 60 *60 - minute * 60).to_i
+              fractional_second = ((diff - diff.to_i)*1000000.0).to_i/1000000.0
+              return DvDuration.new('P0Y0M0W0DT' + hour.to_s + 'H' +
+                        minute.to_s + 'M' +
+                        second.to_s + fractional_second.to_s[1..-1] + 'S')
+            end
+          end
+
+          class DvDateTime < DvTemporal
+            include OpenEhr::AssumedLibraryTypes::ISO8601_DATE_TIME_MODULE
+            attr_reader :value
+
+            def initialize(value, magnitude_status=nil, accuracy=nil,
+                           normal_range=nil, normal_status=nil,
+                           other_reference_range=nil)
+              super(value, magnitude_status, accuracy, normal_range,
+                    normal_status, other_reference_range)
+            end
+
+            def value=(value)              
+              super(value)
+              iso8601date_time = AssumedLibraryTypes::ISO8601_DATE_TIME.new(value)
+              self.year = iso8601date_time.year
+              self.month = iso8601date_time.month
+              self.day = iso8601date_time.day
+              self.minute = iso8601date_time.minute
+              self.second = iso8601date_time.second
+              self.hour = iso8601date_time.hour
+              self.fractional_second = iso8601date_time.fractional_second
+              self.timezone = iso8601date_time.timezone
+            end
+
+            def magnitude
+              seconds = DateTime.new(@year,@month,@day,@hour,@minute,@second) - 
+                DateTime.new(0000,1,1,0,0,0)
+              if @fractional_second.nil?
+                return seconds
+              else
+                return seconds + @fractional_second
+              end
+            end
+
+            undef magnitude=
+
+            def diff(other)
+              if self.magnitude >= other.magnitude
+                past, future = other, self
+              else
+                past, future = self, other
+              end
+              past_date, past_time = split_date_time(past)
+              future_date, future_time = split_date_time(future)
+              time_diff = future_time.magnitude - past_time.magnitude
+              if future_time.magnitude < past_time.magnitude
+                future_date.day = future_date.day - 1
+                time_diff += 24 * 60 * 60
+              end
+              date_duration = past_date.diff(future_date)
+              hour = (time_diff / 60 / 60).to_i
+              minute = ((time_diff - hour*60*60)/60).to_i
+              second = (time_diff - hour * 60 *60 - minute * 60).to_i
+              fractional_second = ((time_diff - time_diff.to_i)*1000000.0).to_i/1000000.0
+
+              return DvDuration.new(date_duration.value + 'T' +
+                        hour.to_s + 'H' +
+                        minute.to_s + 'M' +
+                        second.to_s + fractional_second.to_s[1..-1] + 'S')
+                                   
+            end
+
+            private
+
+            def split_date_time(date_time)
+              /^(.*)T(.*)$/ =~ date_time.as_string
+              return DvDate.new($1), DvTime.new($2)
+            end
+          end
+
+          class DvDuration < DvAmount
+            include AssumedLibraryTypes::ISO8601_DURATION_MODULE
+            attr_reader :value
+            
+            def initialize(value, magnitude_status=nil, accuracy=nil,
+                         accuracy_percent=nil, normal_range=nil,
+                         normal_status = nil, other_reference_ranges=nil)
+              self.value = value
+            end
+
+            def value=(value)
+              raise ArgumentError, 'value must be not nil' if value.nil?
+              @value = value
+              iso8601_duration = AssumedLibraryTypes::ISO8601_DURATION.new(value)
+              self.years = iso8601_duration.years
+              self.months = iso8601_duration.months
+              self.weeks = iso8601_duration.weeks
+              self.days = iso8601_duration.days
+              self.hours = iso8601_duration.hours
+              self.minutes = iso8601_duration.minutes
+              self.seconds = iso8601_duration.seconds
+              self.fractional_second = iso8601_duration.fractional_second
+            end
+
+            def magnitude
+              return ((((@year + @month/MONTH_IN_YEAR)*NOMINAL_DAYS_IN_MONTH) +
+                @week * DAYS_IN_WEEK + @days) * HOURS_IN_DAY * MINUTES_IN_HOUR*
+                SECONDS_IN_MINUTE) + @second + @fractional_second
+            end
+            
+            undef magnitude=
+
+          end
+        end # of DateTime
+      end # of Quantity
+    end # of Data_Types
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_types/text.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_types/text.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_types/text.rb	(revision 302)
@@ -0,0 +1,168 @@
+# This module implemented from this UML
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109067605961_209522_3179Report.html
+# Ticket refs #48
+include OpenEHR::RM::DataTypes::Basic
+
+module OpenEHR
+  module RM
+    module DataTypes
+      module Text
+        class TermMapping
+          attr_reader :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
+        end
+
+        class CodePhrase
+          attr_reader :terminology_id, :code_string
+
+          def initialize(args = {})
+            self.code_string = args[:code_string]
+            self.terminology_id = args[:terminology_id]
+          end
+
+          def terminology_id=(terminology_id)
+            if terminology_id.nil?
+              raise ArgumentError, "terminology_id should not be nil"
+            end
+            @terminology_id = terminology_id
+          end
+
+          def code_string=(code_string)
+            if code_string.nil? or code_string.empty?
+              raise ArgumentError, "code_string should not be empty"
+            end
+            @code_string = code_string
+          end 
+        end # of CodePhrase
+
+        class DvText < OpenEHR::RM::DataTypes::Basic::DataValue
+          attr_reader :formatting, :hyperlink, :mappings,
+                      :language, :encoding
+
+          def initialize(args = {})
+            super(args)
+            self.formatting = args[:formatting]
+            self.encoding = args[:encoding]
+            self.mappings = args[:mappings]
+            self.language = args[:language]
+          end
+
+          def value=(value)
+            if value.nil? or value.empty? or 
+                value.include? CR or value.include? LF
+              raise ArgumentError, "value is not valid"
+              # CR and LF are defined in Basic_Definition inherited DataValue.
+            end
+            @value = value
+          end
+
+          def formatting=(formatting)
+            if !formatting.nil? and formatting.empty?
+              raise ArgumentError, "formatting is not valid"
+            end
+            @formatting = formatting
+          end
+
+          def encoding=(encoding)
+            if !encoding.nil? and encoding.code_string.empty?
+              raise ArgumentError, "encoding is not valid"
+            end
+            @encoding = encoding
+          end
+          def mappings=(mappings)
+            if !mappings.nil? and !mappings.instance_of? Set
+              raise ArgumentError, "mapping(s) is(are) not valid"
+            elsif !mappings.nil? and mappings.instance_of? Set and
+                mappings.empty?
+              raise ArgumentError, "mapping(s) is(are) not valid"
+            end
+            @mappings = mappings
+          end
+          def language=(language)
+            if !@language.nil? and language.empty?
+              raise ArgumentError, "langage is not valid"
+            end
+            @language = language
+          end
+        end
+
+        class DvCodedText < DvText
+          attr_reader :defining_code
+
+          def initialize(args = {})
+            super(args)
+            self.defining_code = args[:defining_code]
+          end
+
+          def defining_code=(defining_code)
+            if defining_code.nil?
+              raise ArgumentError, 'defiining code is mandatory'
+            end
+            @defining_code = defining_code
+          end
+        end
+
+        class DvParagraph < OpenEHR::RM::DataTypes::Basic::DataValue
+          attr_reader :items
+
+          def initialize(args ={})
+            self.items = args[:items]
+          end
+
+          def items=(items)
+            if items.nil? or items.empty?
+              raise ArgumentError, "Items are not valid"
+            end
+            @items = items
+          end
+        end
+
+      end # of Text
+    end # of DataTypes
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_types/time_specification.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_types/time_specification.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_types/time_specification.rb	(revision 302)
@@ -0,0 +1,75 @@
+# This module is related to the ticket #47
+
+module OpenEhr
+  module RM
+    module DataTypes
+      module TimeSpecification
+        class DvTimeSpecification < OpenEhr::RM::DataTypes::Basic::DataValue
+          attr_reader :value
+
+          def initialize(value)
+            self.value=(value)
+          end
+
+          def value=(value)
+            raise ArgumentError, 'value must be not nil' if value.nil?
+            @value = value
+          end
+          
+          def calender_alignment
+            raise NotImlementedError, "calender_alignment must be implemented"
+          end
+
+          def event_alignment
+            raise NotImlementedError, "event_alignment must be implemented"
+          end
+
+          def institution_specified
+            raise NotImlementedError, "institution_specified must be implemented"
+          end
+        end
+
+# I have not implemented two classes bellow,
+# because I could not obtain HL7 specification related them.
+
+
+        class DvGeneralTimeSpecification < DvTimeSpecification
+          attr_reader :value
+          def initialize(value)
+            super(value)
+          end
+          def value=(value)
+            raise ArgumentError, "value is not valied" unless value.formalism.is_equal?('HL7:GTS')
+            @value = value
+          end
+          private
+          def value_valid(value)
+          end
+        end
+
+        class DvPeriodicTimeSpecification < DvTimeSpecification
+          attr_reader :value, :calender_alignment, :event_alingment, :period
+          def initialize(value)
+            value_valid(value)
+            super(value)
+          end
+          def value=(value)
+            unless value.formalism.is_equal('HL7:PIVL') or value.formalism.is_equal('HL7:EIVL')
+              raise ArgumentError, "value is not valid"
+            end
+            if value.formalism('HL7:PIVL')
+              /^\[(\d+)\;?(\d+)?\]\/\((\d+\w+)\)(@(\w+?))?(IST)?$/ =~ value
+              interval1, interval2, difference, allignment = $1, $2, $3, $5
+            end
+            if value
+            end
+          end
+
+          def institution_specified?
+
+          end
+        end
+      end
+    end # of Data_Type
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/data_types/uri.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/data_types/uri.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/data_types/uri.rb	(revision 302)
@@ -0,0 +1,83 @@
+# This module is implemented from this UML:
+#http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109701308832_384250_6986Report.html
+# Ticket refs #46
+
+require 'uri'
+
+module URI
+  class EHR < ::URI::Generic
+    COMPONENT = [
+      :scheme, :path, :fragment, :query
+    ].freeze
+
+    def self.build(args)
+      tmp = Util::make_components_hash(self, args)
+      super(tmp)
+    end
+
+    def initialize(*arg)
+      super(*arg)
+    end
+
+    def self.use_registry
+      true
+    end
+  end
+  @@schemes['EHR'] = EHR
+end
+
+module OpenEHR
+  module RM
+    module DataTypes
+      module Uri
+        class DvUri < OpenEHR::RM::DataTypes::Basic::DataValue
+          def initialize(args = {})
+            self.value = args[:value]
+          end
+
+          def value
+            @value.to_s
+          end
+
+          def fragment_id
+            @value.fragment
+          end
+
+          def path
+            @value.path
+          end
+
+          def query
+            @value.query
+          end
+
+          def scheme
+            @value.scheme
+          end
+
+          def value=(value)
+            raise ArgumentError, "value is empty" if value.nil?
+            parse(value)
+          end
+
+          private
+
+          def parse(value)
+            @value = ::URI.parse(value)
+          end
+        end
+
+        class DvEhrUri < DvUri
+          def initialize(value)
+            super(value)
+          end
+
+          def value=(value)
+            raise ArgumentError, "scheme must be ehr" if !(value =~ /^ehr/i)
+            @value = parse(value)
+          end
+        end # of DV_EHR_URI
+      end # of URI
+    end # of DataTypes
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/demographic.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/demographic.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/demographic.rb	(revision 302)
@@ -0,0 +1,187 @@
+# This module is based on the UML,
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_76d0249_1118674798473_6021_0Report.html
+# Ticket refs #45
+module OpenEHR
+  module RM
+    module Demogrphic
+      class Address < OpenEHR::RM::Common::Archetyped::Locatable
+        attr_reader :details
+
+        def as_string
+
+        end
+
+        def type
+
+        end
+      end
+
+      class Capability < OpenEHR::RM::Common::Archetyped::Locatable
+        attr_reader :credentials, :time_validity
+
+      end
+
+      class Party < OpenEHR::RM::Common::Archetyped::Locatable
+        attr_reader :details, :reverse_relationships, :uid
+        attr_reader :idetities, :contacts, :relationships
+        def initialize(uid, archetype_node_id, name, archetype_details,
+                       feeder_audit, links, identities, contacts,
+                       relationships, reverse_relationships, details)
+          super(uid, archetype_node_id, name, archetype_details,
+                feeder_audit, links, nil)
+          uid_valid(uid)
+          @uid = uid
+          identities_vaild(identities)
+          @identities = identities
+          contacts_valid(contacts)
+          @contacts = contacts
+          relationships_valid(relationships)
+        end
+        def type
+          return name
+        end
+        def uid=(uid)
+          uid_valid(uid)
+          @uid = uid
+        end
+        def identities=(identities)
+          identities_vaild(identities)
+          @identities = identities
+        def contacts=(contacts)
+          contacts_valid(contacts)
+          @contacts = contacts
+        end
+        def parent=(parent)
+          @parent = nil
+        end
+        private
+        def uid_valid(uid)
+          raise ArgumentError, "uid is not valid" if uid.nil?
+        end
+        def identities_vaild(identities)
+          if identities.nil?
+            raise ArgumentError, "identities must not be nil"
+          elsif identities.empty?
+            raise ArgumentError, "identities must not be empty"
+          end
+        end
+        def contacts_valid(contacts)
+          if contacs.nil?
+            raise ArgumentError, "contacts must not be nil"
+          elsif contacts.empty?
+            raise ArgumentError, "contacts must not be empty"
+          end          
+        end
+      end
+
+      class PartyIdentity < OpenEHR::RM::Common::Archetyped::Locatable
+        attr_reader :details
+
+      end
+
+      class PartyRelationship < OpenEHR::RM::Common::Archetyped::Locatable
+
+      end
+
+      class Versioned_Party < OpenEHR::RM::Common::Archetyped::Locatable
+
+      end
+
+      class Role < Party
+
+      end
+
+      class Actor < Party
+        LEAGAL_IDENTITY = 'leagal identity'
+        attr_reader :languages, :rules
+        def initialize(uid, archetype_node_id, name, archetype_details,
+                       feeder_audit, links, identities, contacts,
+                       relationships, reverse_relationships, details,
+                       languages, rules)
+          super(uid, archetype_node_id, name, archetype_details,
+                feeder_audit, links, relationships, reverse_relationships,
+                details)
+          has_legal_identity?
+          set_languages(languages)
+          set_rules(rules)
+        end
+        def has_legal_identity?
+          @identities.each {|identity|
+            if (identity.purpose.value == LEAGAL_IDENTITY)
+              return true
+            end
+          }
+          false
+        end
+        def languages=(languages)
+          set_languages(languages)
+        end
+        def values=(values)
+          set_values(values)
+        end
+        private
+        def set_languages(languages)
+          if languages.nil?
+            raise ArgumentError, "languages should not be nil."
+          elsif languages.empty?
+            raise ArgumentError, "languages shouldnot be empty."
+          end
+          @languages = languages
+        end
+        def set_values(values)
+          if values.nil?
+            raise ArgumentError, "values should not be nil."
+          elsif values.empty?
+            raise ArgumentError, "values should not be nil."
+          end
+          @values = values
+      end
+      class Contact < OpenEHR::RM::Common::Archetyped::Locatable
+        attr_accessor :time_validity
+        attr_reader :addresses
+        def initialize(uid, archetype_node_id, name, archetype_details,
+                       feeder_audit, links, parent, time_validity, addresses)
+          super(uid, archetype_node_id, name, archetype_details,
+                feeder_audit, links, parent)
+          address_exists?(addresses)
+          @addresses = addresses
+          @time_validity = time_validity
+        end
+        def purpose
+          @name
+        end
+        def purpose=(purpose)
+          @name = purpose
+        end
+        def addresses=(addresses)
+          address_exists?(addresses)
+          @addresses = addresses
+        end
+        private
+        def address_exists?(addresses)
+          if addresses.nil?
+            raise ArgumentError, "address must not be nil"
+          elsif addresses.empty?
+            raise ArgumentError, "address must not be empty"
+          end
+        end
+      end
+
+      class Agent < Actor
+
+      end
+
+      class Organisation < Actor
+
+      end
+
+      class Person < Actor
+
+      end
+
+      class Group < Actor
+
+      end
+    end # of Demographic
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/security.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/security.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/security.rb	(revision 302)
@@ -0,0 +1,12 @@
+# This module is based on the UML,
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_1_76d0249_1155650882301_836618_5314Report.html
+# Ticket refs #41
+module OpenEHR
+  module RM
+    module Security
+      class AccessControlSettings
+        
+      end
+    end
+  end
+end
Index: ruby/branches/TRY-open_ehr_gem/rm/support/assumed_types.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/support/assumed_types.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/support/assumed_types.rb	(revision 302)
@@ -0,0 +1,81 @@
+# Because his module utilise common methods in both rm
+# and am, I will integrated to /lib/models/assumed_types.rb.
+# By Shinji KOBAYASHI, 2008-07-20
+module OpenEhr
+  module RM
+    module Support
+      module AssumedTypes
+        class Interval
+          attr_accessor :lower, :upper
+#          attr_accessor :lower_included, :lower_unbounded
+#          attr_accessor :upper_included, :upper_unbounded
+          def initialize(lower, upper,
+                         lower_included = nil, upper_included = nil)
+            if ((lower !=nil) && (upper !=nil)) && lower>upper
+              raise ArgumentError, "upper < lower"
+            end
+            @lower = lower
+            @upper = upper
+          end
+        end
+
+        class List
+          attr_reader :content
+
+          def initialize(arg)
+            @content = arg
+          end
+
+          def first
+            @content.first
+          end
+
+          def last
+            @content.last
+          end
+        end
+
+        class TIME_DEFINITIONS
+        end
+
+
+        class ISO8601_DATE < TIME_DEFINITIONS
+        end
+
+        class ISO8601_TIME < TIME_DEFINITIONS
+        end
+
+        class ISO8601_DURATION < TIME_DEFINITIONS
+        end
+
+        class ISO8601_DATE_TIME < TIME_DEFINITIONS
+        end
+
+        class ISO8601_TIMEZONE < TIME_DEFINITIONS
+        end
+
+        class String
+          attr_reader :content
+          def initialize(arg)
+            @content = arg
+          end
+
+          def as_integer
+            is_integer if is_integer
+          end
+
+          def is_empty
+          end
+
+          def is_integer
+            begin
+              Integer(@content)
+            rescue
+              false
+            end
+          end
+        end
+      end
+    end
+  end
+end
Index: ruby/branches/TRY-open_ehr_gem/rm/support/definition.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/support/definition.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/support/definition.rb	(revision 302)
@@ -0,0 +1,15 @@
+module OpenEHR
+  module RM
+    module Support
+      module Definition
+        module BasicDefinition
+          CR = "\015"
+          LF = "\012"
+        end
+        class OpenEHRDefinitions
+          include BasicDefinition
+        end
+      end
+    end
+  end
+end
Index: ruby/branches/TRY-open_ehr_gem/rm/support/identification.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/support/identification.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/support/identification.rb	(revision 302)
@@ -0,0 +1,407 @@
+# This module is an implementation of this UML:
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109331021343_528780_2066Report.html
+# Ticket refs #39
+module OpenEHR
+  module RM
+    module Support
+      module Identification
+        class ObjectID
+          attr_reader :value
+
+          def initialize(args = {})
+            self.value=args[:value]
+          end
+
+          def value=(value)
+            raise ArgumentError, "empty value" if value.nil? or value.empty?
+            @value = value            
+          end
+
+          def ==(object_id)
+            self.value == object_id.value
+          end
+        end # of ObjectID
+
+        class ObjectRef
+          attr_reader :namespace, :type, :id
+
+          def initialize(args = {})
+            self.namespace = args[:namespace]
+            self.type = args[:type]
+            self.id = args[:id]
+          end
+
+          def namespace=(namespace)
+            if namespace.nil? or namespace.empty? or 
+                !(/^[a-zA-Z][a-zA-Z0-9_\-\:\/\&\+\?]*$/ =~ namespace)
+              raise ArgumentError
+            end
+            @namespace = namespace
+          end
+
+          def type=(type)
+            raise ArgumentError if type.nil? or type.empty?
+            @type = type
+          end
+
+          def id=(id)
+            raise ArgumentError if id.nil?
+            @id = id
+          end
+        end
+
+        class ArchetypeID < ObjectID
+          attr_reader :rm_originator, :rm_name, :rm_entity,
+                      :concept_name, :specialisation, :version_id
+          
+          def initialize(args = {})
+            if args[:value].nil?
+              self.rm_originator = args[:rm_originator]
+              self.rm_name = args[:rm_name]
+              self.rm_entity = args[:rm_entity]
+              self.concept_name = args[:concept_name]
+              self.version_id = args[:version_id]
+              self.specialisation = args[:specialisation]
+            else
+              super(args)
+            end
+          end
+
+          def value=(value)
+            if /([a-zA-Z]\w+)-([a-zA-Z]\w+)-([a-zA-Z]\w+)\.([a-zA-Z]\w+)(-([a-zA-Z]\w+))?\.(v[1-9]\d*)/ =~ value
+              self.rm_originator = $1
+              self.rm_name = $2
+              self.rm_entity = $3
+              self.concept_name = $4
+              self.specialisation = $6
+              self.version_id = $7
+            else
+              raise ArgumentError, 'invalid archetype id form'
+            end
+          end
+
+          def qualified_rm_entity
+            return @rm_originator + '-' + @rm_name + '-' + @rm_entity
+          end
+
+          def domain_concept
+            if @specialisation.nil?
+              return @concept_name
+            else
+              return @concept_name + '-' + @specialisation
+            end
+          end
+
+          def value
+            return self.qualified_rm_entity + '.' +
+              self.domain_concept + '.' + @version_id
+          end
+
+          def concept_name=(concept_name)
+            if concept_name.nil? or concept_name.empty?
+              raise ArgumentError, 'concept_name is mandatory'
+            end
+            @concept_name = concept_name
+          end
+
+          def domain_concept=(domain_concept)
+            if domain_concept.nil? or domain_concept.empty?
+              raise ArgumentError, "domain concept not valid"
+            end
+            if /([a-zA-Z]\w+)(-([a-zA-Z]\w))?/ =~ domain_concept
+              self.concept_name = $1
+              self.specialisation = $3
+            else
+              raise ArgumentError, 'invalid domain concept form'
+            end
+          end
+
+          def rm_name=(rm_name)
+            raise ArgumentError, "rm_name not valid" if rm_name.nil? or rm_name.empty?
+            @rm_name = rm_name
+          end
+
+          def rm_entity=(rm_entity)
+            if rm_entity.nil? or rm_entity.empty?
+              raise ArgumentError, "rm_entity is mandatory"
+            end
+            @rm_entity = rm_entity
+          end
+
+          def rm_originator=(rm_originator)
+            if rm_originator.nil? or rm_originator.empty?
+              raise ArgumentError, "rm_originator not valid"
+            end
+            @rm_originator = rm_originator
+          end
+
+          def specialisation=(specialisation)
+            if !specialisation.nil? and specialisation.empty?
+              raise ArgumentError, "rm_specialisation not valid" 
+            end
+            @specialisation = specialisation
+          end
+
+          def version_id=(version_id)
+            raise ArgumentError, "version_id not valid" if version_id.nil? or version_id.empty?
+            @version_id = version_id
+          end
+        end
+
+        class TerminologyID < ObjectID
+          attr_reader :name, :version_id
+
+          def initialize(args = {})
+            if args[:value].nil?
+              self.name = args[:name]
+              self.version_id = args[:version_id]
+            else
+              super(args)
+            end
+          end
+
+          def value
+            if @version_id.empty?
+              @name
+            else
+              @name + '(' + @version_id + ')'
+            end 
+          end
+
+
+          def value=(value)
+            raise ArgumentError, "value not valid" if value.nil? or value.empty?
+            if /(.*)\((.*)\)/ =~ value
+              self.name = $1
+              self.version_id = $2
+            else
+              self.name = value
+              self.version_id = ''
+            end
+          end
+
+          def name=(name)
+            raise ArgumentError, "name not valid" if name.nil? or name.empty?
+            @name = name
+          end
+
+          def version_id=(version_id)
+            if version_id.nil?
+              @version_id = ''
+            else
+              @version_id = version_id
+            end
+          end
+        end # of Terminology_ID
+
+        class GenericID < ObjectID
+          attr_reader :scheme
+
+          def initialize(args)
+            super(args)
+            self.scheme = args[:scheme]
+          end
+
+          def scheme=(scheme)
+            if scheme.nil? or scheme.empty?
+              raise ArgumentError, "scheme not valid"
+            end
+            @scheme = scheme
+          end
+        end # of Generic_ID
+
+        class TemplateID < ObjectID
+
+        end
+
+        class UIDBasedID < ObjectID
+          attr_reader :root, :extension
+
+          def initialize(args = {})
+            super(args)
+          end
+
+          def value=(value)
+            super(value)
+            if /(\S+)::(\S+)/ =~ value
+              @root = UID.new(:value => $1)
+              @extension = $2
+            else
+              @root = UID.new(:value => value)
+              @extension = ''
+            end
+          end
+
+          def has_extension?
+            return !@extension.empty?
+          end
+        end
+
+        class ObjectVersionID < UIDBasedID
+          attr_reader :object_id, :creating_system_id, :version_tree_id
+
+          def initialize(args= {})
+            super(args)
+          end
+
+          def value=(value)
+            if /^(\S+)::(\S+)::((\d|\.)+)$/ =~ value
+              self.object_id = UID.new(:value => $1)
+              self.creating_system_id = UID.new(:value => $2)
+              self.version_tree_id = VersionTreeID.new(:value => $3)
+            else
+              raise ArgumentError, 'invalid format'
+            end
+          end
+
+          def value
+            return @object_id.value + '::' + 
+              @creating_system_id.value + '::' +
+              @version_tree_id.value
+          end
+
+          def object_id=(object_id)
+            raise ArgumentError, 'object_id is mandatory' if object_id.nil?
+            @object_id = object_id
+          end
+
+          def creating_system_id=(creating_system_id)
+            if creating_system_id.nil?
+              raise ArgumentError, 'creating_system_id is mandatory'
+            end
+            @creating_system_id = creating_system_id
+          end
+
+          def version_tree_id=(version_tree_id)
+            if version_tree_id.nil?
+              raise ArgumentError, 'version_tree_id is mandatory'
+            end
+            @version_tree_id = version_tree_id
+          end
+
+          def is_branch?
+            return @version_tree_id.is_branch?
+          end
+        end
+
+        class LocatableRef < ObjectRef
+          attr_reader :path
+
+          def initialize(args = {})
+            super(args)
+            self.path = args[:path]
+          end
+
+          def path=(path)
+            raise ArgumentError if path.nil? or path.empty?
+            @path = path
+          end
+
+          def as_uri
+            'ehr://' + @id.value + '/' + @path
+          end
+        end
+
+        class PartyRef < ObjectRef
+          def type=(type)
+            parties = %w[PERSON ORGANISATION GROUP AGENT ROLE PARTY ACTOR]
+            raise ArgumentError, 'type invalid' unless parties.include? type
+            @type = type
+          end
+        end
+
+        class AccessGroupRef < ObjectRef
+          def initialize(args = {})
+            super(args)
+            @type = 'ACCESS_GROUP'
+          end
+
+          def type=(type)
+          end
+        end
+
+        class HierObjectID < UIDBasedID
+
+        end
+
+        class VersionTreeID
+          attr_reader :trunk_version, :branch_number, :branch_version
+
+          def initialize(args = {})
+            self.value = args[:value]
+          end
+
+          def value=(value)
+            raise ArgumentError, 'value invalid' if value.nil? or value.empty?
+            (trunk_version, branch_number, branch_version) = value.split '.'
+            self.trunk_version = trunk_version
+            self.branch_number = branch_number
+            self.branch_version = branch_version
+          end
+
+          def value
+            @value = trunk_version
+            @value = @value + '.' + @branch_number unless @branch_number.nil?
+            @value = @value + '.' + @branch_version unless @branch_version.nil?
+            return @value
+          end
+
+          def trunk_version=(trunk_version)
+            if trunk_version.nil? || (trunk_version.to_i < 1)
+              raise ArgumentError, 'trunk_version invalid'
+            end
+            @trunk_version = trunk_version
+          end
+
+          def branch_number=(branch_number)
+            unless branch_number.nil? or branch_number.to_i >= 1
+              raise ArgumentError, 'branch number invalid'
+            end
+            @branch_number = branch_number
+          end
+
+          def branch_version=(branch_version)
+            if (!branch_version.nil? and !(branch_version.to_i >= 1)) or
+                (!branch_version.nil? and @branch_number.nil?)
+              raise ArgumentError, 'branch version invalid'
+            end
+            @branch_version = branch_version
+          end
+
+          def is_branch?
+            !@branch_version.nil? and !@branch_number.nil?
+          end
+
+          def is_first?
+            trunk_version == '1'
+          end
+        end
+
+        class UID
+          attr_reader :value
+
+          def initialize(args = {})
+            self.value = args[:value]
+          end
+
+          def value=(value)
+            raise ArgumentError if value.nil? or value.empty?
+            @value = value
+          end
+        end
+
+        class UUID < UID
+
+        end
+
+        class InternetID <UID
+          
+        end
+
+        class IsoOID <UID
+
+        end        
+      end # of Identification
+    end # of Support
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/support/measurement.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/support/measurement.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/support/measurement.rb	(revision 302)
@@ -0,0 +1,17 @@
+module OpenEHR
+  module RM
+    module Support
+      module Measurement
+        class MeasurementService
+        end
+        module ExternalEnvironmentAccess
+          def eea_terminology_svc
+          end
+          
+          def eea_measurement_svc
+          end
+        end
+      end # of Measurment
+    end # of Support
+  end # of RM
+end # of OpenEHR
Index: ruby/branches/TRY-open_ehr_gem/rm/support/terminology.rb
===================================================================
--- ruby/branches/TRY-open_ehr_gem/rm/support/terminology.rb	(revision 302)
+++ ruby/branches/TRY-open_ehr_gem/rm/support/terminology.rb	(revision 302)
@@ -0,0 +1,135 @@
+
+module OpenEHR
+  module RM
+    module Support
+      module Terminology
+        class CodeSetAccess
+          def all_codes
+            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
+          CODE_SET_ID_COMPRESSION_ALGORITHMS = "compression algorithms".freeze
+          CODE_SET_ID_COUNTRIES = "countries".freeze
+          CODE_SET_ID_INTEGRITY_CHECK_ALGORITHMS = "integrity check algorithms".freeze
+          CODE_SET_ID_LANGUAGES = "languages".freeze
+          CODE_SET_ID_MEDIA_TYPES = "media types".freeze
+          def valid_code_set_id(an_id)
+            !@an_id.nil?
+          end
+        end
+
+        module OpenEHRTerminologyGroupIdentifiers
+          GROUP_ID_ATTESTATION_REASON = "attestation reason".freeze
+          GROUP_ID_AUDIT_CHANGE_TYPE = "audit change type".freeze
+          GROUP_ID_COMPOSITION_CATEGORY = "composition category".freeze
+          GROUP_ID_MATH_FUNCTION = "event math function".freeze
+          GROUP_ID_INSTRUCTION_STATES = "instruction states".freeze
+          GROUP_ID_INSTRUCTION_TRANSITIONS = "instruction transitions".freeze
+          GROUP_ID_NULL_FLAVOURS = "null flavours".freeze
+          GROUP_ID_PARTICIPATION_FUNCTION = "participation function".freeze
+          GROUP_ID_PARTICIPATION_MODE = "participation mode".freeze
+          GROUP_ID_PROPERTY = "property".freeze
+          GROUP_ID_SETTING = "setting".freeze.freeze
+          GROUP_ID_SUBJECT_RELATIONSHIP = "subject relationship".freeze
+          GROUP_ID_TERM_MAPPING_PURPOSE = "term mapping purpose".freeze
+          GROUP_ID_VERSION_LIFECYCLE_STATE = "version lifecycle state".freeze
+          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)
+            
+          end
+
+          def id=(id)
+            @terminology = Terminology.find_all_by_name(id)
+            @id = id
+          end
+
+          def rubric_for_code(code, lang)
+            return Terminology.find(:first, :conditions => {:code => code,
+                                      :lang => lang})
+          end
+
+          private
+          def id_exists
+            if id.nil?
+              raise ArgumentError, "id must not be nil"
+            elsif id.empty?
+              raise ArgumentError, "id must not be empty"
+            end
+          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)
+            return TerminologyAccess.new(:id => name)
+          end
+          
+          def terminology_identifiers
+            raise NotImplementedError, "terminology_identiferes is not implemented"
+          end
+        end 
+      end # of Terminology
+    end # of Support
+  end # of RM
+end # of OpenEHR
