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