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,59 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::AM::Archetype::Ontology
3
+ include OpenEHR::RM::DataTypes::Text
4
+
5
+ describe ArchetypeOntology do
6
+ before(:each) do
7
+ items = {'TEXT' => 'text', 'DESC' => 'description'}
8
+ term1 = ArchetypeTerm.new(:code => 'at0000', :items => items)
9
+ items = {'TEXT' => 'concept'}
10
+ term2 = ArchetypeTerm.new(:code => 'at0001', :items => items)
11
+ term_definitions = {'ja' => [term1, term2]}
12
+ items = {'text' => 'test', 'description' => 'test item'}
13
+ term3 = ArchetypeTerm.new(:code => 'ac0000', :items => items)
14
+ constraint_definitions = {'ja' => [term3]}
15
+ code_phrase = stub(CodePhrase, :code_string => '163020007')
16
+ bind = {'at0000' => code_phrase}
17
+ term_bindings = {'SNOMED-CT(2003)' => [bind]}
18
+ @archetype_ontology =
19
+ ArchetypeOntology.new(:term_definitions => term_definitions,
20
+ :constraint_definitions => constraint_definitions,
21
+ :term_bindings => term_bindings,
22
+ :specialisation_depth => 0)
23
+ end
24
+
25
+ it 'should be an instance of ArchetypeOntology' do
26
+ @archetype_ontology.should be_an_instance_of ArchetypeOntology
27
+ end
28
+
29
+ it 'specialisation depth should be assigned properly' do
30
+ @archetype_ontology.specialisation_depth.should be_equal 0
31
+ end
32
+
33
+ it 'term_definitions should be assigned properly' do
34
+ @archetype_ontology.term_definitions['ja'][0].code.should == 'at0000'
35
+ end
36
+
37
+ it 'term_codes should returnd all at codes' do
38
+ @archetype_ontology.term_codes.should == ['at0000','at0001']
39
+ end
40
+
41
+ it 'constraint_definitions should be assigned properly' do
42
+ @archetype_ontology.constraint_definitions['ja'][0].items['text'].
43
+ should == 'test'
44
+ end
45
+
46
+ it 'constrant_codes should return all ac codes' do
47
+ @archetype_ontology.constraint_codes.should == ['ac0000']
48
+ end
49
+
50
+ it 'term_bindings should be assigned properly' do
51
+ @archetype_ontology.term_bindings['SNOMED-CT(2003)'][0]['at0000'].
52
+ code_string.should == '163020007'
53
+ end
54
+
55
+ it 'terminologies_available should return available terminology' do
56
+ @archetype_ontology.terminologies_available.should == ['SNOMED-CT(2003)']
57
+ end
58
+ end
59
+
@@ -0,0 +1,43 @@
1
+ require File.dirname(__FILE__) + '/../../../../../spec_helper'
2
+ include OpenEHR::AM::Archetype::Ontology
3
+
4
+ describe ArchetypeTerm do
5
+ before(:each) do
6
+ items = {'TEXT' => 'text', 'DESC' => 'description'}
7
+ @archetype_term = ArchetypeTerm.new(:code => 'at0001',
8
+ :items => items)
9
+ end
10
+
11
+ it 'should be an instance of ArchetypeTerm' do
12
+ @archetype_term.should be_an_instance_of ArchetypeTerm
13
+ end
14
+
15
+ it 'code should be assigned properly' do
16
+ @archetype_term.code.should == 'at0001'
17
+ end
18
+
19
+ it 'should raise ArgumentError if code is nil' do
20
+ lambda {
21
+ @archetype_term.code = nil
22
+ }.should raise_error ArgumentError
23
+ end
24
+
25
+ it 'should raise ArgumentError if code is empty' do
26
+ lambda {
27
+ @archetype_term.code = ''
28
+ }.should raise_error ArgumentError
29
+ end
30
+
31
+ it 'items should be assigned properly' do
32
+ @archetype_term.items['TEXT'].should == 'text'
33
+ end
34
+
35
+ it 'keys should be a set of keys of item' do
36
+ @archetype_term.keys.should == Set['TEXT', 'DESC']
37
+ end
38
+
39
+ it 'keys should be empty if items are nil' do
40
+ @archetype_term.items = nil
41
+ @archetype_term.keys.should == Set.new
42
+ end
43
+ end
@@ -0,0 +1,42 @@
1
+ require File.dirname(__FILE__) + '/../../../../spec_helper'
2
+ include OpenEHR::AM::Archetype
3
+
4
+ describe ValidityKind do
5
+ before(:each) do
6
+ @validity_kind = ValidityKind.new(:value => 1002)
7
+ end
8
+
9
+ it 'should be an instance of ValidityKind' do
10
+ @validity_kind.should be_an_instance_of ValidityKind
11
+ end
12
+
13
+ it 'mandatory should be equal 1001' do
14
+ ValidityKind::MANDATORY.should be_equal 1001
15
+ end
16
+
17
+ it 'optional should be equal 1002' do
18
+ ValidityKind::OPTIONAL.should be_equal 1002
19
+ end
20
+
21
+ it 'disallowed should be equal 1003' do
22
+ ValidityKind::DISALLOWED.should be_equal 1003
23
+ end
24
+
25
+ it 'should not raise ArgumentError with valid value' do
26
+ lambda {
27
+ [1001, 1002, 1003].each {|value| @validity_kind.value = value}
28
+ }.should_not raise_error ArgumentError
29
+ end
30
+
31
+ it 'should raise ArgumentError with invalid value such as 1000' do
32
+ lambda {
33
+ @validity_kind.value = 1000
34
+ }.should raise_error ArgumentError
35
+ end
36
+
37
+ it 'should raise ArgumentError with invalid value such as 1004' do
38
+ lambda {
39
+ @validity_kind.value = 1004
40
+ }.should raise_error ArgumentError
41
+ end
42
+ end
@@ -0,0 +1,140 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ include OpenEHR::AssumedLibraryTypes
3
+
4
+ describe Interval do
5
+ before(:each) do
6
+ @interval = Interval.new(:upper => 10,
7
+ :lower => 1)
8
+ end
9
+
10
+ it 'should be an instance of Interval' do
11
+ @interval.should be_an_instance_of Interval
12
+ end
13
+
14
+ it 's upper should be greater than lower' do
15
+ @interval.upper.should be > @interval.lower
16
+ end
17
+
18
+ it 's upper should be equal 10' do
19
+ @interval.upper.should == 10
20
+ end
21
+
22
+ it 's lower should be equal 1' do
23
+ @interval.lower.should == 1
24
+ end
25
+
26
+ it 'should raise ArgumentError with smaller upper' do
27
+ lambda {@interval.upper = -1}.should raise_error ArgumentError
28
+ end
29
+
30
+ it 'should raise ArgumentError with greater lower' do
31
+ lambda {@interval.lower = 11}.should raise_error ArgumentError
32
+ end
33
+
34
+ it 'should have 5' do
35
+ @interval.has?(5).should be_true
36
+ end
37
+
38
+ it 'should not have 11' do
39
+ @interval.has?(11).should_not be_true
40
+ end
41
+
42
+ it 'should not have -1' do
43
+ @interval.has?(-1).should_not be_true
44
+ end
45
+
46
+ it 'should not have 10' do
47
+ @interval.has?(10).should_not be_true
48
+ end
49
+
50
+ it 'should not have 1' do
51
+ @interval.has?(1).should_not be_true
52
+ end
53
+
54
+ describe Interval, 'when lower included' do
55
+ before do
56
+ @interval.lower_included = true
57
+ end
58
+
59
+ it 'should be lower_included' do
60
+ @interval.should be_lower_included
61
+ end
62
+
63
+ it 'should have 1 when lower included' do
64
+ @interval.has?(1).should be_true
65
+ end
66
+
67
+ after do
68
+ @interval.lower_included = false
69
+ end
70
+ end
71
+
72
+ describe Interval, 'when upper included' do
73
+ before do
74
+ @interval.upper_included = true
75
+ end
76
+
77
+ it 'should be upper uncluded' do
78
+ @interval.should be_upper_included
79
+ end
80
+
81
+ it 'should have 10 when upper included' do
82
+ @interval.has?(10).should be_true
83
+ end
84
+
85
+ after do
86
+ @interval.upper_included = false
87
+ end
88
+ end
89
+
90
+ describe Interval, 'when upper unbounded' do
91
+ before do
92
+ @interval.upper = nil
93
+ end
94
+
95
+ it 'should be upper unbounded' do
96
+ @interval.should be_upper_unbounded
97
+ end
98
+
99
+ it 'should have 11' do
100
+ @interval.has?(11).should be_true
101
+ end
102
+
103
+ it 'should raise ArgumentError, when upper_included is assigned' do
104
+ lambda{
105
+ @interval.upper_included = true
106
+ }.should raise_error ArgumentError
107
+ end
108
+
109
+ after do
110
+ @interval.upper = 10
111
+ end
112
+ end
113
+
114
+ describe Interval, 'when lower unbounded' do
115
+ before do
116
+ @interval.lower = nil
117
+ end
118
+
119
+ it 'should be lower unbounded' do
120
+ @interval.should be_lower_unbounded
121
+ end
122
+
123
+ it 'should have -10' do
124
+ @interval.has?(-10).should be_true
125
+ end
126
+
127
+ it 'should raise ArgumentError, when lower_included is assigned' do
128
+ lambda{
129
+ @interval.lower_included = true
130
+ }.should raise_error ArgumentError
131
+ end
132
+ end
133
+
134
+ it 'should raise ArgumentError both upper and lower is nil' do
135
+ lambda {
136
+ Interval.new
137
+ }.should raise_error ArgumentError
138
+ end
139
+ end
140
+
@@ -0,0 +1,236 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ include OpenEHR::AssumedLibraryTypes
3
+
4
+ describe ISO8601Date do
5
+ before do
6
+ @iso8601date = ISO8601Date.new('2009-09-10')
7
+ end
8
+
9
+ it 'should be an instance of ISO8601Date' do
10
+ @iso8601date.should be_an_instance_of ISO8601Date
11
+ end
12
+
13
+ it 'year should be equal 2009' do
14
+ @iso8601date.year.should be_equal 2009
15
+ end
16
+
17
+ it 'month should be equal 9' do
18
+ @iso8601date.month.should be_equal 9
19
+ end
20
+
21
+ it 'day should be equal 10' do
22
+ @iso8601date.day.should be_equal 10
23
+ end
24
+
25
+ it 'should be 2009-09-10 as_string' do
26
+ @iso8601date.as_string.should == '2009-09-10'
27
+ end
28
+
29
+ it 'should be extended ' do
30
+ @iso8601date.is_extended?.should be_true
31
+ end
32
+
33
+ it 'should parse vaild date form' do
34
+
35
+ end
36
+
37
+ it 'should parse valid adte form' do
38
+ ISO8601Date.should be_valid_iso8601_date '2009-09-22'
39
+ end
40
+
41
+ it 'should not parse invalid date form' do
42
+ ISO8601Date.should_not be_valid_iso8601_date '2009-13-54'
43
+ end
44
+
45
+ describe 'year behavior' do
46
+ it 'should raise ArgumentError with nil year string' do
47
+ lambda{ISO8601Date.new('-09-02')}.should raise_error ArgumentError
48
+ end
49
+
50
+ it 'should raise ArgumentError with nil year' do
51
+ lambda{@iso8601date.year = nil}.should raise_error ArgumentError
52
+ end
53
+
54
+ it 'should not raise ArgumentError more than 0 year' do
55
+ lambda{@iso8601date.year = 0}.should_not raise_error ArgumentError
56
+ end
57
+ end
58
+
59
+ describe 'month behavior' do
60
+ it '1 month should not raise ArgumentError' do
61
+ lambda{@iso8601date.month = 1}.should_not raise_error ArgumentError
62
+ end
63
+
64
+ it '12 month should not raise ArgumentError' do
65
+ lambda{@iso8601date.month = 12}.should_not raise_error ArgumentError
66
+ end
67
+
68
+ it '13 month should raise ArgumentError' do
69
+ lambda{@iso8601date.month = 13}.should raise_error ArgumentError
70
+ end
71
+
72
+ it '0 month should raise ArgumentError' do
73
+ lambda{@iso8601date.month = 0}.should raise_error ArgumentError
74
+ end
75
+ end
76
+
77
+ describe 'day behavior' do
78
+ it '0 day should raise ArgumentError' do
79
+ lambda{@iso8601date.day = 0}.should raise_error ArgumentError
80
+ end
81
+ end
82
+
83
+ [1,3,5,7,8,10,12].each do |m|
84
+ describe '#{m}th month behavior' do
85
+ before do
86
+ @iso8601date.month = m
87
+ end
88
+
89
+ it 'should have 31 days' do
90
+ lambda{
91
+ @iso8601date.day = 31
92
+ }.should_not raise_error ArgumentError
93
+ end
94
+
95
+ it 'should not have 32 days' do
96
+ lambda{
97
+ @iso8601date.day = 32
98
+ }.should raise_error ArgumentError
99
+ end
100
+ end
101
+ end
102
+
103
+ describe 'February and leap year behavior' do
104
+ before do
105
+ @iso8601date.month = 2
106
+ end
107
+
108
+ describe '2009(not leap year) behavior' do
109
+ before do
110
+ @iso8601date.year = 2009
111
+ end
112
+
113
+ it '2009 should not be leap year' do
114
+ @iso8601date.should_not be_leapyear 2009
115
+ end
116
+
117
+ it '2009-02-28 should not raise ArgumentError' do
118
+ lambda{@iso8601date.day = 28}.should_not raise_error ArgumentError
119
+ end
120
+
121
+ it '2009-02-29 should raise ArgumentError' do
122
+ lambda{@iso8601date.day = 29}.should raise_error ArgumentError
123
+ end
124
+ end
125
+
126
+ describe '2008(leap year) behavior' do
127
+ before do
128
+ @iso8601date.year = 2008
129
+ end
130
+
131
+ it '2008 should be leap year' do
132
+ @iso8601date.should be_leapyear 2008
133
+ end
134
+
135
+ it '2008-02-29 should not raise ArgumentError' do
136
+ lambda{@iso8601date.day = 29}.should_not raise_error ArgumentError
137
+ end
138
+
139
+ it '2008-02-30 should raise ArgumentError' do
140
+ lambda{@iso8601date.day = 30}.should raise_error ArgumentError
141
+ end
142
+ end
143
+
144
+ describe '2000(irregular leap year' do
145
+ before do
146
+ @iso8601date.year = 2000
147
+ end
148
+
149
+ it 'should not leapyear' do
150
+ @iso8601date.should be_leapyear 2000
151
+ end
152
+
153
+ it '2000-02-29 should not raise ArgumentError' do
154
+ lambda{@iso8601date.day = 29}.should_not raise_error ArgumentError
155
+ end
156
+
157
+ it '2000-02-30 should raise ArgumentError' do
158
+ lambda{@iso8601date.day = 30}.should raise_error ArgumentError
159
+ end
160
+ end
161
+ end
162
+
163
+ [4,6,9,11].each do |month|
164
+ describe "#{month}th month behavior" do
165
+ before do
166
+ @iso8601date.month = month
167
+ end
168
+
169
+ it '30 day should not raise ArgumentError' do
170
+ lambda{
171
+ @iso8601date.day = 30
172
+ }.should_not raise_error ArgumentError
173
+ end
174
+
175
+ it '31 day should raise ArgumentError' do
176
+ lambda{
177
+ @iso8601date.day = 31
178
+ }.should raise_error ArgumentError
179
+ end
180
+ end
181
+ end
182
+
183
+ describe 'partial date data' do
184
+ describe 'day unknown' do
185
+ before do
186
+ @iso8601date.day = nil
187
+ end
188
+
189
+ it 'day should be unknown' do
190
+ @iso8601date.should be_day_unknown
191
+ end
192
+
193
+ it 'should be 2009-09 as string' do
194
+ @iso8601date.as_string.should == '2009-09'
195
+ end
196
+
197
+ it 'should be partial' do
198
+ @iso8601date.is_partial?.should be_true
199
+ end
200
+
201
+ it 'constructor pass partial date' do
202
+ lambda {
203
+ ISO8601Date.new('2009-09')
204
+ }.should_not raise_error ArgumentError
205
+ end
206
+
207
+ after do
208
+ @iso8601date.day = 10
209
+ end
210
+ end
211
+
212
+ describe 'month unknown' do
213
+ before do
214
+ @iso8601date.day = nil
215
+ @iso8601date.month = nil
216
+ end
217
+
218
+ it 'should raise ArgumentError with nil month and not nil day' do
219
+ lambda {
220
+ @iso8601date.day = 11
221
+ }.should raise_error ArgumentError
222
+ end
223
+
224
+ it 's as_string should be 2009' do
225
+ @iso8601date.as_string.should == '2009'
226
+ end
227
+
228
+ it 'constructor pass only year data' do
229
+ lambda {
230
+ ISO8601Date.new('2009')
231
+ }.should_not raise_error ArgumentError
232
+ end
233
+ end
234
+ end
235
+
236
+ end
@@ -0,0 +1,47 @@
1
+ require File.dirname(__FILE__) + '/../../../spec_helper'
2
+ include OpenEHR::AssumedLibraryTypes
3
+
4
+ describe ISO8601DateTime do
5
+ before(:each) do
6
+ @iso8601date_time = ISO8601DateTime.new('2009-06-29T12:34:56.78+0900')
7
+ end
8
+
9
+ it 'should be an instance of ISO8601DateTime' do
10
+ @iso8601date_time.should be_an_instance_of ISO8601DateTime
11
+ end
12
+
13
+ it 'should be 2009-06-29T12:34:56.78T+09:00 as string' do
14
+ @iso8601date_time.as_string.should == '2009-06-29T12:34:56.78+0900'
15
+ end
16
+
17
+ it 'should raise ArgumentError with invalid date format' do
18
+ lambda {
19
+ ISO8601DateTime.new('2009:06:29Z12-34-56')
20
+ }.should raise_error ArgumentError
21
+ end
22
+
23
+ it 'should raise ArgumentErrow with empty argument' do
24
+ lambda {
25
+ ISO8601DateTime.new('')
26
+ }.should raise_error ArgumentError
27
+ end
28
+
29
+ it 'allows without fractional second' do
30
+ lambda {
31
+ ISO8601DateTime.new('2009-06-29T12:34:56')
32
+ }.should_not raise_error ArgumentError
33
+ end
34
+
35
+ describe 'partial date' do
36
+ it 'should recognize 2009-06' do
37
+ @iso8601date_time.day = nil
38
+ @iso8601date_time.as_string.should == '2009-06'
39
+ end
40
+
41
+ it 'should recognize 2009' do
42
+ @iso8601date_time.day = nil
43
+ @iso8601date_time.month = nil
44
+ @iso8601date_time.as_string.should == '2009'
45
+ end
46
+ end
47
+ end