Index: /ruby/trunk/lib/models/rm/common/change_control.rb
===================================================================
--- /ruby/trunk/lib/models/rm/common/change_control.rb	(revision 157)
+++ /ruby/trunk/lib/models/rm/common/change_control.rb	(revision 158)
@@ -9,4 +9,5 @@
         class Contribution
           attr_reader :uid, :versions, :audit
+
           def initialize(uid, versions, audit)
             self.uid = uid
@@ -14,4 +15,5 @@
             self.audit = audit
           end
+
           def uid=(uid)
             if uid.nil?
@@ -20,4 +22,5 @@
             @uid = uid
           end
+
           def versions=(versions)
             unless versions.nil?
@@ -28,4 +31,5 @@
             @versions = versions
           end
+
           def audit=(audit)
             if audit.nil?
@@ -43,31 +47,61 @@
 
         class Version
-          attr_reader :uid, :contribution, :commit_audit, :signature
-          attr_reader :attestations, :data
-          def initialize(uid, contribution, commit_audit, signature=nil, attestations=nil, data=nil)
-            self.uid = uid
-            self.contribution = contribution          
-            self.commit_audit = commit_audit
-          end
-          def canonical_form
-            raise NotImplementedError, 'canonical form not implemented'
+          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
+
+          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 == ''
+            raise ArgumentError, "contribution should not be nil" if contribution.nil? or contribution.type.empty?
             @contribution = contribution
           end
 
-          def commit_audit=(commit_audit)
-            raise ArgumentError, "commit_audit should not be nil" if commit_audit.nil?
-            @commit_audit = commit_audit
+          def owner_id
+            return Hier_Object_ID.new(@uid.object_id.value)
           end
 
           def is_branch?
-            raise NotImplementedError, 'is_branch not implemented'
+            return @uid.is_branch?
+          end
+
+          def canonical_form
+            raise NotImplementedError, 'canonical form not implemented'
           end
         end
@@ -77,6 +111,30 @@
 
         class Original_Version < Version
+          attr_reader :attestations
+
+          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?
+
+          end
         end
-
       end # of Change_Control
     end # of Common
Index: /ruby/trunk/lib/models/rm/support/identification.rb
===================================================================
--- /ruby/trunk/lib/models/rm/support/identification.rb	(revision 157)
+++ /ruby/trunk/lib/models/rm/support/identification.rb	(revision 158)
@@ -94,7 +94,6 @@
           attr_reader :name, :version_id
 
-          def initialize(name, version_id="")
-            self.name = name
-            self.version_id = version_id
+          def initialize(value)
+            super(value)
           end
 
@@ -115,4 +114,5 @@
             else
               @name = value
+              @version_id = ''
             end
             @value = value
@@ -209,4 +209,8 @@
             end
             @version_tree_id = version_tree_id
+          end
+
+          def is_branch?
+            return @version_tree_id.is_branch?
           end
         end
Index: /ruby/trunk/lib/models/tests/rm/test_common.rb
===================================================================
--- /ruby/trunk/lib/models/tests/rm/test_common.rb	(revision 157)
+++ /ruby/trunk/lib/models/tests/rm/test_common.rb	(revision 158)
@@ -7,4 +7,5 @@
 include OpenEHR::RM::Common::Archetyped
 include OpenEHR::RM::Common::Generic
+include OpenEHR::RM::Common::Change_Control
 include OpenEHR::RM::Support::Identification
 include OpenEHR::RM::Data_Types::Basic
@@ -14,5 +15,5 @@
 class RM_Common_Resource_Test < Test::Unit::TestCase
   def setup
-        @authored_resource = OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE.new(:original_language => "ja",
+    @authored_resource = OpenEHR::RM::Common::Resource::AUTHORED_RESOURCE.new(:original_language => "ja",
                                                                               :translations => "en",
                                                                               :description => "test")
@@ -154,5 +155,5 @@
                                                :identifier => identifiers)}
 
-    terminology_id = Terminology_ID.new('test','0.04')
+    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)
@@ -171,5 +172,5 @@
                                          :time => dv_interval)}
     dv_date_time = DV_Date_Time.new('2009-07-04T18:56:00')
-    terminology_id = Terminology_ID.new('openehr','1.0.2')
+    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)
@@ -306,18 +307,74 @@
 class RM_Common_Change_Control_Test < Test::Unit::TestCase
   def setup
-    hier_object_id = OpenEHR::RM::Support::Identification::Hier_Object_ID.new('0.0.4')
-    object_id = OpenEHR::RM::Support::Identification::Object_ID.new("0.0.3")
-    object_ref = OpenEHR::RM::Support::Identification::Object_Ref.new('local', 'ANY', object_id)
-    versions = Set.new [object_ref]
-#    audit_detail = OpenEHR::RM::Generic::Audit_Detail.new()
-#    assert_nothing_raised(Exception){@version = OpenEHR::RM::Common::Change_Control::Version.new(hier_object_id, versions)}
-#    assert_nothing_raised(Exception){@contribution = OpenEHR::RM::Common::Change_Control::Contribution.new(hier_object_id, versions, audit_detail)}
-  end
-  def test_init
-#    assert_instace_of OpenEHR::RM::Common::Change_Control::Contribution @contribution
-#    assert_instace_of OpenEHR::RM::Common::Change_Control::Version @version
-  end
+    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',
+                                      :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')
+    assert_nothing_raised(Exception){
+      @version = Version.new(:uid => object_version_id1,
+                             :preceding_version_uid => object_version_id2,
+                             :lifecycle_state => dv_coded_text,
+                             :commit_audit => audit_details,
+                             :contribution => object_ref,
+                             :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)
+    attestation = Attestation.new(:system_id => 'NERV',
+                                  :committer => party_proxy,
+                                  :time_committed => dv_date_time,
+                                  :change_type => dv_coded_text,
+                                  :reason => DV_Text.new('signed'))
+    assert_nothing_raised(Exception){
+      @original_version = Original_Version.new(:uid => object_version_id3,
+                                               :preceding_version_uid => object_version_id4,
+                                               :other_input_version_uids => Set[object_version_id1, object_version_id2],
+                                               :commit_audit => audit_details,
+                                               :contribution => object_ref,
+                                               :attestations => [attestation],
+                                               :data => 'data',
+                                               :lifecycle_state => dv_coded_text)}
+  end
+
+  def test_init
+    assert_instance_of OpenEHR::RM::Common::Change_Control::Version, @version
+    assert_instance_of Original_Version, @original_version
+#    assert_instance_of OpenEHR::RM::Common::Change_Control::Contribution @contribution
+  end
+
   def test_version
-  end
+    assert_equal 'ABC::DEF::2.2.3', @version.uid.value
+    assert !@version.uid.version_tree_id.is_first?
+    assert_equal 'GHI::JKL::4.5.6', @version.preceding_version_uid.value
+    assert_equal '532', @version.lifecycle_state.defining_code.code_string
+    assert_equal 'MAGI', @version.commit_audit.system_id
+    assert_equal 'local', @version.contribution.namespace
+    assert_equal 'test_version', @version.signature
+    assert_equal 'ABC', @version.owner_id.value
+    assert_equal 'data', @version.data
+    assert @version.is_branch?
+  end
+
+  def test_original_version
+    assert_equal 'MNO::PQR::7.8.9', @original_version.uid.value
+    assert_equal 'NERV', @original_version.attestations[0].system_id
+  end
+
   def test_contribution
 #    assert_equal @contribution.uid
Index: /ruby/trunk/lib/models/tests/rm/test_data_types.rb
===================================================================
--- /ruby/trunk/lib/models/tests/rm/test_data_types.rb	(revision 157)
+++ /ruby/trunk/lib/models/tests/rm/test_data_types.rb	(revision 158)
@@ -7,5 +7,5 @@
   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')
+    @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)
@@ -99,5 +99,5 @@
   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', '')
+    @terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('ICD10')
     
     assert_nothing_raised(Exception){@code_phrase = OpenEHR::RM::Data_Types::Text::Code_Phrase.new('C92.0', @terminology_id)}
@@ -166,5 +166,5 @@
       @dv_ordered = OpenEHR::RM::Data_Types::Quantity::DV_Ordered.new }
     assert_nothing_raised(Exception){
-      terminology = OpenEHR::RM::Support::Identification::Terminology_ID.new('urine', '')
+      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)
@@ -214,5 +214,5 @@
     assert @dv_ordered.is_simple?
     assert_raise(NotImplementedError){@dv_ordered<=>1}
-    openehr_terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('openEHR','')
+    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)
     assert_equal 'N', normal_code.code_string
@@ -232,5 +232,5 @@
     assert_equal 'normal', @reference_range.meaning.value
     assert_equal 1, @reference_range.range.lower.value
-    terminology = OpenEHR::RM::Support::Identification::Terminology_ID.new('urine', '')
+    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)
Index: /ruby/trunk/lib/models/tests/rm/test_support.rb
===================================================================
--- /ruby/trunk/lib/models/tests/rm/test_support.rb	(revision 157)
+++ /ruby/trunk/lib/models/tests/rm/test_support.rb	(revision 158)
@@ -16,5 +16,5 @@
     assert_nothing_raised(Exception){@object_ref = OpenEHR::RM::Support::Identification::Object_Ref.new('local', 'ANY', @object_id)}
     assert_nothing_raised(Exception){@archetype_id = OpenEHR::RM::Support::Identification::Archetype_ID.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::Terminology_ID.new("ICD10",'2003')}
+    assert_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new('ICD10(2003)')}
     assert_nothing_raised(Exception){@generic_id = OpenEHR::RM::Support::Identification::Generic_ID.new("0.0.3", "openehr")}
     assert_nothing_raised(Exception){@uid_based_id = OpenEHR::RM::Support::Identification::UID_Based_ID.new('rrip::0.0.3')}
@@ -155,5 +155,5 @@
     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_nothing_raised(Exception){@terminology_id = OpenEHR::RM::Support::Identification::Terminology_ID.new("SNOMED")}
 
     assert_equal "SNOMED", @terminology_id.name
