openehr 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (384) hide show
  1. data/.document +5 -0
  2. data/.rspec +2 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +23 -0
  5. data/Guardfile +12 -0
  6. data/History.txt +36 -0
  7. data/PostInstall.txt +9 -0
  8. data/README.rdoc +82 -0
  9. data/Rakefile +44 -0
  10. data/VERSION +1 -0
  11. data/doc/openehr_terminology.xml +2700 -0
  12. data/lib/openehr.rb +11 -0
  13. data/lib/openehr/am.rb +8 -0
  14. data/lib/openehr/am/archetype.rb +133 -0
  15. data/lib/openehr/am/archetype/assertion.rb +190 -0
  16. data/lib/openehr/am/archetype/constraint_model.rb +328 -0
  17. data/lib/openehr/am/archetype/constraint_model/primitive.rb +327 -0
  18. data/lib/openehr/am/archetype/ontology.rb +126 -0
  19. data/lib/openehr/am/openehr_profile.rb +9 -0
  20. data/lib/openehr/am/openehr_profile/data_types.rb +13 -0
  21. data/lib/openehr/am/openehr_profile/data_types/basic.rb +114 -0
  22. data/lib/openehr/am/openehr_profile/data_types/quantity.rb +67 -0
  23. data/lib/openehr/am/openehr_profile/data_types/text.rb +22 -0
  24. data/lib/openehr/assumed_library_types.rb +691 -0
  25. data/lib/openehr/parser.rb +23 -0
  26. data/lib/openehr/parser/adl.rb +57 -0
  27. data/lib/openehr/parser/adl_grammar.tt +245 -0
  28. data/lib/openehr/parser/adl_parser.rb +52 -0
  29. data/lib/openehr/parser/cadl_grammar.tt +1527 -0
  30. data/lib/openehr/parser/cadl_node.rb +44 -0
  31. data/lib/openehr/parser/dadl.rb +13 -0
  32. data/lib/openehr/parser/dadl_grammar.tt +358 -0
  33. data/lib/openehr/parser/exception.rb +68 -0
  34. data/lib/openehr/parser/shared_token_grammar.tt +1229 -0
  35. data/lib/openehr/parser/validator.rb +19 -0
  36. data/lib/openehr/parser/xml_perser.rb +13 -0
  37. data/lib/openehr/rm.rb +15 -0
  38. data/lib/openehr/rm/common.rb +14 -0
  39. data/lib/openehr/rm/common/archetyped.rb +182 -0
  40. data/lib/openehr/rm/common/change_control.rb +332 -0
  41. data/lib/openehr/rm/common/directory.rb +29 -0
  42. data/lib/openehr/rm/common/generic.rb +216 -0
  43. data/lib/openehr/rm/common/resource.rb +154 -0
  44. data/lib/openehr/rm/composition.rb +103 -0
  45. data/lib/openehr/rm/composition/content.rb +22 -0
  46. data/lib/openehr/rm/composition/content/entry.rb +253 -0
  47. data/lib/openehr/rm/composition/content/navigation.rb +31 -0
  48. data/lib/openehr/rm/data_structures.rb +25 -0
  49. data/lib/openehr/rm/data_structures/history.rb +117 -0
  50. data/lib/openehr/rm/data_structures/item_structure.rb +218 -0
  51. data/lib/openehr/rm/data_structures/item_structure/representation.rb +63 -0
  52. data/lib/openehr/rm/data_types.rb +14 -0
  53. data/lib/openehr/rm/data_types/basic.rb +108 -0
  54. data/lib/openehr/rm/data_types/charset.lst +818 -0
  55. data/lib/openehr/rm/data_types/charset_extract.rb +24 -0
  56. data/lib/openehr/rm/data_types/encapsulated.rb +98 -0
  57. data/lib/openehr/rm/data_types/quantity.rb +402 -0
  58. data/lib/openehr/rm/data_types/quantity/date_time.rb +256 -0
  59. data/lib/openehr/rm/data_types/text.rb +169 -0
  60. data/lib/openehr/rm/data_types/time_specification.rb +75 -0
  61. data/lib/openehr/rm/data_types/uri.rb +83 -0
  62. data/lib/openehr/rm/demographic.rb +269 -0
  63. data/lib/openehr/rm/ehr.rb +162 -0
  64. data/lib/openehr/rm/integration.rb +27 -0
  65. data/lib/openehr/rm/security.rb +12 -0
  66. data/lib/openehr/rm/support.rb +14 -0
  67. data/lib/openehr/rm/support/definition.rb +15 -0
  68. data/lib/openehr/rm/support/identification.rb +412 -0
  69. data/lib/openehr/rm/support/measurement.rb +17 -0
  70. data/lib/openehr/rm/support/terminology.rb +135 -0
  71. data/lib/openehr/serializer.rb +272 -0
  72. data/lib/openehr/terminology.rb +7 -0
  73. data/lib/openehr/terminology/open_ehr_terminology.rb +41 -0
  74. data/lib/openehr/writer.rb +12 -0
  75. data/openehr.gemspec +472 -0
  76. data/spec/lib/openehr/am/archetype/archetype_spec.rb +103 -0
  77. data/spec/lib/openehr/am/archetype/assertion/assertion_spec.rb +60 -0
  78. data/spec/lib/openehr/am/archetype/assertion/assertion_variable_spec.rb +30 -0
  79. data/spec/lib/openehr/am/archetype/assertion/expr_binary_operator.rb +40 -0
  80. data/spec/lib/openehr/am/archetype/assertion/expr_item_spec.rb +28 -0
  81. data/spec/lib/openehr/am/archetype/assertion/expr_leaf_spec.rb +34 -0
  82. data/spec/lib/openehr/am/archetype/assertion/expr_operator_spec.rb +25 -0
  83. data/spec/lib/openehr/am/archetype/assertion/expr_unary_operator_spec.rb +26 -0
  84. data/spec/lib/openehr/am/archetype/assertion/operator_kind_spec.rb +114 -0
  85. data/spec/lib/openehr/am/archetype/constraint_model/archetype_constraint_spec.rb +56 -0
  86. data/spec/lib/openehr/am/archetype/constraint_model/archetype_internal_ref_spec.rb +36 -0
  87. data/spec/lib/openehr/am/archetype/constraint_model/archetype_slot_spec.rb +61 -0
  88. data/spec/lib/openehr/am/archetype/constraint_model/c_attribute_spec.rb +59 -0
  89. data/spec/lib/openehr/am/archetype/constraint_model/c_complex_object_spec.rb +39 -0
  90. data/spec/lib/openehr/am/archetype/constraint_model/c_defined_object_spec.rb +53 -0
  91. data/spec/lib/openehr/am/archetype/constraint_model/c_domain_type_spec.rb +25 -0
  92. data/spec/lib/openehr/am/archetype/constraint_model/c_multiple_attribute_spec.rb +23 -0
  93. data/spec/lib/openehr/am/archetype/constraint_model/c_object_spec.rb +61 -0
  94. data/spec/lib/openehr/am/archetype/constraint_model/c_primitive_object_spec.rb +33 -0
  95. data/spec/lib/openehr/am/archetype/constraint_model/c_reference_object_spec.rb +17 -0
  96. data/spec/lib/openehr/am/archetype/constraint_model/c_single_attribute_spec.rb +22 -0
  97. data/spec/lib/openehr/am/archetype/constraint_model/cardinality_spec.rb +68 -0
  98. data/spec/lib/openehr/am/archetype/constraint_model/constraint_ref_spec.rb +29 -0
  99. data/spec/lib/openehr/am/archetype/constraint_model/primitive/c_boolean_spec.rb +57 -0
  100. data/spec/lib/openehr/am/archetype/constraint_model/primitive/c_date_spec.rb +52 -0
  101. data/spec/lib/openehr/am/archetype/constraint_model/primitive/c_date_time_spec.rb +136 -0
  102. data/spec/lib/openehr/am/archetype/constraint_model/primitive/c_duration_spec.rb +41 -0
  103. data/spec/lib/openehr/am/archetype/constraint_model/primitive/c_integer_spec.rb +67 -0
  104. data/spec/lib/openehr/am/archetype/constraint_model/primitive/c_primitive_spec.rb +41 -0
  105. data/spec/lib/openehr/am/archetype/constraint_model/primitive/c_real_spec.rb +19 -0
  106. data/spec/lib/openehr/am/archetype/constraint_model/primitive/c_string_spec.rb +73 -0
  107. data/spec/lib/openehr/am/archetype/constraint_model/primitive/c_time_spec.rb +104 -0
  108. data/spec/lib/openehr/am/archetype/ontology/archetype_ontology_spec.rb +97 -0
  109. data/spec/lib/openehr/am/archetype/ontology/archetype_term_spec.rb +43 -0
  110. data/spec/lib/openehr/am/archetype/validity_kind_spec.rb +42 -0
  111. data/spec/lib/openehr/am/openehr_profile/data_types/basic/c_dv_state_spec.rb +34 -0
  112. data/spec/lib/openehr/am/openehr_profile/data_types/basic/non_terminal_state_spec.rb +36 -0
  113. data/spec/lib/openehr/am/openehr_profile/data_types/basic/state_machine_spec.rb +34 -0
  114. data/spec/lib/openehr/am/openehr_profile/data_types/basic/state_spec.rb +26 -0
  115. data/spec/lib/openehr/am/openehr_profile/data_types/basic/terminal_state_spec.rb +18 -0
  116. data/spec/lib/openehr/am/openehr_profile/data_types/basic/transition_spec.rb +62 -0
  117. data/spec/lib/openehr/am/openehr_profile/data_types/quantity/c_dv_ordinal_spec.rb +41 -0
  118. data/spec/lib/openehr/am/openehr_profile/data_types/quantity/c_dv_quantity_spec.rb +50 -0
  119. data/spec/lib/openehr/am/openehr_profile/data_types/quantity/c_quantity_item_spec.rb +46 -0
  120. data/spec/lib/openehr/am/openehr_profile/data_types/text/c_code_phrase_spec.rb +34 -0
  121. data/spec/lib/openehr/assumed_library_types/interval_spec.rb +145 -0
  122. data/spec/lib/openehr/assumed_library_types/iso8601_date_spec.rb +236 -0
  123. data/spec/lib/openehr/assumed_library_types/iso8601_date_time_spec.rb +47 -0
  124. data/spec/lib/openehr/assumed_library_types/iso8601_duration_spec.rb +150 -0
  125. data/spec/lib/openehr/assumed_library_types/iso8601_time_spec.rb +234 -0
  126. data/spec/lib/openehr/assumed_library_types/iso8601_timezone_spec.rb +57 -0
  127. data/spec/lib/openehr/assumed_library_types/time_definitions_spec.rb +136 -0
  128. data/spec/lib/openehr/assumed_library_types/timezone_spec.rb +42 -0
  129. data/spec/lib/openehr/parser/adl14/adl-test-ENTRY.assumed_types.v1.adl +88 -0
  130. data/spec/lib/openehr/parser/adl14/adl-test-ENTRY.basic_types.v1.adl +143 -0
  131. data/spec/lib/openehr/parser/adl14/adl-test-ENTRY.basic_types_fail.v1.adl +50 -0
  132. data/spec/lib/openehr/parser/adl14/adl-test-ENTRY.most_minimal.v1.adl +27 -0
  133. data/spec/lib/openehr/parser/adl14/adl-test-ENTRY.structure_test1.v1.adl +46 -0
  134. data/spec/lib/openehr/parser/adl14/adl-test-SOME_TYPE.generic_type_basic.draft.adl +56 -0
  135. data/spec/lib/openehr/parser/adl14/adl-test-SOME_TYPE.generic_type_use_node.draft.adl +63 -0
  136. data/spec/lib/openehr/parser/adl14/adl-test-car.paths.test.adl +80 -0
  137. data/spec/lib/openehr/parser/adl14/adl-test-car.use_node.test.adl +87 -0
  138. data/spec/lib/openehr/parser/adl14/adl-test-composition.dv_coded_text.test.adl +29 -0
  139. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_bindings.test.adl +47 -0
  140. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_desc_missing_purpose.test.adl +45 -0
  141. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_description.test.adl +61 -0
  142. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_description2.test.adl +45 -0
  143. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_identification.test.adl +26 -0
  144. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_internal_ref.test.adl +36 -0
  145. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_internal_ref2.test.adl +36 -0
  146. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_language.test.adl +47 -0
  147. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_language_no_accreditation.test.adl +38 -0
  148. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_language_order_of_translation_details.test.adl +40 -0
  149. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_ontology.test.adl +25 -0
  150. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_slot.test.adl +40 -0
  151. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_slot.test2.adl +37 -0
  152. data/spec/lib/openehr/parser/adl14/adl-test-entry.archetype_uncommonkeys.test.adl +29 -0
  153. data/spec/lib/openehr/parser/adl14/adl-test-entry.basic_types.test.adl +272 -0
  154. data/spec/lib/openehr/parser/adl14/adl-test-entry.c_code_phrase.test.adl +77 -0
  155. data/spec/lib/openehr/parser/adl14/adl-test-entry.c_dv_ordinal.test.adl +66 -0
  156. data/spec/lib/openehr/parser/adl14/adl-test-entry.c_dv_quantity_empty.test.adl +46 -0
  157. data/spec/lib/openehr/parser/adl14/adl-test-entry.c_dv_quantity_full.test.adl +64 -0
  158. data/spec/lib/openehr/parser/adl14/adl-test-entry.c_dv_quantity_full2.test.adl +64 -0
  159. data/spec/lib/openehr/parser/adl14/adl-test-entry.c_dv_quantity_full3.test.adl +64 -0
  160. data/spec/lib/openehr/parser/adl14/adl-test-entry.c_dv_quantity_item_units_only.test.adl +55 -0
  161. data/spec/lib/openehr/parser/adl14/adl-test-entry.c_dv_quantity_list.test.adl +58 -0
  162. data/spec/lib/openehr/parser/adl14/adl-test-entry.c_dv_quantity_property.test.adl +47 -0
  163. data/spec/lib/openehr/parser/adl14/adl-test-entry.c_dv_quantity_reversed.test.adl +59 -0
  164. data/spec/lib/openehr/parser/adl14/adl-test-entry.constraint_binding.test.adl +37 -0
  165. data/spec/lib/openehr/parser/adl14/adl-test-entry.constraint_ref.test.adl +43 -0
  166. data/spec/lib/openehr/parser/adl14/adl-test-entry.datetime.test.adl +183 -0
  167. data/spec/lib/openehr/parser/adl14/adl-test-entry.domain_types.test.adl +97 -0
  168. data/spec/lib/openehr/parser/adl14/adl-test-entry.durations.test.adl +109 -0
  169. data/spec/lib/openehr/parser/adl14/adl-test-entry.empty_other_contributors.test.adl +42 -0
  170. data/spec/lib/openehr/parser/adl14/adl-test-entry.missing_language.test.adl +23 -0
  171. data/spec/lib/openehr/parser/adl14/adl-test-entry.mixed_node_types.draft.adl +61 -0
  172. data/spec/lib/openehr/parser/adl14/adl-test-entry.most_minimal.test.adl +23 -0
  173. data/spec/lib/openehr/parser/adl14/adl-test-entry.multi_language.test.adl +52 -0
  174. data/spec/lib/openehr/parser/adl14/adl-test-entry.special_string.test.adl +88 -0
  175. data/spec/lib/openehr/parser/adl14/adl-test-entry.structure_test1.test.adl +45 -0
  176. data/spec/lib/openehr/parser/adl14/adl-test-entry.structure_test2.test.adl +45 -0
  177. data/spec/lib/openehr/parser/adl14/adl-test-entry.term_binding.test.adl +37 -0
  178. data/spec/lib/openehr/parser/adl14/adl-test-entry.term_binding2.test.adl +32 -0
  179. data/spec/lib/openehr/parser/adl14/adl-test-entry.testtranslations.test.adl +83 -0
  180. data/spec/lib/openehr/parser/adl14/adl-test-entry.translations_author_language.test.adl +34 -0
  181. data/spec/lib/openehr/parser/adl14/adl-test-entry.translations_language_author.test.adl +34 -0
  182. data/spec/lib/openehr/parser/adl14/adl-test-entry.unicode_BOM_support.test.adl +41 -0
  183. data/spec/lib/openehr/parser/adl14/adl-test-entry.unicode_support.test.adl +41 -0
  184. data/spec/lib/openehr/parser/adl14/openEHR-EHR-ACTION.imaging.v1.adl +275 -0
  185. data/spec/lib/openehr/parser/adl14/openEHR-EHR-ACTION.referral.v1.adl +351 -0
  186. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.auscultation-chest.v1.adl +765 -0
  187. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.auscultation.v1.adl +48 -0
  188. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.dimensions-circumference.v1.adl +134 -0
  189. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.dimensions.v1.adl +241 -0
  190. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.exam-abdomen.v1.adl +321 -0
  191. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.exam-chest.v1.adl +379 -0
  192. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.exam-fetus.v1.adl +577 -0
  193. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.exam-generic-joint.v1.adl +146 -0
  194. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.exam-generic-lymphnode.v1.adl +176 -0
  195. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.exam-generic-mass.v1.adl +221 -0
  196. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.exam-generic.v1.adl +139 -0
  197. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.exam-nervous_system.v1.adl +116 -0
  198. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.exam-uterine_cervix.v1.adl +420 -0
  199. data/spec/lib/openehr/parser/adl14/openEHR-EHR-CLUSTER.exam-uterus.v1.adl +293 -0
  200. data/spec/lib/openehr/parser/adl14/openEHR-EHR-COMPOSITION.discharge.v1draft.adl +53 -0
  201. data/spec/lib/openehr/parser/adl14/openEHR-EHR-COMPOSITION.encounter.v1draft.adl +45 -0
  202. data/spec/lib/openehr/parser/adl14/openEHR-EHR-EVALUATION.adverse.v1.adl +411 -0
  203. data/spec/lib/openehr/parser/adl14/openEHR-EHR-EVALUATION.columna_vertebral.v1.adl +85 -0
  204. data/spec/lib/openehr/parser/adl14/openEHR-EHR-INSTRUCTION.medication.v1.adl +88 -0
  205. data/spec/lib/openehr/parser/adl14/openEHR-EHR-INSTRUCTION.referral.v1.adl +84 -0
  206. data/spec/lib/openehr/parser/adl14/openEHR-EHR-ITEM_TREE.Laboratory_request.v1.adl +492 -0
  207. data/spec/lib/openehr/parser/adl14/openEHR-EHR-ITEM_TREE.follow_up.v1draft.adl +94 -0
  208. data/spec/lib/openehr/parser/adl14/openEHR-EHR-ITEM_TREE.imaging.v1.adl +127 -0
  209. data/spec/lib/openehr/parser/adl14/openEHR-EHR-ITEM_TREE.medication-formulation.v1.adl +457 -0
  210. data/spec/lib/openehr/parser/adl14/openEHR-EHR-ITEM_TREE.medication.v1.adl +869 -0
  211. data/spec/lib/openehr/parser/adl14/openEHR-EHR-ITEM_TREE.referral.v1.adl +494 -0
  212. data/spec/lib/openehr/parser/adl14/openEHR-EHR-OBSERVATION.apgar.v1.adl +545 -0
  213. data/spec/lib/openehr/parser/adl14/openEHR-EHR-OBSERVATION.blood_pressure.v1.adl +673 -0
  214. data/spec/lib/openehr/parser/adl14/openEHR-EHR-OBSERVATION.body_mass_index.v1.adl +166 -0
  215. data/spec/lib/openehr/parser/adl14/openEHR-EHR-OBSERVATION.lab_test.v1.adl +376 -0
  216. data/spec/lib/openehr/parser/adl14/openEHR-EHR-OBSERVATION.testassumedvalue.v1.adl +99 -0
  217. data/spec/lib/openehr/parser/adl14/openEHR-EHR-SECTION.findings.v1.adl +47 -0
  218. data/spec/lib/openehr/parser/adl14/openEHR-EHR-SECTION.reason_for_encounter.v1.adl +51 -0
  219. data/spec/lib/openehr/parser/adl14/openEHR-EHR-SECTION.summary.v1.adl +52 -0
  220. data/spec/lib/openehr/parser/adl14/openEHR-EHR-SECTION.vital_signs.v1.adl +54 -0
  221. data/spec/lib/openehr/parser/adl_archetype_internal_ref2_spec.rb +42 -0
  222. data/spec/lib/openehr/parser/adl_archetype_internal_ref_spec.rb +125 -0
  223. data/spec/lib/openehr/parser/adl_archetype_internal_ref_with_generics_spec.rb +258 -0
  224. data/spec/lib/openehr/parser/adl_archetype_ontology_binding_spec.rb +98 -0
  225. data/spec/lib/openehr/parser/adl_archetype_ontology_spec.rb +42 -0
  226. data/spec/lib/openehr/parser/adl_archetype_slot_cluster_spec.rb +101 -0
  227. data/spec/lib/openehr/parser/adl_archetype_slot_spec.rb +193 -0
  228. data/spec/lib/openehr/parser/adl_archetype_uncommon_term_keys_spec.rb +25 -0
  229. data/spec/lib/openehr/parser/adl_description_spec.rb +164 -0
  230. data/spec/lib/openehr/parser/adl_identification_spec.rb +18 -0
  231. data/spec/lib/openehr/parser/adl_language_no_accreditation_spec.rb +66 -0
  232. data/spec/lib/openehr/parser/adl_language_order_spec.rb +68 -0
  233. data/spec/lib/openehr/parser/adl_language_spec.rb +119 -0
  234. data/spec/lib/openehr/parser/adl_language_translation_author_language_spec.rb +50 -0
  235. data/spec/lib/openehr/parser/adl_language_translation_language_author_spec.rb +46 -0
  236. data/spec/lib/openehr/parser/adl_parser_spec.rb +347 -0
  237. data/spec/lib/openehr/parser/adl_path_spec.rb +176 -0
  238. data/spec/lib/openehr/parser/base_spec.rb +19 -0
  239. data/spec/lib/openehr/parser/basic_generic_type_spec.rb +18 -0
  240. data/spec/lib/openehr/parser/basic_type_spec.rb +2922 -0
  241. data/spec/lib/openehr/parser/c_dv_quantity_any_allowed_spec.rb +34 -0
  242. data/spec/lib/openehr/parser/c_dv_quantity_shared_example_for_lacked_items_spec.rb +36 -0
  243. data/spec/lib/openehr/parser/c_dv_quantity_shared_example_spec.rb +146 -0
  244. data/spec/lib/openehr/parser/cdv_ordinal_parse_spec.rb +231 -0
  245. data/spec/lib/openehr/parser/code_phrase_spec.rb +96 -0
  246. data/spec/lib/openehr/parser/constraint_binding_spec.rb +26 -0
  247. data/spec/lib/openehr/parser/constraint_ref_spec.rb +32 -0
  248. data/spec/lib/openehr/parser/date_time_spec.rb +1953 -0
  249. data/spec/lib/openehr/parser/duration_spec.rb +475 -0
  250. data/spec/lib/openehr/parser/dv_coded_text_parse_spec.rb +27 -0
  251. data/spec/lib/openehr/parser/empty_other_contributors_spec.rb +19 -0
  252. data/spec/lib/openehr/parser/lab_test_parser_spec.rb +14 -0
  253. data/spec/lib/openehr/parser/missing_language_spec.rb +20 -0
  254. data/spec/lib/openehr/parser/missing_purpose_spec.rb +23 -0
  255. data/spec/lib/openehr/parser/mixed_node_types_spec.rb +16 -0
  256. data/spec/lib/openehr/parser/most_minimal_adl_spec.rb +19 -0
  257. data/spec/lib/openehr/parser/multi_language_spec.rb +58 -0
  258. data/spec/lib/openehr/parser/parser_spec_helper.rb +7 -0
  259. data/spec/lib/openehr/parser/path_based_terminology_binding_spec.rb +30 -0
  260. data/spec/lib/openehr/parser/special_string_spec.rb +20 -0
  261. data/spec/lib/openehr/parser/structure_comment_spec.rb +21 -0
  262. data/spec/lib/openehr/parser/structure_nested_comments_spec.rb +22 -0
  263. data/spec/lib/openehr/parser/structure_spec.rb +202 -0
  264. data/spec/lib/openehr/parser/term_binding_spec.rb +54 -0
  265. data/spec/lib/openehr/parser/unicode_bom_spec.rb +17 -0
  266. data/spec/lib/openehr/parser/unicode_support_spec.rb +46 -0
  267. data/spec/lib/openehr/rm/common/archetyped/archetyped_spec.rb +50 -0
  268. data/spec/lib/openehr/rm/common/archetyped/feeder_audit_details_spec.rb +60 -0
  269. data/spec/lib/openehr/rm/common/archetyped/feeder_audit_spec.rb +51 -0
  270. data/spec/lib/openehr/rm/common/archetyped/link_spec.rb +42 -0
  271. data/spec/lib/openehr/rm/common/archetyped/locatable_spec.rb +89 -0
  272. data/spec/lib/openehr/rm/common/archetyped/pathable_spec.rb +42 -0
  273. data/spec/lib/openehr/rm/common/change_control/contribution_spec.rb +56 -0
  274. data/spec/lib/openehr/rm/common/change_control/imported_version_spec.rb +62 -0
  275. data/spec/lib/openehr/rm/common/change_control/original_version_spec.rb +71 -0
  276. data/spec/lib/openehr/rm/common/change_control/version_spec.rb +91 -0
  277. data/spec/lib/openehr/rm/common/change_control/versioned_object_spec.rb +284 -0
  278. data/spec/lib/openehr/rm/common/directory/folder_spec.rb +26 -0
  279. data/spec/lib/openehr/rm/common/generic/attestation_spec.rb +62 -0
  280. data/spec/lib/openehr/rm/common/generic/audit_details_spec.rb +51 -0
  281. data/spec/lib/openehr/rm/common/generic/participation_spec.rb +36 -0
  282. data/spec/lib/openehr/rm/common/generic/party_identified_spec.rb +64 -0
  283. data/spec/lib/openehr/rm/common/generic/party_proxy_spec.rb +18 -0
  284. data/spec/lib/openehr/rm/common/generic/party_related_spec.rb +24 -0
  285. data/spec/lib/openehr/rm/common/generic/revision_history_item_spec.rb +43 -0
  286. data/spec/lib/openehr/rm/common/generic/revision_history_spec.rb +45 -0
  287. data/spec/lib/openehr/rm/common/resource/authored_resource_spec.rb +68 -0
  288. data/spec/lib/openehr/rm/common/resource/resource_description_item_spec.rb +105 -0
  289. data/spec/lib/openehr/rm/common/resource/resource_description_spec.rb +74 -0
  290. data/spec/lib/openehr/rm/common/resource/translation_details_spec.rb +35 -0
  291. data/spec/lib/openehr/rm/composition/composition_spec.rb +92 -0
  292. data/spec/lib/openehr/rm/composition/content/content_item_spec.rb +14 -0
  293. data/spec/lib/openehr/rm/composition/content/entry/action_spec.rb +69 -0
  294. data/spec/lib/openehr/rm/composition/content/entry/activity_spec.rb +61 -0
  295. data/spec/lib/openehr/rm/composition/content/entry/admin_entry_spec.rb +38 -0
  296. data/spec/lib/openehr/rm/composition/content/entry/care_entry_spec.rb +37 -0
  297. data/spec/lib/openehr/rm/composition/content/entry/entry_spec.rb +98 -0
  298. data/spec/lib/openehr/rm/composition/content/entry/evaluation_spec.rb +37 -0
  299. data/spec/lib/openehr/rm/composition/content/entry/instruction_details_spec.rb +51 -0
  300. data/spec/lib/openehr/rm/composition/content/entry/instruction_spec.rb +62 -0
  301. data/spec/lib/openehr/rm/composition/content/entry/ism_transition_spec.rb +46 -0
  302. data/spec/lib/openehr/rm/composition/content/entry/observation_spec.rb +45 -0
  303. data/spec/lib/openehr/rm/composition/content/navigation/section_spec.rb +32 -0
  304. data/spec/lib/openehr/rm/composition/event_context_spec.rb +88 -0
  305. data/spec/lib/openehr/rm/data_structures/data_structure_spec.rb +21 -0
  306. data/spec/lib/openehr/rm/data_structures/history/event_spec.rb +44 -0
  307. data/spec/lib/openehr/rm/data_structures/history/history_spec.rb +67 -0
  308. data/spec/lib/openehr/rm/data_structures/history/interval_event_spec.rb +43 -0
  309. data/spec/lib/openehr/rm/data_structures/item_structure/item_list_spec.rb +53 -0
  310. data/spec/lib/openehr/rm/data_structures/item_structure/item_single_spec.rb +29 -0
  311. data/spec/lib/openehr/rm/data_structures/item_structure/item_table_spec.rb +147 -0
  312. data/spec/lib/openehr/rm/data_structures/item_structure/item_tree_spec.rb +48 -0
  313. data/spec/lib/openehr/rm/data_structures/item_structure/representation/cluster_spec.rb +26 -0
  314. data/spec/lib/openehr/rm/data_structures/item_structure/representation/element_spec.rb +22 -0
  315. data/spec/lib/openehr/rm/data_types/basic/data_value_spec.rb +17 -0
  316. data/spec/lib/openehr/rm/data_types/basic/dv_boolean_spec.rb +29 -0
  317. data/spec/lib/openehr/rm/data_types/basic/dv_identifier_spec.rb +108 -0
  318. data/spec/lib/openehr/rm/data_types/basic/dv_state_spec.rb +44 -0
  319. data/spec/lib/openehr/rm/data_types/encapsulated/dv_encapsulated_spec.rb +42 -0
  320. data/spec/lib/openehr/rm/data_types/encapsulated/dv_multimedia_spec.rb +79 -0
  321. data/spec/lib/openehr/rm/data_types/encapsulated/dv_parsable_spec.rb +34 -0
  322. data/spec/lib/openehr/rm/data_types/quantity/date_time/dv_date_spec.rb +64 -0
  323. data/spec/lib/openehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb +26 -0
  324. data/spec/lib/openehr/rm/data_types/quantity/date_time/dv_duration_spec.rb +44 -0
  325. data/spec/lib/openehr/rm/data_types/quantity/date_time/dv_temporal_spec.rb +25 -0
  326. data/spec/lib/openehr/rm/data_types/quantity/date_time/dv_time_spec.rb +41 -0
  327. data/spec/lib/openehr/rm/data_types/quantity/dv_absolute_quantity_spec.rb +35 -0
  328. data/spec/lib/openehr/rm/data_types/quantity/dv_amount_spec.rb +105 -0
  329. data/spec/lib/openehr/rm/data_types/quantity/dv_count_spec.rb +12 -0
  330. data/spec/lib/openehr/rm/data_types/quantity/dv_interval_spec.rb +17 -0
  331. data/spec/lib/openehr/rm/data_types/quantity/dv_ordered_spec.rb +60 -0
  332. data/spec/lib/openehr/rm/data_types/quantity/dv_ordinal_spec.rb +74 -0
  333. data/spec/lib/openehr/rm/data_types/quantity/dv_proportion_spec.rb +162 -0
  334. data/spec/lib/openehr/rm/data_types/quantity/dv_quantified_spec.rb +36 -0
  335. data/spec/lib/openehr/rm/data_types/quantity/dv_quantity_spec.rb +78 -0
  336. data/spec/lib/openehr/rm/data_types/quantity/proportion_kind_spec.rb +24 -0
  337. data/spec/lib/openehr/rm/data_types/quantity/reference_range_spec.rb +43 -0
  338. data/spec/lib/openehr/rm/data_types/text/code_phrase_spec.rb +23 -0
  339. data/spec/lib/openehr/rm/data_types/text/dv_paragraph_spec.rb +13 -0
  340. data/spec/lib/openehr/rm/data_types/text/dv_text_spec.rb +79 -0
  341. data/spec/lib/openehr/rm/data_types/text/term_mapping_spec.rb +59 -0
  342. data/spec/lib/openehr/rm/data_types/uri/dv_ehr_uri_spec.rb +21 -0
  343. data/spec/lib/openehr/rm/data_types/uri/dv_uri_spec.rb +36 -0
  344. data/spec/lib/openehr/rm/demographic/actor_spec.rb +79 -0
  345. data/spec/lib/openehr/rm/demographic/address_spec.rb +33 -0
  346. data/spec/lib/openehr/rm/demographic/capability_spec.rb +37 -0
  347. data/spec/lib/openehr/rm/demographic/contact_spec.rb +45 -0
  348. data/spec/lib/openehr/rm/demographic/party_identity_spec.rb +32 -0
  349. data/spec/lib/openehr/rm/demographic/party_relationship_spec.rb +84 -0
  350. data/spec/lib/openehr/rm/demographic/party_spec.rb +131 -0
  351. data/spec/lib/openehr/rm/demographic/role_spec.rb +58 -0
  352. data/spec/lib/openehr/rm/ehr/ehr_access_spec.rb +33 -0
  353. data/spec/lib/openehr/rm/ehr/ehr_spec.rb +139 -0
  354. data/spec/lib/openehr/rm/ehr/ehr_status_spec.rb +52 -0
  355. data/spec/lib/openehr/rm/ehr/versioned_composition_spec.rb +33 -0
  356. data/spec/lib/openehr/rm/integration/generic_entry_spec.rb +31 -0
  357. data/spec/lib/openehr/rm/support/identification/access_group_ref_spec.rb +19 -0
  358. data/spec/lib/openehr/rm/support/identification/archetype_id_spec.rb +152 -0
  359. data/spec/lib/openehr/rm/support/identification/generic_id_spec.rb +33 -0
  360. data/spec/lib/openehr/rm/support/identification/hier_object_id_spec.rb +12 -0
  361. data/spec/lib/openehr/rm/support/identification/internet_id_spec.rb +12 -0
  362. data/spec/lib/openehr/rm/support/identification/iso_oid_spec.rb +12 -0
  363. data/spec/lib/openehr/rm/support/identification/locatable_ref_spec.rb +34 -0
  364. data/spec/lib/openehr/rm/support/identification/object_id_spec.rb +24 -0
  365. data/spec/lib/openehr/rm/support/identification/object_ref_spec.rb +33 -0
  366. data/spec/lib/openehr/rm/support/identification/object_version_id_spec.rb +59 -0
  367. data/spec/lib/openehr/rm/support/identification/party_ref_spec.rb +29 -0
  368. data/spec/lib/openehr/rm/support/identification/template_id_spec.rb +12 -0
  369. data/spec/lib/openehr/rm/support/identification/terminology_id_spec.rb +33 -0
  370. data/spec/lib/openehr/rm/support/identification/uid_based_id_spec.rb +50 -0
  371. data/spec/lib/openehr/rm/support/identification/uid_spec.rb +29 -0
  372. data/spec/lib/openehr/rm/support/identification/version_tree_id_spec.rb +104 -0
  373. data/spec/lib/openehr/rm/support/measurement_service_spec.rb +7 -0
  374. data/spec/lib/openehr/rm/support/terminology_service_spec.rb +24 -0
  375. data/spec/lib/openehr/serializer/adl-test-entry.most_minimal.test.adl +20 -0
  376. data/spec/lib/openehr/serializer/adl_serializer_spec.rb +47 -0
  377. data/spec/lib/openehr/serializer/openEHR-EHR-SECTION.test.v1.adl +38 -0
  378. data/spec/lib/openehr/serializer/openEHR-EHR-SECTION.test.v1.xml +58 -0
  379. data/spec/lib/openehr/serializer/sample_archetype_spec.rb +44 -0
  380. data/spec/lib/openehr/serializer/xml_serializer_spec.rb +49 -0
  381. data/spec/lib/openehr/terminology/open_ehr_terminology_spec.rb +40 -0
  382. data/spec/spec.opts +6 -0
  383. data/spec/spec_helper.rb +58 -0
  384. metadata +631 -0
@@ -0,0 +1,23 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ module OpenEHR
4
+ module Parser
5
+ class Base
6
+ attr_reader :filename
7
+
8
+ def initialize(filename)
9
+ @filename = filename
10
+ end
11
+
12
+ def parse
13
+ raise NotImplementedError
14
+ end
15
+ end
16
+
17
+ autoload :ADLParser, 'parser/adl_parser'
18
+ # autoload :CADLParser, 'parser/adl_parser'
19
+ # autoload :XMLParser, 'parser/xml_perser'
20
+ # autoload :Exception, 'parser/exception'
21
+ # autoload :Scanner, 'parser/scanner'
22
+ end
23
+ end
@@ -0,0 +1,57 @@
1
+ require 'openehr/rm/data_types/text'
2
+ include OpenEHR::RM::Support::Identification
3
+ include OpenEHR::RM::Common::Resource
4
+
5
+ module OpenEHR
6
+ module Parser
7
+ module ADLGrammar
8
+ class Base < Treetop::Runtime::SyntaxNode
9
+
10
+ end
11
+
12
+ class ArchLanguage < Base
13
+ def value
14
+ return Language.new(lang.value)
15
+ end
16
+ end
17
+
18
+ class Language
19
+ include OpenEHR::RM::DataTypes::Text
20
+ attr_reader :original_language, :translations
21
+
22
+ def initialize(value)
23
+ self.original_language = value['original_language']
24
+ self.translations = value['translations']
25
+ end
26
+
27
+ def original_language=(original_language)
28
+ @original_language = original_language
29
+ end
30
+
31
+ def translations=(translations)
32
+ if translations.nil?
33
+ @translations = nil
34
+ else
35
+ tr = translations.inject({ }) do |trans, lang|
36
+ code, details = lang
37
+ td = TranslationDetails.new(
38
+ :language => details['language'],
39
+ :author => details['author'],
40
+ :accreditation => details['accreditation'],
41
+ :other_details => details['other_details'])
42
+ trans.update Hash[code, td]
43
+ end
44
+ @translations = tr
45
+ end
46
+ end
47
+
48
+ protected
49
+ def code2lang(code)
50
+ ti, la = code.split '::'
51
+ ti = TerminologyID.new(:value => ti)
52
+ CodePhrase.new(:code_string => la, :terminology_id => ti)
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,245 @@
1
+ require 'shared_token_grammar'
2
+ require 'dadl_grammar'
3
+ require 'cadl_grammar'
4
+ require 'adl'
5
+
6
+ module OpenEHR
7
+ module Parser
8
+ grammar ADLGrammar
9
+
10
+ include SharedToken
11
+ include DADLGrammar
12
+ include CADL
13
+
14
+ rule archetype
15
+ arch_identification
16
+ spec:(arch_specialisation)?
17
+ arch_concept
18
+ lang:(arch_language)?
19
+ desc:(arch_description)?
20
+ arch_definition
21
+ arch_invariant?
22
+ arch_ontology {
23
+ def archetype_id
24
+ arch_identification.archetype_id
25
+ end
26
+
27
+ def adl_version
28
+ arch_identification.adl_version
29
+ end
30
+
31
+ def concept
32
+ arch_concept.value
33
+ end
34
+
35
+ def original_language
36
+ lang.value.original_language unless lang.empty?
37
+ end
38
+
39
+ def translations
40
+ lang.value.translations unless lang.empty?
41
+ end
42
+
43
+ def description
44
+ desc.value unless desc.empty?
45
+ end
46
+
47
+ def definition
48
+ arch_definition.value
49
+ end
50
+
51
+ def ontology
52
+ arch_ontology.value
53
+ end
54
+ }
55
+ end
56
+
57
+ rule arch_identification
58
+ head:arch_head id:V_ARCHETYPE_ID space {
59
+ def archetype_id
60
+ id.value
61
+ end
62
+
63
+ def adl_version
64
+ head.value[:adl_version]
65
+ end
66
+
67
+ def is_controlled?
68
+ head.value[:is_controlled?]
69
+ end
70
+ }
71
+ end
72
+
73
+ rule arch_head
74
+ SYM_ARCHETYPE m:arch_meta_data {
75
+ def value
76
+ m.value
77
+ end
78
+ }
79
+ / SYM_ARCHETYPE {
80
+ def value
81
+ Hash.new
82
+ end
83
+ }
84
+ end
85
+
86
+ rule arch_meta_data
87
+ '(' arch_meta_data_items ')' space {
88
+ def value
89
+ arch_meta_data_items.value
90
+ end
91
+ }
92
+ end
93
+
94
+ rule arch_meta_data_items
95
+ item:arch_meta_data_item other_item:(';' arch_meta_data_item)* {
96
+ def value
97
+ v = item.value
98
+ other_item.elements.map {|i| i.arch_meta_data_item.value}
99
+ v
100
+ end
101
+ }
102
+ end
103
+
104
+ rule arch_meta_data_item
105
+ SYM_ADL_VERSION SYM_EQ ver:V_VERSION_STRING space {
106
+ def value
107
+ {:adl_version => ver.value}
108
+ end
109
+ }
110
+ / SYM_IS_CONTROLED space {
111
+ def value
112
+ {:is_controled? => true} # if elements[0]
113
+ end
114
+ }
115
+ end
116
+
117
+ rule arch_specialisation
118
+ SYM_SPECIALIZE arch_id:V_ARCHETYPE_ID space {
119
+ def specialised?
120
+ true if elements[0]
121
+ end
122
+
123
+ def archetype_id
124
+ arch_id.value
125
+ end
126
+ }
127
+ end
128
+
129
+ rule arch_concept
130
+ SYM_CONCEPT conc:V_LOCAL_TERM_CODE_REF space {
131
+ def value
132
+ conc.text_value[1..-2]
133
+ end
134
+ }
135
+ end
136
+
137
+ rule arch_language
138
+ SYM_LANGUAGE lang:V_DADL_TEXT <ArchLanguage>
139
+ end
140
+
141
+ rule arch_description
142
+ SYM_DESCRIPTION desc:V_DADL_TEXT space {
143
+ def value
144
+ params = desc.value
145
+ details = { }
146
+ params['details'].each do |lang, attrs|
147
+ misuse = attrs['misuse']
148
+ misuse = nil if misuse.nil? or misuse.empty?
149
+ purpose = attrs['purpose'] || '__unknown__' # for backward compat.
150
+ item =
151
+ OpenEHR::RM::Common::Resource::ResourceDescriptionItem.new(
152
+ :language => attrs['language'],
153
+ :purpose => purpose,
154
+ :keywords => attrs["keywords"],
155
+ :use => attrs["use"],
156
+ :misuse => misuse,
157
+ :copyright => attrs['copyright'],
158
+ :original_resource_uri => attrs['original_resource_uri'],
159
+ :other_details => attrs['other_details'])
160
+ details[lang] = item
161
+ end
162
+ oc = params['other_contributors']
163
+ if oc.instance_of? Hash
164
+ oc = oc.values
165
+ end
166
+ OpenEHR::RM::Common::Resource::ResourceDescription.new(
167
+ :original_author => params['original_author'],
168
+ :other_contributors => oc,
169
+ :lifecycle_state => params['lifecycle_state'],
170
+ :details => details,
171
+ :resource_package_uri => params['archetype_package_uri'],
172
+ :other_details => params['other_details'])
173
+ end
174
+ }
175
+ end
176
+
177
+ rule arch_definition
178
+ SYM_DEFINITION definition:V_CADL_TEXT space {
179
+ def value
180
+ definition.value
181
+ end
182
+ }
183
+ end
184
+
185
+ rule arch_invariant
186
+ SYM_INVARIANT V_ASSERTION_TEXT space
187
+ end
188
+
189
+ rule arch_ontology
190
+ SYM_ONTOLOGY ontology:V_DADL_TEXT space {
191
+ def value
192
+ ao = ontology.value
193
+ arc_term = Proc.new do |code, item|
194
+ OpenEHR::AM::Archetype::Ontology::ArchetypeTerm.new(
195
+ :code => code, :items => item)
196
+ end
197
+ td = itemizer(ao['term_definitions'], arc_term)
198
+ cd = ao['constraint_definitions']
199
+ if cd
200
+ cd = itemizer(cd , arc_term)
201
+ end
202
+ tb = ao['term_bindings'] || ao['term_binding']
203
+ term_bind = Proc.new do |code, item|
204
+ unless item.class == Array
205
+ [item]
206
+ else
207
+ item
208
+ end
209
+ end
210
+ if tb
211
+ tb = itemizer(tb, term_bind)
212
+ end
213
+ cons_bind = Proc.new do |code, item|
214
+ OpenEHR::RM::DataTypes::URI::DvUri.new(:value => item)
215
+ end
216
+ cb = ao['constraint_bindings'] || ao['constraint_binding']
217
+ if cb
218
+ cb = itemizer(cb, cons_bind)
219
+ end
220
+ OpenEHR::AM::Archetype::Ontology::ArchetypeOntology.new(
221
+ :primary_language => ao['primary_language'],
222
+ :languages_available => ao['languages_available'],
223
+ :terminologies_available => ao['terminologies_available'],
224
+ :term_definitions => td,
225
+ :constraint_definitions => cd,
226
+ :term_bindings => tb,
227
+ :constraint_bindings => cb)
228
+ end
229
+
230
+ def itemizer(defs, itemize)
231
+ defs.inject({ }) do |term_defs, langs|
232
+ lang, items = langs
233
+ terms = items['items'].inject({ }) do |items, term|
234
+ code, item = term
235
+ item = itemize.call code, item
236
+ items.update Hash[code => item]
237
+ end
238
+ term_defs.update Hash[lang => terms]
239
+ end
240
+ end
241
+ }
242
+ end # of arch_ontology
243
+ end # of ADLGrammar
244
+ end # of Parser
245
+ end # of openEHR
@@ -0,0 +1,52 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ require 'polyglot'
4
+ require 'treetop'
5
+ include OpenEHR::Parser
6
+ include OpenEHR::AM::Archetype
7
+ include OpenEHR::RM::Support::Identification
8
+ include OpenEHR::RM::DataTypes::Text
9
+
10
+ module OpenEHR
11
+ module Parser
12
+ class ADLParser < Base
13
+ def initialize(filename)
14
+ super(filename)
15
+ file = File.open(filename, 'r:bom|utf-8')
16
+ data = file.read
17
+ Treetop.load(File.dirname(__FILE__)+'/adl_grammar.tt')
18
+ ap = ADLGrammarParser.new
19
+ @result = ap.parse(data)
20
+ file.close
21
+ unless @result
22
+ puts ap.failure_reason
23
+ puts ap.failure_line
24
+ puts ap.failure_column
25
+ end
26
+ end
27
+
28
+ def parse
29
+ archetype_id = ArchetypeID.new(:value => @result.archetype_id)
30
+ definition = @result.definition
31
+ ontology = @result.ontology
32
+ original_language = nil
33
+ if @result.original_language
34
+ original_language = @result.original_language
35
+ else
36
+ terminology_id = TerminologyID.new(:value => 'ISO639-1')
37
+ original_language = CodePhrase.new(:terminology_id => terminology_id,
38
+ :code_string =>ontology.primary_language)
39
+ end
40
+ archetype = Archetype.new(:archetype_id => archetype_id,
41
+ :adl_version => @result.adl_version,
42
+ :concept => @result.concept,
43
+ :original_language => original_language,
44
+ :translations => @result.translations,
45
+ :description => @result.description,
46
+ :definition => @result.definition,
47
+ :ontology => @result.ontology)
48
+ return archetype
49
+ end
50
+ end
51
+ end # of Parser
52
+ end # of OpenEHR
@@ -0,0 +1,1527 @@
1
+ require 'shared_token_grammar'
2
+ require 'openehr/assumed_library_types'
3
+ require 'openehr/am/archetype/constraint_model'
4
+ require 'openehr/am/openehr_profile/data_types/text'
5
+ require 'cadl_node'
6
+
7
+ module OpenEHR
8
+ module Parser
9
+ grammar CADL
10
+ # include OpenEHR::Parser::CADL
11
+
12
+ rule V_CADL_TEXT
13
+ c_complex_object '' {
14
+ def value
15
+ c_complex_object.value
16
+ end
17
+ }
18
+ / assertions '' {
19
+ def value
20
+ assertions.value
21
+ end
22
+ }
23
+ end
24
+
25
+ rule c_complex_object
26
+ head:c_complex_object_head SYM_MATCHES SYM_START_CBLOCK body:c_complex_object_body SYM_END_CBLOCK space {
27
+ def value(node = ArchetypeNode.new)
28
+ args = head.value
29
+ args[:occurrences] ||= OpenEHR::AssumedLibraryTypes::Interval.new(
30
+ :lower => 1, :upper => 1)
31
+ node.id = args[:node_id]
32
+ if node.root? or node.id.nil?
33
+ args[:path] = node.path
34
+ else
35
+ args[:path] = node.path + '[' + node.id + ']'
36
+ end
37
+ args.update body.value(node)
38
+ OpenEHR::AM::Archetype::ConstraintModel::CComplexObject.new(args)
39
+ end
40
+ }
41
+ / c_complex_object_head '' {
42
+ def value(node = ArchetypeNode.new)
43
+ args = c_complex_object_head.value
44
+ args[:occurrences] ||= OpenEHR::AssumedLibraryTypes::Interval.new(
45
+ :lower => 1, :upper => 1)
46
+ node.id = args[:node_id]
47
+ args[:path] = node.path
48
+ OpenEHR::AM::Archetype::ConstraintModel::CComplexObject.new(args)
49
+ end
50
+ }
51
+ end
52
+
53
+ rule c_complex_object_head
54
+ c_complex_object_id c_occurrences {
55
+ def value
56
+ args = c_complex_object_id.value
57
+ args[:occurrences] = c_occurrences.value
58
+ args
59
+ end
60
+ }
61
+ / c_complex_object_id '' {
62
+ def value
63
+ c_complex_object_id.value
64
+ end
65
+ }
66
+ end
67
+
68
+ rule c_complex_object_id
69
+ ti:type_identifier lo:V_LOCAL_TERM_CODE_REF space {
70
+ def value
71
+ {:rm_type_name => ti.value,
72
+ :node_id => lo.value}
73
+ end
74
+ }
75
+ / ti:type_identifier space {
76
+ def value
77
+ {:rm_type_name => ti.value}
78
+ end
79
+ }
80
+ end
81
+
82
+ rule c_complex_object_body
83
+ c_any '' {
84
+ def value(node)
85
+ Hash[:attributes => [c_any.value(node)]]
86
+ end
87
+ }
88
+ / c_attributes '' {
89
+ def value(node)
90
+ Hash[:attributes => c_attributes.value(node)]
91
+ end
92
+ }
93
+ end
94
+
95
+ rule c_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 '' {
113
+ def value(node)
114
+ c_primitive_object.value
115
+ end
116
+ }
117
+ / c_complex_object '' {
118
+ def value(node)
119
+ c_complex_object.value(node)
120
+ end
121
+ }
122
+ / c_code_phrase '' {
123
+ def value(node)
124
+ c_code_phrase.value(node)
125
+ end
126
+ }
127
+ / constraint_ref '' {
128
+ def value(node)
129
+ constraint_ref.value(node)
130
+ end
131
+ }
132
+ / archetype_slot '' {
133
+ def value(node)
134
+ archetype_slot.value(node)
135
+ end
136
+ }
137
+ / archetype_internal_ref '' {
138
+ def value(node = nil)
139
+ archetype_internal_ref.value(node)
140
+ end
141
+ }
142
+ / V_C_DOMAIN_TYPE '' {
143
+ def value(node = nil)
144
+ p elemetns
145
+ end
146
+ }
147
+ # / ERR_V_C_DOMAIN_TYPE
148
+ end
149
+
150
+ rule archetype_internal_ref
151
+ SYM_USE_NODE type_identifier c_occurrences object_path space {
152
+ def value(node)
153
+ OpenEHR::AM::Archetype::ConstraintModel::ArchetypeInternalRef.new(
154
+ :rm_type_name => type_identifier.value,
155
+ :occurrences => c_occurrences.value,
156
+ :path => node.path,
157
+ :target_path => object_path.value)
158
+ end
159
+ }
160
+ / SYM_USE_NODE type_identifier object_path space {
161
+ def value(node = nil)
162
+ OpenEHR::AM::Archetype::ConstraintModel::ArchetypeInternalRef.new(
163
+ :rm_type_name => type_identifier.value,
164
+ :occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
165
+ :lower => 1, :upper => 1),
166
+ :path => node.path,
167
+ :target_path => object_path.value)
168
+ end
169
+ }
170
+ end
171
+
172
+ rule archetype_slot
173
+ c_archetype_slot_head SYM_MATCHES SYM_START_CBLOCK c_includes c_excludes SYM_END_CBLOCK space {
174
+ def value(node)
175
+ args = c_archetype_slot_head.value(node)
176
+ args[:includes] = c_includes.value
177
+ args[:excludes] = c_excludes.value
178
+ OpenEHR::AM::Archetype::ConstraintModel::ArchetypeSlot.new(args)
179
+ end
180
+ }
181
+ / c_archetype_slot_head SYM_MATCHES SYM_START_CBLOCK c_includes SYM_END_CBLOCK space {
182
+ def value(node)
183
+ args = c_archetype_slot_head.value(node)
184
+ args[:includes] = c_includes.value
185
+ OpenEHR::AM::Archetype::ConstraintModel::ArchetypeSlot.new(args)
186
+ end
187
+ }
188
+ / c_archetype_slot_head SYM_MATCHES SYM_START_CBLOCK c_excludes SYM_END_CBLOCK space {
189
+ def value(node)
190
+ args = c_archetype_slot_head.value(node)
191
+ args[:excludes] = c_excludes.value
192
+ OpenEHR::AM::Archetype::ConstraintModel::ArchetypeSlot.new(args)
193
+ end
194
+ }
195
+ end
196
+
197
+ rule c_archetype_slot_head
198
+ c_archetype_slot_id white_space c_occurrences {
199
+ def value(node)
200
+ args = c_archetype_slot_id.value(node)
201
+ args[:occurrences] = c_occurrences.value
202
+ args
203
+ end
204
+ }
205
+ / c_archetype_slot_id white_space {
206
+ def value(node)
207
+ args = c_archetype_slot_id.value(node)
208
+ args[:occurrences] = OpenEHR::AssumedLibraryTypes::Interval.new(
209
+ :upper => 1, :lower => 1)
210
+ args
211
+ end
212
+ }
213
+ end
214
+
215
+ rule c_archetype_slot_id
216
+ SYM_ALLOW_ARCHETYPE type_identifier lt:V_LOCAL_TERM_CODE_REF {
217
+ def value(node)
218
+ {:rm_type_name => type_identifier.value,
219
+ :node_id => lt.value,
220
+ :path => node.path + "[#{lt.value}]"}
221
+ end
222
+ }
223
+ / SYM_ALLOW_ARCHETYPE type_identifier {
224
+ def value(node)
225
+ {:rm_type_name => type_identifier.value,
226
+ :path => node.path}
227
+ end
228
+ }
229
+ end
230
+
231
+ rule c_primitive_object
232
+ c_primitive '' {
233
+ def value
234
+ c_primitive.value
235
+ end
236
+ }
237
+ end
238
+
239
+ rule c_primitive
240
+ c_boolean '' {
241
+ def value
242
+ c_boolean.value
243
+ end
244
+ }
245
+ / c_date_time '' {
246
+ def value
247
+ c_date_time.value
248
+ end
249
+ }
250
+ / c_time '' {
251
+ def value
252
+ c_time.value
253
+ end
254
+ }
255
+ / c_date '' {
256
+ def value
257
+ c_date.value
258
+ end
259
+ }
260
+ / c_duration '' {
261
+ def value
262
+ c_duration.value
263
+ end
264
+ }
265
+ / c_real '' {
266
+ def value
267
+ c_real.value
268
+ end
269
+ }
270
+ / c_integer '' {
271
+ def value
272
+ c_integer.value
273
+ end
274
+ }
275
+ / c_string '' {
276
+ def value
277
+ c_string.value
278
+ end
279
+ }
280
+ end
281
+
282
+ rule c_any
283
+ '*' space {
284
+ def value(node)
285
+ OpenEHR::AM::Archetype::ConstraintModel::CAttribute.new(
286
+ :path => node.path, :rm_attribute_name => 'ANY',
287
+ :exsitence => OpenEHR::AssumedLibraryTypes::Interval.new(
288
+ :lower => 1, :upper => 1))
289
+ end
290
+ }
291
+ end
292
+
293
+ rule c_attributes
294
+ c_attribute more_attr:(c_attribute white_space)* {
295
+ def value(node)
296
+ attributes.map {|c| c.value(node)}
297
+ end
298
+
299
+ def attributes
300
+ [c_attribute] + more_attr.elements.map {|e| e.c_attribute}
301
+ end
302
+ }
303
+ end
304
+
305
+ rule c_attribute
306
+ c_attr_head c_attr_body {
307
+ def value(node)
308
+ val = c_attr_head.value(node)
309
+ child_node = ArchetypeNode.new(node)
310
+ child_node.path = val.path
311
+ val.children = c_attr_body.value(child_node)
312
+ val
313
+ end
314
+ }
315
+ end
316
+
317
+ rule c_attr_head
318
+ id:(V_ATTRIBUTE_IDENTIFIER) white_space c_existence c_cardinality {
319
+ def value(node)
320
+ if node.root?
321
+ path = node.path + id.value
322
+ elsif node.id
323
+ path = node.path + "[#{node.id}]/" + id.value
324
+ elsif
325
+ path = node.path + '/' + id.value
326
+ end
327
+ OpenEHR::AM::Archetype::ConstraintModel::CMultipleAttribute.new(
328
+ :rm_attribute_name => id.value,
329
+ :path => path,
330
+ :existence => c_existence.value,
331
+ :cardinality => c_cardinality.value)
332
+ end
333
+ }
334
+ / id:V_ATTRIBUTE_IDENTIFIER white_space c_existence {
335
+ def value(node)
336
+ if node.root?
337
+ path = node.path + id.value
338
+ elsif node.id
339
+ path = node.path + "[#{node.id}]/" + id.value
340
+ elsif
341
+ path = node.path + '/' + id.value
342
+ end
343
+ OpenEHR::AM::Archetype::ConstraintModel::CSingleAttribute.new(
344
+ :rm_attribute_name => id.value,
345
+ :path => path,
346
+ :existence => c_existence.value)
347
+ end
348
+ }
349
+ / id:(V_ATTRIBUTE_IDENTIFIER) white_space c_cardinality {
350
+ def value(node)
351
+ if node.root?
352
+ path = node.path + id.value
353
+ elsif node.id
354
+ path = node.path + "[#{node.id}]/" + id.value
355
+ elsif
356
+ path = node.path + '/' + id.value
357
+ end
358
+ OpenEHR::AM::Archetype::ConstraintModel::CMultipleAttribute.new(
359
+ :rm_attribute_name => id.value,
360
+ :path => path,
361
+ :cardinality => c_cardinality.value)
362
+ end
363
+ }
364
+ / id:(V_ATTRIBUTE_IDENTIFIER) white_space {
365
+ def value(node)
366
+ if node.root?
367
+ path = node.path + id.value
368
+ elsif node.id
369
+ path = node.path + "[#{node.id}]/" + id.value
370
+ elsif
371
+ path = node.path + '/' + id.value
372
+ end
373
+ OpenEHR::AM::Archetype::ConstraintModel::CSingleAttribute.new(
374
+ :rm_attribute_name => id.value, :path => path)
375
+ end
376
+ }
377
+ end
378
+
379
+ rule c_attr_body
380
+ SYM_MATCHES SYM_START_CBLOCK c_attr_values SYM_END_CBLOCK space {
381
+ def value(node)
382
+ c_attr_values.value(node)
383
+ end
384
+ }
385
+ end
386
+
387
+ rule c_attr_values
388
+ c_any '' {
389
+ def value(node)
390
+ [c_any.value(node)]
391
+ end
392
+ }
393
+ / c_object more_co:(c_object '')* {
394
+ def value(node)
395
+ c_objects.map {|c| c.value(node)}
396
+ end
397
+
398
+ def c_objects
399
+ [c_object] + more_co.elements.map {|e| e.c_object }
400
+ end
401
+ }
402
+ end
403
+
404
+ rule c_includes
405
+ SYM_INCLUDE assertions {
406
+ def value
407
+ assertions.value
408
+ end
409
+ }
410
+ end
411
+
412
+ rule c_excludes
413
+ SYM_EXCLUDE assertions {
414
+ def value
415
+ assertions.value
416
+ end
417
+ }
418
+ end
419
+
420
+ rule c_existence
421
+ SYM_EXISTENCE SYM_MATCHES SYM_START_CBLOCK existence_spec SYM_END_CBLOCK space {
422
+ def value
423
+ existence_spec.value
424
+ end
425
+ }
426
+ end
427
+
428
+ rule existence_spec
429
+ lo:V_INTEGER SYM_ELLIPSIS up:V_INTEGER {
430
+ def value
431
+ OpenEHR::AssumedLibraryTypes::Interval.new(:lower => lo.value, :upper => up.value)
432
+ end
433
+ }
434
+ / V_INTEGER '' {
435
+ def value
436
+ OpenEHR::AssumedLibraryTypes::Interval.new(:lower => V_INTEGER.value, :upper => V_INTEGER.value)
437
+ end
438
+ }
439
+ end
440
+
441
+ rule c_cardinality
442
+ SYM_CARDINALITY SYM_MATCHES SYM_START_CBLOCK cardinality_spec SYM_END_CBLOCK space {
443
+ def value
444
+ cardinality_spec.value
445
+ end
446
+ }
447
+ end
448
+
449
+ rule cardinality_spec
450
+ occurrence_spec ';' white_space SYM_ORDERED ';' white_space SYM_UNIQUE {
451
+ def value
452
+ OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
453
+ :interval => occurrence_spec.value,
454
+ :is_unique => true,
455
+ :is_orderd => true)
456
+ end
457
+ }
458
+ / occurrence_spec ';' white_space SYM_ORDERED {
459
+ def value
460
+ OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
461
+ :interval => occurrence_spec.value,
462
+ :is_orderd => true)
463
+ end
464
+ }
465
+ / occurrence_spec ';' white_space SYM_UNORDERD ';' white_space SYM_UNIQUE {
466
+ def value
467
+ OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
468
+ :interval => occurrence_spec.value,
469
+ :is_unique => true,
470
+ :is_orderd => false)
471
+ end
472
+ }
473
+ / occurrence_spec ';' white_space SYM_UNORDERD {
474
+ def value
475
+ OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
476
+ :interval => occurrence_spec.value,
477
+ :is_orderd => false)
478
+ end
479
+ }
480
+ / occurrence_spec SYM_UNIQUE ';' white_space SYM_ORDERED {
481
+ def value
482
+ OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
483
+ :interval => occurrence_spec.value,
484
+ :is_unique => true,
485
+ :is_orderd => true)
486
+ end
487
+ }
488
+ / occurrence_spec SYM_UNIQUE ';' white_space SYM_UNORDERD {
489
+ def value
490
+ OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
491
+ :interval => occurrence_spec.value,
492
+ :is_unique => true,
493
+ :is_ordered => false)
494
+ end
495
+ }
496
+ / occurrence_spec SYM_UNIQUE {
497
+ def value
498
+ OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
499
+ :interval => occurrence_spec.value,
500
+ :is_unique => true)
501
+ end
502
+ }
503
+ / occurrence_spec space {
504
+ def value
505
+ OpenEHR::AM::Archetype::ConstraintModel::Cardinality.new(
506
+ :interval => occurrence_spec.value)
507
+ end
508
+ }
509
+ end
510
+
511
+ rule c_occurrences
512
+ SYM_OCCURRENCES SYM_MATCHES SYM_START_CBLOCK occurrence_spec SYM_END_CBLOCK space {
513
+ def value
514
+ occurrence_spec.value
515
+ end
516
+ }
517
+ end
518
+
519
+ rule occurrence_spec
520
+ st:integer_value SYM_ELLIPSIS ed:cardinality_limit_value {
521
+ def value
522
+ if ed.value == '*'
523
+ OpenEHR::AssumedLibraryTypes::Interval.new(
524
+ :lower => st.value)
525
+ else
526
+ OpenEHR::AssumedLibraryTypes::Interval.new(
527
+ :lower => st.value,
528
+ :upper => ed.value)
529
+ end
530
+ end
531
+ }
532
+ / cardinality_limit_value '' {
533
+ def value
534
+ OpenEHR::AssumedLibraryTypes::Interval.new(
535
+ :lower => cardinality_limit_value.value,
536
+ :upper => cardinality_limit_value.value)
537
+ end
538
+ }
539
+ end
540
+
541
+ rule cardinality_limit_value
542
+ integer_value '' {
543
+ def value
544
+ text_value.to_i
545
+ end
546
+ }
547
+ / '*' {
548
+ def value
549
+ '*'
550
+ end
551
+ }
552
+ end
553
+
554
+ rule c_integer
555
+ c_integer_spec ';' white_space integer_value {
556
+ def value
557
+ args = c_integer_spec.value
558
+ args[:assumed_value] = integer_value.value
559
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CInteger.new(args)
560
+ end
561
+ }
562
+ / c_integer_spec '' {
563
+ def value
564
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CInteger.new(
565
+ c_integer_spec.value)
566
+ end
567
+ }
568
+ end
569
+
570
+ rule c_integer_spec
571
+ integer_list_value '' {
572
+ def value
573
+ {:list => integer_list_value.value}
574
+ end
575
+ }
576
+ / integer_interval_value '' {
577
+ def value
578
+ {:range => integer_interval_value.value}
579
+ end
580
+ }
581
+ / integer_value !'..' '' {
582
+ def value
583
+ {:list => [integer_value.value]}
584
+ end
585
+ }
586
+ / occurrence_spec '' {
587
+ def value
588
+ {:range => occurrence_spec.value}
589
+ end
590
+ }
591
+ end
592
+
593
+ rule c_real_spec
594
+ real_list_value '' {
595
+ def value
596
+ {:list => real_list_value.value}
597
+ end
598
+ }
599
+ / real_interval_value '' {
600
+ def value
601
+ {:range => real_interval_value.value}
602
+ end
603
+ }
604
+ / real_value '' {
605
+ def value
606
+ {:list => [real_value.value]}
607
+ end
608
+ }
609
+ end
610
+
611
+ rule c_real
612
+ c_real_spec ';' white_space real_value {
613
+ def value
614
+ args = c_real_spec.value
615
+ args[:assumed_value] = real_value.value
616
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CReal.new(args)
617
+ end
618
+ }
619
+ / c_real_spec '' {
620
+ def value
621
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CReal.new(
622
+ c_real_spec.value)
623
+ end
624
+ }
625
+ end
626
+
627
+ rule c_date_constraint
628
+ date_interval_value '' {
629
+ def value
630
+ {:range => date_interval_value.value}
631
+ end
632
+ }
633
+ / date_list_value '' {
634
+ def value
635
+ {:list => date_list_value.value}
636
+ end
637
+ }
638
+ / date_value '' {
639
+ def value
640
+ {:list => [date_value.value]}
641
+ end
642
+ }
643
+ / con:V_ISO8601_DATE_CONSTRAINT_PATTERN '' {
644
+ def value
645
+ {:pattern => con.text_value}
646
+ end
647
+ }
648
+ end
649
+
650
+ rule c_date
651
+ c_date_constraint ';' white_space date_value {
652
+ def value
653
+ args = c_date_constraint.value
654
+ args[:assumed_value] = date_value.value
655
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDate.new(
656
+ args)
657
+ end
658
+ }
659
+ / c_date_constraint '' {
660
+ def value
661
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDate.new(
662
+ c_date_constraint.value)
663
+ end
664
+ }
665
+ end
666
+
667
+ rule c_time_constraint
668
+ time_interval_value '' {
669
+ def value
670
+ {:range => time_interval_value.value}
671
+ end
672
+ }
673
+ / time_list_value '' {
674
+ def value
675
+ {:list => time_list_value.value}
676
+ end
677
+ }
678
+ / time_value '' {
679
+ def value
680
+ {:list => [time_value.value]}
681
+ end
682
+ }
683
+ / tc:V_ISO8601_TIME_CONSTRAINT_PATTERN '' {
684
+ def value
685
+ {:pattern => tc.text_value}
686
+ end
687
+ }
688
+ end
689
+
690
+ rule c_time
691
+ c_time_constraint ';' white_space time_value {
692
+ def value
693
+ args = c_time_constraint.value
694
+ args[:assumed_value] = time_value.value
695
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CTime.new(
696
+ args)
697
+ end
698
+ }
699
+ / c_time_constraint '' {
700
+ def value
701
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CTime.new(
702
+ c_time_constraint.value)
703
+ end
704
+ }
705
+ end
706
+
707
+ rule c_date_time_constraint
708
+ date_time_interval_value '' {
709
+ def value
710
+ {:range => date_time_interval_value.value}
711
+ end
712
+ }
713
+ / date_time_value '' {
714
+ def value
715
+ {:list => [date_time_value.value]}
716
+ end
717
+ }
718
+ / dtc:V_ISO8601_DATE_TIME_CONSTRAINT_PATTERN '' {
719
+ def value
720
+ {:pattern => dtc.text_value}
721
+ end
722
+ }
723
+ end
724
+
725
+ rule c_date_time
726
+ c_date_time_constraint ';' white_space date_time_value {
727
+ def value
728
+ args = c_date_time_constraint.value
729
+ args[:assumed_value] = date_time_value.value
730
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDateTime.new(
731
+ args)
732
+ end
733
+ }
734
+ / c_date_time_constraint '' {
735
+ def value
736
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDateTime.new(
737
+ c_date_time_constraint.value)
738
+ end
739
+ }
740
+ end
741
+
742
+ rule c_duration_constraint
743
+ duration_pattern '/' duration_interval_value '' {
744
+ def value
745
+ {:pattern => duration_pattern.value}
746
+ end
747
+ }
748
+ / duration_pattern '' {
749
+ def value
750
+ {:pattern => duration_pattern.value}
751
+ end
752
+ }
753
+ / duration_interval_value '' {
754
+ def value
755
+ {:range => duration_interval_value.value}
756
+ end
757
+ }
758
+ / duration_value '' {
759
+ def value
760
+ {:list => [duration_value.value]}
761
+ end
762
+ }
763
+ end
764
+
765
+ rule duration_pattern
766
+ dp:V_ISO8601_DURATION_CONSTRAINT_PATTERN '' {
767
+ def value
768
+ dp.text_value
769
+ end
770
+ }
771
+ end
772
+
773
+ rule c_duration
774
+ c_duration_constraint ';' white_space duration_value '' {
775
+ def value
776
+ args = c_duration_constraint.value
777
+ args[:assumed_value] = duration_value.value
778
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDuration.new(
779
+ args)
780
+ end
781
+ }
782
+ / c_duration_constraint '' {
783
+ def value
784
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CDuration.new(
785
+ c_duration_constraint.value)
786
+ end
787
+ }
788
+ end
789
+
790
+ rule c_string_spec
791
+ string_list_value ',' white_space SYM_LIST_CONTINUE {
792
+ def value
793
+ {:list => string_list_value.value}
794
+ end
795
+ }
796
+ / string_list_value '' {
797
+ def value
798
+ {:list => string_list_value.value}
799
+ end
800
+ }
801
+ / pat:V_REGEXP '' {
802
+ def value
803
+ {:pattern => pat.value}
804
+ end
805
+ }
806
+ / str:V_STRING '' {
807
+ def value
808
+ {:list => [str.value]}
809
+ end
810
+ }
811
+ end
812
+
813
+ rule c_string
814
+ c_string_spec white_space ';' white_space string_value {
815
+ def value
816
+ args = c_string_spec.value
817
+ args[:assumed_value] = string_value.value
818
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CString.new(
819
+ args)
820
+ end
821
+ }
822
+ / c_string_spec '' {
823
+ def value
824
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CString.new(
825
+ c_string_spec.value)
826
+ end
827
+ }
828
+ end
829
+
830
+ rule c_boolean_spec
831
+ SYM_TRUE ',' white_space SYM_FALSE {
832
+ def value
833
+ {:true_valid => true, :false_valid => true}
834
+ end
835
+ }
836
+ / SYM_TRUE white_space '' {
837
+ def value
838
+ {:true_valid => true, :false_valid => false}
839
+ end
840
+ }
841
+ / SYM_FALSE white_space ',' white_space SYM_TRUE {
842
+ def value
843
+ {:true_valid => true, :false_valid => true}
844
+ end
845
+ }
846
+ / SYM_FALSE white_space '' {
847
+ def value
848
+ {:false_valid => true, :true_valid => false}
849
+ end
850
+ }
851
+ end
852
+
853
+ rule c_boolean
854
+ c_boolean_spec ';' white_space boolean_value {
855
+ def value
856
+ args = c_boolean_spec.value
857
+ args[:assumed_value] = boolean_value.value
858
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CBoolean.new(
859
+ args)
860
+ end
861
+ }
862
+ / c_boolean_spec '' {
863
+ def value
864
+ OpenEHR::AM::Archetype::ConstraintModel::Primitive::CBoolean.new(
865
+ c_boolean_spec.value)
866
+ end
867
+ }
868
+ end
869
+
870
+ rule constraint_ref
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)
878
+ end
879
+ }
880
+ end
881
+
882
+ rule V_REGEXP
883
+ (('=' / '!') '~')? (('/' ('\/' / !'/' .)* '/') / ('^' (!'^' .)* '^') ) {
884
+ def value
885
+ text_value
886
+ end
887
+ }
888
+ end
889
+
890
+ rule code_string
891
+ NAMECHAR+ '' {
892
+ def value
893
+ text_value
894
+ end
895
+ }
896
+ end
897
+
898
+ rule code_string_list
899
+ first:code_string more:(',' space code_string)+ space {
900
+ def value
901
+ codes.map {|c| c.value}
902
+ end
903
+
904
+ def codes
905
+ [first] + more.elements.map {|e| e.code_string}
906
+ end
907
+ }
908
+ end
909
+
910
+ rule code_string_spec
911
+ code_string_list '' {
912
+ def value
913
+ code_string_list.value
914
+ end
915
+ }
916
+ / code_string '' {
917
+ def value
918
+ [code_string.value]
919
+ end
920
+ }
921
+ end
922
+
923
+ rule c_code_phrase
924
+ ti:V_TERM_CODE code_string_spec ';' space code_string ']' space {
925
+ def value(node)
926
+ ::OpenEHR::AM::OpenEHRProfile::DataTypes::Text::CCodePhrase.new(
927
+ :rm_type_name => 'CodePhrase',
928
+ :occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
929
+ :upper => 1, :lower => 1),
930
+ :terminology_id => ti.value, :code_list => code_string_spec.value,
931
+ :assumed_value => code_string.value,
932
+ :path => node.path)
933
+ end
934
+ }
935
+ / ti:V_TERM_CODE code_string_spec ']' space {
936
+ def value(node)
937
+ ::OpenEHR::AM::OpenEHRProfile::DataTypes::Text::CCodePhrase.new(
938
+ :rm_type_name => 'CodePhrase',
939
+ :occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
940
+ :upper => 1, :lower => 1),
941
+ :terminology_id => ti.value, :code_list => code_string_spec.value,
942
+ :path => node.path)
943
+ end
944
+ }
945
+ / ti:V_TERM_CODE ']' space {
946
+ def value(node)
947
+ ::OpenEHR::AM::OpenEHRProfile::DataTypes::Text::CCodePhrase.new(
948
+ :rm_type_name => 'CodePhrase',
949
+ :occurrences => OpenEHR::AssumedLibraryTypes::Interval.new(
950
+ :upper => 1, :lower => 1),
951
+ :terminology_id => ti.value, :code_list => [], :path => node.path)
952
+ end
953
+ }
954
+ end
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
+
1149
+ rule V_C_DOMAIN_TYPE
1150
+ '('? [A-Z] IDCHAR* ')'? [ \n]* '<' [^>]* '>'
1151
+ end
1152
+
1153
+ # assertion block
1154
+
1155
+ rule V_ASSERTION_TEXT
1156
+ assertions '' {
1157
+ def value
1158
+ assertions.value
1159
+ end
1160
+ }
1161
+ end
1162
+
1163
+ rule assertions
1164
+ assertion more_a:(assertion '')* {
1165
+ def value
1166
+ assertions.map {|a| a.value}
1167
+ end
1168
+
1169
+ def assertions
1170
+ [assertion] + more_a.elements.map {|a| a.assertion}
1171
+ end
1172
+ }
1173
+ end
1174
+
1175
+ rule assertion
1176
+ id:(any_identifier ':')? boolean_expression space {
1177
+ def value
1178
+ if (id && !id.empty?)
1179
+ OpenEHR::AM::Archetype::Assertion::Assertion.new(
1180
+ :tag => id.value, :expression => boolean_expression.value,
1181
+ :string_expression => id.text_value + boolean_expression.text_value)
1182
+ else
1183
+ OpenEHR::AM::Archetype::Assertion::Assertion.new(
1184
+ :expression => boolean_expression.value,
1185
+ :string_expression => boolean_expression.text_value)
1186
+ end
1187
+ end
1188
+ }
1189
+ end
1190
+
1191
+ rule boolean_expression
1192
+ boolean_node '' {
1193
+ def value
1194
+ boolean_node.value
1195
+ end
1196
+ }
1197
+ / boolean_leaf '' {
1198
+ def value
1199
+ boolean_leaf.value
1200
+ end
1201
+ }
1202
+ end
1203
+
1204
+ rule boolean_node
1205
+ SYM_EXISTS absolute_path {
1206
+ def value
1207
+ item = OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
1208
+ :type => 'String',
1209
+ :item => absolute_path.value,
1210
+ :reference_type => 'CONSTANT')
1211
+ OpenEHR::AM::Archetype::Assertion::ExprUnaryOperator.new(
1212
+ :type => 'Boolean',
1213
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_EXISTS,
1214
+ :operand => item,
1215
+ :precedence_overridden => false)
1216
+ end
1217
+ }
1218
+ / relative_path white_space SYM_MATCHES SYM_START_CBLOCK c_primitive SYM_END_CBLOCK {
1219
+ def value
1220
+ left_op = OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
1221
+ :type => 'String',
1222
+ :item => relative_path.value,
1223
+ :reference_type => 'Constant')
1224
+ right_op = OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
1225
+ :item => c_primitive.value,
1226
+ :type => c_primitive.value.type,
1227
+ :reference_type => 'Constant')
1228
+ op = OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_MATCHES
1229
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1230
+ :type => 'Boolean',
1231
+ :operator => op,
1232
+ :right_operand => right_op,
1233
+ :left_operand => left_op,
1234
+ :reference_type => 'Constraint')
1235
+ end
1236
+ }
1237
+ / SYM_NOT boolean_leaf '' {
1238
+ def value
1239
+ OpenEHR::AM::Archetype::Assertion::ExprUnaryOperator.new(
1240
+ :type => 'Boolean',
1241
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_NOT,
1242
+ :operand => boolean_leaf.value,
1243
+ :precedence_overridden => false)
1244
+ end
1245
+ }
1246
+ / arithmetic_leaf SYM_EQ arithmetic_expression {
1247
+ def value
1248
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1249
+ :type => 'Boolean',
1250
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_EQ,
1251
+ :left_operand => arithmetic_leaf.value,
1252
+ :right_operand => arithmetic_expression.value,
1253
+ :reference_type => 'Constraint')
1254
+ end
1255
+ }
1256
+ / arithmetic_leaf SYM_NE arithmetic_expression {
1257
+ def value
1258
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1259
+ :type => 'Boolean',
1260
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_NE,
1261
+ :left_operand => arithmetic_leaf.value,
1262
+ :right_operand => arithmetic_expression.value,
1263
+ :reference_type => 'Constraint')
1264
+ end
1265
+ }
1266
+ / arithmetic_leaf SYM_LT arithmetic_expression {
1267
+ def value
1268
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1269
+ :type => 'Boolean',
1270
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_LT,
1271
+ :left_operand => arithmetic_leaf.value,
1272
+ :right_operand => arithmetic_expression.value,
1273
+ :reference_type => 'Constraint')
1274
+ end
1275
+ }
1276
+ / arithmetic_leaf SYM_GT arithmetic_expression {
1277
+ def value
1278
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1279
+ :type => 'Boolean',
1280
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_GT,
1281
+ :left_operand => arithmetic_leaf.value,
1282
+ :right_operand => arithmetic_expression.value,
1283
+ :reference_type => 'Constraint')
1284
+ end
1285
+ }
1286
+ / arithmetic_leaf SYM_LE arithmetic_expression {
1287
+ def value
1288
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1289
+ :type => 'Boolean',
1290
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_LE,
1291
+ :left_operand => arithmetic_leaf.value,
1292
+ :right_operand => arithmetic_expression.value,
1293
+ :reference_type => 'Constraint')
1294
+ end
1295
+ }
1296
+ / arithmetic_leaf SYM_GE arithmetic_expression {
1297
+ def value
1298
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1299
+ :type => 'Boolean',
1300
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_GE,
1301
+ :left_operand => arithmetic_leaf.value,
1302
+ :right_operand => arithmetic_expression.value,
1303
+ :reference_type => 'Constraint')
1304
+ end
1305
+ }
1306
+ / boolean_leaf SYM_AND boolean_expression {
1307
+ def value
1308
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1309
+ :type => 'Boolean',
1310
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_AND,
1311
+ :left_operand => boolean_leaf.value,
1312
+ :right_operand => boolean_expression.value,
1313
+ :reference_type => 'Constraint')
1314
+ end
1315
+ }
1316
+ / boolean_leaf SYM_OR boolean_expression {
1317
+ def value
1318
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1319
+ :type => 'Boolean',
1320
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_OR,
1321
+ :left_operand => boolean_leaf.value,
1322
+ :right_operand => boolean_expression.value,
1323
+ :reference_type => 'Constraint')
1324
+ end
1325
+ }
1326
+ / boolean_leaf SYM_XOR boolean_expression {
1327
+ def value
1328
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1329
+ :type => 'Boolean',
1330
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_XOR,
1331
+ :left_operand => boolean_leaf.value,
1332
+ :right_operand => boolean_expression.value,
1333
+ :reference_type => 'Constraint')
1334
+ end
1335
+ }
1336
+ / boolean_leaf SYM_IMPLIES boolean_expression {
1337
+ def value
1338
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1339
+ :type => 'Boolean',
1340
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_IMPLIES,
1341
+ :left_operand => boolean_leaf.value,
1342
+ :right_operand => boolean_expression.value,
1343
+ :reference_type => 'Constraint')
1344
+ end
1345
+ }
1346
+ end
1347
+
1348
+ rule boolean_leaf
1349
+ '(' boolean_expression ')' {
1350
+ def value
1351
+ boolean_expression.value
1352
+ end
1353
+ }
1354
+ / SYM_TRUE '' {
1355
+ def value
1356
+ OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
1357
+ :type => 'Boolean',
1358
+ :item => true,
1359
+ :reference_type => 'CONSTANT')
1360
+ end
1361
+ }
1362
+ / SYM_FALSE '' {
1363
+ def value
1364
+ OpenEHR::AM::Archetype::Assertion::ExprLeaf.new(
1365
+ :type => 'Boolean',
1366
+ :item => false,
1367
+ :reference_type => 'CONSTANT')
1368
+ end
1369
+ }
1370
+ end
1371
+
1372
+ rule arithmetic_expression
1373
+ arithmetic_node '' {
1374
+ def value
1375
+ arithmetic_node.value
1376
+ end
1377
+ }
1378
+ / arithmetic_leaf '' {
1379
+ def value
1380
+ arithmetic_leaf.value
1381
+ end
1382
+ }
1383
+ end
1384
+
1385
+ rule arithmetic_node
1386
+ arithmetic_leaf '+' arithmetic_expression {
1387
+ def value
1388
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1389
+ :type => 'Boolean',
1390
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_PLUS,
1391
+ :left_operand => arithmetic_leaf.value,
1392
+ :right_operand => arithmetic_expression.value,
1393
+ :reference_type => 'Constraint')
1394
+ end
1395
+ }
1396
+ / arithmetic_leaf '-' arithmetic_expression {
1397
+ def value
1398
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1399
+ :type => 'Boolean',
1400
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_MINUS,
1401
+ :left_operand => arithmetic_leaf.value,
1402
+ :right_operand => arithmetic_expression.value,
1403
+ :reference_type => 'Constraint')
1404
+ end
1405
+ }
1406
+ / arithmetic_leaf '*' arithmetic_expression {
1407
+ def value
1408
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1409
+ :type => 'Boolean',
1410
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_MULTIPLY,
1411
+ :left_operand => arithmetic_leaf.value,
1412
+ :right_operand => arithmetic_expression.value,
1413
+ :reference_type => 'Constraint')
1414
+ end
1415
+ }
1416
+ / arithmetic_leaf '/' arithmetic_expression {
1417
+ def value
1418
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1419
+ :type => 'Boolean',
1420
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_DIVIDE,
1421
+ :left_operand => arithmetic_leaf.value,
1422
+ :right_operand => arithmetic_expression.value,
1423
+ :reference_type => 'Constraint')
1424
+ end
1425
+ }
1426
+ / arithmetic_leaf '^' arithmetic_expression {
1427
+ def value
1428
+ OpenEHR::AM::Archetype::Assertion::ExprBinaryOperator.new(
1429
+ :type => 'Boolean',
1430
+ :operator => OpenEHR::AM::Archetype::Assertion::OperatorKind::OP_EXP,
1431
+ :left_operand => arithmetic_leaf.value,
1432
+ :right_operand => arithmetic_expression.value,
1433
+ :reference_type => 'Constraint')
1434
+ end
1435
+ }
1436
+ end
1437
+
1438
+ rule arithmetic_leaf
1439
+ '(' arithmetic_expression ')' space {
1440
+ def value
1441
+ arithmetic_expression.value
1442
+ end
1443
+ }
1444
+ / integer_value '' {
1445
+ def value
1446
+ OpenEHR::AM::Archetype::ConstraintModel::ExprLeaf.new(
1447
+ :type => 'Integer',
1448
+ :item => integer_value.value,
1449
+ :reference_type => 'CONSTANT')
1450
+ end
1451
+ }
1452
+ / real_value '' {
1453
+ def value
1454
+ OpenEHR::AM::Archetype::ConstraintModel::ExprLeaf.new(
1455
+ :type => 'Real',
1456
+ :item => real_value.value,
1457
+ :reference_type => 'CONSTANT')
1458
+ end
1459
+ }
1460
+ / absolute_path space {
1461
+ def value
1462
+ OpenEHR::AM::Archetype::ConstraintModel::ExprLeaf.new(
1463
+ :type => 'String',
1464
+ :item => absolute_path.value,
1465
+ :reference_type => 'CONSTANT')
1466
+
1467
+ end
1468
+ }
1469
+ end
1470
+
1471
+ # path block
1472
+ rule object_path
1473
+ movable_path '' {
1474
+ def value
1475
+ movable_path.value
1476
+ end
1477
+ }
1478
+ / absolute_path '' {
1479
+ def value
1480
+ absolute_path.value
1481
+ end
1482
+ }
1483
+ / relative_path '' {
1484
+ def value
1485
+ relative_path.value
1486
+ end
1487
+ }
1488
+ end
1489
+
1490
+ rule movable_path
1491
+ SYM_MOVABLE_LEADER relative_path '' {
1492
+ def value
1493
+ text_value
1494
+ end
1495
+ }
1496
+ end
1497
+
1498
+ rule absolute_path
1499
+ '/' relative_path? '' {
1500
+ def value
1501
+ text_value
1502
+ end
1503
+ }
1504
+ end
1505
+
1506
+ rule relative_path
1507
+ path_segment ('/' path_segment)* '' {
1508
+ def value
1509
+ text_value
1510
+ end
1511
+ }
1512
+ end
1513
+
1514
+ rule path_segment
1515
+ V_ATTRIBUTE_IDENTIFIER V_LOCAL_TERM_CODE_REF? '' {
1516
+ def value
1517
+ text_value
1518
+ end
1519
+ }
1520
+ end
1521
+
1522
+ rule SYM_MOVABLE_LEADER
1523
+ '//'
1524
+ end
1525
+ end
1526
+ end
1527
+ end