Index: ruby/branches/0.5/lib/open_ehr/rm/common/generic.rb
===================================================================
--- ruby/branches/0.5/lib/open_ehr/rm/common/generic.rb	(revision 312)
+++ 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 312)
+++ 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
 
