Index: /ruby/branches/0.5/lib/open_ehr/rm/common/generic.rb
===================================================================
--- /ruby/branches/0.5/lib/open_ehr/rm/common/generic.rb	(revision 321)
+++ /ruby/branches/0.5/lib/open_ehr/rm/common/generic.rb	(revision 322)
@@ -109,7 +109,7 @@
               raise ArgumentError, 'cannot identified'
             end
-            super(:external_ref => args[:external_ref])
             self.name = args[:name]
             self.identifier = args[:identifier]
+            super(args)
           end
 
@@ -126,8 +126,15 @@
               raise ArgumentError, 'cannot identified'
             end
-            unless identifier.nil? || !identifier.empty?
+            if !identifier.nil? && identifier.empty?
               raise ArgumentError, 'invaild identifier'
             end
             @identifier = identifier
+          end
+
+          def external_ref=(external_ref)
+            if @name.nil? && @identifier.nil? && external_ref.nil?
+              raise ArgumentError, 'invalid external_ref'
+            end
+            @external_ref = external_ref
           end
         end
Index: /ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity/date_time.rb
===================================================================
--- /ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity/date_time.rb	(revision 321)
+++ /ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity/date_time.rb	(revision 322)
@@ -29,4 +29,6 @@
               @value = value
             end
+
+            undef magnitude=
           end
 
@@ -43,6 +45,4 @@
               @day = iso8601_date.day
             end
-
-            undef magnitude=
 
             def magnitude
@@ -89,15 +89,9 @@
           
           class DvTime < DvTemporal
-            include OpenEHR::AssumedLibraryTypes::ISO8601TimeModule
-            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
+            include ISO8601TimeModule
 
             def value=(value)
               super(value)
-              iso8601_time = AssumedLibraryTypes::ISO8601Time.new(value)
+              iso8601_time = ISO8601Time.new(value)
               @hour = iso8601_time.hour
               @minute = iso8601_time.minute
@@ -124,12 +118,4 @@
           class DvDateTime < DvTemporal
             include OpenEHR::AssumedLibraryTypes::ISO8601DateTimeModule
-            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)              
@@ -147,6 +133,8 @@
 
             def magnitude
-              seconds = ::DateTime.new(@year,@month,@day,@hour,@minute,@second) - 
-                ::DateTime.new(0000,1,1,0,0,0)
+              seconds = (((@year * 365.24 +
+                           @month * 30.42 +
+                           @day) * 24 + @hour) * 60 +
+                         @minute) * 60 + @second
               if @fractional_second.nil?
                 return seconds
@@ -155,6 +143,4 @@
               end
             end
-
-            undef magnitude=
 
             def diff(other)
@@ -175,11 +161,10 @@
               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
-
+              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
 
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/common/generic/audit_details_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/common/generic/audit_details_spec.rb	(revision 321)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/common/generic/audit_details_spec.rb	(revision 322)
@@ -37,3 +37,15 @@
     @audit_details.description.value.should == 'test environment'
   end
+
+  it 'should raise ArgumentError when system_id was assigned nil' do
+    lambda {
+      @audit_details.system_id = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError when time_commited is nil' do
+    lambda {
+      @audit_details.time_committed = nil
+    }.should raise_error ArgumentError
+  end
 end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/common/generic/party_identified_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/common/generic/party_identified_spec.rb	(revision 321)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/common/generic/party_identified_spec.rb	(revision 322)
@@ -26,3 +26,39 @@
     @party_identified.identifier.size.should be_equal 5
   end
+
+  it 'should raise ArgumentError with all nil' do
+    lambda {
+      PartyIdentified.new
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError with nil name when ex_r and id nil' do
+    @party_identified.identifier = nil
+    @party_identified.external_ref = nil
+    lambda {
+      @party_identified.name = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError with nil external_ref when name and id nil' do
+    @party_identified.name = nil
+    @party_identified.identifier = nil
+    lambda {
+      @party_identified.external_ref = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError with nil identifier when name and ex_r nil' do
+    @party_identified.name = nil
+    @party_identified.external_ref = nil
+    lambda {
+      @party_identified.identifier = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError with empty identifier' do
+    lambda {
+      @party_identified.identifier = Array.new
+    }.should raise_error ArgumentError
+  end
 end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/common/generic/party_related_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/common/generic/party_related_spec.rb	(revision 321)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/common/generic/party_related_spec.rb	(revision 322)
@@ -1,5 +1,5 @@
 require File.dirname(__FILE__) + '/../../../../../spec_helper'
 include OpenEHR::RM::Common::Generic
-
+include OpenEHR::RM::DataTypes::Text
 describe PartyRelated do
   before(:each) do
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb	(revision 322)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb	(revision 322)
@@ -0,0 +1,16 @@
+require File.dirname(__FILE__) + '/../../../../../../spec_helper'
+include OpenEHR::RM::DataTypes::Quantity::DateTime
+
+describe DvDateTime do
+  before(:each) do
+    @dv_date_time = DvDateTime.new(:value => '2009-09-29T15:03:22.3')
+  end
+
+  it 'should be an instance of DvDateTime' do
+    @dv_date_time.should be_an_instance_of DvDateTime
+  end
+
+  it 'magnitude should be 63425495002.3' do
+    @dv_date_time.magnitude.should be_close 63423697018.3, 0.001
+  end
+end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_time_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_time_spec.rb	(revision 322)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_time_spec.rb	(revision 322)
@@ -0,0 +1,37 @@
+require File.dirname(__FILE__) + '/../../../../../../spec_helper'
+include OpenEHR::RM::DataTypes::Quantity::DateTime
+
+describe DvTime do
+  before(:each) do
+    @dv_time = DvTime.new(:value => '11:17:30.2')
+  end
+
+  it 'should be an instance of DvTime' do
+    @dv_time.should be_an_instance_of DvTime
+  end
+
+  it 'hour should be 11' do
+    @dv_time.hour.should == 11
+  end
+
+  it 'minute should be 17' do
+    @dv_time.minute.should == 17
+  end
+
+  it 'second should be 30' do
+    @dv_time.second.should == 30
+  end
+
+  it 'fractional_second should be 0.2' do
+    @dv_time.fractional_second.should == 0.2
+  end
+
+  it 'magnitude should 40650.2' do
+    @dv_time.magnitude.should == 40650.2
+  end
+
+  it 'should be ' do
+    diff_time = DvTime.new(:value => '15:36:48.05')
+    @dv_time.diff(diff_time).value.should =='P0Y0M0W0DT4H19M17.85S'
+  end
+end
Index: /ruby/branches/0.5/test/unit/open_ehr/rm/data_types/quantity/date_time_test.rb
===================================================================
--- /ruby/branches/0.5/test/unit/open_ehr/rm/data_types/quantity/date_time_test.rb	(revision 321)
+++ /ruby/branches/0.5/test/unit/open_ehr/rm/data_types/quantity/date_time_test.rb	(revision 322)
@@ -34,5 +34,5 @@
     assert_equal 6, @dv_date.month
     assert_equal 29, @dv_date.day
-    assert_equal 733954, @dv_date.magnitude
+    assert_equal b733954, @dv_date.magnitude
     date2 = OpenEhr::RM::DataTypes::Quantity::DateTime::DvDate.new('2009-07-08')
     assert_equal 'P0Y0M1W9D',@dv_date.diff(date2).value
