Index: ruby/trunk/lib/open_ehr/am/archetype/constraint_model/primitive.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/constraint_model/primitive.rb	(revision 392)
+++ ruby/trunk/lib/open_ehr/am/archetype/constraint_model/primitive.rb	(revision 393)
@@ -1,29 +1,77 @@
-
-
+# Ticket #71
 module OpenEHR
   module AM
     module Archetype
-      module Primitive
-        class CPrimitive
-          attr_reader :default_value
-          attr_accessor :assumed_value
+      module ConstraintModel
+        module Primitive
+          class CPrimitive
+            attr_reader :default_value
+            attr_accessor :assumed_value
 
-          def initialize(args = { })
-            self.default_value = args[:default_value]
-            self.assumed_value = args[:assumed_value]
+            def initialize(args = { })
+              self.default_value = args[:default_value]
+              self.assumed_value = args[:assumed_value]
+            end
+
+            def default_value=(default_value)
+              if default_value.nil?
+                raise ArgumentError, 'default_value is mandatory'
+              end
+              @default_value = default_value
+            end
+
+            def has_assumed_value?
+              return !assumed_value.nil?
+            end
           end
 
-          def default_value=(default_value)
-            if default_value.nil?
-              raise ArgumentError, 'default_value is mandatory'
+          class CBoolean < CPrimitive
+            attr_reader :true_valid, :false_valid
+
+            def initialize(args = { })
+              binary_consistency(args[:true_valid], args[:false_valid])
+              @true_valid = args[:true_valid]
+              @false_valid = args[:false_valid]
+              super(args)
             end
-            @default_value = default_value
+
+            def default_value=(default_value)
+              super
+              default_value_consistency(default_value)
+            end
+
+            def true_valid=(true_valid)
+              binary_consistency(true_valid, @false_valid)
+              @true_valid = true_valid
+            end
+
+            def false_valid=(false_valid)
+              binary_consistency(@true_valid, false_valid)
+              @false_valid = false_valid
+            end
+
+            def true_valid?
+              return @true_valid
+            end
+
+            def false_valid?
+              return @false_valid
+            end
+
+            private
+            def binary_consistency(true_valid, false_valid)
+              if (true_valid == false) && (false_valid == false)
+                raise ArgumentError, 'true_valid or false_valid should be true'
+              end
+            end
+
+            def default_value_consistency(default_value)
+              if (!@true_valid && default_value) || (!@false_valid && !default_value)
+                raise ArgumentError, 'default value inconsistency'
+              end
+            end
           end
-
-          def has_assumed_value?
-            return !assumed_value.nil?
-          end
-        end
-      end # of Primitive
+        end # of Primitive
+      end # of CostraintModel
     end # of Archetype
   end # of AM
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_primitive_object_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_primitive_object_spec.rb	(revision 392)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/c_primitive_object_spec.rb	(revision 393)
@@ -1,5 +1,5 @@
 require File.dirname(__FILE__) + '/../../../../../spec_helper'
 include OpenEHR::AM::Archetype::ConstraintModel
-include OpenEHR::AM::Archetype::Primitive
+include OpenEHR::AM::Archetype::ConstraintModel::Primitive
 include OpenEHR::AssumedLibraryTypes
 
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_boolean_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_boolean_spec.rb	(revision 393)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_boolean_spec.rb	(revision 393)
@@ -0,0 +1,52 @@
+require File.dirname(__FILE__) + '/../../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel::Primitive
+include OpenEHR::RM::DataTypes::Basic
+
+describe CBoolean do
+  before(:each) do
+    default_value = DvBoolean.new(:value => true)
+    @c_boolean = CBoolean.new(:default_value => true,
+                              :true_valid => true,
+                              :false_valid => true)
+  end
+
+  it 'should be_an_instance_of CBoolean' do
+    @c_boolean.should be_an_instance_of CBoolean
+  end
+
+  it 'true_valid should be assigned properly' do
+    @c_boolean.should be_true_valid
+  end
+
+  it 'false_valid should be assigned properly' do
+    @c_boolean.should be_false_valid
+  end
+
+  it 'should raise ArgumentError when both true_valid and false_valid are false' do
+    lambda {
+      @c_boolean.true_valid = false
+      @c_boolean.false_valid = false
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError if both false_valid and true_valid  are false' do
+    lambda {
+      @c_boolean.false_valid = false
+      @c_boolean.true_valid = false
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError if default_value is false and false_valid is false' do
+    lambda {
+      @c_boolean.false_valid = false
+      @c_boolean.default_value = false
+    }.should raise_error ArgumentError
+  end
+
+  it 'should raise ArgumentError if default_value is true and true_valid is false' do
+    lambda {
+      @c_boolean.true_valid = false
+      @c_boolean.default_value = true
+    }.should raise_error ArgumentError
+  end
+end
Index: ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_primitive_spec.rb
===================================================================
--- ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_primitive_spec.rb	(revision 393)
+++ ruby/trunk/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_primitive_spec.rb	(revision 393)
@@ -0,0 +1,39 @@
+require File.dirname(__FILE__) + '/../../../../../../spec_helper'
+include OpenEHR::AM::Archetype::ConstraintModel::Primitive
+include OpenEHR::RM::DataTypes::Text
+
+describe CPrimitive do
+  before(:each) do
+    default = DvText.new(:value => 'DEFAULT')
+    assumed = DvText.new(:value => 'ASSUMED')
+    @c_primitive = CPrimitive.new(:default_value => default,
+                                  :assumed_value => assumed)
+  end
+
+  it 'should be an instance of CPrimitive' do
+    @c_primitive.should be_an_instance_of CPrimitive
+  end
+
+  it 'default value should be assigned properly' do
+    @c_primitive.default_value.value.should == 'DEFAULT'
+  end
+
+  it 'should raise ArgumentError when default_value is nil' do
+    lambda {
+      @c_primitive.default_value = nil
+    }.should raise_error ArgumentError
+  end
+
+  it 'assumed_value should be assigned properly' do
+    @c_primitive.assumed_value.value.should == 'ASSUMED'
+  end
+
+  it 'should be true when assumed_value is assigned' do
+    @c_primitive.should have_assumed_value
+  end
+
+  it 'should not be true when assumed_value is not assigned' do
+    @c_primitive.assumed_value = nil
+    @c_primitive.should_not have_assumed_value
+  end
+end
