open_ehr 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,403 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+ # This modules are implemented from the UML shown bellow
4
+ # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109599337877_94556_1510Report.html
5
+ # Ticket refs #50
6
+
7
+ require 'assumed_library_types'
8
+
9
+ module OpenEHR
10
+ module RM
11
+ module DataTypes
12
+ module Quantity
13
+ autoload :DateTime, 'quantity/date_time'
14
+
15
+ class DvOrdered < OpenEHR::RM::DataTypes::Basic::DataValue
16
+ include Comparable
17
+ attr_accessor :normal_range, :other_refference_ranges, :normal_status
18
+
19
+ def initialize(args = {})
20
+ super(args)
21
+ self.normal_range = args[:normal_range]
22
+ self.normal_status = args[:normal_status]
23
+ self.other_reference_ranges = args[:other_reference_ranges]
24
+ end
25
+
26
+ def is_normal?
27
+ if @normal_range.nil? and @normal_status.nil?
28
+ return false
29
+ elsif !@normal_range.nil?
30
+ return @normal_range.has(@value)
31
+ elsif !@normal_status.nil?
32
+ return @normal_status.code_string == 'N'
33
+ end
34
+ end
35
+
36
+ def is_simple?
37
+ return @other_reference_ranges.nil?
38
+ end
39
+
40
+ def <=>(other)
41
+ raise NotImplementedError, 'This method should be implemented'
42
+ end
43
+
44
+ def other_reference_ranges=(other_reference_ranges)
45
+ if !other_reference_ranges.nil? && other_reference_ranges.empty?
46
+ raise ArgumentError, "Other reference ranges validity error"
47
+ end
48
+ @other_reference_ranges = other_reference_ranges
49
+ end
50
+
51
+ def is_strictly_comparable_to?(others)
52
+ if others.instance_of? self.class
53
+ return true
54
+ else
55
+ return false
56
+ end
57
+ end
58
+ end
59
+
60
+ class DvInterval < OpenEHR::AssumedLibraryTypes::Interval
61
+
62
+ end
63
+
64
+ class DvQuantified < DvOrdered
65
+ attr_reader :magnitude, :magnitude_status
66
+
67
+ def initialize(args = {})
68
+ super(args)
69
+ self.magnitude = args[:magnitude]
70
+ self.magnitude_status = args[:magnitude_status]
71
+ end
72
+
73
+ def <=>(others)
74
+ self.magnitude <=> others.magnitude
75
+ end
76
+
77
+ def magnitude=(magnitude)
78
+ raise ArgumentError, 'magnitude should not be nil' if magnitude.nil?
79
+ @magnitude = magnitude
80
+ end
81
+
82
+ def magnitude_status=(magnitude_status)
83
+ if magnitude_status.nil?
84
+ @magnitude_status = '='
85
+ elsif DvQuantified.valid_magnitude_status?(magnitude_status)
86
+ @magnitude_status = magnitude_status
87
+ else
88
+ raise ArgumentError, 'magnitude_status invalid'
89
+ end
90
+ end
91
+
92
+ def accuracy_unknown?
93
+ return @accuracy.nil?
94
+ end
95
+
96
+ def self.valid_magnitude_status?(s)
97
+ if s == '=' || s == '>' || s == '<' || s == '<=' ||
98
+ s == '>=' || s == '~'
99
+ return true
100
+ else
101
+ return false
102
+ end
103
+ end
104
+ end
105
+
106
+ class DvOrdinal < DvOrdered
107
+ attr_reader :value, :symbol, :limits
108
+
109
+ def initialize(args = {})
110
+ super(args)
111
+ self.symbol = args[:symbol]
112
+ self.limits = args[:limits]
113
+ end
114
+
115
+ def value=(value)
116
+ raise ArgumentError, 'value should not be nil' if value.nil?
117
+ @value = value
118
+ end
119
+
120
+ def symbol=(symbol)
121
+ raise ArgumentError,'symbol should not be nil' if symbol.nil?
122
+ @symbol = symbol
123
+ end
124
+
125
+ def <=>(other)
126
+ @value <=> other.value
127
+ end
128
+
129
+ def limits=(limits)
130
+ unless limits.nil? or limits.meaning.value == 'limits'
131
+ raise ArgumentError, 'invalid limits'
132
+ else
133
+ @limits = limits
134
+ end
135
+ end
136
+ def is_strictly_comparable_to?(others)
137
+ unless super(others)
138
+ return false
139
+ end
140
+ unless others.symbol.defining_code.terminology_id.value ==
141
+ @symbol.defining_code.terminology_id.value
142
+ return false
143
+ else
144
+ return true
145
+ end
146
+ end
147
+ end
148
+
149
+ class DvAbsoluteQuantity < DvQuantified
150
+ attr_accessor :accuracy
151
+
152
+ def initialize(args = {})
153
+ super(args)
154
+ self.accuracy = args[:accuracy]
155
+ end
156
+
157
+ def add(a_diff)
158
+ type_check(a_diff)
159
+ return result_builder(self.class,
160
+ @magnitude+a_diff.magnitude)
161
+ end
162
+
163
+ def diff(other)
164
+ type_check(other)
165
+ return result_builder(self.class,
166
+ (@magnitude-other.magnitude).abs)
167
+ end
168
+
169
+ def subtract(a_diff)
170
+ type_check(a_diff)
171
+ return result_builder(self.class,
172
+ @magnitude-a_diff.magnitude)
173
+ end
174
+ private
175
+ def type_check(other)
176
+ unless self.is_strictly_comparable_to? other
177
+ raise ArgumentError, 'type mismatch'
178
+ end
179
+ end
180
+
181
+ def result_builder(klass, magnitude)
182
+ return klass.new(:magnitude => magnitude,
183
+ :magnitude_status => @magnitude_status,
184
+ :accuracy => @accuracy,
185
+ :accuracy_percent => @accuracy_percent,
186
+ :normal_range => @normal_range,
187
+ :normal_status => @normal_status,
188
+ :other_reference_ranges => @other_reference_ranges)
189
+ end
190
+ end
191
+
192
+ class DvAmount < DvQuantified
193
+ attr_reader :accuracy, :accuracy_percent
194
+
195
+ def initialize(args = {})
196
+ super(args)
197
+ unless args[:accuracy].nil?
198
+ set_accuracy(args[:accuracy], args[:accuracy_percent])
199
+ else
200
+ @accuracy, @accuracy_percent = nil, nil
201
+ end
202
+ end
203
+
204
+ def +(other)
205
+ unless self.is_strictly_comparable_to? other
206
+ raise ArgumentError, 'type mismatch'
207
+ end
208
+ result = self.dup
209
+ result.magnitude = @magnitude + other.magnitude
210
+ return result
211
+ end
212
+
213
+ def -(other)
214
+ other.magnitude = - other.magnitude
215
+ self+(other)
216
+ end
217
+
218
+ def set_accuracy(accuracy, accuracy_percent)
219
+ if accuracy_percent
220
+ raise ArgumentError, 'accuracy invalid' if accuracy < 0.0 || accuracy > 100.0
221
+ else
222
+ raise ArgumentError, 'accuracy invaild' if accuracy < 0.0 || accuracy > 1.0
223
+ end
224
+ @accuracy, @accuracy_percent = accuracy, accuracy_percent
225
+ end
226
+
227
+ def accuracy_is_percent?
228
+ return @accuracy_percent
229
+ end
230
+ end
231
+
232
+ class DvQuantity < DvAmount
233
+ attr_reader :units, :precision
234
+
235
+ def initialize(args = {})
236
+ super(args)
237
+ self.units = args[:units]
238
+ self.precision = args[:precision]
239
+ end
240
+
241
+ def units=(units)
242
+ raise ArgumentError, 'units should not be nil' if units.nil?
243
+ @units = units
244
+ end
245
+
246
+ def precision=(precision)
247
+ unless precision.nil? || precision >= -1
248
+ raise ArgumentError, 'precision invalid'
249
+ end
250
+ @precision = precision
251
+ end
252
+
253
+ def is_strictly_comparable_to?(others)
254
+ unless super(others)
255
+ return false
256
+ end
257
+ if others.units == @units
258
+ return true
259
+ else
260
+ return false
261
+ end
262
+ end
263
+
264
+ def is_integral?
265
+ if @precision.nil? || precision != 0
266
+ return false
267
+ else
268
+ return true
269
+ end
270
+ end
271
+ end
272
+
273
+ class DvCount < DvAmount
274
+
275
+ end
276
+
277
+ class ReferenceRange
278
+ attr_reader :meaning, :range
279
+
280
+ def initialize(args = {})
281
+ self.meaning = args[:meaning]
282
+ self.range = args[:range]
283
+ end
284
+
285
+ def meaning=(meaning)
286
+ if meaning.nil?
287
+ raise ArgumentError, 'meaning should not be nil'
288
+ end
289
+ @meaning = meaning
290
+ end
291
+
292
+ def range=(range)
293
+ if range.nil?
294
+ raise ArgumentError, 'range should not be nil'
295
+ end
296
+ @range = range
297
+ end
298
+
299
+ def is_in_range?(val)
300
+ return @range.has?(val)
301
+ end
302
+ end
303
+
304
+ module ProportionKind
305
+ PK_RATIO = 0
306
+ PK_UNITARY = 1
307
+ PK_PERCENT = 2
308
+ PK_FRACTION = 3
309
+ PK_INTEGER_FRACTION = 4
310
+
311
+ def ProportionKind.valid_proportion_kind?(kind)
312
+ return true if kind >= 0 && kind <= 4
313
+ return false
314
+ end
315
+ end # end of ProportionKind
316
+
317
+ class DvProportion < DvAmount
318
+ include ProportionKind
319
+ attr_reader :numerator, :denominator, :type, :precision
320
+
321
+ def initialize(args = {})
322
+ self.type = args[:type]
323
+ self.numerator = args[:numerator]
324
+ self.denominator = args[:denominator]
325
+ self.precision = args[:precision]
326
+ self.magnitude_status =args[:magnitude_status]
327
+ unless args[:accuracy].nil?
328
+ set_accuracy(args[:accuracy], args[:accuracy_percent])
329
+ else
330
+ @accuracy, @accuracy_percent = nil, nil
331
+ end
332
+ self.normal_range = args[:normal_range]
333
+ self.normal_status = args[:normal_status]
334
+ self.other_reference_ranges = args[:other_reference_ranges]
335
+ end
336
+
337
+ def numerator=(numerator)
338
+ raise ArgumentError, 'numerator should not be nil' if numerator.nil?
339
+ if (@type == PK_FRACTION || @type == PK_INTEGER_FRACTION) &&
340
+ !numerator.integer?
341
+ raise ArgumentError, 'numerator invalid for type'
342
+ end
343
+ @numerator = numerator
344
+ end
345
+
346
+ def denominator=(denominator)
347
+ case @type
348
+ when PK_UNITARY
349
+ unless denominator == 1
350
+ raise ArgumentError, 'Unitary denominator must be 1'
351
+ end
352
+ when PK_PERCENT
353
+ unless denominator == 100
354
+ raise ArgumentError, 'Percent denominator must be 100'
355
+ end
356
+ when PK_FRACTION, PK_INTEGER_FRACTION
357
+ unless denominator.integer? and @numerator.integer?
358
+ raise ArgumentError, 'Fraction numerator/denominator must be integer'
359
+ end
360
+ end
361
+ @denominator = denominator
362
+ end
363
+
364
+ def type=(type)
365
+ if ProportionKind.valid_proportion_kind?(type)
366
+ @type = type
367
+ else
368
+ raise ArgumentError, 'type invalid'
369
+ end
370
+ end
371
+
372
+ def magnitude
373
+ return numerator.to_f/denominator.to_f
374
+ end
375
+
376
+ def precision=(precision)
377
+ unless precision.nil?
378
+ if (self.is_integral? && precision !=0)
379
+ raise ArgumentError, 'precision invalid'
380
+ end
381
+ end
382
+ @precision = precision
383
+ end
384
+
385
+ def is_integral?
386
+ return denominator.integer? && numerator.integer?
387
+ end
388
+
389
+ def is_strictly_comparable_to?(other)
390
+ unless super(other)
391
+ return false
392
+ end
393
+ if other.type == @type
394
+ return true
395
+ else
396
+ return false
397
+ end
398
+ end
399
+ end # end of DvProportion
400
+ end # of Quantity
401
+ end # of Data_Types
402
+ end # of RM
403
+ end # of OpenEHR
@@ -0,0 +1,168 @@
1
+ # This module implemented from this UML
2
+ # http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109067605961_209522_3179Report.html
3
+ # Ticket refs #48
4
+ include OpenEHR::RM::DataTypes::Basic
5
+
6
+ module OpenEHR
7
+ module RM
8
+ module DataTypes
9
+ module Text
10
+ class TermMapping
11
+ attr_reader :match, :purpose, :target
12
+
13
+ def initialize(args ={})
14
+ self.match = args[:match]
15
+ self.purpose = args[:purpose]
16
+ self.target = args[:target]
17
+ end
18
+
19
+ def match=(match)
20
+ unless TermMapping.is_valid_mach_code? match
21
+ raise ArgumentError, 'invalid match character'
22
+ end
23
+ @match = match
24
+ end
25
+
26
+ def purpose=(purpose)
27
+ # if !purpose.nil? and !purpose.instance_of?(DvCodedText)
28
+ # raise ArgumentError, "purpose is not valid"
29
+ # end
30
+ # should be settled after terminology service implemented
31
+ @purpose = purpose
32
+ end
33
+
34
+ def target=(target)
35
+ raise ArgumentError, "target must not be nil" if target.nil?
36
+ @target = target
37
+ end
38
+
39
+ def broader?
40
+ match == '>'
41
+ end
42
+
43
+ def equivalent?
44
+ match == '='
45
+ end
46
+
47
+ def narrower?
48
+ match == '<'
49
+ end
50
+
51
+ def unknown?
52
+ match == '?'
53
+ end
54
+
55
+ def TermMapping.is_valid_mach_code?(c)
56
+ c == '>' or c == '=' or c == '<' or c == '?'
57
+ end
58
+ end
59
+
60
+ class CodePhrase
61
+ attr_reader :terminology_id, :code_string
62
+
63
+ def initialize(args = {})
64
+ self.code_string = args[:code_string]
65
+ self.terminology_id = args[:terminology_id]
66
+ end
67
+
68
+ def terminology_id=(terminology_id)
69
+ if terminology_id.nil?
70
+ raise ArgumentError, "terminology_id should not be nil"
71
+ end
72
+ @terminology_id = terminology_id
73
+ end
74
+
75
+ def code_string=(code_string)
76
+ if code_string.nil? or code_string.empty?
77
+ raise ArgumentError, "code_string should not be empty"
78
+ end
79
+ @code_string = code_string
80
+ end
81
+ end # of CodePhrase
82
+
83
+ class DvText < OpenEHR::RM::DataTypes::Basic::DataValue
84
+ attr_reader :formatting, :hyperlink, :mappings,
85
+ :language, :encoding
86
+
87
+ def initialize(args = {})
88
+ super(args)
89
+ self.formatting = args[:formatting]
90
+ self.encoding = args[:encoding]
91
+ self.mappings = args[:mappings]
92
+ self.language = args[:language]
93
+ end
94
+
95
+ def value=(value)
96
+ if value.nil? or value.empty? or
97
+ value.include? CR or value.include? LF
98
+ raise ArgumentError, "value is not valid"
99
+ # CR and LF are defined in Basic_Definition inherited DataValue.
100
+ end
101
+ @value = value
102
+ end
103
+
104
+ def formatting=(formatting)
105
+ if !formatting.nil? and formatting.empty?
106
+ raise ArgumentError, "formatting is not valid"
107
+ end
108
+ @formatting = formatting
109
+ end
110
+
111
+ def encoding=(encoding)
112
+ if !encoding.nil? and encoding.code_string.empty?
113
+ raise ArgumentError, "encoding is not valid"
114
+ end
115
+ @encoding = encoding
116
+ end
117
+ def mappings=(mappings)
118
+ if !mappings.nil? and !mappings.instance_of? Set
119
+ raise ArgumentError, "mapping(s) is(are) not valid"
120
+ elsif !mappings.nil? and mappings.instance_of? Set and
121
+ mappings.empty?
122
+ raise ArgumentError, "mapping(s) is(are) not valid"
123
+ end
124
+ @mappings = mappings
125
+ end
126
+ def language=(language)
127
+ if !@language.nil? and language.empty?
128
+ raise ArgumentError, "langage is not valid"
129
+ end
130
+ @language = language
131
+ end
132
+ end
133
+
134
+ class DvCodedText < DvText
135
+ attr_reader :defining_code
136
+
137
+ def initialize(args = {})
138
+ super(args)
139
+ self.defining_code = args[:defining_code]
140
+ end
141
+
142
+ def defining_code=(defining_code)
143
+ if defining_code.nil?
144
+ raise ArgumentError, 'defiining code is mandatory'
145
+ end
146
+ @defining_code = defining_code
147
+ end
148
+ end
149
+
150
+ class DvParagraph < OpenEHR::RM::DataTypes::Basic::DataValue
151
+ attr_reader :items
152
+
153
+ def initialize(args ={})
154
+ self.items = args[:items]
155
+ end
156
+
157
+ def items=(items)
158
+ if items.nil? or items.empty?
159
+ raise ArgumentError, "Items are not valid"
160
+ end
161
+ @items = items
162
+ end
163
+ end
164
+
165
+ end # of Text
166
+ end # of DataTypes
167
+ end # of RM
168
+ end # of OpenEHR
@@ -0,0 +1,75 @@
1
+ # This module is related to the ticket #47
2
+
3
+ module OpenEhr
4
+ module RM
5
+ module DataTypes
6
+ module TimeSpecification
7
+ class DvTimeSpecification < OpenEhr::RM::DataTypes::Basic::DataValue
8
+ attr_reader :value
9
+
10
+ def initialize(value)
11
+ self.value=(value)
12
+ end
13
+
14
+ def value=(value)
15
+ raise ArgumentError, 'value must be not nil' if value.nil?
16
+ @value = value
17
+ end
18
+
19
+ def calender_alignment
20
+ raise NotImlementedError, "calender_alignment must be implemented"
21
+ end
22
+
23
+ def event_alignment
24
+ raise NotImlementedError, "event_alignment must be implemented"
25
+ end
26
+
27
+ def institution_specified
28
+ raise NotImlementedError, "institution_specified must be implemented"
29
+ end
30
+ end
31
+
32
+ # I have not implemented two classes bellow,
33
+ # because I could not obtain HL7 specification related them.
34
+
35
+
36
+ class DvGeneralTimeSpecification < DvTimeSpecification
37
+ attr_reader :value
38
+ def initialize(value)
39
+ super(value)
40
+ end
41
+ def value=(value)
42
+ raise ArgumentError, "value is not valied" unless value.formalism.is_equal?('HL7:GTS')
43
+ @value = value
44
+ end
45
+ private
46
+ def value_valid(value)
47
+ end
48
+ end
49
+
50
+ class DvPeriodicTimeSpecification < DvTimeSpecification
51
+ attr_reader :value, :calender_alignment, :event_alingment, :period
52
+ def initialize(value)
53
+ value_valid(value)
54
+ super(value)
55
+ end
56
+ def value=(value)
57
+ unless value.formalism.is_equal('HL7:PIVL') or value.formalism.is_equal('HL7:EIVL')
58
+ raise ArgumentError, "value is not valid"
59
+ end
60
+ if value.formalism('HL7:PIVL')
61
+ /^\[(\d+)\;?(\d+)?\]\/\((\d+\w+)\)(@(\w+?))?(IST)?$/ =~ value
62
+ interval1, interval2, difference, allignment = $1, $2, $3, $5
63
+ end
64
+ if value
65
+ end
66
+ end
67
+
68
+ def institution_specified?
69
+
70
+ end
71
+ end
72
+ end
73
+ end # of Data_Type
74
+ end # of RM
75
+ end # of OpenEHR