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,25 @@
1
+ require File.dirname(__FILE__) + '/../../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity::DateTime
3
+
4
+ describe DvDateTime do
5
+ before(:each) do
6
+ @dv_date_time = DvDateTime.new(:value => '2009-09-29T15:03:22.3')
7
+ end
8
+
9
+ it 'should be an instance of DvDateTime' do
10
+ @dv_date_time.should be_an_instance_of DvDateTime
11
+ end
12
+
13
+ it 'magnitude should be 63425495002.3' do
14
+ @dv_date_time.magnitude.should be_within(0.01).of(63423697018.3)
15
+ end
16
+
17
+ it 'should be equal when magnitude is same' do
18
+ @dv_date_time.should == DvDateTime.new(:value => '2009-09-29T15:03:22.3')
19
+ end
20
+
21
+ it 'diff should be caluculated from past to future' do
22
+ future = DvDateTime.new(:value => '2009-10-29T16:23:30.3')
23
+ @dv_date_time.diff(future).value.should == 'P0Y1M0W0DT1H20M8.0S'
24
+ end
25
+ end
@@ -0,0 +1,24 @@
1
+ require File.dirname(__FILE__) + '/../../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity::DateTime
3
+
4
+ describe DvTemporal do
5
+ before(:each) do
6
+ @dv_temporal = DvTemporal.new(:value => '2009-09-28T23:36')
7
+ end
8
+
9
+ it 'should be an instance of DvTemporal' do
10
+ @dv_temporal.should be_an_instance_of DvTemporal
11
+ end
12
+
13
+ it 'should raise ArgumentError with nil value' do
14
+ lambda {
15
+ @dv_temporal.value = nil
16
+ }.should raise_error ArgumentError
17
+ end
18
+
19
+ it 'should raise ArgumentError with empty value' do
20
+ lambda {
21
+ @dv_temporal.value = ''
22
+ }.should raise_error ArgumentError
23
+ end
24
+ end
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/../../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity::DateTime
3
+
4
+ describe DvTime do
5
+ before(:each) do
6
+ @dv_time = DvTime.new(:value => '11:17:30.2')
7
+ end
8
+
9
+ it 'should be an instance of DvTime' do
10
+ @dv_time.should be_an_instance_of DvTime
11
+ end
12
+
13
+ it 'hour should be 11' do
14
+ @dv_time.hour.should == 11
15
+ end
16
+
17
+ it 'minute should be 17' do
18
+ @dv_time.minute.should == 17
19
+ end
20
+
21
+ it 'second should be 30' do
22
+ @dv_time.second.should == 30
23
+ end
24
+
25
+ it 'fractional_second should be 0.2' do
26
+ @dv_time.fractional_second.should == 0.2
27
+ end
28
+
29
+ it 'magnitude should 40650.2' do
30
+ @dv_time.magnitude.should == 40650.2
31
+ end
32
+
33
+ it 'should be ' do
34
+ diff_time = DvTime.new(:value => '15:36:48.05')
35
+ @dv_time.diff(diff_time).value.should =='P0Y0M0W0DT4H19M17.85S'
36
+ end
37
+ end
@@ -0,0 +1,35 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity
3
+
4
+ describe DvAbsoluteQuantity do
5
+ before(:each) do
6
+ @dv_absolute_quantity = DvAbsoluteQuantity.new(:magnitude => 7)
7
+ end
8
+
9
+ it 'should be an instance of DvAbsoluteQuantity' do
10
+ @dv_absolute_quantity.should be_an_instance_of DvAbsoluteQuantity
11
+ end
12
+
13
+ it 's add 3 method should magnitude 10' do
14
+ dv_absolute_quantity10 =
15
+ @dv_absolute_quantity.add(DvAbsoluteQuantity.new(:magnitude => 3))
16
+ dv_absolute_quantity10.magnitude.should == 10
17
+ end
18
+
19
+ it 's diff method should return DvAmount' do
20
+ diff_dv_amount = @dv_absolute_quantity.diff(DvAbsoluteQuantity.new(
21
+ :magnitude => 10))
22
+ diff_dv_amount.magnitude.should == 3
23
+ end
24
+
25
+ it 's subtract method should raise NotImplementedError' do
26
+ sub_dv_absolute_quantity = @dv_absolute_quantity.subtract(DvAbsoluteQuantity.new(:magnitude => 10))
27
+ sub_dv_absolute_quantity.magnitude.should == -3
28
+ end
29
+
30
+ it 'should be raise ArgumentError when type mismatched' do
31
+ lambda {
32
+ @dv_absolute_quantity.add(1)
33
+ }.should raise_error ArgumentError
34
+ end
35
+ end
@@ -0,0 +1,105 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity
3
+
4
+ describe DvAmount do
5
+ before(:each) do
6
+ @dv_amount = DvAmount.new(:magnitude => 2,
7
+ :accuracy => 100,
8
+ :accuracy_percent => true)
9
+ end
10
+
11
+ it 'should be an instance of DvAmount' do
12
+ @dv_amount.should be_an_instance_of DvAmount
13
+ end
14
+
15
+ it 's magnitude should be equal 2' do
16
+ @dv_amount.magnitude.should be_equal 2
17
+ end
18
+
19
+ it 's accuracy should be 100 percent' do
20
+ @dv_amount.accuracy.should be_equal 100
21
+ end
22
+
23
+ it 's accuracy_is_percent should be true' do
24
+ @dv_amount.accuracy_is_percent?.should be_true
25
+ end
26
+
27
+ it 'should has an instance with nil accuracy' do
28
+ dv_amount = DvAmount.new(:magnitude => 1)
29
+ dv_amount.should be_an_instance_of DvAmount
30
+ end
31
+
32
+ it 'should be 3 if +2 magnitude DvAmount' do
33
+ dv_amount4 = @dv_amount + DvAmount.new(:magnitude => 2)
34
+ dv_amount4.magnitude.should == 4
35
+ end
36
+
37
+ it 'should be -1 if - 3 magnitude DvAmount' do
38
+ dv_amount_1 = @dv_amount - DvAmount.new(:magnitude => 3)
39
+ dv_amount_1.magnitude.should == -1
40
+ end
41
+
42
+ it 'should be type mismatch' do
43
+ lambda {
44
+ @dv_amount + 1
45
+ }.should raise_error ArgumentError
46
+ end
47
+
48
+ it 'should not raise ArgumentError' do
49
+ lambda {
50
+ @dv_amount.set_accuracy(0, true)
51
+ }.should_not raise_error ArgumentError
52
+ end
53
+ it 'should not raise ArgumentError' do
54
+ lambda {
55
+ @dv_amount.set_accuracy(50, true)
56
+ }.should_not raise_error ArgumentError
57
+ end
58
+
59
+ it 'should not raise ArgumentError' do
60
+ lambda {
61
+ @dv_amount.set_accuracy(100, true)
62
+ }.should_not raise_error ArgumentError
63
+ end
64
+
65
+ it 'should raise ArgumentError with invaild accuracy' do
66
+ lambda {
67
+ @dv_amount.set_accuracy(-0.01, true)
68
+ }.should raise_error ArgumentError
69
+ end
70
+
71
+ it 'should raise ArgumentError with invaild accuracy' do
72
+ lambda {
73
+ @dv_amount.set_accuracy(100.1, true)
74
+ }.should raise_error ArgumentError
75
+ end
76
+
77
+ it 'should not raise ArgumentError' do
78
+ lambda {
79
+ @dv_amount.set_accuracy(0, false)
80
+ }.should_not raise_error ArgumentError
81
+ end
82
+ it 'should not raise ArgumentError' do
83
+ lambda {
84
+ @dv_amount.set_accuracy(0.5, false)
85
+ }.should_not raise_error ArgumentError
86
+ end
87
+
88
+ it 'should not raise ArgumentError' do
89
+ lambda {
90
+ @dv_amount.set_accuracy(1.0, false)
91
+ }.should_not raise_error ArgumentError
92
+ end
93
+
94
+ it 'should raise ArgumentError with invaild accuracy' do
95
+ lambda {
96
+ @dv_amount.set_accuracy(-0.01, false)
97
+ }.should raise_error ArgumentError
98
+ end
99
+
100
+ it 'should raise ArgumentError with invaild accuracy' do
101
+ lambda {
102
+ @dv_amount.set_accuracy(1.01, false)
103
+ }.should raise_error ArgumentError
104
+ end
105
+ end
@@ -0,0 +1,12 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity
3
+
4
+ describe DvCount do
5
+ before(:each) do
6
+ @dv_count = DvCount.new(:magnitude => 1)
7
+ end
8
+
9
+ it 'should be an instance of DvCount' do
10
+ @dv_count.should be_an_instance_of DvCount
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity
3
+
4
+ describe DvInterval do
5
+ before(:each) do
6
+ @dv_interval = DvInterval.new(:upper => 100,
7
+ :lower => 1)
8
+ end
9
+
10
+ it 'should be an instance of DvInterval' do
11
+ @dv_interval.should be_an_instance_of DvInterval
12
+ end
13
+
14
+ it 's upper should be larger than lower' do
15
+ @dv_interval.upper.should > @dv_interval.lower
16
+ end
17
+ end
@@ -0,0 +1,60 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity
3
+ include OpenEHR::RM::DataTypes::Text
4
+
5
+ describe DvOrdered do
6
+ before(:each) do
7
+ @dv_ordered = DvOrdered.new
8
+ end
9
+
10
+ it 'should be an instance of DvOrdered' do
11
+ @dv_ordered.should be_an_instance_of DvOrdered
12
+ end
13
+
14
+ it 'is_normal? should be false' do
15
+ @dv_ordered.is_normal?.should be_false
16
+ end
17
+
18
+ it 'should be normal' do
19
+ normal_code = stub(CodePhrase, :code_string => 'N')
20
+ @dv_ordered.normal_status = normal_code
21
+ @dv_ordered.is_normal?.should be_true
22
+ end
23
+
24
+ it 'should not be normal' do
25
+ abnormal_code = stub(CodePhrase, :code_string => 'H')
26
+ @dv_ordered.normal_status = abnormal_code
27
+ @dv_ordered.is_normal?.should_not be_true
28
+ end
29
+
30
+ it 'is_simple? should be true' do
31
+ @dv_ordered.is_simple?.should be_true
32
+ end
33
+
34
+ it 'is_simple? should be false' do
35
+ @dv_ordered.other_reference_ranges = 'dummy'
36
+ @dv_ordered.is_simple?.should be_false
37
+ end
38
+
39
+ it 'should raise ArgumentError' do
40
+ lambda{
41
+ @dv_ordered.other_reference_ranges = ''
42
+ }.should raise_error ArgumentError
43
+ end
44
+
45
+ it 'should be normal in range' do
46
+ normal_range = stub(DvInterval, :has => true)
47
+ @dv_ordered.normal_range = normal_range
48
+ @dv_ordered.is_normal?.should be_true
49
+ end
50
+
51
+ it 'is_strictly_comparable_to should be true for DvOrdered' do
52
+ @dv_ordered.is_strictly_comparable_to?(DvOrdered.new).should be_true
53
+ end
54
+
55
+ it 'should be raise NotImplemented error' do
56
+ lambda {
57
+ @dv_ordered<=>1
58
+ }.should raise_error(NotImplementedError)
59
+ end
60
+ end
@@ -0,0 +1,74 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity
3
+ include OpenEHR::RM::DataTypes::Text
4
+ include OpenEHR::RM::Support::Identification
5
+
6
+ describe DvOrdinal do
7
+ before(:each) do
8
+ terminology_id = stub(TerminologyID, :value => 'urine:prot')
9
+ code_phrase = stub(CodePhrase, :terminology_id => terminology_id)
10
+ symbol = stub(DvCodedText, :code_string => '+',
11
+ :defining_code => code_phrase)
12
+ dv_text = stub(DvText, :value => 'limits')
13
+ limits = stub(ReferenceRange, :meaning => dv_text)
14
+ @dv_ordinal = DvOrdinal.new(:value => 1,
15
+ :symbol => symbol,
16
+ :limits => limits)
17
+ end
18
+
19
+ it 'should be an instance of DvOrdinal' do
20
+ @dv_ordinal.should be_an_instance_of DvOrdinal
21
+ end
22
+
23
+ it 's value should be equal 1' do
24
+ @dv_ordinal.value.should be_equal 1
25
+ end
26
+
27
+ it 's symbol should be + code string' do
28
+ @dv_ordinal.symbol.code_string.should == '+'
29
+ end
30
+
31
+ it 's symbol defining_code should be urine:prot' do
32
+ @dv_ordinal.symbol.defining_code.terminology_id.value.should ==
33
+ 'urine:prot'
34
+ end
35
+
36
+ it 'should be strictry comperable to other DvOrdinal' do
37
+ terminology_id = stub(TerminologyID, :value => 'urine:prot')
38
+ code_phrase = stub(CodePhrase, :terminology_id => terminology_id)
39
+ symbol = stub(DvCodedText, :defining_code => code_phrase)
40
+ dv_ordinal = DvOrdinal.new(:value => 2,
41
+ :symbol => symbol)
42
+ @dv_ordinal.is_strictly_comparable_to?(dv_ordinal).should be_true
43
+ end
44
+
45
+ it 's limit.value should be limits' do
46
+ @dv_ordinal.limits.meaning.value.should == 'limits'
47
+ end
48
+
49
+ it 'should raise error when limits.value is not limitted' do
50
+ unlimit = stub(DvText, :value => 'unimitted')
51
+ unlimitted_range = stub(ReferenceRange, :meaning => unlimit)
52
+ lambda {
53
+ @dv_ordinal.limits = unlimitted_range
54
+ }.should raise_error ArgumentError
55
+ end
56
+
57
+ it 'should be comparable' do
58
+ dv_ordinal = stub(DvOrdinal, :value => 2)
59
+ @dv_ordinal.should < dv_ordinal
60
+ end
61
+
62
+ it 'is_strictly comparable should be false with other instance' do
63
+ @dv_ordinal.is_strictly_comparable_to?('dummy').should be_false
64
+ end
65
+
66
+ it 'is strictly comparable should be false with other terminology' do
67
+ terminology_id = stub(TerminologyID, :value => 'blood pressure')
68
+ code_phrase = stub(CodePhrase, :terminology_id => terminology_id)
69
+ symbol = stub(DvCodedText, :defining_code => code_phrase)
70
+ dv_ordinal = DvOrdinal.new(:value => 3,
71
+ :symbol => symbol)
72
+ @dv_ordinal.is_strictly_comparable_to?(dv_ordinal).should be_false
73
+ end
74
+ end
@@ -0,0 +1,162 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity
3
+ include OpenEHR::RM::DataTypes::Quantity::ProportionKind
4
+
5
+ describe DvProportion do
6
+ before(:all) do
7
+ @dv_proportion0 = DvProportion.new(:numerator => 2,
8
+ :denominator => 3,
9
+ :type => PK_RATIO,
10
+ :accuracy => 1,
11
+ :accuracy_percent => true)
12
+ @dv_proportion1 = DvProportion.new(:numerator => 3,
13
+ :denominator => 1,
14
+ :type => PK_UNITARY)
15
+ @dv_proportion2 = DvProportion.new(:numerator => 5,
16
+ :denominator => 100,
17
+ :type => PK_PERCENT)
18
+ @dv_proportion3 = DvProportion.new(:numerator => 7,
19
+ :denominator => 8,
20
+ :type => PK_FRACTION)
21
+ @dv_proportion4 = DvProportion.new(:numerator => 9,
22
+ :denominator => 10,
23
+ :type => PK_INTEGER_FRACTION)
24
+ end
25
+
26
+ describe 'PK_RATIO type' do
27
+ it 'should be an instance of DvProportion' do
28
+ @dv_proportion0.should be_an_instance_of DvProportion
29
+ end
30
+
31
+ it 's numerator should be equal 2' do
32
+ @dv_proportion0.numerator.should be_equal 2
33
+ end
34
+
35
+ it 's denominator should be equal 3' do
36
+ @dv_proportion0.denominator.should be_equal 3
37
+ end
38
+
39
+ it 's type should be equal 0' do
40
+ @dv_proportion0.type.should == 0
41
+ end
42
+
43
+ it 's magnitude should be 2/3' do
44
+ @dv_proportion0.magnitude.should == 2.0/3.0
45
+ end
46
+
47
+ it 's accuracy should be 1' do
48
+ @dv_proportion0.accuracy.should == 1
49
+ end
50
+
51
+ it 'is_integral? should be true' do
52
+ @dv_proportion0.is_integral?.should be_true
53
+ end
54
+
55
+ it 'should be comperable to same type DvProportion' do
56
+ dv_propotion_type = DvProportion.new(:numerator => 3,
57
+ :denominator => 4,
58
+ :type => 0)
59
+ @dv_proportion0.is_strictly_comparable_to?(dv_propotion_type).
60
+ should be_true
61
+ end
62
+
63
+ it 'should not be comparable to other type DvPropotion' do
64
+ @dv_proportion0.is_strictly_comparable_to?(@dv_proportion1).
65
+ should_not be_true
66
+ end
67
+
68
+ it 'should not be comperable to other class' do
69
+ @dv_proportion0.is_strictly_comparable_to?(1).
70
+ should_not be_true
71
+ end
72
+
73
+ it 'should raise ArguentError with invalid type -1' do
74
+ lambda {
75
+ @dv_proportion0.type = -1
76
+ }.should raise_error ArgumentError
77
+ end
78
+
79
+ it 'should raise ArgumentError with invalid type 5' do
80
+ lambda {
81
+ @dv_proportion0.type = 5
82
+ }.should raise_error ArgumentError
83
+ end
84
+
85
+ it 's precision should be 0' do
86
+ @dv_proportion0.precision = 0
87
+ @dv_proportion0.precision.should == 0
88
+ end
89
+
90
+ it 'should raise ArgumentError when is_integral? and precision !=0' do
91
+ lambda {@dv_proportion0.precision = 1}.should raise_error ArgumentError
92
+ end
93
+
94
+ it 'shoud not raise ArgumentError when is_not ntegral' do
95
+ @dv_proportion0.numerator = 2.5
96
+ lambda {
97
+ @dv_proportion0.precision = 1
98
+ }.should_not raise_error ArgumentError
99
+ end
100
+ end
101
+
102
+ describe 'PK_UNITARY type' do
103
+ it 'should be an instance of DvPropotion' do
104
+ @dv_proportion1.should be_an_instance_of DvProportion
105
+ end
106
+
107
+ it 'should raise ArgumentError without denominator 1' do
108
+ lambda {
109
+ @dv_proportion1.denominator = 10
110
+ }.should raise_error ArgumentError
111
+ end
112
+ end
113
+
114
+ describe 'PK_PERCENT type' do
115
+ it 'should be an instance of DvProportion' do
116
+ @dv_proportion2.should be_an_instance_of DvProportion
117
+ end
118
+
119
+ it 'should raise ArgumentError without denominator 100' do
120
+ lambda {
121
+ @dv_proportion2.denominator = 101
122
+ }.should raise_error ArgumentError
123
+ end
124
+ end
125
+
126
+ describe 'PK_FRACTION type' do
127
+ it 'should be an instance of DvProportion' do
128
+ @dv_proportion3.should be_an_instance_of DvProportion
129
+ end
130
+
131
+ it 'should raise ArgumentError with fractional denominator' do
132
+ lambda {
133
+ @dv_proportion3.denominator = 0.5
134
+ }.should raise_error ArgumentError
135
+ end
136
+
137
+ it 'should raise ArgumentError with fractional numerator' do
138
+ lambda {
139
+ @dv_proportion3.numerator = 0.5
140
+ }.should raise_error ArgumentError
141
+ end
142
+ end
143
+
144
+ describe 'PK_FRACTION_INTEGER type' do
145
+ it 'should be an instance of DvProportion' do
146
+ @dv_proportion4.should be_an_instance_of DvProportion
147
+ end
148
+
149
+ it 'should raise ArgumentError with fractional denominator' do
150
+ lambda {
151
+ @dv_proportion4.denominator = 0.5
152
+ }.should raise_error ArgumentError
153
+
154
+ end
155
+
156
+ it 'should raise ArgumentError with fractional numerator' do
157
+ lambda {
158
+ @dv_proportion4.numerator = 0.5
159
+ }.should raise_error ArgumentError
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,36 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity
3
+
4
+ describe DvQuantified do
5
+ before(:all) do
6
+ @dv_quantified = DvQuantified.new(:magnitude => 1,
7
+ :magnitude_status => '=')
8
+ end
9
+
10
+ it 'should be an instance of DvQuantified' do
11
+ @dv_quantified.should be_an_instance_of DvQuantified
12
+ end
13
+
14
+ it 's magnitude should be 1' do
15
+ @dv_quantified.magnitude.should be_equal 1
16
+ end
17
+
18
+ it 's magnitude_status should be =' do
19
+ @dv_quantified.magnitude_status.should == '='
20
+ end
21
+
22
+ it 's comparable to other DvQuantified' do
23
+ dv_quantified = DvQuantified.new(:magnitude => 2)
24
+ @dv_quantified.should < dv_quantified
25
+ end
26
+
27
+ it 'should raise ArgumentError with invalid magnitude_status' do
28
+ lambda {
29
+ @dv_quantified.magnitude_status = '+'
30
+ }.should raise_error ArgumentError
31
+ end
32
+
33
+ it 's accuracy should be unknown' do
34
+ @dv_quantified.should be_accuracy_unknown
35
+ end
36
+ end
@@ -0,0 +1,78 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::RM::DataTypes::Quantity
3
+
4
+ describe DvQuantity do
5
+ before(:each) do
6
+ @dv_quantity = DvQuantity.new(:magnitude => 3,
7
+ :units => 'mg',
8
+ :precision => 0)
9
+ end
10
+
11
+ it 'should be an instance of DvQuantity' do
12
+ @dv_quantity.should be_instance_of DvQuantity
13
+ end
14
+
15
+ it 's units should be mg' do
16
+ @dv_quantity.units.should == 'mg'
17
+ end
18
+
19
+ describe 'Mathematical Operation' do
20
+ before(:each) do
21
+ @dv_quantity5 = DvQuantity.new(:magnitude => 5,
22
+ :units => 'mg')
23
+ end
24
+
25
+ it 'should be comparable to 5mg' do
26
+ @dv_quantity.is_strictly_comparable_to?(@dv_quantity5).should be_true
27
+ end
28
+
29
+ it 'should be 8mg added 5mg' do
30
+ dv_quantity = @dv_quantity + @dv_quantity5
31
+ dv_quantity.magnitude.should == 8
32
+ end
33
+
34
+ it 'should be -2mg minus 5mg' do
35
+ dv_quantity = @dv_quantity - @dv_quantity5
36
+ dv_quantity.magnitude.should == -2
37
+ end
38
+
39
+ it 's unit should be mg' do
40
+ (@dv_quantity + @dv_quantity5).units.should == 'mg'
41
+ end
42
+ end
43
+
44
+ it 'should not be comparable to 8km' do
45
+ dv_quantity = DvQuantity.new(:magnitude => 8,
46
+ :units => 'km')
47
+ @dv_quantity.is_strictly_comparable_to?(dv_quantity).should_not be_true
48
+ end
49
+
50
+ it 'should return false with other type' do
51
+ @dv_quantity.is_strictly_comparable_to?(1).should_not be_true
52
+ end
53
+
54
+ it 's precision should be equal 0' do
55
+ @dv_quantity.precision.should == 0
56
+ end
57
+
58
+ it 'should be integral' do
59
+ @dv_quantity.is_integral?.should be_true
60
+ end
61
+
62
+ it 'should not be integral do' do
63
+ @dv_quantity.precision = 3
64
+ @dv_quantity.is_integral?.should_not be_true
65
+ end
66
+
67
+ it 'should not raise ArgumentError with -1 precision' do
68
+ lambda {
69
+ @dv_quantity.precision = -1
70
+ }.should_not raise_error ArgumentError
71
+ end
72
+
73
+ it 'should raise ArgumentError with -2 precision' do
74
+ lambda {
75
+ @dv_quantity.precision = -2
76
+ }.should raise_error ArgumentError
77
+ end
78
+ end