Index: ruby/trunk/lib/adl_parser/lib/adl_parser.rb
===================================================================
--- ruby/trunk/lib/adl_parser/lib/adl_parser.rb	(revision 283)
+++ ruby/trunk/lib/adl_parser/lib/adl_parser.rb	(revision 291)
@@ -11,5 +11,5 @@
 require 'adl_exception.rb'
 
-module OpenEHR
+module OpenEhr
 
   if $DEBUG
Index: ruby/trunk/lib/adl_parser/lib/parser.rb
===================================================================
--- ruby/trunk/lib/adl_parser/lib/parser.rb	(revision 283)
+++ ruby/trunk/lib/adl_parser/lib/parser.rb	(revision 291)
@@ -20,5 +20,5 @@
 
 
-module OpenEHR
+module OpenEhr
   module ADL
     class Parser < Racc::Parser
Index: ruby/trunk/lib/adl_parser/lib/shell.rb
===================================================================
--- ruby/trunk/lib/adl_parser/lib/shell.rb	(revision 283)
+++ ruby/trunk/lib/adl_parser/lib/shell.rb	(revision 291)
@@ -3,5 +3,5 @@
 require 'stringio'
 
-module OpenEHR
+module OpenEhr
   module Application
     class Shell
Index: ruby/trunk/lib/adl_parser/lib/validator.rb
===================================================================
--- ruby/trunk/lib/adl_parser/lib/validator.rb	(revision 283)
+++ ruby/trunk/lib/adl_parser/lib/validator.rb	(revision 291)
@@ -3,5 +3,5 @@
 
 
-module OpenEHR
+module OpenEhr
   module ADL
 
Index: ruby/trunk/lib/models/am.rb
===================================================================
--- ruby/trunk/lib/models/am.rb	(revision 283)
+++ 	(revision )
@@ -1,57 +1,0 @@
-#! /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 Data_Types
-        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/trunk/lib/models/assumed_library_types.rb
===================================================================
--- ruby/trunk/lib/models/assumed_library_types.rb	(revision 283)
+++ 	(revision )
@@ -1,563 +1,0 @@
-# This module is related to the ticket #36
-require 'date'
-require 'time'
-
-module OpenEHR
-  module Assumed_Library_Types
-    class Any < Object
-      
-    end # of Any
-
-    class Interval < Any
-      attr_reader :lower, :upper
-      
-      def initialize(lower, upper, 
-                     lower_included = nil, upper_included = nil)
-        check_lower_upper(lower, upper)
-        self.lower_included = lower_included
-        self.upper_included = 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 < value) && (value < @upper) ||
-            (@lower_included == true) && (@lower == value) ||
-            (@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 TIME_DEFINITIONS < 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)
-        year >= 0
-      end
-
-      def self.valid_day?(y, m, d)
-        Date.valid_date?(y,m,d) and valid_year? y
-      end
-
-      def self.valid_hour?(h,m = nil, s = nil)
-        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 TIME_DEFINITIONS
-
-    module ISO8601_DATE_MODULE
-      attr_reader :year, :month, :day
-      def year=(year)
-        raise ArgumentError, "Year is not valid" unless ISO8601_DATE.valid_year?(year)
-        @year = year
-      end
-      def month=(month)
-        raise ArgumentError, "Month is not valid" unless month.nil? or ISO8601_DATE.valid_month?(month)
-        @month = month
-      end
-
-      def day=(day)
-        raise ArgumentError, "Day is not valid" unless day.nil? or ISO8601_DATE.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 ISO8601_DATE < TIME_DEFINITIONS
-      include ISO8601_DATE_MODULE
-      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 ISO8601_TIME_MODULE
-      attr_reader :hour, :minute, :second, :fractional_second, :timezone
-
-      def hour=(hour)
-        raise ArgumentError, "hour is not valid" if !ISO8601_TIME.valid_hour?(hour, @minute, @second)
-        @hour = hour
-      end
-
-      def minute_unknown?
-        @minute.nil?
-      end
-
-      def minute=(minute)
-        raise ArgumentError, "minute is not valid" if !minute.nil? and !ISO8601_TIME.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 !ISO8601_TIME.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?
-        raise ArgumentError, "fractional second should be lower than 1.0" if !fractional_second.nil? and fractional_second >= 1.0
-        @fractional_second = fractional_second
-      end
-
-      def has_fractional_second?
-        if @fractional_second.nil?
-          return false
-        else
-          return true
-        end
-      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 ISO8601_TIME < TIME_DEFINITIONS
-      include ISO8601_TIME_MODULE
-      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
-            else
-              return false
-            end
-          end
-          return true
-        else
-          return false
-        end
-      end
-    end # end of ISO8601_TIME
-
-    module ISO8601_DATE_TIME_MODULE
-      include ISO8601_DATE_MODULE, ISO8601_TIME_MODULE
-      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 ISO8601_DATE_TIME < ISO8601_DATE
-      include ISO8601_DATE_TIME_MODULE
-      def initialize(string)
-        /(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|([+-]\d{2}):?(\d{2}))?)?)?)?/ =~ string
-        if $1.empty?
-          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 ISO8601_TIMEZONE
-      attr_accessor :sign, :hour, :minute
-
-      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("Z%s%02d%02d", s, @hour, @minute)
-      end
-    end # end of ISO8601_TIMEZONE
-
-    module ISO8601_DURATION_MODULE
-      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 ISO8601_DURATION < TIME_DEFINITIONS
-      include ISO8601_DURATION_MODULE
-      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 ISO8601_DURATION
-  end # end of Assumed_Types
-end # end of OpenEHR
Index: ruby/trunk/lib/models/tests/rm/quantity/ts_date_time.rb
===================================================================
--- ruby/trunk/lib/models/tests/rm/quantity/ts_date_time.rb	(revision 283)
+++ ruby/trunk/lib/models/tests/rm/quantity/ts_date_time.rb	(revision 291)
@@ -1,26 +1,26 @@
 require 'test/unit'
 require 'rm'
-include OpenEHR::RM::Data_Types::Quantity::Date_Time
+include OpenEhr::RM::DataTypes::Quantity::DateTime
 
 class DateTimeTest < Test::Unit::TestCase
   def setup
     assert_nothing_raised(Exception){
-      @dv_temporal = DV_Temporal.new('2008')}
+      @dv_temporal = DvTemporal.new('2008')}
     assert_nothing_raised(Exception){
-      @dv_date = DV_Date.new('2009-06-29')}
+      @dv_date = DvDate.new('2009-06-29')}
     assert_nothing_raised(Exception){
-      @dv_time = DV_Time.new('12:34:56.78')}
+      @dv_time = DvTime.new('12:34:56.78')}
     assert_nothing_raised(Exception){
-      @dv_date_time = DV_Date_Time.new('2009-06-29T12:34:56.78')}
+      @dv_date_time = DvDateTime.new('2009-06-29T12:34:56.78')}
     assert_nothing_raised(Exception){
-      @dv_duration = DV_Duration.new('P1Y2M3W4DT5H6M7.8S')}
+      @dv_duration = DvDuration.new('P1Y2M3W4DT5H6M7.8S')}
   end
 
   def test_init
-    assert_instance_of DV_Temporal, @dv_temporal
-    assert_instance_of DV_Date, @dv_date
-    assert_instance_of DV_Time, @dv_time
-    assert_instance_of DV_Date_Time, @dv_date_time
-    assert_instance_of DV_Duration, @dv_duration
+    assert_instance_of DvTemporal, @dv_temporal
+    assert_instance_of DvDate, @dv_date
+    assert_instance_of DvTime, @dv_time
+    assert_instance_of DvDateTime, @dv_date_time
+    assert_instance_of DvDuration, @dv_duration
   end
 
@@ -36,13 +36,13 @@
     assert_equal 29, @dv_date.day
     assert_equal 733954, @dv_date.magnitude
-    date2 = DV_Date.new('2009-07-08')
+    date2 = DvDate.new('2009-07-08')
     assert_equal 'P0Y0M1W9D',@dv_date.diff(date2).value
-    date2 = DV_Date.new('2004-02-28')
-    date3 = DV_Date.new('2004-03-01')
+    date2 = DvDate.new('2004-02-28')
+    date3 = DvDate.new('2004-03-01')
     assert_equal 'P0Y0M0W2D', date2.diff(date3).value
-    date4 = DV_Date.new('2003-12-31')
+    date4 = DvDate.new('2003-12-31')
     assert_equal 'P0Y1M4W28D', date2.diff(date4).value
-    birthday = DV_Date.new('1970-04-19')
-    assert_equal 'P39Y2M1W11D', birthday.diff(DV_Date.new('2009-06-30')).value
+    birthday = DvDate.new('1970-04-19')
+    assert_equal 'P39Y2M1W11D', birthday.diff(DvDate.new('2009-06-30')).value
   end
 
@@ -54,5 +54,5 @@
     assert_equal 0.78, @dv_time.fractional_second
     assert_equal((12*60*60 + 34 * 60 + 56 + 0.78), @dv_time.magnitude)
-    dv_time2 = DV_Time.new('15:36:48.05')
+    dv_time2 = DvTime.new('15:36:48.05')
     assert_equal 'P0Y0M0W0DT3H1M51.27S', @dv_time.diff(dv_time2).value
   end
@@ -67,5 +67,5 @@
     assert_equal 56, @dv_date_time.second
     assert_equal 0.78, @dv_date_time.fractional_second
-    dv_date_time2 = DV_Date_Time.new('1970-04-19T13:55:30.12')
+    dv_date_time2 = DvDateTime.new('1970-04-19T13:55:30.12')
     assert_equal 'P39Y2M1W9DT22H39M26.66S', @dv_date_time.diff(dv_date_time2).value
   end
Index: ruby/trunk/lib/models/tests/rm/test_common.rb
===================================================================
--- ruby/trunk/lib/models/tests/rm/test_common.rb	(revision 283)
+++ ruby/trunk/lib/models/tests/rm/test_common.rb	(revision 291)
@@ -3,23 +3,23 @@
 require 'rm'
 
-include OpenEHR::RM::Data_Types::Text
-include OpenEHR::RM::Common::Resource
-include OpenEHR::RM::Common::Archetyped
-include OpenEHR::RM::Common::Generic
-include OpenEHR::RM::Common::Change_Control
-include OpenEHR::RM::Common::Directory
-include OpenEHR::RM::Support::Identification
-include OpenEHR::RM::Data_Types::Basic
-include OpenEHR::RM::Data_Types::Quantity
-include OpenEHR::RM::Data_Types::URI
+include OpenEhr::RM::DataTypes::Text
+include OpenEhr::RM::Common::Resource
+include OpenEhr::RM::Common::Archetyped
+include OpenEhr::RM::Common::Generic
+include OpenEhr::RM::Common::ChangeControl
+include OpenEhr::RM::Common::Directory
+include OpenEhr::RM::Support::Identification
+include OpenEhr::RM::DataTypes::Basic
+include OpenEhr::RM::DataTypes::Quantity
+include OpenEhr::RM::DataTypes::Uri
 
 class RM_Common_Resource_Test < Test::Unit::TestCase
   def setup
-    terminology_id = Terminology_ID.new('openehr')
-    code_phrase = Code_Phrase.new('ja', terminology_id)    
-    @translation_details = OpenEHR::RM::Common::Resource::Translation_Details.new(:language => code_phrase, :author => {'KOBAYASHI, Shinji', 'Ehime Univ'},
+    terminology_id = TerminologyId.new('openehr')
+    code_phrase = CodePhrase.new('ja', terminology_id)
+    @translation_details = OpenEhr::RM::Common::Resource::TranslationDetails.new(:language => code_phrase, :author => {'KOBAYASHI, Shinji', 'Ehime Univ'},
   :accreditation => 'jp', :other_details => {'ruby', 'test'})
-    @authored_resource = OpenEHR::RM::Common::Resource::Authored_Resource.new(:original_language => code_phrase, :translations => {'ja', @translation_details}, :description => "test")
-    @resource_description_item = OpenEHR::RM::Common::Resource::Resource_Description_Item.new(:language => code_phrase,
+    @authored_resource = OpenEhr::RM::Common::Resource::AuthoredResource.new(:original_language => code_phrase, :translations => {'ja', @translation_details}, :description => "test")
+    @resource_description_item = OpenEhr::RM::Common::Resource::ResourceDescriptionItem.new(:language => code_phrase,
               :purpose => 'test',
               :keywords => %w[test ruby],
@@ -29,5 +29,5 @@
               :original_resource_uri => {'issuer', 'http://openehr.jp/'},
               :other_details => {'samos', 'icicth7'})
-    @resource_description = OpenEHR::RM::Common::Resource::Resource_Description.new(:original_author => {'KOBAYASHI, Shinji' => 'Ehime University'},
+    @resource_description = OpenEhr::RM::Common::Resource::ResourceDescription.new(:original_author => {'KOBAYASHI, Shinji' => 'Ehime University'},
     :lifecycle_state => 'experimental',
     :details => {'ja', @resource_description_item},
@@ -36,12 +36,12 @@
     :other_details => {'ja', 'shikoku'},
     :parent_resource => @authored_resource)
-    @authored_resource = OpenEHR::RM::Common::Resource::Authored_Resource.new(:original_language => code_phrase, :translations => {'ja', @translation_details}, :description => @resource_description)
+    @authored_resource = OpenEhr::RM::Common::Resource::AuthoredResource.new(:original_language => code_phrase, :translations => {'ja', @translation_details}, :description => @resource_description)
   end
 
   def test_init
-    assert_instance_of OpenEHR::RM::Common::Resource::Authored_Resource, @authored_resource
-    assert_instance_of OpenEHR::RM::Common::Resource::Translation_Details, @translation_details
-    assert_instance_of OpenEHR::RM::Common::Resource::Resource_Description_Item, @resource_description_item
-    assert_instance_of OpenEHR::RM::Common::Resource::Resource_Description, @resource_description
+    assert_instance_of OpenEhr::RM::Common::Resource::AuthoredResource, @authored_resource
+    assert_instance_of OpenEhr::RM::Common::Resource::TranslationDetails, @translation_details
+    assert_instance_of OpenEhr::RM::Common::Resource::ResourceDescriptionItem, @resource_description_item
+    assert_instance_of OpenEhr::RM::Common::Resource::ResourceDescription, @resource_description
   end
 
@@ -86,4 +86,5 @@
 class RM_Common_Archetyped_Test < Test::Unit::TestCase
   def setup
+<<<<<<< .working
     @dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new('Test')
     @uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.5')
@@ -92,7 +93,15 @@
     assert_nothing_raised(Exception){@archetyped = OpenEHR::RM::Common::Archetyped::Archetyped.new(@archetype_id, '1.0.1')}
     assert_nothing_raised(Exception){@link = OpenEHR::RM::Common::Archetyped::Link.new(OpenEHR::RM::Data_Types::Text::DV_Text.new("generic"), OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://test/"),OpenEHR::RM::Data_Types::Text::DV_Text.new("problem"))}
-    assert_nothing_raised(Exception){
-      @pathable = OpenEHR::RM::Common::Archetyped::Pathable.new }
-    name = OpenEHR::RM::Data_Types::Text::DV_Text.new('blood')
+=======
+    @dv_text = OpenEhr::RM::DataTypes::Text::DvText.new('Test')
+    @uid_based_id = OpenEhr::RM::Support::Identification::UidBasedId.new('rrip::0.0.5')
+    @archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
+    @template_id = OpenEhr::RM::Support::Identification::TemplateId.new('1.0.1')
+    assert_nothing_raised(Exception){@archetyped = OpenEhr::RM::Common::Archetyped::Archetyped.new(@archetype_id, '1.0.1')}
+    assert_nothing_raised(Exception){@link = OpenEhr::RM::Common::Archetyped::Link.new(OpenEhr::RM::DataTypes::Text::DvText.new("generic"), OpenEhr::RM::DataTypes::Uri::DvEhrUri.new("ehr://test/"),OpenEhr::RM::DataTypes::Text::DvText.new("problem"))}
+>>>>>>> .merge-right.r168
+    assert_nothing_raised(Exception){
+      @pathable = OpenEhr::RM::Common::Archetyped::Pathable.new }
+    name = OpenEhr::RM::DataTypes::Text::DvText.new('blood')
     links = Set.new([@uid_based_id])
     assert_nothing_raised(Exception){
@@ -100,25 +109,25 @@
                                  :name => name,
                                  :links => links)}
-    provider = Party_Identified.new(:name => 'NERV')
-    location = Party_Identified.new(:name => 'GEOFRONT')
-    object_version_id = Object_Version_ID.new('ABC::DEF::1.3.4')
-    party_ref = Party_Ref.new('local', 'ORGANISATION', object_id)
-    assert_nothing_raised(Exception){
-      @feeder_audit_details = Feeder_Audit_Details.new(:system_id => 'MAGI',
+    provider = PartyIdentified.new(:name => 'NERV')
+    location = PartyIdentified.new(:name => 'GEOFRONT')
+    object_version_id = ObjectVersionId.new('ABC::DEF::1.3.4')
+    party_ref = PartyRef.new('local', 'ORGANISATION', object_id)
+    assert_nothing_raised(Exception){
+      @feeder_audit_details = FeederAuditDetails.new(:system_id => 'MAGI',
                                                        :provider => provider,
                                                        :location => location,
-                                                       :time => DV_Date_Time.new('2009-07-03T12:16:31'),
-                                                       :subject => Party_Proxy.new(:external_ref => party_ref),
+                                                       :time => DvDateTime.new('2009-07-03T12:16:31'),
+                                                       :subject => PartyProxy.new(:external_ref => party_ref),
                                                        :version_id => '0.0.4')}
-    feeder_audit_details = Feeder_Audit_Details.new(:system_id => 'AKAGI')
-    dv_identifier = DV_Identifier.new('NERV', 'MELCHIOR', 'RITSUKO', 'COMPUTER')
-    feeder_audit_details2 = Feeder_Audit_Details.new(:system_id => 'KATSURAGI')
-    dv_identifier2 = DV_Identifier.new('NERV', 'SHOGOUKI', 'MISATO', 'EVANGELION')
-    charset = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('UTF-8','character-sets')
-    language = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('ja', 'languages')
-
-    dv_encapsulated = OpenEHR::RM::Data_Types::Encapsulated::DV_Encapsulated.new(charset, language, 10)
-    assert_nothing_raised(Exception){
-      @feeder_audit = Feeder_Audit.new(:originating_system_audit => feeder_audit_details,
+    feeder_audit_details = FeederAuditDetails.new(:system_id => 'AKAGI')
+    dv_identifier = DvIdentifier.new('NERV', 'MELCHIOR', 'RITSUKO', 'COMPUTER')
+    feeder_audit_details2 = FeederAuditDetails.new(:system_id => 'KATSURAGI')
+    dv_identifier2 = DvIdentifier.new('NERV', 'SHOGOUKI', 'MISATO', 'EVANGELION')
+    charset = OpenEhr::RM::DataTypes::Text::CodePhrase.new('UTF-8','character-sets')
+    language = OpenEhr::RM::DataTypes::Text::CodePhrase.new('ja', 'languages')
+
+    dv_encapsulated = OpenEhr::RM::DataTypes::Encapsulated::DvEncapsulated.new(charset, language, 10)
+    assert_nothing_raised(Exception){
+      @feeder_audit = FeederAudit.new(:originating_system_audit => feeder_audit_details,
                                        :originating_system_item_ids => [dv_identifier],
                                        :feeder_system_audit => feeder_audit_details2,
@@ -128,10 +137,10 @@
 
   def test_init
-    assert_instance_of OpenEHR::RM::Common::Archetyped::Archetyped, @archetyped
-    assert_instance_of OpenEHR::RM::Common::Archetyped::Link, @link
-    assert_instance_of OpenEHR::RM::Common::Archetyped::Pathable, @pathable
-    assert_instance_of OpenEHR::RM::Common::Archetyped::Locatable, @locatable
-    assert_instance_of Feeder_Audit_Details, @feeder_audit_details
-    assert_instance_of Feeder_Audit, @feeder_audit
+    assert_instance_of OpenEhr::RM::Common::Archetyped::Archetyped, @archetyped
+    assert_instance_of OpenEhr::RM::Common::Archetyped::Link, @link
+    assert_instance_of OpenEhr::RM::Common::Archetyped::Pathable, @pathable
+    assert_instance_of OpenEhr::RM::Common::Archetyped::Locatable, @locatable
+    assert_instance_of FeederAuditDetails, @feeder_audit_details
+    assert_instance_of FeederAudit, @feeder_audit
   end
 
@@ -144,5 +153,9 @@
     assert_nothing_raised(Exception){@archetyped.template_id = @template_id}
     assert_equal @template_id, @archetyped.template_id
+<<<<<<< .working
     archetype_id2 = OpenEHR::RM::Support::Identification::Archetype_ID.new('openEHR-EHR-SECTION.physical_examination-prenatal.v2')
+=======
+    archetype_id2 = OpenEhr::RM::Support::Identification::ArchetypeId.new("1.0.2", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")
+>>>>>>> .merge-right.r168
     assert_nothing_raised(ArgumentError){@archetyped.archetype_id = archetype_id2}
     assert_equal archetype_id2, @archetyped.archetype_id
@@ -157,13 +170,13 @@
     assert_equal 'problem', @link.type.value
     # test meaning
-    assert_nothing_raised(Exception){@link.meaning = OpenEHR::RM::Data_Types::Text::DV_Text.new('clinical')}
+    assert_nothing_raised(Exception){@link.meaning = OpenEhr::RM::DataTypes::Text::DvText.new('clinical')}
     assert_equal 'clinical', @link.meaning.value
     assert_raise(ArgumentError){@link.meaning = nil}
     # test target
-    assert_nothing_raised(Exception){@link.target = OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://try/")}
+    assert_nothing_raised(Exception){@link.target = OpenEhr::RM::DataTypes::Uri::DvEhrUri.new("ehr://try/")}
     assert_equal 'ehr://try/', @link.target.value
     assert_raise(ArgumentError){@link.target = nil}
     # test type
-    assert_nothing_raised(Exception){@link.type = OpenEHR::RM::Data_Types::Text::DV_Text.new("issue")}
+    assert_nothing_raised(Exception){@link.type = OpenEhr::RM::DataTypes::Text::DvText.new("issue")}
     assert_equal 'issue', @link.type.value
     assert_raise(ArgumentError){@link.type = nil}
@@ -190,35 +203,35 @@
 class RM_Common_Generic_Test < Test::Unit::TestCase
   def setup
-    assert_nothing_raised(Exception){party_proxy = Party_Proxy.new}
-    object_id = Object_ID.new('0.0.4')
-    party_ref = Party_Ref.new('unknown', 'ORGANISATION', object_id)
-    assert_nothing_raised(Exception){
-      @party_proxy = Party_Proxy.new(:external_ref => party_ref)}
-    assert_nothing_raised(Exception){party_self = Party_Self.new}
-    assert_nothing_raised(Exception){
-      @party_self = Party_Self.new(:external_ref => party_ref)}
+    assert_nothing_raised(Exception){party_proxy = PartyProxy.new}
+    object_id = ObjectId.new('0.0.4')
+    party_ref = PartyRef.new('unknown', 'ORGANISATION', object_id)
+    assert_nothing_raised(Exception){
+      @party_proxy = PartyProxy.new(:external_ref => party_ref)}
+    assert_nothing_raised(Exception){party_self = PartySelf.new}
+    assert_nothing_raised(Exception){
+      @party_self = PartySelf.new(:external_ref => party_ref)}
     assert_raise(ArgumentError){
-      party_identified = Party_Identified.new}
+      party_identified = PartyIdentified.new}
 
     identifiers = []
-    identifiers << DV_Identifier.new('NERV', 'MELCHIOR', 'GENDO', 'COMPUTER')
-    identifiers << DV_Identifier.new('NERV', 'CASPER', 'GENDO', 'COMPUTER')
-    identifiers << DV_Identifier.new('NERV', 'BALTHAZAR', 'GENDO', 'COMPUTER')
-    assert_nothing_raised(Exception){
-      @party_identified = Party_Identified.new(:name => 'NERV',
+    identifiers << DvIdentifier.new('NERV', 'MELCHIOR', 'GENDO', 'COMPUTER')
+    identifiers << DvIdentifier.new('NERV', 'CASPER', 'GENDO', 'COMPUTER')
+    identifiers << DvIdentifier.new('NERV', 'BALTHAZAR', 'GENDO', 'COMPUTER')
+    assert_nothing_raised(Exception){
+      @party_identified = PartyIdentified.new(:name => 'NERV',
                                                :external_ref => party_ref,
                                                :identifier => identifiers)}
 
-    terminology_id = Terminology_ID.new('test(0.04)')
-    code_phrase = Code_Phrase.new('self', terminology_id)
-    dv_coded_text = DV_Coded_Text.new('Seele',code_phrase)
-    assert_nothing_raised(Exception){
-      @party_related = Party_Related.new(:name => 'GEHIRN',
+    terminology_id = TerminologyId.new('test(0.04)')
+    code_phrase = CodePhrase.new('self', terminology_id)
+    dv_coded_text = DvCodedText.new('Seele',code_phrase)
+    assert_nothing_raised(Exception){
+      @party_related = PartyRelated.new(:name => 'GEHIRN',
                                          :relationship => dv_coded_text)}
-    dv_text = DV_Text.new('commiter')
-    dv_coded_text = DV_Coded_Text.new('present',terminology_id)
-    dv_date_time1 = DV_Date_Time.new('2009-07-04T16:30:00')
-    dv_date_time2 = DV_Date_Time.new('2009-07-14T00:00:00')
-    dv_interval = DV_Interval.new(dv_date_time1, dv_date_time2)
+    dv_text = DvText.new('commiter')
+    dv_coded_text = DvCodedText.new('present',terminology_id)
+    dv_date_time1 = DvDateTime.new('2009-07-04T16:30:00')
+    dv_date_time2 = DvDateTime.new('2009-07-14T00:00:00')
+    dv_interval = DvInterval.new(dv_date_time1, dv_date_time2)
     assert_nothing_raised(Exception){
       @participation = Participation.new(:performer => @party_proxy,
@@ -226,17 +239,17 @@
                                          :mode => dv_coded_text,
                                          :time => dv_interval)}
-    dv_date_time = DV_Date_Time.new('2009-07-04T18:56:00')
-    terminology_id = Terminology_ID.new('openehr(1.0.2)')
-    code_phrase = Code_Phrase.new('249', terminology_id)
-    dv_coded_text = DV_Coded_Text.new('creation', code_phrase)
-    dv_text = DV_Text.new('test environment')
-    assert_nothing_raised(Exception){
-      @audit_details = Audit_Details.new(:system_id => 'MAGI',
+    dv_date_time = DvDateTime.new('2009-07-04T18:56:00')
+    terminology_id = TerminologyId.new('openehr(1.0.2)')
+    code_phrase = CodePhrase.new('249', terminology_id)
+    dv_coded_text = DvCodedText.new('creation', code_phrase)
+    dv_text = DvText.new('test environment')
+    assert_nothing_raised(Exception){
+      @audit_details = AuditDetails.new(:system_id => 'MAGI',
                                          :committer => @party_proxy,
                                          :time_committed => dv_date_time,
                                          :change_type => dv_coded_text,
                                          :description => dv_text)}
-    dv_text = DV_Text.new('authorisation')
-    dv_ehr_uri = DV_EHR_URI.new('ehr://test/')
+    dv_text = DvText.new('authorisation')
+    dv_ehr_uri = DvEhrUri.new('ehr://test/')
     assert_nothing_raised(Exception){
       @attestation = Attestation.new(:system_id => 'NERV',
@@ -248,38 +261,38 @@
                                      :proof => 'hashedstring',
                                      :items => Set[dv_ehr_uri])}
-    object_version_id = Object_Version_ID.new('SHOGOUKI::NERV::1.1.1')
-    audit_details2 = Audit_Details.new(:system_id => 'MAGI',
+    object_version_id = ObjectVersionId.new('SHOGOUKI::NERV::1.1.1')
+    audit_details2 = AuditDetails.new(:system_id => 'MAGI',
                                        :committer => @party_proxy,
                                        :time_committed => dv_date_time2,
                                        :change_type => dv_coded_text)
     assert_nothing_raised(Exception){
-      @revision_history_item = Revision_History_Item.new(:audits => [@audit_details, audit_details2],
+      @revision_history_item = RevisionHistoryItem.new(:audits => [@audit_details, audit_details2],
                                                          :version_id => object_version_id)}
-    dv_date_time3 = DV_Date_Time.new('2009-07-14T12:00:00')
-    dv_date_time4 = DV_Date_Time.new('2009-07-15T00:00:00')
-    audit_details3 = Audit_Details.new(:system_id => 'MAGI',
+    dv_date_time3 = DvDateTime.new('2009-07-14T12:00:00')
+    dv_date_time4 = DvDateTime.new('2009-07-15T00:00:00')
+    audit_details3 = AuditDetails.new(:system_id => 'MAGI',
                                      :committer => @party_proxy,
                                      :time_committed => dv_date_time3,
                                      :change_type => dv_coded_text)
-    audit_details4 = Audit_Details.new(:system_id => 'MAGI',
+    audit_details4 = AuditDetails.new(:system_id => 'MAGI',
                                      :committer => @party_proxy,
                                      :time_committed => dv_date_time4,
                                      :change_type => dv_coded_text)
-    object_version_id = Object_Version_ID.new('NIGOUKI::NERV::2.2.2')
-    revision_history_item2 = Revision_History_Item.new(:audits => [audit_details3, audit_details4],
+    object_version_id = ObjectVersionId.new('NIGOUKI::NERV::2.2.2')
+    revision_history_item2 = RevisionHistoryItem.new(:audits => [audit_details3, audit_details4],
                                                       :version_id => object_version_id)
     assert_nothing_raised(Exception){
-      @revision_history = Revision_History.new([@revision_history_item, revision_history_item2])}
+      @revision_history = RevisionHistory.new([@revision_history_item, revision_history_item2])}
   end
 
   def test_init
-    assert_instance_of Party_Proxy, @party_proxy
-    assert_instance_of Party_Self, @party_self
-    assert_instance_of Party_Identified, @party_identified
+    assert_instance_of PartyProxy, @party_proxy
+    assert_instance_of PartySelf, @party_self
+    assert_instance_of PartyIdentified, @party_identified
     assert_instance_of Participation, @participation
-    assert_instance_of Audit_Details, @audit_details
+    assert_instance_of AuditDetails, @audit_details
     assert_instance_of Attestation, @attestation
-    assert_instance_of Revision_History_Item, @revision_history_item
-    assert_instance_of Revision_History, @revision_history
+    assert_instance_of RevisionHistoryItem, @revision_history_item
+    assert_instance_of RevisionHistory, @revision_history
   end
 
@@ -347,7 +360,7 @@
   def setup
     archetype_node_id = 'at0001'
-    name = DV_Text.new('folder_test')
-    object_id = Object_ID.new('1.1.1')
-    object_ref = Object_Ref.new('local', 'PARTY', object_id)
+    name = DvText.new('folder_test')
+    object_id = ObjectId.new('1.1.1')
+    object_ref = ObjectRef.new('local', 'PARTY', object_id)
     assert_nothing_raised(Exception){
       @folder = Folder.new(:archetype_node_id => archetype_node_id,
@@ -359,5 +372,5 @@
   
   def test_init
-    assert_instance_of OpenEHR::RM::Common::Directory::Folder, @folder
+    assert_instance_of OpenEhr::RM::Common::Directory::Folder, @folder
   end
 
@@ -370,22 +383,22 @@
 class RM_Common_Change_Control_Test < Test::Unit::TestCase
   def setup
-    object_version_id1 = Object_Version_ID.new('ABC::DEF::2.2.3')
-    object_version_id2 = Object_Version_ID.new('GHI::JKL::4.5.6')
-    object_id = Object_ID.new('ehr://uniqueid1020')
-    dv_date_time = DV_Date_Time.new('2009-07-06T21:10:12')
-    party_ref = Party_Ref.new('unknown', 'ORGANISATION', object_id)
-    party_proxy = Party_Proxy.new(:external_ref => party_ref)
-    terminology_id = Terminology_ID.new('openehr(1.0.2)')
-    code_phrase = Code_Phrase.new('249', terminology_id)
-    dv_coded_text = DV_Coded_Text.new('creation', code_phrase)
-    audit_details = Audit_Details.new(:system_id => 'MAGI',
+    object_version_id1 = ObjectVersionId.new('ABC::DEF::2.2.3')
+    object_version_id2 = ObjectVersionId.new('GHI::JKL::4.5.6')
+    object_id = ObjectId.new('ehr://uniqueid1020')
+    dv_date_time = DvDateTime.new('2009-07-06T21:10:12')
+    party_ref = PartyRef.new('unknown', 'ORGANISATION', object_id)
+    party_proxy = PartyProxy.new(:external_ref => party_ref)
+    terminology_id = TerminologyId.new('openehr(1.0.2)')
+    code_phrase = CodePhrase.new('249', terminology_id)
+    dv_coded_text = DvCodedText.new('creation', code_phrase)
+    audit_details = AuditDetails.new(:system_id => 'MAGI',
                                       :committer => party_proxy,
                                       :time_committed => dv_date_time,
                                       :change_type => dv_coded_text)
-    code_phrase = Code_Phrase.new('532', terminology_id)
-    dv_coded_text = DV_Coded_Text.new('complete', code_phrase)
-    object_id = Object_ID.new('ehr://test_location')
-    object_ref = Object_Ref.new('local', 'PARTY', object_id)
-    hier_object_id = Hier_Object_ID.new('ABC')
+    code_phrase = CodePhrase.new('532', terminology_id)
+    dv_coded_text = DvCodedText.new('complete', code_phrase)
+    object_id = ObjectId.new('ehr://test_location')
+    object_ref = ObjectRef.new('local', 'PARTY', object_id)
+    hier_object_id = HierObjectId.new('ABC')
     assert_nothing_raised(Exception){
       @version = Version.new(:uid => object_version_id1,
@@ -396,20 +409,20 @@
                              :signature => 'test_version',
                              :data => 'data')}
-    object_version_id3 = Object_Version_ID.new('MNO::PQR::7.8.9')
-    object_version_id4 = Object_Version_ID.new('STU::VWX::1.2.3')
-    code_phrase = Code_Phrase.new('240', terminology_id)
-    dv_coded_text2 = DV_Coded_Text.new('signed', code_phrase)
+    object_version_id3 = ObjectVersionId.new('MNO::PQR::7.8.9')
+    object_version_id4 = ObjectVersionId.new('STU::VWX::1.2.3')
+    code_phrase = CodePhrase.new('240', terminology_id)
+    dv_coded_text2 = DvCodedText.new('signed', code_phrase)
     attestation = Attestation.new(:system_id => 'NERV',
                                   :committer => party_proxy,
                                   :time_committed => dv_date_time,
                                   :change_type => dv_coded_text,
-                                  :reason => DV_Text.new('signed'))
-    dv_date_time = DV_Date_Time.new('2009-07-07T21:10:12')
-    audit_details = Audit_Details.new(:system_id => 'MAGI',
+                                  :reason => DvText.new('signed'))
+    dv_date_time = DvDateTime.new('2009-07-07T21:10:12')
+    audit_details = AuditDetails.new(:system_id => 'MAGI',
                                       :committer => party_proxy,
                                       :time_committed => dv_date_time,
                                       :change_type => dv_coded_text)
     assert_nothing_raised(Exception){
-      @original_version = Original_Version.new(:uid => object_version_id3,
+      @original_version = OriginalVersion.new(:uid => object_version_id3,
                                                :preceding_version_uid => object_version_id4,
                                                :other_input_version_uids => Set[object_version_id1, object_version_id2],
@@ -419,13 +432,13 @@
                                                :data => 'data',
                                                :lifecycle_state => dv_coded_text)}
-    dv_date_time = DV_Date_Time.new('2009-07-08T21:10:12')
-    audit_details = Audit_Details.new(:system_id => 'CASPER',
+    dv_date_time = DvDateTime.new('2009-07-08T21:10:12')
+    audit_details = AuditDetails.new(:system_id => 'CASPER',
                                       :committer => party_proxy,
                                       :time_committed => dv_date_time,
                                       :change_type => dv_coded_text,
                                       :description => 'for contribution')
-    object_ref = Object_Ref.new('unknown', 'PARTY', object_id)
-    assert_nothing_raised(Exception){
-      @imported_version = Imported_Version.new(:item => @original_version,
+    object_ref = ObjectRef.new('unknown', 'PARTY', object_id)
+    assert_nothing_raised(Exception){
+      @imported_version = ImportedVersion.new(:item => @original_version,
                                                :commit_audit => audit_details,
                                                :contribution => object_ref,
@@ -435,6 +448,6 @@
                                        :versions => Set[object_ref],
                                        :audit => audit_details)}
-    dv_date_time = DV_Date_Time.new('2009-07-08T18:10:12')
-    audit_details = Audit_Details.new(:system_id => 'MAGI',
+    dv_date_time = DvDateTime.new('2009-07-08T18:10:12')
+    audit_details = AuditDetails.new(:system_id => 'MAGI',
                                       :committer => party_proxy,
                                       :time_committed => dv_date_time,
@@ -446,5 +459,5 @@
                                 :change_type => dv_coded_text)
     assert_nothing_raised(Exception){
-      @versioned_object = Versioned_Object.new(:uid => hier_object_id,
+      @versioned_object = VersionedObject.new(:uid => hier_object_id,
                                                :owner_id => object_ref,
                                                :time_created => dv_date_time,
@@ -453,9 +466,9 @@
 
   def test_init
-    assert_instance_of OpenEHR::RM::Common::Change_Control::Version, @version
-    assert_instance_of Original_Version, @original_version
-    assert_instance_of Imported_Version, @imported_version
-    assert_instance_of OpenEHR::RM::Common::Change_Control::Contribution, @contribution
-    assert_instance_of Versioned_Object, @versioned_object
+    assert_instance_of OpenEhr::RM::Common::ChangeControl::Version, @version
+    assert_instance_of OriginalVersion, @original_version
+    assert_instance_of ImportedVersion, @imported_version
+    assert_instance_of OpenEhr::RM::Common::ChangeControl::Contribution, @contribution
+    assert_instance_of VersionedObject, @versioned_object
   end
 
@@ -505,5 +518,5 @@
     assert !@versioned_object.is_original_version?(@version.uid)
     assert @versioned_object.is_original_version?(@original_version.uid)
-    assert @versioned_object.has_version_at_time?(DV_Date_Time.new('2009-07-06T21:10:12'))
+    assert @versioned_object.has_version_at_time?(DvDateTime.new('2009-07-06T21:10:12'))
     assert_equal @version, @versioned_object.version_with_id(@version.uid)
     assert_equal @version, @versioned_object.version_at_time(@version.commit_audit.time_committed)
@@ -538,10 +551,10 @@
                                                 :item => @imported_version.item)}
     assert_equal 7, @versioned_object.version_count
-    dv_date_time = DV_Date_Time.new('2009-07-07T22:11:31')
+    dv_date_time = DvDateTime.new('2009-07-07T22:11:31')
     attestation = Attestation.new(:system_id => 'NERV2',
                                   :committer => @version.contribution,
                                   :time_committed => dv_date_time,
                                   :change_type => @original_version.commit_audit.change_type,
-                                  :reason => DV_Text.new('signed'))
+                                  :reason => DvText.new('signed'))
     assert_nothing_raised(Exception){
       @versioned_object.commit_attestation(:attestation => attestation,
Index: ruby/trunk/lib/models/tests/rm/test_data_structure.rb
===================================================================
--- ruby/trunk/lib/models/tests/rm/test_data_structure.rb	(revision 283)
+++ ruby/trunk/lib/models/tests/rm/test_data_structure.rb	(revision 291)
@@ -3,5 +3,10 @@
 require 'rm'
 
+<<<<<<< .working
 include OpenEHR::RM::Data_Structures
+=======
+include OpenEHR::RM::Data_Structures
+include OpenEHR::RM::Data_Structures::Item_Structure
+>>>>>>> .merge-right.r168
 
 class RmDataStructureTest < Test::Unit::TestCase
@@ -24,2 +29,12 @@
   end
 end
+
+class RmDataStructureItemStructureTest < Test::Unit::TestCase
+  def setup
+    assert_nothing_raised(Exception){
+      
+  end
+
+  def test_init
+  end
+end
Index: ruby/trunk/lib/models/tests/rm/test_data_types.rb
===================================================================
--- ruby/trunk/lib/models/tests/rm/test_data_types.rb	(revision 283)
+++ ruby/trunk/lib/models/tests/rm/test_data_types.rb	(revision 291)
@@ -6,21 +6,21 @@
 class RM_Data_Types_Basic_Test < Test::Unit::TestCase
   def setup
-    assert_nothing_raised(Exception){@dv_boolean = OpenEHR::RM::Data_Types::Basic::DV_Boolean.new("TRUE")}
-    @terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('openEHR(1.0.2)')
-    @code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('PROPOSED', @terminology_id)
-    @dv_coded_text = OpenEHR::RM::Data_Types::Text::DV_Coded_Text.new("Blood examination", @code_phrase)
-    assert_nothing_raised(Exception){@dv_state = OpenEHR::RM::Data_Types::Basic::DV_State.new(@dv_coded_text, false)}
-    assert_nothing_raised(Exception){@dv_identifier = OpenEHR::RM::Data_Types::Basic::DV_Identifier.new("Ruby Hospital","0123456-0", "Information office", "personal id")}
+    assert_nothing_raised(Exception){@dv_boolean = OpenEhr::RM::DataTypes::Basic::DvBoolean.new("TRUE")}
+    @terminology_id = OpenEhr::RM::Support::Identification::TerminologyId.new('openEHR(1.0.2)')
+    @code_phrase = OpenEhr::RM::DataTypes::Text::CodePhrase.new('PROPOSED', @terminology_id)
+    @dv_coded_text = OpenEhr::RM::DataTypes::Text::DvCodedText.new("Blood examination", @code_phrase)
+    assert_nothing_raised(Exception){@dv_state = OpenEhr::RM::DataTypes::Basic::DvState.new(@dv_coded_text, false)}
+    assert_nothing_raised(Exception){@dv_identifier = OpenEhr::RM::DataTypes::Basic::DvIdentifier.new("Ruby Hospital","0123456-0", "Information office", "personal id")}
   end
 
   def test_init
-    assert_instance_of OpenEHR::RM::Data_Types::Basic::DV_Boolean, @dv_boolean
-    assert_instance_of OpenEHR::RM::Data_Types::Basic::DV_State, @dv_state
-    assert_instance_of OpenEHR::RM::Data_Types::Basic::DV_Identifier, @dv_identifier
+    assert_instance_of OpenEhr::RM::DataTypes::Basic::DvBoolean, @dv_boolean
+    assert_instance_of OpenEhr::RM::DataTypes::Basic::DvState, @dv_state
+    assert_instance_of OpenEhr::RM::DataTypes::Basic::DvIdentifier, @dv_identifier
   end
 
   def test_constant
-    assert_equal("\r", OpenEHR::RM::Data_Types::Basic::Data_Value::CR)
-    assert_equal("\n", OpenEHR::RM::Data_Types::Basic::Data_Value::LF)
+    assert_equal("\r", OpenEhr::RM::DataTypes::Basic::DataValue::CR)
+    assert_equal("\n", OpenEhr::RM::DataTypes::Basic::DataValue::LF)
   end
 
@@ -31,5 +31,5 @@
     # inv: Value_exists
     assert_raise(ArgumentError){@dv_boolean.value=nil}
-    assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Basic::DV_Boolean.new(nil)}
+    assert_raise(ArgumentError){OpenEhr::RM::DataTypes::Basic::DvBoolean.new(nil)}
   end
 
@@ -44,5 +44,5 @@
     assert_equal 'COMPLETED', @dv_state.value.defining_code.code_string
     assert @dv_state.is_terminal?
-    assert_raise(ArgumentError) {OpenEHR::RM::Data_Types::Basic::DV_State.new(nil,nil)}
+    assert_raise(ArgumentError) {OpenEhr::RM::DataTypes::Basic::DvState.new(nil,nil)}
     assert_raise(ArgumentError) {@dv_state.value=nil}
     assert_raise(ArgumentError) {@dv_state.is_terminal=nil}
@@ -62,5 +62,5 @@
     @dv_identifier.type = "test id"
     assert_equal("test id", @dv_identifier.type)
-    assert_raise(ArgumentError) {OpenEHR::RM::Data_Types::Basic::DV_Identifier.new(nil, nil, nil, nil)}
+    assert_raise(ArgumentError) {OpenEhr::RM::DataTypes::Basic::DvIdentifier.new(nil, nil, nil, nil)}
   end
 end
@@ -69,11 +69,11 @@
 class RM_Data_Types_URI_Test < Test::Unit::TestCase
   def setup
-    @dv_uri = OpenEHR::RM::Data_Types::URI::DV_URI.new("http://www.openehr.jp/changeset/test?cmd=93#file0")
-    @dv_ehr_uri = OpenEHR::RM::Data_Types::URI::DV_EHR_URI.new("ehr://1234567/87284370-2D4B-4e3d-A3F3-F303D2F4F34B@2005-08-02T04:30:00")
+    @dv_uri = OpenEhr::RM::DataTypes::Uri::DvUri.new("http://www.openehr.jp/changeset/test?cmd=93#file0")
+    @dv_ehr_uri = OpenEhr::RM::DataTypes::Uri::DvEhrUri.new("ehr://1234567/87284370-2D4B-4e3d-A3F3-F303D2F4F34B@2005-08-02T04:30:00")
   end
 
   def test_init
-    assert_instance_of OpenEHR::RM::Data_Types::URI::DV_URI, @dv_uri
-    assert_instance_of OpenEHR::RM::Data_Types::URI::DV_EHR_URI, @dv_ehr_uri    
+    assert_instance_of OpenEhr::RM::DataTypes::Uri::DvUri, @dv_uri
+    assert_instance_of OpenEhr::RM::DataTypes::Uri::DvEhrUri, @dv_ehr_uri
   end
 
@@ -98,18 +98,18 @@
 class RM_Data_Types_Text_Test < Test::Unit::TestCase
   def setup
-    assert_nothing_raised(Exception){@dv_text = OpenEHR::RM::Data_Types::Text::DV_Text.new("valid value")}
-    @terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('ICD10')
+    assert_nothing_raised(Exception){@dv_text = OpenEhr::RM::DataTypes::Text::DvText.new("valid value")}
+    @terminology_id = OpenEhr::RM::Support::Identification::TerminologyId.new('ICD10')
     
-    assert_nothing_raised(Exception){@code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('C92.0', @terminology_id)}
-    assert_nothing_raised(Exception){@dv_coded_text = OpenEHR::RM::Data_Types::Text::DV_Coded_Text.new("Acute Myeloid Leukemia", @code_phrase)}
-    @dv_paragraph = OpenEHR::RM::Data_Types::Text::DV_Paragraph.new(Set.new(["test1", "test2"]))
-    @term_mapping = OpenEHR::RM::Data_Types::Text::Term_Mapping.new('=',@dv_coded_text,"TEST")
+    assert_nothing_raised(Exception){@code_phrase = OpenEhr::RM::DataTypes::Text::CodePhrase.new('C92.0', @terminology_id)}
+    assert_nothing_raised(Exception){@dv_coded_text = OpenEhr::RM::DataTypes::Text::DvCodedText.new("Acute Myeloid Leukemia", @code_phrase)}
+    @dv_paragraph = OpenEhr::RM::DataTypes::Text::DvParagraph.new(Set.new(["test1", "test2"]))
+    @term_mapping = OpenEhr::RM::DataTypes::Text::TermMapping.new('=',@dv_coded_text,"TEST")
   end
 
   def test_init
-    assert_instance_of OpenEHR::RM::Data_Types::Text::DV_Text, @dv_text
-    assert_instance_of OpenEHR::RM::Data_Types::Text::Code_Phrase, @code_phrase
-    assert_instance_of OpenEHR::RM::Data_Types::Text::DV_Coded_Text, @dv_coded_text
-    assert_instance_of OpenEHR::RM::Data_Types::Text::Term_Mapping, @term_mapping
+    assert_instance_of OpenEhr::RM::DataTypes::Text::DvText, @dv_text
+    assert_instance_of OpenEhr::RM::DataTypes::Text::CodePhrase, @code_phrase
+    assert_instance_of OpenEhr::RM::DataTypes::Text::DvCodedText, @dv_coded_text
+    assert_instance_of OpenEhr::RM::DataTypes::Text::TermMapping, @term_mapping
   end
 
@@ -147,15 +147,15 @@
   def test_term_mapping
     assert_equal '=', @term_mapping.match
-    assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('>')
-    assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('=')
-    assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('<')
-    assert OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('?')
-    assert !OpenEHR::RM::Data_Types::Text::Term_Mapping.is_valid_mach_code?('!')
+    assert OpenEhr::RM::DataTypes::Text::TermMapping.is_valid_mach_code?('>')
+    assert OpenEhr::RM::DataTypes::Text::TermMapping.is_valid_mach_code?('=')
+    assert OpenEhr::RM::DataTypes::Text::TermMapping.is_valid_mach_code?('<')
+    assert OpenEhr::RM::DataTypes::Text::TermMapping.is_valid_mach_code?('?')
+    assert !OpenEhr::RM::DataTypes::Text::TermMapping.is_valid_mach_code?('!')
     assert_equal @dv_coded_text, @term_mapping.purpose
     assert_equal "TEST", @term_mapping.target
-    assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new}
-    assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new('!',@dv_coded_text, "invalid case")}
-    assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new('=',nil , "invalid case")}
-    assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Text::Term_Mapping.new('=',@dv_coded_text, nil)}
+    assert_raise(ArgumentError){OpenEhr::RM::DataTypes::Text::TermMapping.new}
+    assert_raise(ArgumentError){OpenEhr::RM::DataTypes::Text::TermMapping.new('!',@dv_coded_text, "invalid case")}
+    assert_raise(ArgumentError){OpenEhr::RM::DataTypes::Text::TermMapping.new('=',nil , "invalid case")}
+    assert_raise(ArgumentError){OpenEhr::RM::DataTypes::Text::TermMapping.new('=',@dv_coded_text, nil)}
   end
 end
@@ -164,45 +164,45 @@
   def setup
     assert_nothing_raised(Exception){
-      @dv_ordered = OpenEHR::RM::Data_Types::Quantity::DV_Ordered.new }
-    assert_nothing_raised(Exception){
-      terminology = OpenEHR::RM::Support::Identification::Terminology_ID.new('urine')
-      code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('protein',terminology)
-      urinary_protein = OpenEHR::RM::Data_Types::Text::DV_Coded_Text.new('+', code_phrase)
-      @dv_ordinal1 = OpenEHR::RM::Data_Types::Quantity::DV_Ordinal.new(1, urinary_protein)
-      code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('protein',terminology)
-      urinary_protein = OpenEHR::RM::Data_Types::Text::DV_Coded_Text.new('+++', code_phrase)
-      @dv_ordinal2 = OpenEHR::RM::Data_Types::Quantity::DV_Ordinal.new(3, urinary_protein)}
-    assert_nothing_raised(Exception){
-      @dv_interval = OpenEHR::RM::Data_Types::Quantity::DV_Interval.new(@dv_ordinal1, @dv_ordinal2)}
-    meaning = OpenEHR::RM::Data_Types::Text::DV_Text.new('normal')
-    assert_nothing_raised(Exception){
-      @reference_range = OpenEHR::RM::Data_Types::Quantity::Reference_Range.new(meaning, @dv_interval)}
-    assert_nothing_raised(Exception){
-      @dv_quantified = OpenEHR::RM::Data_Types::Quantity::DV_Quantified.new(1,'=')}
-    assert_nothing_raised(Exception){
-      @dv_amount = OpenEHR::RM::Data_Types::Quantity::DV_Amount.new(2,'<')}
-    assert_nothing_raised(Exception){
-      @dv_quantity = OpenEHR::RM::Data_Types::Quantity::DV_Quantity.new(3, 'mg', '~')}
-    assert_nothing_raised(Exception){
-      @dv_count = OpenEHR::RM::Data_Types::Quantity::DV_Count.new(1)}
-    assert_nothing_raised(Exception){
-      @dv_proportion = OpenEHR::RM::Data_Types::Quantity::DV_Proportion.new(2,3,0)}
-    assert_nothing_raised(Exception){
-      @dv_absolute_quantity = OpenEHR::RM::Data_Types::Quantity::DV_Absolute_Quantity.new(7,'=')}
+      @dv_ordered = OpenEhr::RM::DataTypes::Quantity::DvOrdered.new }
+    assert_nothing_raised(Exception){
+      terminology = OpenEhr::RM::Support::Identification::TerminologyId.new('urine')
+      code_phrase = OpenEhr::RM::DataTypes::Text::CodePhrase.new('protein',terminology)
+      urinary_protein = OpenEhr::RM::DataTypes::Text::DvCodedText.new('+', code_phrase)
+      @dv_ordinal1 = OpenEhr::RM::DataTypes::Quantity::DvOrdinal.new(1, urinary_protein)
+      code_phrase = OpenEhr::RM::DataTypes::Text::CodePhrase.new('protein',terminology)
+      urinary_protein = OpenEhr::RM::DataTypes::Text::DvCodedText.new('+++', code_phrase)
+      @dv_ordinal2 = OpenEhr::RM::DataTypes::Quantity::DvOrdinal.new(3, urinary_protein)}
+    assert_nothing_raised(Exception){
+      @dv_interval = OpenEhr::RM::DataTypes::Quantity::DvInterval.new(@dv_ordinal1, @dv_ordinal2)}
+    meaning = OpenEhr::RM::DataTypes::Text::DvText.new('normal')
+    assert_nothing_raised(Exception){
+      @reference_range = OpenEhr::RM::DataTypes::Quantity::ReferenceRange.new(meaning, @dv_interval)}
+    assert_nothing_raised(Exception){
+      @dv_quantified = OpenEhr::RM::DataTypes::Quantity::DvQuantified.new(1,'=')}
+    assert_nothing_raised(Exception){
+      @dv_amount = OpenEhr::RM::DataTypes::Quantity::DvAmount.new(2,'<')}
+    assert_nothing_raised(Exception){
+      @dv_quantity = OpenEhr::RM::DataTypes::Quantity::DvQuantity.new(3, 'mg', '~')}
+    assert_nothing_raised(Exception){
+      @dv_count = OpenEhr::RM::DataTypes::Quantity::DvCount.new(1)}
+    assert_nothing_raised(Exception){
+      @dv_proportion = OpenEhr::RM::DataTypes::Quantity::DvProportion.new(2,3,0)}
+    assert_nothing_raised(Exception){
+      @dv_absolute_quantity = OpenEhr::RM::DataTypes::Quantity::DvAbsoluteQuantity.new(7,'=')}
    end
 
    def test_init
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Ordered, @dv_ordered
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Quantified, @dv_quantified
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Interval, @dv_interval
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::Reference_Range, @reference_range
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Ordinal, @dv_ordinal1
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Ordinal, @dv_ordinal2
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Quantified, @dv_quantified
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Amount, @dv_amount
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Quantity, @dv_quantity
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Count, @dv_count
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Proportion, @dv_proportion
-     assert_instance_of OpenEHR::RM::Data_Types::Quantity::DV_Absolute_Quantity, @dv_absolute_quantity
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvOrdered, @dv_ordered
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvQuantified, @dv_quantified
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvInterval, @dv_interval
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::ReferenceRange, @reference_range
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvOrdinal, @dv_ordinal1
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvOrdinal, @dv_ordinal2
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvQuantified, @dv_quantified
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvAmount, @dv_amount
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvQuantity, @dv_quantity
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvCount, @dv_count
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvProportion, @dv_proportion
+     assert_instance_of OpenEhr::RM::DataTypes::Quantity::DvAbsoluteQuantity, @dv_absolute_quantity
   end
 
@@ -214,11 +214,11 @@
     assert @dv_ordered.is_simple?
     assert_raise(NotImplementedError){@dv_ordered<=>1}
-    openehr_terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('openEHR')
-    normal_code = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('N', openehr_terminology_id)
+    openehr_terminology_id = OpenEhr::RM::Support::Identification::TerminologyId.new('openEHR')
+    normal_code = OpenEhr::RM::DataTypes::Text::CodePhrase.new('N', openehr_terminology_id)
     assert_equal 'N', normal_code.code_string
     assert_nothing_raised(Exception){
       @dv_ordered.normal_status = normal_code }
     assert @dv_ordered.is_normal?
-    other = OpenEHR::RM::Data_Types::Quantity::DV_Ordered.new
+    other = OpenEhr::RM::DataTypes::Quantity::DvOrdered.new
     assert_raise(NotImplementedError){
       @dv_ordered.is_strictly_comparable_to?(other)}
@@ -232,8 +232,8 @@
     assert_equal 'normal', @reference_range.meaning.value
     assert_equal 1, @reference_range.range.lower.value
-    terminology = OpenEHR::RM::Support::Identification::Terminology_ID.new('urine')
-    code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('protein',terminology)
-    urinary_protein = OpenEHR::RM::Data_Types::Text::DV_Coded_Text.new('++', code_phrase)
-    dv_ordinal = OpenEHR::RM::Data_Types::Quantity::DV_Ordinal.new(2, urinary_protein)
+    terminology = OpenEhr::RM::Support::Identification::TerminologyId.new('urine')
+    code_phrase = OpenEhr::RM::DataTypes::Text::CodePhrase.new('protein',terminology)
+    urinary_protein = OpenEhr::RM::DataTypes::Text::DvCodedText.new('++', code_phrase)
+    dv_ordinal = OpenEhr::RM::DataTypes::Quantity::DvOrdinal.new(2, urinary_protein)
     assert @reference_range.is_in_range?(dv_ordinal)
     dv_ordinal.value = 6
@@ -244,10 +244,10 @@
     assert_equal 1, @dv_quantified.magnitude
     assert_equal '=', @dv_quantified.magnitude_status
-    assert !OpenEHR::RM::Data_Types::Quantity::DV_Quantified.valid_magnitude_status?('*')
-    assert OpenEHR::RM::Data_Types::Quantity::DV_Quantified.valid_magnitude_status?('>')
-    assert OpenEHR::RM::Data_Types::Quantity::DV_Quantified.valid_magnitude_status?('<')
-    assert OpenEHR::RM::Data_Types::Quantity::DV_Quantified.valid_magnitude_status?('>=')
-    assert OpenEHR::RM::Data_Types::Quantity::DV_Quantified.valid_magnitude_status?('<=')
-    assert OpenEHR::RM::Data_Types::Quantity::DV_Quantified.valid_magnitude_status?('~')
+    assert !OpenEhr::RM::DataTypes::Quantity::DvQuantified.valid_magnitude_status?('*')
+    assert OpenEhr::RM::DataTypes::Quantity::DvQuantified.valid_magnitude_status?('>')
+    assert OpenEhr::RM::DataTypes::Quantity::DvQuantified.valid_magnitude_status?('<')
+    assert OpenEhr::RM::DataTypes::Quantity::DvQuantified.valid_magnitude_status?('>=')
+    assert OpenEhr::RM::DataTypes::Quantity::DvQuantified.valid_magnitude_status?('<=')
+    assert OpenEhr::RM::DataTypes::Quantity::DvQuantified.valid_magnitude_status?('~')
     assert_nothing_raised(Exception){@dv_quantified.magnitude = 0}
     assert_equal 0, @dv_quantified.magnitude
@@ -289,6 +289,6 @@
     assert @dv_ordinal1 > @dv_ordinal2
     assert_raise(ArgumentError){@dv_ordinal1.limits = @reference_range}
-    meaning = OpenEHR::RM::Data_Types::Text::DV_Text.new('limits')
-    limit_reference_range = OpenEHR::RM::Data_Types::Quantity::Reference_Range.new(meaning, @dv_interval)
+    meaning = OpenEhr::RM::DataTypes::Text::DvText.new('limits')
+    limit_reference_range = OpenEhr::RM::DataTypes::Quantity::ReferenceRange.new(meaning, @dv_interval)
     assert_nothing_raised(Exception){@dv_ordinal1.limits = limit_reference_range}
     assert_equal 'limits', @dv_ordinal1.limits.meaning.value
@@ -299,5 +299,5 @@
     assert_equal 'mg', @dv_quantity.units
     assert_equal '~', @dv_quantity.magnitude_status
-    dv_quantity2 = OpenEHR::RM::Data_Types::Quantity::DV_Quantity.new(4, 'mg', '~')
+    dv_quantity2 = OpenEhr::RM::DataTypes::Quantity::DvQuantity.new(4, 'mg', '~')
     assert_equal 'mg', dv_quantity2.units
     assert @dv_quantity.is_strictly_comparable_to?(dv_quantity2)
@@ -318,5 +318,5 @@
   def test_dv_count
     assert_equal 1, @dv_count.magnitude
-    dv_count2 = OpenEHR::RM::Data_Types::Quantity::DV_Count.new(2)
+    dv_count2 = OpenEhr::RM::DataTypes::Quantity::DvCount.new(2)
     dv_count3 = @dv_count + dv_count2
     assert 3, dv_count3.magnitude
@@ -326,13 +326,13 @@
 
   def test_proportion_kind
-    assert_equal 0, OpenEHR::RM::Data_Types::Quantity::Proportion_Kind::PK_RATIO
-    assert_equal 1, OpenEHR::RM::Data_Types::Quantity::Proportion_Kind::PK_UNITARY
-    assert_equal 2, OpenEHR::RM::Data_Types::Quantity::Proportion_Kind::PK_PERCENT
-    assert_equal 3, OpenEHR::RM::Data_Types::Quantity::Proportion_Kind::PK_FRACTION
-    assert_equal 4, OpenEHR::RM::Data_Types::Quantity::Proportion_Kind::PK_INTEGER_FRACTION
-    assert OpenEHR::RM::Data_Types::Quantity::Proportion_Kind.valid_proportion_kind?(0)
-    assert OpenEHR::RM::Data_Types::Quantity::Proportion_Kind.valid_proportion_kind?(4)
-    assert !OpenEHR::RM::Data_Types::Quantity::Proportion_Kind.valid_proportion_kind?(-1)
-    assert !OpenEHR::RM::Data_Types::Quantity::Proportion_Kind.valid_proportion_kind?(5)
+    assert_equal 0, OpenEhr::RM::DataTypes::Quantity::ProportionKind::PK_RATIO
+    assert_equal 1, OpenEhr::RM::DataTypes::Quantity::ProportionKind::PK_UNITARY
+    assert_equal 2, OpenEhr::RM::DataTypes::Quantity::ProportionKind::PK_PERCENT
+    assert_equal 3, OpenEhr::RM::DataTypes::Quantity::ProportionKind::PK_FRACTION
+    assert_equal 4, OpenEhr::RM::DataTypes::Quantity::ProportionKind::PK_INTEGER_FRACTION
+    assert OpenEhr::RM::DataTypes::Quantity::ProportionKind.valid_proportion_kind?(0)
+    assert OpenEhr::RM::DataTypes::Quantity::ProportionKind.valid_proportion_kind?(4)
+    assert !OpenEhr::RM::DataTypes::Quantity::ProportionKind.valid_proportion_kind?(-1)
+    assert !OpenEhr::RM::DataTypes::Quantity::ProportionKind.valid_proportion_kind?(5)
   end
 
@@ -343,18 +343,18 @@
     assert_equal 2.0/3.0, @dv_proportion.magnitude
     assert @dv_proportion.is_integral?
-    dv_proportion2 = OpenEHR::RM::Data_Types::Quantity::DV_Proportion.new(1,3,0)
+    dv_proportion2 = OpenEhr::RM::DataTypes::Quantity::DvProportion.new(1,3,0)
     assert @dv_proportion.is_strictly_comparable_to?(dv_proportion2)
-    dv_proportion2 = OpenEHR::RM::Data_Types::Quantity::DV_Proportion.new(1,3,4)
+    dv_proportion2 = OpenEhr::RM::DataTypes::Quantity::DvProportion.new(1,3,4)
     assert !@dv_proportion.is_strictly_comparable_to?(dv_proportion2)
     assert_raise(ArgumentError){
-      dv_proportion2 = OpenEHR::RM::Data_Types::Quantity::DV_Proportion.new(1.5,2.3,3)}
-    assert_raise(ArgumentError){
-      dv_proportion2 = OpenEHR::RM::Data_Types::Quantity::DV_Proportion.new(10,10,1)}
-    assert_nothing_raised(Exception){
-      dv_proportion2 = OpenEHR::RM::Data_Types::Quantity::DV_Proportion.new(10,1,1)}
-    assert_raise(ArgumentError){
-      dv_proportion2 = OpenEHR::RM::Data_Types::Quantity::DV_Proportion.new(10,10,2)}
-    assert_nothing_raised(Exception){
-      dv_proportion2 = OpenEHR::RM::Data_Types::Quantity::DV_Proportion.new(10,100,2)}
+      dv_proportion2 = OpenEhr::RM::DataTypes::Quantity::DvProportion.new(1.5,2.3,3)}
+    assert_raise(ArgumentError){
+      dv_proportion2 = OpenEhr::RM::DataTypes::Quantity::DvProportion.new(10,10,1)}
+    assert_nothing_raised(Exception){
+      dv_proportion2 = OpenEhr::RM::DataTypes::Quantity::DvProportion.new(10,1,1)}
+    assert_raise(ArgumentError){
+      dv_proportion2 = OpenEhr::RM::DataTypes::Quantity::DvProportion.new(10,10,2)}
+    assert_nothing_raised(Exception){
+      dv_proportion2 = OpenEhr::RM::DataTypes::Quantity::DvProportion.new(10,100,2)}
   end
 
@@ -363,20 +363,20 @@
 class EncapsulatedTest < Test::Unit::TestCase
   def setup
-    charset = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('UTF-8','character-sets')
-    language = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('ja', 'languages')
-    assert_nothing_raised(Exception){
-      @dv_encapsulated = OpenEHR::RM::Data_Types::Encapsulated::DV_Encapsulated.new(charset, language, 10)}
-    assert_nothing_raised(Exception){
-      @dv_parsable = OpenEHR::RM::Data_Types::Encapsulated::DV_Parsable.new(charset, language, 10, 'XML','<TEST>test</TEST>')}
-    media_type = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('text/html', 'media-types')
-    uri = OpenEHR::RM::Data_Types::URI::DV_URI.new("http://www.openehr.jp/changeset/test?cmd=93#file0")
-    assert_nothing_raised(Exception){
-      @dv_multimedia = OpenEHR::RM::Data_Types::Encapsulated::DV_Multimedia.new(charset, language, 10, media_type, uri)}
+    charset = OpenEhr::RM::DataTypes::Text::CodePhrase.new('UTF-8','character-sets')
+    language = OpenEhr::RM::DataTypes::Text::CodePhrase.new('ja', 'languages')
+    assert_nothing_raised(Exception){
+      @dv_encapsulated = OpenEhr::RM::DataTypes::Encapsulated::DvEncapsulated.new(charset, language, 10)}
+    assert_nothing_raised(Exception){
+      @dv_parsable = OpenEhr::RM::DataTypes::Encapsulated::DvParsable.new(charset, language, 10, 'XML','<TEST>test</TEST>')}
+    media_type = OpenEhr::RM::DataTypes::Text::CodePhrase.new('text/html', 'media-types')
+    uri = OpenEhr::RM::DataTypes::Uri::DvUri.new("http://www.openehr.jp/changeset/test?cmd=93#file0")
+    assert_nothing_raised(Exception){
+      @dv_multimedia = OpenEhr::RM::DataTypes::Encapsulated::DvMultimedia.new(charset, language, 10, media_type, uri)}
   end
 
   def test_init
-    assert_instance_of OpenEHR::RM::Data_Types::Encapsulated::DV_Encapsulated, @dv_encapsulated
-    assert_instance_of OpenEHR::RM::Data_Types::Encapsulated::DV_Parsable, @dv_parsable
-    assert_instance_of OpenEHR::RM::Data_Types::Encapsulated::DV_Multimedia, @dv_multimedia
+    assert_instance_of OpenEhr::RM::DataTypes::Encapsulated::DvEncapsulated, @dv_encapsulated
+    assert_instance_of OpenEhr::RM::DataTypes::Encapsulated::DvParsable, @dv_parsable
+    assert_instance_of OpenEhr::RM::DataTypes::Encapsulated::DvMultimedia, @dv_multimedia
   end
 
@@ -385,12 +385,12 @@
     assert_equal 'ja', @dv_encapsulated.language.code_string
     assert_equal 10, @dv_encapsulated.size
-    wrong_charset = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('USO8000', 'character-sets')
+    wrong_charset = OpenEhr::RM::DataTypes::Text::CodePhrase.new('USO8000', 'character-sets')
     assert_raise(ArgumentError){@dv_encapsulated.charset = wrong_charset}
-    charset = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('EUC-JP', 'character-sets')
+    charset = OpenEhr::RM::DataTypes::Text::CodePhrase.new('EUC-JP', 'character-sets')
     assert_nothing_raised(Exception){@dv_encapsulated.charset = charset}
     assert_equal 'EUC-JP', @dv_encapsulated.charset.code_string
-    wrong_language = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('jpg', 'language')
+    wrong_language = OpenEhr::RM::DataTypes::Text::CodePhrase.new('jpg', 'language')
     assert_raise(ArgumentError){@dv_encapsulated.language = wrong_language}
-    language = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('eng', 'language')
+    language = OpenEhr::RM::DataTypes::Text::CodePhrase.new('eng', 'language')
     assert_nothing_raised(Exception){@dv_encapsulated.language = language}
     assert_equal 'eng', @dv_encapsulated.language.code_string
@@ -429,12 +429,12 @@
 
 class TestDvTimeSpecification < Test::Unit::TestCase
-  include OpenEHR::RM::Data_Types::Time_Specification
-  include OpenEHR::RM::Data_Types::Encapsulated
-  def setup
-    charset = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('UTF-8','character-sets')
-    language = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('ja', 'languages')
-    assert_nothing_raised(Exception){
-      dv_parsable = DV_Parsable.new(charset, language, 10, 'XML','<TEST>test</TEST>')
-      @dv_time_specification = DV_Time_Specification.new(dv_parsable)}
+  include OpenEhr::RM::DataTypes::TimeSpecification
+  include OpenEhr::RM::DataTypes::Encapsulated
+  def setup
+    charset = OpenEhr::RM::DataTypes::Text::CodePhrase.new('UTF-8','character-sets')
+    language = OpenEhr::RM::DataTypes::Text::CodePhrase.new('ja', 'languages')
+    assert_nothing_raised(Exception){
+      dv_parsable = DvParsable.new(charset, language, 10, 'XML','<TEST>test</TEST>')
+      @dv_time_specification = DvTimeSpecification.new(dv_parsable)}
 #    assert_nothing_raised(Exception){
 #      @dv_periodic_time_specification = DV_Periodic_Time_Specification.new('[200004181100;200004181110]/(7d)@DWIST', charset, language, 10, 'HL7:PIVL')}
@@ -442,5 +442,5 @@
 
   def test_init
-    assert_instance_of DV_Time_Specification, @dv_time_specification
+    assert_instance_of DvTimeSpecification, @dv_time_specification
   end
 
Index: ruby/trunk/lib/models/tests/rm/test_security.rb
===================================================================
--- ruby/trunk/lib/models/tests/rm/test_security.rb	(revision 283)
+++ ruby/trunk/lib/models/tests/rm/test_security.rb	(revision 291)
@@ -5,9 +5,9 @@
   def setup
     assert_nothing_raised(Exception){
-      @access_control_setting = OpenEHR::RM::Security::Access_Control_Settings.new}
+      @access_control_setting = OpenEhr::RM::Security::AccessControlSettings.new}
   end
 
   def test_init
-    assert_instance_of OpenEHR::RM::Security::Access_Control_Settings, @access_control_setting
+    assert_instance_of OpenEhr::RM::Security::AccessControlSettings, @access_control_setting
   end
 end
Index: ruby/trunk/lib/models/tests/rm/test_support.rb
===================================================================
--- ruby/trunk/lib/models/tests/rm/test_support.rb	(revision 283)
+++ ruby/trunk/lib/models/tests/rm/test_support.rb	(revision 291)
@@ -5,6 +5,6 @@
 class RM_Support_Definition_Test < Test::Unit::TestCase
     def test_constant
-    assert_equal("\r", OpenEHR::RM::Support::Definition::OpenEHR_Definitions::CR)
-    assert_equal("\n", OpenEHR::RM::Support::Definition::OpenEHR_Definitions::LF)
+    assert_equal("\r", OpenEhr::RM::Support::Definition::OpenEHRDefinitions::CR)
+    assert_equal("\n", OpenEhr::RM::Support::Definition::OpenEHRDefinitions::LF)
   end
 end
@@ -13,4 +13,5 @@
 class RM_Support_Identification_Test < Test::Unit::TestCase
   def setup
+<<<<<<< .working
     assert_nothing_raised(Exception){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.3")}
     assert_nothing_raised(Exception){@object_ref = OpenEHR::RM::Support::Identification::Object_Ref.new('local', 'ANY', @object_id)}
@@ -25,20 +26,34 @@
     assert_nothing_raised(Exception){@version_tree_id = OpenEHR::RM::Support::Identification::Version_Tree_ID.new('1.2.3')}
     assert_nothing_raised(Exception){@object_version_id = OpenEHR::RM::Support::Identification::Object_Version_ID.new('ABC::DEF::1.2.3')}
+=======
+    assert_nothing_raised(Exception){@object_id = OpenEhr::RM::Support::Identification::ObjectId.new("0.0.3")}
+    assert_nothing_raised(Exception){@object_ref = OpenEhr::RM::Support::Identification::ObjectRef.new('local', 'ANY', @object_id)}
+    assert_nothing_raised(Exception){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
+    assert_nothing_raised(Exception){@terminology_id = OpenEhr::RM::Support::Identification::TerminologyId.new('ICD10(2003)')}
+    assert_nothing_raised(Exception){@generic_id = OpenEhr::RM::Support::Identification::GenericId.new("0.0.3", "openehr")}
+    assert_nothing_raised(Exception){@uid_based_id = OpenEhr::RM::Support::Identification::UidBasedId.new('rrip::0.0.3')}
+    assert_nothing_raised(Exception){@hier_object_id = OpenEhr::RM::Support::Identification::HierObjectId.new('0.0.4')}
+    assert_nothing_raised(Exception){@locatable_ref = OpenEhr::RM::Support::Identification::LocatableRef.new('unknown', 'PERSON', @uid_based_id, 'data/event[at0001, standing]')}
+    assert_nothing_raised(Exception){@party_ref = OpenEhr::RM::Support::Identification::PartyRef.new('unknown', 'ORGANISATION', @object_id)}
+    assert_nothing_raised(Exception){@access_group_ref = OpenEhr::RM::Support::Identification::AccessGroupRef.new('unknown', 'ACCESS_GROUP', @object_id)}
+    assert_nothing_raised(Exception){@version_tree_id = OpenEhr::RM::Support::Identification::VersionTreeId.new('1.2.3')}
+    assert_nothing_raised(Exception){@object_version_id = OpenEhr::RM::Support::Identification::ObjectVersionId.new('ABC::DEF::1.2.3')}
+>>>>>>> .merge-right.r168
   end
   
   def test_init
-    assert_instance_of OpenEHR::RM::Support::Identification::Object_ID, @object_id
-    assert_instance_of OpenEHR::RM::Support::Identification::Object_Ref, @object_ref
-    assert_instance_of OpenEHR::RM::Support::Identification::Archetype_ID, @archetype_id
-    assert_instance_of OpenEHR::RM::Support::Identification::Terminology_ID, @terminology_id
-    assert_instance_of OpenEHR::RM::Support::Identification::Object_ID, @object_id
-    assert_instance_of OpenEHR::RM::Support::Identification::Generic_ID, @generic_id
-    assert_instance_of OpenEHR::RM::Support::Identification::UID_Based_ID, @uid_based_id
-    assert_instance_of OpenEHR::RM::Support::Identification::Hier_Object_ID, @hier_object_id
-    assert_instance_of OpenEHR::RM::Support::Identification::Locatable_Ref, @locatable_ref
-    assert_instance_of OpenEHR::RM::Support::Identification::Party_Ref, @party_ref
-    assert_instance_of OpenEHR::RM::Support::Identification::Access_Group_Ref, @access_group_ref
-    assert_instance_of OpenEHR::RM::Support::Identification::Version_Tree_ID, @version_tree_id
-    assert_instance_of OpenEHR::RM::Support::Identification::Object_Version_ID, @object_version_id
+    assert_instance_of OpenEhr::RM::Support::Identification::ObjectId, @object_id
+    assert_instance_of OpenEhr::RM::Support::Identification::ObjectRef, @object_ref
+    assert_instance_of OpenEhr::RM::Support::Identification::ArchetypeId, @archetype_id
+    assert_instance_of OpenEhr::RM::Support::Identification::TerminologyId, @terminology_id
+    assert_instance_of OpenEhr::RM::Support::Identification::ObjectId, @object_id
+    assert_instance_of OpenEhr::RM::Support::Identification::GenericId, @generic_id
+    assert_instance_of OpenEhr::RM::Support::Identification::UidBasedId, @uid_based_id
+    assert_instance_of OpenEhr::RM::Support::Identification::HierObjectId, @hier_object_id
+    assert_instance_of OpenEhr::RM::Support::Identification::LocatableRef, @locatable_ref
+    assert_instance_of OpenEhr::RM::Support::Identification::PartyRef, @party_ref
+    assert_instance_of OpenEhr::RM::Support::Identification::AccessGroupRef, @access_group_ref
+    assert_instance_of OpenEhr::RM::Support::Identification::VersionTreeId, @version_tree_id
+    assert_instance_of OpenEhr::RM::Support::Identification::ObjectVersionId, @object_version_id
   end
 
@@ -49,8 +64,8 @@
     assert_raise(ArgumentError){@object_id.value=nil}
     assert_raise(ArgumentError){@object_id.value=""}
-    assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new}
-    assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new(nil)}
-    assert_raise(ArgumentError){@object_id = OpenEHR::RM::Support::Identification::Object_ID.new("")}
-    assert_equal @object_id, OpenEHR::RM::Support::Identification::Object_ID.new("0.0.4")
+    assert_raise(ArgumentError){@object_id = OpenEhr::RM::Support::Identification::ObjectId.new}
+    assert_raise(ArgumentError){@object_id = OpenEhr::RM::Support::Identification::ObjectId.new(nil)}
+    assert_raise(ArgumentError){@object_id = OpenEhr::RM::Support::Identification::ObjectId.new("")}
+    assert_equal @object_id, OpenEhr::RM::Support::Identification::ObjectId.new("0.0.4")
   end
 
@@ -60,10 +75,10 @@
     assert_equal @object_id, @object_ref.id
 
-    assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new}
-    assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new(nil, 'ANY', @object_id)}
-    assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('', 'ANY', @object_id)}
-    assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', nil, @object_id)}
-    assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', '', @object_id)}
-    assert_raise(ArgumentError){@object_ref = OpenEHR::RM::Support::Identification::Archetype_ID.new('local', 'ANY', nil)}
+    assert_raise(ArgumentError){@object_ref = OpenEhr::RM::Support::Identification::ArchetypeId.new}
+    assert_raise(ArgumentError){@object_ref = OpenEhr::RM::Support::Identification::ArchetypeId.new(nil, 'ANY', @object_id)}
+    assert_raise(ArgumentError){@object_ref = OpenEhr::RM::Support::Identification::ArchetypeId.new('', 'ANY', @object_id)}
+    assert_raise(ArgumentError){@object_ref = OpenEhr::RM::Support::Identification::ArchetypeId.new('local', nil, @object_id)}
+    assert_raise(ArgumentError){@object_ref = OpenEhr::RM::Support::Identification::ArchetypeId.new('local', '', @object_id)}
+    assert_raise(ArgumentError){@object_ref = OpenEhr::RM::Support::Identification::ArchetypeId.new('local', 'ANY', nil)}
 
     assert_nothing_raised(Exception){@object_ref.namespace = 'terminology'}
@@ -79,10 +94,11 @@
     assert_raise(ArgumentError){@object_ref.type = ''}
 
-    assert_nothing_raised(Exception){@object_ref.id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.5")}
-    assert_equal OpenEHR::RM::Support::Identification::Object_ID.new("0.0.5"), @object_ref.id
+    assert_nothing_raised(Exception){@object_ref.id = OpenEhr::RM::Support::Identification::ObjectId.new("0.0.5")}
+    assert_equal OpenEhr::RM::Support::Identification::ObjectId.new("0.0.5"), @object_ref.id
     assert_raise(ArgumentError){@object_ref.id = nil}
   end
 
   def test_archetype_id
+<<<<<<< .working
     assert_equal 'openEHR-EHR-SECTION.physical_examination-prenatal.v2', @archetype_id.value
     assert_equal 'openEHR-EHR-SECTION', @archetype_id.qualified_rm_entity
@@ -93,4 +109,62 @@
     assert_equal 'prenatal', @archetype_id.specialisation
     assert_equal 'v2', @archetype_id.version_id
+=======
+    assert_equal "0.0.5", @archetype_id.value
+    assert_nothing_raised(Exception){@archetype_id.value = "0.0.6"}
+    assert_equal "0.0.6", @archetype_id.value
+    assert_raise(ArgumentError){@archetype_id.value=nil}
+    assert_raise(ArgumentError){@archetype_id.value=""}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new(nil, "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
+    assert_raise(ArgumentError){@object_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", nil, "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "", "entry", "ehr_rm", "openehr","cholesterol","0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", nil, "ehr_rm", "openehr","cholesterol","0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "", "ehr_rm", "openehr","cholesterol","0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "entry", nil, "openehr","cholesterol","0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "entry", "", "openehr","cholesterol","0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", nil,"cholesterol","0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "","cholesterol","0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr",nil ,"0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","","0.0.3")}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol", nil)}
+    assert_raise(ArgumentError){@archetype_id = OpenEhr::RM::Support::Identification::ArchetypeId.new("0.0.5", "biochemistry result_cholesterol", "entry", "ehr_rm", "openehr","cholesterol","")}
+
+    assert_equal "biochemistry result_cholesterol", @archetype_id.domain_concept
+    assert_nothing_raised(Exception){(@archetype_id.domain_concept = "biochemistry result_triglyceride")}
+    assert_equal "biochemistry result_triglyceride", @archetype_id.domain_concept
+    assert_raise(ArgumentError){@archetype_id.domain_concept = nil}
+    assert_raise(ArgumentError){@archetype_id.domain_concept = ""}
+
+    assert_equal "entry", @archetype_id.rm_name
+    assert_nothing_raised(Exception){@archetype_id.rm_name = "section"}
+    assert_equal "section", @archetype_id.rm_name
+    assert_raise(ArgumentError){@archetype_id.rm_name = nil}
+    assert_raise(ArgumentError){@archetype_id.rm_name = ""}
+
+    assert_equal "ehr_rm", @archetype_id.rm_entity
+    assert_nothing_raised(Exception){@archetype_id.rm_entity = "13606"}
+    assert_equal "13606", @archetype_id.rm_entity
+    assert_raise(ArgumentError){@archetype_id.rm_entity = nil}
+    assert_raise(ArgumentError){@archetype_id.rm_entity = ""}
+
+    assert_equal "openehr", @archetype_id.rm_originator
+    assert_nothing_raised(Exception){@archetype_id.rm_originator = "cen"}
+    assert_equal "cen", @archetype_id.rm_originator
+    assert_raise(ArgumentError){@archetype_id.rm_originator = nil}
+    assert_raise(ArgumentError){@archetype_id.rm_originator = ""}
+
+    assert_equal "cholesterol", @archetype_id.specialisation
+    assert_nothing_raised(Exception){@archetype_id.specialisation = "triglyceride"}
+    assert_equal "triglyceride", @archetype_id.specialisation
+    assert_raise(ArgumentError){@archetype_id.specialisation = nil}
+    assert_raise(ArgumentError){@archetype_id.specialisation = ""}
+
+    assert_equal "0.0.3", @archetype_id.version_id
+    assert_nothing_raised(Exception){@archetype_id.version_id = "0.0.7"}
+    assert_equal "0.0.7", @archetype_id.version_id
+    assert_raise(ArgumentError){@archetype_id.version_id = nil}
+    assert_raise(ArgumentError){@archetype_id.version_id = ""}
+>>>>>>> .merge-right.r168
   end
 
@@ -103,9 +177,9 @@
     assert_raise(ArgumentError){@terminology_id.value = ""}
 
-    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new}
-    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new(nil,'2008')}
-    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('','02008')}
-    assert_raise(ArgumentError){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("SNOMED", nil)}
-    assert_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("SNOMED")}
+    assert_raise(ArgumentError){@terminology_id = OpenEhr::RM::Support::Identification::TerminologyId.new}
+    assert_raise(ArgumentError){@terminology_id = OpenEhr::RM::Support::Identification::TerminologyId.new(nil,'2008')}
+    assert_raise(ArgumentError){@terminology_id = OpenEhr::RM::Support::Identification::TerminologyId.new('','02008')}
+    assert_raise(ArgumentError){@terminology_id = OpenEhr::RM::Support::Identification::TerminologyId.new("SNOMED", nil)}
+    assert_nothing_raised(Exception){@terminology_id = OpenEhr::RM::Support::Identification::TerminologyId.new("SNOMED")}
 
     assert_equal "SNOMED", @terminology_id.name
@@ -127,8 +201,8 @@
     assert_equal "openehr", @generic_id.scheme
 
-    assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new(nil, "openehr")}
-    assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("", "openehr")}
-    assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", nil)}
-    assert_raise(ArgumentError){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", "")}
+    assert_raise(ArgumentError){@generic_id = OpenEhr::RM::Support::Identification::GenericId.new(nil, "openehr")}
+    assert_raise(ArgumentError){@generic_id = OpenEhr::RM::Support::Identification::GenericId.new("", "openehr")}
+    assert_raise(ArgumentError){@generic_id = OpenEhr::RM::Support::Identification::GenericId.new("0.0.3", nil)}
+    assert_raise(ArgumentError){@generic_id = OpenEhr::RM::Support::Identification::GenericId.new("0.0.3", "")}
 
     assert_raise(ArgumentError){@generic_id.value = nil}
@@ -149,6 +223,6 @@
     assert @uid_based_id.has_extension?
 
-    assert_raise(ArgumentError){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new(nil)}
-    assert_raise(ArgumentError){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('')}
+    assert_raise(ArgumentError){@uid_based_id = OpenEhr::RM::Support::Identification::UidBasedId.new(nil)}
+    assert_raise(ArgumentError){@uid_based_id = OpenEhr::RM::Support::Identification::UidBasedId.new('')}
     assert_raise(ArgumentError){@uid_based_id.value = nil}
     assert_raise(ArgumentError){@uid_based_id.value = ''}
Index: ruby/trunk/lib/models/tests/test_archetype_model.rb
===================================================================
--- ruby/trunk/lib/models/tests/test_archetype_model.rb	(revision 283)
+++ ruby/trunk/lib/models/tests/test_archetype_model.rb	(revision 291)
@@ -5,25 +5,25 @@
 class ArchetypeModelTest < Test::Unit::TestCase
   def setup
-    @archetype = OpenEHR::AM::Archetype::ARCHETYPE.new
-    @validity_kind = OpenEHR::AM::Archetype::VALIDITY_KIND.new
+    @archetype = OpenEhr::AM::Archetype::ARCHETYPE.new
+    @validity_kind = OpenEhr::AM::Archetype::VALIDITY_KIND.new
 
-    @archetype_description = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new
-    @archetype_description_item = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION_ITEM.new
+    @archetype_description = OpenEhr::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new
+    @archetype_description_item = OpenEhr::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION_ITEM.new
   end
   
   def test_init
-    assert_instance_of OpenEHR::AM::Archetype::ARCHETYPE, @archetype
-    assert_instance_of OpenEHR::AM::Archetype::VALIDITY_KIND, @validity_kind
-    assert_instance_of OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION, @archetype_description
-    assert_instance_of OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION_ITEM, @archetype_description_item
-    assert_instance_of OpenEHR::AM::Archetype::ARCHETYPE, @archetype
+    assert_instance_of OpenEhr::AM::Archetype::ARCHETYPE, @archetype
+    assert_instance_of OpenEhr::AM::Archetype::VALIDITY_KIND, @validity_kind
+    assert_instance_of OpenEhr::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION, @archetype_description
+    assert_instance_of OpenEhr::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION_ITEM, @archetype_description_item
+    assert_instance_of OpenEhr::AM::Archetype::ARCHETYPE, @archetype
   end
 
   def test_create
-    archetype_instance = OpenEHR::AM::Archetype::ARCHETYPE.create() do |archetype|
+    archetype_instance = OpenEhr::AM::Archetype::ARCHETYPE.create() do |archetype|
       archetype.adl_version = '1.4'
     end
 
-    assert_instance_of OpenEHR::AM::Archetype::ARCHETYPE, archetype_instance
+    assert_instance_of OpenEhr::AM::Archetype::ARCHETYPE, archetype_instance
   end
 end
@@ -31,49 +31,49 @@
 class ArchetypeModelConstraintTest < Test::Unit::TestCase
   def setup
-    @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new
-    @cardinality = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new    
+    @archetype_constraint = OpenEhr::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new
+    @cardinality = OpenEhr::AM::Archetype::Constraint_Model::CARDINALITY.new
     
-    @archetype_constraint = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new
-    @c_object = OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT.new
-    @c_defined_object = OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT.new
-    @c_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE.new
-    @c_single_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new
-    @c_multiple_attribute = OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE.new(:rm_attribute_name => 'attribute_name', :cardinality => @cardinality)
-    @c_primitive_object = OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT.new
-    @c_reference_object =  OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT.new
-    @archetype_internal_ref =  OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.new
-    @archetype_slot = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.new
-    @constraint_ref = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new
-    @c_domain_type = OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE.new
-    @c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => [@c_single_attribute])
+    @archetype_constraint = OpenEhr::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT.new
+    @c_object = OpenEhr::AM::Archetype::Constraint_Model::C_OBJECT.new
+    @c_defined_object = OpenEhr::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT.new
+    @c_attribute = OpenEhr::AM::Archetype::Constraint_Model::C_ATTRIBUTE.new
+    @c_single_attribute = OpenEhr::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE.new
+    @c_multiple_attribute = OpenEhr::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE.new(:rm_attribute_name => 'attribute_name', :cardinality => @cardinality)
+    @c_primitive_object = OpenEhr::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT.new
+    @c_reference_object =  OpenEhr::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT.new
+    @archetype_internal_ref =  OpenEhr::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.new
+    @archetype_slot = OpenEhr::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.new
+    @constraint_ref = OpenEhr::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new
+    @c_domain_type = OpenEhr::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE.new
+    @c_complex_object = OpenEhr::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => [@c_single_attribute])
   end
 
   def test_init
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_OBJECT, @c_object
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT, @c_defined_object
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE, @c_attribute
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE, @c_single_attribute
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE, @c_multiple_attribute
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_OBJECT, @c_object
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_DEFINED_OBJECT, @c_defined_object
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_ATTRIBUTE, @c_attribute
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_SINGLE_ATTRIBUTE, @c_single_attribute
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_MULTIPLE_ATTRIBUTE, @c_multiple_attribute
     assert_equal 'attribute_name', @c_multiple_attribute.rm_attribute_name
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY, @c_multiple_attribute.cardinality
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT, @c_primitive_object
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT, @c_reference_object
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF, @archetype_internal_ref
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT, @archetype_slot
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF, @constraint_ref
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE, @c_domain_type
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, @c_complex_object
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::CARDINALITY, @c_multiple_attribute.cardinality
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_PRIMITIVE_OBJECT, @c_primitive_object
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_REFERENCE_OBJECT, @c_reference_object
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF, @archetype_internal_ref
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT, @archetype_slot
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::CONSTRAINT_REF, @constraint_ref
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_DOMAIN_TYPE, @c_domain_type
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, @c_complex_object
     assert_instance_of Array, @c_complex_object.attributes
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY, @cardinality
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::ARCHETYPE_CONSTRAINT, @archetype_constraint
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::CARDINALITY, @cardinality
   end
 
   def test_create
-    c_complex_object = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:node_id => 'test_node',
+    c_complex_object = OpenEhr::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:node_id => 'test_node',
                                                                                          :attributes => [1,2],
                                                                                          :assumed_value => Array
                                                                                          )
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, c_complex_object
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT, c_complex_object
     assert_equal 'test_node', c_complex_object.node_id
   end
@@ -83,26 +83,26 @@
   def setup
     #@c_primitive = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE.new
-    @c_boolean = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true,
+    @c_boolean = OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true,
                                                                                     :false_valid => true,
                                                                                     :assumed_value => true)
-    @c_string = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING.new
-    @c_integer = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.new
-    @c_real = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL.new
-    @c_time = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME.new
-    @c_date = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE.new
-    @c_date_time = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new
-    @c_duration = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new
+    @c_string = OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_STRING.new
+    @c_integer = OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_INTEGER.new
+    @c_real = OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_REAL.new
+    @c_time = OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_TIME.new
+    @c_date = OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_DATE.new
+    @c_date_time = OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME.new
+    @c_duration = OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_DURATION.new
   end
 
   def test_init
     #assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE, @c_primitive
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN, @c_boolean
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_STRING, @c_string
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_INTEGER, @c_integer
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_REAL, @c_real
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_TIME, @c_time
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE, @c_date
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME, @c_date_time
-    assert_instance_of OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_DURATION, @c_duration
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN, @c_boolean
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_STRING, @c_string
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_INTEGER, @c_integer
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_REAL, @c_real
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_TIME, @c_time
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_DATE, @c_date
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_DATE_TIME, @c_date_time
+    assert_instance_of OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_DURATION, @c_duration
   end
 
@@ -119,5 +119,5 @@
     end
     assert_raise(ArgumentError) do 
-      OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid =>false,
+      OpenEhr::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid =>false,
                                                                          :false_valid => false,
                                                                          :assumed_value => false)
@@ -129,11 +129,11 @@
 class ArchetypeModelOntologyTest < Test::Unit::TestCase
   def setup
-    @archetype_ontology = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new
-    @archetype_term = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_TERM.new(:code => '', :items => '')
+    @archetype_ontology = OpenEhr::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new
+    @archetype_term = OpenEhr::AM::Archetype::Ontology::ARCHETYPE_TERM.new(:code => '', :items => '')
   end
 
   def test_init
-    assert_instance_of OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY, @archetype_ontology
-    assert_instance_of OpenEHR::AM::Archetype::Ontology::ARCHETYPE_TERM, @archetype_term
+    assert_instance_of OpenEhr::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY, @archetype_ontology
+    assert_instance_of OpenEhr::AM::Archetype::Ontology::ARCHETYPE_TERM, @archetype_term
   end
 end
@@ -141,23 +141,23 @@
 class ArchetypeModelAssertionTest < Test::Unit::TestCase
   def setup
-    @assertion = OpenEHR::AM::Archetype::Assertion::ASSERTION.new
-    @assertion_variable = OpenEHR::AM::Archetype::Assertion::ASSERTION_VARIABLE.new
-    @operator_kind = OpenEHR::AM::Archetype::Assertion::OPERATOR_KIND.new
-    @expr_item = OpenEHR::AM::Archetype::Assertion::EXPR_ITEM.new
-    @expr_leaf = OpenEHR::AM::Archetype::Assertion::EXPR_LEAF.new
-    @expr_operator = OpenEHR::AM::Archetype::Assertion::EXPR_OPERATOR.new
-    @expr_unary_operator = OpenEHR::AM::Archetype::Assertion::EXPR_UNARY_OPERATOR.new
-    @expr_binary_operator = OpenEHR::AM::Archetype::Assertion::EXPR_BINARY_OPERATOR.new
+    @assertion = OpenEhr::AM::Archetype::Assertion::ASSERTION.new
+    @assertion_variable = OpenEhr::AM::Archetype::Assertion::ASSERTION_VARIABLE.new
+    @operator_kind = OpenEhr::AM::Archetype::Assertion::OPERATOR_KIND.new
+    @expr_item = OpenEhr::AM::Archetype::Assertion::EXPR_ITEM.new
+    @expr_leaf = OpenEhr::AM::Archetype::Assertion::EXPR_LEAF.new
+    @expr_operator = OpenEhr::AM::Archetype::Assertion::EXPR_OPERATOR.new
+    @expr_unary_operator = OpenEhr::AM::Archetype::Assertion::EXPR_UNARY_OPERATOR.new
+    @expr_binary_operator = OpenEhr::AM::Archetype::Assertion::EXPR_BINARY_OPERATOR.new
   end
 
   def test_init
-    assert_instance_of OpenEHR::AM::Archetype::Assertion::ASSERTION, @assertion
-    assert_instance_of OpenEHR::AM::Archetype::Assertion::ASSERTION_VARIABLE, @assertion_variable
-    assert_instance_of OpenEHR::AM::Archetype::Assertion::OPERATOR_KIND, @operator_kind
-    assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_ITEM, @expr_item
-    assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_LEAF, @expr_leaf
-    assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_OPERATOR, @expr_operator
-    assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_UNARY_OPERATOR, @expr_unary_operator
-    assert_instance_of OpenEHR::AM::Archetype::Assertion::EXPR_BINARY_OPERATOR, @expr_binary_operator
+    assert_instance_of OpenEhr::AM::Archetype::Assertion::ASSERTION, @assertion
+    assert_instance_of OpenEhr::AM::Archetype::Assertion::ASSERTION_VARIABLE, @assertion_variable
+    assert_instance_of OpenEhr::AM::Archetype::Assertion::OPERATOR_KIND, @operator_kind
+    assert_instance_of OpenEhr::AM::Archetype::Assertion::EXPR_ITEM, @expr_item
+    assert_instance_of OpenEhr::AM::Archetype::Assertion::EXPR_LEAF, @expr_leaf
+    assert_instance_of OpenEhr::AM::Archetype::Assertion::EXPR_OPERATOR, @expr_operator
+    assert_instance_of OpenEhr::AM::Archetype::Assertion::EXPR_UNARY_OPERATOR, @expr_unary_operator
+    assert_instance_of OpenEhr::AM::Archetype::Assertion::EXPR_BINARY_OPERATOR, @expr_binary_operator
   end
 end
@@ -165,29 +165,29 @@
 class ArchetypeModelProfileTest < Test::Unit::TestCase
   def setup
-    @c_dv_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::C_DV_STATE.new
-    @state_machine = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE_MACHINE.new
-    @state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE.new
-    @terminal_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TERMINAL_STATE.new
-    @non_terminal_state = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::NON_TERMINAL_STATE.new
-    @transition = OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TRANSITION.new
+    @c_dv_state = OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::C_DV_STATE.new
+    @state_machine = OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::STATE_MACHINE.new
+    @state = OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::STATE.new
+    @terminal_state = OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::TERMINAL_STATE.new
+    @non_terminal_state = OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::NON_TERMINAL_STATE.new
+    @transition = OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::TRANSITION.new
 
-    @c_code_phase = OpenEHR::AM::OpenEHR_Profile::Data_Types::Text::C_CODE_PHASE.new
+    @c_code_phase = OpenEhr::AM::OpenEHR_Profile::DataTypes::Text::C_CODE_PHASE.new
 
-    @c_dv_quantity = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_QUANTITY.new
-    @c_dv_ordinal = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_ORDINAL.new
-    @c_quantity_item = OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_QUANTITY_ITEM.new
+    @c_dv_quantity = OpenEhr::AM::OpenEHR_Profile::DataTypes::Quantity::C_DV_QUANTITY.new
+    @c_dv_ordinal = OpenEhr::AM::OpenEHR_Profile::DataTypes::Quantity::C_DV_ORDINAL.new
+    @c_quantity_item = OpenEhr::AM::OpenEHR_Profile::DataTypes::Quantity::C_QUANTITY_ITEM.new
   end
 
   def test_init
-    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::C_DV_STATE, @c_dv_state
-    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE_MACHINE, @state_machine
-    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::STATE, @state
-    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TERMINAL_STATE, @terminal_state
-    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::NON_TERMINAL_STATE, @non_terminal_state
-    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Basic::TRANSITION, @transition
-    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Text::C_CODE_PHASE, @c_code_phase
-    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_QUANTITY, @c_dv_quantity
-    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_DV_ORDINAL, @c_dv_ordinal
-    assert_instance_of OpenEHR::AM::OpenEHR_Profile::Data_Types::Quantity::C_QUANTITY_ITEM, @c_quantity_item
+    assert_instance_of OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::C_DV_STATE, @c_dv_state
+    assert_instance_of OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::STATE_MACHINE, @state_machine
+    assert_instance_of OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::STATE, @state
+    assert_instance_of OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::TERMINAL_STATE, @terminal_state
+    assert_instance_of OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::NON_TERMINAL_STATE, @non_terminal_state
+    assert_instance_of OpenEhr::AM::OpenEHR_Profile::DataTypes::Basic::TRANSITION, @transition
+    assert_instance_of OpenEhr::AM::OpenEHR_Profile::DataTypes::Text::C_CODE_PHASE, @c_code_phase
+    assert_instance_of OpenEhr::AM::OpenEHR_Profile::DataTypes::Quantity::C_DV_QUANTITY, @c_dv_quantity
+    assert_instance_of OpenEhr::AM::OpenEHR_Profile::DataTypes::Quantity::C_DV_ORDINAL, @c_dv_ordinal
+    assert_instance_of OpenEhr::AM::OpenEHR_Profile::DataTypes::Quantity::C_QUANTITY_ITEM, @c_quantity_item
   end
 end
Index: ruby/trunk/lib/models/tests/test_assumed_library_types.rb
===================================================================
--- ruby/trunk/lib/models/tests/test_assumed_library_types.rb	(revision 283)
+++ ruby/trunk/lib/models/tests/test_assumed_library_types.rb	(revision 291)
@@ -2,23 +2,23 @@
 require 'assumed_library_types.rb'
 
-include OpenEHR::Assumed_Library_Types
+include OpenEhr::AssumedLibraryTypes
 
 class Assumed_Library_Test < Test::Unit::TestCase
   def setup
-    assert_nothing_raised(Exception){@interval = OpenEHR::Assumed_Library_Types::Interval.new(1,2)}
-    assert_nothing_raised(Exception){@iso8601_date = OpenEHR::Assumed_Library_Types::ISO8601_DATE.new('2009-04-27')}
-    assert_nothing_raised(Exception){@iso8601_time = OpenEHR::Assumed_Library_Types::ISO8601_TIME.new('15:55:37.32+0900')}
-    assert_nothing_raised(Exception){@iso8601_date_time = OpenEHR::Assumed_Library_Types::ISO8601_DATE_TIME.new('2009-04-27T15:55:37.32+0900')}
-    assert_nothing_raised(Exception){@iso8601_duration = OpenEHR::Assumed_Library_Types::ISO8601_DURATION.new('P1Y2M3W4DT5H6M7.8S')}
-    assert_nothing_raised(Exception){@iso8601_timezone = OpenEHR::Assumed_Library_Types::ISO8601_TIMEZONE.new}
+    assert_nothing_raised(Exception){@interval = OpenEhr::AssumedLibraryTypes::Interval.new(1,2)}
+    assert_nothing_raised(Exception){@iso8601_date = OpenEhr::AssumedLibraryTypes::ISO8601_DATE.new('2009-04-27')}
+    assert_nothing_raised(Exception){@iso8601_time = OpenEhr::AssumedLibraryTypes::ISO8601_TIME.new('15:55:37.32+0900')}
+    assert_nothing_raised(Exception){@iso8601_date_time = OpenEhr::AssumedLibraryTypes::ISO8601_DATE_TIME.new('2009-04-27T15:55:37.32+0900')}
+    assert_nothing_raised(Exception){@iso8601_duration = OpenEhr::AssumedLibraryTypes::ISO8601_DURATION.new('P1Y2M3W4DT5H6M7.8S')}
+    assert_nothing_raised(Exception){@iso8601_timezone = OpenEhr::AssumedLibraryTypes::ISO8601_TIMEZONE.new}
   end
 
   def test_initialize
-    assert_instance_of OpenEHR::Assumed_Library_Types::Interval, @interval
-    assert_instance_of OpenEHR::Assumed_Library_Types::ISO8601_DATE, @iso8601_date
-    assert_instance_of OpenEHR::Assumed_Library_Types::ISO8601_TIME, @iso8601_time
-    assert_instance_of OpenEHR::Assumed_Library_Types::ISO8601_DATE_TIME, @iso8601_date_time
-    assert_instance_of OpenEHR::Assumed_Library_Types::ISO8601_DURATION, @iso8601_duration
-    assert_instance_of OpenEHR::Assumed_Library_Types::ISO8601_TIMEZONE, @iso8601_timezone
+    assert_instance_of OpenEhr::AssumedLibraryTypes::Interval, @interval
+    assert_instance_of OpenEhr::AssumedLibraryTypes::ISO8601_DATE, @iso8601_date
+    assert_instance_of OpenEhr::AssumedLibraryTypes::ISO8601_TIME, @iso8601_time
+    assert_instance_of OpenEhr::AssumedLibraryTypes::ISO8601_DATE_TIME, @iso8601_date_time
+    assert_instance_of OpenEhr::AssumedLibraryTypes::ISO8601_DURATION, @iso8601_duration
+    assert_instance_of OpenEhr::AssumedLibraryTypes::ISO8601_TIMEZONE, @iso8601_timezone
   end
 
@@ -58,114 +58,114 @@
 
   def test_time_definitions
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::DAYS_IN_LEAP_YEAR, 366
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::DAYS_IN_WEEK, 7
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::DAYS_IN_YEAR, 365
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::HOURS_IN_DAY, 24
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::MAX_DAYS_IN_MONTH, 31
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::MAX_DAYS_IN_YEAR, 366
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::MINUTES_IN_HOUR, 60
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::MONTH_IN_YEAR, 12
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::NOMINAL_DAYS_IN_MONTH, 30.42
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::NOMINAL_DAYS_IN_YEAR, 365.24
-    assert_equal OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS::SECONDS_IN_MINUTE, 60
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::DAYS_IN_LEAP_YEAR, 366
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::DAYS_IN_WEEK, 7
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::DAYS_IN_YEAR, 365
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::HOURS_IN_DAY, 24
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MAX_DAYS_IN_MONTH, 31
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MAX_DAYS_IN_YEAR, 366
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MINUTES_IN_HOUR, 60
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::MONTH_IN_YEAR, 12
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::NOMINAL_DAYS_IN_MONTH, 30.42
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::NOMINAL_DAYS_IN_YEAR, 365.24
+    assert_equal OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS::SECONDS_IN_MINUTE, 60
   end
 
   def test_time_definition_validity
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_year?(2008)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_year?(-20)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_year?(0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_year?(2008)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_year?(-20)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_year?(0)
 # today
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,6,19)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,19)
 # test valid_day lower limit
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(0,0,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(0,1,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(-1,1,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(0,1,0)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,0,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,1,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(-1,1,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,1,0)
 # test valid_day upper and lowerlimit of each month
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(0,0,1)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,1,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,1,0)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,0,1)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,1,31)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,1,32)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,2,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,2,0)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,2,31)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,3,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,3,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,3,31)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,3,32)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,4,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,4,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,4,30)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,4,31)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,5,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,5,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,5,31)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,5,32)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,6,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,6,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,6,30)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,6,31)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,7,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,7,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,7,31)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,7,32)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,8,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,8,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,8,31)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,8,32)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,9,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,9,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,9,30)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,9,31)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,10,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,10,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,10,31)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,10,32)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,11,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,11,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,11,30)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,11,31)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,12,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,12,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,12,31)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,12,32)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(0,0,1)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,0)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,0,1)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,31)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,1,32)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,0)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,31)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,31)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,3,32)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,30)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,4,31)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,31)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,5,32)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,30)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,6,31)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,31)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,7,32)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,31)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,8,32)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,30)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,9,31)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,31)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,10,32)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,30)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,11,31)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,31)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,12,32)
 # test valid_day leap year
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(1900,2,28)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(1900,2,29)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2000,2,29)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_day?(2008,2,29)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(1900,2,28)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(1900,2,29)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2000,2,29)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_day?(2008,2,29)
 # test valid_hour lower limit
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(0,0,0)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(-1,0,0)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(0,-1,0)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(0,0,-1)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,0)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(-1,0,0)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,-1,0)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,-1)
 # test valid_hour upper limit
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(0,59,0)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(0,60,0)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(0,0,59)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(0,0,60)
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(24,0,0)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(24,0,1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_hour?(24,1,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,59,0)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,60,0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,59)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(0,0,60)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(24,0,0)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(24,0,1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_hour?(24,1,0)
 # test valid_minute method lower limit
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_minute?(0)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_minute?(-1)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(0)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(-1)
 # test valid_minute method upper limit
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_minute?(59)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_minute?(60)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(59)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_minute?(60)
 # test valid_second method lower limit
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_second?(0)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_second?(-1)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(0)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(-1)
 # test valid_second method upper limit
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_second?(59)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_second?(60)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(59)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_second?(60)
 # test valid_month method lower limit
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_month?(1)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_month?(0)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(1)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(0)
 # test valid_month method upper limit
-    assert OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_month?(12)
-    assert !OpenEHR::Assumed_Library_Types::TIME_DEFINITIONS.valid_month?(13)
+    assert OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(12)
+    assert !OpenEhr::AssumedLibraryTypes::TIME_DEFINITIONS.valid_month?(13)
   end
   def test_iso8601_date
@@ -173,5 +173,5 @@
     assert_equal 4,@iso8601_date.month
     assert_equal 27,@iso8601_date.day
-    assert_nothing_raised(Exception){@iso8601_date = OpenEHR::Assumed_Library_Types::ISO8601_DATE.new('2008')}
+    assert_nothing_raised(Exception){@iso8601_date = OpenEhr::AssumedLibraryTypes::ISO8601_DATE.new('2008')}
     assert @iso8601_date.day_unknown?
     assert @iso8601_date.month_unknown?
@@ -194,6 +194,6 @@
     assert !@iso8601_date.is_partial?
     assert_equal "2008-06-14", @iso8601_date.as_string
-    assert OpenEHR::Assumed_Library_Types::ISO8601_DATE.valid_iso8601_date?("2006-06-14")
-    assert !OpenEHR::Assumed_Library_Types::ISO8601_DATE.valid_iso8601_date?("ABCDEFG")
+    assert OpenEhr::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("2006-06-14")
+    assert !OpenEhr::AssumedLibraryTypes::ISO8601_DATE.valid_iso8601_date?("ABCDEFG")
   end
 
@@ -207,5 +207,5 @@
 #    assert_nothing_raised(Exception){@iso8601_time = OpenEHR::Assumed_Library_Types::ISO8601_TIME.new('15:55:37.32+0900')}
 
-    assert_nothing_raised(Exception){@iso8601_time = OpenEHR::Assumed_Library_Types::ISO8601_TIME.new('01')}
+    assert_nothing_raised(Exception){@iso8601_time = OpenEhr::AssumedLibraryTypes::ISO8601_TIME.new('01')}
     assert_equal 1, @iso8601_time.hour
     assert @iso8601_time.is_partial?
@@ -253,11 +253,11 @@
     assert @iso8601_time.is_extended?
     assert !@iso8601_time.is_decimal_sign_comma?
-    assert OpenEHR::Assumed_Library_Types::ISO8601_TIME.valid_iso8601_time?("012345Z")
-    assert OpenEHR::Assumed_Library_Types::ISO8601_TIME.valid_iso8601_time?("012345.67+0900")
-    assert !OpenEHR::Assumed_Library_Types::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")
-    assert !OpenEHR::Assumed_Library_Types::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")
-    assert OpenEHR::Assumed_Library_Types::ISO8601_TIME.valid_iso8601_time?("240000")
-    assert OpenEHR::Assumed_Library_Types::ISO8601_TIME.valid_iso8601_time?("240000Z")
-    assert !OpenEHR::Assumed_Library_Types::ISO8601_TIME.valid_iso8601_time?("240000.011Z")
+    assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("012345Z")
+    assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("012345.67+0900")
+    assert !OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")
+    assert !OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("242345.67+0900")
+    assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000")
+    assert OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000Z")
+    assert !OpenEhr::AssumedLibraryTypes::ISO8601_TIME.valid_iso8601_time?("240000.011Z")
   end
 
Index: ruby/trunk/lib/open_ehr/am.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/am/archetype/archetype.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/archetype.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am/archetype/archetype.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/am/archetype/archetype_description/archetype_description.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/archetype_description/archetype_description.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am/archetype/archetype_description/archetype_description.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/am/archetype/constraint_model/archetype_constraint.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/constraint_model/archetype_constraint.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am/archetype/constraint_model/archetype_constraint.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/am/archetype/constraint_model/assertion.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/constraint_model/assertion.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am/archetype/constraint_model/assertion.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/am/archetype/constraint_model/primitive.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/constraint_model/primitive.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am/archetype/constraint_model/primitive.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/am/archetype/ontology.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/ontology.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am/archetype/ontology.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/am/archetype/validity_kind.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/validity_kind.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am/archetype/validity_kind.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/am/open_ehr_profile/data_types/basic.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/open_ehr_profile/data_types/basic.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am/open_ehr_profile/data_types/basic.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/am/open_ehr_profile/data_types/quantity.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/open_ehr_profile/data_types/quantity.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am/open_ehr_profile/data_types/quantity.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/am/open_ehr_profile/data_types/text.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/open_ehr_profile/data_types/text.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/am/open_ehr_profile/data_types/text.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/assumed_library_types.rb
===================================================================
--- ruby/trunk/lib/open_ehr/assumed_library_types.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/assumed_library_types.rb	(revision 291)
@@ -0,0 +1,563 @@
+# 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(lower, upper, 
+                     lower_included = nil, upper_included = nil)
+        check_lower_upper(lower, upper)
+        self.lower_included = lower_included
+        self.upper_included = 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 < value) && (value < @upper) ||
+            (@lower_included == true) && (@lower == value) ||
+            (@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 TIME_DEFINITIONS < 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)
+        year >= 0
+      end
+
+      def self.valid_day?(y, m, d)
+        Date.valid_date?(y,m,d) and valid_year? y
+      end
+
+      def self.valid_hour?(h,m = nil, s = nil)
+        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 TIME_DEFINITIONS
+
+    module ISO8601_DATE_MODULE
+      attr_reader :year, :month, :day
+      def year=(year)
+        raise ArgumentError, "Year is not valid" unless ISO8601_DATE.valid_year?(year)
+        @year = year
+      end
+      def month=(month)
+        raise ArgumentError, "Month is not valid" unless month.nil? or ISO8601_DATE.valid_month?(month)
+        @month = month
+      end
+
+      def day=(day)
+        raise ArgumentError, "Day is not valid" unless day.nil? or ISO8601_DATE.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 ISO8601_DATE < TIME_DEFINITIONS
+      include ISO8601_DATE_MODULE
+      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 ISO8601_TIME_MODULE
+      attr_reader :hour, :minute, :second, :fractional_second, :timezone
+
+      def hour=(hour)
+        raise ArgumentError, "hour is not valid" if !ISO8601_TIME.valid_hour?(hour, @minute, @second)
+        @hour = hour
+      end
+
+      def minute_unknown?
+        @minute.nil?
+      end
+
+      def minute=(minute)
+        raise ArgumentError, "minute is not valid" if !minute.nil? and !ISO8601_TIME.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 !ISO8601_TIME.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?
+        raise ArgumentError, "fractional second should be lower than 1.0" if !fractional_second.nil? and fractional_second >= 1.0
+        @fractional_second = fractional_second
+      end
+
+      def has_fractional_second?
+        if @fractional_second.nil?
+          return false
+        else
+          return true
+        end
+      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 ISO8601_TIME < TIME_DEFINITIONS
+      include ISO8601_TIME_MODULE
+      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
+            else
+              return false
+            end
+          end
+          return true
+        else
+          return false
+        end
+      end
+    end # end of ISO8601_TIME
+
+    module ISO8601_DATE_TIME_MODULE
+      include ISO8601_DATE_MODULE, ISO8601_TIME_MODULE
+      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 ISO8601_DATE_TIME < ISO8601_DATE
+      include ISO8601_DATE_TIME_MODULE
+      def initialize(string)
+        /(\d{4})(?:-(\d{2})(?:-(\d{2})(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|([+-]\d{2}):?(\d{2}))?)?)?)?/ =~ string
+        if $1.empty?
+          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 ISO8601_TIMEZONE
+      attr_accessor :sign, :hour, :minute
+
+      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("Z%s%02d%02d", s, @hour, @minute)
+      end
+    end # end of ISO8601_TIMEZONE
+
+    module ISO8601_DURATION_MODULE
+      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 ISO8601_DURATION < TIME_DEFINITIONS
+      include ISO8601_DURATION_MODULE
+      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 ISO8601_DURATION
+  end # end of Assumed_Types
+end # end of OpenEHR
Index: ruby/trunk/lib/open_ehr/rm.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm.rb	(revision 291)
@@ -0,0 +1,53 @@
+$:.unshift File.join(File.dirname(__FILE__))
+# component: openEHR Ruby reference implementation
+# description: This file contains rm.packages.domain classes
+# keywords: archetype
+# author: Shinji KOBAYASHI, Akimichi TATSUKAWA
+# support: openEHR.jp
+# license: openEHR open source license
+#
+
+# OpenEHR::RM
+module OpenEhr
+
+  autoload :Assumed_Library_Types, "assumed_library_types.rb"
+
+  module RM
+    autoload :Demographic, "rm/demographic.rb"
+    autoload :Security, "rm/security.rb"
+
+    module Common
+      autoload :Resource, "rm/common/resource.rb"
+      autoload :Archetyped, "rm/common/archetyped.rb"
+      autoload :Generic, "rm/common/generic.rb"
+      autoload :Directory, "rm/common/directory.rb"
+      autoload :Change_Control, "rm/common/change_control.rb"
+    end
+
+    module Support
+      autoload :Definition, "rm/support/definition.rb"
+      autoload :Identification, "rm/support/identification.rb"
+      autoload :Terminology, "rm/support/terminology.rb"
+    end
+
+    module DataTypes
+      autoload :Basic, "rm/data_types/basic.rb"
+      autoload :Text, "rm/data_types/text.rb"
+      autoload :URI, "rm/data_types/uri.rb"
+      autoload :Quantity, "rm/data_types/quantity.rb"
+      autoload :Encapsulated, "rm/data_types/encapsulated.rb"
+      autoload :Time_Specification, 'rm/data_types/time_specification.rb'
+    end
+
+    module DataStructures
+      autoload :Data_Structure, "rm/data_structure.rb"
+      autoload :History, 'rm/data_structures/history.rb'
+      autoload :Item_Structure, 'rm/data_structures/item_structure.rb'
+    end
+
+    module Security
+      autoload :Security, 'rm/security.rb'
+    end
+  end
+
+end
Index: ruby/trunk/lib/open_ehr/rm/common/archetyped.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/common/archetyped.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/common/archetyped.rb	(revision 291)
@@ -0,0 +1,182 @@
+# 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(parent = nil)
+            @parent = parent
+          end
+
+          def item_at_path(path)
+            raise NotImplementError, "item_at_path must be implemented"
+          end
+
+          def items_at_path(path)
+            raise NotImplementError, "items_at_path must be implemented"
+          end
+
+          def path_exists?(path)
+            raise NotImplementError, "path_exists? must be implemented"
+          end
+
+          def path_of_item(item)
+            raise NotImplementError, "path_of_item must be implemented"
+          end
+
+          def path_unique(path)
+            raise NotImplementError, "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[:parent])
+            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)
+            raise ArgumentError, 'archetype_node_id should not be nil' if archetype_node_id.nil?
+            @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/trunk/lib/open_ehr/rm/common/change_control.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/common/change_control.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/common/change_control.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/common/directory.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/common/directory.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/common/directory.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/common/generic.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/common/generic.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/common/generic.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/common/resource.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/common/resource.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/common/resource.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/composition/content/entry.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/composition/content/entry.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/composition/content/entry.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/data_structure.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_structure.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_structure.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/data_structures/item_structure/representation.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_structures/item_structure/representation.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_structures/item_structure/representation.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/data_types/basic.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_types/basic.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_types/basic.rb	(revision 291)
@@ -0,0 +1,69 @@
+# 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
+        end
+
+        class DvBoolean < DataValue
+          def initialize(value)
+            self.value = value
+          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 :value
+
+          def initialize(value, is_terminal)
+            self.value=value
+            self.is_terminal=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
+          attr_accessor :issuer, :assigner, :id, :type
+          def initialize(assigner, id, issuer, type)
+            if assigner.nil? or assigner.empty?\
+              or id.nil? or id.empty? or issuer.nil? or issuer.empty?\
+              or type.nil? or type.empty?
+              raise ArgumentError, "invalid argument"
+            end
+            @issuer = issuer
+            @assigner = assigner
+            @id = id
+            @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/trunk/lib/open_ehr/rm/data_types/charset.lst
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_types/charset.lst	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_types/charset.lst	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/data_types/charset_extract.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_types/charset_extract.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_types/charset_extract.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/data_types/encapsulated.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_types/encapsulated.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_types/encapsulated.rb	(revision 291)
@@ -0,0 +1,111 @@
+# 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, :size
+          def initialize(charset, language, size)
+            self.charset = charset
+            self.language = language
+            self.size = size
+          end
+
+          def size=(size)
+            if size < 0
+              raise ArgumentError, "negative size"
+            end
+            @size = 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 size_positive
+            raise ArgumentError, "size must be positive" if size < 0
+          end
+
+          def charset_valid?(charset)
+            result = false
+            open('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(charset, language, size, media_type, uri=nil,
+                         data=nil, compression_algorithm=nil,
+                         integrity_check=nil, integrity_check_algorithm=nil,
+                         alternate_text=nil)
+            super(charset, language, size)
+            self.media_type = media_type
+            @uri = uri
+            @data = data
+            @compression_algorithm = compression_algorithm
+            @integrity_check = integrity_check
+            @integrity_check_algorithm = integrity_check_algorithm
+            @alternate_text = 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 :value, :formalism
+          def initialize(charset, language, size, formalism, value)
+            super(charset, language, size)
+            self.formalism = formalism
+            self.value = value
+          end
+
+          def value=(value)
+            raise ArgumentError, 'value must not be nil' if value.nil?
+            @value = value
+          end
+
+          def formalism=(formalism)
+            if formalism.nil?
+              raise ArgumentError, "formalism must not be nil"
+            elsif formalism.empty?
+              raise ArgumentError, "formalism must nto be empty"
+            end
+            @formalism = formalism
+          end
+        end
+      end # of Encapsulated
+    end # of DataTypes
+  end # of RM
+end # of OpenEHR
Index: ruby/trunk/lib/open_ehr/rm/data_types/quantity.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_types/quantity.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_types/quantity.rb	(revision 291)
@@ -0,0 +1,401 @@
+# 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
+
+        autoload :Date_Time, "rm/data_types/quantity/date_time.rb"
+
+        class DvOrdered < OpenEhr::RM::DataTypes::Basic::DataValue
+          include Comparable
+          attr_accessor :normal_range, :other_refference_ranges, :normal_status
+
+          def initialize(normal_range=nil, normal_status = nil,
+                         other_reference_ranges=nil)
+            self.normal_range = normal_range
+            self.normal_status = normal_status
+            self.other_reference_ranges = 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?
+            normal_status.nil? and other_refference_ranges.nil?
+          end
+
+          def <=>(other)
+            raise NotImplementedError, 'This method should be implemented'
+          end
+
+          def other_reference_ranges=(other_reference_ranges)
+            unless other_reference_ranges.nil? or !other_reference_ranges.is_empty?
+              raise ArgumentError, "Other reference ranges validity error"
+            end
+            @other_reference_ranges = other_reference_ranges
+          end
+
+          def is_strictly_comparable_to?(other)
+            raise NotImplementedError, 'this method should be implemented'
+          end
+        end
+
+        class DvInterval < OpenEhr::AssumedLibraryTypes::Interval
+
+        end
+
+        class DvQuantified < DvOrdered
+          attr_reader :magnitude, :magnitude_status
+
+          def initialize(magnitude, magnitude_status=nil,
+                         normal_range=nil, normal_status = nil,
+                         other_reference_ranges=nil)
+            super(normal_range, normal_status, other_reference_ranges)
+            self.magnitude = magnitude
+            self.magnitude_status = magnitude_status
+          end
+
+          def <=>(others)
+            @value <=> others.value
+          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(value, symbol, limits=nil, normal_range=nil,
+                         normal_status = nil, other_reference_ranges=nil)
+            self.value = value
+            self.symbol = symbol
+            self.limits = limits
+            super(normal_range, normal_status, other_reference_ranges)
+          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 is_strictly_comparable_to?(others)
+            unless others.instance_of? OpenEhr::RM::DataTypes::Quantity::DvOrdinal
+              return false
+            end
+            unless others.symbol.defining_code.terminology_id.value ==
+                @symbol.defining_code.terminology_id.value
+              return false
+            end
+            return true
+          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
+        end
+
+        class DvAbsoluteQuantity < DvQuantified
+          attr_accessor :accuracy
+
+          def initialize(magnitude, magnitude_status=nil, accuracy=nil,
+                         normal_range=nil, normal_status = nil,
+                         other_reference_ranges=nil)
+            super(magnitude, magnitude_status, normal_range,
+                   normal_status, other_reference_ranges)
+            self.accuracy = accuracy
+          end
+
+          def add(a_diff)
+            raise NotImplementedError, 'add must be implemented'
+          end
+
+          def diff(other)
+            raise NotImplementedError, 'diff must be implemented'
+          end
+
+          def subtract(a_diff)
+            raise NotImplementedError, 'subtract must be implemented'
+          end
+        end
+
+        class DvAmount < DvQuantified
+          attr_reader :accuracy, :accuracy_percent
+          def initialize(magnitude, magnitude_status=nil, accuracy=nil,
+                         accuracy_percent=nil, normal_range=nil,
+                         normal_status = nil, other_reference_ranges=nil)
+            super(magnitude, magnitude_status, normal_range,
+                  normal_status, other_reference_ranges)
+            unless accuracy.nil?
+              set_accuracy(accuracy, accuracy_percent)
+            else
+              @accuracy, @accuracy_percent = nil, nil
+            end
+          end
+
+          def +(other)
+            unless self.is_strictly_comparable_to?(other)
+              raise ArgumentError, 'type mismatch'
+            end
+            return DvAmount.new(@magnitude+other.magnitude, @magnitude_status,
+                                 @accuracy, @accuracy_percent, @normal_range,
+                                 @normal_status, @other_reference_ranges)
+          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(magnitude, units, magnitude_status=nil, precision=nil,
+                         accuracy=nil, accuracy_percent=nil, normal_range=nil,
+                         normal_status = nil, other_reference_ranges=nil)
+            super(magnitude, magnitude_status, accuracy, accuracy_percent,
+                  normal_range, normal_status, other_reference_ranges)
+            self.units = units
+            self.precision = 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)
+            return false if others.nil?
+            if others.instance_of?(DvQuantity) && 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
+# accuracy???
+          def +(other)
+            dv_amount = super(other)
+            return DvQuantity.new(dv_amount.magnitude, @units,
+                                   @magnitude_status, @precision,
+                                   @accuracy, @accuracy_percent, @normal_range,
+                                   @normal_status, @other_reference_ranges)
+          end
+        end
+
+        class DvCount < DvAmount
+          def is_strictly_comparable_to?(others)
+            return false if others.nil?
+            if others.instance_of?(DvCount)
+              return true
+            else
+              return false
+            end
+          end
+        end
+
+        class ReferenceRange
+          attr_reader :meaning, :range
+
+          def initialize(meaning, range)
+            self.meaning = meaning
+            self.range = 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(numerator, denominator, type, precision=nil,
+                         magnitude_status=nil, accuracy=nil,
+                         accuracy_percent=nil, normal_range=nil,
+                         normal_status = nil, other_reference_ranges=nil)
+            self.type = type
+            self.numerator = numerator
+            self.denominator = denominator
+            self.precision = precision
+            self.magnitude_status = magnitude_status
+            unless accuracy.nil?
+              set_accuracy(accuracy, accuracy_percent)
+            else
+              @accuracy, @accuracy_percent = nil, nil
+            end
+            self.normal_range = normal_range
+            self.normal_status = normal_status
+            self.other_reference_ranges = 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)
+            if denominator.nil? or denominator == PK_RATIO
+              raise ArgumentError, 'denominator invalid'
+            end
+            if (@type == PK_FRACTION || @type == PK_INTEGER_FRACTION) &&
+                !denominator.integer?
+              raise ArgumentError, 'denominator invalid for type'
+            end
+            if @type == PK_UNITARY && denominator != 1
+              raise ArgumentError, 'denominator invalid for type'
+            end
+            if @type == PK_PERCENT && denominator != 100
+              raise ArgumentError, 'denominator invaild for type'
+            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?
+              unless precision == 0 || self.is_integral?
+                @precision = precision
+              else
+                raise ArgumentError, 'precision invalid'
+              end
+            end
+          end
+
+          def is_integral?
+            return denominator.integer? && numerator.integer?
+          end
+
+          def is_strictly_comparable_to?(other)
+            unless other.instance_of?(DvProportion)
+              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/trunk/lib/open_ehr/rm/data_types/quantity/date_time.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_types/quantity/date_time.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_types/quantity/date_time.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/data_types/text.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_types/text.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_types/text.rb	(revision 291)
@@ -0,0 +1,171 @@
+# 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
+module OpenEhr
+  module RM
+    module DataTypes
+      module Text
+        class TermMapping
+          attr_reader :match, :purpose, :target
+          def initialize(match, purpose, target)
+            match_valid(match)
+            purpose_valid(purpose)
+            target_valid(target)
+            @match, @purpose, @target = match, purpose, target
+          end
+          def broader?
+            match == '>'
+          end
+          def equivalent?
+            match == '='
+          end
+          def narrower?
+            match == '<'
+          end
+          def unknown?
+            match == '?'
+          end
+          def TermMapping.is_valid_mach_code?(c)
+            c == '>' or c == '=' or c == '<' or c == '?'
+          end
+          private
+          def match_valid(match)
+            raise ArgumentError, "match is not valid" if !TermMapping.is_valid_mach_code? match
+          end
+          def purpose_valid(purpose)
+            if purpose.nil? or !purpose.instance_of? DvCodedText
+              raise ArgumentError, "purpose is not valid"
+            end
+            # should be settled after terminology service implemented
+          end
+          def target_valid(target)
+            raise ArgumentError, "target must not be nil" if target.nil?
+          end
+        end
+
+        class CodePhrase
+          attr_reader :terminology_id, :code_string
+          def initialize(code_string, terminology_id)
+            self.code_string = code_string
+            self.terminology_id = terminology_id
+          end
+
+          def terminology_id=(terminology_id)
+            raise ArgumentError, "terminology_id should not be nil" if terminology_id.nil?
+            @terminology_id = terminology_id
+          end
+
+          def code_string=(code_string)
+            raise ArgumentError, "code_string should not be empty" if code_string.nil? or code_string.empty?
+            @code_string = code_string
+          end 
+        end # of CodePhrase
+
+        class DvText < OpenEhr::RM::DataTypes::Basic::DataValue
+          attr_reader :value, :formatting, :hyperlink, :mappings
+          attr_reader :language, :encoding
+          def initialize(value, formatting = nil, hyperlink = nil,
+                         mappings = nil, language = nil, encoding = nil)
+            value_valid(value)
+            DvText.formatting_valid(formatting)
+            DvText.encoding_valid(encoding)
+            DvText.mapping_valid(mappings)
+            DvText.language_valid(language)
+            @value, @formatting, @encoding = value, formatting, encoding
+            @mappings, @language = mappings, language
+          end
+          def value=(value)
+            value_valid(value)
+            @value = value
+          end
+          def formatting=(formatting)
+            DvText.formatting_valid(formatting)
+            @formatting = formatting
+          end
+          def encoding=(encoding)
+            DvText.encoding_valid(encoding)
+            @encoding = encoding
+          end
+          def mappings=(mappings)
+            DvText.mapping_valid(mappings)
+            @mappings = mappings
+          end
+          def language=(language)
+            DvText.language_valid(language)
+            @language = language
+          end
+          private
+          def value_valid(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
+          end
+
+          class << self
+
+            def formatting_valid(formatting)
+              raise ArgumentError, "formatting is not valid" if formatting != nil and formatting.empty?
+            end
+
+            def encoding_valid(encoding)
+              raise ArgumentError, "encoding is not valid" if encoding != nil and encoding.empty?
+            end
+
+            def mapping_valid(mapping)
+              if !mapping.nil? and !mapping.instance_of? Set
+                raise ArgumentError, "mapping(s) is(are) not valid"
+              elsif !mapping.nil? and mapping.instance_of? Set
+                raise ArgumentError, "mapping(s) is(are) not valid" if mapping.empty? 
+              end
+            end
+
+            def language_valid(language)
+              raise ArgumentError, "langage is not valid" if language != nil and language.empty?
+            end
+          end
+
+        end
+
+        class DvCodedText < DvText
+          attr_reader :defining_code
+
+          def initialize(value, defining_code, formatting = nil, 
+                         hyperlink = nil, mappings = nil, language = nil, 
+                         encoding = nil)
+            super(value, formatting, hyperlink, mappings, language, encoding)
+            self.defining_code = defining_code
+          end
+
+          def defining_code=(defining_code)
+            if defining_code.nil?
+              raise ArgumentError, "Defiinition must be exist" 
+            end
+            @defining_code = defining_code
+          end
+        end
+
+        class DvParagraph < OpenEhr::RM::DataTypes::Basic::DataValue
+          attr_reader :items
+          def initialize(items)
+            items_exists(items)
+            @items = items
+          end
+          def items=(items)
+            items_exists(items)
+            @items = items
+          end
+          private
+          def items_exists(items)
+            if !items.nil? and !items.instance_of? Set
+              raise ArgumentError, "Items are not valid"
+            elsif !items.nil? and items.instance_of? Set
+              raise ArgumentError, "Items must be exist" if items.empty?
+            end
+          end
+        end
+
+      end # of Text
+    end # of DataTypes
+  end # of RM
+end # of OpenEHR
Index: ruby/trunk/lib/open_ehr/rm/data_types/time_specification.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_types/time_specification.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_types/time_specification.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/data_types/uri.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/data_types/uri.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/data_types/uri.rb	(revision 291)
@@ -0,0 +1,71 @@
+# 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'
+#require 'uri/generic'
+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(value)
+            self.value = value
+          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
+          def value
+            @value.to_s
+          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)
+            parse(value)
+          end
+        end # of DV_EHR_URI
+      end # of URI
+    end # of DataTypes
+  end # of RM
+end # of OpenEHR
Index: ruby/trunk/lib/open_ehr/rm/demographic.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/demographic.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/demographic.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/security.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/security.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/security.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/support/assumed_types.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/support/assumed_types.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/support/assumed_types.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/support/definition.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/support/definition.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/support/definition.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/support/identification.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/support/identification.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/support/identification.rb	(revision 291)
@@ -0,0 +1,331 @@
+# 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(value)
+            self.value=value
+          end
+
+          def value=(value)
+            raise ArgumentError, "empty value" if value.nil? or value.empty?
+            @value = value            
+          end
+          def ==(object_id)
+            @value == object_id.value
+          end
+        end # of ObjectID
+
+        class ObjectRef
+          attr_reader :namespace, :type, :id
+
+          def initialize(namespace, type, id)
+            self.namespace = namespace
+            self.type = type
+            self.id = id
+          end
+
+          def namespace=(namespace)
+            raise ArgumentError if namespace.nil? or namespace.empty? or !(/([a-z]|[A-Z]).*/ =~ namespace) # error original is =~ #([a-z][A-Z])([a-z]|[A-Z]|\s|[0-9]|[_-\:\/\&\+\?])*/
+            @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 :domain_concept, :rm_name, :rm_entity, :rm_originator, :specialisation, :version_id
+
+          def initialize(value, domain_concept, rm_name, rm_entity, rm_originator, specialisation, version_id)
+            super(value)
+            self.domain_concept = domain_concept
+            self.rm_name = rm_name
+            self.rm_entity = rm_entity
+            self.rm_originator = rm_originator
+            self.specialisation = specialisation
+            self.version_id = version_id
+          end
+
+          def domain_concept=(domain_concept)
+            raise ArgumentError, "domain concept not valid" if domain_concept.nil? or domain_concept.empty?
+            @domain_concept = domain_concept
+          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)
+            raise ArgumentError, "rm_entity not valid" if rm_entity.nil? or rm_entity.empty?
+            @rm_entity = rm_entity
+          end
+
+          def rm_originator=(rm_originator)
+            raise ArgumentError, "rm_originator not valid" if rm_originator.nil? or rm_originator.empty?
+            @rm_originator = rm_originator
+          end
+
+          def specialisation=(specialisation)
+            raise ArgumentError, "rm_specialisation not valid" if specialisation.nil? or specialisation.empty?
+            @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(value)
+            super(value)
+          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
+              @name = $1
+              @version_id = $2
+            else
+              @name = value
+              @version_id = ''
+            end
+            @value = value
+          end
+
+          def name=(name)
+            raise ArgumentError, "name not valid" if name.nil? or name.empty?
+            @name = name
+          end
+
+          def version_id=(version_id)
+            raise ArgumentError, "version_id not valid" if version_id.nil?
+            @version_id = version_id
+          end
+        end # of Terminology_ID
+
+        class GenericId < ObjectId
+          attr_reader :scheme
+
+          def initialize(value, scheme)
+            super(value)
+            self.scheme = scheme
+          end
+
+          def scheme=(scheme)
+            raise ArgumentError, "scheme not valid" if scheme.nil? or scheme.empty?
+            @scheme = scheme
+          end
+        end # of Generic_ID
+
+        class TemplateId < ObjectId
+
+        end
+
+        class UidBasedId < ObjectId
+          def initialize(value)
+            super(value)
+          end
+
+          def extension
+            if self.has_extension?
+              @value[/::.*/][2..-1]
+            else
+              ''
+            end
+          end
+
+          def has_extension?
+            @value.include? '::'
+          end
+
+          def root
+            if self.has_extension?
+              @value[/.*::/][0..-3]
+            else
+              @value
+            end
+          end
+        end
+
+        class ObjectVersionId < UidBasedId
+          attr_reader :object_id, :creating_system_id, :version_tree_id
+
+          def initialize(value)
+            super(value)
+          end
+
+          def value=(value)
+            super(value)
+            if /^(\w+)::(\w+)::((\d|\.)+)$/ =~ value
+              self.object_id = Uid.new($1)
+              self.creating_system_id = Uid.new($2)
+              self.version_tree_id = VersionTreeId.new($3)
+            else
+              raise ArgumentError, 'invalid format'
+            end
+          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 :namespace, :type, :id, :path
+
+          def initialize(namespace, type, id, path)
+            super(namespace, type, id)
+            self.path = 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 = ['PERSON', 'ORGANISATION', 'GROUP', 'AGENT', 'ROLE','PARTY', 'ACTOR']
+            raise ArgumentError, 'type invalid' unless parties.include? type
+            @type = type
+          end
+        end
+
+        class AccessGroupRef < ObjectRef
+          def type=(type)
+            raise ArgumentError, 'type invalid' unless type == 'ACCESS_GROUP'
+            @type = type
+          end
+        end
+
+        class HierObjectId < UidBasedId
+
+        end
+
+        class VersionTreeId
+          attr_reader :value, :trunk_version, :branch_number, :branch_version
+
+          def initialize(value)
+            self.value = value
+          end
+
+          def value=(value)
+            raise ArgumentError, 'value invalid' if value.nil? or value.empty?
+            @trunk_version = @branch_number = @branch_version = nil
+            (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 trunk_version=(trunk_version)
+            raise ArgumentError, 'trunk_version invalid' if trunk_version.nil? and !trunk_version.to_i >= 1
+            @trunk_version = trunk_version
+            set_value
+          end
+
+          def branch_number=(branch_number)
+            raise ArgumentError, 'branch number invalid' unless branch_number.nil? or branch_number.to_i >= 1
+            @branch_number = branch_number
+            set_value
+          end
+
+          def branch_version=(branch_version)
+            raise ArgumentError, 'branch version invalid' if (!branch_version.nil? and !( branch_version.to_i >= 1)) or (!branch_version.nil? and @branch_number.nil?)
+            @branch_version = branch_version
+            set_value
+          end
+          def is_branch?
+            !@branch_version.nil? and !@branch_number.nil?
+          end
+
+          def is_first?
+            trunk_version == '1'
+          end
+
+          private
+          def set_value
+            @value = trunk_version
+            @value = @value + '.' + @branch_number unless @branch_number.nil?
+            @value = @value + '.' + @branch_version unless @branch_version.nil?
+          end
+        end
+
+        class Uid
+          attr_reader :value
+
+          def initialize(value)
+            self.value = 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/trunk/lib/open_ehr/rm/support/measurement.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/support/measurement.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/support/measurement.rb	(revision 291)
@@ -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/trunk/lib/open_ehr/rm/support/terminology.rb
===================================================================
--- ruby/trunk/lib/open_ehr/rm/support/terminology.rb	(revision 291)
+++ ruby/trunk/lib/open_ehr/rm/support/terminology.rb	(revision 291)
@@ -0,0 +1,106 @@
+
+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
+          def all_codes
+            raise NotImplementedError, "all_codes is not implemented"
+          end
+          def codes_for_group_id(group_id)
+            raise NotImplementedError, "codes_for_group_id is not implemented"
+          end
+          def codes_for_group_name(name, lang)
+            raise NotImplementedError, "codes_for_group_name is not implemented"
+          end
+          def has_code_for_group_id(group_id, a_code)
+            raise NotImplementedError, "has_code_for_group_id is not implemented"
+          end
+          def id
+            raise NotImplementedError, "id is not implemented"
+          end
+          def rubric_for_code(code, lang)
+            raise NotImplementedError, "rubic_for_code is not implemented"
+          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)
+            raise NotImplementedError, "terminology is not implemented"
+          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
