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,103 @@
1
+ # rm::composition
2
+ # composition module
3
+ # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109005072243_448526_217Report.html
4
+ # refs #79
5
+ include OpenEHR::RM::Common::Archetyped
6
+ module OpenEHR
7
+ module RM
8
+ module Composition
9
+ class Composition < Locatable
10
+ attr_reader :language, :category, :territory, :composer
11
+ attr_accessor :content, :context
12
+
13
+ def initialize(args = { })
14
+ super(args)
15
+ self.language = args[:language]
16
+ self.category = args[:category]
17
+ self.territory = args[:territory]
18
+ self.composer = args[:composer]
19
+ self.content = args[:content]
20
+ self.context = args[:context]
21
+ end
22
+
23
+ def language=(language)
24
+ if language.nil?
25
+ raise ArgumentError, 'language is mandatory'
26
+ end
27
+ @language = language
28
+ end
29
+
30
+ def category=(category)
31
+ if category.nil?
32
+ raise ArgumentError, 'category is mandatory'
33
+ end
34
+ @category = category
35
+ end
36
+
37
+ def territory=(territory)
38
+ if territory.nil?
39
+ raise ArgumentError, 'territory is mandatory'
40
+ end
41
+ @territory = territory
42
+ end
43
+
44
+ def composer=(composer)
45
+ if composer.nil?
46
+ raise ArgumentError, 'composer is mandatory'
47
+ end
48
+ @composer = composer
49
+ end
50
+
51
+ def is_persistent?
52
+ return category.value == 'persistent'
53
+ end
54
+ end
55
+
56
+ class EventContext < Pathable
57
+ attr_reader :start_time, :setting, :participations, :location
58
+ attr_accessor :end_time, :other_context
59
+
60
+ def initialize(args = { })
61
+ super(args)
62
+ self.start_time = args[:start_time]
63
+ self.setting = args[:setting]
64
+ self.end_time = args[:end_time]
65
+ self.participations = args[:participations]
66
+ self.location = args[:location]
67
+ self.other_context = args[:other_context]
68
+ end
69
+
70
+ def start_time=(start_time)
71
+ if start_time.nil?
72
+ raise ArgumentError, 'start_time is mandatory'
73
+ end
74
+ @start_time = start_time
75
+ end
76
+
77
+ def setting=(setting)
78
+ if setting.nil?
79
+ raise ArgumentError, 'setting is mandatory'
80
+ end
81
+ @setting = setting
82
+ end
83
+
84
+ def participations=(participations)
85
+ if !participations.nil? and participations.empty?
86
+ raise ArgumentError, 'participations should not be empty'
87
+ end
88
+ @participations = participations
89
+ end
90
+
91
+ def location=(location)
92
+ if !location.nil? and location.empty?
93
+ raise ArgumentError, 'location should not be empty'
94
+ end
95
+ @location = location
96
+ end
97
+ end
98
+
99
+ autoload :Content, 'composition/content'
100
+
101
+ end # end of Composition
102
+ end # end of RM
103
+ end # end of OpenEHR
@@ -0,0 +1,117 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ # rm::data_structures::history
4
+ # history module
5
+ # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109157527311_729550_7234Report.html
6
+ # refs #55
7
+ require 'time'
8
+ require 'active_support/core_ext'
9
+ include OpenEHR::RM::DataStructures
10
+ include OpenEHR::RM::Common::Archetyped
11
+
12
+ module OpenEHR
13
+ module RM
14
+ module DataStructures
15
+ module History
16
+ class History < DataStructure
17
+ attr_reader :origin, :events
18
+ attr_accessor :duration, :period, :summary
19
+
20
+ def initialize(args = { })
21
+ super(args)
22
+ self.origin = args[:origin]
23
+ self.duration = args[:duration]
24
+ self.period = args[:period]
25
+ self.events = args[:events]
26
+ self.summary = args[:summary]
27
+ end
28
+
29
+ def origin=(origin)
30
+ raise ArgumentError, 'origin is mandatory' if origin.nil?
31
+ @origin = origin
32
+ end
33
+
34
+ def events=(events)
35
+ if !events.nil? and events.empty?
36
+ raise ArgumentError, 'events should not be empty'
37
+ end
38
+ @events = events
39
+ end
40
+
41
+ def is_periodic?
42
+ return !@period.nil?
43
+ end
44
+ end
45
+
46
+ class Event < Locatable
47
+ attr_reader :data, :time
48
+ attr_accessor :state
49
+
50
+ def initialize(args = { })
51
+ super(args)
52
+ self.data = args[:data]
53
+ self.time = args[:time]
54
+ self.state = args[:state]
55
+ end
56
+
57
+ def data=(data)
58
+ raise ArgumentError, 'data is mandatory' if data.nil?
59
+ @data = data
60
+ end
61
+
62
+ def time=(time)
63
+ raise ArgumentError, 'time is mandatory' if time.nil?
64
+ @time = time
65
+ end
66
+
67
+ def offset
68
+ return @time.diff(@parent.origin)
69
+ end
70
+ end
71
+
72
+ class PointEvent < Event
73
+
74
+ end
75
+
76
+ class IntervalEvent < Event
77
+ attr_reader :width, :math_function
78
+ attr_accessor :sample_count
79
+
80
+ def initialize(args = { })
81
+ super(args)
82
+ self.width = args[:width]
83
+ self.math_function = args[:math_function]
84
+ self.sample_count = args[:sample_count]
85
+ end
86
+
87
+ def width=(width)
88
+ raise ArgumentError, 'width is mandatory' if width.nil?
89
+ @width = width
90
+ end
91
+
92
+ def math_function=(math_function)
93
+ if math_function.nil?
94
+ raise ArgumentError, 'math_function is mandatory'
95
+ end
96
+ @math_function = math_function
97
+ end
98
+
99
+ def interval_start_time
100
+ date_time = ::Time.iso8601(time.as_string)
101
+ start_time = (@width.years).years.ago date_time
102
+ start_time = (@width.months).months.ago start_time
103
+ start_time = (@width.days).days.ago start_time
104
+ start_time = (@width.hours).hours.ago start_time
105
+ start_time = (@width.minutes).minutes.ago start_time
106
+ seconds = @width.seconds
107
+ unless @width.fractional_second.nil?
108
+ seconds += @width.fractional_second
109
+ end
110
+ start_time = seconds.ago start_time
111
+ return DvDateTime.new(:value => start_time.iso8601)
112
+ end
113
+ end
114
+ end # end of History
115
+ end # end of DataStructure
116
+ end # end of RM
117
+ end # end of OpenEHR
@@ -0,0 +1,63 @@
1
+ # rm::data_structures::item_structure::representation
2
+ # representation module
3
+ # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109066789167_738055_2581Report.html
4
+ # refs #53
5
+ module OpenEHR
6
+ module RM
7
+ module DataStructures
8
+ module ItemStructure
9
+ module Representation
10
+ class Item < OpenEHR::RM::Common::Archetyped::Locatable
11
+ def initialize(args = {})
12
+ super(args)
13
+ end
14
+ end
15
+
16
+ class Element < Item
17
+ attr_accessor :value
18
+ attr_reader :null_flavor
19
+ def initialize(args = {})
20
+ super(args)
21
+ self.value = args[:value]
22
+ self.null_flavor= args[:null_flavor]
23
+ end
24
+
25
+ def null_flavor=(null_flavor)
26
+ sr = nil
27
+ if !null_flavor.nil? and
28
+ null_flavor.defining_code.terminology_id.name == 'openehr'
29
+ sr = Terminology.find(:first,
30
+ :conditions => "code = '#{null_flavor.defining_code.code_string}'")
31
+ end
32
+ if null_flavor.nil? or (!sr.nil? and sr.group == 'null flavours')
33
+ @null_flavor = null_flavor
34
+ else
35
+ raise ArgumentError, 'null_flavor is invalid'
36
+ end
37
+ end
38
+
39
+ def is_null?
40
+ return @value.nil?
41
+ end
42
+ end
43
+
44
+ class Cluster < Item
45
+ attr_reader :items
46
+
47
+ def initialize(args = {})
48
+ super(args)
49
+ self.items = args[:items]
50
+ end
51
+
52
+ def items=(items)
53
+ if !items.nil? and items.empty?
54
+ raise ArgumentError, 'items should not empty'
55
+ end
56
+ @items = items
57
+ end
58
+ end
59
+ end # of Representation
60
+ end # of ItemStructure
61
+ end # of DataStructures
62
+ end # of RM
63
+ end # of OpenEHR
@@ -0,0 +1,216 @@
1
+ # rm::data_structures::item_structure
2
+ # ItemStructure module
3
+ # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109346709572_859750_3810Report.html
4
+ # refs #54
5
+ require 'set'
6
+ include OpenEHR::RM::DataStructures
7
+ module OpenEHR
8
+ module RM
9
+ module DataStructures
10
+ module ItemStructure
11
+
12
+ autoload :Representation, 'item_structure/representation'
13
+
14
+ class ItemStructure < DataStructure
15
+ end
16
+
17
+ class ItemSingle < ItemStructure
18
+ attr_reader :item
19
+
20
+ def initialize(args = {})
21
+ super(args)
22
+ self.item = args[:item]
23
+ end
24
+
25
+ def as_hierarchy
26
+ return @item
27
+ end
28
+
29
+ def item=(item)
30
+ raise ArgumentError, 'item is mandatory' if item.nil?
31
+ @item = item
32
+ end
33
+ end
34
+
35
+ class ItemList < ItemStructure
36
+ attr_accessor :items
37
+
38
+ def initialize(args = {})
39
+ super(args)
40
+ self.items = args[:items]
41
+ end
42
+
43
+ def item_count
44
+ unless @items.nil?
45
+ return @items.size
46
+ else
47
+ return 0
48
+ end
49
+ end
50
+
51
+ def names
52
+ return @items.collect{|item| item.name}
53
+ end
54
+
55
+ def named_item(a_name)
56
+ @items.each do |item|
57
+ return item if item.name.value == a_name
58
+ end
59
+ return nil
60
+ end
61
+
62
+ def ith_item(i)
63
+ raise ArgumentError, 'index invalid' if i <= 0
64
+ return @items[i - 1]
65
+ end
66
+
67
+ def as_hierarchy
68
+ return Cluster.new(:name => @name,
69
+ :archetype_node_id => @archetype_node_id,
70
+ :items => @items)
71
+ end
72
+ end
73
+
74
+ class ItemTable < ItemStructure
75
+ attr_accessor :rows
76
+
77
+ def initialize(args = {})
78
+ super(args)
79
+ self.rows = args[:rows]
80
+ end
81
+
82
+ def row_count
83
+ if @rows.nil?
84
+ return 0
85
+ else
86
+ return @rows.size
87
+ end
88
+ end
89
+
90
+ def column_count
91
+ if @rows.nil?
92
+ return 0
93
+ else
94
+ return @rows[0].items.count
95
+ end
96
+ end
97
+
98
+ def row_names
99
+ if @rows.nil?
100
+ return []
101
+ else
102
+ return @rows.collect{|r| r.name}
103
+ end
104
+ end
105
+
106
+ def column_names
107
+ if @rows.nil?
108
+ return []
109
+ else
110
+ return @rows[0].items.collect{|i| i.name}
111
+ end
112
+ end
113
+
114
+ def ith_row(i)
115
+ raise ArgumentError, 'invalid index' if i<=0 or i>@rows.size
116
+ return @rows[i - 1]
117
+ end
118
+
119
+ def has_row_with_name?(key)
120
+ raise ArgumentError, 'invalid argument' if key.nil? or key.empty?
121
+ @rows.each do |row|
122
+ return true if row.items[0].name.value == key
123
+ end
124
+ return false
125
+ end
126
+
127
+ def has_column_with_name?(key)
128
+ raise ArgumentError, 'invalid argument' if key.nil? or key.empty?
129
+ self.column_names.each do |name|
130
+ return true if name.value == key
131
+ end
132
+ return false
133
+ end
134
+
135
+ def named_row(key)
136
+ raise ArgumentError, 'invalid argument' unless has_row_with_name?(key)
137
+ @rows.each do |row|
138
+ return row if row.items[0].name.value == key
139
+ end
140
+ end
141
+
142
+ def has_row_with_key?(keys)
143
+ keys.each do |key|
144
+ @rows.each do |row|
145
+ return true if row.items[0].name.value == key
146
+ end
147
+ end
148
+ return false
149
+ end
150
+
151
+ def row_with_key(keys)
152
+ unless has_row_with_key?(keys)
153
+ raise ArgumentError, 'no row for key'
154
+ end
155
+ keys.each do |key|
156
+ @rows.each do |row|
157
+ return row if row.items[0].name.value == key
158
+ end
159
+ end
160
+ end
161
+
162
+ def element_at_cell_ij(i,j)
163
+ return @rows[i-1].items[j-1]
164
+ end
165
+
166
+ def element_at_named_cell(row_key, column_key)
167
+ i,j=0,0
168
+ @rows[0].items.each do |c|
169
+ break if c.name.value == column_key
170
+ i+=1
171
+ end
172
+ @rows.each do |row|
173
+ break if row.name.value == row_key
174
+ j+=1
175
+ end
176
+ return element_at_cell_ij(i,j)
177
+ end
178
+
179
+ def as_hierarchy
180
+ return @rows[0]
181
+ end
182
+ end
183
+
184
+ class ItemTree < ItemStructure
185
+ attr_accessor :items
186
+
187
+ def initialize(args ={ })
188
+ super(args)
189
+ self.items = args[:items]
190
+ end
191
+
192
+ def has_element_path?(path)
193
+ paths = [ ]
194
+ @items.each do |item|
195
+ paths << item.archetype_node_id
196
+ end
197
+ return paths.include? path
198
+ end
199
+
200
+ def element_at_path(path)
201
+ @items.each do |item|
202
+ return item if item.archetype_node_id == path
203
+ end
204
+ return nil
205
+ end
206
+
207
+ def as_hierarchy
208
+ return Cluster.new(:name => @name,
209
+ :archetype_node_id => @archetype_node_id,
210
+ :items => @items)
211
+ end
212
+ end
213
+ end # of ItemStructure
214
+ end # of DataStructures
215
+ end # of RM
216
+ end # of OpenEHR
@@ -0,0 +1,25 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ # rm::data_structures
4
+ # class DATA_STRUCTURE
5
+ # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_5_1_76d0249_1140447518205_872539_864Report.html
6
+ # refs #59
7
+
8
+ module OpenEHR
9
+ module RM
10
+ module DataStructures
11
+ autoload :ItemStructure, 'data_structures/item_structure'
12
+ autoload :History, 'data_structures/history'
13
+
14
+ class DataStructure < OpenEHR::RM::Common::Archetyped::Locatable
15
+ def initialize(args = { })
16
+ super(args)
17
+ end
18
+
19
+ def as_hierarchy
20
+ raise NotImplementedError, "as_hirarchy must be implemented"
21
+ end
22
+ end
23
+ end # of Data_Structures
24
+ end # of RM
25
+ end # of OpenEHR
@@ -0,0 +1,108 @@
1
+ # This module is implemented from this UML:
2
+ # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109067591791_562382_3151Report.html
3
+ # Ticket refs #52
4
+ module OpenEHR
5
+ module RM
6
+ module DataTypes
7
+ module Basic
8
+ module CanonicalFragment
9
+ end
10
+
11
+ class DataValue
12
+ include OpenEHR::RM::Support::Definition::BasicDefinition
13
+ attr_accessor :value
14
+ alias :v :value
15
+
16
+ def initialize(args = {})
17
+ self.value = args[:value]
18
+ end
19
+
20
+ def ==(other)
21
+ return self.value == other.value
22
+ end
23
+ end
24
+
25
+ class DvBoolean < DataValue
26
+ def initialize(args)
27
+ super(args)
28
+ end
29
+
30
+ def value=(value)
31
+ raise ArgumentError, "value must not be nil" if value.nil?
32
+ if value == true or value =~ /TRUE/i
33
+ @value = true
34
+ else
35
+ @value = false
36
+ end
37
+ end
38
+
39
+ def value?
40
+ @value == true
41
+ end
42
+ end # end of DvBoolean
43
+
44
+ class DvState < DataValue
45
+ attr_reader :is_terminal
46
+
47
+ def initialize(args)
48
+ super(args)
49
+ self.is_terminal = args[:is_terminal]
50
+ end
51
+
52
+ def value=(v)
53
+ raise ArgumentError, "value should not be nil" if v.nil?
54
+ @value = v
55
+ end
56
+
57
+ def is_terminal?
58
+ @is_terminal
59
+ end
60
+
61
+ def is_terminal=(s)
62
+ raise ArgumentError, "terminal should not be nil" if s.nil?
63
+ @is_terminal = s
64
+ end
65
+ end # end of DvState
66
+
67
+ class DvIdentifier < DataValue
68
+ attr_reader :issuer, :assigner, :id, :type
69
+
70
+ def initialize(args = {})
71
+ self.issuer = args[:issuer]
72
+ self.assigner = args[:assigner]
73
+ self.id = args[:id]
74
+ self.type = args[:type]
75
+ end
76
+
77
+ def issuer=(issuer)
78
+ if issuer.nil? or issuer.empty?
79
+ raise ArgumentError, 'issuer is mandatory'
80
+ end
81
+ @issuer = issuer
82
+ end
83
+
84
+ def assigner=(assigner)
85
+ if assigner.nil? or assigner.empty?
86
+ raise ArgumentError, 'assigner is mandatory'
87
+ end
88
+ @assigner = assigner
89
+ end
90
+
91
+ def id=(id)
92
+ if id.nil? or id.empty?
93
+ raise ArgumentError, 'id is manadtory'
94
+ end
95
+ @id = id
96
+ end
97
+
98
+ def type=(type)
99
+ if type.nil? or type.empty?
100
+ raise ArgumentError, 'type is mandatory'
101
+ end
102
+ @type = type
103
+ end
104
+ end #end of DvIdentifier
105
+ end # end of Basic
106
+ end # end of DataTypes
107
+ end # end of RM
108
+ end # end of OpenEHR