Index: ruby/trunk/lib/open_ehr/am/archetype/constraint_model.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/constraint_model.rb	(revision 381)
+++ ruby/trunk/lib/open_ehr/am/archetype/constraint_model.rb	(revision 382)
@@ -215,12 +215,49 @@
 
         class CReferenceObject < CObject
+
         end
 
         class ArchetypeInternalRef < CReferenceObject
-          attr_accessor :target_path
+          attr_reader :target_path
+
+          def initialize(args = { })
+            super
+            self.target_path = args[:target_path]
+          end
+
+          def target_path=(target_path)
+            if target_path.nil? or target_path.empty?
+              raise ArgumentError, 'target_path is mandatory'
+            end
+            @target_path = target_path
+          end
         end
 
         class ArchetypeSlot < CReferenceObject
-          attr_accessor :includes, :excludes
+          attr_reader :includes, :excludes
+
+          def initialize(args = { })
+            super
+            self.includes = args[:includes]
+            self.excludes = args[:excludes]
+          end
+
+          def includes=(includes)
+            if !includes.nil? && includes.empty?
+              raise ArgumentError, 'includes should not be empty'
+            end
+            @includes = includes
+          end
+          
+          def excludes=(excludes)
+            if !excludes.nil? && excludes.empty?
+              raise ArgumentError, 'excludes should not be empty'
+            end
+            @excludes = excludes
+          end
+
+          def any_allowed?
+            return includes.nil? && excludes.nil?
+          end
 
           def self.create(args = { }, &block)
@@ -235,6 +272,18 @@
         end
 
-        class ConstantRef < CReferenceObject
-          attr_accessor :reference
+        class ConstraintRef < CReferenceObject
+          attr_reader :reference
+
+          def initialize(args = { })
+            super
+            self.reference = args[:reference]
+          end
+
+          def reference=(reference)
+            if reference.nil?
+              raise ArgumentError, 'reference is mandatory'
+            end
+            @reference = reference
+          end
 
           def self.create(args = { }, &block)
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/archetype_internal_ref_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/archetype_internal_ref_spec.rb	(revision 382)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/archetype_internal_ref_spec.rb	(revision 382)
@@ -0,0 +1,36 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel
+include OpenEHR::AssumedLibraryTypes
+
+describe ArchetypeInternalRef do
+  before(:each) do
+    occurrences = Interval.new(:lower => 0, :upper => 1)
+    @archetype_internal_ref =
+      ArchetypeInternalRef.new(:path => '/event/[at0001]/',
+                               :rm_type_name => 'DV_TIME',
+                               :node_id => 'ac0001',
+                               :occurrences => occurrences,
+                               :target_path => '/data/[at0002]')
+  end
+
+  it 'should be an instance of ArchetypeInternalRef' do
+    @archetype_internal_ref.should be_an_instance_of ArchetypeInternalRef
+  end
+
+  it 'target_path should be assigned properly' do
+    @archetype_internal_ref.target_path.should == '/data/[at0002]'
+  end
+
+  it 'should raise ArgumentError when target_path is nil.' do
+    lambda {
+      @archetype_internal_ref.target_path = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError when target_path is empty.' do
+    lambda {
+      @archetype_internal_ref.target_path = ''
+    }.should raise_error ArgumentError
+  end
+end
+  
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/archetype_slot_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/archetype_slot_spec.rb	(revision 382)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/archetype_slot_spec.rb	(revision 382)
@@ -0,0 +1,61 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel
+include OpenEHR::AssumedLibraryTypes
+
+describe ArchetypeSlot do
+  before(:each) do
+    occurrences = Interval.new(:lower => 0, :upper => 1)
+    includes = stub(Set, :empty? => false, :size => 2)
+    excludes = stub(Set, :empty? => false, :size => 10)
+    @archetype_slot = ArchetypeSlot.new(:path => '/event/[at0001]/',
+                                        :rm_type_name => 'DV_TIME',
+                                        :node_id => 'ac0001',
+                                        :occurrences => occurrences,
+                                        :includes => includes,
+                                        :excludes => excludes)
+  end
+
+  it 'should be an instance of ArchetypeSlot' do
+    @archetype_slot.should be_an_instance_of ArchetypeSlot
+  end
+
+  it 'includes should be assigned properly' do
+    @archetype_slot.includes.size.should be_equal 2
+  end
+
+  it 'should raise ArgumentError when includes are empty' do
+    lambda {
+      @archetype_slot.includes = Set.new
+    }.should raise_error ArgumentError
+  end
+
+  it 'excludes should be assigned properly' do
+    @archetype_slot.excludes.size.should be_equal 10
+  end
+
+  it 'should raise ArgumentError when excludes are empty' do
+    lambda {
+      @archetype_slot.excludes = Set.new
+    }.should raise_error ArgumentError
+  end
+
+  it 'any_allowed should be false when includes and excludes are not nil' do
+    @archetype_slot.should_not be_any_allowed
+  end
+
+  it 'any_allowed should be false when includes are nil and excludes are not nil' do
+    @archetype_slot.includes = nil
+    @archetype_slot.should_not be_any_allowed
+  end
+
+  it 'any_allowed should be false when includes are not nil and excludes are nil' do
+    @archetype_slot.excludes = nil
+    @archetype_slot.should_not be_any_allowed
+  end
+
+  it 'any_allowed should be true when includes and excludes are nil' do
+    @archetype_slot.includes = nil
+    @archetype_slot.excludes = nil
+    @archetype_slot.should be_any_allowed
+  end
+end
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_reference_object_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_reference_object_spec.rb	(revision 382)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_reference_object_spec.rb	(revision 382)
@@ -0,0 +1,17 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel
+include OpenEHR::AssumedLibraryTypes
+
+describe CReferenceObject do
+  before(:each) do
+    occurrences = Interval.new(:lower => 0, :upper => 1)
+    @c_reference_object = CReferenceObject.new(:path => '/event/[at0001]/',
+                                               :rm_type_name => 'DV_TIME',
+                                               :node_id => 'ac0001',
+                                               :occurrences => occurrences)
+  end
+
+  it 'should be an instance of CReferenceObject' do
+    @c_reference_object.should be_an_instance_of CReferenceObject
+  end
+end
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/constraint_ref_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/constraint_ref_spec.rb	(revision 382)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/constraint_ref_spec.rb	(revision 382)
@@ -0,0 +1,29 @@
+require File.dirname(__FILE__) + '/../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel
+include OpenEHR::AssumedLibraryTypes
+
+describe ConstraintRef do
+  before(:each) do
+    occurrences = Interval.new(:lower => 0, :upper => 1)
+    @constraint_ref =
+      ConstraintRef.new(:path => '/event/[at0001]/',
+                        :rm_type_name => 'DV_TIME',
+                        :node_id => 'ac0001',
+                        :occurrences => occurrences,
+                        :reference => 'ac0002')
+  end
+
+  it 'should be an instance of ConstraintRef' do
+    @constraint_ref.should be_an_instance_of ConstraintRef
+  end
+
+  it 'reference should be assigned properly' do
+    @constraint_ref.reference.should == 'ac0002'
+  end
+
+  it 'should raise ArgumentError when reference is nil' do
+    lambda {
+      @constraint_ref.reference = nil
+    }.should raise_error ArgumentError
+  end
+end
