Index: ruby/trunk/lib/open_ehr/am.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am.rb	(revision 371)
+++ 	(revision )
@@ -1,57 +1,0 @@
-#! /usr/bin/env ruby
-# component: openEHR Ruby reference implementation
-# description: This file includes Archetype 
-#      class that contains Archetype values.
-#      Main concept is based on Java ref impl.
-#      We should make refactoring to suit for Ruby way.
-# keywords: archetype
-# author: Akimichi TATSUKAWA, Shinji KOBAYASHI
-# support: openEHR.jp
-# license: openEHR open source license
-#
-
-$:.unshift File.join(File.dirname(__FILE__))
-require 'rm/common/resource.rb'
-#require 'rm/support/terminology/openehr_code_set_identifier.rb'
-module OpenEhr
-  module AM
-    module Archetype
-      autoload :ARCHETYPE, "am/archetype/archetype.rb"
-      autoload :Constraint_Model, "am/archetype/constraint_model/archetype_constraint.rb"
-      autoload :Ontology, "am/archetype/ontology.rb"
-      
-      module Archetype_Description
-        autoload :ARCHETYPE_DESCRIPTION, "am/archetype/archetype_description/archetype_description.rb"
-      end
-
-      module Constraint_Model
-        autoload :ARCHETYPE_CONSTRAINT, "am/archetype/constraint_model/archetype_constraint.rb"
-        autoload :ARCHETYPE_SLOT, "am/archetype/constraint_model/archetype_constraint.rb"
-        autoload :Primitive, "am/archetype/constraint_model/primitive.rb"
-      end #end of ConstraintModel
-
-      module Assertion
-        autoload :ASSERTION, "am/archetype/constraint_model/assertion.rb"
-      end
-
-    end # of Archetype
-
-    module OpenEHR_Profile
-      module DataTypes
-        module Basic
-          autoload :C_DV_STATE, "am/openehr_profile/data_types/basic.rb"
-        end
-
-        module Text
-          autoload :C_CODE_PHASE, "am/openehr_profile/data_types/text.rb"
-        end
-
-        module Quantity
-          autoload :C_DV_QUANTITY, "am/openehr_profile/data_types/quantity.rb"
-          autoload :C_DV_ORDINAL, "am/openehr_profile/data_types/quantity.rb"
-          autoload :C_QUANTITY_ITEM, "am/openehr_profile/data_types/quantity.rb"
-        end
-      end
-    end
-  end # of AM
-end # of OpenEHR
Index: ruby/trunk/lib/open_ehr/am/archetype.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype.rb	(revision 372)
+++ ruby/trunk/lib/open_ehr/am/archetype.rb	(revision 372)
@@ -0,0 +1,111 @@
+include OpenEHR::RM::Common::Resource
+
+module OpenEHR
+  module AM
+    module Archetype
+      module ADLDefinition
+        include OpenEHR::RM::Support::Terminology
+#        include OpenEHR::RM::Support::Terminology::OpenEHR_Code_Set_Identifier
+        CURRENT_ADL_VERSION = "1.4"
+      end
+
+      class Archetype < AuthoredResource
+        include ADLDefinition
+        attr_reader :archetype_id, :concept, :definition, :ontology
+        attr_accessor :uid, :adl_version, :parent_archetype_id, :invariants
+
+        def initialize(args = {})
+          super(args)
+          self.adl_version = args[:adl_version] 
+          self.archetype_id = args[:archetype_id]
+          self.uid = args[:uid]
+          self.concept = args[:concept]
+          self.parent_archetype_id = args[:parent_archetype_id]
+          self.definition = args[:definition]
+          self.ontology = args[:ontology]
+          self.invariants = args[:invariants]
+        end
+
+        def archetype_id=(archetype_id)
+          if archetype_id.nil?
+            raise ArgumentError, 'archetype_id is mandatory'
+          end
+          @archetype_id = archetype_id
+        end
+
+        def concept=(concept)
+          if concept.nil?
+            raise ArgumentError, 'concept is mandatory'
+          end
+          @concept = concept
+        end
+
+        def definition=(definition)
+          if definition.nil?
+            raise ArgumentError, 'definition is mandatory'
+          end
+          @definition = definition
+        end
+
+        def ontology=(ontology)
+          if ontology.nil?
+            raise ArgumentError, 'ontology is mandatory'
+          end
+          @ontology = ontology
+        end
+
+        def version
+          return @archetype_id.version_id
+        end
+
+        def short_concept_name
+          return @archetype_id.concept_name
+        end
+
+        def self.create(args ={}, &block)
+          archetype = new(args)
+          if block_given?
+            yield archetype
+          end
+          return archetype
+        end
+
+        def concept_name(a_lang)
+        end
+
+        def constraint_references_valid?
+        end
+
+        def internal_references_valid?
+        end
+
+        def is_specialised?
+        end
+
+        def is_valid?
+        end
+
+        def logical_paths(a_lang)          
+        end
+
+        def node_ids_vaild?
+        end
+
+        def physical_paths
+        end
+
+        def previous_version
+        end
+
+        def specialisation_depth
+        end
+        
+      end # end of Archetype
+      # original file:
+      # ref_imple_eiffel/components/adl_parser/src/interface/adl_definition.e
+
+      class VALIDITY_KIND
+      end
+    end
+  end # of AM
+end # of OpenEHR
Index: ruby/trunk/lib/open_ehr/am/archetype/archetype.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/archetype.rb	(revision 371)
+++ 	(revision )
@@ -1,85 +1,0 @@
-require 'rm/support/terminology.rb'
-
-module OpenEhr
-  module AM
-    module Archetype
-      module ADL_Definition
-#        include OpenEHR::RM::Support::Terminology::OpenEHR_Code_Set_Identifier
-        include OpenEhr::RM::Support::Terminology
-        CURRENT_ADL_VERSION = "1.4"
-      end
-
-      class ARCHETYPE < OpenEhr::RM::Common::Resource::AuthoredResource
-        include ADL_Definition
-        attr_accessor :archetype_id, :concept_code, :is_controlled, :original_language, :parent_archtype_id, :uid
-
-        attr_reader :parent_id,:concept, :definition, :ontology
-        attr_accessor :adl_version,:description,:original_language
-        attr_accessor :revision_history, :translation
-
-        def initialize(args = {})
-          @adl_version = args[:adl_version] if args[:adl_version]
-          @archetype_id = args[:archetype_id] ? args[:archetype_id] : nil
-          @parent_id = args[:parent_id] if args[:parent_id]
-          @concept = args[:concept] if args[:concept]
-          @is_controled = args[:is_controled] if args[:is_controled]
-          @definition = args[:definition] if args[:definition]
-          @ontology = args[:ontology] if args[:ontology]
- #         loadMaps(definition)
-          super
-        end
-
-        def self.create(args ={}, &block)
-          archetype = new(args)
-          if block_given?
-            yield archetype
-          end
-          return archetype
-        end
-
-        def concept_name(a_lang)
-        end
-
-        def constraint_references_valid?
-        end
-
-        def internal_references_valid?
-        end
-
-        def is_specialised?
-        end
-
-        def is_valid?
-        end
-
-        def logical_paths(a_lang)          
-        end
-
-        def node_ids_vaild?
-        end
-
-        def physical_paths
-        end
-
-        def previous_version
-        end
-
-        def short_concept_name
-        end
-
-        def specialisation_depth
-        end
-        
-        def version
-        end
-      end # end of ARCHETYPE
-      # original file:
-      # ref_imple_eiffel/components/adl_parser/src/interface/adl_definition.e
-
-      class VALIDITY_KIND
-      end
-    end
-
-
-  end # end of AM
-end # end of OpenEHR
Index: ruby/trunk/lib/open_ehr/am/archetype/constraint_model.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/constraint_model.rb	(revision 372)
+++ ruby/trunk/lib/open_ehr/am/archetype/constraint_model.rb	(revision 372)
@@ -0,0 +1,144 @@
+
+module OpenEHR
+  module AM
+    module Archetype
+      module ConstraintModel
+        class ArchetypeConstraint
+
+        end
+
+        class Cardinality
+          attr_accessor :interval, :is_ordered, :is_unique
+
+          def initialize(args = { })
+            @interval = args[:interval]
+            @is_ordered = args[:is_ordered]
+            @is_unique = args[:is_unique]
+          end
+        end
+
+        class CObject < ArchetypeConstraint
+          attr_accessor :node_id, :occurrences, :rm_type_name
+
+          def initialize(args = { })
+            @node_id = args[:node_id] if args[:node_id]
+            @occurrences = args[:occurrences] if args[:occurrences]
+            @rm_type_name = args[:rm_type_name] if args[:rm_type_name]
+          end
+
+          def self.create(args = { }, &block)
+            c_object = new(args)
+            if block_given?
+              yield c_object
+            end
+            return c_object
+          end
+        end
+
+        class CAttribute < ArchetypeConstraint
+          attr_accessor :rm_attribute_name, :existence, :children
+
+          def initialize(args = { })
+            @rm_attribute_name = args[:rm_attribute_name] if args[:rm_attribute_name]
+            @existence = args[:existence] if args[:existence]
+            @children = args[:children] ? args[:children] : []
+            
+          end
+        end
+
+        class CDefinedObject < CObject
+          attr_accessor :assumed_value
+          
+          def initialize(args = { })
+            @assumed_value = args[:assumed_value] if args[:assumed_value]
+            super
+          end
+        end
+
+        class CPrimitiveObject < CDefinedObject
+          attr_accessor :item
+
+          def initialize(args = { })
+            @attributes = args[:item] if args[:item]
+            super
+          end
+        end
+
+        class CComplexObject < CDefinedObject
+          attr_accessor :attributes, :attributes_valid
+
+          def initialize(args = { })
+            @attributes = args[:attributes] ? args[:attributes] : []
+            super
+          end
+
+          def self.create(args = { }, &block)
+            c_complex_object = new(args)
+            if block_given?
+              yield c_complex_object
+            end
+            return c_complex_object
+          end
+        end
+
+        class CDomainType < CDefinedObject
+          
+        end
+
+        class CReferenceObject < CObject
+        end
+
+        class ArchetypeInternalRef < CReferenceObject
+          attr_accessor :target_path
+        end
+
+        class ArchetypeSlot < CReferenceObject
+          attr_accessor :includes, :excludes
+
+          def self.create(args = { }, &block)
+            archetype_slot = new(args)
+            archetype_slot.includes = args[:includes]
+            archetype_slot.excludes = args[:excludes]
+            if block_given?
+              yield archetype_slot
+            end
+            return archetype_slot
+          end
+        end
+
+        class ConstantRef < CReferenceObject
+          attr_accessor :reference
+
+          def self.create(args = { }, &block)
+            constraint_ref = new(args)
+            constraint_ref.reference = args[:reference]
+            if block_given?
+              yield constraint_ref
+            end
+            return constraint_ref
+          end
+        end
+
+        class CSingleAttribute < CAttribute
+          attr_accessor :alternatives
+
+          def initialize(args = { })
+            @alternatives = args[:alternatives] ? args[:alternatives] : []
+            super
+          end
+        end
+
+        class CMultipleAttribute < CAttribute
+          attr_accessor :members, :cardinality
+          
+          def initialize(args = { })
+            @members = args[:members] ? args[:members] : []
+            @cardinality = args[:cardinality] if args[:cardinality]
+            super
+          end
+        end
+      end
+    end
+  end
+end
+  
Index: ruby/trunk/lib/open_ehr/am/archetype/constraint_model/archetype_constraint.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/constraint_model/archetype_constraint.rb	(revision 371)
+++ 	(revision )
@@ -1,144 +1,0 @@
-
-module OpenEhr
-  module AM
-    module Archetype
-      module Constraint_Model
-        class ARCHETYPE_CONSTRAINT
-          
-        end
-
-        class CARDINALITY
-          attr_accessor :interval, :is_ordered, :is_unique
-
-          def initialize(args = { })
-            @interval = args[:interval]
-            @is_ordered = args[:is_ordered]
-            @is_unique = args[:is_unique]
-          end
-        end
-
-        class C_OBJECT < ARCHETYPE_CONSTRAINT
-          attr_accessor :node_id, :occurrences, :rm_type_name
-
-          def initialize(args = { })
-            @node_id = args[:node_id] if args[:node_id]
-            @occurrences = args[:occurrences] if args[:occurrences]
-            @rm_type_name = args[:rm_type_name] if args[:rm_type_name]
-          end
-
-          def self.create(args = { }, &block)
-            c_object = new(args)
-            if block_given?
-              yield c_object
-            end
-            return c_object
-          end
-        end
-
-        class C_ATTRIBUTE < ARCHETYPE_CONSTRAINT
-          attr_accessor :rm_attribute_name, :existence, :children
-
-          def initialize(args = { })
-            @rm_attribute_name = args[:rm_attribute_name] if args[:rm_attribute_name]
-            @existence = args[:existence] if args[:existence]
-            @children = args[:children] ? args[:children] : []
-            
-          end
-        end
-
-        class C_DEFINED_OBJECT < C_OBJECT
-          attr_accessor :assumed_value
-          
-          def initialize(args = { })
-            @assumed_value = args[:assumed_value] if args[:assumed_value]
-            super
-          end
-        end
-
-        class C_PRIMITIVE_OBJECT < C_DEFINED_OBJECT
-          attr_accessor :item
-
-          def initialize(args = { })
-            @attributes = args[:item] if args[:item]
-            super
-          end
-        end
-
-        class C_COMPLEX_OBJECT < C_DEFINED_OBJECT
-          attr_accessor :attributes, :attributes_valid
-
-          def initialize(args = { })
-            @attributes = args[:attributes] ? args[:attributes] : []
-            super
-          end
-
-          def self.create(args = { }, &block)
-            c_complex_object = new(args)
-            if block_given?
-              yield c_complex_object
-            end
-            return c_complex_object
-          end
-        end
-
-        class C_DOMAIN_TYPE < C_DEFINED_OBJECT
-          
-        end
-
-        class C_REFERENCE_OBJECT < C_OBJECT
-        end
-
-        class ARCHETYPE_INTERNAL_REF < C_REFERENCE_OBJECT
-          attr_accessor :target_path
-        end
-
-        class ARCHETYPE_SLOT < C_REFERENCE_OBJECT
-          attr_accessor :includes, :excludes
-
-          def self.create(args = { }, &block)
-            archetype_slot = new(args)
-            archetype_slot.includes = args[:includes]
-            archetype_slot.excludes = args[:excludes]
-            if block_given?
-              yield archetype_slot
-            end
-            return archetype_slot
-          end
-        end
-
-        class CONSTRAINT_REF < C_REFERENCE_OBJECT
-          attr_accessor :reference
-
-          def self.create(args = { }, &block)
-            constraint_ref = new(args)
-            constraint_ref.reference = args[:reference]
-            if block_given?
-              yield constraint_ref
-            end
-            return constraint_ref
-          end
-        end
-
-        class C_SINGLE_ATTRIBUTE < C_ATTRIBUTE
-          attr_accessor :alternatives
-
-          def initialize(args = { })
-            @alternatives = args[:alternatives] ? args[:alternatives] : []
-            super
-          end
-        end
-
-        class C_MULTIPLE_ATTRIBUTE < C_ATTRIBUTE
-          attr_accessor :members, :cardinality
-          
-          def initialize(args = { })
-            @members = args[:members] ? args[:members] : []
-            @cardinality = args[:cardinality] if args[:cardinality]
-            super
-          end
-        end
-      end
-    end
-  end
-end
-  
Index: ruby/trunk/lib/open_ehr/am/archetype/ontology.rb
===================================================================
--- ruby/trunk/lib/open_ehr/am/archetype/ontology.rb	(revision 371)
+++ ruby/trunk/lib/open_ehr/am/archetype/ontology.rb	(revision 372)
@@ -1,7 +1,7 @@
-module OpenEhr
+module OpenEHR
   module AM
     module Archetype
       module Ontology
-        class ARCHETYPE_ONTOLOGY
+        class ArchetypeOntology
           attr_accessor :constraint_codes, :specialisation_depth
           attr_accessor :term_attribute_names, :term_codes
