Index: /ruby/trunk/adl_parser/Rakefile
===================================================================
--- /ruby/trunk/adl_parser/Rakefile	(revision 25)
+++ /ruby/trunk/adl_parser/Rakefile	(revision 26)
@@ -92,4 +92,5 @@
   s.extra_rdoc_files = ["README"]
   s.add_dependency("yaparc", ">= 0.2.0")
+  s.add_dependency("openehr_models", ">= 0.0.1")
 end
 
Index: /ruby/trunk/adl_parser/lib/parser.rb
===================================================================
--- /ruby/trunk/adl_parser/lib/parser.rb	(revision 25)
+++ /ruby/trunk/adl_parser/lib/parser.rb	(revision 26)
@@ -13,5 +13,4 @@
 require 'lib/util.rb'
 require 'lib/scanner.rb'
-#require 'lib/model.rb'
 require 'rubygems'
 require 'am.rb'
@@ -27,5 +26,5 @@
     class Parser < Racc::Parser
 
-module_eval <<'..end lib/parser.y modeval..iddb76fb97bf', 'lib/parser.y', 1106
+module_eval <<'..end lib/parser.y modeval..id3b9eed63e6', 'lib/parser.y', 1127
 
 def assert_at(file,line, message = "")
@@ -820,5 +819,5 @@
 
 
-..end lib/parser.y modeval..iddb76fb97bf
+..end lib/parser.y modeval..id3b9eed63e6
 
 ##### racc 1.4.5 generates ###
@@ -841,7 +840,7 @@
  2, 98, :_reduce_none,
  2, 98, :_reduce_none,
+ 2, 99, :_reduce_16,
  2, 99, :_reduce_none,
- 2, 99, :_reduce_none,
- 0, 100, :_reduce_none,
+ 0, 100, :_reduce_18,
  2, 100, :_reduce_19,
  2, 100, :_reduce_none,
@@ -1200,5 +1199,5 @@
  1, 149, :_reduce_none,
  1, 149, :_reduce_374,
- 1, 217, :_reduce_none ]
+ 1, 217, :_reduce_375 ]
 
 racc_reduce_n = 376
@@ -2029,5 +2028,5 @@
  # reduce 2 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 46
+module_eval <<'.,.,', 'lib/parser.y', 57
   def _reduce_3( val, _values, result )
     assert_at(__FILE__,__LINE__) do
@@ -2035,14 +2034,25 @@
     end
     
-    result = OpenEHR::AM::Archetype::ARCHETYPE.new(
-                                                   :description => val[4],
-                                                   :definition => val[5],
-                                                   :ontology => val[7]
-                                                   )
-   result
-  end
-.,.,
-
-module_eval <<'.,.,', 'lib/parser.y', 52
+    archetype_id = val[0][:archetype_id]
+    adl_version = val[0][:arch_head][:arch_meta_data][:adl_version]
+    concept = val[2]
+    language = val[3][:arch_language]
+    archetype = OpenEHR::AM::Archetype::ARCHETYPE.create(
+                                                         :archetype_id => archetype_id,
+                                                         :adl_version => adl_version,
+                                                         :concept => concept,
+                                                         :description => val[4],
+                                                         :definition => val[5],
+                                                         :ontology => val[7]
+                                                         ) do |archetype|
+      archetype.original_language = language
+    end
+    @@log.info("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")
+    result = archetype
+   result
+  end
+.,.,
+
+module_eval <<'.,.,', 'lib/parser.y', 63
   def _reduce_4( val, _values, result )
     result = {:arch_head => val[0], :archetype_id => val[1] }
@@ -2051,5 +2061,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 56
+module_eval <<'.,.,', 'lib/parser.y', 67
   def _reduce_5( val, _values, result )
     raise
@@ -2058,5 +2068,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 61
+module_eval <<'.,.,', 'lib/parser.y', 72
   def _reduce_6( val, _values, result )
     result = {:arch_meta_data => nil }
@@ -2065,6 +2075,13 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 65
+module_eval <<'.,.,', 'lib/parser.y', 76
   def _reduce_7( val, _values, result )
+    result = val[1]
+   result
+  end
+.,.,
+
+module_eval <<'.,.,', 'lib/parser.y', 81
+  def _reduce_8( val, _values, result )
     result = {:arch_meta_data => val[1] }
    result
@@ -2072,35 +2089,28 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 70
-  def _reduce_8( val, _values, result )
-    result = {:arch_meta_data_items => val[1] }
-   result
-  end
-.,.,
-
-module_eval <<'.,.,', 'lib/parser.y', 75
+module_eval <<'.,.,', 'lib/parser.y', 86
   def _reduce_9( val, _values, result )
-    result = Array[val[0]]
-   result
-  end
-.,.,
-
-module_eval <<'.,.,', 'lib/parser.y', 79
+    result = val[0]
+   result
+  end
+.,.,
+
+module_eval <<'.,.,', 'lib/parser.y', 90
   def _reduce_10( val, _values, result )
-    result = (val[0] << val[2])
-   result
-  end
-.,.,
-
-module_eval <<'.,.,', 'lib/parser.y', 85
+    result = val[0].merge(val[2])
+   result
+  end
+.,.,
+
+module_eval <<'.,.,', 'lib/parser.y', 96
   def _reduce_11( val, _values, result )
-    result = {:adl_version => val[2] }
-   result
-  end
-.,.,
-
-module_eval <<'.,.,', 'lib/parser.y', 89
+    result = {:adl_version => val[2], :is_controlled => false }
+   result
+  end
+.,.,
+
+module_eval <<'.,.,', 'lib/parser.y', 100
   def _reduce_12( val, _values, result )
-    result = val[0]
+    result = {:is_controlled => true }
    result
   end
@@ -2113,13 +2123,23 @@
  # reduce 15 omitted
 
- # reduce 16 omitted
+module_eval <<'.,.,', 'lib/parser.y', 111
+  def _reduce_16( val, _values, result )
+    result = {:arch_concept => val[1] }
+   result
+  end
+.,.,
 
  # reduce 17 omitted
 
- # reduce 18 omitted
-
-module_eval <<'.,.,', 'lib/parser.y', 108
+module_eval <<'.,.,', 'lib/parser.y', 121
+  def _reduce_18( val, _values, result )
+    result = {:arch_language => nil}
+   result
+  end
+.,.,
+
+module_eval <<'.,.,', 'lib/parser.y', 125
   def _reduce_19( val, _values, result )
-    result = {:language => val[1]}
+    result = {:arch_language => val[1]}
    result
   end
@@ -2130,5 +2150,5 @@
  # reduce 21 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 119
+module_eval <<'.,.,', 'lib/parser.y', 136
   def _reduce_22( val, _values, result )
     result = OpenEHR::AM::Archetype::Archetype_Description::ARCHETYPE_DESCRIPTION.new(:details => val[1])
@@ -2139,5 +2159,5 @@
  # reduce 23 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 127
+module_eval <<'.,.,', 'lib/parser.y', 144
   def _reduce_24( val, _values, result )
     result = val[1]
@@ -2148,5 +2168,5 @@
  # reduce 25 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 137
+module_eval <<'.,.,', 'lib/parser.y', 154
   def _reduce_26( val, _values, result )
     assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT)}
@@ -2157,5 +2177,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 141
+module_eval <<'.,.,', 'lib/parser.y', 158
   def _reduce_27( val, _values, result )
     result = val[0]
@@ -2164,5 +2184,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 152
+module_eval <<'.,.,', 'lib/parser.y', 169
   def _reduce_28( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object|
@@ -2175,5 +2195,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 160
+module_eval <<'.,.,', 'lib/parser.y', 177
   def _reduce_29( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.create(:attributes => val[3]) do |c_complex_object|
@@ -2186,5 +2206,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 167
+module_eval <<'.,.,', 'lib/parser.y', 184
   def _reduce_30( val, _values, result )
     result = {:c_complex_object_id => val[0], :c_occurrences => val[1]}
@@ -2193,5 +2213,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 172
+module_eval <<'.,.,', 'lib/parser.y', 189
   def _reduce_31( val, _values, result )
     result = {:type_identifier => val[0]}
@@ -2200,5 +2220,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 176
+module_eval <<'.,.,', 'lib/parser.y', 193
   def _reduce_32( val, _values, result )
     result = {:type_identifier => val[0], :local_term_code_ref => val[1]}
@@ -2209,5 +2229,5 @@
  # reduce 33 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 182
+module_eval <<'.,.,', 'lib/parser.y', 199
   def _reduce_34( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new(:attributes => val[0])
@@ -2216,5 +2236,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 190
+module_eval <<'.,.,', 'lib/parser.y', 207
   def _reduce_35( val, _values, result )
     result = val[0]
@@ -2223,5 +2243,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 194
+module_eval <<'.,.,', 'lib/parser.y', 211
   def _reduce_36( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::C_COMPLEX_OBJECT.new
@@ -2230,5 +2250,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 198
+module_eval <<'.,.,', 'lib/parser.y', 215
   def _reduce_37( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_INTERNAL_REF.new
@@ -2237,5 +2257,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 202
+module_eval <<'.,.,', 'lib/parser.y', 219
   def _reduce_38( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::ARCHETYPE_SLOT.new
@@ -2244,5 +2264,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 206
+module_eval <<'.,.,', 'lib/parser.y', 223
   def _reduce_39( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::CONSTRAINT_REF.new
@@ -2251,5 +2271,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 210
+module_eval <<'.,.,', 'lib/parser.y', 227
   def _reduce_40( val, _values, result )
     result = val[0]
@@ -2258,5 +2278,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 214
+module_eval <<'.,.,', 'lib/parser.y', 231
   def _reduce_41( val, _values, result )
     result = val[0]
@@ -2265,5 +2285,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 218
+module_eval <<'.,.,', 'lib/parser.y', 235
   def _reduce_42( val, _values, result )
     result = val[0]
@@ -2276,5 +2296,5 @@
  # reduce 44 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 233
+module_eval <<'.,.,', 'lib/parser.y', 250
   def _reduce_45( val, _values, result )
     result = val[1]
@@ -2297,5 +2317,5 @@
  # reduce 52 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 253
+module_eval <<'.,.,', 'lib/parser.y', 270
   def _reduce_53( val, _values, result )
     assert_at(__FILE__,__LINE__){val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_PRIMITIVE)}
@@ -2305,5 +2325,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 259
+module_eval <<'.,.,', 'lib/parser.y', 276
   def _reduce_54( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: c_integer = #{val[0]} at #{@filename}:#{@lineno}")
@@ -2313,5 +2333,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 264
+module_eval <<'.,.,', 'lib/parser.y', 281
   def _reduce_55( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: c_real = #{val[0]} at #{@filename}:#{@lineno}")
@@ -2321,5 +2341,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 269
+module_eval <<'.,.,', 'lib/parser.y', 286
   def _reduce_56( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: c_date = #{val[0]} at #{@filename}:#{@lineno}")
@@ -2329,5 +2349,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 274
+module_eval <<'.,.,', 'lib/parser.y', 291
   def _reduce_57( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: c_time = #{val[0]} at #{@filename}:#{@lineno}")
@@ -2337,5 +2357,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 279
+module_eval <<'.,.,', 'lib/parser.y', 296
   def _reduce_58( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: c_date_time = #{val[0]} at #{@filename}:#{@lineno}")
@@ -2345,5 +2365,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 284
+module_eval <<'.,.,', 'lib/parser.y', 301
   def _reduce_59( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: c_duration = #{val[0]} at #{@filename}:#{@lineno}")
@@ -2353,5 +2373,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 289
+module_eval <<'.,.,', 'lib/parser.y', 306
   def _reduce_60( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: c_string = #{val[0]} at #{@filename}:#{@lineno}")
@@ -2361,5 +2381,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 295
+module_eval <<'.,.,', 'lib/parser.y', 312
   def _reduce_61( val, _values, result )
     assert_at(__FILE__,__LINE__){val[0].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN)}
@@ -2372,5 +2392,5 @@
  # reduce 62 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 305
+module_eval <<'.,.,', 'lib/parser.y', 322
   def _reduce_63( val, _values, result )
     result = [val[0]]
@@ -2379,5 +2399,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 309
+module_eval <<'.,.,', 'lib/parser.y', 326
   def _reduce_64( val, _values, result )
     result = (val[0] << val[1])
@@ -2386,5 +2406,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 318
+module_eval <<'.,.,', 'lib/parser.y', 335
   def _reduce_65( val, _values, result )
     assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)}
@@ -2396,5 +2416,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 323
+module_eval <<'.,.,', 'lib/parser.y', 340
   def _reduce_66( val, _values, result )
     assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)}
@@ -2404,5 +2424,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 328
+module_eval <<'.,.,', 'lib/parser.y', 345
   def _reduce_67( val, _values, result )
     assert_at(__FILE__,__LINE__){ val[0].kind_of?(OpenEHR::AM::Archetype::Constraint_Model::C_ATTRIBUTE)}
@@ -2412,5 +2432,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 339
+module_eval <<'.,.,', 'lib/parser.y', 356
   def _reduce_68( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]}, c_existence = #{val[1]} at #{@filename}")
@@ -2423,5 +2443,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 349
+module_eval <<'.,.,', 'lib/parser.y', 366
   def _reduce_69( val, _values, result )
     assert_at(__FILE__,__LINE__){ val[2].instance_of?(OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY) }
@@ -2436,5 +2456,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 354
+module_eval <<'.,.,', 'lib/parser.y', 371
   def _reduce_70( val, _values, result )
     result = Array[val[0]]
@@ -2443,5 +2463,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 358
+module_eval <<'.,.,', 'lib/parser.y', 375
   def _reduce_71( val, _values, result )
     result = (val[0] << val[1])
@@ -2450,5 +2470,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 362
+module_eval <<'.,.,', 'lib/parser.y', 379
   def _reduce_72( val, _values, result )
     result = Array[val[0]]
@@ -2481,7 +2501,7 @@
  # reduce 84 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 393
+module_eval <<'.,.,', 'lib/parser.y', 410
   def _reduce_85( val, _values, result )
-    dadl_sections = val[1]
+    dadl_section = val[1]
     result = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new
    result
@@ -2497,5 +2517,5 @@
  # reduce 89 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 407
+module_eval <<'.,.,', 'lib/parser.y', 424
   def _reduce_90( val, _values, result )
     result = Array[val[0]]
@@ -2504,5 +2524,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 411
+module_eval <<'.,.,', 'lib/parser.y', 428
   def _reduce_91( val, _values, result )
     result = (val[0] << val[1])
@@ -2511,5 +2531,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 415
+module_eval <<'.,.,', 'lib/parser.y', 432
   def _reduce_92( val, _values, result )
     result = (val[0] << val[2])
@@ -2518,5 +2538,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 421
+module_eval <<'.,.,', 'lib/parser.y', 438
   def _reduce_93( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: attr_id = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
@@ -2526,5 +2546,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 427
+module_eval <<'.,.,', 'lib/parser.y', 444
   def _reduce_94( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}:#{@lineno}")
@@ -2536,5 +2556,5 @@
  # reduce 95 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 433
+module_eval <<'.,.,', 'lib/parser.y', 450
   def _reduce_96( val, _values, result )
     result = val[0]
@@ -2543,5 +2563,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 437
+module_eval <<'.,.,', 'lib/parser.y', 454
   def _reduce_97( val, _values, result )
     result = val[0]
@@ -2550,5 +2570,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 442
+module_eval <<'.,.,', 'lib/parser.y', 459
   def _reduce_98( val, _values, result )
     result = val[0]
@@ -2557,5 +2577,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 446
+module_eval <<'.,.,', 'lib/parser.y', 463
   def _reduce_99( val, _values, result )
     result = val[0]
@@ -2564,5 +2584,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 451
+module_eval <<'.,.,', 'lib/parser.y', 468
   def _reduce_100( val, _values, result )
     result = {:untyped_multiple_attr_object_block => val[0]}
@@ -2571,5 +2591,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 455
+module_eval <<'.,.,', 'lib/parser.y', 472
   def _reduce_101( val, _values, result )
     result = {:type_identifier => val[0], :untyped_multiple_attr_object_block => val[1]}
@@ -2578,5 +2598,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 460
+module_eval <<'.,.,', 'lib/parser.y', 477
   def _reduce_102( val, _values, result )
     result = {:multiple_attr_object_block_head => val[0], :keyed_objects => val[1]}
@@ -2585,5 +2605,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 466
+module_eval <<'.,.,', 'lib/parser.y', 483
   def _reduce_103( val, _values, result )
     @@log.info("SYM_START_DBLOCK: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2593,5 +2613,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 471
+module_eval <<'.,.,', 'lib/parser.y', 488
   def _reduce_104( val, _values, result )
     result = Array[val[0]]
@@ -2600,5 +2620,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 475
+module_eval <<'.,.,', 'lib/parser.y', 492
   def _reduce_105( val, _values, result )
     result = (val[0] << val[1])
@@ -2607,5 +2627,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 481
+module_eval <<'.,.,', 'lib/parser.y', 498
   def _reduce_106( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: keyed_object = #{val[0]}, object_block = #{val[2]} at #{@filename}:#{@lineno}")
@@ -2615,5 +2635,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 487
+module_eval <<'.,.,', 'lib/parser.y', 504
   def _reduce_107( val, _values, result )
     @@log.info("object_key: [#{val[1]}] at #{@filename}:#{@lineno}")
@@ -2623,5 +2643,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 492
+module_eval <<'.,.,', 'lib/parser.y', 509
   def _reduce_108( val, _values, result )
     result = {:untyped_single_attr_object_block => val[0]}
@@ -2630,5 +2650,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 496
+module_eval <<'.,.,', 'lib/parser.y', 513
   def _reduce_109( val, _values, result )
     result = {:type_identifier => val[0], :untyped_single_attr_object_block => val[1]}
@@ -2637,5 +2657,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 502
+module_eval <<'.,.,', 'lib/parser.y', 519
   def _reduce_110( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]} at #{@filename}:#{@lineno}")
@@ -2645,5 +2665,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 507
+module_eval <<'.,.,', 'lib/parser.y', 524
   def _reduce_111( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: single_attr_object_complex_head = #{val[0]}, attr_vals = #{val[1]} at #{@filename}:#{@lineno}")
@@ -2655,5 +2675,5 @@
  # reduce 112 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 513
+module_eval <<'.,.,', 'lib/parser.y', 530
   def _reduce_113( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: untyped_primitive_object_block = #{val[0]} at #{@filename}:#{@lineno}")
@@ -2663,5 +2683,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 518
+module_eval <<'.,.,', 'lib/parser.y', 535
   def _reduce_114( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: type_identifier = #{val[0]}, untyped_primitive_object_block = #{val[1]} at #{@filename}:#{@lineno}")
@@ -2671,5 +2691,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 523
+module_eval <<'.,.,', 'lib/parser.y', 540
   def _reduce_115( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: primitive_object_block = <#{val[1]}> at #{@filename}:#{@lineno}")
@@ -2679,5 +2699,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 527
+module_eval <<'.,.,', 'lib/parser.y', 544
   def _reduce_116( val, _values, result )
     result = val[0]
@@ -2686,5 +2706,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 531
+module_eval <<'.,.,', 'lib/parser.y', 548
   def _reduce_117( val, _values, result )
     result = val[0]
@@ -2693,5 +2713,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 535
+module_eval <<'.,.,', 'lib/parser.y', 552
   def _reduce_118( val, _values, result )
     result = val[0]
@@ -2700,5 +2720,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 539
+module_eval <<'.,.,', 'lib/parser.y', 556
   def _reduce_119( val, _values, result )
     result = val[0]
@@ -2707,5 +2727,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 543
+module_eval <<'.,.,', 'lib/parser.y', 560
   def _reduce_120( val, _values, result )
     result = val[0]
@@ -2714,5 +2734,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 548
+module_eval <<'.,.,', 'lib/parser.y', 565
   def _reduce_121( val, _values, result )
     @@log.info("string_value: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2722,5 +2742,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 553
+module_eval <<'.,.,', 'lib/parser.y', 570
   def _reduce_122( val, _values, result )
     @@log.info("integer_value: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2730,5 +2750,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 558
+module_eval <<'.,.,', 'lib/parser.y', 575
   def _reduce_123( val, _values, result )
     @@log.info("real_value: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2738,5 +2758,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 563
+module_eval <<'.,.,', 'lib/parser.y', 580
   def _reduce_124( val, _values, result )
     @@log.info("boolean_value: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2746,5 +2766,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 568
+module_eval <<'.,.,', 'lib/parser.y', 585
   def _reduce_125( val, _values, result )
     @@log.info("character_value: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2754,5 +2774,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 573
+module_eval <<'.,.,', 'lib/parser.y', 590
   def _reduce_126( val, _values, result )
     @@log.info("date_value: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2762,5 +2782,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 578
+module_eval <<'.,.,', 'lib/parser.y', 595
   def _reduce_127( val, _values, result )
     @@log.info("time_value: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2770,5 +2790,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 583
+module_eval <<'.,.,', 'lib/parser.y', 600
   def _reduce_128( val, _values, result )
     @@log.info("date_time_value: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2778,5 +2798,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 588
+module_eval <<'.,.,', 'lib/parser.y', 605
   def _reduce_129( val, _values, result )
     @@log.info("duration_value: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2786,5 +2806,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 593
+module_eval <<'.,.,', 'lib/parser.y', 610
   def _reduce_130( val, _values, result )
     @@log.info("uri_value: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2824,5 +2844,5 @@
  # reduce 145 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 616
+module_eval <<'.,.,', 'lib/parser.y', 633
   def _reduce_146( val, _values, result )
     @@log.info("V_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2832,5 +2852,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 621
+module_eval <<'.,.,', 'lib/parser.y', 638
   def _reduce_147( val, _values, result )
     @@log.info("V_GENERIC_TYPE_IDENTIFIER: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2840,5 +2860,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 627
+module_eval <<'.,.,', 'lib/parser.y', 644
   def _reduce_148( val, _values, result )
     @@log.info("V_STRING: #{val[0]} at #{@filename}:#{@lineno}")
@@ -2854,5 +2874,5 @@
  # reduce 151 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 641
+module_eval <<'.,.,', 'lib/parser.y', 658
   def _reduce_152( val, _values, result )
     begin
@@ -2866,5 +2886,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 650
+module_eval <<'.,.,', 'lib/parser.y', 667
   def _reduce_153( val, _values, result )
     begin
@@ -2878,5 +2898,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 659
+module_eval <<'.,.,', 'lib/parser.y', 676
   def _reduce_154( val, _values, result )
     begin
@@ -2914,5 +2934,5 @@
  # reduce 166 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 685
+module_eval <<'.,.,', 'lib/parser.y', 702
   def _reduce_167( val, _values, result )
     begin
@@ -2926,5 +2946,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 694
+module_eval <<'.,.,', 'lib/parser.y', 711
   def _reduce_168( val, _values, result )
     begin
@@ -2938,5 +2958,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 703
+module_eval <<'.,.,', 'lib/parser.y', 720
   def _reduce_169( val, _values, result )
     begin
@@ -2974,5 +2994,5 @@
  # reduce 181 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 723
+module_eval <<'.,.,', 'lib/parser.y', 740
   def _reduce_182( val, _values, result )
     result = true
@@ -2981,5 +3001,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 727
+module_eval <<'.,.,', 'lib/parser.y', 744
   def _reduce_183( val, _values, result )
     result = false
@@ -3080,5 +3100,5 @@
  # reduce 229 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 791
+module_eval <<'.,.,', 'lib/parser.y', 808
   def _reduce_230( val, _values, result )
     @@log.info("V_ISO8601_DURATION: #{val[0]} at #{@filename}:#{@lineno}")
@@ -3112,7 +3132,8 @@
  # reduce 242 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 810
+module_eval <<'.,.,', 'lib/parser.y', 828
   def _reduce_243( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")
+    result = val[0]
    result
   end
@@ -3125,7 +3146,8 @@
  # reduce 246 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 819
+module_eval <<'.,.,', 'lib/parser.y', 838
   def _reduce_247( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")
+    result = val[0]
    result
   end
@@ -3212,5 +3234,5 @@
  # reduce 287 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 888
+module_eval <<'.,.,', 'lib/parser.y', 907
   def _reduce_288( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}")
@@ -3219,5 +3241,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 892
+module_eval <<'.,.,', 'lib/parser.y', 911
   def _reduce_289( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{val[0]} at #{@filename}")
@@ -3226,5 +3248,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 903
+module_eval <<'.,.,', 'lib/parser.y', 922
   def _reduce_290( val, _values, result )
     result = Range.new(1,1)
@@ -3233,5 +3255,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 907
+module_eval <<'.,.,', 'lib/parser.y', 926
   def _reduce_291( val, _values, result )
     result = val[3]
@@ -3240,5 +3262,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 917
+module_eval <<'.,.,', 'lib/parser.y', 936
   def _reduce_292( val, _values, result )
     begin
@@ -3252,5 +3274,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 927
+module_eval <<'.,.,', 'lib/parser.y', 946
   def _reduce_293( val, _values, result )
     begin
@@ -3265,5 +3287,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 932
+module_eval <<'.,.,', 'lib/parser.y', 951
   def _reduce_294( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::CARDINALITY.new
@@ -3294,5 +3316,5 @@
  # reduce 305 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 951
+module_eval <<'.,.,', 'lib/parser.y', 970
   def _reduce_306( val, _values, result )
     result = val[3]
@@ -3393,5 +3415,5 @@
  # reduce 352 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 1021
+module_eval <<'.,.,', 'lib/parser.y', 1040
   def _reduce_353( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true)
@@ -3400,5 +3422,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 1025
+module_eval <<'.,.,', 'lib/parser.y', 1044
   def _reduce_354( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false)
@@ -3407,5 +3429,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 1029
+module_eval <<'.,.,', 'lib/parser.y', 1048
   def _reduce_355( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => true,:false_valid => false)
@@ -3414,5 +3436,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 1033
+module_eval <<'.,.,', 'lib/parser.y', 1052
   def _reduce_356( val, _values, result )
     result = OpenEHR::AM::Archetype::Constraint_Model::Primitive::C_BOOLEAN.new(:true_valid => false,:false_valid => true)
@@ -3421,5 +3443,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 1038
+module_eval <<'.,.,', 'lib/parser.y', 1057
   def _reduce_357( val, _values, result )
     result = val[0]
@@ -3428,5 +3450,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 1042
+module_eval <<'.,.,', 'lib/parser.y', 1061
   def _reduce_358( val, _values, result )
     raise 'Not implemented yet'
@@ -3435,5 +3457,5 @@
 .,.,
 
-module_eval <<'.,.,', 'lib/parser.y', 1046
+module_eval <<'.,.,', 'lib/parser.y', 1065
   def _reduce_359( val, _values, result )
     raise 'Not implemented yet'
@@ -3452,5 +3474,5 @@
  # reduce 364 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 1059
+module_eval <<'.,.,', 'lib/parser.y', 1078
   def _reduce_365( val, _values, result )
     @in_interval = false
@@ -3476,5 +3498,5 @@
  # reduce 373 omitted
 
-module_eval <<'.,.,', 'lib/parser.y', 1081
+module_eval <<'.,.,', 'lib/parser.y', 1100
   def _reduce_374( val, _values, result )
     @@log.info("#{__FILE__}:#{__LINE__}, V_ATTRIBUTE_IDENTIFIER = #{word} at #{@filename}")
@@ -3483,5 +3505,10 @@
 .,.,
 
- # reduce 375 omitted
+module_eval <<'.,.,', 'lib/parser.y', 1110
+  def _reduce_375( val, _values, result )
+    result = val[0]
+   result
+  end
+.,.,
 
  def _reduce_none( val, _values, result )
Index: /ruby/trunk/adl_parser/lib/parser.y
===================================================================
--- /ruby/trunk/adl_parser/lib/parser.y	(revision 25)
+++ /ruby/trunk/adl_parser/lib/parser.y	(revision 26)
@@ -39,9 +39,20 @@
     end
     
-    result = OpenEHR::AM::Archetype::ARCHETYPE.new(
-                                                   :description => val[4],
-                                                   :definition => val[5],
-                                                   :ontology => val[7]
-                                                   )
+    archetype_id = val[0][:archetype_id]
+    adl_version = val[0][:arch_head][:arch_meta_data][:adl_version]
+    concept = val[2]
+    language = val[3][:arch_language]
+    archetype = OpenEHR::AM::Archetype::ARCHETYPE.create(
+                                                         :archetype_id => archetype_id,
+                                                         :adl_version => adl_version,
+                                                         :concept => concept,
+                                                         :description => val[4],
+                                                         :definition => val[5],
+                                                         :ontology => val[7]
+                                                         ) do |archetype|
+      archetype.original_language = language
+    end
+    @@log.info("#{__FILE__}:#{__LINE__}: archetype = #{archetype} at #{@filename}:#{@lineno}")
+    result = archetype
   }
 
@@ -62,19 +73,19 @@
   | SYM_ARCHETYPE arch_meta_data
   { 
+    result = val[1]
+  }
+
+arch_meta_data: Left_parenthesis_code arch_meta_data_items Right_parenthesis_code
+  { 
     result = {:arch_meta_data => val[1] }
   }
 
-arch_meta_data: Left_parenthesis_code arch_meta_data_items Right_parenthesis_code
-  { 
-    result = {:arch_meta_data_items => val[1] }
-  }
-
 arch_meta_data_items: arch_meta_data_item
   { 
-    result = Array[val[0]]
+    result = val[0]
   }
   | arch_meta_data_items Semicolon_code arch_meta_data_item
   { 
-    result = (val[0] << val[2])
+    result = val[0].merge(val[2])
   }
 
@@ -82,9 +93,9 @@
 arch_meta_data_item: SYM_ADL_VERSION SYM_EQ V_VERSION_STRING
   { 
-    result = {:adl_version => val[2] }
+    result = {:adl_version => val[2], :is_controlled => false }
   }
   | SYM_IS_CONTROLLED
   { 
-    result = val[0]
+    result = {:is_controlled => true }
   }
 
@@ -96,4 +107,7 @@
 
 arch_concept: SYM_CONCEPT V_LOCAL_TERM_CODE_REF
+  { 
+    result = {:arch_concept => val[1] }
+  }
   | SYM_CONCEPT error
 
@@ -103,7 +117,10 @@
 
 arch_language: #-- empty is ok for ADL 1.4 tools
+  {
+    result = {:arch_language => nil}
+  }
     | SYM_LANGUAGE dadl_section
   {
-    result = {:language => val[1]}
+    result = {:arch_language => val[1]}
   }
   | SYM_LANGUAGE error
@@ -389,5 +406,5 @@
 arch_ontology: SYM_ONTOLOGY dadl_section
   { 
-    dadl_sections = val[1]
+    dadl_section = val[1]
     result = OpenEHR::AM::Archetype::Ontology::ARCHETYPE_ONTOLOGY.new
   }
@@ -808,4 +825,5 @@
   {
     @@log.info("#{__FILE__}:#{__LINE__}: V_QUALIFIED_TERM_CODE_REF = #{val[0]} at #{@filename}:#{@lineno}")
+    result = val[0]
   }
 
@@ -817,4 +835,5 @@
   {
     @@log.info("#{__FILE__}:#{__LINE__}: V_URI = #{val[0]} at #{@filename}:#{@lineno}")
+    result = val[0]
   }
 
@@ -1087,4 +1106,7 @@
 
 duration_pattern: V_ISO8601_DURATION_CONSTRAINT_PATTERN
+  { 
+    result = val[0]
+  }
 
 
@@ -1096,5 +1118,4 @@
 require 'lib/util.rb'
 require 'lib/scanner.rb'
-#require 'lib/model.rb'
 require 'rubygems'
 require 'am.rb'
Index: /ruby/trunk/adl_parser/lib/scanner.rb
===================================================================
--- /ruby/trunk/adl_parser/lib/scanner.rb	(revision 25)
+++ /ruby/trunk/adl_parser/lib/scanner.rb	(revision 26)
@@ -115,7 +115,5 @@
               Yaparc::Apply.new(
                                 Yaparc::Alt.new(Yaparc::Regex.new(/\AP([0-9]+|[yY])?([0-9]+|[mM])?([0-9]+|[wW])?([0-9]+|[dD])?T([0-9]+|[hH])?([0-9]+|[mM])?([0-9]+|[sS])?/),
-                                                Yaparc::Regex.new(/AP([0-9]+|[yY])?([0-9]+|[mM])?([0-9]+|[wW])?([0-9]+|[dD])?/))) do |match|
-#                                 Yaparc::Alt.new(Yaparc::Regex.new(/\AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?T([0-9]+[hH])?([0-9]+[mM])?([0-9]+[sS])?/),
-#                                                 Yaparc::Regex.new(/AP([0-9]+[yY])?([0-9]+[mM])?([0-9]+[wW])?([0-9]+[dD])?/))) do |match|
+                                                Yaparc::Regex.new(/\AP([0-9]+|[yY])?([0-9]+|[mM])?([0-9]+|[wW])?([0-9]+|[dD])?/))) do |match|
                 LOG.info("V_ISO8601_DURATION: #{match}")
                 [:V_ISO8601_DURATION, match]
@@ -250,4 +248,18 @@
         end
 
+        #V_ISO8601_DURATION_CONSTRAINT_PATTERN 
+        class V_ISO8601_DURATION_CONSTRAINT_PATTERN
+          include Yaparc::Parsable
+          def initialize
+            @parser = lambda do |input|
+              Yaparc::Apply.new(Yaparc::Alt.new(Yaparc::Regex.new(/\AP[yY]?[mM]?[wW]?[dD]?T[hH]?[mM]?[sS]?/),
+                                                Yaparc::Regex.new(/\AP[yY]?[mM]?[wW]?[dD]?/))) do |match|
+                OpenEHR::ADL::Scanner::Common::LOG.info("V_ISO8601_DURATION_CONSTRAINT_PATTERN: #{match}")
+                [:V_ISO8601_DURATION_CONSTRAINT_PATTERN, match]
+              end
+            end
+          end
+        end
+
         #V_C_DOMAIN_TYPE /\A[A-Z][a-zA-Z0-9_]*[ \n]*\</
         class V_C_DOMAIN_TYPE
@@ -272,4 +284,5 @@
                               OpenEHR::ADL::Scanner::Common::V_ISO8601_DURATION.new,
                               V_C_DOMAIN_TYPE.new,
+                              V_ISO8601_DURATION_CONSTRAINT_PATTERN.new,
                               Reserved.new,
                               OpenEHR::ADL::Scanner::Common::V_QUALIFIED_TERM_CODE_REF.new,
Index: by/trunk/adl_parser/tests/cparser_test.rb
===================================================================
--- /ruby/trunk/adl_parser/tests/cparser_test.rb	(revision 25)
+++ 	(revision )
@@ -1,22 +1,0 @@
-#$:.unshift File.join(File.dirname(__FILE__))
-
-require 'lib/cparser.rb'
-require 'test/unit'
-
-class CADLParserTest < Test::Unit::TestCase
-  def setup
-    @parser = ::OpenEHR::CADLParser.new
-  end
-
-  def test_init
-    assert_instance_of ::OpenEHR::CADLParser,@parser
-  end
-
-  def test_parse
-    vital_signs = File.read('tests/vital_signs.cadl')
-    assert_nothing_raised do
-      @parser.parse(vital_signs, 'vital_signs')
-    end
-  end
-
-end
Index: /ruby/trunk/models/am/archetype/archetype.rb
===================================================================
--- /ruby/trunk/models/am/archetype/archetype.rb	(revision 25)
+++ /ruby/trunk/models/am/archetype/archetype.rb	(revision 26)
@@ -14,5 +14,5 @@
         attr_accessor :archetype_id, :concept_code, :is_controlled, :original_language, :parent_archtype_id, :uid
 
-        attr_reader :id, :parent_id,:concept, :definition, :ontology
+        attr_reader :parent_id,:concept, :definition, :ontology
         attr_accessor :adl_version,:description,:original_language
         attr_accessor :revision_history, :translation
@@ -20,13 +20,9 @@
         def initialize(args = {})
           @adl_version = args[:adl_version] if args[:adl_version]
-          @id = args[:id] ? args[:id] : nil
+          @archetype_id = args[:archetype_id] ? args[:archetype_id] : nil
           @parent_id = args[:parent_id] if args[:parent_id]
           @concept = args[:concept] if args[:concept]
-#          @original_language = args[:original_language] ? args[:original_language] : nil
-#          @translation = args[:translation] ? args[:translation] : nil
-#          @description = args[:description] if args[:description]
-#          @revision_history = args[:revision_history] if args[:revision_history]
           @is_controled = args[:is_controled] if args[:is_controled]
-          @definition = args[:definition] if args[:definition] 
+          @definition = args[:definition] if args[:definition]
           @ontology = args[:ontology] if args[:ontology]
  #         loadMaps(definition)
Index: /ruby/trunk/models/am/archetype/constraint_model/primitive.rb
===================================================================
--- /ruby/trunk/models/am/archetype/constraint_model/primitive.rb	(revision 25)
+++ /ruby/trunk/models/am/archetype/constraint_model/primitive.rb	(revision 26)
@@ -87,5 +87,5 @@
 
           class C_DURATION < C_PRIMITIVE
-            
+            attr_accessor :years_allowed, :months_allowed, :weeks_allowed, :days_allowed, :hours_allowed, :minutes_allowed, :seconds_allowed, :fractional_seconds_allowed, :range, :assumed_value
           end
 
Index: /ruby/trunk/models/rm.rb
===================================================================
--- /ruby/trunk/models/rm.rb	(revision 25)
+++ /ruby/trunk/models/rm.rb	(revision 26)
@@ -13,13 +13,21 @@
   module RM
     autoload :Demographic, "rm/demographic.rb"
+
     module Common
       autoload :Resource, "rm/common/resource.rb"
     end
+
     module Support
       autoload :Definition, "rm/support/definition.rb"
+
+      module Identification
+        autoload :OBJECT_ID, "rm/support/identification.rb"
+      end
+
       module Terminology
         autoload :Terminology, "rm/support/terminology.rb"
       end
     end
+
     module Data_Types
       autoload :Basic, "rm/data_types/basic.rb"
Index: /ruby/trunk/models/rm/support/identification.rb
===================================================================
--- /ruby/trunk/models/rm/support/identification.rb	(revision 25)
+++ /ruby/trunk/models/rm/support/identification.rb	(revision 26)
@@ -2,36 +2,46 @@
   module RM
     module Support
-      module Definition
-        class Object_ID
+      module Identification
+
+        class OBJECT_ID
           attr_accessor :value
+
           def initiallize(value)
-            if value == nil
-              raise Exception.new("empty value")
-            end
+            raise "empty value" unless value
             @value = value
           end
         end # of ObjectID
-        class Terminology_ID < Object_ID
+
+        class ARCHETYPE_ID < OBJECT_ID
+        end
+
+        class TERMINOLOGY_ID < OBJECT_ID
           attr_reader :name
-          def initialize(arg0, arg1=nil)
-            if arg1 == nil
-              super(arg0)
-            else
-              super(toValue(arg0, arg1))
-              @name = arg0
-              @version = arg1      
-            end
+
+          def initialize(name , version_id)
+            @name , @version_id = name , version_id
+#             if arg1 == nil
+#               super(arg0)
+#             else
+#               super(toValue(arg0, arg1))
+#               @name = arg0
+#               @version = arg1      
+#             end
           end
+
           def setValue(value)
             loadValue(value)
             super.value = value
           end
+
           def version_id
             @version
           end
+
           private
+
           def loadValue(value)
             if /\(.*\)$/ =~ value
-              @name, @version = value.split(\())
+#              @name, @version = value.split(\())
               @version.chop!
             else
@@ -40,4 +50,5 @@
             end
           end
+
           def toValue(name, version)
             if name == ""
Index: /ruby/trunk/models/tests/test_reference_model.rb
===================================================================
--- /ruby/trunk/models/tests/test_reference_model.rb	(revision 25)
+++ /ruby/trunk/models/tests/test_reference_model.rb	(revision 26)
@@ -31,4 +31,5 @@
     assert_instance_of OpenEHR::RM::Data_Types::Text::DV_Coded_Text, @dv_coded_text
   end
+
   def test_constant
     assert_equal("\r", OpenEHR::RM::Support::Definition::OpenEHR_Definitions::CR)
@@ -37,4 +38,5 @@
     assert_equal("\n", OpenEHR::RM::Data_Types::Basic::Data_Value::LF)
   end
+
   def test_dv_boolean
     assert @dv_boolean.value?
@@ -45,4 +47,5 @@
     assert_raise(ArgumentError){OpenEHR::RM::Data_Types::Basic::DV_Boolean.new(nil)}
   end
+
   def test_dv_state
     assert_equal("code1", @dv_state.value)
@@ -54,4 +57,5 @@
     assert_raise(ArgumentError) {OpenEHR::RM::Data_Types::Basic::DV_State.new(nil,nil)}
   end
+
   def test_dv_identifier
     assert_equal("Ruby Hospital", @dv_identifier.assigner)
@@ -69,4 +73,5 @@
     assert_raise(ArgumentError) {OpenEHR::RM::Data_Types::Basic::DV_Identifier.new(nil, nil, nil, nil)}
   end
+
   def test_dv_uri
     assert_equal("file0", @dv_uri.fragment_id)
@@ -79,4 +84,5 @@
     assert_equal("/openehr-jp/", @dv_uri.path)
   end
+
   def test_dv_ehr_uri
     assert_equal("ehr", @dv_ehr_uri.scheme)
@@ -84,36 +90,29 @@
       @dv_ehr_uri.value="svn://www.openehr.jp/openehr-jp/" }
   end
+
   def test_dv_text
     assert_equal("valid value", @dv_text.value)
-    assert_raise(ArgumentError){
-      @dv_text.value = "not valid value\n"}
-    assert_raise(ArgumentError){
-      @dv_text.value = nil }
-    assert_raise(ArgumentError){
-      @dv_text.value = "" }
-    assert_raise(ArgumentError){
-      @dv_text.formatting = "" }
-    assert_raise(ArgumentError){
-      @dv_text.encoding = ""}
-    assert_raise(ArgumentError){
-      @dv_text.language = ""}
-    assert_raise(ArgumentError){
-      @dv_text.mappings = Set.new}
-    assert_raise(ArgumentError){
-      @dv_text.mappings = ""}
-    assert_raise(ArgumentError){
-      @dv_text.language = ""}
+    assert_raise(ArgumentError){@dv_text.value = "not valid value\n"}
+    assert_raise(ArgumentError){@dv_text.value = nil }
+    assert_raise(ArgumentError){@dv_text.value = "" }
+    assert_raise(ArgumentError){@dv_text.formatting = "" }
+    assert_raise(ArgumentError){@dv_text.encoding = ""}
+    assert_raise(ArgumentError){@dv_text.language = ""}
+    assert_raise(ArgumentError){@dv_text.mappings = Set.new}
+    assert_raise(ArgumentError){@dv_text.mappings = ""}
+    assert_raise(ArgumentError){@dv_text.language = ""}
   end
+
   def test_dv_coded_text
     assert_equal("valid value", @dv_coded_text.value)
     assert_equal("AT1000", @dv_coded_text.defining_code)
-    assert_raise(ArgumentError){
-      @dv_coded_text.defining_code=nil}
+    assert_raise(ArgumentError){@dv_coded_text.defining_code=nil}
   end
+
   def test_dv_paragraph
     assert_equal((Set.new ["test1", "test2"]), @dv_paragraph.items)
-    assert_raise(ArgumentError){
-      @dv_paragraph.items=Set.new}
+    assert_raise(ArgumentError){@dv_paragraph.items=Set.new}
   end
+
   def test_terminology_mapping
     
@@ -121,2 +120,17 @@
 end
 
+
+class ReferenceModelSupportIdentificationTest < Test::Unit::TestCase
+  def setup
+    @object_id = OpenEHR::RM::Support::Identification::OBJECT_ID.new
+    @terminology_id = OpenEHR::RM::Support::Identification::TERMINOLOGY_ID.new('terminology','version')
+    @archetype_id = OpenEHR::RM::Support::Identification::ARCHETYPE_ID.new
+  end
+  
+  def test_init
+    assert_instance_of OpenEHR::RM::Support::Identification::OBJECT_ID, @object_id
+    assert_instance_of OpenEHR::RM::Support::Identification::TERMINOLOGY_ID, @terminology_id
+    assert_instance_of OpenEHR::RM::Support::Identification::ARCHETYPE_ID, @archetype_id
+
+  end
+end
