Index: /ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity.rb
===================================================================
--- /ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity.rb	(revision 248)
+++ /ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity.rb	(revision 249)
@@ -129,6 +129,5 @@
           end
           def is_strictly_comparable_to?(others)
-            super
-            unless others.instance_of? self.class
+            unless super(others)
               return false
             end
@@ -145,22 +144,41 @@
           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)
+          def initialize(args = {})
+            super(args)
             self.accuracy = accuracy
           end
 
           def add(a_diff)
-            raise NotImplementedError, 'add must be implemented'
+            type_check(a_diff)
+            return result_builder(DvAbsoluteQuantity,
+                                  @magnitude+a_diff.magnitude)
           end
 
           def diff(other)
-            raise NotImplementedError, 'diff must be implemented'
+            type_check(other)
+            return result_builder(DvAmount,
+                                  (@magnitude-other.magnitude).abs)
           end
 
           def subtract(a_diff)
-            raise NotImplementedError, 'subtract must be implemented'
+            type_check(a_diff)
+            return result_builder(DvAbsoluteQuantity,
+                                  @magnitude-a_diff.magnitude)
+          end
+          private
+          def type_check(other)
+            unless self.is_strictly_comparable_to? other
+              raise ArgumentError, 'type mismatch'
+            end
+          end
+
+          def result_builder(klass, magnitude)
+            return klass.new(:magnitude => magnitude,
+                             :magnitude_status => @magnitude_status,
+                             :accuracy => @accuracy,
+                             :accuracy_percent => @accuracy_percent,
+                             :normal_range => @normal_range,
+                             :normal_status => @normal_status,
+                             :other_reference_ranges => @other_reference_ranges)
           end
         end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/dv_absolute_quantity_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/dv_absolute_quantity_spec.rb	(revision 249)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/data_types/quantity/dv_absolute_quantity_spec.rb	(revision 249)
@@ -0,0 +1,35 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::RM::DataTypes::Quantity
+
+describe DvAbsoluteQuantity do
+  before(:each) do
+    @dv_absolute_quantity = DvAbsoluteQuantity.new(:magnitude => 7)
+  end
+
+  it 'should be an instance of DvAbsoluteQuantity' do
+    @dv_absolute_quantity.should be_an_instance_of DvAbsoluteQuantity
+  end
+
+  it 's add 3 method should magnitude 10' do
+    dv_absolute_quantity10 =
+      @dv_absolute_quantity.add(DvAbsoluteQuantity.new(:magnitude => 3))
+    dv_absolute_quantity10.magnitude.should == 10
+  end
+
+  it 's diff method should return DvAmount' do    
+    diff_dv_amount = @dv_absolute_quantity.diff(DvAbsoluteQuantity.new(
+                                                    :magnitude => 10))
+    diff_dv_amount.magnitude.should == 3
+  end
+
+  it 's subtract method should raise NotImplementedError' do
+    sub_dv_absolute_quantity = @dv_absolute_quantity.subtract(DvAbsoluteQuantity.new(:magnitude => 10))
+    sub_dv_absolute_quantity.magnitude.should == -3
+  end
+
+  it 'should be raise ArgumentError when type mismatched' do
+    lambda {
+      @dv_absolute_quantity.add(1)
+    }.should raise_error ArgumentError
+  end
+end
