open_ehr 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (253) hide show
  1. data/.document +5 -0
  2. data/Gemfile +14 -0
  3. data/Gemfile.lock +43 -0
  4. data/Guardfile +9 -0
  5. data/History.txt +4 -0
  6. data/Manifest.txt +16 -0
  7. data/PostInstall.txt +9 -0
  8. data/README.rdoc +66 -0
  9. data/Rakefile +49 -0
  10. data/VERSION +1 -0
  11. data/doc/README_rdoc.html +148 -0
  12. data/doc/created.rid +2 -0
  13. data/doc/images/brick.png +0 -0
  14. data/doc/images/brick_link.png +0 -0
  15. data/doc/images/bug.png +0 -0
  16. data/doc/images/bullet_black.png +0 -0
  17. data/doc/images/bullet_toggle_minus.png +0 -0
  18. data/doc/images/bullet_toggle_plus.png +0 -0
  19. data/doc/images/date.png +0 -0
  20. data/doc/images/find.png +0 -0
  21. data/doc/images/loadingAnimation.gif +0 -0
  22. data/doc/images/macFFBgHack.png +0 -0
  23. data/doc/images/package.png +0 -0
  24. data/doc/images/page_green.png +0 -0
  25. data/doc/images/page_white_text.png +0 -0
  26. data/doc/images/page_white_width.png +0 -0
  27. data/doc/images/plugin.png +0 -0
  28. data/doc/images/ruby.png +0 -0
  29. data/doc/images/tag_green.png +0 -0
  30. data/doc/images/wrench.png +0 -0
  31. data/doc/images/wrench_orange.png +0 -0
  32. data/doc/images/zoom.png +0 -0
  33. data/doc/index.html +54 -0
  34. data/doc/js/darkfish.js +116 -0
  35. data/doc/js/jquery.js +32 -0
  36. data/doc/js/quicksearch.js +114 -0
  37. data/doc/js/thickbox-compressed.js +10 -0
  38. data/doc/openehr_terminology.xml +2700 -0
  39. data/doc/rdoc.css +706 -0
  40. data/lib/#open_ehr.rb# +11 -0
  41. data/lib/open_ehr/am/archetype/archetype_description/archetype_description.rb +21 -0
  42. data/lib/open_ehr/am/archetype/assertion.rb +190 -0
  43. data/lib/open_ehr/am/archetype/constraint_model/primitive.rb +296 -0
  44. data/lib/open_ehr/am/archetype/constraint_model.rb +340 -0
  45. data/lib/open_ehr/am/archetype/ontology.rb +97 -0
  46. data/lib/open_ehr/am/archetype.rb +134 -0
  47. data/lib/open_ehr/am/open_ehr_profile/data_types/basic.rb +29 -0
  48. data/lib/open_ehr/am/open_ehr_profile/data_types/quantity.rb +19 -0
  49. data/lib/open_ehr/am/open_ehr_profile/data_types/text.rb +12 -0
  50. data/lib/open_ehr/am.rb +8 -0
  51. data/lib/open_ehr/assumed_library_types.rb +627 -0
  52. data/lib/open_ehr/parser/xml_perser.rb +13 -0
  53. data/lib/open_ehr/parser.rb +19 -0
  54. data/lib/open_ehr/rm/common/archetyped.rb +182 -0
  55. data/lib/open_ehr/rm/common/change_control.rb +332 -0
  56. data/lib/open_ehr/rm/common/directory.rb +29 -0
  57. data/lib/open_ehr/rm/common/generic.rb +216 -0
  58. data/lib/open_ehr/rm/common/resource.rb +154 -0
  59. data/lib/open_ehr/rm/common.rb +14 -0
  60. data/lib/open_ehr/rm/composition/content/entry.rb +246 -0
  61. data/lib/open_ehr/rm/composition/content/navigation.rb +31 -0
  62. data/lib/open_ehr/rm/composition/content.rb +22 -0
  63. data/lib/open_ehr/rm/composition.rb +103 -0
  64. data/lib/open_ehr/rm/data_structures/history.rb +117 -0
  65. data/lib/open_ehr/rm/data_structures/item_structure/representation.rb +63 -0
  66. data/lib/open_ehr/rm/data_structures/item_structure.rb +216 -0
  67. data/lib/open_ehr/rm/data_structures.rb +25 -0
  68. data/lib/open_ehr/rm/data_types/basic.rb +108 -0
  69. data/lib/open_ehr/rm/data_types/charset.lst +818 -0
  70. data/lib/open_ehr/rm/data_types/charset_extract.rb +24 -0
  71. data/lib/open_ehr/rm/data_types/encapsulated.rb +98 -0
  72. data/lib/open_ehr/rm/data_types/quantity/date_time.rb +229 -0
  73. data/lib/open_ehr/rm/data_types/quantity.rb +403 -0
  74. data/lib/open_ehr/rm/data_types/text.rb +168 -0
  75. data/lib/open_ehr/rm/data_types/time_specification.rb +75 -0
  76. data/lib/open_ehr/rm/data_types/uri.rb +82 -0
  77. data/lib/open_ehr/rm/data_types.rb +14 -0
  78. data/lib/open_ehr/rm/demographic.rb +269 -0
  79. data/lib/open_ehr/rm/ehr.rb +162 -0
  80. data/lib/open_ehr/rm/integration.rb +27 -0
  81. data/lib/open_ehr/rm/security.rb +12 -0
  82. data/lib/open_ehr/rm/support/assumed_types.rb +81 -0
  83. data/lib/open_ehr/rm/support/definition.rb +15 -0
  84. data/lib/open_ehr/rm/support/identification.rb +408 -0
  85. data/lib/open_ehr/rm/support/measurement.rb +17 -0
  86. data/lib/open_ehr/rm/support/terminology.rb +135 -0
  87. data/lib/open_ehr/rm/support.rb +14 -0
  88. data/lib/open_ehr/rm.rb +16 -0
  89. data/lib/open_ehr/serializer.rb +272 -0
  90. data/lib/open_ehr/terminology/open_ehr_terminology.rb +41 -0
  91. data/lib/open_ehr/terminology.rb +7 -0
  92. data/lib/open_ehr/writer.rb +12 -0
  93. data/lib/open_ehr.rb +11 -0
  94. data/spec/lib/open_ehr/am/archetype/archetype_spec.rb +98 -0
  95. data/spec/lib/open_ehr/am/archetype/assertion/assertion_spec.rb +60 -0
  96. data/spec/lib/open_ehr/am/archetype/assertion/assertion_variable_spec.rb +30 -0
  97. data/spec/lib/open_ehr/am/archetype/assertion/expr_binary_operator.rb +40 -0
  98. data/spec/lib/open_ehr/am/archetype/assertion/expr_item_spec.rb +28 -0
  99. data/spec/lib/open_ehr/am/archetype/assertion/expr_leaf_spec.rb +34 -0
  100. data/spec/lib/open_ehr/am/archetype/assertion/expr_operator_spec.rb +25 -0
  101. data/spec/lib/open_ehr/am/archetype/assertion/expr_unary_operator_spec.rb +26 -0
  102. data/spec/lib/open_ehr/am/archetype/assertion/operator_kind_spec.rb +110 -0
  103. data/spec/lib/open_ehr/am/archetype/constraint_model/archetype_constraint_spec.rb +56 -0
  104. data/spec/lib/open_ehr/am/archetype/constraint_model/archetype_internal_ref_spec.rb +36 -0
  105. data/spec/lib/open_ehr/am/archetype/constraint_model/archetype_slot_spec.rb +61 -0
  106. data/spec/lib/open_ehr/am/archetype/constraint_model/c_attribute_spec.rb +59 -0
  107. data/spec/lib/open_ehr/am/archetype/constraint_model/c_complex_object_spec.rb +39 -0
  108. data/spec/lib/open_ehr/am/archetype/constraint_model/c_defined_object_spec.rb +53 -0
  109. data/spec/lib/open_ehr/am/archetype/constraint_model/c_domain_type_spec.rb +25 -0
  110. data/spec/lib/open_ehr/am/archetype/constraint_model/c_multiple_attribute_spec.rb +29 -0
  111. data/spec/lib/open_ehr/am/archetype/constraint_model/c_object_spec.rb +61 -0
  112. data/spec/lib/open_ehr/am/archetype/constraint_model/c_primitive_object_spec.rb +33 -0
  113. data/spec/lib/open_ehr/am/archetype/constraint_model/c_reference_object_spec.rb +17 -0
  114. data/spec/lib/open_ehr/am/archetype/constraint_model/c_single_attribute_spec.rb +28 -0
  115. data/spec/lib/open_ehr/am/archetype/constraint_model/cardinality_spec.rb +68 -0
  116. data/spec/lib/open_ehr/am/archetype/constraint_model/constraint_ref_spec.rb +29 -0
  117. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_boolean_spec.rb +52 -0
  118. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_spec.rb +80 -0
  119. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_time_spec.rb +106 -0
  120. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_duration_spec.rb +69 -0
  121. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_integer_spec.rb +62 -0
  122. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_primitive_spec.rb +39 -0
  123. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_real_spec.rb +14 -0
  124. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_string_spec.rb +69 -0
  125. data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_time_spec.rb +79 -0
  126. data/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb +59 -0
  127. data/spec/lib/open_ehr/am/archetype/ontology/archetype_term_spec.rb +43 -0
  128. data/spec/lib/open_ehr/am/archetype/validity_kind_spec.rb +42 -0
  129. data/spec/lib/open_ehr/assumed_library_types/interval_spec.rb +140 -0
  130. data/spec/lib/open_ehr/assumed_library_types/iso8601_date_spec.rb +236 -0
  131. data/spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb +47 -0
  132. data/spec/lib/open_ehr/assumed_library_types/iso8601_duration_spec.rb +150 -0
  133. data/spec/lib/open_ehr/assumed_library_types/iso8601_time_spec.rb +234 -0
  134. data/spec/lib/open_ehr/assumed_library_types/iso8601_timezone_spec.rb +57 -0
  135. data/spec/lib/open_ehr/assumed_library_types/time_definitions_spec.rb +136 -0
  136. data/spec/lib/open_ehr/rm/common/archetyped/archetyped_spec.rb +50 -0
  137. data/spec/lib/open_ehr/rm/common/archetyped/feeder_audit_details_spec.rb +60 -0
  138. data/spec/lib/open_ehr/rm/common/archetyped/feeder_audit_spec.rb +51 -0
  139. data/spec/lib/open_ehr/rm/common/archetyped/link_spec.rb +42 -0
  140. data/spec/lib/open_ehr/rm/common/archetyped/locatable_spec.rb +89 -0
  141. data/spec/lib/open_ehr/rm/common/archetyped/pathable_spec.rb +42 -0
  142. data/spec/lib/open_ehr/rm/common/change_control/contribution_spec.rb +56 -0
  143. data/spec/lib/open_ehr/rm/common/change_control/imported_version_spec.rb +63 -0
  144. data/spec/lib/open_ehr/rm/common/change_control/original_version_spec.rb +71 -0
  145. data/spec/lib/open_ehr/rm/common/change_control/version_spec.rb +92 -0
  146. data/spec/lib/open_ehr/rm/common/change_control/versioned_object_spec.rb +285 -0
  147. data/spec/lib/open_ehr/rm/common/directory/folder_spec.rb +26 -0
  148. data/spec/lib/open_ehr/rm/common/generic/attestation_spec.rb +62 -0
  149. data/spec/lib/open_ehr/rm/common/generic/audit_details_spec.rb +51 -0
  150. data/spec/lib/open_ehr/rm/common/generic/participation_spec.rb +36 -0
  151. data/spec/lib/open_ehr/rm/common/generic/party_identified_spec.rb +64 -0
  152. data/spec/lib/open_ehr/rm/common/generic/party_proxy_spec.rb +18 -0
  153. data/spec/lib/open_ehr/rm/common/generic/party_related_spec.rb +24 -0
  154. data/spec/lib/open_ehr/rm/common/generic/revision_history_item_spec.rb +43 -0
  155. data/spec/lib/open_ehr/rm/common/generic/revision_history_spec.rb +45 -0
  156. data/spec/lib/open_ehr/rm/common/resource/authored_resource_spec.rb +68 -0
  157. data/spec/lib/open_ehr/rm/common/resource/resource_description_item_spec.rb +105 -0
  158. data/spec/lib/open_ehr/rm/common/resource/resource_description_spec.rb +74 -0
  159. data/spec/lib/open_ehr/rm/common/resource/translation_details_spec.rb +35 -0
  160. data/spec/lib/open_ehr/rm/composition/composition_spec.rb +92 -0
  161. data/spec/lib/open_ehr/rm/composition/content/content_item_spec.rb +14 -0
  162. data/spec/lib/open_ehr/rm/composition/content/entry/action_spec.rb +69 -0
  163. data/spec/lib/open_ehr/rm/composition/content/entry/activity_spec.rb +61 -0
  164. data/spec/lib/open_ehr/rm/composition/content/entry/admin_entry_spec.rb +38 -0
  165. data/spec/lib/open_ehr/rm/composition/content/entry/care_entry_spec.rb +37 -0
  166. data/spec/lib/open_ehr/rm/composition/content/entry/entry_spec.rb +88 -0
  167. data/spec/lib/open_ehr/rm/composition/content/entry/evaluation_spec.rb +37 -0
  168. data/spec/lib/open_ehr/rm/composition/content/entry/instruction_details_spec.rb +51 -0
  169. data/spec/lib/open_ehr/rm/composition/content/entry/instruction_spec.rb +62 -0
  170. data/spec/lib/open_ehr/rm/composition/content/entry/ism_transition_spec.rb +46 -0
  171. data/spec/lib/open_ehr/rm/composition/content/entry/observation_spec.rb +45 -0
  172. data/spec/lib/open_ehr/rm/composition/content/navigation/section_spec.rb +32 -0
  173. data/spec/lib/open_ehr/rm/composition/event_context_spec.rb +88 -0
  174. data/spec/lib/open_ehr/rm/data_structures/data_structure_spec.rb +21 -0
  175. data/spec/lib/open_ehr/rm/data_structures/history/event_spec.rb +44 -0
  176. data/spec/lib/open_ehr/rm/data_structures/history/history_spec.rb +67 -0
  177. data/spec/lib/open_ehr/rm/data_structures/history/interval_event_spec.rb +43 -0
  178. data/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb +53 -0
  179. data/spec/lib/open_ehr/rm/data_structures/item_structure/item_single_spec.rb +29 -0
  180. data/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb +147 -0
  181. data/spec/lib/open_ehr/rm/data_structures/item_structure/item_tree_spec.rb +48 -0
  182. data/spec/lib/open_ehr/rm/data_structures/item_structure/representation/cluster_spec.rb +26 -0
  183. data/spec/lib/open_ehr/rm/data_structures/item_structure/representation/element_spec.rb +22 -0
  184. data/spec/lib/open_ehr/rm/data_types/basic/data_value_spec.rb +17 -0
  185. data/spec/lib/open_ehr/rm/data_types/basic/dv_boolean_spec.rb +29 -0
  186. data/spec/lib/open_ehr/rm/data_types/basic/dv_identifier_spec.rb +108 -0
  187. data/spec/lib/open_ehr/rm/data_types/basic/dv_state_spec.rb +44 -0
  188. data/spec/lib/open_ehr/rm/data_types/encapsulated/dv_encapsulated_spec.rb +42 -0
  189. data/spec/lib/open_ehr/rm/data_types/encapsulated/dv_multimedia_spec.rb +79 -0
  190. data/spec/lib/open_ehr/rm/data_types/encapsulated/dv_parsable_spec.rb +34 -0
  191. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_spec.rb +64 -0
  192. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb +25 -0
  193. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_tempral_spec.rb +24 -0
  194. data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_time_spec.rb +37 -0
  195. data/spec/lib/open_ehr/rm/data_types/quantity/dv_absolute_quantity_spec.rb +35 -0
  196. data/spec/lib/open_ehr/rm/data_types/quantity/dv_amount_spec.rb +105 -0
  197. data/spec/lib/open_ehr/rm/data_types/quantity/dv_count_spec.rb +12 -0
  198. data/spec/lib/open_ehr/rm/data_types/quantity/dv_interval_spec.rb +17 -0
  199. data/spec/lib/open_ehr/rm/data_types/quantity/dv_ordered_spec.rb +60 -0
  200. data/spec/lib/open_ehr/rm/data_types/quantity/dv_ordinal_spec.rb +74 -0
  201. data/spec/lib/open_ehr/rm/data_types/quantity/dv_proportion_spec.rb +162 -0
  202. data/spec/lib/open_ehr/rm/data_types/quantity/dv_quantified_spec.rb +36 -0
  203. data/spec/lib/open_ehr/rm/data_types/quantity/dv_quantity_spec.rb +78 -0
  204. data/spec/lib/open_ehr/rm/data_types/quantity/proportion_kind_spec.rb +24 -0
  205. data/spec/lib/open_ehr/rm/data_types/quantity/reference_range_spec.rb +43 -0
  206. data/spec/lib/open_ehr/rm/data_types/text/code_phrase_spec.rb +23 -0
  207. data/spec/lib/open_ehr/rm/data_types/text/dv_paragraph_spec.rb +13 -0
  208. data/spec/lib/open_ehr/rm/data_types/text/dv_text_spec.rb +57 -0
  209. data/spec/lib/open_ehr/rm/data_types/text/term_mapping_spec.rb +59 -0
  210. data/spec/lib/open_ehr/rm/data_types/uri/dv_ehr_uri_spec.rb +21 -0
  211. data/spec/lib/open_ehr/rm/data_types/uri/dv_uri_spec.rb +36 -0
  212. data/spec/lib/open_ehr/rm/demographic/actor_spec.rb +79 -0
  213. data/spec/lib/open_ehr/rm/demographic/address_spec.rb +33 -0
  214. data/spec/lib/open_ehr/rm/demographic/capability_spec.rb +37 -0
  215. data/spec/lib/open_ehr/rm/demographic/contact_spec.rb +45 -0
  216. data/spec/lib/open_ehr/rm/demographic/party_identity_spec.rb +32 -0
  217. data/spec/lib/open_ehr/rm/demographic/party_relationship_spec.rb +84 -0
  218. data/spec/lib/open_ehr/rm/demographic/party_spec.rb +133 -0
  219. data/spec/lib/open_ehr/rm/demographic/role_spec.rb +58 -0
  220. data/spec/lib/open_ehr/rm/ehr/ehr_access_spec.rb +33 -0
  221. data/spec/lib/open_ehr/rm/ehr/ehr_spec.rb +139 -0
  222. data/spec/lib/open_ehr/rm/ehr/ehr_status_spec.rb +52 -0
  223. data/spec/lib/open_ehr/rm/ehr/versioned_composition_spec.rb +33 -0
  224. data/spec/lib/open_ehr/rm/integration/generic_entry_spec.rb +31 -0
  225. data/spec/lib/open_ehr/rm/support/identification/access_group_ref_spec.rb +19 -0
  226. data/spec/lib/open_ehr/rm/support/identification/archetype_id_spec.rb +152 -0
  227. data/spec/lib/open_ehr/rm/support/identification/generic_id_spec.rb +33 -0
  228. data/spec/lib/open_ehr/rm/support/identification/hier_object_id_spec.rb +12 -0
  229. data/spec/lib/open_ehr/rm/support/identification/internet_id_spec.rb +12 -0
  230. data/spec/lib/open_ehr/rm/support/identification/iso_oid_spec.rb +12 -0
  231. data/spec/lib/open_ehr/rm/support/identification/locatable_ref_spec.rb +34 -0
  232. data/spec/lib/open_ehr/rm/support/identification/object_id_spec.rb +24 -0
  233. data/spec/lib/open_ehr/rm/support/identification/object_ref_spec.rb +33 -0
  234. data/spec/lib/open_ehr/rm/support/identification/object_version_id_spec.rb +60 -0
  235. data/spec/lib/open_ehr/rm/support/identification/party_ref_spec.rb +29 -0
  236. data/spec/lib/open_ehr/rm/support/identification/template_id_spec.rb +12 -0
  237. data/spec/lib/open_ehr/rm/support/identification/terminology_id_spec.rb +33 -0
  238. data/spec/lib/open_ehr/rm/support/identification/uid_based_id_spec.rb +50 -0
  239. data/spec/lib/open_ehr/rm/support/identification/uid_spec.rb +29 -0
  240. data/spec/lib/open_ehr/rm/support/identification/version_tree_id_spec.rb +104 -0
  241. data/spec/lib/open_ehr/rm/support/measurement_service_spec.rb +7 -0
  242. data/spec/lib/open_ehr/rm/support/terminology_service_spec.rb +24 -0
  243. data/spec/lib/open_ehr/serializer/adl-test-entry.most_minimal.test.adl +20 -0
  244. data/spec/lib/open_ehr/serializer/adl_serializer_spec.rb +47 -0
  245. data/spec/lib/open_ehr/serializer/openEHR-EHR-SECTION.test.v1.adl +38 -0
  246. data/spec/lib/open_ehr/serializer/openEHR-EHR-SECTION.test.v1.xml +58 -0
  247. data/spec/lib/open_ehr/serializer/sample_archetype_spec.rb +44 -0
  248. data/spec/lib/open_ehr/serializer/xml_serializer_spec.rb +49 -0
  249. data/spec/lib/open_ehr/terminology/open_ehr_terminology_spec.rb +40 -0
  250. data/spec/rcov.opts +1 -0
  251. data/spec/spec.opts +5 -0
  252. data/spec/spec_helper.rb +54 -0
  253. metadata +401 -0
@@ -0,0 +1,190 @@
1
+ module OpenEHR
2
+ module AM
3
+ module Archetype
4
+ module Assertion
5
+ class Assertion
6
+ attr_reader :expression, :tag
7
+ attr_accessor :string_expression, :variables
8
+
9
+ def initialize(args = { })
10
+ self.expression = args[:expression]
11
+ self.tag = args[:tag]
12
+ self.string_expression = args[:string_expression]
13
+ self.variables = args[:variables]
14
+ end
15
+
16
+ def expression=(expression)
17
+ if expression.nil? or expression.type.upcase != 'BOOLEAN'
18
+ raise ArgumentError, 'invalid expression'
19
+ end
20
+ @expression = expression
21
+ end
22
+
23
+ def tag=(tag)
24
+ if !tag.nil? && tag.empty?
25
+ raise ArgumentError, 'tag should not be empty'
26
+ end
27
+ @tag = tag
28
+ end
29
+ end
30
+
31
+ class ExprItem
32
+ attr_reader :type
33
+
34
+ def initialize(args = { })
35
+ self.type = args[:type]
36
+ end
37
+
38
+ def type=(type)
39
+ if type.nil? or type.empty?
40
+ raise ArgumentError, 'type is mandatory'
41
+ end
42
+ @type = type
43
+ end
44
+ end
45
+
46
+ class ExprLeaf < ExprItem
47
+ attr_reader :item, :reference_type
48
+
49
+ def initialize(args = { })
50
+ super
51
+ self.item = args[:item]
52
+ self.reference_type = args[:reference_type]
53
+ end
54
+
55
+ def item=(item)
56
+ if item.nil?
57
+ raise ArgumentError, 'item is mandatory'
58
+ end
59
+ @item = item
60
+ end
61
+
62
+ def reference_type=(reference_type)
63
+ if reference_type.nil?
64
+ raise ArgumentError, 'reference_type is mandatory'
65
+ end
66
+ @reference_type = reference_type
67
+ end
68
+ end
69
+
70
+ class ExprOperator < ExprItem
71
+ attr_accessor :operator, :precedence_overridden
72
+
73
+ def initialize(args = { })
74
+ super
75
+ self.operator = args[:operator]
76
+ self.precedence_overridden = args[:precedence_overridden]
77
+ end
78
+ end
79
+
80
+ class ExprUnaryOperator < ExprOperator
81
+ attr_reader :operand
82
+
83
+ def initialize(args = { })
84
+ super
85
+ self.operand = args[:operand]
86
+ end
87
+
88
+ def operand=(operand)
89
+ if operand.nil?
90
+ raise ArgumentError, 'operand is mandatory'
91
+ end
92
+ @operand = operand
93
+ end
94
+ end
95
+
96
+ class ExprBinaryOperator < ExprOperator
97
+ attr_reader :right_operand, :left_operand
98
+
99
+ def initialize(args = { })
100
+ super
101
+ self.right_operand = args[:right_operand]
102
+ self.left_operand = args[:left_operand]
103
+ end
104
+
105
+ def right_operand=(right_operand)
106
+ if right_operand.nil?
107
+ raise ArgumentError, 'right_operand is mandatory'
108
+ end
109
+ @right_operand = right_operand
110
+ end
111
+
112
+ def left_operand=(left_operand)
113
+ if left_operand.nil?
114
+ raise ArgumentError, 'left_operand is mandatory'
115
+ end
116
+ @left_operand = left_operand
117
+ end
118
+ end
119
+
120
+ class AssertionVariable
121
+ attr_reader :name, :definition
122
+
123
+ def initialize(args = { })
124
+ self.name = args[:name]
125
+ self.definition = args[:definition]
126
+ end
127
+
128
+ def name=(name)
129
+ if name.nil?
130
+ raise ArgumentError, 'name is mandatory'
131
+ end
132
+ @name = name
133
+ end
134
+
135
+ def definition=(definition)
136
+ if definition.nil?
137
+ raise ArgumentError, 'definition is mandatory'
138
+ end
139
+ @definition = definition
140
+ end
141
+ end
142
+
143
+ class OperatorKind
144
+ OP_EQ = 2001
145
+ OP_NE = 2002
146
+ OP_LE = 2003
147
+ OP_LT = 2004
148
+ OP_GE = 2005
149
+ OP_GT = 2006
150
+ OP_MATCHES = 2007
151
+
152
+ OP_NOT = 2010
153
+ OP_AND = 2011
154
+ OP_OR = 2012
155
+ OP_XOR = 2013
156
+ OP_IMPLIES = 2014
157
+ OP_FOR_ALL = 2015
158
+ OP_EXISTS = 2016
159
+
160
+ OP_PLUS = 2020
161
+ OP_MINUS = 2021
162
+ OP_MULTIPLY = 2022
163
+ OP_DIVIDE = 2023
164
+ OP_EXP = 2024
165
+
166
+ attr_reader :value
167
+
168
+ def initialize(args = { })
169
+ self.value = args[:value]
170
+ end
171
+
172
+ def value=(value)
173
+ unless OperatorKind.valid_operator? value
174
+ raise ArgumentError, 'invalid value'
175
+ end
176
+ @value = value
177
+ end
178
+
179
+ def self.valid_operator?(value)
180
+ if value >= OP_EQ && value <= OP_EXP
181
+ return true
182
+ else
183
+ return false
184
+ end
185
+ end
186
+ end
187
+ end # of Assetion
188
+ end # of Archtype
189
+ end #of AM
190
+ end # of OpenEHR
@@ -0,0 +1,296 @@
1
+ # Ticket #71
2
+ module OpenEHR
3
+ module AM
4
+ module Archetype
5
+ module ConstraintModel
6
+ module Primitive
7
+ class CPrimitive
8
+ attr_reader :default_value
9
+ attr_accessor :assumed_value
10
+
11
+ def initialize(args = { })
12
+ self.default_value = args[:default_value]
13
+ self.assumed_value = args[:assumed_value]
14
+ end
15
+
16
+ def default_value=(default_value)
17
+ if default_value.nil?
18
+ raise ArgumentError, 'default_value is mandatory'
19
+ end
20
+ @default_value = default_value
21
+ end
22
+
23
+ def has_assumed_value?
24
+ return !assumed_value.nil?
25
+ end
26
+ end
27
+
28
+ class CBoolean < CPrimitive
29
+ attr_reader :true_valid, :false_valid
30
+
31
+ def initialize(args = { })
32
+ binary_consistency(args[:true_valid], args[:false_valid])
33
+ @true_valid = args[:true_valid]
34
+ @false_valid = args[:false_valid]
35
+ super(args)
36
+ end
37
+
38
+ def default_value=(default_value)
39
+ super
40
+ default_value_consistency(default_value)
41
+ end
42
+
43
+ def true_valid=(true_valid)
44
+ binary_consistency(true_valid, @false_valid)
45
+ @true_valid = true_valid
46
+ end
47
+
48
+ def false_valid=(false_valid)
49
+ binary_consistency(@true_valid, false_valid)
50
+ @false_valid = false_valid
51
+ end
52
+
53
+ def true_valid?
54
+ return @true_valid
55
+ end
56
+
57
+ def false_valid?
58
+ return @false_valid
59
+ end
60
+
61
+ private
62
+ def binary_consistency(true_valid, false_valid)
63
+ if (true_valid == false) && (false_valid == false)
64
+ raise ArgumentError, 'true_valid or false_valid should be true'
65
+ end
66
+ end
67
+
68
+ def default_value_consistency(default_value)
69
+ if (!@true_valid && default_value) || (!@false_valid && !default_value)
70
+ raise ArgumentError, 'default value inconsistency'
71
+ end
72
+ end
73
+ end
74
+
75
+ class CString < CPrimitive
76
+ attr_reader :pattern, :list
77
+
78
+ def initialize(args = { })
79
+ super
80
+ consistency(args[:pattern], args[:list])
81
+ @pattern = args[:pattern]
82
+ @list = args[:list]
83
+ end
84
+
85
+ def pattern=(pattern)
86
+ consistency(pattern, @list)
87
+ @pattern = pattern
88
+ end
89
+
90
+ def list=(list)
91
+ consistency(@pattern, list)
92
+ @list = list
93
+ end
94
+
95
+ private
96
+ def consistency(pattern, list)
97
+ if pattern.nil? == list.nil?
98
+ raise ArgumentError, 'consistency invaild'
99
+ end
100
+ end
101
+ end
102
+
103
+ class CInteger < CPrimitive
104
+ attr_reader :list, :range
105
+
106
+ def initialize(args = { })
107
+ super
108
+ consistency(args[:list], args[:range])
109
+ @list = args[:list]
110
+ @range = args[:range]
111
+ end
112
+
113
+ def list=(list)
114
+ consistency(list, @range)
115
+ @list = list
116
+ end
117
+
118
+ def range=(range)
119
+ consistency(@list, range)
120
+ @range = range
121
+ end
122
+
123
+ private
124
+ def consistency(list, range)
125
+ if list.nil? == range.nil?
126
+ raise ArgumentError, 'consistency invalid'
127
+ end
128
+ end
129
+ end
130
+
131
+ class CReal < CInteger
132
+
133
+ end
134
+
135
+ module CDateModule
136
+ attr_accessor :range, :timezone_validity
137
+ attr_reader :month_validity, :day_validity
138
+
139
+ def month_validity=(month_validity)
140
+ if (month_validity == ValidityKind::OPTIONAL &&
141
+ !(@day_validity == ValidityKind::OPTIONAL ||
142
+ @day_validity == ValidityKind::DISALLOWED)) ||
143
+ (month_validity == ValidityKind::DISALLOWED &&
144
+ !(@day_validity == ValidityKind::DISALLOWED))
145
+ raise ArgumentError, 'month validity disallowed'
146
+ end
147
+ @month_validity = month_validity
148
+ end
149
+
150
+ def day_validity=(day_validity)
151
+ @day_validity = day_validity
152
+ end
153
+
154
+ def validity_is_range?
155
+ return !@range.nil?
156
+ end
157
+
158
+ private
159
+ def consistency_validity(month_validity, day_validity)
160
+ end
161
+ end
162
+
163
+ class CDate < CPrimitive
164
+ include CDateModule
165
+
166
+ def initialize(args = { })
167
+ super(args)
168
+ self.range = args[:range]
169
+ self.timezone_validity = args[:timezone_validity]
170
+ self.day_validity = args[:day_validity]
171
+ self.month_validity = args[:month_validity]
172
+ end
173
+ end
174
+
175
+ module CTimeModule
176
+ attr_accessor :range
177
+ attr_reader :minute_validity, :second_validity,
178
+ :millisecond_validity
179
+
180
+ def minute_validity=(minute_validity)
181
+ if (minute_validity == ValidityKind::OPTIONAL &&
182
+ @second_validity == ValidityKind::MANDATORY) ||
183
+ (minute_validity == ValidityKind::DISALLOWED &&
184
+ @second_validity != ValidityKind::DISALLOWED)
185
+ raise ArgumentError, 'minute_validity is invalid'
186
+ end
187
+ @minute_validity = minute_validity
188
+ end
189
+
190
+ def second_validity=(second_validity)
191
+ if (second_validity == ValidityKind::OPTIONAL &&
192
+ @millisecond_validity == ValidityKind::MANDATORY) ||
193
+ (second_validity == ValidityKind::DISALLOWED &&
194
+ @millisecond_validity != ValidityKind::DISALLOWED)
195
+ raise ArgumentError, 'second_validity is invalid'
196
+ end
197
+ @second_validity = second_validity
198
+ end
199
+
200
+ def millisecond_validity=(millisecond_validity)
201
+ @millisecond_validity = millisecond_validity
202
+ end
203
+
204
+ def validity_is_range?
205
+ return !@range.nil?
206
+ end
207
+ end
208
+
209
+ class CTime < CPrimitive
210
+ include CTimeModule
211
+
212
+ def initialize(args = { })
213
+ super
214
+ self.range = args[:range]
215
+ self.millisecond_validity = args[:millisecond_validity]
216
+ self.second_validity = args[:second_validity]
217
+ self.minute_validity = args[:minute_validity]
218
+ end
219
+ end
220
+
221
+ class CDateTime < CPrimitive
222
+ include CDateModule, CTimeModule
223
+ attr_reader :hour_validity
224
+
225
+ def initialize(args = { })
226
+ super
227
+ self.timezone_validity = args[:timezone_validity]
228
+ self.millisecond_validity = args[:millisecond_validity]
229
+ self.second_validity = args[:second_validity]
230
+ self.minute_validity = args[:minute_validity]
231
+ self.hour_validity = args[:hour_vaildity]
232
+ self.day_validity = args[:day_validity]
233
+ self.month_validity = args[:day_validity]
234
+ end
235
+
236
+ def hour_validity=(hour_validity)
237
+ if (hour_validity == ValidityKind::DISALLOWED &&
238
+ @minute_validity != ValidityKind::DISALLOWED) ||
239
+ (hour_validity == ValidityKind::OPTIONAL &&
240
+ !(@minute_validity == ValidityKind::OPTIONAL ||
241
+ @minute_validity == ValidityKind::DISALLOWED))
242
+ raise ArgumentError, 'hour_validity is invalid'
243
+ end
244
+ @hour_validity = hour_validity
245
+ end
246
+
247
+ def day_validity=(day_validity)
248
+ if (day_validity == ValidityKind::DISALLOWED &&
249
+ @hour_validity != ValidityKind::DISALLOWED) ||
250
+ (day_validity == ValidityKind::OPTIONAL &&
251
+ !(@hour_validity == ValidityKind::OPTIONAL ||
252
+ @hour_validity == ValidityKind::DISALLOWED))
253
+ raise ArgumentError, 'day_validity is invaild'
254
+ end
255
+ @day_validity = day_validity
256
+ end
257
+ end
258
+
259
+ class CDuration < CPrimitive
260
+ attr_reader :range
261
+ attr_accessor :years_allowed, :months_allowed, :weeks_allowed,
262
+ :days_allowed, :hours_allowed, :minutes_allowed,
263
+ :seconds_allowed, :fractional_seconds_allowed
264
+
265
+ def initialize(args = { })
266
+ super
267
+ self.fractional_seconds_allowed = args[:fractional_seconds_allowed]
268
+ self.seconds_allowed = args[:seconds_allowed]
269
+ self.minutes_allowed = args[:minutes_allowed]
270
+ self.hours_allowed = args[:hours_allowed]
271
+ self.days_allowed = args[:days_allowed]
272
+ self.months_allowed = args[:months_allowed]
273
+ self.weeks_allowed = args[:weeks_allowed]
274
+ self.years_allowed = args[:years_allowed]
275
+ self.range = args[:range]
276
+ end
277
+
278
+ def range=(range)
279
+ if range.nil? && !(@years_allowed ||
280
+ @months_allowed ||
281
+ @weeks_allowed ||
282
+ @days_allowed ||
283
+ @hours_allowed ||
284
+ @minutes_allowed ||
285
+ @seconds_allowed ||
286
+ @fractional_seconds_allowed)
287
+ raise ArgumentError, 'invalid range'
288
+ end
289
+ @range = range
290
+ end
291
+ end
292
+ end # of Primitive
293
+ end # of CostraintModel
294
+ end # of Archetype
295
+ end # of AM
296
+ end # of OpenEHR