Index: /ruby/branches/0.5/lib/open_ehr/rm/data_structures/history.rb
===================================================================
--- /ruby/branches/0.5/lib/open_ehr/rm/data_structures/history.rb	(revision 342)
+++ /ruby/branches/0.5/lib/open_ehr/rm/data_structures/history.rb	(revision 342)
@@ -0,0 +1,46 @@
+# rm::data_structures::history
+# history module
+# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109157527311_729550_7234Report.html
+# refs #55
+include OpenEHR::RM::DataStructures
+
+module OpenEHR
+  module RM
+    module DataStructures
+      module History
+        class History < DataStructure
+          attr_reader :origin, :events
+          attr_accessor :duration, :period, :summary
+
+          def initialize(args = { })
+            super(args)
+            self.origin = args[:origin]
+            self.duration = args[:duration]
+            self.period = args[:period]
+            self.events = args[:events]
+            self.summary = args[:summary]
+          end
+
+          def origin=(origin)
+            raise ArgumentError, 'origin is mandatory' if origin.nil?
+            @origin = origin
+          end
+
+          def events=(events)
+            if !events.nil? and events.empty?
+              raise ArgumentError, 'events should not be empty'
+            end
+            @events = events
+          end
+
+          def is_periodic?
+            return !@period.nil?
+          end
+        end
+
+        class Event
+        end
+      end # end of History
+    end # end of DataStructure
+  end # end of RM
+end # end of OpenEHR
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 341)
+++ /ruby/branches/0.5/lib/open_ehr/rm/data_types/quantity/date_time.rb	(revision 342)
@@ -81,5 +81,5 @@
               end
               year += future.year - past.year
-              return DvDuration.new(
+              return DvDuration.new(:value =>
                    'P' + year.to_s + 'Y' + month.to_s + 'M' + 
                          week.to_s + 'W' + day.to_s + 'D')
@@ -109,5 +109,6 @@
               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' +
+              return DvDuration.new(:value =>
+                        'P0Y0M0W0DT' + hour.to_s + 'H' +
                         minute.to_s + 'M' +
                         second.to_s + fractional_second.to_s[1..-1] + 'S')
@@ -162,5 +163,6 @@
               fractional_second = 
                 ((time_diff - time_diff.to_i)*1000000.0).to_i/1000000.0
-              return DvDuration.new(date_duration.value + 'T' +
+              return DvDuration.new(:value => 
+                        date_duration.value + 'T' +
                         hour.to_s + 'H' +
                         minute.to_s + 'M' +
@@ -180,8 +182,10 @@
             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
+            def initialize(args = { })
+              self.value = args[:value]
+              self.magnitude_status = args[:magnitude_status]
+              self.normal_range = args[:normal_range]
+              self.normal_status = args[:normal_status]
+              self.other_reference_ranges = args[:other_reference_ranges]
             end
 
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/history/history_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/history/history_spec.rb	(revision 342)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/history/history_spec.rb	(revision 342)
@@ -0,0 +1,66 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::RM::DataStructures::History
+include OpenEHR::RM::DataStructures::ItemStructure
+include OpenEHR::RM::DataTypes::Text
+include OpenEHR::RM::DataTypes::Quantity::DateTime
+describe History do
+  before(:each) do
+    origin = DvDateTime.new(:value => '2009-11-01T00:00:00')
+    period = DvDuration.new(:value => 'P1Y2M3W4D')
+    duration = DvDuration.new(:value => 'P0Y0M0W6D')
+    events = [stub(Event, :archetype_node_id => 'at0002')]
+    summary = stub(ItemStructure, :archetype_node_id => 'at0003')
+    @history = History.new(:archetype_node_id => 'at0001',
+                           :name => DvText.new(:value => 'history test'),
+                           :origin => origin,
+                           :period => period,
+                           :duration => duration,
+                           :events => events,
+                           :summary => summary)
+  end
+
+  it 'should be an instance of History' do
+    @history.should be_an_instance_of History
+  end
+
+  it 'origin should be properly assigned' do
+    @history.origin.value.should == '2009-11-01T00:00:00'
+  end
+
+  it 'should raise ArgumentError with nil origin' do
+    lambda {
+      @history.origin = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'period should be properly assigned' do
+    @history.period.value.should == 'P1Y2M3W4D'
+  end
+
+  it 'duration should be properly assigned' do
+    @history.duration.value.should == 'P0Y0M0W6D'
+  end
+
+  it 'is_periodic? should be true when period is not nil' do
+    @history.is_periodic?.should be_true
+  end
+
+  it 'is_periodic? should be false when period is nil' do
+    @history.period = nil
+    @history.is_periodic?.should be_false
+  end
+
+  it 'events should be properly assigned' do
+    @history.events[0].archetype_node_id.should == 'at0002'
+  end
+
+  it 'empty events should raise ArgumentError' do
+    lambda {
+      @history.events = []
+    }.should raise_error ArgumentError
+  end
+
+  it 'summary should be properly assigned' do
+    @history.summary.archetype_node_id.should == 'at0003'
+  end
+end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/representation/cluster_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/representation/cluster_spec.rb	(revision 342)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/representation/cluster_spec.rb	(revision 342)
@@ -0,0 +1,26 @@
+require File.dirname(__FILE__) + '/../../../../../../spec_helper'
+include OpenEHR::RM::DataStructures::ItemStructure::Representation
+include OpenEHR::RM::DataTypes::Text
+
+describe Cluster do
+  before(:each) do
+    item = stub(Item)
+    @cluster = Cluster.new(:archetype_node_id => 'at0001',
+                           :name => DvText.new(:value => 'cluster'),
+                           :items => [item, item])
+  end
+
+  it 'should be an isntance of Cluster' do
+    @cluster.should be_an_instance_of Cluster
+  end
+
+  it 'item size should be 2' do
+    @cluster.items.size.should == 2
+  end
+
+  it 'should raise ArgumentError with empty items' do
+    lambda {
+      @cluster.items = []
+    }.should raise_error ArgumentError
+  end
+end
Index: /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/representation/element_spec.rb
===================================================================
--- /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/representation/element_spec.rb	(revision 342)
+++ /ruby/branches/0.5/spec/lib/open_ehr/rm/data_structures/item_structure/representation/element_spec.rb	(revision 342)
@@ -0,0 +1,22 @@
+require File.dirname(__FILE__) + '/../../../../../../spec_helper'
+include OpenEHR::RM::DataStructures::ItemStructure::Representation
+include OpenEHR::RM::DataTypes::Text
+
+describe Element do
+  before(:each) do
+    value = DvText.new(:value => 'test')
+    @element = Element.new(:archetype_node_id => 'at0001',
+                           :name => DvText.new(:value => 'element'),
+                           :value => value)
+  end
+
+  it 'should be an instance of Element' do
+    @element.should be_an_instance_of Element
+  end
+
+  it 'value should be assigned as test' do
+    @element.value.value.should == 'test'
+  end
+
+  it 'nullflavor should be assigned'
+end
