open_ehr 0.9.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/History.txt +3 -0
  2. data/README.rdoc +35 -25
  3. data/VERSION +1 -1
  4. data/lib/open_ehr.rb +2 -3
  5. data/lib/open_ehr/am.rb +1 -2
  6. data/lib/open_ehr/am/openehr_profile.rb +0 -1
  7. data/lib/open_ehr/am/openehr_profile/data_types.rb +2 -1
  8. data/lib/open_ehr/am/openehr_profile/data_types/basic.rb +88 -1
  9. data/lib/open_ehr/am/openehr_profile/data_types/quantity.rb +51 -2
  10. data/lib/open_ehr/am/openehr_profile/data_types/text.rb +2 -2
  11. data/lib/open_ehr/assumed_library_types.rb +5 -0
  12. data/lib/open_ehr/parser/adl.rb +5 -5
  13. data/lib/open_ehr/parser/adl_grammar.tt +13 -16
  14. data/lib/open_ehr/parser/adl_parser.rb +13 -5
  15. data/lib/open_ehr/parser/cadl_grammar.tt +247 -31
  16. data/lib/open_ehr/parser/cadl_node.rb +25 -0
  17. data/lib/open_ehr/parser/dadl_grammar.tt +6 -6
  18. data/lib/open_ehr/parser/shared_token_grammar.tt +14 -5
  19. data/lib/open_ehr/rm.rb +1 -2
  20. data/lib/open_ehr/rm/composition/content/entry.rb +8 -1
  21. data/lib/open_ehr/rm/data_types.rb +2 -2
  22. data/lib/open_ehr/rm/data_types/quantity.rb +1 -2
  23. data/lib/open_ehr/rm/data_types/quantity/date_time.rb +8 -5
  24. data/lib/open_ehr/rm/data_types/text.rb +7 -6
  25. data/lib/open_ehr/rm/support/identification.rb +13 -9
  26. data/open_ehr.gemspec +34 -4
  27. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/c_dv_state_spec.rb +34 -0
  28. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/non_terminal_state_spec.rb +36 -0
  29. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/state_machine_spec.rb +34 -0
  30. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/state_spec.rb +26 -0
  31. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/terminal_state_spec.rb +18 -0
  32. data/spec/lib/open_ehr/am/openehr_profile/data_types/basic/transition_spec.rb +62 -0
  33. data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_dv_ordinal_spec.rb +41 -0
  34. data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_dv_quantity_spec.rb +50 -0
  35. data/spec/lib/open_ehr/am/openehr_profile/data_types/quantity/c_quantity_item_spec.rb +46 -0
  36. data/spec/lib/open_ehr/am/openehr_profile/data_types/text/c_code_phrase_spec.rb +0 -1
  37. data/spec/lib/open_ehr/assumed_library_types/interval_spec.rb +5 -0
  38. data/spec/lib/open_ehr/parser/adl14/adl-test-composition.dv_coded_text.test.adl +1 -1
  39. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.archetype_desc_missing_purpose.test.adl +1 -1
  40. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_ordinal.test.adl +1 -1
  41. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_empty.test.adl +1 -1
  42. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full.test.adl +1 -1
  43. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full2.test.adl +1 -1
  44. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_full3.test.adl +1 -1
  45. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_item_units_only.test.adl +1 -1
  46. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_list.test.adl +1 -1
  47. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_property.test.adl +1 -1
  48. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.c_dv_quantity_reversed.test.adl +1 -1
  49. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.constraint_binding.test.adl +1 -1
  50. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.constraint_ref.test.adl +1 -1
  51. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.empty_other_contributors.test.adl +1 -1
  52. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.missing_language.test.adl +1 -1
  53. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.mixed_node_types.draft.adl +1 -1
  54. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.most_minimal.test.adl +1 -1
  55. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.multi_language.test.adl +1 -1
  56. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.special_string.test.adl +1 -1
  57. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.structure_test1.test.adl +1 -1
  58. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.structure_test2.test.adl +1 -1
  59. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.term_binding.test.adl +1 -1
  60. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.term_binding2.test.adl +1 -1
  61. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.unicode_BOM_support.test.adl +1 -1
  62. data/spec/lib/open_ehr/parser/adl14/adl-test-entry.unicode_support.test.adl +1 -1
  63. data/spec/lib/open_ehr/parser/adl_archetype_ontology_binding_spec.rb +3 -3
  64. data/spec/lib/open_ehr/parser/c_dv_quantity_any_allowed_spec.rb +34 -0
  65. data/spec/lib/open_ehr/parser/c_dv_quantity_shared_example_for_lacked_items_spec.rb +36 -0
  66. data/spec/lib/open_ehr/parser/c_dv_quantity_shared_example_spec.rb +146 -0
  67. data/spec/lib/open_ehr/parser/cdv_ordinal_parse_spec.rb +231 -0
  68. data/spec/lib/open_ehr/parser/code_phrase_spec.rb +7 -2
  69. data/spec/lib/open_ehr/parser/constraint_binding_spec.rb +26 -0
  70. data/spec/lib/open_ehr/parser/constraint_ref_spec.rb +32 -0
  71. data/spec/lib/open_ehr/parser/dv_coded_text_parse_spec.rb +27 -0
  72. data/spec/lib/open_ehr/parser/empty_other_contributors_spec.rb +19 -0
  73. data/spec/lib/open_ehr/parser/missing_language_spec.rb +20 -0
  74. data/spec/lib/open_ehr/parser/missing_purpose_spec.rb +23 -0
  75. data/spec/lib/open_ehr/parser/mixed_node_types_spec.rb +16 -0
  76. data/spec/lib/open_ehr/parser/most_minimal_adl_spec.rb +19 -0
  77. data/spec/lib/open_ehr/parser/multi_language_spec.rb +58 -0
  78. data/spec/lib/open_ehr/parser/path_based_terminology_binding_spec.rb +30 -0
  79. data/spec/lib/open_ehr/parser/special_string_spec.rb +20 -0
  80. data/spec/lib/open_ehr/parser/structure_comment_spec.rb +21 -0
  81. data/spec/lib/open_ehr/parser/structure_nested_comments_spec.rb +22 -0
  82. data/spec/lib/open_ehr/parser/structure_spec.rb +202 -0
  83. data/spec/lib/open_ehr/parser/term_binding_spec.rb +54 -0
  84. data/spec/lib/open_ehr/parser/unicode_bom_spec.rb +17 -0
  85. data/spec/lib/open_ehr/parser/unicode_support_spec.rb +46 -0
  86. data/spec/lib/open_ehr/rm/common/change_control/imported_version_spec.rb +0 -1
  87. data/spec/lib/open_ehr/rm/common/change_control/original_version_spec.rb +2 -2
  88. data/spec/lib/open_ehr/rm/common/change_control/version_spec.rb +0 -1
  89. data/spec/lib/open_ehr/rm/common/change_control/versioned_object_spec.rb +0 -1
  90. data/spec/lib/open_ehr/rm/common/generic/revision_history_item_spec.rb +3 -3
  91. data/spec/lib/open_ehr/rm/composition/content/entry/entry_spec.rb +12 -2
  92. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb +1 -0
  93. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/{dv_tempral_spec.rb → dv_temporal_spec.rb} +1 -0
  94. data/spec/lib/open_ehr/rm/data_types/text/dv_text_spec.rb +25 -3
  95. data/spec/lib/open_ehr/rm/demographic/party_spec.rb +1 -3
  96. data/spec/lib/open_ehr/rm/support/identification/access_group_ref_spec.rb +2 -2
  97. data/spec/lib/open_ehr/rm/support/identification/object_version_id_spec.rb +3 -4
  98. metadata +69 -39
@@ -53,8 +53,9 @@ module OpenEHR
53
53
  rule c_complex_object_head
54
54
  c_complex_object_id c_occurrences {
55
55
  def value
56
- c_complex_object_id.value[:occurrences] = c_occurrences.value
57
- c_complex_object_id.value
56
+ args = c_complex_object_id.value
57
+ args[:occurrences] = c_occurrences.value
58
+ args
58
59
  end
59
60
  }
60
61
  / c_complex_object_id '' {
@@ -92,24 +93,40 @@ module OpenEHR
92
93
  end
93
94
 
94
95
  rule c_object
95
- c_primitive_object '' {
96
+ c_dv_quantity '' {
97
+ def value(node)
98
+ c_dv_quantity.value(node)
99
+ end
100
+ }
101
+ / c_ordinal '' {
102
+ def value(node)
103
+ args = c_ordinal.value
104
+ args[:path] = node.path
105
+ args[:rm_type_name] = 'DvOrdinal'
106
+ args[:occurrences] ||= OpenEHR::AssumedLibraryTypes::Interval.new(
107
+ :upper => 1, :lower => 1)
108
+ OpenEHR::AM::OpenEHRProfile::DataTypes::Quantity::CDvOrdinal.new(
109
+ args)
110
+ end
111
+ }
112
+ / c_primitive_object '' {
96
113
  def value(node)
97
114
  c_primitive_object.value
98
115
  end
99
116
  }
100
- / c_complex_object '' {
117
+ / c_complex_object '' {
101
118
  def value(node)
102
119
  c_complex_object.value(node)
103
120
  end
104
121
  }
105
- / vtc:V_TERM_CODE_CONSTRAINT '' {
122
+ / c_code_phrase '' {
106
123
  def value(node)
107
- vtc.value(node)
124
+ c_code_phrase.value(node)
108
125
  end
109
126
  }
110
127
  / constraint_ref '' {
111
- def value(node = nil)
112
- constraint_ref.value
128
+ def value(node)
129
+ constraint_ref.value(node)
113
130
  end
114
131
  }
115
132
  / archetype_slot '' {
@@ -187,7 +204,10 @@ module OpenEHR
187
204
  }
188
205
  / c_archetype_slot_id white_space {
189
206
  def value(node)
190
- c_archetype_slot_id.value
207
+ args = c_archetype_slot_id.value(node)
208
+ args[:occurrences] = OpenEHR::AssumedLibraryTypes::Interval.new(
209
+ :upper => 1, :lower => 1)
210
+ args
191
211
  end
192
212
  }
193
213
  end
@@ -217,9 +237,9 @@ module OpenEHR
217
237
  end
218
238
 
219
239
  rule c_primitive
220
- c_duration '' {
240
+ c_boolean '' {
221
241
  def value
222
- c_duration.value
242
+ c_boolean.value
223
243
  end
224
244
  }
225
245
  / c_date_time '' {
@@ -237,6 +257,11 @@ module OpenEHR
237
257
  c_date.value
238
258
  end
239
259
  }
260
+ / c_duration '' {
261
+ def value
262
+ c_duration.value
263
+ end
264
+ }
240
265
  / c_real '' {
241
266
  def value
242
267
  c_real.value
@@ -247,11 +272,6 @@ module OpenEHR
247
272
  c_integer.value
248
273
  end
249
274
  }
250
- / c_boolean '' {
251
- def value
252
- c_boolean.value
253
- end
254
- }
255
275
  / c_string '' {
256
276
  def value
257
277
  c_string.value
@@ -408,12 +428,12 @@ module OpenEHR
408
428
  rule existence_spec
409
429
  lo:V_INTEGER SYM_ELLIPSIS up:V_INTEGER {
410
430
  def value
411
- OpenEHR::AssumedTypesLibrary::Interval.new(:lower => lo.value, :upper => up.value)
431
+ OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value, :upper => up.value)
412
432
  end
413
433
  }
414
434
  / V_INTEGER '' {
415
435
  def value
416
- OpenEHR::AssumedTypesLibrary::Interval.new(:lower => V_INTEGER.value, :upper => V_INTEGER.value)
436
+ OpenEHR::AssumedLibraryTypes::Interval.new(:lower => V_INTEGER.value, :upper => V_INTEGER.value)
417
437
  end
418
438
  }
419
439
  end
@@ -500,11 +520,10 @@ module OpenEHR
500
520
  st:integer_value SYM_ELLIPSIS ed:cardinality_limit_value {
501
521
  def value
502
522
  if ed.value == '*'
503
- interval = OpenEHR::AssumedLibraryTypes::Interval.new(
504
- :lower => st.value,
505
- :upper_unbounded => true)
523
+ OpenEHR::AssumedLibraryTypes::Interval.new(
524
+ :lower => st.value)
506
525
  else
507
- interval = OpenEHR::AssumedLibraryTypes::Interval.new(
526
+ OpenEHR::AssumedLibraryTypes::Interval.new(
508
527
  :lower => st.value,
509
528
  :upper => ed.value)
510
529
  end
@@ -726,7 +745,7 @@ module OpenEHR
726
745
  {:pattern => duration_pattern.value}
727
746
  end
728
747
  }
729
- / duration_pattern '' {
748
+ / duration_pattern '' {
730
749
  def value
731
750
  {:pattern => duration_pattern.value}
732
751
  end
@@ -760,7 +779,7 @@ module OpenEHR
760
779
  args)
761
780
  end
762
781
  }
763
- / c_duration_constraint !';' '' {
782
+ / c_duration_constraint '' {
764
783
  def value
765
784
  OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDuration.new(
766
785
  c_duration_constraint.value)
@@ -849,9 +868,13 @@ module OpenEHR
849
868
  end
850
869
 
851
870
  rule constraint_ref
852
- V_LOCAL_TERM_CODE_REF '' {
853
- def value
854
- V_LOCAL_TERM_CODE_REF.value
871
+ vltcr:V_LOCAL_TERM_CODE_REF '' {
872
+ def value(node)
873
+ OpenEHR::AM::Archetype::ConstraintModel::ConstraintRef.new(
874
+ :path => node.path,
875
+ :rm_type_name => 'ConstraintRef',
876
+ :occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(:upper => 1, :lower => 1),
877
+ :reference => vltcr.value)
855
878
  end
856
879
  }
857
880
  end
@@ -897,7 +920,7 @@ module OpenEHR
897
920
  }
898
921
  end
899
922
 
900
- rule V_TERM_CODE_CONSTRAINT
923
+ rule c_code_phrase
901
924
  ti:V_TERM_CODE code_string_spec ';' space code_string ']' space {
902
925
  def value(node)
903
926
  ::OpenEHR::AM::OpenEHRProfile::DataTypes::Text::CCodePhrase.new(
@@ -930,6 +953,199 @@ module OpenEHR
930
953
  }
931
954
  end
932
955
 
956
+ rule SYM_C_DV_ORDINAL
957
+ 'C_DV_ORDINAL' space
958
+ end
959
+
960
+ rule c_ordinal
961
+ c_ordinal_spec ';' space integer_value space {
962
+ def value
963
+ args = c_ordinal_spec.value
964
+ args[:assumed_value] = integer_value.value
965
+ args
966
+ end
967
+ }
968
+ / c_ordinal_spec space '' {
969
+ def value
970
+ c_ordinal_spec.value
971
+ end
972
+ }
973
+ / SYM_C_DV_ORDINAL SYM_LT white_space SYM_GT space {
974
+ def value
975
+ {:list => nil}
976
+ end
977
+ }
978
+ end
979
+
980
+ rule c_ordinal_spec
981
+ ordinal_list '' {
982
+ def value
983
+ {:list => ordinal_list.value}
984
+ end
985
+ }
986
+ / ordinal '' {
987
+ def value
988
+ {:list => [ordinal.value]}
989
+ end
990
+ }
991
+ end
992
+
993
+ rule ordinal_list
994
+ first:ordinal more:(',' space ordinal)+ {
995
+ def value
996
+ ordinals.map {|o| o.value}
997
+ end
998
+
999
+ def ordinals
1000
+ [first] + more.elements.map {|e| e.ordinal}
1001
+ end
1002
+ }
1003
+ end
1004
+
1005
+ rule ordinal
1006
+ integer_value SYM_INTERVAL_DELIM vqtc:V_QUALIFIED_TERM_CODE_REF !SYM_INTERVAL_DELIM '' {
1007
+ def value
1008
+ symbol = ::OpenEHR::RM::DataTypes::Text::DvCodedText.new(
1009
+ :value => vqtc.text_value, :defining_code => vqtc.value)
1010
+ ::OpenEHR::RM::DataTypes::Quantity::DvOrdinal.new(
1011
+ :value => integer_value.value,
1012
+ :symbol => symbol)
1013
+ end
1014
+ }
1015
+ end
1016
+
1017
+ rule c_dv_quantity
1018
+ SYM_C_DV_QUANTITY SYM_START_DBLOCK
1019
+ prop:property? ql:quantity_list? aqv:assumed_quantity_value?
1020
+ SYM_END_DBLOCK <CDvQuantityItems>
1021
+ / SYM_C_DV_QUANTITY SYM_START_DBLOCK
1022
+ prop:property? aqv:assumed_quantity_value? ql:quantity_list?
1023
+ SYM_END_DBLOCK <CDvQuantityItems>
1024
+ / SYM_C_DV_QUANTITY SYM_START_DBLOCK
1025
+ aqv:assumed_quantity_value? prop:property? ql:quantity_list?
1026
+ SYM_END_DBLOCK <CDvQuantityItems>
1027
+ / SYM_C_DV_QUANTITY SYM_START_DBLOCK
1028
+ aqv:assumed_quantity_value? ql:quantity_list? prop:property?
1029
+ SYM_END_DBLOCK <CDvQuantityItems>
1030
+ / SYM_C_DV_QUANTITY SYM_START_DBLOCK
1031
+ ql:quantity_list? aqv:assumed_quantity_value? prop:property?
1032
+ SYM_END_DBLOCK <CDvQuantityItems>
1033
+ / SYM_C_DV_QUANTITY SYM_START_DBLOCK
1034
+ ql:quantity_list? prop:property? aqv:assumed_quantity_value?
1035
+ SYM_END_DBLOCK <CDvQuantityItems>
1036
+ end
1037
+
1038
+ rule SYM_C_DV_QUANTITY
1039
+ 'C_DV_QUANTITY' space
1040
+ end
1041
+
1042
+ rule property
1043
+ SYM_PROPERTY SYM_EQ SYM_START_DBLOCK
1044
+ prop:V_QUALIFIED_TERM_CODE_REF SYM_END_DBLOCK {
1045
+ def value
1046
+ prop.value
1047
+ end
1048
+ }
1049
+ end
1050
+
1051
+ rule SYM_PROPERTY
1052
+ 'property' space
1053
+ end
1054
+
1055
+ rule quantity_list
1056
+ SYM_QUANTITY_LIST SYM_EQ SYM_START_DBLOCK
1057
+ c_quantity_items SYM_END_DBLOCK {
1058
+ def value(node)
1059
+ c_quantity_items.value(node)
1060
+ end
1061
+ }
1062
+ end
1063
+
1064
+ rule assumed_quantity_value
1065
+ SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
1066
+ SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
1067
+ mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
1068
+ prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
1069
+ SYM_END_DBLOCK <AssumedValueItems>
1070
+ / SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
1071
+ SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
1072
+ prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
1073
+ mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
1074
+ SYM_END_DBLOCK <AssumedValueItems>
1075
+ / SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
1076
+ prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
1077
+ SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
1078
+ mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
1079
+ SYM_END_DBLOCK <AssumedValueItems>
1080
+ / SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
1081
+ prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
1082
+ mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
1083
+ SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
1084
+ SYM_END_DBLOCK <AssumedValueItems>
1085
+ / SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
1086
+ mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
1087
+ prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
1088
+ SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
1089
+ SYM_END_DBLOCK <AssumedValueItems>
1090
+ / SYM_ASSUMED_VALUE SYM_EQ SYM_START_DBLOCK
1091
+ mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK val:real_value SYM_END_DBLOCK)?
1092
+ SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
1093
+ prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK val:integer_value SYM_END_DBLOCK)?
1094
+ SYM_END_DBLOCK <AssumedValueItems>
1095
+ end
1096
+
1097
+ rule SYM_QUANTITY_LIST
1098
+ 'list' space
1099
+ end
1100
+
1101
+ rule c_quantity_items
1102
+ c_quantity_item more_cdv:(c_quantity_item white_space)* {
1103
+ def value(node)
1104
+ quantities.map {|q| q.value(node)}
1105
+ end
1106
+
1107
+ def quantities
1108
+ [c_quantity_item] + more_cdv.elements.map {|e| e.c_quantity_item}
1109
+ end
1110
+ }
1111
+ end
1112
+
1113
+ rule c_quantity_item
1114
+ '[' V_STRING ']' white_space SYM_EQ SYM_START_DBLOCK
1115
+ SYM_UNITS SYM_EQ SYM_START_DBLOCK units:V_STRING SYM_END_DBLOCK
1116
+ mag:(SYM_MAGNITUDE SYM_EQ SYM_START_DBLOCK int:real_interval_value SYM_END_DBLOCK)?
1117
+ prec:(SYM_PRECISION SYM_EQ SYM_START_DBLOCK int:integer_interval_value SYM_END_DBLOCK)?
1118
+ SYM_END_DBLOCK {
1119
+ def value(node)
1120
+ magnitude, precision = nil
1121
+ magnitude = mag.int.value unless mag.empty?
1122
+ precision = prec.int.value unless prec.empty?
1123
+ OpenEHR::AM::OpenEHRProfile::DataTypes::Quantity::CQuantityItem.new(
1124
+ :path => node.path, :rm_type_name => 'DvQuantity',
1125
+ :occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
1126
+ :upper => 1, :lower => 1),
1127
+ :units => units.value,
1128
+ :magnitude => magnitude, :precision => precision)
1129
+ end
1130
+ }
1131
+ end
1132
+
1133
+ rule SYM_UNITS
1134
+ 'units' space
1135
+ end
1136
+
1137
+ rule SYM_MAGNITUDE
1138
+ 'magnitude' space
1139
+ end
1140
+
1141
+ rule SYM_PRECISION
1142
+ 'precision' space
1143
+ end
1144
+
1145
+ rule SYM_ASSUMED_VALUE
1146
+ 'assumed_value' space
1147
+ end
1148
+
933
1149
  rule V_C_DOMAIN_TYPE
934
1150
  '('? [A-Z] IDCHAR* ')'? [ \n]* '<' [^>]* '>'
935
1151
  end
@@ -1018,7 +1234,7 @@ module OpenEHR
1018
1234
  :reference_type => 'Constraint')
1019
1235
  end
1020
1236
  }
1021
- / SYM_NOT boolean_leaf {
1237
+ / SYM_NOT boolean_leaf '' {
1022
1238
  def value
1023
1239
  OpenEHR::AM::Archetype::Assertion::ExprUnaryOperator.new(
1024
1240
  :type => 'Boolean',
@@ -1135,7 +1351,7 @@ module OpenEHR
1135
1351
  boolean_expression.value
1136
1352
  end
1137
1353
  }
1138
- / SYM_TRUE {
1354
+ / SYM_TRUE '' {
1139
1355
  def value
1140
1356
  OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
1141
1357
  :type => 'Boolean',
@@ -1143,7 +1359,7 @@ module OpenEHR
1143
1359
  :reference_type => 'CONSTANT')
1144
1360
  end
1145
1361
  }
1146
- / SYM_FALSE {
1362
+ / SYM_FALSE '' {
1147
1363
  def value
1148
1364
  OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
1149
1365
  :type => 'Boolean',
@@ -14,6 +14,31 @@ module OpenEHR
14
14
  return parent.nil?
15
15
  end
16
16
  end
17
+
18
+ class CDvQuantityItems < Treetop::Runtime::SyntaxNode
19
+ def value(node)
20
+ property = prop.value unless prop.empty?
21
+ list = ql.value(node) unless ql.empty?
22
+ av = aqv.value unless aqv.empty?
23
+ OpenEHR::AM::OpenEHRProfile::DataTypes::Quantity::CDvQuantity.new(
24
+ :path => node.path, :rm_type_name => 'DvQuantity',
25
+ :occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
26
+ :upper => 1, :lower => 1),
27
+ :property => property, :list => list, :assumed_value => av)
28
+ end
29
+ end
30
+
31
+ class AssumedValueItems < Treetop::Runtime::SyntaxNode
32
+ def value
33
+ magnitude, precision = nil
34
+ magnitude = mag.val.value unless mag.empty?
35
+ precision = prec.val.value unless prec.empty?
36
+ OpenEHR::RM::DataTypes::Quantity::DvQuantity.new(
37
+ :units => units.value,
38
+ :magnitude => magnitude,
39
+ :precision => precision)
40
+ end
41
+ end
17
42
  end
18
43
  end
19
44
  end
@@ -160,7 +160,12 @@ module OpenEHR
160
160
  end
161
161
 
162
162
  rule primitive_object_value
163
- term_code '' {
163
+ term_code_list_value '' {
164
+ def value
165
+ term_code_list_value.value
166
+ end
167
+ }
168
+ / term_code '' {
164
169
  def value
165
170
  term_code.value
166
171
  end
@@ -175,11 +180,6 @@ module OpenEHR
175
180
  simple_interval_value.value
176
181
  end
177
182
  }
178
- / term_code_list_value '' {
179
- def value
180
- term_code_list_value.value
181
- end
182
- }
183
183
  / simple_value '' {
184
184
  def value
185
185
  simple_value.value