open_ehr 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +43 -0
- data/Guardfile +9 -0
- data/History.txt +4 -0
- data/Manifest.txt +16 -0
- data/PostInstall.txt +9 -0
- data/README.rdoc +66 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/doc/README_rdoc.html +148 -0
- data/doc/created.rid +2 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +54 -0
- data/doc/js/darkfish.js +116 -0
- data/doc/js/jquery.js +32 -0
- data/doc/js/quicksearch.js +114 -0
- data/doc/js/thickbox-compressed.js +10 -0
- data/doc/openehr_terminology.xml +2700 -0
- data/doc/rdoc.css +706 -0
- data/lib/#open_ehr.rb# +11 -0
- data/lib/open_ehr/am/archetype/archetype_description/archetype_description.rb +21 -0
- data/lib/open_ehr/am/archetype/assertion.rb +190 -0
- data/lib/open_ehr/am/archetype/constraint_model/primitive.rb +296 -0
- data/lib/open_ehr/am/archetype/constraint_model.rb +340 -0
- data/lib/open_ehr/am/archetype/ontology.rb +97 -0
- data/lib/open_ehr/am/archetype.rb +134 -0
- data/lib/open_ehr/am/open_ehr_profile/data_types/basic.rb +29 -0
- data/lib/open_ehr/am/open_ehr_profile/data_types/quantity.rb +19 -0
- data/lib/open_ehr/am/open_ehr_profile/data_types/text.rb +12 -0
- data/lib/open_ehr/am.rb +8 -0
- data/lib/open_ehr/assumed_library_types.rb +627 -0
- data/lib/open_ehr/parser/xml_perser.rb +13 -0
- data/lib/open_ehr/parser.rb +19 -0
- data/lib/open_ehr/rm/common/archetyped.rb +182 -0
- data/lib/open_ehr/rm/common/change_control.rb +332 -0
- data/lib/open_ehr/rm/common/directory.rb +29 -0
- data/lib/open_ehr/rm/common/generic.rb +216 -0
- data/lib/open_ehr/rm/common/resource.rb +154 -0
- data/lib/open_ehr/rm/common.rb +14 -0
- data/lib/open_ehr/rm/composition/content/entry.rb +246 -0
- data/lib/open_ehr/rm/composition/content/navigation.rb +31 -0
- data/lib/open_ehr/rm/composition/content.rb +22 -0
- data/lib/open_ehr/rm/composition.rb +103 -0
- data/lib/open_ehr/rm/data_structures/history.rb +117 -0
- data/lib/open_ehr/rm/data_structures/item_structure/representation.rb +63 -0
- data/lib/open_ehr/rm/data_structures/item_structure.rb +216 -0
- data/lib/open_ehr/rm/data_structures.rb +25 -0
- data/lib/open_ehr/rm/data_types/basic.rb +108 -0
- data/lib/open_ehr/rm/data_types/charset.lst +818 -0
- data/lib/open_ehr/rm/data_types/charset_extract.rb +24 -0
- data/lib/open_ehr/rm/data_types/encapsulated.rb +98 -0
- data/lib/open_ehr/rm/data_types/quantity/date_time.rb +229 -0
- data/lib/open_ehr/rm/data_types/quantity.rb +403 -0
- data/lib/open_ehr/rm/data_types/text.rb +168 -0
- data/lib/open_ehr/rm/data_types/time_specification.rb +75 -0
- data/lib/open_ehr/rm/data_types/uri.rb +82 -0
- data/lib/open_ehr/rm/data_types.rb +14 -0
- data/lib/open_ehr/rm/demographic.rb +269 -0
- data/lib/open_ehr/rm/ehr.rb +162 -0
- data/lib/open_ehr/rm/integration.rb +27 -0
- data/lib/open_ehr/rm/security.rb +12 -0
- data/lib/open_ehr/rm/support/assumed_types.rb +81 -0
- data/lib/open_ehr/rm/support/definition.rb +15 -0
- data/lib/open_ehr/rm/support/identification.rb +408 -0
- data/lib/open_ehr/rm/support/measurement.rb +17 -0
- data/lib/open_ehr/rm/support/terminology.rb +135 -0
- data/lib/open_ehr/rm/support.rb +14 -0
- data/lib/open_ehr/rm.rb +16 -0
- data/lib/open_ehr/serializer.rb +272 -0
- data/lib/open_ehr/terminology/open_ehr_terminology.rb +41 -0
- data/lib/open_ehr/terminology.rb +7 -0
- data/lib/open_ehr/writer.rb +12 -0
- data/lib/open_ehr.rb +11 -0
- data/spec/lib/open_ehr/am/archetype/archetype_spec.rb +98 -0
- data/spec/lib/open_ehr/am/archetype/assertion/assertion_spec.rb +60 -0
- data/spec/lib/open_ehr/am/archetype/assertion/assertion_variable_spec.rb +30 -0
- data/spec/lib/open_ehr/am/archetype/assertion/expr_binary_operator.rb +40 -0
- data/spec/lib/open_ehr/am/archetype/assertion/expr_item_spec.rb +28 -0
- data/spec/lib/open_ehr/am/archetype/assertion/expr_leaf_spec.rb +34 -0
- data/spec/lib/open_ehr/am/archetype/assertion/expr_operator_spec.rb +25 -0
- data/spec/lib/open_ehr/am/archetype/assertion/expr_unary_operator_spec.rb +26 -0
- data/spec/lib/open_ehr/am/archetype/assertion/operator_kind_spec.rb +110 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/archetype_constraint_spec.rb +56 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/archetype_internal_ref_spec.rb +36 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/archetype_slot_spec.rb +61 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_attribute_spec.rb +59 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_complex_object_spec.rb +39 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_defined_object_spec.rb +53 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_domain_type_spec.rb +25 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_multiple_attribute_spec.rb +29 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_object_spec.rb +61 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_primitive_object_spec.rb +33 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_reference_object_spec.rb +17 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/c_single_attribute_spec.rb +28 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/cardinality_spec.rb +68 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/constraint_ref_spec.rb +29 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_boolean_spec.rb +52 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_spec.rb +80 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_date_time_spec.rb +106 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_duration_spec.rb +69 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_integer_spec.rb +62 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_primitive_spec.rb +39 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_real_spec.rb +14 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_string_spec.rb +69 -0
- data/spec/lib/open_ehr/am/archetype/constraint_model/primitive/c_time_spec.rb +79 -0
- data/spec/lib/open_ehr/am/archetype/ontology/archetype_ontology_spec.rb +59 -0
- data/spec/lib/open_ehr/am/archetype/ontology/archetype_term_spec.rb +43 -0
- data/spec/lib/open_ehr/am/archetype/validity_kind_spec.rb +42 -0
- data/spec/lib/open_ehr/assumed_library_types/interval_spec.rb +140 -0
- data/spec/lib/open_ehr/assumed_library_types/iso8601_date_spec.rb +236 -0
- data/spec/lib/open_ehr/assumed_library_types/iso8601_date_time_spec.rb +47 -0
- data/spec/lib/open_ehr/assumed_library_types/iso8601_duration_spec.rb +150 -0
- data/spec/lib/open_ehr/assumed_library_types/iso8601_time_spec.rb +234 -0
- data/spec/lib/open_ehr/assumed_library_types/iso8601_timezone_spec.rb +57 -0
- data/spec/lib/open_ehr/assumed_library_types/time_definitions_spec.rb +136 -0
- data/spec/lib/open_ehr/rm/common/archetyped/archetyped_spec.rb +50 -0
- data/spec/lib/open_ehr/rm/common/archetyped/feeder_audit_details_spec.rb +60 -0
- data/spec/lib/open_ehr/rm/common/archetyped/feeder_audit_spec.rb +51 -0
- data/spec/lib/open_ehr/rm/common/archetyped/link_spec.rb +42 -0
- data/spec/lib/open_ehr/rm/common/archetyped/locatable_spec.rb +89 -0
- data/spec/lib/open_ehr/rm/common/archetyped/pathable_spec.rb +42 -0
- data/spec/lib/open_ehr/rm/common/change_control/contribution_spec.rb +56 -0
- data/spec/lib/open_ehr/rm/common/change_control/imported_version_spec.rb +63 -0
- data/spec/lib/open_ehr/rm/common/change_control/original_version_spec.rb +71 -0
- data/spec/lib/open_ehr/rm/common/change_control/version_spec.rb +92 -0
- data/spec/lib/open_ehr/rm/common/change_control/versioned_object_spec.rb +285 -0
- data/spec/lib/open_ehr/rm/common/directory/folder_spec.rb +26 -0
- data/spec/lib/open_ehr/rm/common/generic/attestation_spec.rb +62 -0
- data/spec/lib/open_ehr/rm/common/generic/audit_details_spec.rb +51 -0
- data/spec/lib/open_ehr/rm/common/generic/participation_spec.rb +36 -0
- data/spec/lib/open_ehr/rm/common/generic/party_identified_spec.rb +64 -0
- data/spec/lib/open_ehr/rm/common/generic/party_proxy_spec.rb +18 -0
- data/spec/lib/open_ehr/rm/common/generic/party_related_spec.rb +24 -0
- data/spec/lib/open_ehr/rm/common/generic/revision_history_item_spec.rb +43 -0
- data/spec/lib/open_ehr/rm/common/generic/revision_history_spec.rb +45 -0
- data/spec/lib/open_ehr/rm/common/resource/authored_resource_spec.rb +68 -0
- data/spec/lib/open_ehr/rm/common/resource/resource_description_item_spec.rb +105 -0
- data/spec/lib/open_ehr/rm/common/resource/resource_description_spec.rb +74 -0
- data/spec/lib/open_ehr/rm/common/resource/translation_details_spec.rb +35 -0
- data/spec/lib/open_ehr/rm/composition/composition_spec.rb +92 -0
- data/spec/lib/open_ehr/rm/composition/content/content_item_spec.rb +14 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/action_spec.rb +69 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/activity_spec.rb +61 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/admin_entry_spec.rb +38 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/care_entry_spec.rb +37 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/entry_spec.rb +88 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/evaluation_spec.rb +37 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/instruction_details_spec.rb +51 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/instruction_spec.rb +62 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/ism_transition_spec.rb +46 -0
- data/spec/lib/open_ehr/rm/composition/content/entry/observation_spec.rb +45 -0
- data/spec/lib/open_ehr/rm/composition/content/navigation/section_spec.rb +32 -0
- data/spec/lib/open_ehr/rm/composition/event_context_spec.rb +88 -0
- data/spec/lib/open_ehr/rm/data_structures/data_structure_spec.rb +21 -0
- data/spec/lib/open_ehr/rm/data_structures/history/event_spec.rb +44 -0
- data/spec/lib/open_ehr/rm/data_structures/history/history_spec.rb +67 -0
- data/spec/lib/open_ehr/rm/data_structures/history/interval_event_spec.rb +43 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/item_list_spec.rb +53 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/item_single_spec.rb +29 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/item_table_spec.rb +147 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/item_tree_spec.rb +48 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/representation/cluster_spec.rb +26 -0
- data/spec/lib/open_ehr/rm/data_structures/item_structure/representation/element_spec.rb +22 -0
- data/spec/lib/open_ehr/rm/data_types/basic/data_value_spec.rb +17 -0
- data/spec/lib/open_ehr/rm/data_types/basic/dv_boolean_spec.rb +29 -0
- data/spec/lib/open_ehr/rm/data_types/basic/dv_identifier_spec.rb +108 -0
- data/spec/lib/open_ehr/rm/data_types/basic/dv_state_spec.rb +44 -0
- data/spec/lib/open_ehr/rm/data_types/encapsulated/dv_encapsulated_spec.rb +42 -0
- data/spec/lib/open_ehr/rm/data_types/encapsulated/dv_multimedia_spec.rb +79 -0
- data/spec/lib/open_ehr/rm/data_types/encapsulated/dv_parsable_spec.rb +34 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_spec.rb +64 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_date_time_spec.rb +25 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_tempral_spec.rb +24 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/date_time/dv_time_spec.rb +37 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_absolute_quantity_spec.rb +35 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_amount_spec.rb +105 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_count_spec.rb +12 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_interval_spec.rb +17 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_ordered_spec.rb +60 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_ordinal_spec.rb +74 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_proportion_spec.rb +162 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_quantified_spec.rb +36 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/dv_quantity_spec.rb +78 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/proportion_kind_spec.rb +24 -0
- data/spec/lib/open_ehr/rm/data_types/quantity/reference_range_spec.rb +43 -0
- data/spec/lib/open_ehr/rm/data_types/text/code_phrase_spec.rb +23 -0
- data/spec/lib/open_ehr/rm/data_types/text/dv_paragraph_spec.rb +13 -0
- data/spec/lib/open_ehr/rm/data_types/text/dv_text_spec.rb +57 -0
- data/spec/lib/open_ehr/rm/data_types/text/term_mapping_spec.rb +59 -0
- data/spec/lib/open_ehr/rm/data_types/uri/dv_ehr_uri_spec.rb +21 -0
- data/spec/lib/open_ehr/rm/data_types/uri/dv_uri_spec.rb +36 -0
- data/spec/lib/open_ehr/rm/demographic/actor_spec.rb +79 -0
- data/spec/lib/open_ehr/rm/demographic/address_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/demographic/capability_spec.rb +37 -0
- data/spec/lib/open_ehr/rm/demographic/contact_spec.rb +45 -0
- data/spec/lib/open_ehr/rm/demographic/party_identity_spec.rb +32 -0
- data/spec/lib/open_ehr/rm/demographic/party_relationship_spec.rb +84 -0
- data/spec/lib/open_ehr/rm/demographic/party_spec.rb +133 -0
- data/spec/lib/open_ehr/rm/demographic/role_spec.rb +58 -0
- data/spec/lib/open_ehr/rm/ehr/ehr_access_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/ehr/ehr_spec.rb +139 -0
- data/spec/lib/open_ehr/rm/ehr/ehr_status_spec.rb +52 -0
- data/spec/lib/open_ehr/rm/ehr/versioned_composition_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/integration/generic_entry_spec.rb +31 -0
- data/spec/lib/open_ehr/rm/support/identification/access_group_ref_spec.rb +19 -0
- data/spec/lib/open_ehr/rm/support/identification/archetype_id_spec.rb +152 -0
- data/spec/lib/open_ehr/rm/support/identification/generic_id_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/support/identification/hier_object_id_spec.rb +12 -0
- data/spec/lib/open_ehr/rm/support/identification/internet_id_spec.rb +12 -0
- data/spec/lib/open_ehr/rm/support/identification/iso_oid_spec.rb +12 -0
- data/spec/lib/open_ehr/rm/support/identification/locatable_ref_spec.rb +34 -0
- data/spec/lib/open_ehr/rm/support/identification/object_id_spec.rb +24 -0
- data/spec/lib/open_ehr/rm/support/identification/object_ref_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/support/identification/object_version_id_spec.rb +60 -0
- data/spec/lib/open_ehr/rm/support/identification/party_ref_spec.rb +29 -0
- data/spec/lib/open_ehr/rm/support/identification/template_id_spec.rb +12 -0
- data/spec/lib/open_ehr/rm/support/identification/terminology_id_spec.rb +33 -0
- data/spec/lib/open_ehr/rm/support/identification/uid_based_id_spec.rb +50 -0
- data/spec/lib/open_ehr/rm/support/identification/uid_spec.rb +29 -0
- data/spec/lib/open_ehr/rm/support/identification/version_tree_id_spec.rb +104 -0
- data/spec/lib/open_ehr/rm/support/measurement_service_spec.rb +7 -0
- data/spec/lib/open_ehr/rm/support/terminology_service_spec.rb +24 -0
- data/spec/lib/open_ehr/serializer/adl-test-entry.most_minimal.test.adl +20 -0
- data/spec/lib/open_ehr/serializer/adl_serializer_spec.rb +47 -0
- data/spec/lib/open_ehr/serializer/openEHR-EHR-SECTION.test.v1.adl +38 -0
- data/spec/lib/open_ehr/serializer/openEHR-EHR-SECTION.test.v1.xml +58 -0
- data/spec/lib/open_ehr/serializer/sample_archetype_spec.rb +44 -0
- data/spec/lib/open_ehr/serializer/xml_serializer_spec.rb +49 -0
- data/spec/lib/open_ehr/terminology/open_ehr_terminology_spec.rb +40 -0
- data/spec/rcov.opts +1 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +54 -0
- metadata +401 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# charactor sets extraction from download file from
|
3
|
+
# http://www.iana.org/assignments/character-sets
|
4
|
+
# as character-sets
|
5
|
+
|
6
|
+
class CharacterSets
|
7
|
+
def self.get_list
|
8
|
+
list = Array.new
|
9
|
+
open('character-sets') do |file|
|
10
|
+
while line = file.gets
|
11
|
+
if /^((Name:)|(Alias:)) (\S+)/ =~ line
|
12
|
+
list << $4 unless $4 == "None"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
return list
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
open('charset.lst','w') do |f|
|
21
|
+
CharacterSets.get_list.each do |line|
|
22
|
+
f.puts(line)
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# OpenEHR::RM::Data_Types::Encapsulated
|
2
|
+
# http://www.openehr.org/svn/specification/TAGS/Release-1.0.2/publishing/architecture/computable/UML/uml_start_view.html
|
3
|
+
# refs #51
|
4
|
+
require 'rubygems'
|
5
|
+
require 'locale/info'
|
6
|
+
|
7
|
+
module OpenEHR
|
8
|
+
module RM
|
9
|
+
module DataTypes
|
10
|
+
module Encapsulated
|
11
|
+
class DvEncapsulated < OpenEHR::RM::DataTypes::Basic::DataValue
|
12
|
+
attr_reader :language, :charset
|
13
|
+
|
14
|
+
def initialize(args = {})
|
15
|
+
super(args)
|
16
|
+
self.charset = args[:charset]
|
17
|
+
self.language = args[:language]
|
18
|
+
end
|
19
|
+
|
20
|
+
def size
|
21
|
+
@value.size
|
22
|
+
end
|
23
|
+
|
24
|
+
def language=(language)
|
25
|
+
if !language.nil? &&
|
26
|
+
!Locale::Info.language_code?(language.code_string)
|
27
|
+
raise ArgumentError, 'invalid language code'
|
28
|
+
end
|
29
|
+
@language = language
|
30
|
+
end
|
31
|
+
|
32
|
+
def charset=(charset)
|
33
|
+
if !charset.nil? && !charset_valid?(charset.code_string)
|
34
|
+
raise ArgumentError, 'invalid charset'
|
35
|
+
end
|
36
|
+
@charset = charset
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def charset_valid?(charset)
|
42
|
+
result = false
|
43
|
+
open('lib/open_ehr/rm/data_types/charset.lst') do |file|
|
44
|
+
while line = file.gets
|
45
|
+
if charset == line.chomp
|
46
|
+
result = true
|
47
|
+
break
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
return result
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# media type http://www.iana.org/assignments/media-types/text/
|
56
|
+
class DvMultimedia < DvEncapsulated
|
57
|
+
attr_reader :media_type
|
58
|
+
attr_accessor :uri, :data, :compression_algorithm,
|
59
|
+
:integrity_check, :integrity_check_algorithm, :alternate_text
|
60
|
+
|
61
|
+
def initialize(args = {})
|
62
|
+
super(args)
|
63
|
+
self.media_type = args[:media_type]
|
64
|
+
self.uri = args[:uri]
|
65
|
+
self.data = args[:data]
|
66
|
+
self.compression_algorithm = args[:compression_algorithm]
|
67
|
+
self.integrity_check = args[:integrity_check]
|
68
|
+
self.integrity_check_algorithm = args[:integrity_check_algorithm]
|
69
|
+
self.alternate_text = args[:alternate_text]
|
70
|
+
end
|
71
|
+
|
72
|
+
def media_type=(media_type)
|
73
|
+
if media_type.code_string.nil?
|
74
|
+
raise ArgumentError, 'media_type should not be nil'
|
75
|
+
end
|
76
|
+
@media_type = media_type
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
class DvParsable < DvEncapsulated
|
81
|
+
attr_reader :formalism
|
82
|
+
|
83
|
+
def initialize(args = {})
|
84
|
+
super(args)
|
85
|
+
self.formalism = args[:formalism]
|
86
|
+
end
|
87
|
+
|
88
|
+
def formalism=(formalism)
|
89
|
+
if formalism.nil? || formalism.empty?
|
90
|
+
raise ArgumentError, 'formalism is mandatory'
|
91
|
+
end
|
92
|
+
@formalism = formalism
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end # of Encapsulated
|
96
|
+
end # of DataTypes
|
97
|
+
end # of RM
|
98
|
+
end # of OpenEHR
|
@@ -0,0 +1,229 @@
|
|
1
|
+
# This module is implementation of the UML:
|
2
|
+
# http://www.openehr.org/uml/release-1.0.1/Browsable/_9_0_76d0249_1109696321450_28117_5362Report.html
|
3
|
+
# Ticket refs #49
|
4
|
+
#require 'assumed_library_types'
|
5
|
+
require 'date'
|
6
|
+
include OpenEHR::RM::DataTypes::Quantity
|
7
|
+
include OpenEHR::AssumedLibraryTypes
|
8
|
+
|
9
|
+
module OpenEHR
|
10
|
+
module RM
|
11
|
+
module DataTypes
|
12
|
+
module Quantity
|
13
|
+
module DateTime
|
14
|
+
class DvTemporal < DvAbsoluteQuantity
|
15
|
+
def initialize(args = {})
|
16
|
+
self.value = args[:value]
|
17
|
+
self.magnitude_status = args[:magnitude_status]
|
18
|
+
self.accuracy = args[:accuracy]
|
19
|
+
self.normal_range = args[:normal_range]
|
20
|
+
self.normal_status = args[:normal_status]
|
21
|
+
self.other_reference_ranges = args[:other_reference_ranges]
|
22
|
+
end
|
23
|
+
|
24
|
+
def value=(value)
|
25
|
+
if value.nil? or value.empty?
|
26
|
+
raise ArgumentError, 'invalid value'
|
27
|
+
end
|
28
|
+
@value = value
|
29
|
+
end
|
30
|
+
|
31
|
+
undef magnitude=
|
32
|
+
end
|
33
|
+
|
34
|
+
class DvDate < DvTemporal
|
35
|
+
include ISO8601DateModule
|
36
|
+
|
37
|
+
DAYS_IN_MONTH = [0,31,28,31,30,31,30,31,31,30,31,30,31]
|
38
|
+
|
39
|
+
def value=(value)
|
40
|
+
super(value)
|
41
|
+
iso8601_date = ISO8601Date.new(value)
|
42
|
+
@year = iso8601_date.year
|
43
|
+
@month = iso8601_date.month
|
44
|
+
@day = iso8601_date.day
|
45
|
+
end
|
46
|
+
|
47
|
+
def magnitude
|
48
|
+
return Date.new(@year, @month, @day)-Date.new(0000,1,1)
|
49
|
+
end
|
50
|
+
|
51
|
+
def diff(other)
|
52
|
+
if self.magnitude > other.magnitude
|
53
|
+
past, future = other, self
|
54
|
+
else
|
55
|
+
past, future = self, other
|
56
|
+
end
|
57
|
+
year, month, day = 0, 0, 0
|
58
|
+
if (future.day >= past.day)
|
59
|
+
day = future.day - past.day
|
60
|
+
else
|
61
|
+
month = -1
|
62
|
+
previous_month = future.month - 1
|
63
|
+
if previous_month == 0
|
64
|
+
previous_month = 12
|
65
|
+
end
|
66
|
+
day = DAYS_IN_MONTH[previous_month] + future.day - past.day
|
67
|
+
if leapyear?(future.year) && (previous_month == 2)
|
68
|
+
day += 1
|
69
|
+
end
|
70
|
+
end
|
71
|
+
week = day / 7
|
72
|
+
if (future.month >= past.month)
|
73
|
+
month += future.month - past.month
|
74
|
+
else
|
75
|
+
year -= 1
|
76
|
+
month += future.month + 12 - past.month
|
77
|
+
end
|
78
|
+
if month < 0
|
79
|
+
year -= 1
|
80
|
+
month += 12
|
81
|
+
end
|
82
|
+
year += future.year - past.year
|
83
|
+
return DvDuration.new(:value =>
|
84
|
+
'P' + year.to_s + 'Y' + month.to_s + 'M' +
|
85
|
+
week.to_s + 'W' + day.to_s + 'D')
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
class DvTime < DvTemporal
|
90
|
+
include ISO8601TimeModule
|
91
|
+
|
92
|
+
def value=(value)
|
93
|
+
super(value)
|
94
|
+
iso8601_time = ISO8601Time.new(value)
|
95
|
+
@hour = iso8601_time.hour
|
96
|
+
@minute = iso8601_time.minute
|
97
|
+
@second = iso8601_time.second
|
98
|
+
@fractional_second = iso8601_time.fractional_second
|
99
|
+
end
|
100
|
+
|
101
|
+
def magnitude
|
102
|
+
if @fractional_second.nil?
|
103
|
+
return @hour * 60 * 60 + @minute * 60 + @second
|
104
|
+
else
|
105
|
+
return @hour * 60 * 60 + @minute * 60 + @second + @fractional_second
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def diff(other)
|
110
|
+
diff = (other.magnitude - self.magnitude).abs
|
111
|
+
hour = (diff / 60 / 60).to_i
|
112
|
+
minute = ((diff - hour*60*60)/60).to_i
|
113
|
+
second = (diff - hour * 60 *60 - minute * 60).to_i
|
114
|
+
fractional_second = ((diff - diff.to_i)*1000000.0).to_i/1000000.0
|
115
|
+
str = 'P0Y0M0W0DT' + hour.to_s + 'H' +
|
116
|
+
minute.to_s + 'M' + second.to_s
|
117
|
+
if @fractional_second.nil?
|
118
|
+
str += 'S'
|
119
|
+
else
|
120
|
+
str += fractional_second.to_s[1..-1] + 'S'
|
121
|
+
end
|
122
|
+
return DvDuration.new(:value => str)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
class DvDateTime < DvTemporal
|
127
|
+
include OpenEHR::AssumedLibraryTypes::ISO8601DateTimeModule
|
128
|
+
|
129
|
+
def value=(value)
|
130
|
+
super(value)
|
131
|
+
iso8601date_time = AssumedLibraryTypes::ISO8601DateTime.new(value)
|
132
|
+
self.year = iso8601date_time.year
|
133
|
+
self.month = iso8601date_time.month
|
134
|
+
self.day = iso8601date_time.day
|
135
|
+
self.minute = iso8601date_time.minute
|
136
|
+
self.second = iso8601date_time.second
|
137
|
+
self.hour = iso8601date_time.hour
|
138
|
+
self.fractional_second = iso8601date_time.fractional_second
|
139
|
+
self.timezone = iso8601date_time.timezone
|
140
|
+
end
|
141
|
+
|
142
|
+
def magnitude
|
143
|
+
seconds = (((@year * 365.24 +
|
144
|
+
@month * 30.42 +
|
145
|
+
@day) * 24 + @hour) * 60 +
|
146
|
+
@minute) * 60 + @second
|
147
|
+
if @fractional_second.nil?
|
148
|
+
return seconds
|
149
|
+
else
|
150
|
+
return seconds + @fractional_second
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def diff(other)
|
155
|
+
if self.magnitude >= other.magnitude
|
156
|
+
past, future = other, self
|
157
|
+
else
|
158
|
+
past, future = self, other
|
159
|
+
end
|
160
|
+
past_date, past_time = split_date_time(past)
|
161
|
+
future_date, future_time = split_date_time(future)
|
162
|
+
time_diff = future_time.magnitude - past_time.magnitude
|
163
|
+
if future_time.magnitude < past_time.magnitude
|
164
|
+
future_date.day = future_date.day - 1
|
165
|
+
time_diff += 24 * 60 * 60
|
166
|
+
end
|
167
|
+
date_duration = past_date.diff(future_date)
|
168
|
+
hour = (time_diff / 60 / 60).to_i
|
169
|
+
minute = ((time_diff - hour*60*60)/60).to_i
|
170
|
+
second = (time_diff - hour * 60 *60 - minute * 60).to_i
|
171
|
+
str = date_duration.value + 'T' + hour.to_s + 'H' +
|
172
|
+
minute.to_s + 'M' + second.to_s
|
173
|
+
if @fractional_second.nil?
|
174
|
+
return DvDuration.new(:value => str +'S')
|
175
|
+
else
|
176
|
+
fractional_second =
|
177
|
+
((time_diff - time_diff.to_i)*1000000.0).to_i/1000000.0
|
178
|
+
return DvDuration.new(:value => str +
|
179
|
+
fractional_second.to_s[1..-1] + 'S')
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
private
|
184
|
+
def split_date_time(date_time)
|
185
|
+
/^(.*)T(.*)$/ =~ date_time.as_string
|
186
|
+
return DvDate.new(:value => $1), DvTime.new(:value => $2)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
class DvDuration < DvAmount
|
191
|
+
include AssumedLibraryTypes::ISO8601DurationModule
|
192
|
+
attr_reader :value
|
193
|
+
|
194
|
+
def initialize(args = { })
|
195
|
+
self.value = args[:value]
|
196
|
+
self.magnitude_status = args[:magnitude_status]
|
197
|
+
self.normal_range = args[:normal_range]
|
198
|
+
self.normal_status = args[:normal_status]
|
199
|
+
self.other_reference_ranges = args[:other_reference_ranges]
|
200
|
+
end
|
201
|
+
|
202
|
+
def value=(value)
|
203
|
+
raise ArgumentError, 'value must be not nil' if value.nil?
|
204
|
+
@value = value
|
205
|
+
iso8601_duration = AssumedLibraryTypes::ISO8601Duration.new(value)
|
206
|
+
self.years = iso8601_duration.years
|
207
|
+
self.months = iso8601_duration.months
|
208
|
+
self.weeks = iso8601_duration.weeks
|
209
|
+
self.days = iso8601_duration.days
|
210
|
+
self.hours = iso8601_duration.hours
|
211
|
+
self.minutes = iso8601_duration.minutes
|
212
|
+
self.seconds = iso8601_duration.seconds
|
213
|
+
self.fractional_second = iso8601_duration.fractional_second
|
214
|
+
end
|
215
|
+
|
216
|
+
def magnitude
|
217
|
+
return ((((@year + @month/MONTH_IN_YEAR)*NOMINAL_DAYS_IN_MONTH) +
|
218
|
+
@week * DAYS_IN_WEEK + @days) * HOURS_IN_DAY * MINUTES_IN_HOUR*
|
219
|
+
SECONDS_IN_MINUTE) + @second + @fractional_second
|
220
|
+
end
|
221
|
+
|
222
|
+
undef magnitude=
|
223
|
+
|
224
|
+
end
|
225
|
+
end # of DateTime
|
226
|
+
end # of Quantity
|
227
|
+
end # of Data_Types
|
228
|
+
end # of RM
|
229
|
+
end # of OpenEHR
|