Class: ODDB::Drugs::Composition

Inherits:
Model
  • Object
show all
Defined in:
lib/oddb/export/yaml.rb,
lib/oddb/drugs/composition.rb,
lib/oddb/persistence/og/drugs/composition.rb

Constant Summary

Constants included from OddbUri

OddbUri::YAML_URI

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#__odba_delete__, #__odba_save__, _serializables, belongs_to, connections, connector, connectors, #data_origin, #data_origins, delegates, #delete, find_by_uid, has_many, is_coded, m10l_document, multilingual, #odba_serializables, #oid, on_delete, on_save, predicates, #save, #saved?, serializables, serialize, singular

Methods included from ODBA::Persistable

#to_yaml_properties

Methods included from Yaml

append_features, #to_yaml_properties

Methods included from OddbUri

#to_yaml, #to_yaml_map, #to_yaml_type

Instance Attribute Details

#equivalence_factorObject

Returns the value of attribute equivalence_factor.



10
11
12
# File 'lib/oddb/drugs/composition.rb', line 10

def equivalence_factor
  @equivalence_factor
end

#galenic_formObject

Returns the value of attribute galenic_form.



10
11
12
# File 'lib/oddb/drugs/composition.rb', line 10

def galenic_form
  @galenic_form
end

Instance Method Details

#==(other) ⇒ Object



34
35
36
37
38
# File 'lib/oddb/drugs/composition.rb', line 34

def ==(other)
  other.is_a?(Composition) \
    && @galenic_form == other.galenic_form \
    && active_agents.sort == other.active_agents.sort
end

#active_agent(substance) ⇒ Object



14
15
16
# File 'lib/oddb/drugs/composition.rb', line 14

def active_agent(substance)
  active_agents.find { |agent| agent.substance == substance }
end

#dosesObject



17
18
19
# File 'lib/oddb/drugs/composition.rb', line 17

def doses
  active_agents.collect { |agent| agent.dose }
end

#include?(substance, dose, unit = nil) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
23
24
25
26
27
# File 'lib/oddb/drugs/composition.rb', line 20

def include?(substance, dose, unit=nil)
  unless(dose.is_a?(Drugs::Dose))
    dose = Drugs::Dose.new(dose, unit)
  end
  active_agents.any? { |act|
    act.substance == substance && act.dose == dose
  }
end

#substancesObject



28
29
30
# File 'lib/oddb/drugs/composition.rb', line 28

def substances
  active_agents.collect { |agent| agent.substance }
end

#to_s(language = :de) ⇒ Object



31
32
33
# File 'lib/oddb/drugs/composition.rb', line 31

def to_s(language=:de)
  active_agents.collect { |agent| agent.to_s(language) }.join(', ')
end