Class: OpenehrRails::Rm::DataValue
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- OpenehrRails::Rm::DataValue
show all
- Defined in:
- lib/openehr_rails/rm/data_value.rb
Overview
STI base for stored DATA_VALUE leaves (DV_*). Each subclass maps its
openEHR attributes onto the shared typed columns and implements
#value (polymorphic reader) and #to_canonical_hash (must emit the
exact shape Storable#rm_value writes into the JSON cache).
Direct Known Subclasses
DvBoolean, DvCount, DvDate, DvDateTime, DvDuration, DvIdentifier, DvMultimedia, DvOrdinal, DvParsable, DvProportion, DvQuantity, DvText, DvTime, DvUri
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.find_sti_class(type_name) ⇒ Object
29
30
31
|
# File 'lib/openehr_rails/rm/data_value.rb', line 29
def find_sti_class(type_name)
TypeMap.data_value_class_for(type_name)
end
|
.matching(value) ⇒ Object
Type-aware value matching across the typed columns; used by the
AQL path fallback where the caller does not know the DV type.
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/openehr_rails/rm/data_value.rb', line 39
def matching(value)
case value
when Numeric
where(magnitude: value.to_f)
.or(where(integer_value: value.to_i))
.or(where(numerator: value.to_f))
when true, false
where(boolean_value: value)
when Date, Time, DateTime
where(datetime_value: value)
.or(where(date_value: value))
else
text = value.to_s
where(text_value: text)
.or(where(code_string: text))
.or(where(uri_value: text))
.or(where(duration_value: text))
.or(where(identifier_id: text))
end
end
|
.sti_class_for(type_name) ⇒ Object
.sti_name ⇒ Object
25
26
27
|
# File 'lib/openehr_rails/rm/data_value.rb', line 25
def sti_name
TypeMap.rm_type_for(self) || super
end
|
Instance Method Details
#to_canonical_hash ⇒ Object
65
66
67
|
# File 'lib/openehr_rails/rm/data_value.rb', line 65
def to_canonical_hash
raise NotImplementedError, "#{self.class.name} must implement #to_canonical_hash"
end
|
#value ⇒ Object
61
62
63
|
# File 'lib/openehr_rails/rm/data_value.rb', line 61
def value
raise NotImplementedError, "#{self.class.name} must implement #value"
end
|